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 a856cb52..eb039cbb 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 @@ -65,7 +65,7 @@ public class PreDetectionController extends BaseController { @PostMapping("/ytxCheckSimulate") @OperateInfo - @ApiOperation("模拟检测-源通讯校验") + @ApiOperation("源通讯校验") @ApiImplicitParam(name = "param", value = "查询参数", required = true) public HttpResult ytxCheckSimulate(@RequestBody @Validated SimulateDetectionParam param) { String methodDescribe = getMethodDescribe("ytxCheckSimulate"); @@ -78,7 +78,7 @@ public class PreDetectionController extends BaseController { */ @PostMapping("/startSimulateTest") @OperateInfo - @ApiOperation("模拟检测-下发脚本") + @ApiOperation("启动") @ApiImplicitParam(name = "param", value = "查询参数", required = true) public HttpResult startTestSimulate(@RequestBody @Validated SimulateDetectionParam param) { String methodDescribe = getMethodDescribe("startTestSimulate"); @@ -91,7 +91,7 @@ public class PreDetectionController extends BaseController { */ @PostMapping("/closeSimulateTest") @OperateInfo - @ApiOperation("模拟检测-停止") + @ApiOperation("停止") @ApiImplicitParam(name = "param", value = "查询参数", required = true) public HttpResult closeSimulateTest(@RequestBody @Validated SimulateDetectionParam param) { String methodDescribe = getMethodDescribe("closeSimulateTest"); diff --git a/detection/src/main/java/com/njcn/gather/detection/pojo/enums/DetectionResponseEnum.java b/detection/src/main/java/com/njcn/gather/detection/pojo/enums/DetectionResponseEnum.java index 1d576e06..bbdeda98 100644 --- a/detection/src/main/java/com/njcn/gather/detection/pojo/enums/DetectionResponseEnum.java +++ b/detection/src/main/java/com/njcn/gather/detection/pojo/enums/DetectionResponseEnum.java @@ -12,8 +12,8 @@ public enum DetectionResponseEnum { SOURCE_INFO_NOT("A020002", "源表信息不存在"), PLAN_AND_SOURCE_NOT("A020003", "计划和源关系不存在"), ITEM_TEST_NOT("A020004", "检测项为空"), - PLAN_DEV_IP_HAS("A20005","当前计划检测装置ip重复") - ; + PLAN_DEV_IP_HAS("A20005","当前计划检测装置ip重复"), + SOURCE_NOT_CONNECT("A020006", "源未连接"); private final String code; private final String message; diff --git a/detection/src/main/java/com/njcn/gather/detection/pojo/param/SimulateDetectionParam.java b/detection/src/main/java/com/njcn/gather/detection/pojo/param/SimulateDetectionParam.java index 6df79034..f60aec7c 100644 --- a/detection/src/main/java/com/njcn/gather/detection/pojo/param/SimulateDetectionParam.java +++ b/detection/src/main/java/com/njcn/gather/detection/pojo/param/SimulateDetectionParam.java @@ -1,7 +1,10 @@ package com.njcn.gather.detection.pojo.param; +import com.njcn.gather.source.pojo.constant.PqSourceValidMessage; import lombok.Data; +import javax.validation.constraints.NotBlank; + /** * @author caozehui * @data 2025-03-06 @@ -30,6 +33,7 @@ public class SimulateDetectionParam { /** * 源id */ + @NotBlank(message = PqSourceValidMessage.ID_NOT_BLANK) private String sourceId; 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 43914ad6..a35a230b 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 @@ -4,6 +4,7 @@ package com.njcn.gather.detection.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.gather.detection.handler.SocketDevResponseService; @@ -12,6 +13,7 @@ import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum; import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum; import com.njcn.gather.detection.pojo.param.PreDetectionParam; import com.njcn.gather.detection.pojo.param.SimulateDetectionParam; +import com.njcn.gather.detection.pojo.vo.SocketDataMsg; import com.njcn.gather.detection.pojo.vo.SocketMsg; import com.njcn.gather.detection.service.PreDetectionService; import com.njcn.gather.detection.util.socket.CnSocketUtil; @@ -276,6 +278,10 @@ public class PreDetectionServiceImpl implements PreDetectionService { @Override public void closeTestSimulate(SimulateDetectionParam param) { + Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source); + if (Objects.isNull(channel) || !channel.isActive()) { + throw new BusinessException(DetectionResponseEnum.SOURCE_NOT_CONNECT); + } SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(param.getSourceId()); PreDetectionParam preDetectionParam = new PreDetectionParam(); preDetectionParam.setSourceId(sourceParam.getSourceId()); diff --git a/detection/src/main/java/com/njcn/gather/source/pojo/constant/PqSourceValidMessage.java b/detection/src/main/java/com/njcn/gather/source/pojo/constant/PqSourceValidMessage.java new file mode 100644 index 00000000..d58b2463 --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/source/pojo/constant/PqSourceValidMessage.java @@ -0,0 +1,9 @@ +package com.njcn.gather.source.pojo.constant; + +/** + * @author caozehui + * @data 2025-03-07 + */ +public interface PqSourceValidMessage { + String ID_NOT_BLANK = "检测源id不能为空"; +}