整理代码

This commit is contained in:
caozehui
2025-03-26 10:01:56 +08:00
parent 4ef5c982de
commit 9a7d841d9c
29 changed files with 174 additions and 513 deletions

View File

@@ -1,37 +0,0 @@
package com.njcn.gather.device.pojo.enums;
import lombok.Getter;
@Getter
public enum DevResponseEnum {
//NAME_REPEAT("A001001", "名称重复"),
IMPORT_DATA_FAIL("A001002", "导入数据失败"),
SERIES_AND_DEVKEY_NOT_BLANK("A001003", "当为加密设备时,加密设备的序列号和设备密钥不能为空"),
PQ_SOURCE_GEN_NAME_ERROR("A001004", "检测源生成名称出错"),
ERR_SOURCE_GEN_NAME_ERROR("A001005", "误差体系生成名称出错"),
PQ_ERRSYS_GEN_NAME_ERROR("A001005", "误差体系生成名称出错"),
PLAN_HAS_DEVICE_BIND("A001006", "检测计划下已绑定设备,请先解绑设备"),
PQ_DEV_REPEAT("A001007", "重复的被检设备"),
PQ_DEV_HAS_MONITOR("A001008", "该设备下关联有监测点,请先移除监测点"),
HAS_NOT_UNCHECKED_DEVICE("A001009", "设备在检测中或已被检测过,请勿解除绑定"),
IMPORT_PLAN_DATA_FAIL("A001010", "导入的检测计划为空"),
IMPORT_DATA_FORMAT_FAIL("A001011", "导入数据格式错误"),
IMPORT_SOURCE_ERROR("A001012","当前模式下一个检测计划只能有一个检测源" ),
IMPORT_DATASOURCE_ERROR("A001013","当前模式下一个检测计划只能有一个数据源" ),
DEV_UN_CHECKED("A001013","装置还未检测完成!" ),
DEV_UN_REPORT("A001013","装置报告未生成!" ),
DEVICE_DIS_ERROR("A001014","装置配置异常" ),
DEVICE_DELETE("A001015","设备无法删除,已绑定计划!" )
;
private final String message;
private final String code;
DevResponseEnum(String code, String message) {
this.code = code;
this.message = message;
}
}

View File

@@ -31,6 +31,7 @@ import com.njcn.gather.device.pojo.vo.ProvinceDevExcel;
import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.monitor.pojo.po.PqMonitor;
import com.njcn.gather.monitor.service.IPqMonitorService;
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
import com.njcn.gather.storage.service.DetectionDataDealService;
import com.njcn.gather.system.cfg.pojo.enums.SceneEnum;
import com.njcn.gather.system.cfg.pojo.po.SysTestConfig;
@@ -113,7 +114,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
pqDev.setDevKey(EncryptionUtil.encodeString(1, pqDev.getDevKey()));
} else {
throw new BusinessException(DevResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
throw new BusinessException(DetectionResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
}
}
if ("1".equals(sysTestConfigService.getCurrrentScene())) {
@@ -150,7 +151,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
pqDev.setDevKey(EncryptionUtil.encodeString(1, pqDev.getDevKey()));
} else {
throw new BusinessException(DevResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
throw new BusinessException(DetectionResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
}
}
// 比对式设备修改监测点
@@ -168,7 +169,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
if (PatternEnum.CONTRAST.getValue().equals(dictDataService.getDictDataById(param.getPattern()).getCode())) {
for (String id : param.getIds()) {
if (ObjectUtils.isEmpty(pqMonitorService.listPqMonitorByDevId(id))) {
throw new BusinessException(DevResponseEnum.PQ_DEV_HAS_MONITOR);
throw new BusinessException(DetectionResponseEnum.PQ_DEV_HAS_MONITOR);
}
}
}
@@ -200,7 +201,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
str = null;
}
if (ObjectUtil.isNotNull(str)) {
throw new BusinessException(DevResponseEnum.DEVICE_DELETE, str.toString());
throw new BusinessException(DetectionResponseEnum.DEVICE_DELETE, str.toString());
}
return this.lambdaUpdate().set(PqDev::getState, DataStateEnum.DELETED.getCode()).in(PqDev::getId, param.getIds()).update();
}
@@ -433,7 +434,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
public List<PreDetection> getDevInfo(List<String> devIds) {
List<PreDetection> preDetections = this.baseMapper.selectDevInfo(devIds);
if (devIds.size() != preDetections.size()) {
throw new BusinessException(DevResponseEnum.DEVICE_DIS_ERROR);
throw new BusinessException(DetectionResponseEnum.DEVICE_DIS_ERROR);
}
for (PreDetection preDetection : preDetections) {
@@ -463,10 +464,10 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
PqDev pqDev = this.getById(id);
if (ObjectUtil.isNotNull(pqDev)) {
if (!pqDev.getCheckState().equals(CheckStateEnum.CHECKED.getValue())) {
throw new BusinessException(DevResponseEnum.DEV_UN_CHECKED);
throw new BusinessException(DetectionResponseEnum.DEV_UN_CHECKED);
}
if (!pqDev.getReportState().equals(DevReportStateEnum.GENERATED.getValue())) {
throw new BusinessException(DevResponseEnum.DEV_UN_REPORT);
throw new BusinessException(DetectionResponseEnum.DEV_UN_REPORT);
}
boolean update = this.lambdaUpdate()
.set(PqDev::getCheckState, CheckStateEnum.DOCUMENTED.getValue())
@@ -486,7 +487,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
}
}
} else {
throw new BusinessException(DevResponseEnum.DEV_UN_CHECKED);
throw new BusinessException(DetectionResponseEnum.DEV_UN_CHECKED);
}
}
}
@@ -664,7 +665,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
cnDevExcelList = excelImportResult.getList();
}
} catch (Exception e) {
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
throw new BusinessException(DetectionResponseEnum.IMPORT_DATA_FAIL);
}
this.importCNDev(cnDevExcelList, patternId, planId);
}
@@ -687,7 +688,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
pqDev.setDevKey(EncryptionUtil.encodeString(1, pqDev.getDevKey()));
} else {
throw new BusinessException(DevResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
throw new BusinessException(DetectionResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
}
}
@@ -722,7 +723,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
}
}
} else {
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FORMAT_FAIL);
throw new BusinessException(DetectionResponseEnum.IMPORT_DATA_FORMAT_FAIL);
}
} else {
param.setName(pqDev.getName());
@@ -765,7 +766,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
}
int count = this.count(queryWrapper);
if (count > 0) {
throw new BusinessException(DevResponseEnum.PQ_DEV_REPEAT);
throw new BusinessException(DetectionResponseEnum.PQ_DEV_REPEAT);
}
}
@@ -986,7 +987,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
cnDevExcelList = excelImportResult.getList();
}
} catch (Exception e) {
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
throw new BusinessException(DetectionResponseEnum.IMPORT_DATA_FAIL);
}
this.importProvinceDev(cnDevExcelList, patternId, planId);
}
@@ -1009,7 +1010,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
pqDev.setDevKey(EncryptionUtil.encodeString(1, pqDev.getDevKey()));
} else {
throw new BusinessException(DevResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
throw new BusinessException(DetectionResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
}
}
@@ -1044,7 +1045,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
}
}
} else {
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FORMAT_FAIL);
throw new BusinessException(DetectionResponseEnum.IMPORT_DATA_FORMAT_FAIL);
}
} else {
param.setName(pqDev.getName());