From 4f7bad232ae71e4be48dbf3763b9828e9f71bd52 Mon Sep 17 00:00:00 2001 From: chendaofei <857448963@qq.com> Date: Fri, 13 Dec 2024 09:20:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- detection/pom.xml | 7 ++++ .../controller/PreDetectionController.java | 25 +++++++++---- .../pojo/param/PreDetectionParam.java | 12 ++++++ .../service/PreDetectionService.java | 6 ++- .../service/impl/PreDetectionServiceImpl.java | 37 +++++++++++++++++-- .../util/socket/web/WebSocketHandler.java | 1 - .../util/socket/web/WebSocketService.java | 2 +- entrance/src/main/resources/application.yml | 4 +- 8 files changed, 77 insertions(+), 17 deletions(-) diff --git a/detection/pom.xml b/detection/pom.xml index 0aadecef..2d8526b8 100644 --- a/detection/pom.xml +++ b/detection/pom.xml @@ -36,6 +36,13 @@ 4.1.68.Final + + com.njcn.gather + device + 1.0.0 + compile + + com.alibaba fastjson 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 30bc6d1b..8b985627 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 @@ -1,17 +1,21 @@ package com.njcn.gather.detection.controller; +import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.response.HttpResult; +import com.njcn.gather.detection.pojo.param.PreDetectionParam; import com.njcn.gather.detection.service.PreDetectionService; import com.njcn.web.controller.BaseController; import com.njcn.web.utils.HttpResultUtil; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.Get; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import java.util.List; @Slf4j @Api(tags = "预检测") @@ -22,13 +26,18 @@ public class PreDetectionController extends BaseController { private final PreDetectionService preDetectionService; + + /** - * + * 开始检测 */ - @GetMapping("/test") - public HttpResult test(){ - String methodDescribe = getMethodDescribe("test"); - preDetectionService.test(); + @PostMapping("/startTest") + @OperateInfo + @ApiOperation("开始检测") + @ApiImplicitParam(name = "param", value = "查询参数", required = true) + public HttpResult startTest(@RequestBody PreDetectionParam param){ + String methodDescribe = getMethodDescribe("startTest"); + preDetectionService.startTest(param); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); } 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 28109c91..7cb63940 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 @@ -1,9 +1,21 @@ package com.njcn.gather.detection.pojo.param; +import lombok.Data; + +import java.util.List; + /** * @author wr * @description * @date 2024/12/11 13:45 */ +@Data public class PreDetectionParam { + + //用户功能组成唯一标识 zhangsan_test + private String userPageId; + + private List devIds; + + } diff --git a/detection/src/main/java/com/njcn/gather/detection/service/PreDetectionService.java b/detection/src/main/java/com/njcn/gather/detection/service/PreDetectionService.java index 3bb58bf5..d9f94637 100644 --- a/detection/src/main/java/com/njcn/gather/detection/service/PreDetectionService.java +++ b/detection/src/main/java/com/njcn/gather/detection/service/PreDetectionService.java @@ -1,5 +1,9 @@ package com.njcn.gather.detection.service; +import com.njcn.gather.detection.pojo.param.PreDetectionParam; + +import java.util.List; + /** * @author wr * @description 预检测流程 @@ -32,7 +36,7 @@ public interface PreDetectionService { void phaseSequenceCheck(); - void test(); + void startTest(PreDetectionParam param); 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 82ee0958..655bcd51 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 @@ -1,25 +1,42 @@ package com.njcn.gather.detection.service.impl; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.njcn.gather.detection.handler.SocketSourceResponseService; +import com.njcn.gather.detection.handler.SocketResponseService; +import com.njcn.gather.detection.pojo.param.PreDetectionParam; +import com.njcn.gather.detection.pojo.vo.SocketMsg; import com.njcn.gather.detection.service.PreDetectionService; import com.njcn.gather.detection.util.socket.cilent.NettyClient; import com.njcn.gather.detection.util.socket.cilent.NettySourceClientHandler; +import com.njcn.gather.device.device.mapper.PqDevMapper; +import com.njcn.gather.device.device.pojo.po.PqDev; +import com.njcn.gather.device.device.pojo.vo.PreDetection; +import com.njcn.gather.device.device.service.IPqDevService; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + @Service @RequiredArgsConstructor public class PreDetectionServiceImpl implements PreDetectionService { + private final IPqDevService iPqDevService; + @Value("${socket.source.ip}") - private static String ip; + private String ip; @Value("${socket.source.port}") - private static Integer port; + private Integer port; private final SocketSourceResponseService sourceResponseService; @@ -45,10 +62,22 @@ public class PreDetectionServiceImpl implements PreDetectionService { } @Override - public void test() { + public void startTest(PreDetectionParam param) { + List pqDevList = iPqDevService.getDevInfo(Arrays.asList("578c142b7e4e4978a35bd6225aa62a23", "393504f55f1f79bce255bfc195cfdb56")); + System.out.println(pqDevList); + //校验 + //组装请求数据 + SocketMsg socketMsg = new SocketMsg(); + Map > map=new HashMap(); + map.put("deviceList",pqDevList); + String jsonString = JSON.toJSONString(map); + socketMsg.setRequestId("adawdawd"); + socketMsg.setOperateCode("INIT_GATHER$03"); + socketMsg.setData(jsonString); + String json = JSON.toJSONString(socketMsg); - NettyClient.socketClient(ip,port,"test------------>",new NettySourceClientHandler("aaa",sourceResponseService)); + NettyClient.socketClient(ip,port,"{\"data\":\"{\\\"deviceList\\\":[{\\\"devIP\\\":\\\"192.168.1.186\\\",\\\"port\\\":102,\\\"devType\\\":\\\"PQS882B\\\",\\\"icdType\\\":\\\"PQS882_VX_ZJ_1(V102)\\\",\\\"devCode\\\":\\\"Pqs\\u0026cn870299\\\",\\\"devKey\\\":\\\"!qaz@wsx3edc4rfv\\\",\\\"monitorList\\\":[{\\\"lineId\\\":\\\"1_192.168.1.186_102_1\\\",\\\"line\\\":1}]}]}\",\"operateCode\":\"INIT_GATHER$03\",\"requestId\":\"dansldquiwdlandalksn\"}",new NettySourceClientHandler(param.getUserPageId(),sourceResponseService)); } } diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/web/WebSocketHandler.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/web/WebSocketHandler.java index 0e05366f..76647b39 100644 --- a/detection/src/main/java/com/njcn/gather/detection/util/socket/web/WebSocketHandler.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/web/WebSocketHandler.java @@ -3,7 +3,6 @@ package com.njcn.gather.detection.util.socket.web; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.njcn.gather.detection.pojo.vo.SocketMsg; -import com.njcn.gather.detection.pojo.vo.aa; import com.njcn.gather.detection.util.socket.WebServiceManager; import com.njcn.gather.detection.util.socket.cilent.NettyClient; import com.njcn.gather.detection.util.socket.cilent.NettySourceClientHandler; diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/web/WebSocketService.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/web/WebSocketService.java index 60efbef3..a90a1280 100644 --- a/detection/src/main/java/com/njcn/gather/detection/util/socket/web/WebSocketService.java +++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/web/WebSocketService.java @@ -30,7 +30,7 @@ public class WebSocketService { /** * 端口号 */ - @Value("${webSocket.port}") + @Value("${webSocket.port:7777}") int port; diff --git a/entrance/src/main/resources/application.yml b/entrance/src/main/resources/application.yml index 5131da0f..bd7c7e31 100644 --- a/entrance/src/main/resources/application.yml +++ b/entrance/src/main/resources/application.yml @@ -45,8 +45,8 @@ mybatis-plus: socket: source: - ip: 127.0.0.1 - port: 7777 + ip: 192.168.1.138 + port: 61000 device: ip: 127.0.0.1 port: 7777