测试提交

This commit is contained in:
2024-12-13 09:20:24 +08:00
parent bc0e93b522
commit 4f7bad232a
8 changed files with 77 additions and 17 deletions

View File

@@ -36,6 +36,13 @@
<version>4.1.68.Final</version>
</dependency>
<dependency>
<groupId>com.njcn.gather</groupId>
<artifactId>device</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>

View File

@@ -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<String> test(){
String methodDescribe = getMethodDescribe("test");
preDetectionService.test();
@PostMapping("/startTest")
@OperateInfo
@ApiOperation("开始检测")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<String> startTest(@RequestBody PreDetectionParam param){
String methodDescribe = getMethodDescribe("startTest");
preDetectionService.startTest(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}

View File

@@ -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<String> devIds;
}

View File

@@ -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);

View File

@@ -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<PreDetection> pqDevList = iPqDevService.getDevInfo(Arrays.asList("578c142b7e4e4978a35bd6225aa62a23", "393504f55f1f79bce255bfc195cfdb56"));
System.out.println(pqDevList);
//校验
//组装请求数据
SocketMsg socketMsg = new SocketMsg();
Map<String,List<PreDetection> > 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));
}
}

View File

@@ -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;

View File

@@ -30,7 +30,7 @@ public class WebSocketService {
/**
* 端口号
*/
@Value("${webSocket.port}")
@Value("${webSocket.port:7777}")
int port;