1.微调实体信息
This commit is contained in:
@@ -41,10 +41,6 @@ public class SocketDevResponseService {
|
||||
private final IPqScriptDtlsService scriptDtlsService;
|
||||
private final IPqScriptDtlsService pqScriptDtlsService;
|
||||
|
||||
/**
|
||||
* 所有装置通道信息
|
||||
*/
|
||||
List<String> moniterIdList = new ArrayList<>();
|
||||
/**
|
||||
* 存储的装置相序数据
|
||||
*/
|
||||
@@ -53,24 +49,20 @@ public class SocketDevResponseService {
|
||||
* 成功结束的装置
|
||||
*/
|
||||
List<String> success = new ArrayList<>();
|
||||
/**
|
||||
* 装置名称
|
||||
*/
|
||||
Map<String, String> devNameMap = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
* 所有装置通道信息
|
||||
*/
|
||||
List<String> moniterIdListComm = new ArrayList<>();
|
||||
/**
|
||||
* 成功结束的装置
|
||||
*/
|
||||
List<String> successComm = new ArrayList<>();
|
||||
List<String> monitorIdListComm = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 装置名称
|
||||
*/
|
||||
Map<String, String> devNameMapComm = new HashMap<>();
|
||||
/**
|
||||
* 成功结束的装置
|
||||
*/
|
||||
List<String> successComm = new ArrayList<>();
|
||||
|
||||
|
||||
/**
|
||||
@@ -78,10 +70,7 @@ public class SocketDevResponseService {
|
||||
*/
|
||||
List<String> successXieyi = new ArrayList<>();
|
||||
List<String> successXieyi3 = new ArrayList<>();
|
||||
/**
|
||||
* 装置名称
|
||||
*/
|
||||
Map<String, String> devNameMapXieyi = new HashMap<>();
|
||||
|
||||
|
||||
public void deal(PreDetectionParam param, String msg) {
|
||||
SocketDataMsg socketDataMsg = MsgUtil.socketDataMsg(msg);
|
||||
@@ -100,7 +89,7 @@ public class SocketDevResponseService {
|
||||
switch (dictDataEnumByCode) {
|
||||
case SUCCESS:
|
||||
//通讯校验成功
|
||||
switch (operateCodeEnum){
|
||||
switch (operateCodeEnum) {
|
||||
case QUIT_INIT_01:
|
||||
break;
|
||||
case QUIT_INIT_02:
|
||||
@@ -153,8 +142,8 @@ public class SocketDevResponseService {
|
||||
String mId = JSON.parseObject(msg).get("data").toString();
|
||||
successComm.add(mId);
|
||||
|
||||
System.out.println(successComm.size() + "=====" + moniterIdListComm.size());
|
||||
if (successComm.size() == moniterIdListComm.size()) {
|
||||
System.out.println(successComm.size() + "=====" + monitorIdListComm.size());
|
||||
if (successComm.size() == monitorIdListComm.size()) {
|
||||
//开始进行协议校验
|
||||
List<PreDetection> devList = iPqDevService.getDevInfo(param.getDevIds());
|
||||
Map<String, List<PreDetection>> map = new HashMap(1);
|
||||
@@ -184,7 +173,7 @@ public class SocketDevResponseService {
|
||||
break;
|
||||
case RE_OPERATE:
|
||||
//发起关闭操作
|
||||
quitSend(param,socketMsg);
|
||||
quitSend(param, socketMsg);
|
||||
break;
|
||||
default:
|
||||
WebSocketVO webSocketVO = new WebSocketVO();
|
||||
@@ -211,7 +200,7 @@ public class SocketDevResponseService {
|
||||
String type = jsonObject.get("operateCode").toString();
|
||||
if (type.equals(SourceOperateCodeEnum.DEV_INIT_GATHER_02.getValue())) {
|
||||
successXieyi.add(mId);
|
||||
if (successXieyi.size() == moniterIdListComm.size()) {
|
||||
if (successXieyi.size() == monitorIdListComm.size()) {
|
||||
//协议3校验
|
||||
successXieyi = new ArrayList<>();
|
||||
|
||||
@@ -230,21 +219,21 @@ public class SocketDevResponseService {
|
||||
}
|
||||
} else if (type.equals(SourceOperateCodeEnum.DEV_INIT_GATHER_03.getValue())) {
|
||||
successXieyi3.add(mId);
|
||||
System.out.println(successXieyi3.size() + "=====" + moniterIdListComm.size());
|
||||
if (successXieyi3.size() == moniterIdListComm.size()) {
|
||||
System.out.println(successXieyi3.size() + "=====" + monitorIdListComm.size());
|
||||
if (successXieyi3.size() == monitorIdListComm.size()) {
|
||||
System.out.println("开始相序校验++++++++++");
|
||||
PqScriptIssueParam issueParam=new PqScriptIssueParam();
|
||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||
issueParam.setPlanId(param.getPlanId());
|
||||
issueParam.setSourceId(param.getSourceId());
|
||||
issueParam.setIsPhaseSequence(true);
|
||||
issueParam.setDevIds(param.getDevIds());
|
||||
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||
if(CollUtil.isNotEmpty(sourceIssues)){
|
||||
SocketMsg xuMsg=new SocketMsg();
|
||||
if (CollUtil.isNotEmpty(sourceIssues)) {
|
||||
SocketMsg xuMsg = new SocketMsg();
|
||||
xuMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||
xuMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
xuMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||
SocketManager.sendMsg(param.getUserPageId()+"_Source",JSON.toJSONString(xuMsg));
|
||||
SocketManager.sendMsg(param.getUserPageId() + "_Source", JSON.toJSONString(xuMsg));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -255,7 +244,7 @@ public class SocketDevResponseService {
|
||||
break;
|
||||
case RE_OPERATE:
|
||||
//发起关闭操作
|
||||
quitSend(param,socketMsg);
|
||||
quitSend(param, socketMsg);
|
||||
break;
|
||||
default:
|
||||
WebSocketVO webSocketVO = new WebSocketVO();
|
||||
@@ -268,24 +257,15 @@ public class SocketDevResponseService {
|
||||
/**
|
||||
* 退出检测
|
||||
*/
|
||||
private void quitSend(PreDetectionParam param,SocketMsg socketMsg){
|
||||
private void quitSend(PreDetectionParam param, SocketMsg 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() + handlerStr, JSON.toJSONString(socketMsg));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void devXu(PreDetectionParam param, SocketDataMsg socketDataMsg) {
|
||||
if (CollUtil.isEmpty(moniterIdList)) {
|
||||
List<PreDetection> pqDevList = iPqDevService.getDevInfo(param.getDevIds());
|
||||
moniterIdList = pqDevList.stream().flatMap(x -> x.getMonitorList().stream())
|
||||
.map(PreDetection.MonitorListDTO::getLineId)
|
||||
.collect(Collectors.toList());
|
||||
devNameMap = pqDevList.stream().collect(Collectors.toMap(PreDetection::getDevIP, PreDetection::getDevName));
|
||||
// moniterIdList.add("192.168.1.186_1");
|
||||
|
||||
}
|
||||
String data = socketDataMsg.getData();
|
||||
DevData devData = JSON.parseObject(data, DevData.class);
|
||||
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||
@@ -295,7 +275,7 @@ public class SocketDevResponseService {
|
||||
case SUCCESS:
|
||||
devInfo.add(devData);
|
||||
success.add(devData.getId());
|
||||
if (success.size() == moniterIdList.size()) {
|
||||
if (success.size() == monitorIdListComm.size()) {
|
||||
PqScriptIssueParam sourceParam = new PqScriptIssueParam();
|
||||
sourceParam.setPlanId(param.getPlanId());
|
||||
sourceParam.setDevIds(param.getDevIds());
|
||||
@@ -308,16 +288,15 @@ public class SocketDevResponseService {
|
||||
info.addAll(devIsSource(dev, sourceIssues.get(0)));
|
||||
}
|
||||
}
|
||||
xuClear();
|
||||
String s = param.getUserPageId() + "_Source";
|
||||
SocketMsg msg= new SocketMsg();
|
||||
SocketMsg msg = new SocketMsg();
|
||||
msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
||||
msg.setOperateCode(SourceOperateCodeEnum.CLOSE_GATHER.getValue());
|
||||
Map<String,String> map=new HashMap<>(1);
|
||||
map.put("sourceId",sourceIssues.get(0).getSourceId());
|
||||
Map<String, String> map = new HashMap<>(1);
|
||||
map.put("sourceId", sourceIssues.get(0).getSourceId());
|
||||
msg.setData(JSON.toJSONString(map));
|
||||
SocketManager.sendMsg(s, JSON.toJSONString(msg));
|
||||
|
||||
//向前端推送消息
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_XUJY.getValue());
|
||||
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
|
||||
socketMsg.setData(JSON.toJSONString(info));
|
||||
@@ -425,28 +404,24 @@ public class SocketDevResponseService {
|
||||
return compareDev;
|
||||
}
|
||||
|
||||
public void xuClear() {
|
||||
this.moniterIdList.clear();
|
||||
this.devInfo.clear();
|
||||
this.success.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化集合
|
||||
*/
|
||||
public void initList(PreDetectionParam param) {
|
||||
this.moniterIdListComm = new ArrayList<>();
|
||||
this.monitorIdListComm = new ArrayList<>();
|
||||
this.successComm = new ArrayList<>();
|
||||
this.devNameMapComm = new HashMap<>();
|
||||
|
||||
this.successXieyi = new ArrayList<>();
|
||||
this.successXieyi3 = new ArrayList<>();
|
||||
this.devNameMapXieyi = new HashMap<>();
|
||||
this.devInfo = new ArrayList<>();
|
||||
this.success = new ArrayList<>();
|
||||
|
||||
|
||||
List<PreDetection> pqDevList = iPqDevService.getDevInfo(param.getDevIds());
|
||||
this.moniterIdListComm = pqDevList.stream().flatMap(x -> x.getMonitorList().stream())
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public class PreDetectionParam {
|
||||
private String scriptId;
|
||||
|
||||
/**
|
||||
* 检测脚本Id
|
||||
* 源id
|
||||
*/
|
||||
private String sourceId;
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void sendYtxSocket(PreDetectionParam param) {
|
||||
AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>()
|
||||
.eq(AdPlanSource::getPlanId, param.getPlanId())
|
||||
@@ -95,20 +96,13 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId());
|
||||
if (ObjectUtil.isNotNull(sourceParam)) {
|
||||
//开始组装socket报文请求头
|
||||
SocketMsg msg ;
|
||||
String s = param.getUserPageId() + "_Source";
|
||||
//PQC600A_192.168.1.133_6806
|
||||
Channel channel = SocketManager.getChannelByUserId(s);
|
||||
socketDevResponseService.xuClear();
|
||||
socketDevResponseService.initList(param);
|
||||
|
||||
msg= new SocketMsg();
|
||||
SocketMsg msg = new SocketMsg();
|
||||
msg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
||||
msg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
|
||||
msg.setData(JSON.toJSONString(sourceParam));
|
||||
NettyClient.socketClient(ip, port, param.getUserPageId(), JSON.toJSONString(msg),new NettySourceClientHandler(param, sourceResponseService));
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -129,7 +123,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
String ddId = param.getUserPageId() + "_Source";
|
||||
Channel channel = SocketManager.getChannelByUserId(ddId);
|
||||
if (channel == null || !channel.isActive()) {
|
||||
NettyClient.socketClient(ip, port, param.getUserPageId(),"start\n", new NettySourceClientHandler(param, sourceResponseService));
|
||||
NettyClient.socketClient(ip, port, param.getUserPageId(), "start\n", new NettySourceClientHandler(param, sourceResponseService));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -92,7 +92,6 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||
socketResponseService.xuClear();
|
||||
// 处理异常,例如记录日志、关闭连接等
|
||||
cause.printStackTrace();
|
||||
// 根据异常类型进行不同的处理
|
||||
|
||||
Reference in New Issue
Block a user