From f2cfc383fdac5cff80097a5dc86a7fd4b9d67677 Mon Sep 17 00:00:00 2001 From: chendaofei <857448963@qq.com> Date: Thu, 9 Jan 2025 20:02:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PreDetectionController.java | 2 +- .../handler/SocketDevResponseService.java | 18 +++++++++++++++-- .../handler/SocketSourceResponseService.java | 14 +++++++++++++ .../pojo/enums/SourceOperateCodeEnum.java | 3 ++- .../service/impl/PreDetectionServiceImpl.java | 20 +++++++++++++++---- .../script/pojo/param/PqScriptIssueParam.java | 2 ++ .../service/impl/PqScriptDtlsServiceImpl.java | 9 ++++++--- .../service/impl/AdHarmonicServiceImpl.java | 8 ++++++-- 8 files changed, 63 insertions(+), 13 deletions(-) diff --git a/detection/src/main/java/com/njcn/gather/detection/controller/PreDetectionController.java b/detection/src/main/java/com/njcn/gather/detection/controller/PreDetectionController.java index fd128c18..fedfba79 100644 --- a/detection/src/main/java/com/njcn/gather/detection/controller/PreDetectionController.java +++ b/detection/src/main/java/com/njcn/gather/detection/controller/PreDetectionController.java @@ -95,7 +95,7 @@ public class PreDetectionController extends BaseController { /** * 重新开始检测 */ - @GetMapping("/restartTemTest") + @PostMapping("/restartTemTest") @OperateInfo @ApiOperation("重新开始检测") @ApiImplicitParam(name = "param", value = "参数", required = true) 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 f12d5c54..e103b157 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 @@ -20,8 +20,10 @@ import com.njcn.gather.device.script.pojo.param.PqScriptIssueParam; import com.njcn.gather.device.script.pojo.po.SourceIssue; import com.njcn.gather.device.script.service.IPqScriptCheckDataService; import com.njcn.gather.device.script.service.IPqScriptDtlsService; +import com.njcn.gather.storage.pojo.param.StorageParam; import com.njcn.gather.storage.pojo.po.AdHarmonicResult; import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult; +import com.njcn.gather.storage.service.AdHarmonicService; import com.njcn.gather.storage.service.DetectionDataDealService; import com.njcn.gather.system.config.pojo.po.SysTestConfig; import com.njcn.gather.system.config.service.ISysTestConfigService; @@ -75,6 +77,7 @@ public class SocketDevResponseService { private final ISysRegResService iSysRegResService; private final IPqScriptCheckDataService iPqScriptCheckDataService; private final ISysTestConfigService sysTestConfigService; + private final AdHarmonicService adHarmonicService; private final ExecutorService executorPool = Executors.newFixedThreadPool(10); @@ -668,9 +671,20 @@ public class SocketDevResponseService { successDevComm.clear(); socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue()); List sourceIssues; - if (SourceOperateCodeEnum.FORMAL_TEST.getValue().equals(param.getOperateType())) { + if (SourceOperateCodeEnum.FORMAL_TEST.getValue().equals(param.getOperateType()) || SourceOperateCodeEnum.RE_ERROR_TEST.getValue().equals(param.getOperateType())) { + + if(param.getOperateType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())){ + //不合格项复检 + StorageParam storageParam = new StorageParam(); + storageParam.setCode(Integer.valueOf(param.getPlanCode())); + storageParam.setScriptId(param.getScriptId()); + List indexes = adHarmonicService.getIndex(storageParam); + issueParam.setIndexList(indexes); + issueParam.setIsPhaseSequence(SourceOperateCodeEnum.COEFFICIENT_TEST.getValue()); + }else { + issueParam.setIsPhaseSequence(SourceOperateCodeEnum.FORMAL_TEST.getValue()); + } //正式检测 - issueParam.setIsPhaseSequence(SourceOperateCodeEnum.FORMAL_TEST.getValue()); sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam); sourceIssues = sourceIssues.stream().sorted(Comparator.comparing(SourceIssue::getIndex)).collect(Collectors.toList()); SocketManager.addSourceList(sourceIssues); diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java index 3f60a128..7d9588af 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java @@ -168,8 +168,22 @@ public class SocketSourceResponseService { webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg)); break; case SOURCE_CONNECTION_ERROR: + CnSocketUtil.quitSendSource(param); webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg)); break; + case CONTROLLED_SOURCE_ERROR: + CnSocketUtil.quitSendSource(param); + webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg)); + break; + case TEST_ITEM_PARSING_ERROR: + CnSocketUtil.quitSendSource(param); + webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg)); + break; + case SOURCE_CONTROL_ERROR: + CnSocketUtil.quitSendSource(param); + webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg)); + break; + default: socketMsg = new SocketMsg<>(); socketMsg.setRequestId(socketDataMsg.getRequestId()); diff --git a/detection/src/main/java/com/njcn/gather/detection/pojo/enums/SourceOperateCodeEnum.java b/detection/src/main/java/com/njcn/gather/detection/pojo/enums/SourceOperateCodeEnum.java index 45597939..edad4731 100644 --- a/detection/src/main/java/com/njcn/gather/detection/pojo/enums/SourceOperateCodeEnum.java +++ b/detection/src/main/java/com/njcn/gather/detection/pojo/enums/SourceOperateCodeEnum.java @@ -44,7 +44,7 @@ public enum SourceOperateCodeEnum { */ YJC_YTXJY("yjc_ytxjy", "源通讯检测"), YJC_SBTXJY("yjc_sbtxjy", "设备通讯检测"), - YJC_XYJY("yjc_xyjy", "预检测_协议校验"), + YJC_XYJY("yjc_xyjy", "协议校验"), YJC_XUJY("YJC_xujy", "相序校验"), FORMAL_REAL("formal_real","正式检测_获取实时数据"), FORMAL_STATISTIC("formal_statistic","正式检测_获取统计数据"), @@ -73,6 +73,7 @@ public enum SourceOperateCodeEnum { TEST_TEM_STOP("5","临时停止"), TEST_TEM_START("6","继续检测"), TEST_STOP("7","停止检测"), + RE_ERROR_TEST("8","不合格项复检"), /** diff --git a/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java b/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java index 8840f080..ba451350 100644 --- a/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/detection/service/impl/PreDetectionServiceImpl.java @@ -5,6 +5,8 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.github.yulichang.wrapper.MPJLambdaWrapper; +import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.gather.detection.handler.SocketDevResponseService; import com.njcn.gather.detection.handler.SocketSourceResponseService; @@ -22,6 +24,9 @@ import com.njcn.gather.detection.util.socket.SocketManager; import com.njcn.gather.detection.util.socket.cilent.NettyClient; import com.njcn.gather.detection.util.socket.cilent.NettySourceClientHandler; import com.njcn.gather.device.device.service.IPqDevService; +import com.njcn.gather.device.script.pojo.param.PqScriptIssueParam; +import com.njcn.gather.device.script.pojo.po.PqScriptCheckData; +import com.njcn.gather.device.script.pojo.po.PqScriptDtls; import com.njcn.gather.device.script.pojo.po.SourceIssue; import com.njcn.gather.device.script.service.IPqScriptDtlsService; import com.njcn.gather.device.source.pojo.po.PqSource; @@ -31,7 +36,10 @@ import com.njcn.gather.plan.pojo.po.AdPlan; import com.njcn.gather.plan.pojo.po.AdPlanSource; import com.njcn.gather.plan.service.IAdPlanService; import com.njcn.gather.plan.service.IAdPlanSourceService; +import com.njcn.gather.storage.pojo.param.StorageParam; +import com.njcn.gather.storage.service.AdHarmonicService; import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum; +import com.njcn.gather.system.dictionary.pojo.po.DictTree; import com.njcn.gather.system.dictionary.service.IDictDataService; import io.netty.channel.Channel; import io.netty.channel.ChannelFutureListener; @@ -39,6 +47,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import java.util.List; import java.util.Objects; @@ -58,6 +67,7 @@ public class PreDetectionServiceImpl implements PreDetectionService { private final SocketDevResponseService socketDevResponseService; private final SocketSourceResponseService socketSourceResponseService; + private final AdHarmonicService adHarmonicService; @Value("${socket.source.ip:192.168.1.136}") @@ -78,10 +88,7 @@ public class PreDetectionServiceImpl implements PreDetectionService { 查询计划什么模式的(除了对比式,其他都是一个计划对应一个源) */ AdPlan plan = iAdPlanService.getById(param.getPlanId()); - param.setSourceId(plan.getDatasourceId()); if (ObjectUtil.isNotNull(plan)) { - plan.setErrorSysId(plan.getId()); - param.setCode(String.valueOf(plan.getCode())); String code = dictDataService.getDictDataById(plan.getPattern()).getCode(); DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code); switch (dictDataEnumByCode) { @@ -127,7 +134,12 @@ public class PreDetectionServiceImpl implements PreDetectionService { private void sendYtxSocket(PreDetectionParam param) { + AdPlan plan = iAdPlanService.getById(param.getPlanId()); AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper().eq(AdPlanSource::getPlanId, param.getPlanId())); + param.setSourceId(planSource.getSourceId()); + param.setScriptId(plan.getScriptId()); + param.setErrorSysId(plan.getErrorSysId()); + param.setCode(String.valueOf(plan.getCode())); if (ObjectUtil.isNotNull(planSource)) { SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId()); if (ObjectUtil.isNotNull(sourceParam)) { @@ -138,7 +150,7 @@ public class PreDetectionServiceImpl implements PreDetectionService { msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue()); msg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue()); msg.setData(JSON.toJSONString(sourceParam)); - param.setSourceId(sourceParam.getSourceId()); + NettyClient.socketClient(ip, port, param, JSON.toJSONString(msg), new NettySourceClientHandler(param, sourceResponseService)); } else { throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT); diff --git a/device/src/main/java/com/njcn/gather/device/script/pojo/param/PqScriptIssueParam.java b/device/src/main/java/com/njcn/gather/device/script/pojo/param/PqScriptIssueParam.java index 2ab3332a..7304a165 100644 --- a/device/src/main/java/com/njcn/gather/device/script/pojo/param/PqScriptIssueParam.java +++ b/device/src/main/java/com/njcn/gather/device/script/pojo/param/PqScriptIssueParam.java @@ -28,4 +28,6 @@ public class PqScriptIssueParam { @ApiModelProperty("源id") private String sourceId; + + private List indexList; } diff --git a/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptDtlsServiceImpl.java b/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptDtlsServiceImpl.java index b0292b6d..8be2fedd 100644 --- a/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptDtlsServiceImpl.java +++ b/device/src/main/java/com/njcn/gather/device/script/service/impl/PqScriptDtlsServiceImpl.java @@ -124,7 +124,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl pqScriptDtls = this.pqScriptDtls(param.getScriptId(), param.getIsPhaseSequence(), volt, curr); + List pqScriptDtls = this.pqScriptDtls(param.getScriptId(), param.getIsPhaseSequence(), volt, curr,param.getIndexList()); if (CollUtil.isNotEmpty(pqScriptDtls)) { /** * 1.获取全部检测点脚本 @@ -200,6 +200,9 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl getIndexList(String scriptType, String scriptId) { MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(); @@ -210,7 +213,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl pqScriptDtls(String scriptId, String isPhaseSequence, Double volt, Double curr) { + public List pqScriptDtls(String scriptId, String isPhaseSequence, Double volt, Double curr,List indexList) { List pqScriptDtls; MPJLambdaWrapper queryWrapper = new MPJLambdaWrapper<>(); queryWrapper.selectAll(PqScriptDtls.class) @@ -228,7 +231,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.select(AdHarmonicResult::getSort).eq(AdHarmonicResult::getResultFlag, 2); + lambdaQueryWrapper.select(AdHarmonicResult::getSort) + .eq(AdHarmonicResult::getResultFlag, 2) + .eq(AdHarmonicResult::getScriptId,param.getScriptId()); List adHarmonicResultList = this.list(lambdaQueryWrapper); List indexes = new ArrayList<>(adHarmonicResultList.stream().map(AdHarmonicResult::getSort).collect(Collectors.toList())); DynamicTableNameHandler.setTableName(prefixNon + param.getCode()); LambdaQueryWrapper resultLambdaQueryWrapper = new LambdaQueryWrapper<>(); - resultLambdaQueryWrapper.select(AdNonHarmonicResult::getSort).eq(AdNonHarmonicResult::getResultFlag,2); + resultLambdaQueryWrapper.select(AdNonHarmonicResult::getSort) + .eq(AdNonHarmonicResult::getResultFlag,2) + .eq(AdNonHarmonicResult::getScriptId,param.getScriptId());; List nonHarmonicResults = adNonHarmonicMapper.selectList(resultLambdaQueryWrapper); indexes.addAll(nonHarmonicResults.stream().map(AdNonHarmonicResult::getSort).collect(Collectors.toList()));