1.微调
This commit is contained in:
@@ -28,7 +28,7 @@ import java.util.*;
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class SocketResponseService {
|
public class SocketDevResponseService {
|
||||||
|
|
||||||
|
|
||||||
private final WebSocketHandler webSocketHandler;
|
private final WebSocketHandler webSocketHandler;
|
||||||
@@ -4,6 +4,8 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||||
import com.njcn.gather.detection.pojo.enums.SourceResponseCodeEnum;
|
import com.njcn.gather.detection.pojo.enums.SourceResponseCodeEnum;
|
||||||
|
import com.njcn.gather.detection.pojo.param.DevPhaseSequenceParam;
|
||||||
|
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||||
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
|
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
|
||||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||||
import com.njcn.gather.detection.util.socket.MsgUtil;
|
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||||
@@ -11,10 +13,17 @@ 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.NettyClient;
|
||||||
import com.njcn.gather.detection.util.socket.cilent.NettyDevClientHandler;
|
import com.njcn.gather.detection.util.socket.cilent.NettyDevClientHandler;
|
||||||
import com.njcn.gather.detection.util.socket.web.WebSocketHandler;
|
import com.njcn.gather.detection.util.socket.web.WebSocketHandler;
|
||||||
|
import com.njcn.gather.device.device.pojo.vo.PreDetection;
|
||||||
|
import com.njcn.gather.device.device.service.IPqDevService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class SocketSourceResponseService {
|
public class SocketSourceResponseService {
|
||||||
@@ -23,44 +32,111 @@ public class SocketSourceResponseService {
|
|||||||
* 向webSocket客户端发送消息
|
* 向webSocket客户端发送消息
|
||||||
*/
|
*/
|
||||||
private final WebSocketHandler webSocketHandler;
|
private final WebSocketHandler webSocketHandler;
|
||||||
|
private final SocketDevResponseService socketDevResponseService;
|
||||||
|
private final IPqDevService iPqDevService;
|
||||||
|
|
||||||
private final SocketResponseService sourceResponseService;
|
|
||||||
|
|
||||||
@Value("${socket.device.ip}")
|
@Value("${socket.device.ip}")
|
||||||
private String ip;
|
private String ip;
|
||||||
|
|
||||||
@Value("${socket.device.port}")
|
@Value("${socket.device.port}")
|
||||||
private Integer port;
|
private Integer port;
|
||||||
public void deal(String userId,String msg){
|
public void deal(PreDetectionParam param, String msg){
|
||||||
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
|
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
|
||||||
if(SourceOperateCodeEnum.YJC_YTXJY.getValue().equals(socketDataMsg.getRequestId())){
|
SourceOperateCodeEnum enumByCode = SourceOperateCodeEnum.getDictDataEnumByCode(socketDataMsg.getRequestId());
|
||||||
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
switch (enumByCode){
|
||||||
if(ObjectUtil.isNotNull(dictDataEnumByCode)){
|
case YJC_YTXJY:
|
||||||
switch (dictDataEnumByCode){
|
extracted(param, msg, socketDataMsg);
|
||||||
case SUCCESS:
|
break;
|
||||||
webSocketHandler.sendMsgToUser(userId,msg);
|
case YJC_XUJY:
|
||||||
String s = userId + "_Dev";
|
break;
|
||||||
//todo 创建终端socket连接
|
|
||||||
NettyClient.socketClient(ip, port, s, new NettyDevClientHandler(s, sourceResponseService));
|
|
||||||
SocketManager.sendMsg(s,"向127服务器发送");
|
|
||||||
break;
|
|
||||||
case UNPROCESSED_BUSINESS:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
SocketMsg socketMsg=new SocketMsg();
|
|
||||||
socketMsg.setRequestId(socketDataMsg.getRequestId());
|
|
||||||
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
|
|
||||||
socketMsg.setData(dictDataEnumByCode.getMessage());
|
|
||||||
webSocketHandler.sendMsgToUser(userId, JSON.toJSONString(socketMsg));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(SourceOperateCodeEnum.YJC_YTXJY.getValue().equals(socketDataMsg.getRequestId())){
|
||||||
|
|
||||||
|
}
|
||||||
|
//装置通讯成功之后,会跟据获取到的源通道,进行发送源参数发送(处理发送成功后的信息)
|
||||||
|
if(SourceOperateCodeEnum.YJC_XUJY.getValue().equals(socketDataMsg.getRequestId())){
|
||||||
|
extracted1(param, msg, socketDataMsg);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 源装置检测
|
||||||
|
* @param param
|
||||||
|
* @param msg
|
||||||
|
* @param socketDataMsg
|
||||||
|
*/
|
||||||
|
private void extracted(PreDetectionParam param, String msg, SocketDataMsg socketDataMsg) {
|
||||||
|
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||||
|
if(ObjectUtil.isNotNull(dictDataEnumByCode)){
|
||||||
|
SocketMsg socketMsg=new SocketMsg();
|
||||||
|
switch (dictDataEnumByCode){
|
||||||
|
case SUCCESS:
|
||||||
|
webSocketHandler.sendMsgToUser(param.getUserPageId(), msg);
|
||||||
|
String s = param.getUserPageId() + "_Dev";
|
||||||
|
//开始设备通讯检测
|
||||||
|
NettyClient.socketClient(ip, port,param.getPlanId(), new NettyDevClientHandler(param.getPlanId(), socketDevResponseService));
|
||||||
|
List<PreDetection> devList = iPqDevService.getDevInfo(param.getDevIds());
|
||||||
|
Map<String, List<PreDetection>> map = new HashMap(1);
|
||||||
|
map.put("deviceList", devList);
|
||||||
|
String jsonString = JSON.toJSONString(map);
|
||||||
|
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_SBTXJY.getValue());
|
||||||
|
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_01.getValue());
|
||||||
|
socketMsg.setData(jsonString);
|
||||||
|
String json = JSON.toJSONString(socketMsg);
|
||||||
|
SocketManager.sendMsg(s,json);
|
||||||
|
break;
|
||||||
|
case UNPROCESSED_BUSINESS:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
socketMsg.setRequestId(socketDataMsg.getRequestId());
|
||||||
|
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
|
||||||
|
socketMsg.setData(dictDataEnumByCode.getMessage());
|
||||||
|
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketMsg));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void extracted1(PreDetectionParam param, String msg, SocketDataMsg socketDataMsg) {
|
||||||
|
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||||
|
if(ObjectUtil.isNotNull(dictDataEnumByCode)){
|
||||||
|
SocketMsg socketMsg=new SocketMsg();
|
||||||
|
switch (dictDataEnumByCode){
|
||||||
|
case SUCCESS:
|
||||||
|
webSocketHandler.sendMsgToUser(param.getUserPageId(), msg);
|
||||||
|
String s = param.getUserPageId() + "_Dev";
|
||||||
|
//缺少向终端发送相序校验的参数
|
||||||
|
socketMsg.setRequestId(socketDataMsg.getRequestId());
|
||||||
|
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
|
||||||
|
List<PreDetection> pqDevList = iPqDevService.getDevInfo(param.getDevIds());
|
||||||
|
List<String> moniterIdList = pqDevList.stream().flatMap(x -> x.getMonitorList().stream())
|
||||||
|
.map(PreDetection.MonitorListDTO::getLineId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
DevPhaseSequenceParam phaseSequenceParam=new DevPhaseSequenceParam();
|
||||||
|
phaseSequenceParam.setMoniterIdList(moniterIdList);
|
||||||
|
// phaseSequenceParam.setDataType();
|
||||||
|
// phaseSequenceParam.setReadCount();
|
||||||
|
// phaseSequenceParam.setIgnoreCount();
|
||||||
|
//
|
||||||
|
// socketMsg.setData();
|
||||||
|
SocketManager.sendMsg(s,JSON.toJSONString(socketMsg));
|
||||||
|
break;
|
||||||
|
case UNPROCESSED_BUSINESS:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
socketMsg.setRequestId(socketDataMsg.getRequestId());
|
||||||
|
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
|
||||||
|
socketMsg.setData(dictDataEnumByCode.getMessage());
|
||||||
|
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketMsg));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.njcn.gather.detection.pojo.enums;
|
package com.njcn.gather.detection.pojo.enums;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,4 +42,13 @@ public enum SourceOperateCodeEnum {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
this.msg = msg;
|
this.msg = msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SourceOperateCodeEnum getDictDataEnumByCode(String value) {
|
||||||
|
for (SourceOperateCodeEnum sourceOperateCodeEnum : SourceOperateCodeEnum.values()) {
|
||||||
|
if (ObjectUtil.equals(value, sourceOperateCodeEnum.getValue())) {
|
||||||
|
return sourceOperateCodeEnum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.njcn.gather.detection.pojo.param;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wr
|
||||||
|
* @description
|
||||||
|
* @date 2024/12/18 9:17
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class DevPhaseSequenceParam {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 装置下测点集合
|
||||||
|
*/
|
||||||
|
@JSONField(name = "moniterIdList", ordinal = 1)
|
||||||
|
private List<String> moniterIdList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置需要的取值(平均值/电压有效值)
|
||||||
|
*/
|
||||||
|
@JSONField(name = "dataType", ordinal = 2)
|
||||||
|
private List<String> dataType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取多少组数据
|
||||||
|
*/
|
||||||
|
@JSONField(name = "readCount", ordinal = 3)
|
||||||
|
private Integer readCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 忽略多少组数据
|
||||||
|
*/
|
||||||
|
@JSONField(name = "ignoreCount", ordinal = 4)
|
||||||
|
private Integer ignoreCount;
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
package com.njcn.gather.detection.pojo.po;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wr
|
||||||
|
* @description
|
||||||
|
* @date 2024/12/18 9:09
|
||||||
|
*/
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class DevData {
|
||||||
|
|
||||||
|
@JSONField(name = "Time", ordinal = 1)
|
||||||
|
private String time;
|
||||||
|
|
||||||
|
@JSONField(name = "ID", ordinal = 2)
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@JSONField(name = "result", ordinal = 3)
|
||||||
|
private Boolean result;
|
||||||
|
|
||||||
|
@JSONField(name = "SqlData", ordinal = 4)
|
||||||
|
private List<SqlDataDTO> sqlData;
|
||||||
|
|
||||||
|
@JSONField(name = "SqlDataHarm", ordinal = 5)
|
||||||
|
private List<SqlDataHarmDTO> sqlDataHarm;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public static class SqlDataDTO {
|
||||||
|
//类型 平均值 最大值 最小值 CP95值 实时值
|
||||||
|
@JSONField(name = "type", ordinal = 1)
|
||||||
|
private String type;
|
||||||
|
//指标 电流有效值
|
||||||
|
@JSONField(name = "desc", ordinal = 2)
|
||||||
|
private String desc;
|
||||||
|
@JSONField(name = "list", ordinal = 3)
|
||||||
|
private ListDTO list;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public static class ListDTO {
|
||||||
|
@JSONField(name = "A", ordinal = 1)
|
||||||
|
private Float a;
|
||||||
|
@JSONField(name = "B", ordinal = 2)
|
||||||
|
private Float b;
|
||||||
|
@JSONField(name = "C", ordinal = 3)
|
||||||
|
private Float c;
|
||||||
|
@JSONField(name = "T", ordinal = 4)
|
||||||
|
private Float t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public static class SqlDataHarmDTO {
|
||||||
|
@JSONField(name = "type", ordinal = 1)
|
||||||
|
private String type;
|
||||||
|
@JSONField(name = "desc", ordinal = 2)
|
||||||
|
private String desc;
|
||||||
|
@JSONField(name = "num", ordinal = 3)
|
||||||
|
private Integer num;
|
||||||
|
@JSONField(name = "list", ordinal = 4)
|
||||||
|
private ListDTO list;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public static class ListDTO {
|
||||||
|
@JSONField(name = "A", ordinal = 1)
|
||||||
|
private List<String> a;
|
||||||
|
@JSONField(name = "B", ordinal = 2)
|
||||||
|
private List<String> b;
|
||||||
|
@JSONField(name = "C", ordinal = 3)
|
||||||
|
private List<String> c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,9 +12,7 @@ import com.njcn.gather.detection.service.PreDetectionService;
|
|||||||
|
|
||||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
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.NettyClient;
|
||||||
import com.njcn.gather.detection.util.socket.cilent.NettyDevClientHandler;
|
|
||||||
import com.njcn.gather.detection.util.socket.cilent.NettySourceClientHandler;
|
import com.njcn.gather.detection.util.socket.cilent.NettySourceClientHandler;
|
||||||
import com.njcn.gather.device.device.pojo.vo.PreDetection;
|
|
||||||
import com.njcn.gather.device.device.service.IPqDevService;
|
import com.njcn.gather.device.device.service.IPqDevService;
|
||||||
import com.njcn.gather.device.script.pojo.param.PqScriptIssueParam;
|
import com.njcn.gather.device.script.pojo.param.PqScriptIssueParam;
|
||||||
import com.njcn.gather.device.script.pojo.po.SourceIssue;
|
import com.njcn.gather.device.script.pojo.po.SourceIssue;
|
||||||
@@ -27,11 +25,6 @@ import com.njcn.gather.plan.service.IAdPlanService;
|
|||||||
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
||||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||||
import io.netty.channel.Channel;
|
|
||||||
import io.netty.channel.ChannelFuture;
|
|
||||||
import io.netty.channel.ChannelFutureListener;
|
|
||||||
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
|
||||||
import io.netty.channel.Channel;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -75,11 +68,11 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
switch (dictDataEnumByCode) {
|
switch (dictDataEnumByCode) {
|
||||||
case DIGITAL:
|
case DIGITAL:
|
||||||
case SIMULATE:
|
case SIMULATE:
|
||||||
sendYtxSocket(plan.getId(),param.getUserPageId());
|
sendYtxSocket(param);
|
||||||
break;
|
break;
|
||||||
case CONTRAST:
|
case CONTRAST:
|
||||||
//todo 对比式可以是多个源
|
//todo 对比式可以是多个源
|
||||||
sendYtxSocket(plan.getId(),param.getUserPageId());
|
sendYtxSocket(param);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//todo 没有找到对应的模式
|
//todo 没有找到对应的模式
|
||||||
@@ -92,9 +85,9 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
private void sendYtxSocket(String planId,String userPageId){
|
private void sendYtxSocket(PreDetectionParam param){
|
||||||
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>()
|
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>()
|
||||||
.eq(AdPlanSource::getPlanId,planId)
|
.eq(AdPlanSource::getPlanId,param.getPlanId())
|
||||||
);
|
);
|
||||||
if(ObjectUtil.isNotNull(planSource)){
|
if(ObjectUtil.isNotNull(planSource)){
|
||||||
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId());
|
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId());
|
||||||
@@ -104,16 +97,16 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
||||||
msg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
msg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||||
msg.setData(JSON.toJSONString(sourceParam));
|
msg.setData(JSON.toJSONString(sourceParam));
|
||||||
String s = userPageId + "_Source";
|
String s = param.getUserPageId() + "_Source";
|
||||||
NettyClient.socketClient(ip, port,userPageId, new NettySourceClientHandler(s, sourceResponseService));
|
NettyClient.socketClient(ip, port,param.getUserPageId(), new NettySourceClientHandler(param, sourceResponseService));
|
||||||
SocketManager.sendMsg(s,JSON.toJSONString(msg));
|
SocketManager.sendMsg(s,JSON.toJSONString(msg));
|
||||||
|
|
||||||
|
|
||||||
PqScriptIssueParam param=new PqScriptIssueParam();
|
PqScriptIssueParam issueParam=new PqScriptIssueParam();
|
||||||
param.setScriptId(planSource.getSourceId());
|
issueParam.setScriptId(planSource.getSourceId());
|
||||||
param.setPlanId(planId);
|
issueParam.setPlanId(param.getPlanId());
|
||||||
param.setSourceId(planSource.getSourceId());
|
issueParam.setSourceId(planSource.getSourceId());
|
||||||
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(param);
|
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||||
for (SourceIssue sourceIssue : sourceIssues) {
|
for (SourceIssue sourceIssue : sourceIssues) {
|
||||||
String jsonString = JSON.toJSONString(sourceIssue);
|
String jsonString = JSON.toJSONString(sourceIssue);
|
||||||
}
|
}
|
||||||
@@ -130,18 +123,18 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
@Override
|
@Override
|
||||||
public boolean startTest(PreDetectionParam param) {
|
public boolean startTest(PreDetectionParam param) {
|
||||||
|
|
||||||
Runnable runnable = new Runnable() {
|
// Runnable runnable = new Runnable() {
|
||||||
@Override
|
// @Override
|
||||||
public void run() {
|
// public void run() {
|
||||||
String ddId = param.getUserPageId();
|
// String ddId = param.getUserPageId();
|
||||||
Channel channel = SocketManager.getChannelByUserId(ddId);
|
// Channel channel = SocketManager.getChannelByUserId(ddId);
|
||||||
if( channel== null || !channel.isActive()){
|
// if( channel== null || !channel.isActive()){
|
||||||
NettyClient.socketClient(ip, port,param.getUserPageId(),new NettySourceClientHandler(ddId, sourceResponseService));
|
// NettyClient.socketClient(ip, port,param.getUserPageId(),new NettySourceClientHandler(ddId, sourceResponseService));
|
||||||
}
|
// }
|
||||||
SocketManager.sendMsg(ddId,"start\n");
|
// SocketManager.sendMsg(ddId,"start\n");
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
runnable.run();
|
// runnable.run();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.njcn.gather.detection.util.socket.cilent;
|
package com.njcn.gather.detection.util.socket.cilent;
|
||||||
|
|
||||||
import com.njcn.gather.detection.handler.SocketResponseService;
|
import com.njcn.gather.detection.handler.SocketDevResponseService;
|
||||||
import com.njcn.gather.detection.handler.SocketSourceResponseService;
|
|
||||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||||
import com.njcn.gather.detection.util.socket.WebServiceManager;
|
import com.njcn.gather.detection.util.socket.WebServiceManager;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
@@ -28,7 +27,7 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
|||||||
|
|
||||||
private final String webUser;
|
private final String webUser;
|
||||||
|
|
||||||
private final SocketResponseService socketResponseService;
|
private final SocketDevResponseService socketResponseService;
|
||||||
|
|
||||||
@Value("${socket.device.ip}")
|
@Value("${socket.device.ip}")
|
||||||
private String devIp;
|
private String devIp;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.gather.detection.util.socket.cilent;
|
package com.njcn.gather.detection.util.socket.cilent;
|
||||||
|
|
||||||
import com.njcn.gather.detection.handler.SocketSourceResponseService;
|
import com.njcn.gather.detection.handler.SocketSourceResponseService;
|
||||||
|
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.SimpleChannelInboundHandler;
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
@@ -17,8 +18,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class NettySourceClientHandler extends SimpleChannelInboundHandler<String> {
|
public class NettySourceClientHandler extends SimpleChannelInboundHandler<String> {
|
||||||
|
|
||||||
private final String webUser;
|
private final PreDetectionParam webUser;
|
||||||
|
|
||||||
private final SocketSourceResponseService sourceResponseService;
|
private final SocketSourceResponseService sourceResponseService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,7 +78,7 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<Strin
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handlerAdded(ChannelHandlerContext ctx) {
|
public void handlerAdded(ChannelHandlerContext ctx) {
|
||||||
SocketManager.addUser(webUser,ctx.channel());
|
SocketManager.addUser(webUser.getUserPageId()+"_Source",ctx.channel());
|
||||||
System.out.println("有通道接入" + ctx.channel());
|
System.out.println("有通道接入" + ctx.channel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user