代码优化

This commit is contained in:
xy
2025-01-06 18:09:29 +08:00
parent da3b99f663
commit 98b901e6ab

View File

@@ -91,6 +91,12 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
json = JsonUtil.convertStreamToString(file.getInputStream());
Gson gson = new Gson();
TemplateDto templateDto = gson.fromJson(json, TemplateDto.class);
//判断设备型号
String devType = templateDto.getDevType();
DictTreeVO dictTreeVO = dictTreeFeignClient.queryByCode(devType).getData();
if (Objects.isNull(dictTreeVO)){
throw new BusinessException(AccessResponseEnum.DEV_TYPE_NOT_FIND);
}
logDto.setOperate("新增设备模板,模板名称:" + templateDto.getDevType());
//模板文件存入文件服务器
String filePath = fileStorageUtil.uploadMultipart(file, OssPath.DEV_MODEL + templateDto.getDevType() + "_");
@@ -838,9 +844,6 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
List<DataSetDto> dataSetList = templateDto.getDataSet();
String devType = templateDto.getDevType();
DictTreeVO dictTreeVO = dictTreeFeignClient.queryByCode(devType).getData();
if (Objects.isNull(dictTreeVO)){
throw new BusinessException(AccessResponseEnum.DEV_TYPE_NOT_FIND);
}
String code = dictTreeFeignClient.queryById(dictTreeVO.getPid()).getData().getCode();
//逻辑设备录入
if (CollectionUtil.isNotEmpty(dataSetList)){