diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketContrastResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketContrastResponseService.java index 6ff844ca..c1c21c94 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketContrastResponseService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketContrastResponseService.java @@ -307,7 +307,7 @@ public class SocketContrastResponseService { FormalTestManager.numMap.clear(); FormalTestManager.numMap.putAll(numMap); SysTestConfig oneConfig = sysTestConfigService.getOneConfig(); - if (param.getTestItemList().get(2)) { + if (param.isFormalTestSelected()) { numMap.forEach((devMonitorId, num) -> { if (oneConfig.getMaxTime() < num) { throw new BusinessException(DetectionResponseEnum.EXCEED_MAX_TIME); @@ -1154,7 +1154,7 @@ public class SocketContrastResponseService { private void sendFormalTest(String s, PreDetectionParam param, SourceOperateCodeEnum requestOperateCode, SourceOperateCodeEnum quitOperateCode) { // 后续做正式检测 - if (param.getTestItemList().get(2)) { + if (param.isFormalTestSelected()) { System.out.println("开始正式检测!"); if (ObjectUtil.isNotNull(FormalTestManager.nonWaveDataSourceEnum)) { SocketMsg socketMsg = new SocketMsg<>(); diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java index 0abd418b..5ce19351 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketDevResponseService.java @@ -398,7 +398,7 @@ public class SocketDevResponseService { sendWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.small_comp_end.getValue(), XiNumberManager.devParameterList.get(1)); System.out.println("-------------------------已经全部结束----------------------"); - if (param.getTestItemList().get(2)) { + if (param.isFormalTestSelected()) { //如果后续做正式检测 PqScriptIssueParam issueParam = new PqScriptIssueParam(); issueParam.setSourceId(param.getSourceName()); @@ -912,13 +912,13 @@ public class SocketDevResponseService { socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue()); List sourceIssues; // 做预检测、后续做系数校准 - if (param.getTestItemList().get(0) || param.getTestItemList().get(1)) { + if (param.isPreTestSelected() || param.isCoefficientSelected()) { issueParam.setIsPhaseSequence(CommonEnum.PHASE_TEST.getValue()); sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam); socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue()); socketMsg.setData(JSON.toJSONString(sourceIssues.get(0))); 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())) { //不合格项复检 @@ -1147,7 +1147,7 @@ public class SocketDevResponseService { } // 后续做系数校准 - if (param.getTestItemList().get(1)) { + if (param.isCoefficientSelected()) { WebSocketVO webSocketVO = new WebSocketVO<>(); webSocketVO.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue()); webSocketVO.setOperateCode(SourceOperateCodeEnum.big_start.getValue()); @@ -1171,7 +1171,7 @@ public class SocketDevResponseService { XiNumberManager.smallDevXiNumDataMap.clear(); System.out.println("开始系数校准》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》"); - } else if (param.getTestItemList().get(2)) { + } else if (param.isFormalTestSelected()) { // 后续做正式检测 PqScriptIssueParam issueParam = new PqScriptIssueParam(); issueParam.setSourceId(param.getSourceName()); @@ -1815,7 +1815,7 @@ public class SocketDevResponseService { //字典树 SocketManager.valueTypeMap = iPqScriptCheckDataService.getValueTypeMap(param.getScriptId()); - if (param.getTestItemList().get(1)) { + if (param.isCoefficientSelected()) { initXiManager(param); } diff --git a/detection/src/main/java/com/njcn/gather/detection/pojo/param/ContrastDetectionParam.java b/detection/src/main/java/com/njcn/gather/detection/pojo/param/ContrastDetectionParam.java index 795cff86..ecee900a 100644 --- a/detection/src/main/java/com/njcn/gather/detection/pojo/param/ContrastDetectionParam.java +++ b/detection/src/main/java/com/njcn/gather/detection/pojo/param/ContrastDetectionParam.java @@ -38,10 +38,31 @@ public class ContrastDetectionParam { @NotEmpty(message = DetectionValidMessage.PAIRS_NOT_EMPTY) private Map pairs; /** - * 检测项列表。第一个元素为预检测、第二个元素为系数校准、第三个元素为正式检测 + * 检测项列表。第一个元素为预检测、第二个元素为系数校准、第三个元素为守时校验、第四个元素为正式检测。 + * 比对场景暂不支持系数校准和守时校验,第二、第三个元素固定为 false。 */ private List 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; /** diff --git a/detection/src/main/java/com/njcn/gather/detection/pojo/param/PreDetectionParam.java b/detection/src/main/java/com/njcn/gather/detection/pojo/param/PreDetectionParam.java index 4f89bdbd..212c4449 100644 --- a/detection/src/main/java/com/njcn/gather/detection/pojo/param/PreDetectionParam.java +++ b/detection/src/main/java/com/njcn/gather/detection/pojo/param/PreDetectionParam.java @@ -5,7 +5,6 @@ import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import java.util.List; -import java.util.Map; /** * @author wr @@ -76,7 +75,27 @@ public class PreDetectionParam { private Float humidity; /** - * 检测项列表。第一个元素为预检测、第二个元素为系数校准、第三个元素为正式检测 + * 检测项列表。第一个元素为预检测、第二个元素为系数校准、第三个元素为守时校验、第四个元素为正式检测 */ private List 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)); + } }