Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0cd8e454fc | ||
|
|
95005d2462 | ||
|
|
16ace94f8d |
@@ -12,9 +12,11 @@ import com.njcn.gather.detection.lock.DetectionLockManager;
|
|||||||
import com.njcn.gather.detection.lock.DetectionLockManager.AcquireResult;
|
import com.njcn.gather.detection.lock.DetectionLockManager.AcquireResult;
|
||||||
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
|
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
|
||||||
import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
|
import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
|
||||||
|
import com.njcn.gather.detection.pojo.param.FormalProgressParam;
|
||||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||||
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
||||||
import com.njcn.gather.detection.pojo.vo.DetectionLockHolderVO;
|
import com.njcn.gather.detection.pojo.vo.DetectionLockHolderVO;
|
||||||
|
import com.njcn.gather.detection.pojo.vo.FormalProgressVO;
|
||||||
import com.njcn.gather.detection.service.PreDetectionService;
|
import com.njcn.gather.detection.service.PreDetectionService;
|
||||||
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
||||||
import com.njcn.gather.user.user.pojo.po.SysUser;
|
import com.njcn.gather.user.user.pojo.po.SysUser;
|
||||||
@@ -202,6 +204,36 @@ public class PreDetectionController extends BaseController {
|
|||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/saveFormalProgress")
|
||||||
|
@OperateInfo
|
||||||
|
@ApiOperation("保存正式检测暂存进度")
|
||||||
|
public HttpResult<?> saveFormalProgress(@RequestBody @Validated FormalProgressParam param) {
|
||||||
|
String methodDescribe = getMethodDescribe("saveFormalProgress");
|
||||||
|
HttpResult<DetectionLockHolderVO> busy = requireHolderSelf();
|
||||||
|
if (busy != null) {
|
||||||
|
return busy;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
preDetectionService.saveFormalProgress(param);
|
||||||
|
} finally {
|
||||||
|
releaseLockSelf("SAVE_FORMAL_PROGRESS");
|
||||||
|
}
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/formalProgress")
|
||||||
|
@OperateInfo
|
||||||
|
@ApiOperation("查询正式检测暂存进度并放行续检")
|
||||||
|
public HttpResult<?> formalProgress(@RequestBody @Validated FormalProgressParam param) {
|
||||||
|
String methodDescribe = getMethodDescribe("formalProgress");
|
||||||
|
HttpResult<DetectionLockHolderVO> busy = requireHolderSelf();
|
||||||
|
if (busy != null) {
|
||||||
|
return busy;
|
||||||
|
}
|
||||||
|
FormalProgressVO data = preDetectionService.formalProgress(param);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, data, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开始比对检测(包括预检测、正式检测)通用入口
|
* 开始比对检测(包括预检测、正式检测)通用入口
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import com.njcn.gather.monitor.service.IPqMonitorService;
|
|||||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||||
import com.njcn.gather.plan.service.IAdPlanService;
|
import com.njcn.gather.plan.service.IAdPlanService;
|
||||||
import com.njcn.gather.plan.service.IAdPlanTestConfigService;
|
import com.njcn.gather.plan.service.IAdPlanTestConfigService;
|
||||||
|
import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
|
||||||
import com.njcn.gather.storage.pojo.po.ContrastHarmonicResult;
|
import com.njcn.gather.storage.pojo.po.ContrastHarmonicResult;
|
||||||
import com.njcn.gather.storage.pojo.po.ContrastNonHarmonicResult;
|
import com.njcn.gather.storage.pojo.po.ContrastNonHarmonicResult;
|
||||||
import com.njcn.gather.storage.service.DetectionDataDealService;
|
import com.njcn.gather.storage.service.DetectionDataDealService;
|
||||||
@@ -132,17 +133,17 @@ public class SocketContrastResponseService {
|
|||||||
private final PathConfig pathConfig;
|
private final PathConfig pathConfig;
|
||||||
|
|
||||||
public static final Map<String, List<String>> testItemCodeMap = new HashMap() {{
|
public static final Map<String, List<String>> testItemCodeMap = new HashMap() {{
|
||||||
put("FREQ", Arrays.asList(DetectionCodeEnum.FREQ.getCode()));
|
put(PowerIndexEnum.FREQ.getKey(), Arrays.asList(DetectionCodeEnum.FREQ.getCode()));
|
||||||
put("V", Arrays.asList(DetectionCodeEnum.VRMS.getCode(), DetectionCodeEnum.PVRMS.getCode()));
|
put(PowerIndexEnum.V.getKey(), Arrays.asList(DetectionCodeEnum.VRMS.getCode(), DetectionCodeEnum.PVRMS.getCode()));
|
||||||
put("HV", Arrays.asList(DetectionCodeEnum.V2_50.getCode(), DetectionCodeEnum.PV2_50.getCode()));
|
put(PowerIndexEnum.HV.getKey(), Arrays.asList(DetectionCodeEnum.V2_50.getCode(), DetectionCodeEnum.PV2_50.getCode()));
|
||||||
put("HI", Arrays.asList(DetectionCodeEnum.I2_50.getCode()));
|
put(PowerIndexEnum.HI.getKey(), Arrays.asList(DetectionCodeEnum.I2_50.getCode()));
|
||||||
put("HP", Arrays.asList(DetectionCodeEnum.P2_50.getCode()));
|
put(PowerIndexEnum.HP.getKey(), Arrays.asList(DetectionCodeEnum.P2_50.getCode()));
|
||||||
put("HSV", Arrays.asList(DetectionCodeEnum.SV_1_49.getCode(), DetectionCodeEnum.PSV_1_49.getCode()));
|
put(PowerIndexEnum.HSV.getKey(), Arrays.asList(DetectionCodeEnum.SV_1_49.getCode(), DetectionCodeEnum.PSV_1_49.getCode()));
|
||||||
put("HSI", Arrays.asList(DetectionCodeEnum.SI_1_49.getCode()));
|
put(PowerIndexEnum.HSI.getKey(), Arrays.asList(DetectionCodeEnum.SI_1_49.getCode()));
|
||||||
put("I", Arrays.asList(DetectionCodeEnum.IRMS.getCode()));
|
put(PowerIndexEnum.I.getKey(), Arrays.asList(DetectionCodeEnum.IRMS.getCode()));
|
||||||
put("IMBV", Arrays.asList(DetectionCodeEnum.V_UNBAN.getCode()));
|
put(PowerIndexEnum.IMBV.getKey(), Arrays.asList(DetectionCodeEnum.V_UNBAN.getCode()));
|
||||||
put("IMBA", Arrays.asList(DetectionCodeEnum.I_UNBAN.getCode()));
|
put(PowerIndexEnum.IMBA.getKey(), Arrays.asList(DetectionCodeEnum.I_UNBAN.getCode()));
|
||||||
put("F", Arrays.asList(DetectionCodeEnum.PST.getCode()));
|
put(PowerIndexEnum.F.getKey(), Arrays.asList(DetectionCodeEnum.PST.getCode()));
|
||||||
}};
|
}};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -307,7 +308,7 @@ public class SocketContrastResponseService {
|
|||||||
FormalTestManager.numMap.clear();
|
FormalTestManager.numMap.clear();
|
||||||
FormalTestManager.numMap.putAll(numMap);
|
FormalTestManager.numMap.putAll(numMap);
|
||||||
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||||
if (param.getTestItemList().get(2)) {
|
if (param.isFormalTestSelected()) {
|
||||||
numMap.forEach((devMonitorId, num) -> {
|
numMap.forEach((devMonitorId, num) -> {
|
||||||
if (oneConfig.getMaxTime() < num) {
|
if (oneConfig.getMaxTime() < num) {
|
||||||
throw new BusinessException(DetectionResponseEnum.EXCEED_MAX_TIME);
|
throw new BusinessException(DetectionResponseEnum.EXCEED_MAX_TIME);
|
||||||
@@ -1154,7 +1155,7 @@ public class SocketContrastResponseService {
|
|||||||
|
|
||||||
private void sendFormalTest(String s, PreDetectionParam param, SourceOperateCodeEnum requestOperateCode, SourceOperateCodeEnum quitOperateCode) {
|
private void sendFormalTest(String s, PreDetectionParam param, SourceOperateCodeEnum requestOperateCode, SourceOperateCodeEnum quitOperateCode) {
|
||||||
// 后续做正式检测
|
// 后续做正式检测
|
||||||
if (param.getTestItemList().get(2)) {
|
if (param.isFormalTestSelected()) {
|
||||||
System.out.println("开始正式检测!");
|
System.out.println("开始正式检测!");
|
||||||
if (ObjectUtil.isNotNull(FormalTestManager.nonWaveDataSourceEnum)) {
|
if (ObjectUtil.isNotNull(FormalTestManager.nonWaveDataSourceEnum)) {
|
||||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import com.njcn.gather.device.service.IPqDevService;
|
|||||||
import com.njcn.gather.device.service.IPqDevSubService;
|
import com.njcn.gather.device.service.IPqDevSubService;
|
||||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||||
import com.njcn.gather.plan.service.IAdPlanService;
|
import com.njcn.gather.plan.service.IAdPlanService;
|
||||||
import com.njcn.gather.result.pojo.enums.ResultUnitEnum;
|
import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
|
||||||
import com.njcn.gather.result.service.IResultService;
|
import com.njcn.gather.result.service.IResultService;
|
||||||
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
||||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||||
@@ -45,7 +45,6 @@ import com.njcn.gather.storage.service.SimAndDigHarmonicService;
|
|||||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||||
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -69,7 +68,7 @@ public class SocketDevResponseService {
|
|||||||
|
|
||||||
private List<String> icdTypeList;
|
private List<String> icdTypeList;
|
||||||
|
|
||||||
private final List<String> nonHarmonicList = Stream.of(DicDataEnum.FREQ.getCode(), DicDataEnum.V.getCode(), DicDataEnum.I.getCode(), DicDataEnum.IMBV.getCode(), DicDataEnum.IMBA.getCode(), DicDataEnum.VOLTAGE.getCode(), DicDataEnum.F.getCode()).collect(Collectors.toList());
|
private final List<String> nonHarmonicList = Stream.of(PowerIndexEnum.FREQ.getKey(), PowerIndexEnum.V.getKey(), PowerIndexEnum.I.getKey(), PowerIndexEnum.IMBV.getKey(), PowerIndexEnum.IMBA.getKey(), PowerIndexEnum.VOLTAGE.getKey(), PowerIndexEnum.F.getKey()).collect(Collectors.toList());
|
||||||
|
|
||||||
private final IPqDevService iPqDevService;
|
private final IPqDevService iPqDevService;
|
||||||
private final IPqDevSubService iPqDevSubService;
|
private final IPqDevSubService iPqDevSubService;
|
||||||
@@ -398,72 +397,8 @@ public class SocketDevResponseService {
|
|||||||
sendWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.small_comp_end.getValue(), XiNumberManager.devParameterList.get(1));
|
sendWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.small_comp_end.getValue(), XiNumberManager.devParameterList.get(1));
|
||||||
System.out.println("-------------------------已经全部结束----------------------");
|
System.out.println("-------------------------已经全部结束----------------------");
|
||||||
|
|
||||||
if (param.getTestItemList().get(2)) {
|
if (param.isFormalTestSelected()) {
|
||||||
//如果后续做正式检测
|
startFormalScripts(param, null, param.isResumeFormal());
|
||||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
|
||||||
issueParam.setSourceId(param.getSourceName());
|
|
||||||
issueParam.setPlanId(param.getPlanId());
|
|
||||||
issueParam.setSourceId(param.getSourceId());
|
|
||||||
issueParam.setDevIds(param.getDevIds());
|
|
||||||
issueParam.setScriptId(param.getScriptId());
|
|
||||||
|
|
||||||
if (param.getReCheckType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())) {
|
|
||||||
//不合格项复检
|
|
||||||
Set<Integer> indexes = new HashSet<>();
|
|
||||||
StorageParam storageParam = new StorageParam();
|
|
||||||
storageParam.setCode(param.getCode());
|
|
||||||
storageParam.setScriptId(param.getScriptId());
|
|
||||||
param.getDevIds().forEach(devId -> {
|
|
||||||
storageParam.setDevId(devId);
|
|
||||||
indexes.addAll(adHarmonicService.getIndex(storageParam));
|
|
||||||
});
|
|
||||||
issueParam.setIndexList(indexes.stream().collect(Collectors.toList()));
|
|
||||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.RE_ERROR_TEST.getValue());
|
|
||||||
} else {
|
|
||||||
issueParam.setIsPhaseSequence(CommonEnum.FORMAL_TEST.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
|
||||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
|
||||||
List<SourceIssue> sourceIssues;
|
|
||||||
|
|
||||||
//正式检测
|
|
||||||
sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
|
||||||
sourceIssues = sourceIssues.stream().sorted(Comparator.comparing(SourceIssue::getIndex)).collect(Collectors.toList());
|
|
||||||
// 使用 LinkedHashMap 保持分组顺序
|
|
||||||
Map<String, List<SourceIssue>> groupedIssues = sourceIssues.stream()
|
|
||||||
.collect(Collectors.groupingBy(
|
|
||||||
SourceIssue::getType,
|
|
||||||
LinkedHashMap::new,
|
|
||||||
Collectors.toList()
|
|
||||||
));
|
|
||||||
|
|
||||||
// 将分组后的元素合并成一个新的集合,保持原有顺序
|
|
||||||
sourceIssues = groupedIssues.values().stream()
|
|
||||||
.flatMap(List::stream)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
// 存放所有检测小项
|
|
||||||
SocketManager.addSourceList(sourceIssues);
|
|
||||||
// 按照大项分组。key为大项code,value为小项个数
|
|
||||||
Map<String, Long> sourceIssueMap = sourceIssues.stream().collect(Collectors.groupingBy(SourceIssue::getType, Collectors.counting()));
|
|
||||||
SocketManager.initMap(sourceIssueMap);
|
|
||||||
|
|
||||||
//告诉前端当前项开始了
|
|
||||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
|
||||||
FormalTestManager.currentIssue = sourceIssues.get(0);
|
|
||||||
String type = sourceIssues.get(0).getType();
|
|
||||||
if (ResultUnitEnum.P.getCode().equals(type)) {
|
|
||||||
sourceIssues.get(0).setType(ResultUnitEnum.V_ABSOLUTELY.getCode());
|
|
||||||
webSocketVO.setRequestId(ResultUnitEnum.P.getCode() + CnSocketUtil.START_TAG);
|
|
||||||
} else {
|
|
||||||
webSocketVO.setRequestId(sourceIssues.get(0).getType() + CnSocketUtil.START_TAG);
|
|
||||||
}
|
|
||||||
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
|
||||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + type);
|
|
||||||
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(socketMsg));
|
|
||||||
|
|
||||||
webSocketVO.setDesc(null);
|
|
||||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
|
||||||
} else {
|
} else {
|
||||||
//后续什么都不做
|
//后续什么都不做
|
||||||
CnSocketUtil.quitSend(param);
|
CnSocketUtil.quitSend(param);
|
||||||
@@ -615,7 +550,7 @@ public class SocketDevResponseService {
|
|||||||
private BigDecimal rangeNum(double num1, double num2, String type) {
|
private BigDecimal rangeNum(double num1, double num2, String type) {
|
||||||
double diff = Math.abs(num1 - num2);
|
double diff = Math.abs(num1 - num2);
|
||||||
double larger = Math.max(num1, num2);
|
double larger = Math.max(num1, num2);
|
||||||
if (DicDataEnum.V.getCode().equals(type)) {
|
if (PowerIndexEnum.V.getKey().equals(type)) {
|
||||||
return BigDecimal.valueOf(num1 - num2).setScale(4, RoundingMode.HALF_UP);
|
return BigDecimal.valueOf(num1 - num2).setScale(4, RoundingMode.HALF_UP);
|
||||||
} else {
|
} else {
|
||||||
return BigDecimal.valueOf(diff / larger).multiply(BigDecimal.valueOf(100)).setScale(4, RoundingMode.HALF_UP);
|
return BigDecimal.valueOf(diff / larger).multiply(BigDecimal.valueOf(100)).setScale(4, RoundingMode.HALF_UP);
|
||||||
@@ -678,12 +613,12 @@ public class SocketDevResponseService {
|
|||||||
coefficientVO.setBIeXi(isWithinTenPercent(optionalIB, devParameter.getDevCurr(), iLimit) ? "合格" : "不合格");
|
coefficientVO.setBIeXi(isWithinTenPercent(optionalIB, devParameter.getDevCurr(), iLimit) ? "合格" : "不合格");
|
||||||
coefficientVO.setCIeXi(isWithinTenPercent(optionalIC, devParameter.getDevCurr(), iLimit) ? "合格" : "不合格");
|
coefficientVO.setCIeXi(isWithinTenPercent(optionalIC, devParameter.getDevCurr(), iLimit) ? "合格" : "不合格");
|
||||||
|
|
||||||
coefficientVO.setAV(rangeNum(optionalA, devParameter.getDevVolt(), DicDataEnum.V.getCode()).toString());
|
coefficientVO.setAV(rangeNum(optionalA, devParameter.getDevVolt(), PowerIndexEnum.V.getKey()).toString());
|
||||||
coefficientVO.setBV(rangeNum(optionalB, devParameter.getDevVolt(), DicDataEnum.V.getCode()).toString());
|
coefficientVO.setBV(rangeNum(optionalB, devParameter.getDevVolt(), PowerIndexEnum.V.getKey()).toString());
|
||||||
coefficientVO.setCV(rangeNum(optionalC, devParameter.getDevVolt(), DicDataEnum.V.getCode()).toString());
|
coefficientVO.setCV(rangeNum(optionalC, devParameter.getDevVolt(), PowerIndexEnum.V.getKey()).toString());
|
||||||
coefficientVO.setAI(rangeNum(optionalIA, devParameter.getDevCurr(), DicDataEnum.I.getCode()).toString());
|
coefficientVO.setAI(rangeNum(optionalIA, devParameter.getDevCurr(), PowerIndexEnum.I.getKey()).toString());
|
||||||
coefficientVO.setBI(rangeNum(optionalIB, devParameter.getDevCurr(), DicDataEnum.I.getCode()).toString());
|
coefficientVO.setBI(rangeNum(optionalIB, devParameter.getDevCurr(), PowerIndexEnum.I.getKey()).toString());
|
||||||
coefficientVO.setCI(rangeNum(optionalIC, devParameter.getDevCurr(), DicDataEnum.I.getCode()).toString());
|
coefficientVO.setCI(rangeNum(optionalIC, devParameter.getDevCurr(), PowerIndexEnum.I.getKey()).toString());
|
||||||
|
|
||||||
if ("不合格".equals(coefficientVO.getAVuXi()) || "不合格".equals(coefficientVO.getBVuXi()) || "不合格".equals(coefficientVO.getCVuXi()) || "不合格".equals(coefficientVO.getAIeXi()) || "不合格".equals(coefficientVO.getBIeXi()) || "不合格".equals(coefficientVO.getCIeXi())) {
|
if ("不合格".equals(coefficientVO.getAVuXi()) || "不合格".equals(coefficientVO.getBVuXi()) || "不合格".equals(coefficientVO.getCVuXi()) || "不合格".equals(coefficientVO.getAIeXi()) || "不合格".equals(coefficientVO.getBIeXi()) || "不合格".equals(coefficientVO.getCIeXi())) {
|
||||||
coefficientVO.setResultFlag(0);
|
coefficientVO.setResultFlag(0);
|
||||||
@@ -912,69 +847,70 @@ public class SocketDevResponseService {
|
|||||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||||
List<SourceIssue> sourceIssues;
|
List<SourceIssue> sourceIssues;
|
||||||
// 做预检测、后续做系数校准
|
// 做预检测、后续做系数校准
|
||||||
if (param.getTestItemList().get(0) || param.getTestItemList().get(1)) {
|
// if (param.isPreTestSelected() || param.isCoefficientSelected() || param.isFormalTestSelected()) {
|
||||||
issueParam.setIsPhaseSequence(CommonEnum.PHASE_TEST.getValue());
|
issueParam.setIsPhaseSequence(CommonEnum.PHASE_TEST.getValue());
|
||||||
sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||||
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||||
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(socketMsg));
|
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(socketMsg));
|
||||||
} else if (param.getTestItemList().get(2)) {
|
// }
|
||||||
// 后续做正式检测
|
// else if (param.isFormalTestSelected()) {
|
||||||
if (param.getReCheckType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())) {
|
// // 后续做正式检测
|
||||||
//不合格项复检
|
// if (param.getReCheckType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())) {
|
||||||
Set<Integer> indexes = new HashSet<>();
|
// //不合格项复检
|
||||||
StorageParam storageParam = new StorageParam();
|
// Set<Integer> indexes = new HashSet<>();
|
||||||
storageParam.setCode(param.getCode());
|
// StorageParam storageParam = new StorageParam();
|
||||||
storageParam.setScriptId(param.getScriptId());
|
// storageParam.setCode(param.getCode());
|
||||||
param.getDevIds().forEach(devId -> {
|
// storageParam.setScriptId(param.getScriptId());
|
||||||
storageParam.setDevId(devId);
|
// param.getDevIds().forEach(devId -> {
|
||||||
indexes.addAll(adHarmonicService.getIndex(storageParam));
|
// storageParam.setDevId(devId);
|
||||||
});
|
// indexes.addAll(adHarmonicService.getIndex(storageParam));
|
||||||
issueParam.setIndexList(indexes.stream().collect(Collectors.toList()));
|
// });
|
||||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.RE_ERROR_TEST.getValue());
|
// issueParam.setIndexList(indexes.stream().collect(Collectors.toList()));
|
||||||
} else {
|
// issueParam.setIsPhaseSequence(SourceOperateCodeEnum.RE_ERROR_TEST.getValue());
|
||||||
issueParam.setIsPhaseSequence(CommonEnum.FORMAL_TEST.getValue());
|
// } else {
|
||||||
}
|
// issueParam.setIsPhaseSequence(CommonEnum.FORMAL_TEST.getValue());
|
||||||
//正式检测
|
// }
|
||||||
sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
// //正式检测
|
||||||
sourceIssues = sourceIssues.stream().sorted(Comparator.comparing(SourceIssue::getIndex)).collect(Collectors.toList());
|
// sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||||
// 使用 LinkedHashMap 保持分组顺序
|
// sourceIssues = sourceIssues.stream().sorted(Comparator.comparing(SourceIssue::getIndex)).collect(Collectors.toList());
|
||||||
Map<String, List<SourceIssue>> groupedIssues = sourceIssues.stream()
|
// // 使用 LinkedHashMap 保持分组顺序
|
||||||
.collect(Collectors.groupingBy(
|
// Map<String, List<SourceIssue>> groupedIssues = sourceIssues.stream()
|
||||||
SourceIssue::getType,
|
// .collect(Collectors.groupingBy(
|
||||||
LinkedHashMap::new,
|
// SourceIssue::getType,
|
||||||
Collectors.toList()
|
// LinkedHashMap::new,
|
||||||
));
|
// Collectors.toList()
|
||||||
|
// ));
|
||||||
// 将分组后的元素合并成一个新的集合,保持原有顺序
|
//
|
||||||
sourceIssues = groupedIssues.values().stream()
|
// // 将分组后的元素合并成一个新的集合,保持原有顺序
|
||||||
.flatMap(List::stream)
|
// sourceIssues = groupedIssues.values().stream()
|
||||||
.collect(Collectors.toList());
|
// .flatMap(List::stream)
|
||||||
// 存放所有检测小项
|
// .collect(Collectors.toList());
|
||||||
SocketManager.addSourceList(sourceIssues);
|
// // 存放所有检测小项
|
||||||
// 按照大项分组。key为大项code,value为小项个数
|
// SocketManager.addSourceList(sourceIssues);
|
||||||
Map<String, Long> sourceIssueMap = sourceIssues.stream().collect(Collectors.groupingBy(SourceIssue::getType, Collectors.counting()));
|
// // 按照大项分组。key为大项code,value为小项个数
|
||||||
SocketManager.initMap(sourceIssueMap);
|
// Map<String, Long> sourceIssueMap = sourceIssues.stream().collect(Collectors.groupingBy(SourceIssue::getType, Collectors.counting()));
|
||||||
|
// SocketManager.initMap(sourceIssueMap);
|
||||||
//告诉前端当前项开始了
|
//
|
||||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
// //告诉前端当前项开始了
|
||||||
String type = sourceIssues.get(0).getType();
|
// WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||||
if (StrUtil.isNotBlank(sourceIssues.get(0).getOtherType())) {
|
// String type = sourceIssues.get(0).getType();
|
||||||
sourceIssues.get(0).setType(ResultUnitEnum.V_ABSOLUTELY.getCode());
|
// if (StrUtil.isNotBlank(sourceIssues.get(0).getOtherType())) {
|
||||||
webSocketVO.setRequestId(sourceIssues.get(0).getOtherType() + CnSocketUtil.START_TAG);
|
// sourceIssues.get(0).setType(PowerIndexEnum.V.getKey());
|
||||||
type = sourceIssues.get(0).getOtherType();
|
// webSocketVO.setRequestId(sourceIssues.get(0).getOtherType() + CnSocketUtil.START_TAG);
|
||||||
} else {
|
// type = sourceIssues.get(0).getOtherType();
|
||||||
webSocketVO.setRequestId(sourceIssues.get(0).getType() + CnSocketUtil.START_TAG);
|
// } else {
|
||||||
}
|
// webSocketVO.setRequestId(sourceIssues.get(0).getType() + CnSocketUtil.START_TAG);
|
||||||
FormalTestManager.currentIssue = sourceIssues.get(0);
|
// }
|
||||||
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
// FormalTestManager.currentIssue = sourceIssues.get(0);
|
||||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + type);
|
// socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
// socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + type);
|
||||||
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(socketMsg));
|
// socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||||
|
// SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(socketMsg));
|
||||||
webSocketVO.setDesc(null);
|
//
|
||||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
// webSocketVO.setDesc(null);
|
||||||
}
|
// WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||||
|
// }
|
||||||
} else {
|
} else {
|
||||||
// 发送下一个脚本与icd校验
|
// 发送下一个脚本与icd校验
|
||||||
String icdType = icdTypeList.stream().filter(it -> !icdCheckDataMap.containsKey(it)).findFirst().orElse(null);
|
String icdType = icdTypeList.stream().filter(it -> !icdCheckDataMap.containsKey(it)).findFirst().orElse(null);
|
||||||
@@ -1147,7 +1083,7 @@ public class SocketDevResponseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 后续做系数校准
|
// 后续做系数校准
|
||||||
if (param.getTestItemList().get(1)) {
|
if (param.isCoefficientSelected()) {
|
||||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||||
webSocketVO.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
webSocketVO.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||||
webSocketVO.setOperateCode(SourceOperateCodeEnum.big_start.getValue());
|
webSocketVO.setOperateCode(SourceOperateCodeEnum.big_start.getValue());
|
||||||
@@ -1171,70 +1107,8 @@ public class SocketDevResponseService {
|
|||||||
XiNumberManager.smallDevXiNumDataMap.clear();
|
XiNumberManager.smallDevXiNumDataMap.clear();
|
||||||
|
|
||||||
System.out.println("开始系数校准》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》");
|
System.out.println("开始系数校准》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》");
|
||||||
} else if (param.getTestItemList().get(2)) {
|
} else if (param.isFormalTestSelected()) {
|
||||||
// 后续做正式检测
|
startFormalScripts(param, null, param.isResumeFormal());
|
||||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
|
||||||
issueParam.setSourceId(param.getSourceName());
|
|
||||||
issueParam.setPlanId(param.getPlanId());
|
|
||||||
issueParam.setDevIds(param.getDevIds());
|
|
||||||
issueParam.setScriptId(param.getScriptId());
|
|
||||||
|
|
||||||
if (param.getReCheckType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())) {
|
|
||||||
//不合格项复检
|
|
||||||
Set<Integer> indexes = new HashSet<>();
|
|
||||||
StorageParam storageParam = new StorageParam();
|
|
||||||
storageParam.setCode(param.getCode());
|
|
||||||
storageParam.setScriptId(param.getScriptId());
|
|
||||||
param.getDevIds().forEach(devId -> {
|
|
||||||
storageParam.setDevId(devId);
|
|
||||||
indexes.addAll(adHarmonicService.getIndex(storageParam));
|
|
||||||
});
|
|
||||||
issueParam.setIndexList(indexes.stream().collect(Collectors.toList()));
|
|
||||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.RE_ERROR_TEST.getValue());
|
|
||||||
} else {
|
|
||||||
issueParam.setIsPhaseSequence(CommonEnum.FORMAL_TEST.getValue());
|
|
||||||
}
|
|
||||||
//正式检测
|
|
||||||
sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
|
||||||
sourceIssues = sourceIssues.stream().sorted(Comparator.comparing(SourceIssue::getIndex)).collect(Collectors.toList());
|
|
||||||
// 使用 LinkedHashMap 保持分组顺序
|
|
||||||
Map<String, List<SourceIssue>> groupedIssues = sourceIssues.stream()
|
|
||||||
.collect(Collectors.groupingBy(
|
|
||||||
SourceIssue::getType,
|
|
||||||
LinkedHashMap::new,
|
|
||||||
Collectors.toList()
|
|
||||||
));
|
|
||||||
|
|
||||||
// 将分组后的元素合并成一个新的集合,保持原有顺序
|
|
||||||
sourceIssues = groupedIssues.values().stream()
|
|
||||||
.flatMap(List::stream)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
// 存放所有检测小项
|
|
||||||
SocketManager.addSourceList(sourceIssues);
|
|
||||||
// 按照大项分组。key为大项code,value为小项个数
|
|
||||||
Map<String, Long> sourceIssueMap = sourceIssues.stream().collect(Collectors.groupingBy(SourceIssue::getType, Collectors.counting()));
|
|
||||||
SocketManager.initMap(sourceIssueMap);
|
|
||||||
|
|
||||||
//告诉前端当前项开始了
|
|
||||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
|
||||||
|
|
||||||
String type = sourceIssues.get(0).getType();
|
|
||||||
if (StrUtil.isNotBlank(sourceIssues.get(0).getOtherType())) {
|
|
||||||
sourceIssues.get(0).setType(ResultUnitEnum.V_ABSOLUTELY.getCode());
|
|
||||||
webSocketVO.setRequestId(sourceIssues.get(0).getOtherType() + CnSocketUtil.START_TAG);
|
|
||||||
type = sourceIssues.get(0).getOtherType();
|
|
||||||
} else {
|
|
||||||
webSocketVO.setRequestId(sourceIssues.get(0).getType() + CnSocketUtil.START_TAG);
|
|
||||||
}
|
|
||||||
|
|
||||||
FormalTestManager.currentIssue = sourceIssues.get(0);
|
|
||||||
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
|
||||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + type);
|
|
||||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
|
||||||
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(socketMsg));
|
|
||||||
|
|
||||||
webSocketVO.setDesc(null);
|
|
||||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
|
||||||
} else {
|
} else {
|
||||||
//后续什么都不做
|
//后续什么都不做
|
||||||
System.out.println("预检测流程结束-----------------关闭源");
|
System.out.println("预检测流程结束-----------------关闭源");
|
||||||
@@ -1279,6 +1153,97 @@ public class SocketDevResponseService {
|
|||||||
// key为 检测大项对应的code,value为当前大项的检测结果
|
// key为 检测大项对应的code,value为当前大项的检测结果
|
||||||
Map<String, List<DevLineTestResult>> targetTestMap = new HashMap<>();
|
Map<String, List<DevLineTestResult>> targetTestMap = new HashMap<>();
|
||||||
|
|
||||||
|
public void startFormalAfterProgressRestore(PreDetectionParam param, Integer nextSort) {
|
||||||
|
FormalTestManager.resumeFormalPending = false;
|
||||||
|
FormalTestManager.resumeNextSort = nextSort;
|
||||||
|
if (nextSort == null) {
|
||||||
|
WebServiceManager.sendDetectionMessage(param.getUserPageId(), "formal_progress_no_next", null, null, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
startFormalScripts(param, nextSort, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startFormalScripts(PreDetectionParam param, Integer startSort, boolean waitForProgressRestore) {
|
||||||
|
List<SourceIssue> sourceIssues = buildFormalIssues(param);
|
||||||
|
if (ObjectUtil.isNotNull(startSort)) {
|
||||||
|
sourceIssues = sourceIssues.stream()
|
||||||
|
.filter(issue -> issue.getIndex() >= startSort)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
sourceIssues = sourceIssues.stream()
|
||||||
|
.sorted(Comparator.comparing(SourceIssue::getIndex))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
Map<String, List<SourceIssue>> groupedIssues = sourceIssues.stream()
|
||||||
|
.collect(Collectors.groupingBy(SourceIssue::getType, LinkedHashMap::new, Collectors.toList()));
|
||||||
|
sourceIssues = groupedIssues.values().stream().flatMap(List::stream).collect(Collectors.toList());
|
||||||
|
if (!param.isResumeFormal() && CollUtil.isNotEmpty(sourceIssues)) {
|
||||||
|
iPqDevService.clearFormalProgressForNewRun(param.getDevIds());
|
||||||
|
}
|
||||||
|
SocketManager.addSourceList(sourceIssues);
|
||||||
|
Map<String, Long> sourceIssueMap = sourceIssues.stream()
|
||||||
|
.collect(Collectors.groupingBy(SourceIssue::getType, Collectors.counting()));
|
||||||
|
SocketManager.initMap(sourceIssueMap);
|
||||||
|
|
||||||
|
if (waitForProgressRestore) {
|
||||||
|
FormalTestManager.resumeFormalPending = true;
|
||||||
|
WebServiceManager.sendDetectionMessage(param.getUserPageId(), "formal_progress_required", null, null, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sendFirstFormalIssue(param, sourceIssues);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SourceIssue> buildFormalIssues(PreDetectionParam param) {
|
||||||
|
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||||
|
issueParam.setSourceId(param.getSourceName());
|
||||||
|
issueParam.setPlanId(param.getPlanId());
|
||||||
|
issueParam.setDevIds(param.getDevIds());
|
||||||
|
issueParam.setScriptId(param.getScriptId());
|
||||||
|
|
||||||
|
if (!param.isResumeFormal() && SourceOperateCodeEnum.RE_ERROR_TEST.getValue().equals(param.getReCheckType())) {
|
||||||
|
Set<Integer> indexes = new HashSet<>();
|
||||||
|
StorageParam storageParam = new StorageParam();
|
||||||
|
storageParam.setCode(param.getCode());
|
||||||
|
storageParam.setScriptId(param.getScriptId());
|
||||||
|
param.getDevIds().forEach(devId -> {
|
||||||
|
storageParam.setDevId(devId);
|
||||||
|
indexes.addAll(adHarmonicService.getIndex(storageParam));
|
||||||
|
});
|
||||||
|
issueParam.setIndexList(indexes.stream().collect(Collectors.toList()));
|
||||||
|
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.RE_ERROR_TEST.getValue());
|
||||||
|
} else {
|
||||||
|
issueParam.setIsPhaseSequence(CommonEnum.FORMAL_TEST.getValue());
|
||||||
|
}
|
||||||
|
return pqScriptDtlsService.listSourceIssue(issueParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendFirstFormalIssue(PreDetectionParam param, List<SourceIssue> sourceIssues) {
|
||||||
|
if (CollUtil.isEmpty(sourceIssues)) {
|
||||||
|
WebServiceManager.sendDetectionMessage(param.getUserPageId(), "formal_progress_no_next", null, null, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SourceIssue firstIssue = sourceIssues.get(0);
|
||||||
|
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||||
|
String type = firstIssue.getType();
|
||||||
|
if (StrUtil.isNotBlank(firstIssue.getOtherType())) {
|
||||||
|
firstIssue.setType(PowerIndexEnum.V.getKey());
|
||||||
|
webSocketVO.setRequestId(firstIssue.getOtherType() + CnSocketUtil.START_TAG);
|
||||||
|
type = firstIssue.getOtherType();
|
||||||
|
} else {
|
||||||
|
webSocketVO.setRequestId(firstIssue.getType() + CnSocketUtil.START_TAG);
|
||||||
|
}
|
||||||
|
FormalTestManager.currentIssue = firstIssue;
|
||||||
|
FormalTestManager.resumeFormalStartTime = LocalDateTime.now();
|
||||||
|
|
||||||
|
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||||
|
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||||
|
socketMsg.setData(JSON.toJSONString(firstIssue));
|
||||||
|
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + CnSocketUtil.STEP_TAG + type);
|
||||||
|
SocketManager.sendMsg(param.getUserPageId() + CnSocketUtil.SOURCE_TAG, JSON.toJSONString(socketMsg));
|
||||||
|
|
||||||
|
webSocketVO.setDesc(null);
|
||||||
|
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 正式检测
|
* 正式检测
|
||||||
*/
|
*/
|
||||||
@@ -1369,7 +1334,7 @@ public class SocketDevResponseService {
|
|||||||
|
|
||||||
String type = sourceIssues.getType();
|
String type = sourceIssues.getType();
|
||||||
if (StrUtil.isNotBlank(sourceIssues.getOtherType())) {
|
if (StrUtil.isNotBlank(sourceIssues.getOtherType())) {
|
||||||
sourceIssues.setType(ResultUnitEnum.V_ABSOLUTELY.getCode());
|
sourceIssues.setType(PowerIndexEnum.V.getKey());
|
||||||
type = sourceIssues.getOtherType();
|
type = sourceIssues.getOtherType();
|
||||||
}
|
}
|
||||||
// 如果上一个大项检测完成,则检测下一个大项,并向前端推送消息
|
// 如果上一个大项检测完成,则检测下一个大项,并向前端推送消息
|
||||||
@@ -1815,7 +1780,7 @@ public class SocketDevResponseService {
|
|||||||
//字典树
|
//字典树
|
||||||
SocketManager.valueTypeMap = iPqScriptCheckDataService.getValueTypeMap(param.getScriptId());
|
SocketManager.valueTypeMap = iPqScriptCheckDataService.getValueTypeMap(param.getScriptId());
|
||||||
|
|
||||||
if (param.getTestItemList().get(1)) {
|
if (param.isCoefficientSelected()) {
|
||||||
initXiManager(param);
|
initXiManager(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2014,7 +1979,7 @@ public class SocketDevResponseService {
|
|||||||
adHarmonicResult.setAdType(checkDataMap.get(sqlDataDTO.getDesc()));
|
adHarmonicResult.setAdType(checkDataMap.get(sqlDataDTO.getDesc()));
|
||||||
adHarmonicResult.setDataType(sourceIssue.getDataType());
|
adHarmonicResult.setDataType(sourceIssue.getDataType());
|
||||||
|
|
||||||
if (!DicDataEnum.HSV.getCode().equals(sourceIssue.getType()) && !DicDataEnum.HSI.getCode().equals(sourceIssue.getType()) && !DicDataEnum.HP.getCode().equals(sourceIssue.getType())) {
|
if (!PowerIndexEnum.HSV.getKey().equals(sourceIssue.getType()) && !PowerIndexEnum.HSI.getKey().equals(sourceIssue.getType()) && !PowerIndexEnum.HP.getKey().equals(sourceIssue.getType())) {
|
||||||
if (CollUtil.isNotEmpty(data.getSqlData())) {
|
if (CollUtil.isNotEmpty(data.getSqlData())) {
|
||||||
DevData.SqlDataDTO.ListDTO vvv = data.getSqlData().stream().filter(it -> it.getDesc().equals(dui)).collect(Collectors.toList()).get(0).getList();
|
DevData.SqlDataDTO.ListDTO vvv = data.getSqlData().stream().filter(it -> it.getDesc().equals(dui)).collect(Collectors.toList()).get(0).getList();
|
||||||
Double aV = vvv.getA();
|
Double aV = vvv.getA();
|
||||||
@@ -2039,7 +2004,7 @@ public class SocketDevResponseService {
|
|||||||
List<String> c = tem.getC();
|
List<String> c = tem.getC();
|
||||||
|
|
||||||
Class<SimAndDigHarmonicResult> example = (Class<SimAndDigHarmonicResult>) adHarmonicResult.getClass();
|
Class<SimAndDigHarmonicResult> example = (Class<SimAndDigHarmonicResult>) adHarmonicResult.getClass();
|
||||||
if (DicDataEnum.HSV.getCode().equals(sourceIssue.getType()) || DicDataEnum.HSI.getCode().equals(sourceIssue.getType())) {
|
if (PowerIndexEnum.HSV.getKey().equals(sourceIssue.getType()) || PowerIndexEnum.HSI.getKey().equals(sourceIssue.getType())) {
|
||||||
for (int i = 1; i < a.size() + 1; i++) {
|
for (int i = 1; i < a.size() + 1; i++) {
|
||||||
try {
|
try {
|
||||||
Field aField = example.getDeclaredField("aValue" + i);
|
Field aField = example.getDeclaredField("aValue" + i);
|
||||||
|
|||||||
@@ -17,11 +17,10 @@ import com.njcn.gather.device.pojo.vo.PreDetection;
|
|||||||
import com.njcn.gather.device.service.IPqDevService;
|
import com.njcn.gather.device.service.IPqDevService;
|
||||||
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
||||||
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
||||||
import com.njcn.gather.result.pojo.enums.ResultUnitEnum;
|
import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
|
||||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||||
import com.njcn.gather.source.pojo.po.SourceInitialize;
|
import com.njcn.gather.source.pojo.po.SourceInitialize;
|
||||||
import com.njcn.gather.source.service.IPqSourceService;
|
import com.njcn.gather.source.service.IPqSourceService;
|
||||||
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
@@ -386,8 +385,8 @@ public class SocketSourceResponseService {
|
|||||||
|
|
||||||
//重新下发脚本
|
//重新下发脚本
|
||||||
String type = FormalTestManager.currentIssue.getType();
|
String type = FormalTestManager.currentIssue.getType();
|
||||||
if (ResultUnitEnum.P.getCode().equals(type)) {
|
if (PowerIndexEnum.P.getKey().equals(type)) {
|
||||||
FormalTestManager.currentIssue.setType(ResultUnitEnum.V_ABSOLUTELY.getCode());
|
FormalTestManager.currentIssue.setType(PowerIndexEnum.V.getKey());
|
||||||
}
|
}
|
||||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||||
socketMsg.setData(JSON.toJSONString(FormalTestManager.currentIssue));
|
socketMsg.setData(JSON.toJSONString(FormalTestManager.currentIssue));
|
||||||
@@ -538,14 +537,14 @@ public class SocketSourceResponseService {
|
|||||||
int ignoreCount;
|
int ignoreCount;
|
||||||
int readData;
|
int readData;
|
||||||
|
|
||||||
if (DicDataEnum.F.getCode().equals(sourceIssue.getType())) {
|
if (PowerIndexEnum.F.getKey().equals(sourceIssue.getType())) {
|
||||||
// 闪变检测:数据变化较慢,只需少量预热和读取
|
// 闪变检测:数据变化较慢,只需少量预热和读取
|
||||||
// 闪变测量稳定性好,预热1次即可
|
// 闪变测量稳定性好,预热1次即可
|
||||||
ignoreCount = 1;
|
ignoreCount = 1;
|
||||||
// 读取2次数据计算闪变值
|
// 读取2次数据计算闪变值
|
||||||
readData = 2;
|
readData = 2;
|
||||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
|
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
|
||||||
} else if (DicDataEnum.VOLTAGE.getCode().equals(sourceIssue.getType())) {
|
} else if (PowerIndexEnum.VOLTAGE.getKey().equals(sourceIssue.getType())) {
|
||||||
// 暂态电压检测:需要更多预热时间,但只读取一次快照
|
// 暂态电压检测:需要更多预热时间,但只读取一次快照
|
||||||
// 暂态事件需要5次预热确保触发稳定
|
// 暂态事件需要5次预热确保触发稳定
|
||||||
ignoreCount = 5;
|
ignoreCount = 5;
|
||||||
|
|||||||
@@ -38,10 +38,31 @@ public class ContrastDetectionParam {
|
|||||||
@NotEmpty(message = DetectionValidMessage.PAIRS_NOT_EMPTY)
|
@NotEmpty(message = DetectionValidMessage.PAIRS_NOT_EMPTY)
|
||||||
private Map<String, String> pairs;
|
private Map<String, String> pairs;
|
||||||
/**
|
/**
|
||||||
* 检测项列表。第一个元素为预检测、第二个元素为系数校准、第三个元素为正式检测
|
* 检测项列表。第一个元素为预检测、第二个元素为系数校准、第三个元素为守时校验、第四个元素为正式检测。
|
||||||
|
* 比对场景暂不支持系数校准和守时校验,第二、第三个元素固定为 false。
|
||||||
*/
|
*/
|
||||||
private List<Boolean> testItemList;
|
private List<Boolean> testItemList;
|
||||||
|
|
||||||
|
public boolean isPreTestSelected() {
|
||||||
|
return isTestItemSelected(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCoefficientSelected() {
|
||||||
|
return isTestItemSelected(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTimeCheckSelected() {
|
||||||
|
return isTestItemSelected(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFormalTestSelected() {
|
||||||
|
return isTestItemSelected(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isTestItemSelected(int index) {
|
||||||
|
return testItemList != null && testItemList.size() > index && Boolean.TRUE.equals(testItemList.get(index));
|
||||||
|
}
|
||||||
|
|
||||||
private String userId;
|
private String userId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.njcn.gather.detection.pojo.param;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FormalProgressParam {
|
||||||
|
@NotBlank(message = "计划id不可为空")
|
||||||
|
private String planId;
|
||||||
|
|
||||||
|
@NotEmpty(message = "装置不能为空")
|
||||||
|
private List<String> devIds;
|
||||||
|
|
||||||
|
private String userPageId;
|
||||||
|
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存暂存进度时必传;查询/放行续检时以后端设备表为准。
|
||||||
|
*/
|
||||||
|
private Integer formalCheckTime;
|
||||||
|
}
|
||||||
@@ -5,7 +5,6 @@ import lombok.Data;
|
|||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wr
|
* @author wr
|
||||||
@@ -76,7 +75,36 @@ public class PreDetectionParam {
|
|||||||
private Float humidity;
|
private Float humidity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检测项列表。第一个元素为预检测、第二个元素为系数校准、第三个元素为正式检测
|
* 检测项列表。第一个元素为预检测、第二个元素为系数校准、第三个元素为守时校验、第四个元素为正式检测
|
||||||
*/
|
*/
|
||||||
private List<Boolean> testItemList;
|
private List<Boolean> testItemList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否从正式检测暂存进度续检
|
||||||
|
*/
|
||||||
|
private Boolean resumeFormal;
|
||||||
|
|
||||||
|
public boolean isPreTestSelected() {
|
||||||
|
return isTestItemSelected(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCoefficientSelected() {
|
||||||
|
return isTestItemSelected(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTimeCheckSelected() {
|
||||||
|
return isTestItemSelected(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFormalTestSelected() {
|
||||||
|
return isTestItemSelected(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isResumeFormal() {
|
||||||
|
return Boolean.TRUE.equals(resumeFormal);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isTestItemSelected(int index) {
|
||||||
|
return testItemList != null && testItemList.size() > index && Boolean.TRUE.equals(testItemList.get(index));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.njcn.gather.detection.pojo.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FormalProgressVO {
|
||||||
|
private Integer formalCheckTime;
|
||||||
|
private Integer minMaxSort;
|
||||||
|
private Integer nextSort;
|
||||||
|
private Double process;
|
||||||
|
private List<TableRow> tableRows = new ArrayList<>();
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class TableRow {
|
||||||
|
private String scriptType;
|
||||||
|
private String scriptCode;
|
||||||
|
private String scriptName;
|
||||||
|
private List<DeviceResult> devices = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class DeviceResult {
|
||||||
|
private String deviceId;
|
||||||
|
private String deviceName;
|
||||||
|
private List<Integer> chnResult = new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.njcn.gather.detection.service;
|
||||||
|
|
||||||
|
import com.njcn.gather.detection.pojo.param.FormalProgressParam;
|
||||||
|
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||||
|
import com.njcn.gather.detection.pojo.vo.FormalProgressVO;
|
||||||
|
|
||||||
|
public interface FormalProgressService {
|
||||||
|
FormalProgressVO restoreAndRelease(FormalProgressParam param);
|
||||||
|
|
||||||
|
Integer calculateNextSort(PreDetectionParam param);
|
||||||
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.njcn.gather.detection.service;
|
package com.njcn.gather.detection.service;
|
||||||
|
|
||||||
import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
|
import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
|
||||||
|
import com.njcn.gather.detection.pojo.param.FormalProgressParam;
|
||||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||||
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
||||||
|
import com.njcn.gather.detection.pojo.vo.FormalProgressVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -33,6 +35,10 @@ public interface PreDetectionService {
|
|||||||
|
|
||||||
boolean restartTemTest(PreDetectionParam param);
|
boolean restartTemTest(PreDetectionParam param);
|
||||||
|
|
||||||
|
void saveFormalProgress(FormalProgressParam param);
|
||||||
|
|
||||||
|
FormalProgressVO formalProgress(FormalProgressParam param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模拟测试-源通讯校验
|
* 模拟测试-源通讯校验
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import com.njcn.gather.monitor.pojo.po.PqMonitor;
|
|||||||
import com.njcn.gather.monitor.service.IPqMonitorService;
|
import com.njcn.gather.monitor.service.IPqMonitorService;
|
||||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||||
import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
|
import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
|
||||||
import com.njcn.gather.result.pojo.enums.ResultUnitEnum;
|
|
||||||
import com.njcn.gather.script.mapper.PqScriptMapper;
|
import com.njcn.gather.script.mapper.PqScriptMapper;
|
||||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||||
@@ -82,7 +81,6 @@ public class DetectionServiceImpl {
|
|||||||
public static final String TYPE_T = "T";
|
public static final String TYPE_T = "T";
|
||||||
private final String U = "U";
|
private final String U = "U";
|
||||||
private final String I = "I";
|
private final String I = "I";
|
||||||
private final String F = "F";
|
|
||||||
private final String HP = "HP";
|
private final String HP = "HP";
|
||||||
private final String P = "P";
|
private final String P = "P";
|
||||||
private final String MAG = "MAG";
|
private final String MAG = "MAG";
|
||||||
@@ -163,33 +161,31 @@ public class DetectionServiceImpl {
|
|||||||
param.setIn(sourceIssue.getFIn());
|
param.setIn(sourceIssue.getFIn());
|
||||||
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||||
List<ErrDtlsCheckDataVO> errDtlsCheckData = pqErrSysDtlsService.listByPqErrSysIdAndTypes(param);
|
List<ErrDtlsCheckDataVO> errDtlsCheckData = pqErrSysDtlsService.listByPqErrSysIdAndTypes(param);
|
||||||
ResultUnitEnum resultUnitEnumByCode = ResultUnitEnum.getResultUnitEnumByCode(sourceIssue.getType());
|
PowerIndexEnum powerIndexEnum = PowerIndexEnum.getByKey(sourceIssue.getType());
|
||||||
if (StrUtil.isNotBlank(sourceIssue.getOtherType())) {
|
if (StrUtil.isNotBlank(sourceIssue.getOtherType())) {
|
||||||
resultUnitEnumByCode = ResultUnitEnum.getResultUnitEnumByCode(sourceIssue.getOtherType());
|
powerIndexEnum = PowerIndexEnum.getByKey(sourceIssue.getOtherType());
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (resultUnitEnumByCode) {
|
switch (powerIndexEnum) {
|
||||||
/**
|
/**
|
||||||
* 频率
|
* 频率
|
||||||
*/
|
*/
|
||||||
case FREQ:
|
case FREQ:
|
||||||
return isQualified(dev, devIdMapComm, errDtlsCheckData, F, sourceIssue, dataRule, code, oneConfig.getScale());
|
return isQualified(dev, devIdMapComm, errDtlsCheckData, PowerIndexEnum.FREQ.getKey(), sourceIssue, dataRule, code, oneConfig.getScale());
|
||||||
case P:
|
case P:
|
||||||
return isQualified(dev, devIdMapComm, errDtlsCheckData, P, sourceIssue, dataRule, code, oneConfig.getScale());
|
return isQualified(dev, devIdMapComm, errDtlsCheckData, PowerIndexEnum.P.getKey(), sourceIssue, dataRule, code, oneConfig.getScale());
|
||||||
case ANGLE:
|
case ANGLE:
|
||||||
return isQualified(dev, devIdMapComm, errDtlsCheckData, resultUnitEnumByCode.getCode(), sourceIssue, dataRule, code, oneConfig.getScale());
|
return isQualified(dev, devIdMapComm, errDtlsCheckData, PowerIndexEnum.ANGLE.getKey(), sourceIssue, dataRule, code, oneConfig.getScale());
|
||||||
/**
|
/**
|
||||||
* 电压
|
* 电压
|
||||||
*/
|
*/
|
||||||
case V_RELATIVE:
|
case V:
|
||||||
case V_ABSOLUTELY:
|
return isQualified(dev, devIdMapComm, errDtlsCheckData, PowerIndexEnum.V.getKey(), sourceIssue, dataRule, code, oneConfig.getScale());
|
||||||
return isQualified(dev, devIdMapComm, errDtlsCheckData, U, sourceIssue, dataRule, code, oneConfig.getScale());
|
|
||||||
/**
|
/**
|
||||||
* 电流
|
* 电流
|
||||||
*/
|
*/
|
||||||
case I_RELATIVE:
|
case I:
|
||||||
case I_ABSOLUTELY:
|
return isQualified(dev, devIdMapComm, errDtlsCheckData, PowerIndexEnum.I.getKey(), sourceIssue, dataRule, code, oneConfig.getScale());
|
||||||
return isQualified(dev, devIdMapComm, errDtlsCheckData, I, sourceIssue, dataRule, code, oneConfig.getScale());
|
|
||||||
/**
|
/**
|
||||||
* 谐波
|
* 谐波
|
||||||
*/
|
*/
|
||||||
@@ -234,8 +230,7 @@ public class DetectionServiceImpl {
|
|||||||
/**
|
/**
|
||||||
* 暂态
|
* 暂态
|
||||||
*/
|
*/
|
||||||
case VOLTAGE_MAG:
|
case VOLTAGE:
|
||||||
case VOLTAGE_DUR:
|
|
||||||
return isVoltageQualified(dev, devIdMapComm, errDtlsCheckData, sourceIssue, dataRule, code, oneConfig.getScale());
|
return isVoltageQualified(dev, devIdMapComm, errDtlsCheckData, sourceIssue, dataRule, code, oneConfig.getScale());
|
||||||
default:
|
default:
|
||||||
return isUnknownQualified(dev, devIdMapComm, errDtlsCheckData, sourceIssue, dataRule, code, oneConfig.getScale());
|
return isUnknownQualified(dev, devIdMapComm, errDtlsCheckData, sourceIssue, dataRule, code, oneConfig.getScale());
|
||||||
@@ -428,17 +423,17 @@ public class DetectionServiceImpl {
|
|||||||
dtlsCheckData = errDtlsCheckData.stream().filter(x -> x.getValueTypeCode().equals(splitArr[1])).collect(Collectors.toList());
|
dtlsCheckData = errDtlsCheckData.stream().filter(x -> x.getValueTypeCode().equals(splitArr[1])).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
Double fData = 1.0;
|
Double fData = 1.0;
|
||||||
if (U.equals(type)) {
|
if (PowerIndexEnum.V.getKey().equals(type)) {
|
||||||
fData = sourceIssue.getFUn();
|
fData = sourceIssue.getFUn();
|
||||||
}
|
}
|
||||||
if (I.equals(type)) {
|
if (PowerIndexEnum.I.getKey().equals(type)) {
|
||||||
fData = sourceIssue.getFIn();
|
fData = sourceIssue.getFIn();
|
||||||
}
|
}
|
||||||
if (F.equals(type)) {
|
if (PowerIndexEnum.FREQ.getKey().equals(type)) {
|
||||||
fData = sourceIssue.getFFreq();
|
fData = sourceIssue.getFFreq();
|
||||||
}
|
}
|
||||||
if (P.equals(type)) {
|
if (PowerIndexEnum.P.getKey().equals(type)) {
|
||||||
if (!DetectionCodeEnum.PF.getCode().equals(splitArr[1])) {
|
if (!DetectionCodeEnum.PF.getCode().equals(splitArr[1]) && !DetectionCodeEnum.TOTPF.getCode().equals(splitArr[1])) {
|
||||||
Boolean valueType = pqScriptMapper.selectScriptIsValueType(sourceIssue.getScriptId());
|
Boolean valueType = pqScriptMapper.selectScriptIsValueType(sourceIssue.getScriptId());
|
||||||
if (valueType) {
|
if (valueType) {
|
||||||
fData = sourceIssue.getFUn() * sourceIssue.getFIn() / 100;
|
fData = sourceIssue.getFUn() * sourceIssue.getFIn() / 100;
|
||||||
@@ -488,7 +483,7 @@ public class DetectionServiceImpl {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
if (CollUtil.isNotEmpty(checkData)) {
|
if (CollUtil.isNotEmpty(checkData)) {
|
||||||
List<Double> phaseValue = map.get(phase);
|
List<Double> phaseValue = map.get(phase);
|
||||||
if (ResultUnitEnum.ANGLE.getCode().equals(type)) {
|
if (PowerIndexEnum.ANGLE.getKey().equals(type)) {
|
||||||
phaseValue = phaseValue.stream().map(x -> {
|
phaseValue = phaseValue.stream().map(x -> {
|
||||||
// 原始误差值
|
// 原始误差值
|
||||||
double originDiff = x - checkData.get(0).getValue();
|
double originDiff = x - checkData.get(0).getValue();
|
||||||
@@ -543,11 +538,15 @@ public class DetectionServiceImpl {
|
|||||||
SourceIssue sourceIssue,
|
SourceIssue sourceIssue,
|
||||||
DictDataEnum dataRule,
|
DictDataEnum dataRule,
|
||||||
Integer num, Integer scale) {
|
Integer num, Integer scale) {
|
||||||
Double fData = 1.0;
|
Double fDataA = 1.0;
|
||||||
|
Double fDataB = 1.0;
|
||||||
|
Double fDataC = 1.0;
|
||||||
String fundCode = "";
|
String fundCode = "";
|
||||||
String harmCode = "";
|
String harmCode = "";
|
||||||
if (U.equals(type)) {
|
if (U.equals(type)) {
|
||||||
fData = sourceIssue.getFUn();
|
fDataA = sourceIssue.getChannelList().stream().filter(x -> x.getChannelType().contains("Ua")).findFirst().get().getFAmp();
|
||||||
|
fDataB = sourceIssue.getChannelList().stream().filter(x -> x.getChannelType().contains("Ub")).findFirst().get().getFAmp();
|
||||||
|
fDataC = sourceIssue.getChannelList().stream().filter(x -> x.getChannelType().contains("Uc")).findFirst().get().getFAmp();
|
||||||
fundCode = DetectionCodeEnum.U1.getCode();
|
fundCode = DetectionCodeEnum.U1.getCode();
|
||||||
if (num == 1) {
|
if (num == 1) {
|
||||||
harmCode = DetectionCodeEnum.SV_1_49.getCode();
|
harmCode = DetectionCodeEnum.SV_1_49.getCode();
|
||||||
@@ -556,7 +555,9 @@ public class DetectionServiceImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (I.equals(type)) {
|
if (I.equals(type)) {
|
||||||
fData = sourceIssue.getFIn();
|
fDataA = sourceIssue.getChannelList().stream().filter(x -> x.getChannelType().contains("Ia")).findFirst().get().getFAmp();
|
||||||
|
fDataB = sourceIssue.getChannelList().stream().filter(x -> x.getChannelType().contains("Ib")).findFirst().get().getFAmp();
|
||||||
|
fDataC = sourceIssue.getChannelList().stream().filter(x -> x.getChannelType().contains("Ic")).findFirst().get().getFAmp();
|
||||||
fundCode = DetectionCodeEnum.I1.getCode();
|
fundCode = DetectionCodeEnum.I1.getCode();
|
||||||
if (num == 1) {
|
if (num == 1) {
|
||||||
harmCode = DetectionCodeEnum.SI_1_49.getCode();
|
harmCode = DetectionCodeEnum.SI_1_49.getCode();
|
||||||
@@ -565,7 +566,9 @@ public class DetectionServiceImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (HP.equals(type)) {
|
if (HP.equals(type)) {
|
||||||
fData = (sourceIssue.getFIn() * sourceIssue.getFUn()) * 0.01;
|
fDataA = (sourceIssue.getFIn() * sourceIssue.getFUn()) * 0.01;
|
||||||
|
fDataB = (sourceIssue.getFIn() * sourceIssue.getFUn()) * 0.01;
|
||||||
|
fDataC = (sourceIssue.getFIn() * sourceIssue.getFUn()) * 0.01;
|
||||||
harmCode = DetectionCodeEnum.P2_50.getCode();
|
harmCode = DetectionCodeEnum.P2_50.getCode();
|
||||||
}
|
}
|
||||||
// if (P.equals(type)) {
|
// if (P.equals(type)) {
|
||||||
@@ -591,9 +594,9 @@ public class DetectionServiceImpl {
|
|||||||
pqErrSysDtls = adDtlsCheckData.get(0).getErrSysDtls();
|
pqErrSysDtls = adDtlsCheckData.get(0).getErrSysDtls();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<DetectionData> integerBooleanA = harmRangeComparison(isQualified, pqErrSysDtls, type, TYPE_A, sourceIssue, dataRule, devMap.get(TYPE_A), fData, num, scale);
|
List<DetectionData> integerBooleanA = harmRangeComparison(isQualified, pqErrSysDtls, type, TYPE_A, sourceIssue, dataRule, devMap.get(TYPE_A), fDataA, num, scale);
|
||||||
List<DetectionData> integerBooleanB = harmRangeComparison(isQualified, pqErrSysDtls, type, TYPE_B, sourceIssue, dataRule, devMap.get(TYPE_B), fData, num, scale);
|
List<DetectionData> integerBooleanB = harmRangeComparison(isQualified, pqErrSysDtls, type, TYPE_B, sourceIssue, dataRule, devMap.get(TYPE_B), fDataB, num, scale);
|
||||||
List<DetectionData> integerBooleanC = harmRangeComparison(isQualified, pqErrSysDtls, type, TYPE_C, sourceIssue, dataRule, devMap.get(TYPE_C), fData, num, scale);
|
List<DetectionData> integerBooleanC = harmRangeComparison(isQualified, pqErrSysDtls, type, TYPE_C, sourceIssue, dataRule, devMap.get(TYPE_C), fDataC, num, scale);
|
||||||
harmonicResult.setDataType(sourceIssue.getDataType());
|
harmonicResult.setDataType(sourceIssue.getDataType());
|
||||||
reflectHarmonic(false, "a", integerBooleanA, harmonicResult, num);
|
reflectHarmonic(false, "a", integerBooleanA, harmonicResult, num);
|
||||||
reflectHarmonic(false, "b", integerBooleanB, harmonicResult, num);
|
reflectHarmonic(false, "b", integerBooleanB, harmonicResult, num);
|
||||||
|
|||||||
@@ -0,0 +1,218 @@
|
|||||||
|
package com.njcn.gather.detection.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.gather.detection.handler.SocketDevResponseService;
|
||||||
|
import com.njcn.gather.detection.pojo.param.FormalProgressParam;
|
||||||
|
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||||
|
import com.njcn.gather.detection.pojo.vo.FormalProgressVO;
|
||||||
|
import com.njcn.gather.detection.service.FormalProgressService;
|
||||||
|
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
||||||
|
import com.njcn.gather.device.pojo.enums.CommonEnum;
|
||||||
|
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||||
|
import com.njcn.gather.device.service.IPqDevService;
|
||||||
|
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||||
|
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||||
|
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||||
|
import com.njcn.gather.storage.pojo.po.SimAndDigBaseResult;
|
||||||
|
import com.njcn.gather.storage.service.SimAndDigHarmonicService;
|
||||||
|
import com.njcn.gather.storage.service.SimAndDigNonHarmonicService;
|
||||||
|
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||||
|
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class FormalProgressServiceImpl implements FormalProgressService {
|
||||||
|
|
||||||
|
private static final long RESUME_RELEASE_DELAY_MILLIS = 300L;
|
||||||
|
|
||||||
|
private final IPqDevService pqDevService;
|
||||||
|
private final IPqScriptDtlsService pqScriptDtlsService;
|
||||||
|
private final IDictTreeService dictTreeService;
|
||||||
|
private final SimAndDigHarmonicService harmonicService;
|
||||||
|
private final SimAndDigNonHarmonicService nonHarmonicService;
|
||||||
|
private final SocketDevResponseService socketDevResponseService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FormalProgressVO restoreAndRelease(FormalProgressParam param) {
|
||||||
|
PreDetectionParam preParam = WebServiceManager.getPreDetectionParam(param.getUserPageId());
|
||||||
|
if (preParam == null) {
|
||||||
|
throw new BusinessException(CommonResponseEnum.FAIL, "未找到续检上下文,请重新开始检测");
|
||||||
|
}
|
||||||
|
FormalProgressVO vo = buildSnapshot(preParam, param.getDevIds());
|
||||||
|
releaseResumeAfterSnapshotApplied(preParam, vo.getNextSort());
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer calculateNextSort(PreDetectionParam param) {
|
||||||
|
return buildSnapshot(param, param.getDevIds()).getNextSort();
|
||||||
|
}
|
||||||
|
|
||||||
|
private FormalProgressVO buildSnapshot(PreDetectionParam param, List<String> devIds) {
|
||||||
|
FormalProgressVO vo = new FormalProgressVO();
|
||||||
|
vo.setFormalCheckTime(pqDevService.getMinFormalCheckTime(devIds));
|
||||||
|
|
||||||
|
Map<String, Integer> harmonicMax = harmonicService.maxSortByDevIds(param.getCode(), param.getScriptId(), devIds);
|
||||||
|
Map<String, Integer> nonHarmonicMax = nonHarmonicService.maxSortByDevIds(param.getCode(), param.getScriptId(), devIds);
|
||||||
|
|
||||||
|
Integer minMaxSort = devIds.stream()
|
||||||
|
.map(devId -> Math.max(harmonicMax.getOrDefault(devId, -1), nonHarmonicMax.getOrDefault(devId, -1)))
|
||||||
|
.min(Integer::compareTo)
|
||||||
|
.orElse(-1);
|
||||||
|
vo.setMinMaxSort(minMaxSort);
|
||||||
|
|
||||||
|
List<SourceIssue> allIssues = buildAllFormalIssues(param);
|
||||||
|
List<Integer> allSorts = allIssues.stream()
|
||||||
|
.map(SourceIssue::getIndex)
|
||||||
|
.filter(sort -> sort != null && sort >= 0)
|
||||||
|
.sorted()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
Integer nextSort = allSorts.stream()
|
||||||
|
.filter(sort -> sort > minMaxSort)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
vo.setNextSort(nextSort);
|
||||||
|
|
||||||
|
Set<String> completedTypes = completedBigTypes(allIssues, minMaxSort);
|
||||||
|
long totalBigTypes = allIssues.stream().map(SourceIssue::getType).distinct().count();
|
||||||
|
vo.setProcess(totalBigTypes == 0 ? 0D : completedTypes.size() * 100D / totalBigTypes);
|
||||||
|
vo.setTableRows(buildRows(param, devIds, allIssues, completedTypes));
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void releaseResumeAfterSnapshotApplied(PreDetectionParam preParam, Integer nextSort) {
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
|
try {
|
||||||
|
Thread.sleep(RESUME_RELEASE_DELAY_MILLIS);
|
||||||
|
socketDevResponseService.startFormalAfterProgressRestore(preParam, nextSort);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
log.warn("正式检测续检放行等待被中断", e);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("正式检测续检放行失败", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SourceIssue> buildAllFormalIssues(PreDetectionParam param) {
|
||||||
|
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||||
|
issueParam.setPlanId(param.getPlanId());
|
||||||
|
issueParam.setSourceId(param.getSourceName());
|
||||||
|
issueParam.setDevIds(param.getDevIds());
|
||||||
|
issueParam.setScriptId(param.getScriptId());
|
||||||
|
issueParam.setIsPhaseSequence(CommonEnum.FORMAL_TEST.getValue());
|
||||||
|
return pqScriptDtlsService.listSourceIssue(issueParam)
|
||||||
|
.stream()
|
||||||
|
.sorted(Comparator.comparing(SourceIssue::getIndex))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<String> completedBigTypes(List<SourceIssue> issues, Integer minMaxSort) {
|
||||||
|
return issues.stream()
|
||||||
|
.collect(Collectors.groupingBy(SourceIssue::getType, LinkedHashMap::new, Collectors.toList()))
|
||||||
|
.entrySet()
|
||||||
|
.stream()
|
||||||
|
.filter(entry -> entry.getValue().stream().allMatch(issue -> issue.getIndex() <= minMaxSort))
|
||||||
|
.map(Map.Entry::getKey)
|
||||||
|
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<FormalProgressVO.TableRow> buildRows(PreDetectionParam param,
|
||||||
|
List<String> devIds,
|
||||||
|
List<SourceIssue> issues,
|
||||||
|
Set<String> completedTypes) {
|
||||||
|
Map<String, List<SourceIssue>> byType = issues.stream()
|
||||||
|
.collect(Collectors.groupingBy(SourceIssue::getType, LinkedHashMap::new, Collectors.toList()));
|
||||||
|
if (byType.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
Map<String, DictTree> dictTreeByCode = dictTreeService.lambdaQuery()
|
||||||
|
.in(DictTree::getCode, byType.keySet())
|
||||||
|
.list()
|
||||||
|
.stream()
|
||||||
|
.collect(Collectors.toMap(DictTree::getCode, dictTree -> dictTree, (left, right) -> left));
|
||||||
|
return byType.entrySet().stream().map(entry -> {
|
||||||
|
List<SourceIssue> typeIssues = entry.getValue();
|
||||||
|
boolean completed = completedTypes.contains(entry.getKey());
|
||||||
|
DictTree dictTree = dictTreeByCode.get(entry.getKey());
|
||||||
|
FormalProgressVO.TableRow row = new FormalProgressVO.TableRow();
|
||||||
|
row.setScriptCode(entry.getKey());
|
||||||
|
row.setScriptName(dictTree.getName());
|
||||||
|
row.setScriptType(dictTree.getId());
|
||||||
|
row.setDevices(completed
|
||||||
|
? buildCompletedDeviceResults(param, devIds, typeIssues)
|
||||||
|
: buildUnknownDeviceResults(devIds));
|
||||||
|
return row;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<FormalProgressVO.DeviceResult> buildUnknownDeviceResults(List<String> devIds) {
|
||||||
|
return pqDevService.getDevInfo(devIds).stream().map(dev -> {
|
||||||
|
FormalProgressVO.DeviceResult item = new FormalProgressVO.DeviceResult();
|
||||||
|
item.setDeviceId(dev.getDevId());
|
||||||
|
item.setDeviceName(dev.getDevName());
|
||||||
|
item.setChnResult(dev.getMonitorList().stream().map(monitor -> -1).collect(Collectors.toList()));
|
||||||
|
return item;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<FormalProgressVO.DeviceResult> buildCompletedDeviceResults(PreDetectionParam param,
|
||||||
|
List<String> devIds,
|
||||||
|
List<SourceIssue> typeIssues) {
|
||||||
|
List<Integer> sorts = typeIssues.stream().map(SourceIssue::getIndex).distinct().collect(Collectors.toList());
|
||||||
|
List<SimAndDigBaseResult> rows = new ArrayList<>();
|
||||||
|
rows.addAll(harmonicService.listByDevIdsAndSorts(param.getCode(), param.getScriptId(), devIds, sorts));
|
||||||
|
rows.addAll(nonHarmonicService.listByDevIdsAndSorts(param.getCode(), param.getScriptId(), devIds, sorts));
|
||||||
|
|
||||||
|
Map<String, List<Integer>> flagMap = rows.stream()
|
||||||
|
.filter(row -> row.getResultFlag() != null)
|
||||||
|
.collect(Collectors.groupingBy(SimAndDigBaseResult::getDevMonitorId,
|
||||||
|
Collectors.mapping(SimAndDigBaseResult::getResultFlag, Collectors.toList())));
|
||||||
|
|
||||||
|
return pqDevService.getDevInfo(devIds).stream().map(dev -> {
|
||||||
|
FormalProgressVO.DeviceResult item = new FormalProgressVO.DeviceResult();
|
||||||
|
item.setDeviceId(dev.getDevId());
|
||||||
|
item.setDeviceName(dev.getDevName());
|
||||||
|
item.setChnResult(dev.getMonitorList().stream()
|
||||||
|
.map(monitor -> mergeResultFlags(resolveResultFlags(flagMap, dev, monitor)))
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
return item;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Integer> resolveResultFlags(Map<String, List<Integer>> flagMap, PreDetection dev, PreDetection.MonitorListDTO monitor) {
|
||||||
|
List<Integer> flags = new ArrayList<>();
|
||||||
|
List<Integer> byDevLine = flagMap.get(dev.getDevId() + "_" + monitor.getLine());
|
||||||
|
if (CollUtil.isNotEmpty(byDevLine)) {
|
||||||
|
flags.addAll(byDevLine);
|
||||||
|
}
|
||||||
|
List<Integer> byLineId = flagMap.get(monitor.getLineId());
|
||||||
|
if (CollUtil.isNotEmpty(byLineId)) {
|
||||||
|
flags.addAll(byLineId);
|
||||||
|
}
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer mergeResultFlags(List<Integer> flags) {
|
||||||
|
if (CollUtil.isEmpty(flags)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
List<Integer> effective = flags.stream()
|
||||||
|
.filter(flag -> flag != null && flag != 4 && flag != 5)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollUtil.isNotEmpty(effective)) {
|
||||||
|
return effective.stream().max(Integer::compareTo).orElse(1);
|
||||||
|
}
|
||||||
|
return flags.get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,8 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.gather.detection.handler.SocketContrastResponseService;
|
import com.njcn.gather.detection.handler.SocketContrastResponseService;
|
||||||
import com.njcn.gather.detection.handler.SocketDevResponseService;
|
import com.njcn.gather.detection.handler.SocketDevResponseService;
|
||||||
@@ -14,9 +16,12 @@ import com.njcn.gather.detection.pojo.constant.DetectionCommunicateConstant;
|
|||||||
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
|
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
|
||||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||||
import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
|
import com.njcn.gather.detection.pojo.param.ContrastDetectionParam;
|
||||||
|
import com.njcn.gather.detection.pojo.param.FormalProgressParam;
|
||||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||||
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
||||||
|
import com.njcn.gather.detection.pojo.vo.FormalProgressVO;
|
||||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||||
|
import com.njcn.gather.detection.service.FormalProgressService;
|
||||||
import com.njcn.gather.detection.service.PreDetectionService;
|
import com.njcn.gather.detection.service.PreDetectionService;
|
||||||
import com.njcn.gather.detection.util.business.DetectionCommunicateUtil;
|
import com.njcn.gather.detection.util.business.DetectionCommunicateUtil;
|
||||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||||
@@ -25,15 +30,20 @@ import com.njcn.gather.detection.util.socket.SocketManager;
|
|||||||
import com.njcn.gather.detection.util.socket.XiNumberManager;
|
import com.njcn.gather.detection.util.socket.XiNumberManager;
|
||||||
import com.njcn.gather.detection.util.socket.cilent.NettyContrastClientHandler;
|
import com.njcn.gather.detection.util.socket.cilent.NettyContrastClientHandler;
|
||||||
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
||||||
|
import com.njcn.gather.device.pojo.enums.CheckResultEnum;
|
||||||
|
import com.njcn.gather.device.pojo.enums.CheckStateEnum;
|
||||||
|
import com.njcn.gather.device.pojo.enums.CommonEnum;
|
||||||
import com.njcn.gather.device.pojo.po.PqDev;
|
import com.njcn.gather.device.pojo.po.PqDev;
|
||||||
|
import com.njcn.gather.device.pojo.po.PqDevSub;
|
||||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||||
import com.njcn.gather.device.service.IPqDevService;
|
import com.njcn.gather.device.service.IPqDevService;
|
||||||
|
import com.njcn.gather.device.service.IPqDevSubService;
|
||||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||||
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
||||||
import com.njcn.gather.plan.service.IAdPlanService;
|
import com.njcn.gather.plan.service.IAdPlanService;
|
||||||
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
||||||
import com.njcn.gather.result.pojo.enums.ResultUnitEnum;
|
import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
|
||||||
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
||||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||||
@@ -41,6 +51,8 @@ import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
|||||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||||
import com.njcn.gather.source.pojo.po.SourceInitialize;
|
import com.njcn.gather.source.pojo.po.SourceInitialize;
|
||||||
import com.njcn.gather.source.service.IPqSourceService;
|
import com.njcn.gather.source.service.IPqSourceService;
|
||||||
|
import com.njcn.gather.storage.service.SimAndDigHarmonicService;
|
||||||
|
import com.njcn.gather.storage.service.SimAndDigNonHarmonicService;
|
||||||
import com.njcn.gather.system.cfg.service.ISysTestConfigService;
|
import com.njcn.gather.system.cfg.service.ISysTestConfigService;
|
||||||
import com.njcn.gather.system.config.PathConfig;
|
import com.njcn.gather.system.config.PathConfig;
|
||||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||||
@@ -50,7 +62,6 @@ import com.njcn.web.utils.RequestUtil;
|
|||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.servlet.ServletOutputStream;
|
import javax.servlet.ServletOutputStream;
|
||||||
@@ -82,9 +93,13 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
private final IPqScriptCheckDataService iPqScriptCheckDataService;
|
private final IPqScriptCheckDataService iPqScriptCheckDataService;
|
||||||
private final SocketManager socketManager;
|
private final SocketManager socketManager;
|
||||||
private final ISysTestConfigService sysTestConfigService;
|
private final ISysTestConfigService sysTestConfigService;
|
||||||
|
private final FormalProgressService formalProgressService;
|
||||||
|
private final IPqDevSubService pqDevSubService;
|
||||||
|
private final SimAndDigHarmonicService harmonicService;
|
||||||
|
private final SimAndDigNonHarmonicService nonHarmonicService;
|
||||||
|
|
||||||
|
|
||||||
// @Value("${report.reportDir}")
|
// @Value("${report.reportDir}")
|
||||||
// private String alignDataFilePath;
|
// private String alignDataFilePath;
|
||||||
private final PathConfig pathConfig;
|
private final PathConfig pathConfig;
|
||||||
|
|
||||||
@@ -103,6 +118,28 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
param.setScriptId(plan.getScriptId());
|
param.setScriptId(plan.getScriptId());
|
||||||
param.setErrorSysId(plan.getErrorSysId());
|
param.setErrorSysId(plan.getErrorSysId());
|
||||||
param.setCode(String.valueOf(plan.getCode()));
|
param.setCode(String.valueOf(plan.getCode()));
|
||||||
|
if (param.isFormalTestSelected()) {
|
||||||
|
List<PqDevSub> devSubs = pqDevSubService.lambdaQuery()
|
||||||
|
.in(PqDevSub::getDevId, param.getDevIds())
|
||||||
|
.list();
|
||||||
|
boolean hasSaved = devSubs.stream().anyMatch(this::isSavedFormalProgress);
|
||||||
|
if (param.isResumeFormal() && !hasSaved) {
|
||||||
|
throw new BusinessException(CommonResponseEnum.FAIL, "未找到正式检测暂存进度");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (param.isFormalTestSelected() && !param.isResumeFormal()) {
|
||||||
|
FormalTestManager.resumeBaseFormalCheckTime = null;
|
||||||
|
FormalTestManager.resumeFormalStartTime = null;
|
||||||
|
FormalTestManager.resumeNextSort = null;
|
||||||
|
FormalTestManager.resumeFormalPending = false;
|
||||||
|
}
|
||||||
|
if (param.isFormalTestSelected() && param.isResumeFormal()) {
|
||||||
|
FormalTestManager.resumeBaseFormalCheckTime = iPqDevService.getMinFormalCheckTime(param.getDevIds());
|
||||||
|
pqDevSubService.lambdaUpdate()
|
||||||
|
.set(PqDevSub::getCheckState, CheckStateEnum.CHECKING.getValue())
|
||||||
|
.in(PqDevSub::getDevId, param.getDevIds())
|
||||||
|
.update();
|
||||||
|
}
|
||||||
if (ObjectUtil.isNotNull(plan)) {
|
if (ObjectUtil.isNotNull(plan)) {
|
||||||
String code = dictDataService.getDictDataById(plan.getPattern()).getCode();
|
String code = dictDataService.getDictDataById(plan.getPattern()).getCode();
|
||||||
DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code);
|
DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code);
|
||||||
@@ -247,33 +284,254 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean restartTemTest(PreDetectionParam param) {
|
public boolean restartTemTest(PreDetectionParam param) {
|
||||||
|
PreDetectionParam runtimeParam = WebServiceManager.getPreDetectionParam(param.getUserPageId());
|
||||||
|
if (runtimeParam == null) {
|
||||||
|
if (StrUtil.isBlank(param.getSourceId()) || StrUtil.isBlank(param.getScriptId()) || StrUtil.isBlank(param.getCode())) {
|
||||||
|
throw new BusinessException(CommonResponseEnum.FAIL, "未找到暂停检测上下文,请重新开始检测");
|
||||||
|
}
|
||||||
|
runtimeParam = param;
|
||||||
|
}
|
||||||
FormalTestManager.stopFlag = false;
|
FormalTestManager.stopFlag = false;
|
||||||
socketDevResponseService.initRestart();
|
socketDevResponseService.initRestart();
|
||||||
List<SourceIssue> sourceIssueList = SocketManager.getSourceList();
|
List<SourceIssue> sourceIssueList = SocketManager.getSourceList();
|
||||||
SourceInitialize sourceInitialize = pqSourceService.getSourceInitializeParam(param.getSourceId());
|
if (StrUtil.isBlank(runtimeParam.getSourceName()) && StrUtil.isNotBlank(runtimeParam.getSourceId())) {
|
||||||
param.setSourceName(sourceInitialize.getSourceId());
|
SourceInitialize sourceInitialize = pqSourceService.getSourceInitializeParam(runtimeParam.getSourceId());
|
||||||
|
if (sourceInitialize == null) {
|
||||||
|
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
|
||||||
|
}
|
||||||
|
runtimeParam.setSourceName(sourceInitialize.getSourceId());
|
||||||
|
}
|
||||||
if (CollUtil.isNotEmpty(sourceIssueList)) {
|
if (CollUtil.isNotEmpty(sourceIssueList)) {
|
||||||
SourceIssue sourceIssues = SocketManager.getSourceList().get(0);
|
SourceIssue sourceIssues = SocketManager.getSourceList().get(0);
|
||||||
|
String type = resolveFormalIssueType(sourceIssues);
|
||||||
|
sendBigItemStartIfFirstFormalIssue(runtimeParam, sourceIssues, type);
|
||||||
|
if (StrUtil.isNotBlank(sourceIssues.getOtherType())) {
|
||||||
|
sourceIssues.setType(PowerIndexEnum.V.getKey());
|
||||||
|
}
|
||||||
SocketMsg<String> xuMsg = new SocketMsg<>();
|
SocketMsg<String> xuMsg = new SocketMsg<>();
|
||||||
xuMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
xuMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||||
xuMsg.setData(JSON.toJSONString(sourceIssues));
|
xuMsg.setData(JSON.toJSONString(sourceIssues));
|
||||||
xuMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + "&&" + sourceIssues.getType());
|
xuMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + "&&" + type);
|
||||||
SocketManager.sendMsg(param.getUserPageId() + DetectionCommunicateConstant.SOURCE, JSON.toJSONString(xuMsg));
|
SocketManager.sendMsg(runtimeParam.getUserPageId() + DetectionCommunicateConstant.SOURCE, JSON.toJSONString(xuMsg));
|
||||||
// Resume_Success
|
// Resume_Success
|
||||||
} else {
|
} else {
|
||||||
//TODO 是否最终检测完成需要推送给用户 检测完成
|
//TODO 是否最终检测完成需要推送给用户 检测完成
|
||||||
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
|
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
|
||||||
checkDataParam.setScriptId(param.getScriptId());
|
checkDataParam.setScriptId(runtimeParam.getScriptId());
|
||||||
checkDataParam.setIsValueTypeName(false);
|
checkDataParam.setIsValueTypeName(false);
|
||||||
List<String> adType = iPqScriptCheckDataService.getValueType(checkDataParam);
|
List<String> adType = iPqScriptCheckDataService.getValueType(checkDataParam);
|
||||||
|
|
||||||
iPqDevService.updateResult(param.getDevIds(), adType, param.getCode(), param.getUserId(), param.getTemperature(), param.getHumidity(), true);
|
iPqDevService.updateResult(runtimeParam.getDevIds(), adType, runtimeParam.getCode(), runtimeParam.getUserId(), runtimeParam.getTemperature(), runtimeParam.getHumidity(), true);
|
||||||
CnSocketUtil.quitSend(param);
|
CnSocketUtil.quitSend(runtimeParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveFormalProgress(FormalProgressParam param) {
|
||||||
|
if (param.getFormalCheckTime() == null) {
|
||||||
|
throw new BusinessException(CommonResponseEnum.FAIL, "正式检测耗时不能为空");
|
||||||
|
}
|
||||||
|
PreDetectionParam preParam = WebServiceManager.getPreDetectionParam(param.getUserPageId());
|
||||||
|
Map<String, Integer> checkResultMap = summarizeSavedFormalCheckResult(param, preParam);
|
||||||
|
Integer formalCheckTime = Math.max(param.getFormalCheckTime(), 1);
|
||||||
|
Map<Integer, List<String>> devIdsByResult = param.getDevIds().stream()
|
||||||
|
.collect(Collectors.groupingBy(devId -> checkResultMap.getOrDefault(devId, CheckResultEnum.UNCHECKED.getValue())));
|
||||||
|
devIdsByResult.forEach((checkResult, devIds) -> pqDevSubService.update(new LambdaUpdateWrapper<PqDevSub>()
|
||||||
|
.set(PqDevSub::getCheckState, CheckStateEnum.CHECKING.getValue())
|
||||||
|
.set(PqDevSub::getFormalCheckTime, formalCheckTime)
|
||||||
|
.set(PqDevSub::getCheckResult, checkResult)
|
||||||
|
.in(PqDevSub::getDevId, devIds)));
|
||||||
|
refreshPlanTestState(param.getPlanId());
|
||||||
|
|
||||||
|
if (preParam != null) {
|
||||||
|
CnSocketUtil.quitSend(preParam);
|
||||||
|
}
|
||||||
|
SocketManager.clearFormalRuntime();
|
||||||
|
FormalTestManager.clearFormalRuntime();
|
||||||
|
WebServiceManager.removePreDetectionParam(param.getUserPageId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FormalProgressVO formalProgress(FormalProgressParam param) {
|
||||||
|
return formalProgressService.restoreAndRelease(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Integer> summarizeSavedFormalCheckResult(FormalProgressParam param, PreDetectionParam preParam) {
|
||||||
|
Map<String, Integer> result = new HashMap<>();
|
||||||
|
if (CollUtil.isEmpty(param.getDevIds())) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
param.getDevIds().forEach(devId -> result.put(devId, CheckResultEnum.UNCHECKED.getValue()));
|
||||||
|
|
||||||
|
AdPlan plan = iAdPlanService.getById(param.getPlanId());
|
||||||
|
String code = preParam != null && StrUtil.isNotBlank(preParam.getCode())
|
||||||
|
? preParam.getCode()
|
||||||
|
: plan != null && plan.getCode() != null ? String.valueOf(plan.getCode()) : null;
|
||||||
|
String scriptId = preParam != null && StrUtil.isNotBlank(preParam.getScriptId())
|
||||||
|
? preParam.getScriptId()
|
||||||
|
: plan != null ? plan.getScriptId() : null;
|
||||||
|
if (StrUtil.isBlank(code) || StrUtil.isBlank(scriptId)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Integer> completedSorts = resolveCompletedFormalSorts(preParam);
|
||||||
|
if (completedSorts != null && CollUtil.isEmpty(completedSorts)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, List<Integer>> resultFlags = new HashMap<>();
|
||||||
|
mergeResultFlags(resultFlags, nonHarmonicService.resultFlagsByDevIdsAndSorts(code, scriptId, param.getDevIds(), completedSorts));
|
||||||
|
mergeResultFlags(resultFlags, harmonicService.resultFlagsByDevIdsAndSorts(code, scriptId, param.getDevIds(), completedSorts));
|
||||||
|
param.getDevIds().forEach(devId -> result.put(devId, toCheckResult(resultFlags.get(devId))));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Integer> resolveCompletedFormalSorts(PreDetectionParam preParam) {
|
||||||
|
if (preParam == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
List<SourceIssue> allIssues = buildAllFormalIssues(preParam);
|
||||||
|
if (CollUtil.isEmpty(allIssues)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
List<SourceIssue> remainingIssues = SocketManager.getSourceList();
|
||||||
|
Set<Integer> remainingSorts = CollUtil.isEmpty(remainingIssues)
|
||||||
|
? Collections.emptySet()
|
||||||
|
: remainingIssues.stream()
|
||||||
|
.map(SourceIssue::getIndex)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
return allIssues.stream()
|
||||||
|
.map(SourceIssue::getIndex)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.filter(sort -> !remainingSorts.contains(sort))
|
||||||
|
.distinct()
|
||||||
|
.sorted()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SourceIssue> buildAllFormalIssues(PreDetectionParam param) {
|
||||||
|
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||||
|
issueParam.setPlanId(param.getPlanId());
|
||||||
|
issueParam.setSourceId(param.getSourceName());
|
||||||
|
issueParam.setDevIds(param.getDevIds());
|
||||||
|
issueParam.setScriptId(param.getScriptId());
|
||||||
|
issueParam.setIsPhaseSequence(CommonEnum.FORMAL_TEST.getValue());
|
||||||
|
return pqScriptDtlsService.listSourceIssue(issueParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendBigItemStartIfFirstFormalIssue(PreDetectionParam param, SourceIssue currentIssue, String type) {
|
||||||
|
if (param == null || currentIssue == null || currentIssue.getIndex() == null || StrUtil.isBlank(type)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<SourceIssue> allIssues = buildAllFormalIssues(param);
|
||||||
|
if (isFirstFormalIssueOfBigItem(allIssues, currentIssue, type)) {
|
||||||
|
WebServiceManager.sendDetectionMessage(param.getUserPageId(), type + CnSocketUtil.START_TAG, null, new ArrayList<>(), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean isFirstFormalIssueOfBigItem(List<SourceIssue> allIssues, SourceIssue currentIssue, String type) {
|
||||||
|
if (CollUtil.isEmpty(allIssues) || currentIssue == null || currentIssue.getIndex() == null || StrUtil.isBlank(type)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Integer firstSort = allIssues.stream()
|
||||||
|
.filter(issue -> type.equals(resolveFormalIssueType(issue)))
|
||||||
|
.map(SourceIssue::getIndex)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.min(Integer::compareTo)
|
||||||
|
.orElse(null);
|
||||||
|
return Objects.equals(firstSort, currentIssue.getIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
static String resolveFormalIssueType(SourceIssue issue) {
|
||||||
|
if (issue == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return StrUtil.isNotBlank(issue.getOtherType()) ? issue.getOtherType() : issue.getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mergeResultFlags(Map<String, List<Integer>> target, Map<String, List<Integer>> source) {
|
||||||
|
if (CollUtil.isEmpty(source)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
source.forEach((devId, flags) -> target.computeIfAbsent(devId, key -> new ArrayList<>()).addAll(flags));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer toCheckResult(List<Integer> resultFlags) {
|
||||||
|
if (CollUtil.isEmpty(resultFlags)) {
|
||||||
|
return CheckResultEnum.UNCHECKED.getValue();
|
||||||
|
}
|
||||||
|
List<Integer> effectiveFlags = resultFlags.stream()
|
||||||
|
.filter(flag -> flag != null && flag != 4 && flag != 5)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollUtil.isEmpty(effectiveFlags)) {
|
||||||
|
return CheckResultEnum.ACCORD.getValue();
|
||||||
|
}
|
||||||
|
boolean hasFailed = effectiveFlags.stream().anyMatch(flag -> !Objects.equals(flag, 1));
|
||||||
|
return hasFailed ? CheckResultEnum.NOT_ACCORD.getValue() : CheckResultEnum.ACCORD.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isSavedFormalProgress(PqDevSub dev) {
|
||||||
|
return CheckStateEnum.CHECKING.getValue().equals(dev.getCheckState())
|
||||||
|
&& ObjectUtil.isNotNull(dev.getFormalCheckTime())
|
||||||
|
&& dev.getFormalCheckTime() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshPlanTestState(String planId) {
|
||||||
|
if (StrUtil.isBlank(planId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<String> planDevIds = iPqDevService.lambdaQuery()
|
||||||
|
.eq(PqDev::getPlanId, planId)
|
||||||
|
.list()
|
||||||
|
.stream()
|
||||||
|
.map(PqDev::getId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollUtil.isEmpty(planDevIds)) {
|
||||||
|
iAdPlanService.lambdaUpdate()
|
||||||
|
.set(AdPlan::getTestState, CheckStateEnum.UNCHECKED.getValue())
|
||||||
|
.set(AdPlan::getResult, CheckResultEnum.UNCHECKED.getValue())
|
||||||
|
.eq(AdPlan::getId, planId)
|
||||||
|
.update();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<PqDevSub> devSubs = pqDevSubService.lambdaQuery()
|
||||||
|
.in(PqDevSub::getDevId, planDevIds)
|
||||||
|
.list();
|
||||||
|
boolean allUnchecked = devSubs.stream()
|
||||||
|
.allMatch(dev -> CheckStateEnum.UNCHECKED.getValue().equals(dev.getCheckState()));
|
||||||
|
boolean allArchived = CollUtil.isNotEmpty(devSubs) && devSubs.stream()
|
||||||
|
.allMatch(dev -> dev.getCheckState() != null && dev.getCheckState() >= CheckStateEnum.DOCUMENTED.getValue());
|
||||||
|
Integer testState = allUnchecked
|
||||||
|
? CheckStateEnum.UNCHECKED.getValue()
|
||||||
|
: allArchived ? CheckStateEnum.CHECKED.getValue() : CheckStateEnum.CHECKING.getValue();
|
||||||
|
Integer planResult = resolvePlanCheckResult(devSubs);
|
||||||
|
iAdPlanService.lambdaUpdate()
|
||||||
|
.set(AdPlan::getTestState, testState)
|
||||||
|
.set(AdPlan::getResult, planResult)
|
||||||
|
.eq(AdPlan::getId, planId)
|
||||||
|
.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer resolvePlanCheckResult(List<PqDevSub> devSubs) {
|
||||||
|
if (CollUtil.isEmpty(devSubs)) {
|
||||||
|
return CheckResultEnum.UNCHECKED.getValue();
|
||||||
|
}
|
||||||
|
Set<Integer> resultSet = devSubs.stream()
|
||||||
|
.map(PqDevSub::getCheckResult)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
if (resultSet.contains(CheckResultEnum.NOT_ACCORD.getValue())) {
|
||||||
|
return CheckResultEnum.NOT_ACCORD.getValue();
|
||||||
|
}
|
||||||
|
if (resultSet.contains(CheckResultEnum.UNCHECKED.getValue()) || CollUtil.isEmpty(resultSet)) {
|
||||||
|
return CheckResultEnum.UNCHECKED.getValue();
|
||||||
|
}
|
||||||
|
return CheckResultEnum.ACCORD.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ytxCheckSimulate(SimulateDetectionParam param) {
|
public void ytxCheckSimulate(SimulateDetectionParam param) {
|
||||||
PreDetectionParam preDetectionParam = new PreDetectionParam();
|
PreDetectionParam preDetectionParam = new PreDetectionParam();
|
||||||
@@ -312,7 +570,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
SourceIssue sourceIssue = sourceIssues.get(0);
|
SourceIssue sourceIssue = sourceIssues.get(0);
|
||||||
String type = sourceIssue.getType();
|
String type = sourceIssue.getType();
|
||||||
if (StrUtil.isNotBlank(sourceIssue.getOtherType())) {
|
if (StrUtil.isNotBlank(sourceIssue.getOtherType())) {
|
||||||
sourceIssue.setType(ResultUnitEnum.V_ABSOLUTELY.getCode());
|
sourceIssue.setType(PowerIndexEnum.V.getKey());
|
||||||
type = sourceIssue.getOtherType();
|
type = sourceIssue.getOtherType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -220,9 +220,29 @@ public class FormalTestManager {
|
|||||||
*/
|
*/
|
||||||
public static LocalDateTime checkStartTime;
|
public static LocalDateTime checkStartTime;
|
||||||
|
|
||||||
|
public static boolean resumeFormalPending;
|
||||||
|
|
||||||
|
public static Integer resumeNextSort;
|
||||||
|
|
||||||
|
public static Integer resumeBaseFormalCheckTime;
|
||||||
|
|
||||||
|
public static LocalDateTime resumeFormalStartTime;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数模式 检测类型"1"-"全部检测" , "2"-"不合格项复检"
|
* 数模式 检测类型"1"-"全部检测" , "2"-"不合格项复检"
|
||||||
*/
|
*/
|
||||||
public static String reCheckType;
|
public static String reCheckType;
|
||||||
|
|
||||||
|
public static void clearFormalRuntime() {
|
||||||
|
stopFlag = false;
|
||||||
|
hasStopFlag = false;
|
||||||
|
stopTime = 0;
|
||||||
|
resumeFormalPending = false;
|
||||||
|
resumeNextSort = null;
|
||||||
|
resumeBaseFormalCheckTime = null;
|
||||||
|
resumeFormalStartTime = null;
|
||||||
|
realDataXiList.clear();
|
||||||
|
currentIssue = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -343,6 +343,11 @@ public class SocketManager {
|
|||||||
return targetMap.get(scriptType);
|
return targetMap.get(scriptType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clearFormalRuntime() {
|
||||||
|
sourceIssueList.clear();
|
||||||
|
targetMap.clear();
|
||||||
|
valueTypeMap.clear();
|
||||||
|
clockMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,8 +15,8 @@ import com.njcn.gather.detection.util.socket.FormalTestManager;
|
|||||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||||
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
import com.njcn.gather.detection.util.socket.websocket.WebServiceManager;
|
||||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||||
|
import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
|
||||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||||
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.SimpleChannelInboundHandler;
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
@@ -55,17 +55,17 @@ import java.util.stream.Collectors;
|
|||||||
public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 闪变检测超时时间:20分钟(1300秒)
|
* 短闪检测超时时间:20分钟+100秒(1300秒)
|
||||||
*/
|
*/
|
||||||
private static final long FLICKER_TIMEOUT = 1300L;
|
private static final long SHORT_FLICKER_TIMEOUT = 1300L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计数据检测超时时间:3分钟(180秒)
|
* 统计数据检测超时时间:3分钟+100秒(190秒)
|
||||||
*/
|
*/
|
||||||
private static final long STATISTICS_TIMEOUT = 180L;
|
private static final long STATISTICS_TIMEOUT = 190L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实时数据检测超时时间:1分钟(60秒)
|
* 实时数据检测超时时间:1分钟*3
|
||||||
*/
|
*/
|
||||||
private static final long REALTIME_TIMEOUT = 60 * 3L;
|
private static final long REALTIME_TIMEOUT = 60 * 3L;
|
||||||
|
|
||||||
@@ -305,10 +305,10 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
|||||||
String type = sourceIssue.getType();
|
String type = sourceIssue.getType();
|
||||||
|
|
||||||
// 根据不同检测类型使用不同的超时阈值
|
// 根据不同检测类型使用不同的超时阈值
|
||||||
if (DicDataEnum.F.getCode().equals(type)) {
|
if (PowerIndexEnum.F.getKey().equals(type)) {
|
||||||
// 闪变检测:需要更长时间,20分钟超时
|
// 闪变检测:需要更长时间,20分钟超时
|
||||||
return currentTime >= FLICKER_TIMEOUT;
|
return currentTime >= SHORT_FLICKER_TIMEOUT;
|
||||||
} else if (DicDataEnum.VOLTAGE.getCode().equals(type) || DicDataEnum.HP.getCode().equals(type)) {
|
} else if (PowerIndexEnum.VOLTAGE.getKey().equals(type) || PowerIndexEnum.HP.getKey().equals(type)) {
|
||||||
// 统计数据类型(电压、谐波):中等时间,3分钟超时
|
// 统计数据类型(电压、谐波):中等时间,3分钟超时
|
||||||
return currentTime >= STATISTICS_TIMEOUT;
|
return currentTime >= STATISTICS_TIMEOUT;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -371,7 +371,7 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
|
|||||||
if (ObjectUtil.isNotNull(preDetectionParam)) {
|
if (ObjectUtil.isNotNull(preDetectionParam)) {
|
||||||
// 使用该用户的检测参数关闭Socket连接
|
// 使用该用户的检测参数关闭Socket连接
|
||||||
log.info("使用用户检测参数关闭Socket连接,userId: {}", userId);
|
log.info("使用用户检测参数关闭Socket连接,userId: {}", userId);
|
||||||
if (PatternEnum.CONTRAST.equals(FormalTestManager.patternEnum)) {
|
if (FormalTestManager.patternEnum.equals(PatternEnum.CONTRAST)) {
|
||||||
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
|
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
|
||||||
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_02, false);
|
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_02, false);
|
||||||
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_03, false);
|
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_03, false);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public enum CheckStateEnum {
|
|||||||
CHECKING("检测中", 1),
|
CHECKING("检测中", 1),
|
||||||
CHECKED("检测完成", 2),
|
CHECKED("检测完成", 2),
|
||||||
/**
|
/**
|
||||||
* 检测计划没有该状态,只有未检、检测中、检测完成三种状态。被检设备有这种状态
|
* 检测计划没有归档状态,只有未检、检测中、检测完成三种状态。被检设备有归档状态
|
||||||
*/
|
*/
|
||||||
DOCUMENTED("归档", 3);
|
DOCUMENTED("归档", 3);
|
||||||
|
|
||||||
|
|||||||
@@ -129,6 +129,13 @@ public interface IPqDevService extends IService<PqDev> {
|
|||||||
*/
|
*/
|
||||||
boolean updateResult(List<String> ids, List<String> adType, String code, String userId, Float temperature, Float humidity, boolean updateCheckNum);
|
boolean updateResult(List<String> ids, List<String> adType, String code, String userId, Float temperature, Float humidity, boolean updateCheckNum);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新一轮正式检测真正开始前,仅清理原检测中设备的暂存耗时,并把本次设备置为检测中。
|
||||||
|
*/
|
||||||
|
void clearFormalProgressForNewRun(List<String> devIds);
|
||||||
|
|
||||||
|
Integer getMinFormalCheckTime(List<String> devIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 比对式-修改设备状态
|
* 比对式-修改设备状态
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -367,24 +367,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
List<String> notUnchecked = list.stream().filter(x -> !CheckStateEnum.UNCHECKED.getValue().equals(x.getCheckState())).map(PqDevSub::getDevId).distinct().collect(Collectors.toList());
|
List<String> notUnchecked = list.stream().filter(x -> !CheckStateEnum.UNCHECKED.getValue().equals(x.getCheckState())).map(PqDevSub::getDevId).distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
if (CollUtil.isNotEmpty(notUnchecked)) {
|
if (CollUtil.isNotEmpty(notUnchecked)) {
|
||||||
List<String> unchecked = list.stream().filter(x -> CheckStateEnum.UNCHECKED.getValue().equals(x.getCheckState())).map(PqDevSub::getDevId).distinct().collect(Collectors.toList());
|
boolean allArchived = list.stream().allMatch(x -> x.getCheckState() != null && x.getCheckState() >= CheckStateEnum.DOCUMENTED.getValue());
|
||||||
//计划未检测
|
return allArchived ? CheckStateEnum.CHECKED.getValue() : CheckStateEnum.CHECKING.getValue();
|
||||||
if (CollUtil.isNotEmpty(unchecked)) {
|
|
||||||
return CheckStateEnum.CHECKING.getValue();
|
|
||||||
}
|
|
||||||
//计划检测中
|
|
||||||
List<String> checking = list.stream().filter(x -> x.getCheckState().equals(CheckStateEnum.CHECKED.getValue()) &&
|
|
||||||
!CheckStateEnum.DOCUMENTED.getValue().equals(x.getCheckState())
|
|
||||||
).map(PqDevSub::getDevId).distinct().collect(Collectors.toList());
|
|
||||||
if (checking.size() == notUnchecked.size()) {
|
|
||||||
return CheckStateEnum.CHECKING.getValue();
|
|
||||||
}
|
|
||||||
//检测完成
|
|
||||||
List<String> checked = list.stream().filter(x -> CheckStateEnum.DOCUMENTED.getValue().equals(x.getCheckState())).map(PqDevSub::getDevId).distinct().collect(Collectors.toList());
|
|
||||||
if (checked.size() == notUnchecked.size()) {
|
|
||||||
return CheckStateEnum.CHECKED.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CheckStateEnum.UNCHECKED.getValue();
|
return CheckStateEnum.UNCHECKED.getValue();
|
||||||
@@ -547,6 +531,45 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
return preDetections;
|
return preDetections;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearFormalProgressForNewRun(List<String> devIds) {
|
||||||
|
if (CollUtil.isEmpty(devIds)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<PqDevSub> devSubs = pqDevSubService.lambdaQuery()
|
||||||
|
.in(PqDevSub::getDevId, devIds)
|
||||||
|
.list();
|
||||||
|
List<String> resetFormalCheckIds = devSubs.stream()
|
||||||
|
.filter(dev -> CheckStateEnum.CHECKING.getValue().equals(dev.getCheckState()))
|
||||||
|
.map(PqDevSub::getDevId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollUtil.isNotEmpty(resetFormalCheckIds)) {
|
||||||
|
pqDevSubService.lambdaUpdate()
|
||||||
|
.set(PqDevSub::getFormalCheckTime, 0)
|
||||||
|
.in(PqDevSub::getDevId, resetFormalCheckIds)
|
||||||
|
.update();
|
||||||
|
}
|
||||||
|
pqDevSubService.lambdaUpdate()
|
||||||
|
.set(PqDevSub::getCheckState, CheckStateEnum.CHECKING.getValue())
|
||||||
|
.in(PqDevSub::getDevId, devIds)
|
||||||
|
.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getMinFormalCheckTime(List<String> devIds) {
|
||||||
|
if (CollUtil.isEmpty(devIds)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return pqDevSubService.lambdaQuery()
|
||||||
|
.in(PqDevSub::getDevId, devIds)
|
||||||
|
.list()
|
||||||
|
.stream()
|
||||||
|
.map(PqDevSub::getFormalCheckTime)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.min(Integer::compareTo)
|
||||||
|
.orElse(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateResult(List<String> ids, List<String> adType, String code, String userId, Float temperature, Float humidity, boolean updateCheckNum) {
|
public boolean updateResult(List<String> ids, List<String> adType, String code, String userId, Float temperature, Float humidity, boolean updateCheckNum) {
|
||||||
@@ -590,6 +613,21 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
}
|
}
|
||||||
wrapper.set(PqDevSub::getReportState, DevReportStateEnum.NOT_GENERATED.getValue());
|
wrapper.set(PqDevSub::getReportState, DevReportStateEnum.NOT_GENERATED.getValue());
|
||||||
}
|
}
|
||||||
|
if (ObjectUtil.isNotNull(FormalTestManager.resumeBaseFormalCheckTime)
|
||||||
|
&& ObjectUtil.isNotNull(FormalTestManager.resumeFormalStartTime)) {
|
||||||
|
int elapsedSeconds = (int) java.time.Duration.between(
|
||||||
|
FormalTestManager.resumeFormalStartTime,
|
||||||
|
LocalDateTime.now()
|
||||||
|
).getSeconds();
|
||||||
|
wrapper.set(PqDevSub::getFormalCheckTime,
|
||||||
|
FormalTestManager.resumeBaseFormalCheckTime + Math.max(elapsedSeconds, 0));
|
||||||
|
} else if (updateCheckNum && ObjectUtil.isNotNull(FormalTestManager.checkStartTime)) {
|
||||||
|
int elapsedSeconds = (int) java.time.Duration.between(
|
||||||
|
FormalTestManager.checkStartTime,
|
||||||
|
LocalDateTime.now()
|
||||||
|
).getSeconds();
|
||||||
|
wrapper.set(PqDevSub::getFormalCheckTime, Math.max(elapsedSeconds, 0));
|
||||||
|
}
|
||||||
wrapper.set(PqDevSub::getRecheckNum, i)
|
wrapper.set(PqDevSub::getRecheckNum, i)
|
||||||
.set(PqDevSub::getCheckState, checkState);
|
.set(PqDevSub::getCheckState, checkState);
|
||||||
pqDevSubService.update(wrapper);
|
pqDevSubService.update(wrapper);
|
||||||
@@ -608,19 +646,14 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
this.baseMapper.updatePlanCheckResult(pqDevVo.getPlanId(), CheckResultEnum.ACCORD.getValue());
|
this.baseMapper.updatePlanCheckResult(pqDevVo.getPlanId(), CheckResultEnum.ACCORD.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
set = pqDevVOList.stream().map(PqDevVO::getCheckState).collect(Collectors.toSet());
|
boolean allUnchecked = pqDevVOList.stream().allMatch(obj -> CheckStateEnum.UNCHECKED.getValue().equals(obj.getCheckState()));
|
||||||
if (set.contains(CheckStateEnum.UNCHECKED.getValue())) {
|
boolean allArchived = pqDevVOList.stream().allMatch(obj -> obj.getCheckState() != null && obj.getCheckState() >= CheckStateEnum.DOCUMENTED.getValue());
|
||||||
this.baseMapper.updatePlanTestState(pqDevVo.getPlanId(), CheckStateEnum.CHECKING.getValue());
|
if (allUnchecked) {
|
||||||
|
this.baseMapper.updatePlanTestState(pqDevVo.getPlanId(), CheckStateEnum.UNCHECKED.getValue());
|
||||||
|
} else if (allArchived) {
|
||||||
|
this.baseMapper.updatePlanTestState(pqDevVo.getPlanId(), CheckStateEnum.CHECKED.getValue());
|
||||||
} else {
|
} else {
|
||||||
if (checkState.equals(CheckStateEnum.DOCUMENTED.getValue())) {
|
this.baseMapper.updatePlanTestState(pqDevVo.getPlanId(), CheckStateEnum.CHECKING.getValue());
|
||||||
long count = pqDevVOList.stream().filter(obj -> !CheckStateEnum.DOCUMENTED.getValue().equals(obj.getCheckState())).count();
|
|
||||||
if (count == 0) {
|
|
||||||
// 如果非归档状态的设备数量为0,则更新计划已完成
|
|
||||||
this.baseMapper.finishPlan(pqDevVo.getPlanId());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.baseMapper.updatePlanTestState(pqDevVo.getPlanId(), CheckStateEnum.CHECKING.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -677,7 +710,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
List<PqDevVO> pqDevVOList = this.baseMapper.selectByQueryParam(param);
|
List<PqDevVO> pqDevVOList = this.baseMapper.selectByQueryParam(param);
|
||||||
|
|
||||||
if (CollUtil.isNotEmpty(pqDevVOList)) {
|
if (CollUtil.isNotEmpty(pqDevVOList)) {
|
||||||
Set<Integer> set = pqDevVOList.stream().filter(obj -> CheckStateEnum.CHECKED.getValue().equals(obj.getCheckState()) || CheckStateEnum.DOCUMENTED.getValue().equals(obj.getCheckState())).map(PqDevVO::getCheckResult).collect(Collectors.toSet());
|
Set<Integer> set = pqDevVOList.stream().filter(obj -> obj.getCheckState() != null && obj.getCheckState() >= CheckStateEnum.CHECKED.getValue()).map(PqDevVO::getCheckResult).collect(Collectors.toSet());
|
||||||
if (checkState == CheckStateEnum.CHECKED.getValue()) {
|
if (checkState == CheckStateEnum.CHECKED.getValue()) {
|
||||||
set.add(checkResult);
|
set.add(checkResult);
|
||||||
}
|
}
|
||||||
@@ -694,20 +727,22 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
set = pqDevVOList.stream().map(PqDevVO::getCheckState).collect(Collectors.toSet());
|
boolean allUnchecked = pqDevVOList.stream().allMatch(obj -> CheckStateEnum.UNCHECKED.getValue().equals(obj.getCheckState()));
|
||||||
if (set.contains(CheckStateEnum.UNCHECKED.getValue())) {
|
boolean allArchived = pqDevVOList.stream().allMatch(obj -> obj.getCheckState() != null && obj.getCheckState() >= CheckStateEnum.DOCUMENTED.getValue());
|
||||||
this.baseMapper.updatePlanTestState(planId, CheckStateEnum.CHECKING.getValue());
|
if (allUnchecked) {
|
||||||
} else if (set.contains(CheckStateEnum.CHECKING.getValue())) {
|
this.baseMapper.updatePlanTestState(planId, CheckStateEnum.UNCHECKED.getValue());
|
||||||
this.baseMapper.updatePlanTestState(planId, CheckStateEnum.CHECKING.getValue());
|
} else if (allArchived) {
|
||||||
} else {
|
|
||||||
this.baseMapper.updatePlanTestState(planId, CheckStateEnum.CHECKED.getValue());
|
this.baseMapper.updatePlanTestState(planId, CheckStateEnum.CHECKED.getValue());
|
||||||
|
} else {
|
||||||
|
this.baseMapper.updatePlanTestState(planId, CheckStateEnum.CHECKING.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveCheckHistory(PqDevVO pqDevVo, Integer recheckNum, Integer checkState, String userId) {
|
private void saveCheckHistory(PqDevVO pqDevVo, Integer recheckNum, Integer checkState, String userId) {
|
||||||
if (ObjectUtil.isNull(pqDevVo)
|
if (ObjectUtil.isNull(pqDevVo)
|
||||||
|| (!CheckStateEnum.CHECKED.getValue().equals(checkState) && !CheckStateEnum.DOCUMENTED.getValue().equals(checkState))) {
|
|| checkState == null
|
||||||
|
|| checkState < CheckStateEnum.CHECKED.getValue()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AdPlan plan = adPlanMapper.selectById(pqDevVo.getPlanId());
|
AdPlan plan = adPlanMapper.selectById(pqDevVo.getPlanId());
|
||||||
@@ -723,7 +758,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
private void saveCheckHistory(String devId, String userId) {
|
private void saveCheckHistory(String devId, String userId) {
|
||||||
PqDevVO pqDevVo = this.baseMapper.selectByDevId(devId);
|
PqDevVO pqDevVo = this.baseMapper.selectByDevId(devId);
|
||||||
if (ObjectUtil.isNull(pqDevVo)
|
if (ObjectUtil.isNull(pqDevVo)
|
||||||
|| (!CheckStateEnum.CHECKED.getValue().equals(pqDevVo.getCheckState()) && !CheckStateEnum.DOCUMENTED.getValue().equals(pqDevVo.getCheckState()))) {
|
|| pqDevVo.getCheckState() == null
|
||||||
|
|| pqDevVo.getCheckState() < CheckStateEnum.CHECKED.getValue()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AdPlan plan = adPlanMapper.selectById(pqDevVo.getPlanId());
|
AdPlan plan = adPlanMapper.selectById(pqDevVo.getPlanId());
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
|||||||
this.baseMapper.updateDeviceReportRState(devId, DevReportStateEnum.NOT_GENERATED.getValue());
|
this.baseMapper.updateDeviceReportRState(devId, DevReportStateEnum.NOT_GENERATED.getValue());
|
||||||
}
|
}
|
||||||
if (enableCheckMonitorList.size() > checkedMonitorList.size() && checkedMonitorList.size() > 0) {
|
if (enableCheckMonitorList.size() > checkedMonitorList.size() && checkedMonitorList.size() > 0) {
|
||||||
this.baseMapper.updateDeviceCheckState(devId, CheckStateEnum.CHECKING.getValue());
|
this.baseMapper.updateDeviceCheckState(devId, CheckStateEnum.UNCHECKED.getValue());
|
||||||
this.baseMapper.updateDeviceReportRState(devId, DevReportStateEnum.NOT_GENERATED.getValue());
|
this.baseMapper.updateDeviceReportRState(devId, DevReportStateEnum.NOT_GENERATED.getValue());
|
||||||
}
|
}
|
||||||
if (enableCheckMonitorList.size() > 0 && checkedMonitorList.size() == 0) {
|
if (enableCheckMonitorList.size() > 0 && checkedMonitorList.size() == 0) {
|
||||||
@@ -142,13 +142,14 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
|||||||
List<PqDevSub> devSubList = this.baseMapper.listDevSubByPlanId(plan.getId());
|
List<PqDevSub> devSubList = this.baseMapper.listDevSubByPlanId(plan.getId());
|
||||||
|
|
||||||
List<PqDevSub> checkedDevSubList = devSubList.stream().filter(pqDevSub -> pqDevSub.getCheckState() == CheckStateEnum.CHECKED.getValue()).collect(Collectors.toList());
|
List<PqDevSub> checkedDevSubList = devSubList.stream().filter(pqDevSub -> pqDevSub.getCheckState() == CheckStateEnum.CHECKED.getValue()).collect(Collectors.toList());
|
||||||
List<PqDevSub> checkingDevSubList = devSubList.stream().filter(pqDevSub -> pqDevSub.getCheckState() == CheckStateEnum.CHECKING.getValue()).collect(Collectors.toList());
|
boolean allUnchecked = devSubList.stream().allMatch(pqDevSub -> CheckStateEnum.UNCHECKED.getValue().equals(pqDevSub.getCheckState()));
|
||||||
if (checkedDevSubList.size() == devSubList.size() && devSubList.size() > 0) {
|
boolean allArchived = devSubList.stream().allMatch(pqDevSub -> pqDevSub.getCheckState() != null && pqDevSub.getCheckState() >= CheckStateEnum.DOCUMENTED.getValue());
|
||||||
|
if (allArchived && CollUtil.isNotEmpty(devSubList)) {
|
||||||
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.CHECKED.getValue());
|
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.CHECKED.getValue());
|
||||||
} else if (checkedDevSubList.size() > 0 || checkingDevSubList.size() > 0) {
|
} else if (allUnchecked) {
|
||||||
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.CHECKING.getValue());
|
|
||||||
} else {
|
|
||||||
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.UNCHECKED.getValue());
|
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.UNCHECKED.getValue());
|
||||||
|
} else {
|
||||||
|
this.baseMapper.updatePlanCheckState(plan.getId(), CheckStateEnum.CHECKING.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PqDevSub> accordDevSubList = checkedDevSubList.stream().filter(pqDevSub -> pqDevSub.getCheckResult() == CheckResultEnum.ACCORD.getValue()).collect(Collectors.toList());
|
List<PqDevSub> accordDevSubList = checkedDevSubList.stream().filter(pqDevSub -> pqDevSub.getCheckResult() == CheckResultEnum.ACCORD.getValue()).collect(Collectors.toList());
|
||||||
@@ -372,10 +373,6 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
|||||||
|
|
||||||
if (checkedNumList.containsAll(allNumList)) {
|
if (checkedNumList.containsAll(allNumList)) {
|
||||||
return CheckStateEnum.CHECKED.getValue();
|
return CheckStateEnum.CHECKED.getValue();
|
||||||
} else {
|
|
||||||
if (checkedNumList.size() > 0) {
|
|
||||||
return CheckStateEnum.CHECKING.getValue();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CheckStateEnum.UNCHECKED.getValue();
|
return CheckStateEnum.UNCHECKED.getValue();
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ public class PlanStatisticsVO {
|
|||||||
*/
|
*/
|
||||||
private Integer uncheckedDeviceCount;
|
private Integer uncheckedDeviceCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测中设备总数。
|
||||||
|
*/
|
||||||
|
private Integer checkingDeviceCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 第一次检测合格的设备数量。
|
* 第一次检测合格的设备数量。
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -436,20 +436,14 @@ public class AsyncPlanHandler {
|
|||||||
planIds.add(planId);
|
planIds.add(planId);
|
||||||
List<String> devIds = pqDevService.lambdaQuery().in(PqDev::getPlanId, planIds).list().stream().map(PqDev::getId).collect(Collectors.toList());
|
List<String> devIds = pqDevService.lambdaQuery().in(PqDev::getPlanId, planIds).list().stream().map(PqDev::getId).collect(Collectors.toList());
|
||||||
List<PqDevSub> devSubs = pqDevSubService.lambdaQuery().in(PqDevSub::getDevId, devIds).list();
|
List<PqDevSub> devSubs = pqDevSubService.lambdaQuery().in(PqDevSub::getDevId, devIds).list();
|
||||||
long checkedCount = devSubs.stream().filter(sub -> sub.getCheckState().equals(CheckStateEnum.CHECKED.getValue())).count();
|
boolean allUnchecked = devSubs.stream().allMatch(sub -> CheckStateEnum.UNCHECKED.getValue().equals(sub.getCheckState()));
|
||||||
if (checkedCount > 0) {
|
boolean allArchived = devSubs.stream().allMatch(sub -> sub.getCheckState() != null && sub.getCheckState() >= CheckStateEnum.DOCUMENTED.getValue());
|
||||||
plan.setTestState(CheckStateEnum.CHECKING.getValue());
|
if (allUnchecked) {
|
||||||
// 都已检测完成
|
|
||||||
if (checkedCount == devSubs.size()) {
|
|
||||||
plan.setTestState(CheckStateEnum.CHECKED.getValue());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
plan.setTestState(CheckStateEnum.UNCHECKED.getValue());
|
plan.setTestState(CheckStateEnum.UNCHECKED.getValue());
|
||||||
// 是否有检测中
|
} else if (allArchived && !devSubs.isEmpty()) {
|
||||||
long checkingCount = devSubs.stream().filter(sub -> sub.getCheckState().equals(CheckStateEnum.CHECKING.getValue())).count();
|
plan.setTestState(CheckStateEnum.CHECKED.getValue());
|
||||||
if (checkingCount > 0) {
|
} else {
|
||||||
plan.setTestState(CheckStateEnum.CHECKING.getValue());
|
plan.setTestState(CheckStateEnum.CHECKING.getValue());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
adPlanService.updateById(plan);
|
adPlanService.updateById(plan);
|
||||||
LocalDateTime endTime = LocalDateTime.now();
|
LocalDateTime endTime = LocalDateTime.now();
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
|||||||
}
|
}
|
||||||
List<PqDevVO> pqDevVOList = pqDevMapper.selectByQueryParam(queryParam1);
|
List<PqDevVO> pqDevVOList = pqDevMapper.selectByQueryParam(queryParam1);
|
||||||
if (CollUtil.isNotEmpty(pqDevVOList)) {
|
if (CollUtil.isNotEmpty(pqDevVOList)) {
|
||||||
long count = pqDevVOList.stream().filter(pqDev -> CheckStateEnum.CHECKED.getValue().equals(pqDev.getCheckState()) || CheckStateEnum.DOCUMENTED.getValue().equals(pqDev.getCheckState())).count();
|
long count = pqDevVOList.stream().filter(pqDev -> pqDev.getCheckState() != null && pqDev.getCheckState() >= CheckStateEnum.CHECKED.getValue()).count();
|
||||||
adPlanVO.setProgress((float) count / pqDevVOList.size());
|
adPlanVO.setProgress((float) count / pqDevVOList.size());
|
||||||
} else {
|
} else {
|
||||||
adPlanVO.setProgress(0.0f);
|
adPlanVO.setProgress(0.0f);
|
||||||
@@ -405,10 +405,13 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
|||||||
PqDevParam.QueryParam queryParam = new PqDevParam.QueryParam();
|
PqDevParam.QueryParam queryParam = new PqDevParam.QueryParam();
|
||||||
queryParam.setPlanIdList(Collections.singletonList(plan1.getId()));
|
queryParam.setPlanIdList(Collections.singletonList(plan1.getId()));
|
||||||
List<PqDevVO> pqDevVOS = pqDevService.listByPlanId(queryParam);
|
List<PqDevVO> pqDevVOS = pqDevService.listByPlanId(queryParam);
|
||||||
long checkedCount = pqDevVOS.stream().filter(pqDevVO -> pqDevVO.getCheckState().equals(CheckStateEnum.CHECKED.getValue())).count();
|
boolean allUnchecked = pqDevVOS.stream().allMatch(pqDevVO -> CheckStateEnum.UNCHECKED.getValue().equals(pqDevVO.getCheckState()));
|
||||||
if (checkedCount == pqDevVOS.size()) {
|
boolean allArchived = pqDevVOS.stream().allMatch(pqDevVO -> pqDevVO.getCheckState() != null && pqDevVO.getCheckState() >= CheckStateEnum.DOCUMENTED.getValue());
|
||||||
|
if (allUnchecked) {
|
||||||
|
plan1.setTestState(CheckStateEnum.UNCHECKED.getValue());
|
||||||
|
} else if (allArchived && !pqDevVOS.isEmpty()) {
|
||||||
plan1.setTestState(CheckStateEnum.CHECKED.getValue());
|
plan1.setTestState(CheckStateEnum.CHECKED.getValue());
|
||||||
} else if (checkedCount > 0) {
|
} else {
|
||||||
plan1.setTestState(CheckStateEnum.CHECKING.getValue());
|
plan1.setTestState(CheckStateEnum.CHECKING.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -832,12 +835,19 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
|||||||
List<PqDevVO> checkedDevices = planDevices.stream()
|
List<PqDevVO> checkedDevices = planDevices.stream()
|
||||||
.filter(this::isCheckedDevice)
|
.filter(this::isCheckedDevice)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
int uncheckedDeviceCount = (int) planDevices.stream()
|
||||||
|
.filter(dev -> Objects.equals(dev.getCheckState(), CheckStateEnum.UNCHECKED.getValue()))
|
||||||
|
.count();
|
||||||
|
int checkingDeviceCount = (int) planDevices.stream()
|
||||||
|
.filter(dev -> Objects.equals(dev.getCheckState(), CheckStateEnum.CHECKING.getValue()))
|
||||||
|
.count();
|
||||||
PlanStatisticsVO statistics = new PlanStatisticsVO();
|
PlanStatisticsVO statistics = new PlanStatisticsVO();
|
||||||
statistics.setPlanId(plan.getId());
|
statistics.setPlanId(plan.getId());
|
||||||
statistics.setPlanName(plan.getName());
|
statistics.setPlanName(plan.getName());
|
||||||
statistics.setManufacturerOptions(buildManufacturerOptions(allPlanDevices, param.getDevType()));
|
statistics.setManufacturerOptions(buildManufacturerOptions(allPlanDevices, param.getDevType()));
|
||||||
statistics.setDevTypeOptions(buildDevTypeOptions(allPlanDevices, param.getManufacturer()));
|
statistics.setDevTypeOptions(buildDevTypeOptions(allPlanDevices, param.getManufacturer()));
|
||||||
statistics.setUncheckedDeviceCount(planDevices.size() - checkedDevices.size());
|
statistics.setUncheckedDeviceCount(uncheckedDeviceCount);
|
||||||
|
statistics.setCheckingDeviceCount(checkingDeviceCount);
|
||||||
statistics.setCheckedDeviceCount(checkedDevices.size());
|
statistics.setCheckedDeviceCount(checkedDevices.size());
|
||||||
statistics.setTotalCheckCount(checkedDevices.stream().mapToInt(dev -> defaultZero(dev.getRecheckNum())).sum());
|
statistics.setTotalCheckCount(checkedDevices.stream().mapToInt(dev -> defaultZero(dev.getRecheckNum())).sum());
|
||||||
|
|
||||||
@@ -935,9 +945,8 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCheckedDevice(PqDevVO dev) {
|
private boolean isCheckedDevice(PqDevVO dev) {
|
||||||
return (Objects.equals(dev.getCheckState(), CheckStateEnum.CHECKED.getValue())
|
Integer checkState = dev.getCheckState();
|
||||||
|| Objects.equals(dev.getCheckState(), CheckStateEnum.DOCUMENTED.getValue()))
|
return checkState != null && checkState >= CheckStateEnum.CHECKED.getValue();
|
||||||
&& !Objects.equals(dev.getCheckResult(), CheckResultEnum.UNCHECKED.getValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<PlanStatisticsItemVO> buildItemDistributions(AdPlan plan, List<PqDevVO> checkedDevices) {
|
private List<PlanStatisticsItemVO> buildItemDistributions(AdPlan plan, List<PqDevVO> checkedDevices) {
|
||||||
@@ -1235,26 +1244,22 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
|||||||
// 0-解绑、1-绑定
|
// 0-解绑、1-绑定
|
||||||
if (param.getBindFlag().equals(1)) {
|
if (param.getBindFlag().equals(1)) {
|
||||||
pqDevService.lambdaUpdate().set(PqDev::getPlanId, plan.getId()).in(PqDev::getId, param.getDevIds()).update();
|
pqDevService.lambdaUpdate().set(PqDev::getPlanId, plan.getId()).in(PqDev::getId, param.getDevIds()).update();
|
||||||
// 绑定被检设备,若检测计划已检测完成,则修改为检测中
|
|
||||||
if (plan.getTestState().equals(CheckStateEnum.CHECKED.getValue())) {
|
|
||||||
plan.setTestState(CheckStateEnum.CHECKING.getValue());
|
|
||||||
this.updateById(plan);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
pqDevService.lambdaUpdate().set(PqDev::getPlanId, plan.getFatherPlanId()).in(PqDev::getId, param.getDevIds()).update();
|
pqDevService.lambdaUpdate().set(PqDev::getPlanId, plan.getFatherPlanId()).in(PqDev::getId, param.getDevIds()).update();
|
||||||
// 解绑被检设备,若检测计划检测中,且所有设备已检测完成,则修改为检测完成
|
|
||||||
if (plan.getTestState().equals(CheckStateEnum.CHECKING.getValue())) {
|
|
||||||
PqDevParam.QueryParam queryParam = new PqDevParam.QueryParam();
|
|
||||||
queryParam.setPlanIdList(Collections.singletonList(plan.getId()));
|
|
||||||
List<PqDevVO> pqDevVOS = pqDevService.listByPlanId(queryParam);
|
|
||||||
long checkedCount = pqDevVOS.stream().filter(pqDevVO -> pqDevVO.getCheckState().equals(CheckStateEnum.CHECKED.getValue())).count();
|
|
||||||
if (checkedCount == pqDevVOS.size()) {
|
|
||||||
plan.setTestState(CheckStateEnum.CHECKED.getValue());
|
|
||||||
this.updateById(plan);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
PqDevParam.QueryParam queryParam = new PqDevParam.QueryParam();
|
||||||
|
queryParam.setPlanIdList(Collections.singletonList(plan.getId()));
|
||||||
|
List<PqDevVO> pqDevVOS = pqDevService.listByPlanId(queryParam);
|
||||||
|
boolean allUnchecked = pqDevVOS.stream().allMatch(pqDevVO -> CheckStateEnum.UNCHECKED.getValue().equals(pqDevVO.getCheckState()));
|
||||||
|
boolean allArchived = pqDevVOS.stream().allMatch(pqDevVO -> pqDevVO.getCheckState() != null && pqDevVO.getCheckState() >= CheckStateEnum.DOCUMENTED.getValue());
|
||||||
|
if (allUnchecked) {
|
||||||
|
plan.setTestState(CheckStateEnum.UNCHECKED.getValue());
|
||||||
|
} else if (allArchived && !pqDevVOS.isEmpty()) {
|
||||||
|
plan.setTestState(CheckStateEnum.CHECKED.getValue());
|
||||||
|
} else {
|
||||||
|
plan.setTestState(CheckStateEnum.CHECKING.getValue());
|
||||||
|
}
|
||||||
|
this.updateById(plan);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import lombok.Getter;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 电能质量测试大项枚举
|
* 电能质量测试大项枚举
|
||||||
|
*
|
||||||
* @author hongawen
|
* @author hongawen
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
* @data 2025/3/27 18:29
|
* @data 2025/3/27 18:29
|
||||||
@@ -13,22 +14,21 @@ public enum PowerIndexEnum {
|
|||||||
|
|
||||||
|
|
||||||
UNKNOWN("UNKNOWN", "未知指标"),
|
UNKNOWN("UNKNOWN", "未知指标"),
|
||||||
FREQ("FREQ", "频率"),
|
|
||||||
LINE_TITLE("LINE_TITLE", "测量回路"),
|
LINE_TITLE("LINE_TITLE", "测量回路"),
|
||||||
|
FREQ("FREQ", "频率"),
|
||||||
V("V", "电压"),
|
V("V", "电压"),
|
||||||
I("I", "电流"),
|
|
||||||
P("P", "功率"),
|
|
||||||
ANGLE("Angle", "基波相位"),
|
|
||||||
IMBV("IMBV", "负序电压不平衡度"),
|
|
||||||
IMBA("IMBA", "负序电流不平衡度"),
|
|
||||||
F("F", "短时电压闪变"),
|
|
||||||
HP("HP", "谐波有功功率"),
|
|
||||||
HV("HV", "谐波电压"),
|
HV("HV", "谐波电压"),
|
||||||
HI("HI", "谐波电流"),
|
HI("HI", "谐波电流"),
|
||||||
|
HP("HP", "谐波有功功率"),
|
||||||
HSV("HSV", "间谐波电压"),
|
HSV("HSV", "间谐波电压"),
|
||||||
HSI("HSI", "间谐波电流"),
|
HSI("HSI", "间谐波电流"),
|
||||||
VOLTAGE("VOLTAGE", "电压暂降、暂升及短时中断"),
|
VOLTAGE("VOLTAGE", "电压暂降、暂升及短时中断"),
|
||||||
PST("PST", "短时间闪变");
|
I("I", "电流"),
|
||||||
|
IMBV("IMBV", "负序电压不平衡度"),
|
||||||
|
IMBA("IMBA", "负序电流不平衡度"),
|
||||||
|
F("F", "短时电压闪变"),
|
||||||
|
P("P", "功率"),
|
||||||
|
ANGLE("Angle", "基波相位");
|
||||||
|
|
||||||
private String key;
|
private String key;
|
||||||
|
|
||||||
|
|||||||
@@ -2220,7 +2220,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
queryParam.setPlanIdList(Arrays.asList(tempPqDevVO.getPlanId()));
|
queryParam.setPlanIdList(Arrays.asList(tempPqDevVO.getPlanId()));
|
||||||
List<PqDevVO> pqDevVOList1 = pqDevMapper.selectByQueryParam(queryParam);
|
List<PqDevVO> pqDevVOList1 = pqDevMapper.selectByQueryParam(queryParam);
|
||||||
|
|
||||||
long count = pqDevVOList1.stream().filter(obj -> !CheckStateEnum.DOCUMENTED.getValue().equals(obj.getCheckState())).count();
|
long count = pqDevVOList1.stream().filter(obj -> obj.getCheckState() == null || obj.getCheckState() < CheckStateEnum.DOCUMENTED.getValue()).count();
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
// 如果非归档状态的设备数量为0,则更新计划已完成
|
// 如果非归档状态的设备数量为0,则更新计划已完成
|
||||||
pqDevMapper.finishPlan(pqDevVO.getPlanId());
|
pqDevMapper.finishPlan(pqDevVO.getPlanId());
|
||||||
|
|||||||
@@ -92,7 +92,6 @@ import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
|||||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||||
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
|
||||||
import com.njcn.gather.util.StorageUtil;
|
import com.njcn.gather.util.StorageUtil;
|
||||||
import com.njcn.http.util.RestTemplateUtil;
|
import com.njcn.http.util.RestTemplateUtil;
|
||||||
import com.njcn.web.utils.ExcelUtil;
|
import com.njcn.web.utils.ExcelUtil;
|
||||||
@@ -2204,15 +2203,15 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
DictTree dictTree = dictTreeList.get(0);
|
DictTree dictTree = dictTreeList.get(0);
|
||||||
|
|
||||||
String unit = StorageUtil.unit(dictTree.getCode());
|
String unit = StorageUtil.unit(dictTree.getCode());
|
||||||
if (DicDataEnum.HV.getCode().equals(dictTree.getCode()) || DicDataEnum.HI.getCode().equals(dictTree.getCode())) {
|
if (PowerIndexEnum.HV.getKey().equals(dictTree.getCode()) || PowerIndexEnum.HI.getKey().equals(dictTree.getCode())) {
|
||||||
unit = "%";
|
unit = "%";
|
||||||
if (DicDataEnum.HI.getCode().equals(dictTree.getCode())) {
|
if (PowerIndexEnum.HI.getKey().equals(dictTree.getCode())) {
|
||||||
unit = "A";
|
unit = "A";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DicDataEnum.HSV.getCode().equals(dictTree.getCode()) || DicDataEnum.HSI.getCode().equals(dictTree.getCode())) {
|
if (PowerIndexEnum.HSV.getKey().equals(dictTree.getCode()) || PowerIndexEnum.HSI.getKey().equals(dictTree.getCode())) {
|
||||||
unit = "%";
|
unit = "%";
|
||||||
if (DicDataEnum.HSI.getCode().equals(dictTree.getCode())) {
|
if (PowerIndexEnum.HSI.getKey().equals(dictTree.getCode())) {
|
||||||
unit = "A";
|
unit = "A";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3424,10 +3423,10 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
if (CollUtil.isNotEmpty(contrastHarmonicResults)) {
|
if (CollUtil.isNotEmpty(contrastHarmonicResults)) {
|
||||||
ContrastHarmonicResult contrastHarmonicResult = contrastHarmonicResults.get(0);
|
ContrastHarmonicResult contrastHarmonicResult = contrastHarmonicResults.get(0);
|
||||||
List<Double> harmonicNum = null;
|
List<Double> harmonicNum = null;
|
||||||
if (DicDataEnum.HV.getCode().equals(dictTree.getCode()) || DicDataEnum.HI.getCode().equals(dictTree.getCode()) || DicDataEnum.HP.getCode().equals(dictTree.getCode())) {
|
if (PowerIndexEnum.HV.getKey().equals(dictTree.getCode()) || PowerIndexEnum.HI.getKey().equals(dictTree.getCode()) || PowerIndexEnum.HP.getKey().equals(dictTree.getCode())) {
|
||||||
harmonicNum = Stream.iterate(2.0, n -> n + 1).limit(49).collect(Collectors.toList());
|
harmonicNum = Stream.iterate(2.0, n -> n + 1).limit(49).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
if (DicDataEnum.HSV.getCode().equals(dictTree.getCode()) || DicDataEnum.HSI.getCode().equals(dictTree.getCode())) {
|
if (PowerIndexEnum.HSV.getKey().equals(dictTree.getCode()) || PowerIndexEnum.HSI.getKey().equals(dictTree.getCode())) {
|
||||||
harmonicNum = Stream.iterate(0.5, n -> n + 1).limit(50).collect(Collectors.toList());
|
harmonicNum = Stream.iterate(0.5, n -> n + 1).limit(50).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
for (Double n : harmonicNum) {
|
for (Double n : harmonicNum) {
|
||||||
@@ -3493,7 +3492,7 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
|
|
||||||
ContrastNonHarmonicResult contrastNonHarmonicResultStdDev = stdDevNonHarmonicRawDataList.get(i);
|
ContrastNonHarmonicResult contrastNonHarmonicResultStdDev = stdDevNonHarmonicRawDataList.get(i);
|
||||||
rawDataVO.setTimeStdDev(contrastNonHarmonicResultStdDev.getTimeId().format(dtf));
|
rawDataVO.setTimeStdDev(contrastNonHarmonicResultStdDev.getTimeId().format(dtf));
|
||||||
if (!DicDataEnum.IMBV.getCode().equals(dictTree.getCode()) && !DicDataEnum.IMBA.getCode().equals(dictTree.getCode())) {
|
if (!PowerIndexEnum.IMBV.getKey().equals(dictTree.getCode()) && !PowerIndexEnum.IMBA.getKey().equals(dictTree.getCode())) {
|
||||||
rawDataVO.setUaDev(getValue(contrastNonHarmonicResultDev.getAValue()));
|
rawDataVO.setUaDev(getValue(contrastNonHarmonicResultDev.getAValue()));
|
||||||
rawDataVO.setUcDev(getValue(contrastNonHarmonicResultDev.getCValue()));
|
rawDataVO.setUcDev(getValue(contrastNonHarmonicResultDev.getCValue()));
|
||||||
rawDataVO.setUaStdDev(getValue(contrastNonHarmonicResultStdDev.getAValue()));
|
rawDataVO.setUaStdDev(getValue(contrastNonHarmonicResultStdDev.getAValue()));
|
||||||
@@ -3512,11 +3511,11 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
if (CollUtil.isNotEmpty(devHarmonicRawDataList) && CollUtil.isNotEmpty(stdDevHarmonicRawDataList)) {
|
if (CollUtil.isNotEmpty(devHarmonicRawDataList) && CollUtil.isNotEmpty(stdDevHarmonicRawDataList)) {
|
||||||
List<Double> harmonicNum = null;
|
List<Double> harmonicNum = null;
|
||||||
boolean isHarm = true;
|
boolean isHarm = true;
|
||||||
if (DicDataEnum.HV.getCode().equals(dictTree.getCode()) || DicDataEnum.HI.getCode().equals(dictTree.getCode()) || DicDataEnum.HP.getCode().equals(dictTree.getCode())) {
|
if (PowerIndexEnum.HV.getKey().equals(dictTree.getCode()) || PowerIndexEnum.HI.getKey().equals(dictTree.getCode()) || PowerIndexEnum.HP.getKey().equals(dictTree.getCode())) {
|
||||||
harmonicNum = Stream.iterate(2.0, n -> n + 1).limit(49).collect(Collectors.toList());
|
harmonicNum = Stream.iterate(2.0, n -> n + 1).limit(49).collect(Collectors.toList());
|
||||||
isHarm = true;
|
isHarm = true;
|
||||||
}
|
}
|
||||||
if (DicDataEnum.HSV.getCode().equals(dictTree.getCode()) || DicDataEnum.HSI.getCode().equals(dictTree.getCode())) {
|
if (PowerIndexEnum.HSV.getKey().equals(dictTree.getCode()) || PowerIndexEnum.HSI.getKey().equals(dictTree.getCode())) {
|
||||||
harmonicNum = Stream.iterate(0.5, n -> n + 1).limit(50).collect(Collectors.toList());
|
harmonicNum = Stream.iterate(0.5, n -> n + 1).limit(50).collect(Collectors.toList());
|
||||||
isHarm = false;
|
isHarm = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import com.njcn.gather.device.pojo.vo.PqDevVO;
|
|||||||
import com.njcn.gather.device.service.IPqDevService;
|
import com.njcn.gather.device.service.IPqDevService;
|
||||||
import com.njcn.gather.plan.mapper.AdPlanMapper;
|
import com.njcn.gather.plan.mapper.AdPlanMapper;
|
||||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||||
import com.njcn.gather.result.pojo.enums.ResultUnitEnum;
|
import com.njcn.gather.report.pojo.enums.PowerIndexEnum;
|
||||||
import com.njcn.gather.script.mapper.PqScriptCheckDataMapper;
|
import com.njcn.gather.script.mapper.PqScriptCheckDataMapper;
|
||||||
import com.njcn.gather.script.mapper.PqScriptDtlsMapper;
|
import com.njcn.gather.script.mapper.PqScriptDtlsMapper;
|
||||||
import com.njcn.gather.script.mapper.PqScriptMapper;
|
import com.njcn.gather.script.mapper.PqScriptMapper;
|
||||||
@@ -37,12 +37,10 @@ import com.njcn.gather.script.util.ThreePhaseUnbalance;
|
|||||||
import com.njcn.gather.source.service.IPqSourceService;
|
import com.njcn.gather.source.service.IPqSourceService;
|
||||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||||
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
|
||||||
import com.njcn.gather.type.pojo.po.DevType;
|
import com.njcn.gather.type.pojo.po.DevType;
|
||||||
import com.njcn.gather.type.service.IDevTypeService;
|
import com.njcn.gather.type.service.IDevTypeService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -69,7 +67,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
private final static String INHARM_I = "InHarm_I";
|
private final static String INHARM_I = "InHarm_I";
|
||||||
private final static String DIP = "Dip";
|
private final static String DIP = "Dip";
|
||||||
private final static String FLICKER = "Flicker";
|
private final static String FLICKER = "Flicker";
|
||||||
// @Value("${Dip.fPreTime}")
|
// @Value("${Dip.fPreTime}")
|
||||||
// private Double fPreTime;
|
// private Double fPreTime;
|
||||||
// @Value("${Dip.fRampIn}")
|
// @Value("${Dip.fRampIn}")
|
||||||
// private Double fRampIn;
|
// private Double fRampIn;
|
||||||
@@ -205,7 +203,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
checkDataParam.setScriptId(freqDtls.getScriptId());
|
checkDataParam.setScriptId(freqDtls.getScriptId());
|
||||||
checkDataParam.setIndex(freqDtls.getScriptIndex());
|
checkDataParam.setIndex(freqDtls.getScriptIndex());
|
||||||
checkDataParam.setIsValueTypeName(true);
|
checkDataParam.setIsValueTypeName(true);
|
||||||
if (DicDataEnum.F.getCode().equals(issue.getType()) || DicDataEnum.VOLTAGE.getCode().equals(issue.getType())) {
|
if (PowerIndexEnum.F.getKey().equals(issue.getType()) || PowerIndexEnum.VOLTAGE.getKey().equals(issue.getType())) {
|
||||||
checkDataParam.setDataType("avg");
|
checkDataParam.setDataType("avg");
|
||||||
issue.setDataType("avg");
|
issue.setDataType("avg");
|
||||||
} else {
|
} else {
|
||||||
@@ -247,7 +245,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
issueAdd(curList, dtlsIList, HARM_I, INHARM_I, freqDtls.getValue(), "I", channelListDTOS, checkDataParam, devFly, isValueType);
|
issueAdd(curList, dtlsIList, HARM_I, INHARM_I, freqDtls.getValue(), "I", channelListDTOS, checkDataParam, devFly, isValueType);
|
||||||
|
|
||||||
issue.setChannelList(channelListDTOS);
|
issue.setChannelList(channelListDTOS);
|
||||||
if (ResultUnitEnum.P.getCode().equals(issue.getType()) || ResultUnitEnum.ANGLE.getCode().equals(issue.getType())) {
|
if (PowerIndexEnum.P.getKey().equals(issue.getType()) || PowerIndexEnum.ANGLE.getKey().equals(issue.getType())) {
|
||||||
issue.setOtherType(issue.getType());
|
issue.setOtherType(issue.getType());
|
||||||
} else {
|
} else {
|
||||||
issue.setOtherType(null);
|
issue.setOtherType(null);
|
||||||
@@ -665,7 +663,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
if (v == 90 || v == -90 || v == 270 || v == -270) {
|
if (v == 90 || v == -90 || v == 270 || v == -270) {
|
||||||
checkData.setValue(0.0);
|
checkData.setValue(0.0);
|
||||||
} else {
|
} else {
|
||||||
checkData.setValue(channelI.get(0).getFAmp() * listDTO.getFAmp() * Math.cos(v * Math.PI / 180));
|
checkData.setValue(channelI.get(0).getFAmp() * listDTO.getFAmp() / radio * Math.cos(v * Math.PI / 180));
|
||||||
}
|
}
|
||||||
setCheck(info, checkData, channelListDTO, checkArchive, listDTO);
|
setCheck(info, checkData, channelListDTO, checkArchive, listDTO);
|
||||||
}
|
}
|
||||||
@@ -690,7 +688,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
if (v == 0 || v == 360 || v == 180 || v == -180) {
|
if (v == 0 || v == 360 || v == 180 || v == -180) {
|
||||||
checkData.setValue(0.0);
|
checkData.setValue(0.0);
|
||||||
} else {
|
} else {
|
||||||
checkData.setValue(channelI.get(0).getFAmp() * listDTO.getFAmp() * Math.sin(v * Math.PI / 180));
|
checkData.setValue(channelI.get(0).getFAmp() * listDTO.getFAmp() / radio * Math.sin(v * Math.PI / 180));
|
||||||
}
|
}
|
||||||
// if (valueType) {
|
// if (valueType) {
|
||||||
// checkData.setValue(checkData.getValue() * 57.74 * 5);
|
// checkData.setValue(checkData.getValue() * 57.74 * 5);
|
||||||
@@ -760,7 +758,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
if (v == 90 || v == -90 || v == 270 || v == -270) {
|
if (v == 90 || v == -90 || v == 270 || v == -270) {
|
||||||
value += 0.0;
|
value += 0.0;
|
||||||
} else {
|
} else {
|
||||||
value += channelI.get(0).getFAmp() * listDTO.getFAmp() * Math.cos(v * Math.PI / 180);
|
value += channelI.get(0).getFAmp() * listDTO.getFAmp() / radio * Math.cos(v * Math.PI / 180);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -789,7 +787,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
if (v == 0 || v == 360 || v == 180 || v == -180) {
|
if (v == 0 || v == 360 || v == 180 || v == -180) {
|
||||||
value += 0.0;
|
value += 0.0;
|
||||||
} else {
|
} else {
|
||||||
value += channelI.get(0).getFAmp() * listDTO.getFAmp() * Math.sin(v * Math.PI / 180);
|
value += channelI.get(0).getFAmp() * listDTO.getFAmp() / radio * Math.sin(v * Math.PI / 180);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -813,7 +811,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
.filter(x -> x.getChannelType().contains("I" + listDTO.getChannelType().substring(1, 2)))
|
.filter(x -> x.getChannelType().contains("I" + listDTO.getChannelType().substring(1, 2)))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
if (CollUtil.isNotEmpty(channelI)) {
|
if (CollUtil.isNotEmpty(channelI)) {
|
||||||
value += channelI.get(0).getFAmp() * listDTO.getFAmp();
|
value += channelI.get(0).getFAmp() * listDTO.getFAmp() / radio;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkData = new PqScriptDtlsParam.CheckData();
|
checkData = new PqScriptDtlsParam.CheckData();
|
||||||
@@ -843,9 +841,9 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
if (v == 90 || v == -90 || v == 270 || v == -270) {
|
if (v == 90 || v == -90 || v == 270 || v == -270) {
|
||||||
valueTotW += 0.0;
|
valueTotW += 0.0;
|
||||||
} else {
|
} else {
|
||||||
valueTotW += channelI.get(0).getFAmp() * listDTO.getFAmp() * Math.cos(v * Math.PI / 180);
|
valueTotW += channelI.get(0).getFAmp() * listDTO.getFAmp() / radio * Math.cos(v * Math.PI / 180);
|
||||||
}
|
}
|
||||||
valueTotVA += channelI.get(0).getFAmp() * listDTO.getFAmp();
|
valueTotVA += channelI.get(0).getFAmp() * listDTO.getFAmp() / radio;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkData = new PqScriptDtlsParam.CheckData();
|
checkData = new PqScriptDtlsParam.CheckData();
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.njcn.gather.detection.service.impl;
|
||||||
|
|
||||||
|
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
public class PreDetectionServiceImplTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isFirstFormalIssueOfBigItem_returnsTrueForFirstIssueOfType() {
|
||||||
|
List<SourceIssue> allIssues = Arrays.asList(issue(10, "voltage"), issue(20, "voltage"), issue(30, "current"));
|
||||||
|
|
||||||
|
assertTrue(PreDetectionServiceImpl.isFirstFormalIssueOfBigItem(allIssues, issue(10, "voltage"), "voltage"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isFirstFormalIssueOfBigItem_returnsFalseWhenResumingInsideSameBigItem() {
|
||||||
|
List<SourceIssue> allIssues = Arrays.asList(issue(10, "voltage"), issue(20, "voltage"), issue(30, "current"));
|
||||||
|
|
||||||
|
assertFalse(PreDetectionServiceImpl.isFirstFormalIssueOfBigItem(allIssues, issue(20, "voltage"), "voltage"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isFirstFormalIssueOfBigItem_usesOtherTypeAsBigItemType() {
|
||||||
|
List<SourceIssue> allIssues = Arrays.asList(otherTypeIssue(10, "V", "voltage"), otherTypeIssue(20, "V", "voltage"));
|
||||||
|
|
||||||
|
assertTrue(PreDetectionServiceImpl.isFirstFormalIssueOfBigItem(allIssues, otherTypeIssue(10, "V", "voltage"), "voltage"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private SourceIssue issue(Integer index, String type) {
|
||||||
|
SourceIssue issue = new SourceIssue();
|
||||||
|
issue.setIndex(index);
|
||||||
|
issue.setType(type);
|
||||||
|
return issue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SourceIssue otherTypeIssue(Integer index, String type, String otherType) {
|
||||||
|
SourceIssue issue = issue(index, type);
|
||||||
|
issue.setOtherType(otherType);
|
||||||
|
return issue;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -74,4 +74,10 @@ public interface SimAndDigHarmonicService extends IService<SimAndDigHarmonicResu
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<SimAndDigHarmonicResult> listAllRawData(String scriptId, String code, String devId);
|
List<SimAndDigHarmonicResult> listAllRawData(String scriptId, String code, String devId);
|
||||||
|
|
||||||
|
Map<String, Integer> maxSortByDevIds(String code, String scriptId, List<String> devIds);
|
||||||
|
|
||||||
|
List<SimAndDigHarmonicResult> listByDevIdsAndSorts(String code, String scriptId, List<String> devIds, List<Integer> sorts);
|
||||||
|
|
||||||
|
Map<String, List<Integer>> resultFlagsByDevIdsAndSorts(String code, String scriptId, List<String> devIds, List<Integer> sorts);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,4 +79,10 @@ public interface SimAndDigNonHarmonicService extends IService<SimAndDigNonHarmon
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<SimAndDigNonHarmonicResult> listAllSimAndDigRawData(String scriptId, String code, String devId);
|
List<SimAndDigNonHarmonicResult> listAllSimAndDigRawData(String scriptId, String code, String devId);
|
||||||
|
|
||||||
|
Map<String, Integer> maxSortByDevIds(String code, String scriptId, List<String> devIds);
|
||||||
|
|
||||||
|
List<SimAndDigNonHarmonicResult> listByDevIdsAndSorts(String code, String scriptId, List<String> devIds, List<Integer> sorts);
|
||||||
|
|
||||||
|
Map<String, List<Integer>> resultFlagsByDevIdsAndSorts(String code, String scriptId, List<String> devIds, List<Integer> sorts);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -276,4 +276,96 @@ public class SimAndDigHarmonicServiceImpl extends ServiceImpl<SimAndDigHarmonicM
|
|||||||
DynamicTableNameHandler.remove();
|
DynamicTableNameHandler.remove();
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Integer> maxSortByDevIds(String code, String scriptId, List<String> devIds) {
|
||||||
|
Map<String, Integer> result = new HashMap<>();
|
||||||
|
if (CollUtil.isEmpty(devIds)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
DynamicTableNameHandler.setTableName("ad_harmonic_result_" + code);
|
||||||
|
try {
|
||||||
|
LambdaQueryWrapper<SimAndDigHarmonicResult> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.select(SimAndDigHarmonicResult::getDevMonitorId, SimAndDigHarmonicResult::getSort)
|
||||||
|
.eq(SimAndDigHarmonicResult::getScriptId, scriptId)
|
||||||
|
.and(w -> {
|
||||||
|
for (String devId : devIds) {
|
||||||
|
w.or().likeRight(SimAndDigHarmonicResult::getDevMonitorId, devId + "_");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.list(wrapper).forEach(row -> {
|
||||||
|
String devId = row.getDevMonitorId().split("_")[0];
|
||||||
|
result.merge(devId, row.getSort(), Math::max);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
} finally {
|
||||||
|
DynamicTableNameHandler.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SimAndDigHarmonicResult> listByDevIdsAndSorts(String code, String scriptId, List<String> devIds, List<Integer> sorts) {
|
||||||
|
if (CollUtil.isEmpty(devIds) || CollUtil.isEmpty(sorts)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
DynamicTableNameHandler.setTableName("ad_harmonic_result_" + code);
|
||||||
|
try {
|
||||||
|
LambdaQueryWrapper<SimAndDigHarmonicResult> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SimAndDigHarmonicResult::getScriptId, scriptId)
|
||||||
|
.in(SimAndDigHarmonicResult::getSort, sorts)
|
||||||
|
.and(w -> {
|
||||||
|
for (String devId : devIds) {
|
||||||
|
w.or().likeRight(SimAndDigHarmonicResult::getDevMonitorId, devId + "_");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return this.list(wrapper);
|
||||||
|
} finally {
|
||||||
|
DynamicTableNameHandler.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, List<Integer>> resultFlagsByDevIdsAndSorts(String code, String scriptId, List<String> devIds, List<Integer> sorts) {
|
||||||
|
Map<String, List<Integer>> result = new HashMap<>();
|
||||||
|
if (CollUtil.isEmpty(devIds) || StrUtil.isBlank(code)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (sorts != null && CollUtil.isEmpty(sorts)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
DynamicTableNameHandler.setTableName("ad_harmonic_result_" + code);
|
||||||
|
try {
|
||||||
|
LambdaQueryWrapper<SimAndDigHarmonicResult> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.select(SimAndDigHarmonicResult::getDevMonitorId,
|
||||||
|
SimAndDigHarmonicResult::getResultFlag)
|
||||||
|
.eq(StrUtil.isNotBlank(scriptId), SimAndDigHarmonicResult::getScriptId, scriptId)
|
||||||
|
.in(CollUtil.isNotEmpty(sorts), SimAndDigHarmonicResult::getSort, sorts)
|
||||||
|
.and(w -> {
|
||||||
|
for (String devId : devIds) {
|
||||||
|
w.or().likeRight(SimAndDigHarmonicResult::getDevMonitorId, devId + "_");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.list(wrapper).forEach(row -> {
|
||||||
|
String devId = resolveDevId(row.getDevMonitorId(), devIds);
|
||||||
|
if (StrUtil.isNotBlank(devId) && row.getResultFlag() != null) {
|
||||||
|
result.computeIfAbsent(devId, key -> new ArrayList<>()).add(row.getResultFlag());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
} finally {
|
||||||
|
DynamicTableNameHandler.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String resolveDevId(String devMonitorId, List<String> devIds) {
|
||||||
|
if (StrUtil.isBlank(devMonitorId)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (String devId : devIds) {
|
||||||
|
if (StrUtil.isNotBlank(devId) && devMonitorId.startsWith(devId + "_")) {
|
||||||
|
return devId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import cn.hutool.core.date.DatePattern;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||||
@@ -211,5 +212,96 @@ public class SimAndDigNonHarmonicServiceImpl extends ServiceImpl<SimAndDigNonHar
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Integer> maxSortByDevIds(String code, String scriptId, List<String> devIds) {
|
||||||
|
Map<String, Integer> result = new HashMap<>();
|
||||||
|
if (CollUtil.isEmpty(devIds)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
DynamicTableNameHandler.setTableName("ad_non_harmonic_result_" + code);
|
||||||
|
try {
|
||||||
|
LambdaQueryWrapper<SimAndDigNonHarmonicResult> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.select(SimAndDigNonHarmonicResult::getDevMonitorId, SimAndDigNonHarmonicResult::getSort)
|
||||||
|
.eq(SimAndDigNonHarmonicResult::getScriptId, scriptId)
|
||||||
|
.and(w -> {
|
||||||
|
for (String devId : devIds) {
|
||||||
|
w.or().likeRight(SimAndDigNonHarmonicResult::getDevMonitorId, devId + "_");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.list(wrapper).forEach(row -> {
|
||||||
|
String devId = row.getDevMonitorId().split("_")[0];
|
||||||
|
result.merge(devId, row.getSort(), Math::max);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
} finally {
|
||||||
|
DynamicTableNameHandler.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SimAndDigNonHarmonicResult> listByDevIdsAndSorts(String code, String scriptId, List<String> devIds, List<Integer> sorts) {
|
||||||
|
if (CollUtil.isEmpty(devIds) || CollUtil.isEmpty(sorts)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
DynamicTableNameHandler.setTableName("ad_non_harmonic_result_" + code);
|
||||||
|
try {
|
||||||
|
LambdaQueryWrapper<SimAndDigNonHarmonicResult> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(SimAndDigNonHarmonicResult::getScriptId, scriptId)
|
||||||
|
.in(SimAndDigNonHarmonicResult::getSort, sorts)
|
||||||
|
.and(w -> {
|
||||||
|
for (String devId : devIds) {
|
||||||
|
w.or().likeRight(SimAndDigNonHarmonicResult::getDevMonitorId, devId + "_");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return this.list(wrapper);
|
||||||
|
} finally {
|
||||||
|
DynamicTableNameHandler.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, List<Integer>> resultFlagsByDevIdsAndSorts(String code, String scriptId, List<String> devIds, List<Integer> sorts) {
|
||||||
|
Map<String, List<Integer>> result = new HashMap<>();
|
||||||
|
if (CollUtil.isEmpty(devIds) || StrUtil.isBlank(code)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (sorts != null && CollUtil.isEmpty(sorts)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
DynamicTableNameHandler.setTableName("ad_non_harmonic_result_" + code);
|
||||||
|
try {
|
||||||
|
LambdaQueryWrapper<SimAndDigNonHarmonicResult> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.select(SimAndDigNonHarmonicResult::getDevMonitorId,
|
||||||
|
SimAndDigNonHarmonicResult::getResultFlag)
|
||||||
|
.eq(StrUtil.isNotBlank(scriptId), SimAndDigNonHarmonicResult::getScriptId, scriptId)
|
||||||
|
.in(CollUtil.isNotEmpty(sorts), SimAndDigNonHarmonicResult::getSort, sorts)
|
||||||
|
.and(w -> {
|
||||||
|
for (String devId : devIds) {
|
||||||
|
w.or().likeRight(SimAndDigNonHarmonicResult::getDevMonitorId, devId + "_");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.list(wrapper).forEach(row -> {
|
||||||
|
String devId = resolveDevId(row.getDevMonitorId(), devIds);
|
||||||
|
if (StrUtil.isNotBlank(devId) && row.getResultFlag() != null) {
|
||||||
|
result.computeIfAbsent(devId, key -> new ArrayList<>()).add(row.getResultFlag());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
} finally {
|
||||||
|
DynamicTableNameHandler.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String resolveDevId(String devMonitorId, List<String> devIds) {
|
||||||
|
if (StrUtil.isBlank(devMonitorId)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (String devId : devIds) {
|
||||||
|
if (StrUtil.isNotBlank(devId) && devMonitorId.startsWith(devId + "_")) {
|
||||||
|
return devId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
package com.njcn.gather.system.pojo.enums;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author cdf
|
|
||||||
* @version 1.0.0
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
public enum DicDataEnum {
|
|
||||||
|
|
||||||
|
|
||||||
FREQ("FREQ","频率"),
|
|
||||||
V("V","电压"),
|
|
||||||
I("I","电流"),
|
|
||||||
IMBV("IMBV","三相电压不平衡度"),
|
|
||||||
IMBA("IMBA","三相电流不平衡度"),
|
|
||||||
|
|
||||||
HV("HV","谐波电压"),
|
|
||||||
HI("HI","谐波电流"),
|
|
||||||
HP("HP","谐波有功功率"),
|
|
||||||
HSV("HSV","间谐波电压"),
|
|
||||||
HSI("HSI","间谐波电流"),
|
|
||||||
VOLTAGE("VOLTAGE","暂态"),
|
|
||||||
F("F","闪变"),
|
|
||||||
P("P","功率")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
private final String code;
|
|
||||||
|
|
||||||
private final String message;
|
|
||||||
|
|
||||||
DicDataEnum(String code, String message) {
|
|
||||||
this.code = code;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DicDataEnum getEnumByCode(String code) {
|
|
||||||
for (DicDataEnum e : DicDataEnum.values()) {
|
|
||||||
if (e.getCode().equals(code)) {
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getMessageByCode(String code) {
|
|
||||||
DicDataEnum e = getEnumByCode(code);
|
|
||||||
if (e!= null) {
|
|
||||||
return e.getMessage();
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user