diff --git a/detection/pom.xml b/detection/pom.xml
index 92441418..0aadecef 100644
--- a/detection/pom.xml
+++ b/detection/pom.xml
@@ -36,6 +36,11 @@
4.1.68.Final
+
+ com.alibaba
+ fastjson
+ 1.2.83
+
\ No newline at end of file
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
new file mode 100644
index 00000000..3fe7eb8f
--- /dev/null
+++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java
@@ -0,0 +1,26 @@
+package com.njcn.gather.detection.handler;
+
+import com.njcn.gather.detection.util.socket.SocketManager;
+import com.njcn.gather.detection.util.socket.web.WebSocketHandler;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+@Service
+@RequiredArgsConstructor
+public class SocketSourceResponseService {
+
+ private final WebSocketHandler webSocketHandler;
+
+ public void deal(String userId,String msg){
+
+ System.out.println("进入deal+++++++++++++++++++");
+ webSocketHandler.senMsgToUser(userId,msg);
+
+ SocketManager.getChannelByUserId(userId).close();
+
+ }
+
+
+
+
+}
diff --git a/detection/src/main/java/com/njcn/gather/detection/pojo/vo/SocketMsg.java b/detection/src/main/java/com/njcn/gather/detection/pojo/vo/SocketMsg.java
index 7cb7cae1..7c579505 100644
--- a/detection/src/main/java/com/njcn/gather/detection/pojo/vo/SocketMsg.java
+++ b/detection/src/main/java/com/njcn/gather/detection/pojo/vo/SocketMsg.java
@@ -4,7 +4,7 @@ import lombok.Data;
/**
* @author wr
- * @description
+ * @description socket 通用发送报文请求
* @date 2024/12/11 15:57
*/
@Data
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 cf84ab1d..3bb58bf5 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
@@ -8,7 +8,11 @@ package com.njcn.gather.detection.service;
public interface PreDetectionService {
/**
- * 源通讯校验
+ * 源通讯校验socket入参拼接
+ * @param
+ * @return: java.lang.String
+ * @Author: wr
+ * @Date: 2024/12/11 13:26
*/
void sourceCommunicationCheck();
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 9c55222f..82ee0958 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,7 +1,7 @@
package com.njcn.gather.detection.service.impl;
-import com.njcn.gather.detection.handler.SocketResponseService;
+import com.njcn.gather.detection.handler.SocketSourceResponseService;
import com.njcn.gather.detection.service.PreDetectionService;
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
@@ -21,7 +21,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
@Value("${socket.source.port}")
private static Integer port;
- private final SocketResponseService socketResponseService;
+ private final SocketSourceResponseService sourceResponseService;
@Override
@@ -48,7 +48,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
public void test() {
- NettyClient.socketClient(ip,port,"test------------>",new NettySourceClientHandler("aa",socketResponseService));
+ NettyClient.socketClient(ip,port,"test------------>",new NettySourceClientHandler("aaa",sourceResponseService));
}
}
diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/MsgUtil.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/MsgUtil.java
index 1170036f..e167a922 100644
--- a/detection/src/main/java/com/njcn/gather/detection/util/socket/MsgUtil.java
+++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/MsgUtil.java
@@ -1,5 +1,8 @@
package com.njcn.gather.detection.util.socket;
+import com.alibaba.fastjson.JSON;
+import com.njcn.gather.detection.pojo.vo.SocketMsg;
+
/**
* @author wr
* @description
@@ -9,4 +12,7 @@ package com.njcn.gather.detection.util.socket;
public class MsgUtil {
+ public SocketMsg a(String textMsg){
+ return JSON.parseObject(textMsg,SocketMsg.class);
+ }
}
diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/WebServiceManager.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/WebServiceManager.java
index 3c39026a..6dab056f 100644
--- a/detection/src/main/java/com/njcn/gather/detection/util/socket/WebServiceManager.java
+++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/WebServiceManager.java
@@ -42,8 +42,8 @@ public class WebServiceManager {
public static void sendMsg(String userId,String msg) {
Channel channel = userSessions.get(userId);
- TextWebSocketFrame wd1 = new TextWebSocketFrame(msg);
- channel.writeAndFlush(wd1);
+ TextWebSocketFrame wd = new TextWebSocketFrame(msg);
+ channel.writeAndFlush(wd);
}
}
\ No newline at end of file
diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyClient.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyClient.java
index 02637eb8..10ecdbfc 100644
--- a/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyClient.java
+++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettyClient.java
@@ -8,8 +8,6 @@ import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.util.CharsetUtil;
-import io.swagger.models.auth.In;
-import org.springframework.beans.factory.annotation.Value;
import java.util.concurrent.TimeUnit;
@@ -45,7 +43,6 @@ public class NettyClient {
e.printStackTrace();
} finally {
group.shutdownGracefully();
- System.out.println("程序结束");
}
}
diff --git a/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettySourceClientHandler.java b/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettySourceClientHandler.java
index 92ec85df..33330877 100644
--- a/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettySourceClientHandler.java
+++ b/detection/src/main/java/com/njcn/gather/detection/util/socket/cilent/NettySourceClientHandler.java
@@ -1,18 +1,15 @@
package com.njcn.gather.detection.util.socket.cilent;
-import com.njcn.gather.detection.handler.SocketResponseService;
+import com.njcn.gather.detection.handler.SocketSourceResponseService;
import com.njcn.gather.detection.util.socket.SocketManager;
-import com.njcn.gather.detection.util.socket.WebServiceManager;
-import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.RequiredArgsConstructor;
-import org.springframework.stereotype.Component;
-import java.util.Scanner;
+
/**
- * @Description: 客户端业务处理(示例)
+ * @Description: 源客户端业务处理(示例)
* @Author: wr
* @Date: 2024/12/10 14:16
*/
@@ -22,14 +19,7 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler {
+ private final static String QUESTION_MARK = "?";
+ private final static String EQUAL_TO = "=";
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
@@ -41,10 +46,9 @@ public class WebSocketHandler extends SimpleChannelInboundHandler {
//可以自定义线程的数量
bossGroup = new NioEventLoopGroup();
@@ -94,41 +94,4 @@ public class WebSocketService {
System.out.println("webSocket销毁---------------");
}
-
-
-
- /* public static void main(String[] args) {
- //可以自定义线程的数量
- EventLoopGroup bossGroup = new NioEventLoopGroup();
- // 默认创建的线程数量 = CPU 处理器数量 *2
- EventLoopGroup workerGroup = new NioEventLoopGroup();
- try {
- ServerBootstrap serverBootstrap = new ServerBootstrap();
- serverBootstrap.group(bossGroup, workerGroup)
- .channel(NioServerSocketChannel.class)
- .handler(new LoggingHandler())
- //当前连接被阻塞的时候,BACKLOG代表的事 阻塞队列的长度
- .option(ChannelOption.SO_BACKLOG, 128)
- //设置连接保持为活动状态
- .childOption(ChannelOption.SO_KEEPALIVE, true)
- .childHandler(new WebSocketInitializer());
-
- ChannelFuture future = serverBootstrap.bind(7777).sync();
- future.addListener(f -> {
- if (future.isSuccess()) {
- System.out.println("webSocket服务启动成功");
- } else {
- System.out.println("webSocket服务启动失败");
- }
- });
- future.channel().closeFuture().sync();
- } catch (InterruptedException e) {
- e.printStackTrace();
- } finally {
- bossGroup.shutdownGracefully();
- workerGroup.shutdownGracefully();
- }
- }*/
-
-
}
diff --git a/device/src/main/java/com/njcn/gather/device/device/controller/PqDevController.java b/device/src/main/java/com/njcn/gather/device/device/controller/PqDevController.java
index 6005a5ee..5b902499 100644
--- a/device/src/main/java/com/njcn/gather/device/device/controller/PqDevController.java
+++ b/device/src/main/java/com/njcn/gather/device/device/controller/PqDevController.java
@@ -17,6 +17,7 @@ import com.njcn.gather.device.device.pojo.param.PqDevParam;
import com.njcn.gather.device.device.pojo.po.PqDev;
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
import com.njcn.gather.device.device.pojo.vo.PqDevVO;
+import com.njcn.gather.device.device.pojo.vo.PreDetection;
import com.njcn.gather.device.device.service.IPqDevService;
import com.njcn.gather.device.pojo.constant.DevConst;
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
@@ -37,6 +38,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -56,6 +58,17 @@ public class PqDevController extends BaseController {
private final IDictDataService dictDataService;
+ @OperateInfo
+ @GetMapping("/aaa")
+ @ApiOperation("分页查询被检设备")
+ @ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
+ public HttpResult > aaa() {
+ String methodDescribe = getMethodDescribe("list");
+ List devInfo = pqDevService.getDevInfo(Arrays.asList("578c142b7e4e4978a35bd6225aa62a23", "393504f55f1f79bce255bfc195cfdb56"));
+ return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, devInfo, methodDescribe);
+ }
+
+
@OperateInfo
@PostMapping("/list")
@ApiOperation("分页查询被检设备")
diff --git a/device/src/main/java/com/njcn/gather/device/device/mapper/PqDevMapper.java b/device/src/main/java/com/njcn/gather/device/device/mapper/PqDevMapper.java
index e1a6b1a6..1734a4e6 100644
--- a/device/src/main/java/com/njcn/gather/device/device/mapper/PqDevMapper.java
+++ b/device/src/main/java/com/njcn/gather/device/device/mapper/PqDevMapper.java
@@ -2,6 +2,10 @@ package com.njcn.gather.device.device.mapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.njcn.gather.device.device.pojo.po.PqDev;
+import com.njcn.gather.device.device.pojo.vo.PreDetection;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
/**
* @author caozehui
@@ -9,5 +13,13 @@ import com.njcn.gather.device.device.pojo.po.PqDev;
*/
public interface PqDevMapper extends MPJBaseMapper {
+ /**
+ * 根据装置id集合获取装置信息
+ * @param devIds 装置id
+ * @return: java.util.List
+ * @Author: wr
+ * @Date: 2024/12/12 11:46
+ */
+ List selectDevInfo(@Param("devIds") List devIds);
}
diff --git a/device/src/main/java/com/njcn/gather/device/device/mapper/mapping/PqDevMapper.xml b/device/src/main/java/com/njcn/gather/device/device/mapper/mapping/PqDevMapper.xml
index ad06399d..a142f083 100644
--- a/device/src/main/java/com/njcn/gather/device/device/mapper/mapping/PqDevMapper.xml
+++ b/device/src/main/java/com/njcn/gather/device/device/mapper/mapping/PqDevMapper.xml
@@ -2,6 +2,39 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/device/src/main/java/com/njcn/gather/device/device/pojo/vo/PreDetection.java b/device/src/main/java/com/njcn/gather/device/device/pojo/vo/PreDetection.java
new file mode 100644
index 00000000..e58aa8d2
--- /dev/null
+++ b/device/src/main/java/com/njcn/gather/device/device/pojo/vo/PreDetection.java
@@ -0,0 +1,98 @@
+package com.njcn.gather.device.device.pojo.vo;
+
+import cn.hutool.core.util.StrUtil;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.njcn.gather.device.device.util.DeviceUtil;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+/**
+ * @author wr
+ * @description 预检测装置报文初始化
+ * @date 2024/12/12 11:21
+ */
+@Data
+@NoArgsConstructor
+public class PreDetection {
+
+ /**
+ * 装置ip
+ */
+ @JsonProperty("devIP")
+ private String devIP;
+
+ /**
+ * 装置端口
+ */
+ @JsonProperty("port")
+ private Integer port;
+
+ /**
+ * 设备类型,字典表
+ */
+ @JsonProperty("devType")
+ private String devType;
+
+ /**
+ * icd设备类型
+ */
+ @JsonProperty("icdType")
+ private String icdType;
+
+ /**
+ * 装置识别码(3ds加密)
+ */
+ @JsonProperty("devCode")
+ private String devCode;
+
+ /**
+ * 装置秘钥(3ds加密)
+ */
+ @JsonProperty("devKey")
+ private String devKey;
+
+ /**
+ * 监测点信息
+ */
+ @JsonProperty("monitorList")
+ private List monitorList;
+
+
+ @Data
+ @NoArgsConstructor
+ public static class MonitorListDTO {
+ /**
+ * 监测点id
+ */
+ @JsonProperty("lineId")
+ private String lineId;
+
+ /**
+ * 监测点线路号
+ */
+ @JsonProperty("line")
+ private Integer line;
+ }
+
+ public String getDevKey() {
+ if(StrUtil.isNotBlank(devKey)){
+ String key = DeviceUtil.decoderString(1, devKey);
+ if(StrUtil.isNotBlank(key)){
+ return key;
+ }
+ }
+ return null;
+ }
+
+ public String getDevCode() {
+ if(StrUtil.isNotBlank(devCode)){
+ String code= DeviceUtil.decoderString(1,devCode);
+ if(StrUtil.isNotBlank(code)){
+ return code;
+ }
+ }
+ return null;
+ }
+}
diff --git a/device/src/main/java/com/njcn/gather/device/device/service/IPqDevService.java b/device/src/main/java/com/njcn/gather/device/device/service/IPqDevService.java
index 323c8ff0..bbe2794e 100644
--- a/device/src/main/java/com/njcn/gather/device/device/service/IPqDevService.java
+++ b/device/src/main/java/com/njcn/gather/device/device/service/IPqDevService.java
@@ -7,7 +7,9 @@ import com.njcn.gather.device.device.pojo.param.PqDevParam;
import com.njcn.gather.device.device.pojo.po.PqDev;
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
import com.njcn.gather.device.device.pojo.vo.PqDevVO;
+import com.njcn.gather.device.device.pojo.vo.PreDetection;
import com.njcn.gather.device.plan.pojo.param.AdPlanParam;
+import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@@ -141,4 +143,13 @@ public interface IPqDevService extends IService {
* @return 所有非未检测状态的设备列表
*/
List listNotUnchecked();
+
+ /**
+ * 获取装置信息和装置下监测点信息
+ * @param devIds
+ * @return: java.util.List
+ * @Author: wr
+ * @Date: 2024/12/12 15:50
+ */
+ List getDevInfo(@Param("devIds") List devIds);
}
diff --git a/device/src/main/java/com/njcn/gather/device/device/service/impl/PqDevServiceImpl.java b/device/src/main/java/com/njcn/gather/device/device/service/impl/PqDevServiceImpl.java
index d15bd992..8083a262 100644
--- a/device/src/main/java/com/njcn/gather/device/device/service/impl/PqDevServiceImpl.java
+++ b/device/src/main/java/com/njcn/gather/device/device/service/impl/PqDevServiceImpl.java
@@ -17,6 +17,7 @@ import com.njcn.gather.device.device.pojo.param.PqDevParam;
import com.njcn.gather.device.device.pojo.po.PqDev;
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
import com.njcn.gather.device.device.pojo.vo.PqDevVO;
+import com.njcn.gather.device.device.pojo.vo.PreDetection;
import com.njcn.gather.device.device.service.IPqDevService;
import com.njcn.gather.device.device.util.DeviceUtil;
import com.njcn.gather.device.monitor.pojo.po.PqMonitor;
@@ -334,6 +335,11 @@ public class PqDevServiceImpl extends ServiceImpl implements
return queryWrapper;
}
+ @Override
+ public List getDevInfo(List devIds) {
+ return this.baseMapper.selectDevInfo(devIds);
+ }
+
/**
* 获取检测状态饼状图数据
*
diff --git a/device/src/main/java/com/njcn/gather/device/monitor/mapper/PqMonitorMapper.java b/device/src/main/java/com/njcn/gather/device/monitor/mapper/PqMonitorMapper.java
index b8b01315..6814776f 100644
--- a/device/src/main/java/com/njcn/gather/device/monitor/mapper/PqMonitorMapper.java
+++ b/device/src/main/java/com/njcn/gather/device/monitor/mapper/PqMonitorMapper.java
@@ -1,7 +1,11 @@
package com.njcn.gather.device.monitor.mapper;
import com.github.yulichang.base.MPJBaseMapper;
+import com.njcn.gather.device.device.pojo.vo.PreDetection;
import com.njcn.gather.device.monitor.pojo.po.PqMonitor;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
/**
* @author caozehui
@@ -9,5 +13,13 @@ import com.njcn.gather.device.monitor.pojo.po.PqMonitor;
*/
public interface PqMonitorMapper extends MPJBaseMapper {
+ /**
+ * 根据终端id获取监测点集合
+ * @param devId
+ * @return: java.util.List
+ * @Author: wr
+ * @Date: 2024/12/12 13:15
+ */
+ List selectMonitorInfo(@Param("devId") String devId);
}
diff --git a/device/src/main/java/com/njcn/gather/device/monitor/mapper/mapping/PqMonitorMapper.xml b/device/src/main/java/com/njcn/gather/device/monitor/mapper/mapping/PqMonitorMapper.xml
index 69d9f065..abda3aa7 100644
--- a/device/src/main/java/com/njcn/gather/device/monitor/mapper/mapping/PqMonitorMapper.xml
+++ b/device/src/main/java/com/njcn/gather/device/monitor/mapper/mapping/PqMonitorMapper.xml
@@ -2,6 +2,16 @@
+