代码调整
This commit is contained in:
@@ -47,18 +47,7 @@ public class PreDetectionController extends BaseController {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 终止预检测
|
||||
*/
|
||||
@PostMapping("/closePreTest")
|
||||
@OperateInfo
|
||||
@ApiOperation("终止检测")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<String> closePreTest(@RequestBody PreDetectionParam param){
|
||||
String methodDescribe = getMethodDescribe("closePreTest");
|
||||
preDetectionService.closePreTest(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 开始检测
|
||||
@@ -90,6 +79,33 @@ public class PreDetectionController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 暂停检测
|
||||
*/
|
||||
@GetMapping("/closePreTest")
|
||||
@OperateInfo
|
||||
@ApiOperation("暂停检测")
|
||||
@ApiImplicitParam(name = "param", value = "参数", required = true)
|
||||
public HttpResult<String> temStopTest(){
|
||||
String methodDescribe = getMethodDescribe("temStopTest");
|
||||
preDetectionService.temStopTest();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新开始检测
|
||||
*/
|
||||
@GetMapping("/restartTemTest")
|
||||
@OperateInfo
|
||||
@ApiOperation("重新开始检测")
|
||||
@ApiImplicitParam(name = "param", value = "参数", required = true)
|
||||
public HttpResult<String> restartTemTest(){
|
||||
String methodDescribe = getMethodDescribe("restartTemTest");
|
||||
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 测试
|
||||
|
||||
@@ -12,10 +12,7 @@ import com.njcn.gather.detection.pojo.po.DevData;
|
||||
import com.njcn.gather.detection.pojo.po.SourceCompareDev;
|
||||
import com.njcn.gather.detection.pojo.vo.*;
|
||||
import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import com.njcn.gather.detection.util.socket.XiNumberManager;
|
||||
import com.njcn.gather.detection.util.socket.*;
|
||||
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;
|
||||
@@ -58,11 +55,15 @@ public class SocketDevResponseService {
|
||||
|
||||
private final String handlerStr = "_Dev";
|
||||
private final String handlerSourceStr = "_Source";
|
||||
private final String stepTag = "&&";
|
||||
private final String splitTag = "_";
|
||||
private final String stepBegin = "_Start";
|
||||
private final String stepEnd = "_End";
|
||||
// ISO 8601格式
|
||||
private final DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;
|
||||
|
||||
|
||||
private final List<String> nonHarmonicList = Stream.of(DicDataEnum.FREQ.getCode(), DicDataEnum.V.getCode(), DicDataEnum.I.getCode(), DicDataEnum.IMBV.getCode(), DicDataEnum.IMBA.getCode(),DicDataEnum.VOLTAGE.getCode()).collect(Collectors.toList());
|
||||
private final List<String> nonHarmonicList = Stream.of(DicDataEnum.FREQ.getCode(), DicDataEnum.V.getCode(), DicDataEnum.I.getCode(), DicDataEnum.IMBV.getCode(), DicDataEnum.IMBA.getCode(), DicDataEnum.VOLTAGE.getCode()).collect(Collectors.toList());
|
||||
private final List<String> harmonicList = Stream.of(DicDataEnum.HV.getCode(), DicDataEnum.HI.getCode(), DicDataEnum.HP.getCode(), DicDataEnum.HSV.getCode(), DicDataEnum.HSI.getCode()).collect(Collectors.toList());
|
||||
|
||||
private final WebSocketHandler webSocketHandler;
|
||||
@@ -93,7 +94,7 @@ public class SocketDevResponseService {
|
||||
*/
|
||||
List<String> monitorIdListComm = new ArrayList<>();
|
||||
|
||||
private List<PreDetection> devList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 装置名称
|
||||
*/
|
||||
@@ -112,16 +113,14 @@ public class SocketDevResponseService {
|
||||
*/
|
||||
List<String> successXieyi = new ArrayList<>();
|
||||
List<String> successXieyi3 = new ArrayList<>();
|
||||
DictDataEnum dataRule;
|
||||
|
||||
|
||||
DictDataEnum dataRule;
|
||||
|
||||
|
||||
//标识当前检测小项是否结束
|
||||
|
||||
public void deal(PreDetectionParam param, String msg) throws Exception {
|
||||
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
|
||||
String[] tem = socketDataMsg.getRequestId().split("&&");
|
||||
String[] tem = socketDataMsg.getRequestId().split(stepTag);
|
||||
SourceOperateCodeEnum sourceOperateCodeEnum = SourceOperateCodeEnum.getDictDataEnumByCode(tem[0]);
|
||||
|
||||
switch (Objects.requireNonNull(sourceOperateCodeEnum)) {
|
||||
@@ -157,6 +156,7 @@ public class SocketDevResponseService {
|
||||
|
||||
//用于存储所有测点的试试数据
|
||||
private final List<DevData> realDataXiList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 系数校验
|
||||
*/
|
||||
@@ -197,7 +197,7 @@ public class SocketDevResponseService {
|
||||
System.out.println("开始配置小电压电流参数下发给源----------------------");
|
||||
xiSocket.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
xiSocket.setData(JSON.toJSONString(XiNumberManager.xiSourceIssueList.get(1)));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, MsgUtil.toJsonWithNewLinePlain(xiSocket));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(xiSocket));
|
||||
} else if (XiNumberManager.stepNumber == 1) {
|
||||
//小电流系数下发完毕;开始重新测试一次大电压
|
||||
sendWebSocket(param.getUserPageId(), SourceOperateCodeEnum.Coefficient_Check.getValue(), SourceOperateCodeEnum.small_end.getValue(), XiNumberManager.devParameterList.get(0));
|
||||
@@ -205,7 +205,7 @@ public class SocketDevResponseService {
|
||||
|
||||
xiSocket.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
xiSocket.setData(JSON.toJSONString(XiNumberManager.xiSourceIssueList.get(0)));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, MsgUtil.toJsonWithNewLinePlain(xiSocket));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(xiSocket));
|
||||
XiNumberManager.stepNumber = 2;
|
||||
}
|
||||
realDataXiList.clear();
|
||||
@@ -247,7 +247,7 @@ public class SocketDevResponseService {
|
||||
if (successComm.size() == monitorIdListComm.size()) {
|
||||
System.out.println("从装置中已经完成获取原始数据,准备开始计算----------------------");
|
||||
//获取数据流程结束,先把所有数据存到内存中
|
||||
Map<String, List<DevData>> realDataXiMap = realDataXiList.stream().collect(Collectors.groupingBy(it -> it.getId().split("_")[0]));
|
||||
Map<String, List<DevData>> realDataXiMap = realDataXiList.stream().collect(Collectors.groupingBy(it -> it.getId().split(splitTag)[0]));
|
||||
realDataXiMap.forEach((devIp, dataList) -> {
|
||||
XiNumberManager.devXiList.add(devIp);
|
||||
Map<String, List<DevData>> monitorMap = dataList.stream().collect(Collectors.groupingBy(DevData::getId));
|
||||
@@ -267,7 +267,7 @@ public class SocketDevResponseService {
|
||||
coefficientVO.setType("small");
|
||||
}
|
||||
|
||||
String[] splitStr = monitorId.split("_");
|
||||
String[] splitStr = monitorId.split(splitTag);
|
||||
coefficientVO.setMonitorNum(splitStr[1]);
|
||||
coefficientVO.setDevName(devNameMapComm.get(splitStr[0]));
|
||||
coefficientVO.setDesc((XiNumberManager.stepNumber == 0 || XiNumberManager.stepNumber == 1) ? "系数下装" : "系数校准");
|
||||
@@ -378,7 +378,7 @@ public class SocketDevResponseService {
|
||||
//小电流系数下发完毕;开始重新测试一次大电压
|
||||
xiSocket.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
xiSocket.setData(JSON.toJSONString(XiNumberManager.xiSourceIssueList.get(0)));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, MsgUtil.toJsonWithNewLinePlain(xiSocket));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(xiSocket));
|
||||
XiNumberManager.stepNumber = 2;
|
||||
realDataXiList.clear();
|
||||
successComm.clear();
|
||||
@@ -390,7 +390,7 @@ public class SocketDevResponseService {
|
||||
|
||||
xiSocket.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
xiSocket.setData(JSON.toJSONString(XiNumberManager.xiSourceIssueList.get(1)));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, MsgUtil.toJsonWithNewLinePlain(xiSocket));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(xiSocket));
|
||||
XiNumberManager.stepNumber = 3;
|
||||
realDataXiList.clear();
|
||||
successComm.clear();
|
||||
@@ -523,7 +523,7 @@ public class SocketDevResponseService {
|
||||
//通讯校验成功
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), MsgUtil.msgToWebData(socketDataMsg, devNameMapComm, 1));
|
||||
successComm.add(socketDataMsg.getData());
|
||||
System.out.println("设备通讯校验全部成功!"+successComm.size() + "=====" + monitorIdListComm.size());
|
||||
System.out.println("设备通讯校验全部成功!" + successComm.size() + "=====" + monitorIdListComm.size());
|
||||
if (successComm.size() == monitorIdListComm.size()) {
|
||||
|
||||
SocketDataMsg temMsg = new SocketDataMsg();
|
||||
@@ -574,7 +574,7 @@ public class SocketDevResponseService {
|
||||
WebSocketVO<String> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(SourceOperateCodeEnum.UNKNOWN_OPERATE.getValue());
|
||||
webSocketVO.setData(SourceOperateCodeEnum.UNKNOWN_OPERATE.getMsg());
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(),JSON.toJSONString(webSocketVO));
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -586,7 +586,6 @@ public class SocketDevResponseService {
|
||||
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
String s = param.getUserPageId() + handlerStr;
|
||||
|
||||
switch (Objects.requireNonNull(dictDataEnumByCode)) {
|
||||
case SUCCESS:
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), MsgUtil.msgToWebData(socketDataMsg, devNameMapComm, 2));
|
||||
@@ -604,7 +603,7 @@ public class SocketDevResponseService {
|
||||
}
|
||||
|
||||
Map<String, List<PreDetection>> map = new HashMap<>(1);
|
||||
map.put("deviceList", devList);
|
||||
map.put("deviceList", FormalTestManager.devList);
|
||||
String jsonString = JSON.toJSONString(map);
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XYJY.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_INIT_GATHER_03.getValue());
|
||||
@@ -628,8 +627,7 @@ public class SocketDevResponseService {
|
||||
issueParam.setDevIds(param.getDevIds());
|
||||
issueParam.setScriptId(param.getScriptId());
|
||||
|
||||
SocketMsg<String> xuMsg = new SocketMsg<>();
|
||||
xuMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
List<SourceIssue> sourceIssues;
|
||||
if (SourceOperateCodeEnum.FORMAL_TEST.getValue().equals(param.getOperateType())) {
|
||||
//正式检测
|
||||
@@ -639,39 +637,27 @@ public class SocketDevResponseService {
|
||||
SocketManager.addSourceList(sourceIssues);
|
||||
Map<String, Long> sourceIssueMap = sourceIssues.stream().collect(Collectors.groupingBy(SourceIssue::getType, Collectors.counting()));
|
||||
SocketManager.initMap(sourceIssueMap);
|
||||
xuMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||
xuMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + "&&" + sourceIssues.get(0).getType());
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, MsgUtil.toJsonWithNewLinePlain(xuMsg));
|
||||
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + stepTag + sourceIssues.get(0).getType());
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(socketMsg));
|
||||
|
||||
} else if (SourceOperateCodeEnum.PRE_TEST.getValue().equals(param.getOperateType()) || SourceOperateCodeEnum.COEFFICIENT_TEST.getValue().equals(param.getOperateType())) {
|
||||
//预检测的相序检测 以及系数校验都需要进行相序检测
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.PHASE_TEST.getValue());
|
||||
xuMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||
sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||
xuMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, MsgUtil.toJsonWithNewLinePlain(xuMsg));
|
||||
} else {
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(socketMsg));
|
||||
} else if (SourceOperateCodeEnum.TEST_TEM_START.getValue().equals(param.getOperateType())) {
|
||||
if (CollUtil.isNotEmpty(SocketManager.getSourceList())) {
|
||||
SourceIssue sourceIssue = SocketManager.getSourceList().get(0);
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + stepTag + sourceIssue.getType());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
socketMsg.setData(JSON.toJSONString(sourceIssue));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(socketMsg));
|
||||
}
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
/* WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||
webSocketVO.setOperateCode(SourceOperateCodeEnum.big_start.getValue());
|
||||
webSocketVO.setData(XiNumberManager.devParameterList.get(0));
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||
|
||||
xuMsg.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||
xuMsg.setData(JSON.toJSONString(XiNumberManager.xiSourceIssueList.get(0)));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, MsgUtil.toJsonWithNewLinePlain(xuMsg));
|
||||
|
||||
XiNumberManager.stepNumber = 0;
|
||||
XiNumberManager.devXiList.clear();
|
||||
XiNumberManager.devXiNumDataMap.clear();
|
||||
XiNumberManager.smallDevXiNumDataMap.clear();*/
|
||||
|
||||
|
||||
//系数校验只支持单个装置修改系数
|
||||
// SocketManager.monitorXiList = new ArrayList<>(monitorIdListComm);
|
||||
}
|
||||
successComm.clear();
|
||||
}
|
||||
@@ -700,7 +686,7 @@ public class SocketDevResponseService {
|
||||
WebSocketVO<String> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(SourceOperateCodeEnum.UNKNOWN_OPERATE.getValue());
|
||||
webSocketVO.setData(SourceOperateCodeEnum.UNKNOWN_OPERATE.getMsg());
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(),JSON.toJSONString(webSocketVO));
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -722,7 +708,7 @@ public class SocketDevResponseService {
|
||||
success.add(devData.getId());
|
||||
|
||||
if (success.size() == monitorIdListComm.size()) {
|
||||
System.out.println("相序校验接受数据完成---------"+success.size()+"__"+monitorIdListComm.size());
|
||||
System.out.println("相序校验接受数据完成---------" + success.size() + "__" + monitorIdListComm.size());
|
||||
|
||||
PqScriptIssueParam sourceParam = new PqScriptIssueParam();
|
||||
sourceParam.setPlanId(param.getPlanId());
|
||||
@@ -743,7 +729,7 @@ public class SocketDevResponseService {
|
||||
dataMsg.setCode(SourceResponseCodeEnum.SUCCESS.getCode());
|
||||
|
||||
for (SourceCompareDev sourceCompareDev : info) {
|
||||
dataMsg.setData(sourceCompareDev.getDevName() + "_" + sourceCompareDev.getLineNum() + sourceCompareDev.getDesc() + "校验结果:" + (sourceCompareDev.getIsQualified() ? "合格" : "不合格"));
|
||||
dataMsg.setData(sourceCompareDev.getDevName() + splitTag + sourceCompareDev.getLineNum() + sourceCompareDev.getDesc() + "校验结果:" + (sourceCompareDev.getIsQualified() ? "合格" : "不合格"));
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(dataMsg));
|
||||
}
|
||||
}
|
||||
@@ -755,11 +741,11 @@ public class SocketDevResponseService {
|
||||
temMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(temMsg));
|
||||
|
||||
if(param.getOperateType().equals(SourceOperateCodeEnum.PRE_TEST.getValue())){
|
||||
if (param.getOperateType().equals(SourceOperateCodeEnum.PRE_TEST.getValue())) {
|
||||
System.out.println("预检测流程接受-----------------关闭源");
|
||||
//同时关闭设备三个步骤
|
||||
CnSocketUtil.quitSend(param);
|
||||
}else if(param.getOperateType().equals(SourceOperateCodeEnum.COEFFICIENT_TEST.getValue())){
|
||||
} else if (param.getOperateType().equals(SourceOperateCodeEnum.COEFFICIENT_TEST.getValue())) {
|
||||
WebSocketVO<Object> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||
webSocketVO.setOperateCode(SourceOperateCodeEnum.big_start.getValue());
|
||||
@@ -770,7 +756,7 @@ public class SocketDevResponseService {
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
socketMsg.setData(JSON.toJSONString(XiNumberManager.xiSourceIssueList.get(0)));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, MsgUtil.toJsonWithNewLinePlain(socketMsg));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(socketMsg));
|
||||
|
||||
XiNumberManager.stepNumber = 0;
|
||||
XiNumberManager.devXiList.clear();
|
||||
@@ -803,7 +789,7 @@ public class SocketDevResponseService {
|
||||
WebSocketVO<String> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(SourceOperateCodeEnum.UNKNOWN_OPERATE.getValue());
|
||||
webSocketVO.setData(SourceOperateCodeEnum.UNKNOWN_OPERATE.getMsg());
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(),JSON.toJSONString(webSocketVO));
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -823,17 +809,19 @@ public class SocketDevResponseService {
|
||||
switch (Objects.requireNonNull(dictDataEnumByCode)) {
|
||||
case SUCCESS:
|
||||
realDataXiList.add(devData);
|
||||
successComm.add(socketDataMsg.getRequestId());
|
||||
successComm.add(devData.getId());
|
||||
|
||||
//FormalTestManager.devXiNumDataMap.put(devData.getId(),)
|
||||
|
||||
if (successComm.size() == monitorIdListComm.size()) {
|
||||
//TODO 理论上遇到返回code10200的数量与监测点数量一致则认为数据返回结束,但是会存在缺失数据情况,例如有部分装置是没有暂降功能的
|
||||
System.out.println(sourceIssue.getType() + "_" + sourceIssue.getIndex() + "当前测试小项读取数据已经全部结束。。。。。。。。。");
|
||||
System.out.println(sourceIssue.getType() + splitTag + sourceIssue.getIndex() + "当前测试小项读取数据已经全部结束。。。。。。。。。");
|
||||
|
||||
//开启线程进行入库原始数据操作
|
||||
baseDataInsert(realDataXiList, sourceIssue, param, SocketManager.valueTypeMap);
|
||||
|
||||
Map<String, Integer> flag = detectionServiceImpl.processing(realDataXiList, param, devIdMapComm, sourceIssue, dataRule);
|
||||
System.out.println(flag);
|
||||
//调用判断方法
|
||||
Map<String, Integer> textResult = detectionServiceImpl.processing(realDataXiList, param, devIdMapComm, sourceIssue, dataRule);
|
||||
|
||||
long tem = SocketManager.getSourceTarget(sourceIssue.getType()) - 1;
|
||||
SocketManager.addTargetMap(sourceIssue.getType(), tem);
|
||||
@@ -841,13 +829,12 @@ public class SocketDevResponseService {
|
||||
|
||||
if (tem == 0) {
|
||||
System.out.println(sourceIssue.getType() + sourceIssue.getIndex() + "当前测试大项已经全部结束》》》》》》》》");
|
||||
|
||||
//当val为0则认为大项中的小项已经全部跑完,开始组装信息推送给前端
|
||||
WebSocketVO<List<DevLineTestResult>> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(socketDataMsg.getRequestId().split("&&")[1] + "_End");
|
||||
webSocketVO.setRequestId(socketDataMsg.getRequestId().split(stepTag)[1] + stepEnd);
|
||||
//组装实体推送给前台
|
||||
List<DevLineTestResult> devListRes = new ArrayList<>();
|
||||
devList.forEach(dev -> {
|
||||
FormalTestManager.devList.forEach(dev -> {
|
||||
DevLineTestResult devLineTestResult = new DevLineTestResult();
|
||||
devLineTestResult.setDeviceId(dev.getDevId());
|
||||
devLineTestResult.setDeviceName(dev.getDevName());
|
||||
@@ -855,7 +842,7 @@ public class SocketDevResponseService {
|
||||
List<Integer> resultFlagList = new ArrayList<>();
|
||||
List<PreDetection.MonitorListDTO> monitorListDTOList = dev.getMonitorList();
|
||||
for (PreDetection.MonitorListDTO point : monitorListDTOList) {
|
||||
Integer resultFlag = flag.get(dev.getDevIP() + "_" + point.getLine());
|
||||
Integer resultFlag = textResult.get(dev.getDevIP() + splitTag + point.getLine());
|
||||
resultFlagList.add(resultFlag);
|
||||
}
|
||||
devLineTestResult.setChnResult(resultFlagList.toArray(new Integer[monitorListDTOList.size()]));
|
||||
@@ -864,21 +851,28 @@ public class SocketDevResponseService {
|
||||
webSocketVO.setData(devListRes);
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||
}
|
||||
System.out.println("当前小项结束进行删除============" + sourceIssue.getType() + "_" + sourceIssue.getIndex());
|
||||
System.out.println("当前小项结束进行删除============" + sourceIssue.getType() + splitTag + sourceIssue.getIndex());
|
||||
|
||||
//当小项结束后需要删除集合中的小项
|
||||
SocketManager.delSource(sourceIssue.getIndex());
|
||||
//在这一步判断是否已经触发暂停按钮
|
||||
if (FormalTestManager.stopFlag) {
|
||||
CnSocketUtil.quitSend(param);
|
||||
successComm.clear();
|
||||
realDataXiList.clear();
|
||||
sendWebSocket(param.getUserPageId(), "preStopTest", "stop", null);
|
||||
}
|
||||
|
||||
//开始进行下一项检测
|
||||
List<SourceIssue> sourceIssueList = SocketManager.getSourceList();
|
||||
if (CollUtil.isNotEmpty(sourceIssueList)) {
|
||||
|
||||
SourceIssue sourceIssues = SocketManager.getSourceList().get(0);
|
||||
SocketMsg<String> xuMsg = new SocketMsg<>();
|
||||
xuMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
|
||||
//正式检测
|
||||
SourceIssue sourceIssues = SocketManager.getSourceList().get(0);
|
||||
xuMsg.setData(JSON.toJSONString(sourceIssues));
|
||||
xuMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + "&&" + sourceIssues.getType());
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, MsgUtil.toJsonWithNewLinePlain(xuMsg));
|
||||
xuMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + stepTag + sourceIssues.getType());
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(xuMsg));
|
||||
} else {
|
||||
//TODO 是否最终检测完成需要推送给用户
|
||||
CnSocketUtil.quitSend(param);
|
||||
@@ -918,8 +912,6 @@ public class SocketDevResponseService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 退出检测返回
|
||||
*/
|
||||
@@ -980,32 +972,11 @@ public class SocketDevResponseService {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出检测
|
||||
*/
|
||||
private void quitSend(PreDetectionParam param) {
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.QUIT_INIT_03.getValue());
|
||||
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerStr, JSON.toJSONString(socketMsg));
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭源连接
|
||||
*/
|
||||
private void quitSendSource(PreDetectionParam param) {
|
||||
SocketMsg socketMsg = new SocketMsg();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE_SOURCE.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.CLOSE_GATHER.getValue());
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(socketMsg));
|
||||
}
|
||||
|
||||
|
||||
private List<SourceCompareDev> devIsSource(DevData dev, SourceIssue issue) {
|
||||
|
||||
List<SourceCompareDev> info = new ArrayList<>();
|
||||
String[] split = dev.getId().split("_");
|
||||
String[] split = dev.getId().split(splitTag);
|
||||
String devName = null;
|
||||
if (devNameMapComm.containsKey(split[0])) {
|
||||
devName = devNameMapComm.get(split[0]);
|
||||
@@ -1096,23 +1067,20 @@ public class SocketDevResponseService {
|
||||
* 初始化集合
|
||||
*/
|
||||
public void initList(PreDetectionParam param) {
|
||||
this.monitorIdListComm = new ArrayList<>();
|
||||
this.successComm = new ArrayList<>();
|
||||
this.successXieyi = new ArrayList<>();
|
||||
this.successXieyi3 = new ArrayList<>();
|
||||
this.monitorIdListComm.clear();
|
||||
this.successComm.clear();
|
||||
this.successXieyi.clear();
|
||||
this.successXieyi3.clear();
|
||||
//初始化相序集合
|
||||
this.devInfo = new ArrayList<>();
|
||||
this.success = new ArrayList<>();
|
||||
this.devDataMap = new HashMap<>();
|
||||
this.devInfo.clear();
|
||||
this.success.clear();
|
||||
this.devDataMap.clear();
|
||||
|
||||
this.realDataXiList.clear();
|
||||
this.devList.clear();
|
||||
|
||||
FormalTestManager.devList.clear();
|
||||
List<PreDetection> pqDevList = iPqDevService.getDevInfo(param.getDevIds());
|
||||
this.devList = pqDevList;
|
||||
this.monitorIdListComm = pqDevList.stream().flatMap(x -> x.getMonitorList().stream())
|
||||
.map(PreDetection.MonitorListDTO::getLineId)
|
||||
.collect(Collectors.toList());
|
||||
FormalTestManager.devList = pqDevList;
|
||||
this.monitorIdListComm = pqDevList.stream().flatMap(x -> x.getMonitorList().stream()).map(PreDetection.MonitorListDTO::getLineId).collect(Collectors.toList());
|
||||
this.devNameMapComm = pqDevList.stream().collect(Collectors.toMap(PreDetection::getDevIP, PreDetection::getDevName));
|
||||
this.devIdMapComm = pqDevList.stream().collect(Collectors.toMap(PreDetection::getDevIP, PreDetection::getDevId));
|
||||
SocketManager.clockMap.clear();
|
||||
@@ -1120,10 +1088,10 @@ public class SocketDevResponseService {
|
||||
Map<String, SysRegResVO> sysRegResMap = iSysRegResService.listRegRes();
|
||||
|
||||
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||
if(ObjectUtil.isNotNull(oneConfig)){
|
||||
dataRule=DictDataEnum.getDictDataEnumByCode(oneConfig.getDataRule());
|
||||
}else{
|
||||
dataRule=DictDataEnum.AT_WILL_VALUE;
|
||||
if (ObjectUtil.isNotNull(oneConfig)) {
|
||||
dataRule = DictDataEnum.getDictDataEnumByCode(oneConfig.getDataRule());
|
||||
} else {
|
||||
dataRule = DictDataEnum.AT_WILL_VALUE;
|
||||
}
|
||||
//字典树
|
||||
SocketManager.valueTypeMap.clear();
|
||||
@@ -1134,9 +1102,8 @@ public class SocketDevResponseService {
|
||||
|
||||
//初始化
|
||||
private void initXiManager(PreDetectionParam param) {
|
||||
|
||||
Double v = devList.get(0).getDevVolt();
|
||||
Double i = devList.get(0).getDevCurr();
|
||||
Double v = FormalTestManager.devList.get(0).getDevVolt();
|
||||
Double i = FormalTestManager.devList.get(0).getDevCurr();
|
||||
CoefficientVO.DevParameter devParameterBig = new CoefficientVO.DevParameter();
|
||||
devParameterBig.setDevVolt(BigDecimal.valueOf(v * 1.2).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
devParameterBig.setDevCurr(BigDecimal.valueOf(i * 1.5).setScale(2, RoundingMode.HALF_UP).doubleValue());
|
||||
@@ -1176,7 +1143,6 @@ public class SocketDevResponseService {
|
||||
}
|
||||
}
|
||||
XiNumberManager.xiSourceIssueList = sourceIssues;
|
||||
|
||||
System.out.println(XiNumberManager.xiSourceIssueList);
|
||||
}
|
||||
|
||||
@@ -1188,116 +1154,116 @@ public class SocketDevResponseService {
|
||||
* @date 2024/12/29
|
||||
*/
|
||||
private void baseDataInsert(List<DevData> devDataList, SourceIssue sourceIssue, PreDetectionParam param, Map<String, String> checkDataMap) {
|
||||
// Runnable runnable = () -> {
|
||||
// Runnable runnable = () -> {
|
||||
|
||||
System.out.println("原始数据插入数据库开始执行=========================================");
|
||||
List<AdNonHarmonicResult> adNonHarmonicResultList = new ArrayList<>();
|
||||
List<AdHarmonicResult> adHarmonicResultList = new ArrayList<>();
|
||||
for (DevData data : devDataList) {
|
||||
LocalDateTime localDateTime = timeFormat(data.getTime(), formatter);
|
||||
if (Objects.nonNull(localDateTime)) {
|
||||
System.out.println("原始数据插入数据库开始执行=========================================");
|
||||
List<AdNonHarmonicResult> adNonHarmonicResultList = new ArrayList<>();
|
||||
List<AdHarmonicResult> adHarmonicResultList = new ArrayList<>();
|
||||
for (DevData data : devDataList) {
|
||||
LocalDateTime localDateTime = timeFormat(data.getTime(), formatter);
|
||||
if (Objects.nonNull(localDateTime)) {
|
||||
|
||||
String[] splitArr = data.getId().split("_");
|
||||
String temId = devIdMapComm.get(splitArr[0]) + "_" + splitArr[1];
|
||||
String[] splitArr = data.getId().split(splitTag);
|
||||
String temId = devIdMapComm.get(splitArr[0]) + splitTag + splitArr[1];
|
||||
|
||||
if (nonHarmonicList.contains(sourceIssue.getType())) {
|
||||
for (DevData.SqlDataDTO sqlDataDTO : data.getSqlData()) {
|
||||
DevData.SqlDataDTO.ListDTO listDTO = sqlDataDTO.getList();
|
||||
AdNonHarmonicResult adNonHarmonicResult = new AdNonHarmonicResult();
|
||||
adNonHarmonicResult.setTimeId(localDateTime);
|
||||
adNonHarmonicResult.setMonitorId(temId);
|
||||
adNonHarmonicResult.setScriptId(param.getScriptId());
|
||||
adNonHarmonicResult.setSort(sourceIssue.getIndex());
|
||||
adNonHarmonicResult.setAdType(checkDataMap.get(sqlDataDTO.getDesc()));
|
||||
adNonHarmonicResult.setDataType("avg");
|
||||
if (nonHarmonicList.contains(sourceIssue.getType())) {
|
||||
for (DevData.SqlDataDTO sqlDataDTO : data.getSqlData()) {
|
||||
DevData.SqlDataDTO.ListDTO listDTO = sqlDataDTO.getList();
|
||||
AdNonHarmonicResult adNonHarmonicResult = new AdNonHarmonicResult();
|
||||
adNonHarmonicResult.setTimeId(localDateTime);
|
||||
adNonHarmonicResult.setMonitorId(temId);
|
||||
adNonHarmonicResult.setScriptId(param.getScriptId());
|
||||
adNonHarmonicResult.setSort(sourceIssue.getIndex());
|
||||
adNonHarmonicResult.setAdType(checkDataMap.get(sqlDataDTO.getDesc()));
|
||||
adNonHarmonicResult.setDataType("avg");
|
||||
|
||||
Double a = listDTO.getA();
|
||||
Double b = listDTO.getB();
|
||||
Double c = listDTO.getC();
|
||||
Double d = listDTO.getT();
|
||||
if (Objects.nonNull(a)) {
|
||||
adNonHarmonicResult.setAValue(String.format("%.7f", a));
|
||||
}
|
||||
if (Objects.nonNull(b)) {
|
||||
adNonHarmonicResult.setBValue(String.format("%.7f", b));
|
||||
}
|
||||
if (Objects.nonNull(c)) {
|
||||
adNonHarmonicResult.setCValue(String.format("%.7f", c));
|
||||
}
|
||||
if (Objects.nonNull(d)) {
|
||||
adNonHarmonicResult.setTValue(String.format("%.7f", d));
|
||||
}
|
||||
adNonHarmonicResultList.add(adNonHarmonicResult);
|
||||
Double a = listDTO.getA();
|
||||
Double b = listDTO.getB();
|
||||
Double c = listDTO.getC();
|
||||
Double d = listDTO.getT();
|
||||
if (Objects.nonNull(a)) {
|
||||
adNonHarmonicResult.setAValue(String.format("%.7f", a));
|
||||
}
|
||||
} else {
|
||||
for (DevData.SqlDataHarmDTO sqlDataDTO : data.getSqlDataHarm()) {
|
||||
AdHarmonicResult adHarmonicResult = new AdHarmonicResult();
|
||||
adHarmonicResult.setTimeId(localDateTime);
|
||||
if (Objects.nonNull(b)) {
|
||||
adNonHarmonicResult.setBValue(String.format("%.7f", b));
|
||||
}
|
||||
if (Objects.nonNull(c)) {
|
||||
adNonHarmonicResult.setCValue(String.format("%.7f", c));
|
||||
}
|
||||
if (Objects.nonNull(d)) {
|
||||
adNonHarmonicResult.setTValue(String.format("%.7f", d));
|
||||
}
|
||||
adNonHarmonicResultList.add(adNonHarmonicResult);
|
||||
}
|
||||
} else {
|
||||
for (DevData.SqlDataHarmDTO sqlDataDTO : data.getSqlDataHarm()) {
|
||||
AdHarmonicResult adHarmonicResult = new AdHarmonicResult();
|
||||
adHarmonicResult.setTimeId(localDateTime);
|
||||
|
||||
adHarmonicResult.setMonitorId(temId);
|
||||
adHarmonicResult.setScriptId(param.getScriptId());
|
||||
adHarmonicResult.setSort(sourceIssue.getIndex());
|
||||
adHarmonicResult.setAdType(checkDataMap.get(sqlDataDTO.getDesc()));
|
||||
adHarmonicResult.setDataType("avg");
|
||||
adHarmonicResult.setMonitorId(temId);
|
||||
adHarmonicResult.setScriptId(param.getScriptId());
|
||||
adHarmonicResult.setSort(sourceIssue.getIndex());
|
||||
adHarmonicResult.setAdType(checkDataMap.get(sqlDataDTO.getDesc()));
|
||||
adHarmonicResult.setDataType("avg");
|
||||
|
||||
if (!DicDataEnum.HI.getCode().equals(sourceIssue.getType()) && !DicDataEnum.HSI.getCode().equals(sourceIssue.getType()) && !DicDataEnum.HP.getCode().equals(sourceIssue.getType())) {
|
||||
DevData.SqlDataDTO.ListDTO vvv = data.getSqlData().get(0).getList();
|
||||
Double aV = vvv.getA();
|
||||
Double bV = vvv.getB();
|
||||
Double cV = vvv.getC();
|
||||
if (Objects.nonNull(aV)) {
|
||||
adHarmonicResult.setAValue1(String.format("%.7f", aV));
|
||||
}
|
||||
if (Objects.nonNull(bV)) {
|
||||
adHarmonicResult.setBValue1(String.format("%.7f", bV));
|
||||
}
|
||||
if (Objects.nonNull(cV)) {
|
||||
adHarmonicResult.setCValue1(String.format("%.7f", cV));
|
||||
}
|
||||
if (!DicDataEnum.HI.getCode().equals(sourceIssue.getType()) && !DicDataEnum.HSI.getCode().equals(sourceIssue.getType()) && !DicDataEnum.HP.getCode().equals(sourceIssue.getType())) {
|
||||
DevData.SqlDataDTO.ListDTO vvv = data.getSqlData().get(0).getList();
|
||||
Double aV = vvv.getA();
|
||||
Double bV = vvv.getB();
|
||||
Double cV = vvv.getC();
|
||||
if (Objects.nonNull(aV)) {
|
||||
adHarmonicResult.setAValue1(String.format("%.7f", aV));
|
||||
}
|
||||
|
||||
DevData.SqlDataHarmDTO.ListDTO tem = sqlDataDTO.getList();
|
||||
List<String> a = tem.getA();
|
||||
List<String> b = tem.getB();
|
||||
List<String> c = tem.getC();
|
||||
|
||||
Class<AdHarmonicResult> example = (Class<AdHarmonicResult>) adHarmonicResult.getClass();
|
||||
for (int i = 2; i <= 50; i++) {
|
||||
// 通过反射设置name字段的值
|
||||
try {
|
||||
// 假设这些字段已经以正确的方式定义在AdHarmonicResult类中
|
||||
Field aField = example.getDeclaredField("aValue" + i);
|
||||
Field bField = example.getDeclaredField("bValue" + i);
|
||||
Field cField = example.getDeclaredField("cValue" + i);
|
||||
|
||||
aField.setAccessible(true);
|
||||
aField.set(adHarmonicResult, a.get(i - 2));
|
||||
bField.setAccessible(true);
|
||||
bField.set(adHarmonicResult, b.get(i - 2));
|
||||
cField.setAccessible(true);
|
||||
cField.set(adHarmonicResult, c.get(i - 2));
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (Objects.nonNull(bV)) {
|
||||
adHarmonicResult.setBValue1(String.format("%.7f", bV));
|
||||
}
|
||||
if (Objects.nonNull(cV)) {
|
||||
adHarmonicResult.setCValue1(String.format("%.7f", cV));
|
||||
}
|
||||
adHarmonicResultList.add(adHarmonicResult);
|
||||
}
|
||||
|
||||
DevData.SqlDataHarmDTO.ListDTO tem = sqlDataDTO.getList();
|
||||
List<String> a = tem.getA();
|
||||
List<String> b = tem.getB();
|
||||
List<String> c = tem.getC();
|
||||
|
||||
Class<AdHarmonicResult> example = (Class<AdHarmonicResult>) adHarmonicResult.getClass();
|
||||
for (int i = 2; i <= 50; i++) {
|
||||
// 通过反射设置name字段的值
|
||||
try {
|
||||
// 假设这些字段已经以正确的方式定义在AdHarmonicResult类中
|
||||
Field aField = example.getDeclaredField("aValue" + i);
|
||||
Field bField = example.getDeclaredField("bValue" + i);
|
||||
Field cField = example.getDeclaredField("cValue" + i);
|
||||
|
||||
aField.setAccessible(true);
|
||||
aField.set(adHarmonicResult, a.get(i - 2));
|
||||
bField.setAccessible(true);
|
||||
bField.set(adHarmonicResult, b.get(i - 2));
|
||||
cField.setAccessible(true);
|
||||
cField.set(adHarmonicResult, c.get(i - 2));
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
adHarmonicResultList.add(adHarmonicResult);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(adNonHarmonicResultList)) {
|
||||
detectionDataDealService.acceptAdNon(adNonHarmonicResultList, param.getCode());
|
||||
|
||||
}
|
||||
if (CollUtil.isNotEmpty(adHarmonicResultList)) {
|
||||
detectionDataDealService.acceptAd(adHarmonicResultList, param.getCode());
|
||||
}
|
||||
System.out.println("原始数据插入数据库执行成功=========================================");
|
||||
// };
|
||||
// executorPool.submit(runnable);
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(adNonHarmonicResultList)) {
|
||||
detectionDataDealService.acceptAdNon(adNonHarmonicResultList, param.getCode());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(adHarmonicResultList)) {
|
||||
detectionDataDealService.acceptAd(adHarmonicResultList, param.getCode());
|
||||
}
|
||||
System.out.println("原始数据插入数据库执行成功=========================================");
|
||||
// };
|
||||
// executorPool.submit(runnable);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -42,6 +42,10 @@ public class SocketSourceResponseService {
|
||||
private final String DEV = "_Dev";
|
||||
private final String source = "_Source";
|
||||
|
||||
private final String stepTag = "&&";
|
||||
private final String stepBegin = "_Start";
|
||||
private final String stepEnd = "_End";
|
||||
|
||||
|
||||
@Value("${socket.device.ip}")
|
||||
private String ip;
|
||||
@@ -56,7 +60,7 @@ public class SocketSourceResponseService {
|
||||
|
||||
public void deal(PreDetectionParam param, String msg) throws Exception {
|
||||
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
|
||||
String[] tem = socketDataMsg.getRequestId().split("&&");
|
||||
String[] tem = socketDataMsg.getRequestId().split(stepTag);
|
||||
SourceOperateCodeEnum enumByCode = SourceOperateCodeEnum.getDictDataEnumByCode(tem[0]);
|
||||
if (ObjectUtil.isNotNull(enumByCode)) {
|
||||
switch (enumByCode) {
|
||||
@@ -82,7 +86,7 @@ public class SocketSourceResponseService {
|
||||
|
||||
}
|
||||
} else {
|
||||
System.out.println("1");
|
||||
System.out.println("fggggggggggggggggggggg"+enumByCode);
|
||||
}
|
||||
|
||||
|
||||
@@ -243,7 +247,7 @@ public class SocketSourceResponseService {
|
||||
SourceIssue sourceIssue = SocketManager.getSourceList().get(0);
|
||||
List<String> comm = sourceIssue.getDevValueTypeList();
|
||||
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue()+"&&"+sourceIssue.getType());
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue()+stepTag+sourceIssue.getType());
|
||||
|
||||
int ignoreCount;
|
||||
int readData;
|
||||
@@ -281,7 +285,7 @@ public class SocketSourceResponseService {
|
||||
|
||||
//告诉前端当前项开始了
|
||||
WebSocketVO<List<DevLineTestResult>> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(socketDataMsg.getRequestId().split("&&")[1]+"_Start");
|
||||
webSocketVO.setRequestId(socketDataMsg.getRequestId().split(stepTag)[1]+stepBegin);
|
||||
List<DevLineTestResult> devListRes = new ArrayList<>();
|
||||
devList.forEach(item->{
|
||||
DevLineTestResult devLineTestResult = new DevLineTestResult();
|
||||
|
||||
@@ -67,6 +67,9 @@ public enum SourceOperateCodeEnum {
|
||||
FORMAL_TEST("2","正式检测"),
|
||||
TIME_TEST("3","守时检测"),
|
||||
PHASE_TEST("4","相序检测"),
|
||||
TEST_TEM_STOP("5","临时停止"),
|
||||
TEST_TEM_START("6","继续检测"),
|
||||
TEST_STOP("7","停止检测"),
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,9 +26,11 @@ public interface PreDetectionService {
|
||||
boolean startTest(PreDetectionParam param);
|
||||
|
||||
|
||||
boolean closePreTest(PreDetectionParam param);
|
||||
boolean temStopTest();
|
||||
|
||||
|
||||
boolean restartTemTest(PreDetectionParam param);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||
import com.njcn.gather.detection.service.PreDetectionService;
|
||||
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.FormalTestManager;
|
||||
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
|
||||
@@ -68,34 +69,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
@Override
|
||||
public void sourceCommunicationCheck(PreDetectionParam param) {
|
||||
|
||||
|
||||
System.out.println("进来了啊啊啊啊啊啊啊啊啊啊啊啊啊----------------------------------------------------------------");
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
|
||||
System.out.println("存活的源=========================="+channel);
|
||||
|
||||
if (Objects.nonNull(channel) && channel.isActive()) {
|
||||
System.out.println("进入关闭源。。//////");
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
SocketManager.removeUser(param.getUserPageId() + source);
|
||||
SocketManager.removeUser(param.getUserPageId() + dev);
|
||||
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
specialDeal(param);
|
||||
|
||||
/*
|
||||
先组装源通讯协议
|
||||
@@ -125,58 +99,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
@Override
|
||||
public void coefficientCheck(PreDetectionParam param) {
|
||||
System.out.println("进来了啊啊啊啊啊啊啊啊啊啊啊啊啊----------------------------------------------------------------");
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
|
||||
System.out.println("存活的源=========================="+channel);
|
||||
|
||||
if (Objects.nonNull(channel) && channel.isActive()) {
|
||||
System.out.println("进入关闭源。。//////");
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
SocketManager.removeUser(param.getUserPageId() + source);
|
||||
SocketManager.removeUser(param.getUserPageId() + dev);
|
||||
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>()
|
||||
.eq(AdPlanSource::getPlanId, param.getPlanId())
|
||||
);
|
||||
if (ObjectUtil.isNotNull(planSource)) {
|
||||
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId());
|
||||
if (ObjectUtil.isNotNull(sourceParam)) {
|
||||
//开始组装socket报文请求头
|
||||
socketDevResponseService.initList(param);
|
||||
socketSourceResponseService.initList(param);
|
||||
SocketMsg<String> msg = new SocketMsg<>();
|
||||
msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
||||
msg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
|
||||
msg.setData(JSON.toJSONString(sourceParam));
|
||||
param.setSourceId(sourceParam.getSourceId());
|
||||
NettyClient.socketClient(ip, port, param.getUserPageId(), MsgUtil.toJsonWithNewLinePlain(msg), new NettySourceClientHandler(param, sourceResponseService));
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
|
||||
}
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.PLAN_AND_SOURCE_NOT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void sendYtxSocket(PreDetectionParam param) {
|
||||
specialDeal(param);
|
||||
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>()
|
||||
.eq(AdPlanSource::getPlanId, param.getPlanId())
|
||||
);
|
||||
@@ -191,7 +114,30 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
msg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
|
||||
msg.setData(JSON.toJSONString(sourceParam));
|
||||
param.setSourceId(sourceParam.getSourceId());
|
||||
NettyClient.socketClient(ip, port, param.getUserPageId(), MsgUtil.toJsonWithNewLinePlain(msg), new NettySourceClientHandler(param, sourceResponseService));
|
||||
NettyClient.socketClient(ip, port, param.getUserPageId(), JSON.toJSONString(msg), new NettySourceClientHandler(param, sourceResponseService));
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
|
||||
}
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.PLAN_AND_SOURCE_NOT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void sendYtxSocket(PreDetectionParam param) {
|
||||
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>().eq(AdPlanSource::getPlanId, param.getPlanId()));
|
||||
if (ObjectUtil.isNotNull(planSource)) {
|
||||
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId());
|
||||
if (ObjectUtil.isNotNull(sourceParam)) {
|
||||
//开始组装socket报文请求头
|
||||
socketDevResponseService.initList(param);
|
||||
socketSourceResponseService.initList(param);
|
||||
SocketMsg<String> msg = new SocketMsg<>();
|
||||
msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
||||
msg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
|
||||
msg.setData(JSON.toJSONString(sourceParam));
|
||||
param.setSourceId(sourceParam.getSourceId());
|
||||
NettyClient.socketClient(ip, port, param.getUserPageId(), JSON.toJSONString(msg), new NettySourceClientHandler(param, sourceResponseService));
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
|
||||
}
|
||||
@@ -211,10 +157,58 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean closePreTest(PreDetectionParam param) {
|
||||
|
||||
|
||||
|
||||
public boolean temStopTest() {
|
||||
FormalTestManager.stopFlag = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean restartTemTest(PreDetectionParam param) {
|
||||
FormalTestManager.stopFlag = false;
|
||||
specialDeal(param);
|
||||
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>().eq(AdPlanSource::getPlanId, param.getPlanId()));
|
||||
if (ObjectUtil.isNotNull(planSource)) {
|
||||
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId());
|
||||
if (ObjectUtil.isNotNull(sourceParam)) {
|
||||
//开始组装socket报文请求头
|
||||
socketDevResponseService.initList(param);
|
||||
socketSourceResponseService.initList(param);
|
||||
SocketMsg<String> msg = new SocketMsg<>();
|
||||
msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
||||
msg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
|
||||
msg.setData(JSON.toJSONString(sourceParam));
|
||||
param.setSourceId(sourceParam.getSourceId());
|
||||
param.setOperateType(SourceOperateCodeEnum.TEST_TEM_START.getValue());
|
||||
NettyClient.socketClient(ip, port, param.getUserPageId(), JSON.toJSONString(msg), new NettySourceClientHandler(param, sourceResponseService));
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
|
||||
}
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.PLAN_AND_SOURCE_NOT);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void specialDeal(PreDetectionParam param) {
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
|
||||
if (Objects.nonNull(channel) && channel.isActive()) {
|
||||
System.out.println("进入关闭源。。//////");
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
SocketManager.removeUser(param.getUserPageId() + source);
|
||||
SocketManager.removeUser(param.getUserPageId() + dev);
|
||||
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,8 +13,8 @@ import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||
*/
|
||||
public class CnSocketUtil {
|
||||
|
||||
private final static String handlerStr = "_Dev";
|
||||
private final static String handlerSourceStr = "_Source";
|
||||
private final static String devTag = "_Dev";
|
||||
private final static String sourceTag = "_Source";
|
||||
|
||||
/**
|
||||
* 退出检测
|
||||
@@ -23,7 +23,7 @@ public class CnSocketUtil {
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.QUIT_INIT_03.getValue());
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerStr, JSON.toJSONString(socketMsg));
|
||||
SocketManager.sendMsg(param.getUserPageId() + devTag, JSON.toJSONString(socketMsg));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ public class CnSocketUtil {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("sourceId",param.getSourceId());
|
||||
socketMsg.setData(jsonObject.toJSONString());
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(socketMsg));
|
||||
SocketManager.sendMsg(param.getUserPageId() + sourceTag, JSON.toJSONString(socketMsg));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.njcn.gather.detection.util.socket;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-01-08
|
||||
* @Description: 正式检测对象管理
|
||||
*/
|
||||
public class FormTestManager {
|
||||
|
||||
public static Map<String, String> devXiNumDataMap = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.njcn.gather.detection.util.socket;
|
||||
|
||||
import com.njcn.gather.device.device.pojo.vo.PreDetection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-01-08
|
||||
* @Description: 正式检测对象管理
|
||||
*/
|
||||
public class FormalTestManager {
|
||||
|
||||
public static Map<String, String> devXiNumDataMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 存储所有准备测试的检测点通道
|
||||
*/
|
||||
public static List<String> allMonitorList = new ArrayList<>();
|
||||
|
||||
|
||||
/**
|
||||
* 存储每个测试项正常结束的监测点通道
|
||||
*/
|
||||
public static List<String> monitorSuccessList = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
public static List<PreDetection> devList = new ArrayList<>();
|
||||
|
||||
|
||||
public static Boolean stopFlag = false;
|
||||
|
||||
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public class SocketManager {
|
||||
|
||||
|
||||
/**
|
||||
* 用于存储
|
||||
* 用于存储每个测试小项超时时长key key:检测项 value:时间秒
|
||||
*/
|
||||
public static volatile Map<Integer,Long> clockMap = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -95,7 +95,6 @@ public class SocketManager {
|
||||
|
||||
public static void addSourceList(List<SourceIssue> sList) {
|
||||
sourceIssueList = sList;
|
||||
// System.out.println(sList);
|
||||
}
|
||||
|
||||
public static List<SourceIssue> getSourceList() {
|
||||
|
||||
@@ -69,7 +69,7 @@ public class NettyClient {
|
||||
} else {
|
||||
System.out.println("链接服务端成功...");
|
||||
System.out.println("客户端向服务端发送消息:"+msg);
|
||||
channelFuture.channel().writeAndFlush(msg);
|
||||
channelFuture.channel().writeAndFlush(msg+"\n");
|
||||
}
|
||||
});
|
||||
NioEventLoopGroup groupByUserId = SocketManager.getGroupByUserId(userPageId + "_Dev");
|
||||
|
||||
@@ -5,12 +5,11 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.njcn.gather.detection.handler.SocketDevResponseService;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.vo.DevLineTestResult;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||
import com.njcn.gather.detection.pojo.vo.WebSocketVO;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import com.njcn.gather.detection.util.socket.WebServiceManager;
|
||||
import com.njcn.gather.detection.util.socket.*;
|
||||
import com.njcn.gather.device.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.system.pojo.enums.DicDataEnum;
|
||||
import io.netty.channel.Channel;
|
||||
@@ -24,6 +23,8 @@ import lombok.RequiredArgsConstructor;
|
||||
import java.io.IOException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.ProtocolException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@@ -45,20 +46,21 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
|
||||
/**
|
||||
* 当通道进行连接时推送消息
|
||||
*
|
||||
* @param ctx
|
||||
*/
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx)throws Exception {
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
System.out.println("客户端通道已建立" + ctx.channel().id());
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId()+dev);
|
||||
if(Objects.nonNull(channel)){
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + dev);
|
||||
if (Objects.nonNull(channel)) {
|
||||
try {
|
||||
channel.close().sync();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
SocketManager.addUser(param.getUserPageId()+dev,ctx.channel());
|
||||
SocketManager.addUser(param.getUserPageId() + dev, ctx.channel());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,9 +68,9 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
*/
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws InterruptedException {
|
||||
System.out.println("devhandler接收server端数据>>>>>>"+msg);
|
||||
System.out.println("devhandler接收server端数据>>>>>>" + msg);
|
||||
try {
|
||||
socketResponseService.deal(param,msg);
|
||||
socketResponseService.deal(param, msg);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
CnSocketUtil.quitSend(param);
|
||||
@@ -79,20 +81,21 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
|
||||
/**
|
||||
* 当通道断线时,支持重连
|
||||
*
|
||||
* @param ctx
|
||||
*/
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) {
|
||||
System.out.println("设备通讯客户端断线");
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId()+dev);
|
||||
if(Objects.nonNull(channel)){
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + dev);
|
||||
if (Objects.nonNull(channel)) {
|
||||
try {
|
||||
channel.close().sync();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
SocketManager.removeUser(param.getUserPageId()+dev);
|
||||
SocketManager.removeUser(param.getUserPageId() + dev);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,58 +108,40 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
|
||||
if (evt instanceof IdleStateEvent) {
|
||||
if (((IdleStateEvent) evt).state() == IdleState.READER_IDLE) {
|
||||
if(CollUtil.isNotEmpty(SocketManager.getSourceList())) {
|
||||
if (CollUtil.isNotEmpty(SocketManager.getSourceList())) {
|
||||
SourceIssue sourceIssue = SocketManager.getSourceList().get(0);
|
||||
if(SocketManager.clockMap.containsKey(sourceIssue.getIndex())){
|
||||
SocketManager.clockMap.put(sourceIssue.getIndex(),SocketManager.clockMap.get(sourceIssue.getIndex())+60L);
|
||||
}else {
|
||||
SocketManager.clockMap.put(sourceIssue.getIndex(),60L);
|
||||
if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) {
|
||||
SocketManager.clockMap.put(sourceIssue.getIndex(), SocketManager.clockMap.get(sourceIssue.getIndex()) + 60L);
|
||||
} else {
|
||||
SocketManager.clockMap.put(sourceIssue.getIndex(), 60L);
|
||||
}
|
||||
|
||||
System.out.println("超时函数进入-----》"+sourceIssue.getType()+"----:"+SocketManager.clockMap.get(sourceIssue.getIndex())+"S");
|
||||
System.out.println("超时函数进入-----》" + sourceIssue.getType() + "----:" + SocketManager.clockMap.get(sourceIssue.getIndex()) + "S");
|
||||
|
||||
if (sourceIssue.getType().equals(DicDataEnum.F.getCode())) {
|
||||
//闪变
|
||||
if(SocketManager.clockMap.get(sourceIssue.getIndex()) > 1800){
|
||||
System.out.println("超时处理-----》"+sourceIssue.getType()+"已超时----------------关闭");
|
||||
if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 1800) {
|
||||
System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
|
||||
CnSocketUtil.quitSend(param);
|
||||
|
||||
WebSocketVO<String> socketVO = new WebSocketVO<>();
|
||||
socketVO.setRequestId(SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue());
|
||||
socketVO.setOperateCode(sourceIssue.getType());
|
||||
socketVO.setData(SourceOperateCodeEnum.SOCKET_TIMEOUT.getMsg());
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketVO));
|
||||
|
||||
timeoutSend(sourceIssue);
|
||||
}
|
||||
} else if (sourceIssue.getType().equals(DicDataEnum.VOLTAGE.getCode()) || sourceIssue.getType().equals(DicDataEnum.HP.getCode())) {
|
||||
//统计数据项
|
||||
if(SocketManager.clockMap.get(sourceIssue.getIndex()) > 180){
|
||||
if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 180) {
|
||||
CnSocketUtil.quitSend(param);
|
||||
System.out.println("超时处理-----》"+sourceIssue.getType()+"已超时----------------关闭");
|
||||
|
||||
|
||||
WebSocketVO<String> socketVO = new WebSocketVO<>();
|
||||
socketVO.setRequestId(SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue());
|
||||
socketVO.setOperateCode(sourceIssue.getType());
|
||||
socketVO.setData(SourceOperateCodeEnum.SOCKET_TIMEOUT.getMsg());
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketVO));
|
||||
System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
|
||||
timeoutSend(sourceIssue);
|
||||
}
|
||||
|
||||
}else {
|
||||
} else {
|
||||
//实时数据
|
||||
if(SocketManager.clockMap.get(sourceIssue.getIndex()) > 60){
|
||||
if (SocketManager.clockMap.get(sourceIssue.getIndex()) > 60) {
|
||||
CnSocketUtil.quitSend(param);
|
||||
System.out.println("超时处理-----》"+sourceIssue.getType()+"已超时----------------关闭");
|
||||
|
||||
|
||||
WebSocketVO<String> socketVO = new WebSocketVO<>();
|
||||
socketVO.setRequestId(SourceOperateCodeEnum.SOCKET_TIMEOUT.getValue());
|
||||
socketVO.setOperateCode(sourceIssue.getType());
|
||||
socketVO.setData(SourceOperateCodeEnum.SOCKET_TIMEOUT.getMsg());
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketVO));
|
||||
System.out.println("超时处理-----》" + sourceIssue.getType() + "已超时----------------关闭");
|
||||
timeoutSend(sourceIssue);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
//为空则认为是常规步骤,设定一分钟超时
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
@@ -165,9 +150,11 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void handlerAdded(ChannelHandlerContext ctx) {
|
||||
System.out.println("有通道准备接入" + ctx.channel());
|
||||
@@ -203,4 +190,24 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
|
||||
private void timeoutSend(SourceIssue sourceIssue){
|
||||
List<DevLineTestResult> devListRes = new ArrayList<>();
|
||||
FormalTestManager.devList.forEach(dev -> {
|
||||
DevLineTestResult devLineTestResult = new DevLineTestResult();
|
||||
devLineTestResult.setDeviceId(dev.getDevId());
|
||||
devLineTestResult.setDeviceName(dev.getDevName());
|
||||
List<Integer> resultFlagList = new ArrayList<>();
|
||||
List<PreDetection.MonitorListDTO> monitorListDTOList = dev.getMonitorList();
|
||||
monitorListDTOList.forEach(i -> resultFlagList.add(3));
|
||||
devLineTestResult.setChnResult(resultFlagList.toArray(new Integer[monitorListDTOList.size()]));
|
||||
devListRes.add(devLineTestResult);
|
||||
});
|
||||
WebSocketVO<List<DevLineTestResult>> socketVO = new WebSocketVO<>();
|
||||
socketVO.setRequestId(sourceIssue.getType()+"_End");
|
||||
socketVO.setOperateCode(sourceIssue.getType());
|
||||
socketVO.setData(devListRes);
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketVO));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.detection.util.socket.cilent;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.njcn.gather.detection.handler.SocketSourceResponseService;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
@@ -105,7 +106,7 @@ public class NettySourceClientHandler extends SimpleChannelInboundHandler<String
|
||||
msg.setRequestId("yxt");
|
||||
msg.setOperateCode(SourceOperateCodeEnum.HEARTBEAT.getValue());
|
||||
msg.setData("");
|
||||
ctx.writeAndFlush(MsgUtil.toJsonWithNewLinePlain(msg));
|
||||
ctx.writeAndFlush(JSON.toJSONString(msg));
|
||||
}
|
||||
} else {
|
||||
//防止堆栈溢出
|
||||
|
||||
Reference in New Issue
Block a user