Merge branch 'develop-business-css' of http://121.37.111.42:3000/ThbTech/JavaProjectRepo into develop-business-css
This commit is contained in:
commit
088347289a
@ -0,0 +1,12 @@
|
||||
package com.yfd.business.css.common.exception;
|
||||
|
||||
public class BizException extends RuntimeException {
|
||||
|
||||
public BizException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public BizException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@ -34,3 +34,27 @@ public class MybatisConfig {
|
||||
}
|
||||
}
|
||||
|
||||
// @Configuration
|
||||
// public class MybatisConfig {
|
||||
|
||||
// @Bean
|
||||
// public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
// return new MybatisPlusInterceptor();
|
||||
// }
|
||||
|
||||
// @Bean
|
||||
// public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
|
||||
// MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean();
|
||||
// factoryBean.setDataSource(dataSource);
|
||||
// factoryBean.setMapperLocations(
|
||||
// new PathMatchingResourcePatternResolver()
|
||||
// .getResources("classpath*:/mapper/**/*.xml"));
|
||||
// return factoryBean.getObject();
|
||||
// }
|
||||
|
||||
// @Bean
|
||||
// public SqlSessionTemplate sqlSessionTemplate(SqlSessionFactory sqlSessionFactory) {
|
||||
// return new SqlSessionTemplate(sqlSessionFactory);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
@ -77,7 +77,7 @@ public class AlgorithmModelController {
|
||||
@DeleteMapping
|
||||
@Operation(summary = "删除模型版本(批量)", description = "请求体传入模型ID列表,批量删除模型版本")
|
||||
public boolean deleteBatch(@RequestBody List<String> ids) {
|
||||
return algorithmModelService.removeByIds(ids);
|
||||
return algorithmModelService.deleteBatchWithCheck(ids);
|
||||
}
|
||||
|
||||
//返回:该算法+设备类型的版本列表
|
||||
|
||||
@ -3,6 +3,8 @@ package com.yfd.business.css.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yfd.business.css.domain.AlgorithmModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AlgorithmModelService extends IService<AlgorithmModel> {
|
||||
|
||||
/**
|
||||
@ -13,5 +15,7 @@ public interface AlgorithmModelService extends IService<AlgorithmModel> {
|
||||
* @return 激活版本的模型文件路径,如果不存在则返回null
|
||||
*/
|
||||
String getCurrentModelPath(String algorithmType, String deviceType) ;
|
||||
|
||||
boolean deleteBatchWithCheck(List<String> ids);
|
||||
|
||||
}
|
||||
|
||||
@ -8,4 +8,6 @@ public interface DeviceService extends IService<Device> {
|
||||
* 导入设备
|
||||
*/
|
||||
boolean importDevices(MultipartFile file, String deviceType);
|
||||
|
||||
public boolean createDevice(Device device) ;
|
||||
}
|
||||
|
||||
@ -5,8 +5,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.yfd.business.css.domain.AlgorithmModel;
|
||||
import com.yfd.business.css.mapper.AlgorithmModelMapper;
|
||||
import com.yfd.business.css.service.AlgorithmModelService;
|
||||
import com.yfd.business.css.common.exception.BizException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class AlgorithmModelServiceImpl extends ServiceImpl<AlgorithmModelMapper, AlgorithmModel> implements AlgorithmModelService {
|
||||
|
||||
@ -19,4 +23,32 @@ public class AlgorithmModelServiceImpl extends ServiceImpl<AlgorithmModelMapper,
|
||||
AlgorithmModel model = getOne(queryWrapper);
|
||||
return model != null ? model.getModelPath() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean deleteBatchWithCheck(List<String> ids) {
|
||||
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 1. 查询是否存在当前激活版本
|
||||
List<AlgorithmModel> currentModels = this.list(
|
||||
new QueryWrapper<AlgorithmModel>()
|
||||
.in("id", ids)
|
||||
.eq("is_current", 1)
|
||||
.select("id", "model_name")
|
||||
);
|
||||
// 2. 若存在激活版本,拒绝删除
|
||||
if (!currentModels.isEmpty()) {
|
||||
String names = currentModels.stream()
|
||||
.map(m -> m.getAlgorithmType() + "-" + m.getDeviceType())
|
||||
.collect(Collectors.joining(", "));
|
||||
throw new BizException("以下模型为当前激活版本,不允许删除:" + names);
|
||||
}
|
||||
|
||||
|
||||
// 3. 执行批量删除
|
||||
return this.removeByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,10 @@ import com.yfd.business.css.domain.Device;
|
||||
import com.yfd.business.css.mapper.DeviceMapper;
|
||||
import com.yfd.business.css.service.DeviceService;
|
||||
import com.yfd.platform.system.service.IUserService;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
@ -52,6 +56,18 @@ public class DeviceServiceImpl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createDevice(Device device) {
|
||||
|
||||
// 1. 如果前端没有传 deviceId,显式生成
|
||||
if (StrUtil.isBlank(device.getDeviceId())) {
|
||||
device.setDeviceId(IdUtil.fastUUID());
|
||||
}
|
||||
|
||||
// 2. 如果前端传了 deviceId,直接使用
|
||||
return this.save(device);
|
||||
}
|
||||
|
||||
private boolean importExcel(Workbook workbook, String deviceType) {
|
||||
try (Workbook wb = workbook) {
|
||||
Sheet sheet = wb.getSheetAt(0);
|
||||
|
||||
@ -1282,7 +1282,7 @@ public class ProjectServiceImpl
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
//6. 调用模型进行推理
|
||||
//6. 调用模型进行推理,把结果写入推理结果表
|
||||
deviceInferService.processDeviceInference(projectId, scenarioId, groupedDevices);
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user