调整
This commit is contained in:
@@ -6,8 +6,10 @@ 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.DevPhaseSequenceParam;
|
||||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||||
|
import com.njcn.gather.detection.pojo.vo.DevLineTestResult;
|
||||||
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.pojo.vo.WebSocketVO;
|
||||||
import com.njcn.gather.detection.util.socket.MsgUtil;
|
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||||
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;
|
||||||
@@ -19,10 +21,7 @@ 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.Arrays;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -46,9 +45,14 @@ public class SocketSourceResponseService {
|
|||||||
@Value("${socket.device.port}")
|
@Value("${socket.device.port}")
|
||||||
private Integer port;
|
private Integer port;
|
||||||
|
|
||||||
|
private List<PreDetection> devList = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void deal(PreDetectionParam param, String msg) {
|
public void deal(PreDetectionParam param, String msg) {
|
||||||
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
|
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
|
||||||
SourceOperateCodeEnum enumByCode = SourceOperateCodeEnum.getDictDataEnumByCode(socketDataMsg.getRequestId());
|
String[] tem = socketDataMsg.getRequestId().split("&&");
|
||||||
|
SourceOperateCodeEnum enumByCode = SourceOperateCodeEnum.getDictDataEnumByCode(tem[0]);
|
||||||
if (ObjectUtil.isNotNull(enumByCode)) {
|
if (ObjectUtil.isNotNull(enumByCode)) {
|
||||||
switch (enumByCode) {
|
switch (enumByCode) {
|
||||||
//源初始化
|
//源初始化
|
||||||
@@ -64,8 +68,8 @@ public class SocketSourceResponseService {
|
|||||||
openSource(param, socketDataMsg);
|
openSource(param, socketDataMsg);
|
||||||
break;
|
break;
|
||||||
case QUITE_SOURCE:
|
case QUITE_SOURCE:
|
||||||
|
quitDeal(socketDataMsg,param);
|
||||||
// System.out.println("关闭源回调:"+msg);
|
// System.out.println("关闭源回调:"+msg);
|
||||||
SocketManager.removeUser(param.getUserPageId() + source);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -92,7 +96,7 @@ public class SocketSourceResponseService {
|
|||||||
|
|
||||||
//todo 前端推送收到的消息暂未处理好
|
//todo 前端推送收到的消息暂未处理好
|
||||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||||
String s = param.getUserPageId() + "_Dev";
|
String s = param.getUserPageId() + DEV;
|
||||||
//开始设备通讯检测(发送设备初始化)
|
//开始设备通讯检测(发送设备初始化)
|
||||||
List<PreDetection> devList = iPqDevService.getDevInfo(param.getDevIds());
|
List<PreDetection> devList = iPqDevService.getDevInfo(param.getDevIds());
|
||||||
Map<String, List<PreDetection>> map = new HashMap(1);
|
Map<String, List<PreDetection>> map = new HashMap(1);
|
||||||
@@ -180,19 +184,32 @@ public class SocketSourceResponseService {
|
|||||||
// webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
// webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||||
|
|
||||||
String s = param.getUserPageId() + DEV;
|
String s = param.getUserPageId() + DEV;
|
||||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue());
|
socketMsg.setRequestId(SourceOperateCodeEnum.Test_VOL.getValue());
|
||||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue());
|
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_02.getValue());
|
||||||
List<PreDetection> pqDevList = iPqDevService.getDevInfo(param.getDevIds());
|
List<String> moniterIdList = devList.stream().flatMap(x -> x.getMonitorList().stream())
|
||||||
List<String> moniterIdList = pqDevList.stream().flatMap(x -> x.getMonitorList().stream())
|
|
||||||
.map(PreDetection.MonitorListDTO::getLineId)
|
.map(PreDetection.MonitorListDTO::getLineId)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
|
DevPhaseSequenceParam phaseSequenceParam = new DevPhaseSequenceParam();
|
||||||
phaseSequenceParam.setMoniterIdList(moniterIdList);
|
phaseSequenceParam.setMoniterIdList(moniterIdList);
|
||||||
phaseSequenceParam.setDataType(Arrays.asList("实时数据/电压有效值", "实时数据/电流有效值"));
|
phaseSequenceParam.setDataType(Arrays.asList("real$VRMS"));
|
||||||
phaseSequenceParam.setReadCount(20);
|
phaseSequenceParam.setReadCount(20);
|
||||||
phaseSequenceParam.setIgnoreCount(10);
|
phaseSequenceParam.setIgnoreCount(10);
|
||||||
socketMsg.setData(JSON.toJSONString(phaseSequenceParam));
|
socketMsg.setData(JSON.toJSONString(phaseSequenceParam));
|
||||||
SocketManager.sendMsg(s, JSON.toJSONString(socketMsg));
|
SocketManager.sendMsg(s, JSON.toJSONString(socketMsg));
|
||||||
|
|
||||||
|
|
||||||
|
WebSocketVO<List<DevLineTestResult>> webSocketVO = new WebSocketVO<>();
|
||||||
|
webSocketVO.setRequestId(socketDataMsg.getRequestId().split("&&")[1]+"_Start");
|
||||||
|
List<DevLineTestResult> devListRes = new ArrayList<>();
|
||||||
|
devList.forEach(item->{
|
||||||
|
DevLineTestResult devLineTestResult = new DevLineTestResult();
|
||||||
|
devLineTestResult.setDeviceId(item.getDevId());
|
||||||
|
devLineTestResult.setDeviceName(item.getDevName());
|
||||||
|
devListRes.add(devLineTestResult);
|
||||||
|
});
|
||||||
|
webSocketVO.setData(devListRes);
|
||||||
|
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case UNPROCESSED_BUSINESS:
|
case UNPROCESSED_BUSINESS:
|
||||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||||
@@ -207,4 +224,33 @@ public class SocketSourceResponseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退出检测返回
|
||||||
|
*/
|
||||||
|
private void quitDeal(SocketDataMsg socketDataMsg, PreDetectionParam param) {
|
||||||
|
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||||
|
SourceOperateCodeEnum operateCodeEnum = SourceOperateCodeEnum.getDictDataEnumByCode(socketDataMsg.getOperateCode());
|
||||||
|
SocketMsg socketMsg = new SocketMsg();
|
||||||
|
switch (dictDataEnumByCode) {
|
||||||
|
case SUCCESS:
|
||||||
|
//通讯校验成功
|
||||||
|
SocketManager.removeUser(param.getUserPageId() + source);
|
||||||
|
break;
|
||||||
|
case UNPROCESSED_BUSINESS:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
WebSocketVO webSocketVO = new WebSocketVO();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void initList(PreDetectionParam param){
|
||||||
|
devList.clear();
|
||||||
|
this.devList = iPqDevService.getDevInfo(param.getDevIds());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,16 @@ public enum SourceOperateCodeEnum {
|
|||||||
|
|
||||||
PRE_TEST("0","预检测"),
|
PRE_TEST("0","预检测"),
|
||||||
FORMAL_TEST("1","正式检测"),
|
FORMAL_TEST("1","正式检测"),
|
||||||
TIME_TEST("2","守时检测")
|
TIME_TEST("2","守时检测"),
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测类型
|
||||||
|
*/
|
||||||
|
Test_Freq("formal_real&&Test_Freq","频率检测"),
|
||||||
|
Test_VOL("formal_real&&Test_VOL","电压检测"),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.njcn.gather.detection.pojo.vo;
|
||||||
|
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: cdf
|
||||||
|
* @CreateTime: 2024-12-26
|
||||||
|
* @Description: 装置测点检测结果
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DevLineTestResult {
|
||||||
|
|
||||||
|
private String deviceId;
|
||||||
|
|
||||||
|
private String deviceName;
|
||||||
|
|
||||||
|
private Integer[] chnResult;
|
||||||
|
}
|
||||||
@@ -47,7 +47,7 @@ public class DetectionServiceImpl {
|
|||||||
devDataMap.forEach(((key, value) -> {
|
devDataMap.forEach(((key, value) -> {
|
||||||
Integer num;
|
Integer num;
|
||||||
Boolean b = DetectionIndexProcessing(value, dataRule, issue);
|
Boolean b = DetectionIndexProcessing(value, dataRule, issue);
|
||||||
if (ObjectUtil.isNull(b)) {
|
if (ObjectUtil.isNotNull(b)) {
|
||||||
if (b) {
|
if (b) {
|
||||||
num = 1;
|
num = 1;
|
||||||
} else {
|
} else {
|
||||||
@@ -74,7 +74,7 @@ public class DetectionServiceImpl {
|
|||||||
public Boolean DetectionIndexProcessing(List<DevData> dev, DictDataEnum dataRule, SourceIssue sourceIssue) {
|
public Boolean DetectionIndexProcessing(List<DevData> dev, DictDataEnum dataRule, SourceIssue sourceIssue) {
|
||||||
PqErrSysParam.DetectionParam param = new PqErrSysParam.DetectionParam();
|
PqErrSysParam.DetectionParam param = new PqErrSysParam.DetectionParam();
|
||||||
List<PqErrSysDtls> pqErrSysDtls = pqErrSysDtlsService.listPqErrSysDtlsByPqErrSysIdAndTypes(param);
|
List<PqErrSysDtls> pqErrSysDtls = pqErrSysDtlsService.listPqErrSysDtlsByPqErrSysIdAndTypes(param);
|
||||||
switch (sourceIssue.getType()) {
|
switch ("V") {
|
||||||
/**
|
/**
|
||||||
* 频率
|
* 频率
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
private final IPqScriptDtlsService pqScriptDtlsService;
|
private final IPqScriptDtlsService pqScriptDtlsService;
|
||||||
|
|
||||||
private final SocketDevResponseService socketDevResponseService;
|
private final SocketDevResponseService socketDevResponseService;
|
||||||
|
private final SocketSourceResponseService socketSourceResponseService;
|
||||||
|
|
||||||
|
|
||||||
@Value("${socket.source.ip:192.168.1.136}")
|
@Value("${socket.source.ip:192.168.1.136}")
|
||||||
@@ -68,6 +69,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
public void sourceCommunicationCheck(PreDetectionParam param) {
|
public void sourceCommunicationCheck(PreDetectionParam param) {
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println("进来了啊啊啊啊啊啊啊啊啊啊啊啊啊");
|
||||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
|
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
|
||||||
if (Objects.nonNull(channel) && channel.isActive()) {
|
if (Objects.nonNull(channel) && channel.isActive()) {
|
||||||
System.out.println("进入关闭源。。//////");
|
System.out.println("进入关闭源。。//////");
|
||||||
@@ -133,6 +135,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
|||||||
if (ObjectUtil.isNotNull(sourceParam)) {
|
if (ObjectUtil.isNotNull(sourceParam)) {
|
||||||
//开始组装socket报文请求头
|
//开始组装socket报文请求头
|
||||||
socketDevResponseService.initList(param);
|
socketDevResponseService.initList(param);
|
||||||
|
socketSourceResponseService.initList(param);
|
||||||
SocketMsg msg = new SocketMsg();
|
SocketMsg msg = new SocketMsg();
|
||||||
msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
||||||
msg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
|
msg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.gather.detection.util.socket;
|
package com.njcn.gather.detection.util.socket;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.njcn.gather.device.script.pojo.po.SourceIssue;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.nio.NioEventLoopGroup;
|
import io.netty.channel.nio.NioEventLoopGroup;
|
||||||
|
|
||||||
@@ -60,5 +61,26 @@ public class SocketManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于存储源操作的脚本信息
|
||||||
|
* key:
|
||||||
|
*/
|
||||||
|
private static final Map<String, SourceIssue> targetMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public static void addSourceTarget(String sourceTag, SourceIssue sourceIssue) {
|
||||||
|
targetMap.put(sourceTag, sourceIssue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void delSourceTarget(String sourceTag) {
|
||||||
|
targetMap.remove(sourceTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SourceIssue getSourceTarget(String sourceTag) {
|
||||||
|
return targetMap.get(sourceTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -69,6 +70,11 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PqErrSysDtls> listPqErrSysDtlsByPqErrSysIdAndTypes(PqErrSysParam.DetectionParam param) {
|
public List<PqErrSysDtls> listPqErrSysDtlsByPqErrSysIdAndTypes(PqErrSysParam.DetectionParam param) {
|
||||||
|
return this.list(new LambdaQueryWrapper<PqErrSysDtls>()
|
||||||
|
.in(PqErrSysDtls::getId, Arrays.asList("ae86b657f37151d78b7c34ec64eefa10"))
|
||||||
|
// .eq(PqErrSysDtls::getErrorSysId, param.getErrorSysId())
|
||||||
|
// .in(PqErrSysDtls::getErrorSysId, param.getType())
|
||||||
|
);
|
||||||
//根据检测脚本id和检测序号,查询出检测子项目
|
//根据检测脚本id和检测序号,查询出检测子项目
|
||||||
|
|
||||||
|
|
||||||
@@ -76,6 +82,6 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
|
|||||||
// .eq(PqErrSysDtls::getErrorSysId, param.getErrorSysId())
|
// .eq(PqErrSysDtls::getErrorSysId, param.getErrorSysId())
|
||||||
// .in(PqErrSysDtls::getErrorSysId, param.getType())
|
// .in(PqErrSysDtls::getErrorSysId, param.getType())
|
||||||
// );
|
// );
|
||||||
return new ArrayList<>();
|
// return new ArrayList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user