代码调整
This commit is contained in:
@@ -52,7 +52,7 @@ public class PreDetectionController extends BaseController {
|
||||
*/
|
||||
@PostMapping("/closePreTest")
|
||||
@OperateInfo
|
||||
@ApiOperation("终止预检测")
|
||||
@ApiOperation("终止检测")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<String> closePreTest(@RequestBody PreDetectionParam param){
|
||||
String methodDescribe = getMethodDescribe("closePreTest");
|
||||
|
||||
@@ -15,6 +15,7 @@ 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.web.WebSocketHandler;
|
||||
import com.njcn.gather.device.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.device.service.IPqDevService;
|
||||
@@ -1108,7 +1109,7 @@ public class SocketDevResponseService {
|
||||
.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();
|
||||
//初始化有效数据数
|
||||
Map<String, SysRegResVO> sysRegResMap = iSysRegResService.listRegRes();
|
||||
|
||||
@@ -1141,7 +1142,7 @@ public class SocketDevResponseService {
|
||||
issueParam.setPlanId(param.getPlanId());
|
||||
issueParam.setSourceId(param.getSourceId());
|
||||
issueParam.setDevIds(param.getDevIds());
|
||||
issueParam.setScriptId("a303b2224845fcc6f60198b8ca23dca9");
|
||||
issueParam.setScriptId(param.getScriptId());
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.COEFFICIENT_TEST.getValue());
|
||||
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||
for (int j = 0; j < sourceIssues.size(); j++) {
|
||||
@@ -1178,8 +1179,6 @@ public class SocketDevResponseService {
|
||||
private void baseDataInsert(List<DevData> devDataList, SourceIssue sourceIssue, PreDetectionParam param, Map<String, String> checkDataMap) {
|
||||
// Runnable runnable = () -> {
|
||||
|
||||
|
||||
|
||||
System.out.println("原始数据插入数据库开始执行=========================================");
|
||||
List<AdNonHarmonicResult> adNonHarmonicResultList = new ArrayList<>();
|
||||
List<AdHarmonicResult> adHarmonicResultList = new ArrayList<>();
|
||||
|
||||
@@ -213,16 +213,8 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
@Override
|
||||
public boolean closePreTest(PreDetectionParam param) {
|
||||
|
||||
SocketMsg socketMsg = new SocketMsg();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.QUIT_INIT_03.getValue());
|
||||
SocketManager.sendMsg(param.getUserPageId() + dev, JSON.toJSONString(socketMsg));
|
||||
|
||||
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.QUITE_SOURCE.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.CLOSE_GATHER.getValue());
|
||||
SocketManager.sendMsg(param.getUserPageId() + source, JSON.toJSONString(socketMsg));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
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<>();
|
||||
|
||||
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.njcn.gather.detection.handler;
|
||||
package com.njcn.gather.detection.util.socket;
|
||||
|
||||
import com.njcn.gather.detection.pojo.dto.DevXiNumData;
|
||||
import com.njcn.gather.detection.pojo.vo.CoefficientVO;
|
||||
import com.njcn.gather.device.script.pojo.po.SourceIssue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -13,7 +12,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-01-05
|
||||
* @Description: 系数管理器
|
||||
* @Description: 系数校验管理器
|
||||
*/
|
||||
public class XiNumberManager {
|
||||
|
||||
@@ -54,7 +54,7 @@ public class NettyClient {
|
||||
//空闲状态的handler
|
||||
// 添加LineBasedFrameDecoder来按行分割数据
|
||||
.addLast(new LineBasedFrameDecoder(10240))
|
||||
.addLast(new IdleStateHandler(180, 0, 0, TimeUnit.SECONDS))
|
||||
.addLast(new IdleStateHandler(60, 0, 0, TimeUnit.SECONDS))
|
||||
.addLast(new StringDecoder(CharsetUtil.UTF_8))
|
||||
.addLast(new StringEncoder(CharsetUtil.UTF_8))
|
||||
.addLast(handler);
|
||||
|
||||
@@ -94,14 +94,22 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
if (evt instanceof IdleStateEvent) {
|
||||
if (((IdleStateEvent) evt).state() == IdleState.READER_IDLE) {
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
System.out.println("超时函数进入-----》"+sourceIssue.getType()+"----:"+SocketManager.clockMap.get(sourceIssue.getIndex())+"S");
|
||||
|
||||
if (sourceIssue.getType().equals(DicDataEnum.F.getCode())) {
|
||||
//闪变
|
||||
//CnSocketUtil.quitSend(param);
|
||||
} else if (sourceIssue.getType().equals(DicDataEnum.VOLTAGE.getCode()) || sourceIssue.getType().equals(DicDataEnum.HP.getCode())) {
|
||||
|
||||
System.out.println("进入统计数据3分钟读超时。。。。。。");
|
||||
if(SocketManager.clockMap.get(sourceIssue.getIndex()) > 1800){
|
||||
System.out.println("超时处理-----》"+sourceIssue.getType()+"已超时----------------关闭");
|
||||
CnSocketUtil.quitSend(param);
|
||||
|
||||
WebSocketVO<String> socketVO = new WebSocketVO<>();
|
||||
@@ -109,14 +117,38 @@ public class NettyDevClientHandler extends SimpleChannelInboundHandler<String> {
|
||||
socketVO.setOperateCode(sourceIssue.getType());
|
||||
socketVO.setData(SourceOperateCodeEnum.SOCKET_TIMEOUT.getMsg());
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketVO));
|
||||
//统计数据项
|
||||
}else {
|
||||
System.out.println("进入实时数据3分钟读超时。。。。。。");
|
||||
//实时数据
|
||||
CnSocketUtil.quitSend(param);
|
||||
|
||||
}
|
||||
} else if (sourceIssue.getType().equals(DicDataEnum.VOLTAGE.getCode()) || sourceIssue.getType().equals(DicDataEnum.HP.getCode())) {
|
||||
//统计数据项
|
||||
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));
|
||||
}
|
||||
|
||||
}else {
|
||||
//实时数据
|
||||
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("已经等了一分钟了。。。。。。。。。。。。");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +215,8 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
queryWrapper.selectAll(PqScriptDtls.class)
|
||||
.selectAs(DictTree::getCode, PqScriptDtls::getScriptCode)
|
||||
.leftJoin(DictTree.class, DictTree::getId, PqScriptDtls::getScriptType)
|
||||
.eq(PqScriptDtls::getEnable, 1);
|
||||
.eq(PqScriptDtls::getEnable, 1).eq(PqScriptDtls::getIndex, 48);
|
||||
|
||||
|
||||
if (isPhaseSequence.equals(CommonEnum.PHASE_TEST.getValue())) {
|
||||
//相序
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.storage.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||
import com.njcn.db.mybatisplus.service.impl.ReplenishMybatisServiceImpl;
|
||||
@@ -12,9 +13,11 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 接收检测的原始数据以及计算后的结果
|
||||
*
|
||||
* @author chendaofei
|
||||
*/
|
||||
@Service
|
||||
@@ -25,71 +28,63 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean acceptAdNon(List<AdNonHarmonicResult> adNonHarmonicResultList,String code) {
|
||||
public Boolean acceptAdNon(List<AdNonHarmonicResult> adNonHarmonicResultList, String code) {
|
||||
String adNonTable = "ad_non_harmonic_";
|
||||
DynamicTableNameHandler.setTableName(adNonTable +code);
|
||||
for(AdNonHarmonicResult item :adNonHarmonicResultList){
|
||||
adNonHarmonicService.remove(new LambdaQueryWrapper<AdNonHarmonicResult>()
|
||||
.eq(AdNonHarmonicResult::getMonitorId,item.getMonitorId())
|
||||
.eq(AdNonHarmonicResult::getSort,item.getSort())
|
||||
.eq(AdNonHarmonicResult::getScriptId,item.getScriptId())
|
||||
);
|
||||
DynamicTableNameHandler.setTableName(adNonTable + code);
|
||||
List<String> monitorIds = adNonHarmonicResultList.stream().map(AdNonHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(monitorIds)){
|
||||
adNonHarmonicService.remove(new LambdaQueryWrapper<AdNonHarmonicResult>().in(AdNonHarmonicResult::getMonitorId, monitorIds).eq(AdNonHarmonicResult::getScriptId,adNonHarmonicResultList.get(0).getScriptId()));
|
||||
adNonHarmonicService.saveBatch(adNonHarmonicResultList, 100);
|
||||
}
|
||||
|
||||
adNonHarmonicService.saveBatch(adNonHarmonicResultList,100);
|
||||
DynamicTableNameHandler.remove();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean acceptAd(List<AdHarmonicResult> adHarmonicResultList,String code) {
|
||||
public Boolean acceptAd(List<AdHarmonicResult> adHarmonicResultList, String code) {
|
||||
String adTable = "ad_harmonic_";
|
||||
DynamicTableNameHandler.setTableName(adTable +code);
|
||||
DynamicTableNameHandler.setTableName(adTable + code);
|
||||
List<String> monitorIds = adHarmonicResultList.stream().map(AdHarmonicResult::getMonitorId).distinct().collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(monitorIds)){
|
||||
this.remove(new LambdaQueryWrapper<AdHarmonicResult>().in(AdHarmonicResult::getMonitorId, monitorIds).eq(AdHarmonicResult::getScriptId,adHarmonicResultList.get(0).getScriptId()));
|
||||
this.saveBatch(adHarmonicResultList, 100);
|
||||
|
||||
for(AdHarmonicResult item :adHarmonicResultList){
|
||||
this.remove(new LambdaQueryWrapper<AdHarmonicResult>()
|
||||
.eq(AdHarmonicResult::getMonitorId,item.getMonitorId())
|
||||
.eq(AdHarmonicResult::getSort,item.getSort())
|
||||
.eq(AdHarmonicResult::getScriptId,item.getScriptId())
|
||||
);
|
||||
}
|
||||
|
||||
this.saveBatch(adHarmonicResultList,100);
|
||||
DynamicTableNameHandler.remove();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean acceptAdNonResult(List<AdNonHarmonicResult> adNonHarmonicResultList,String code) {
|
||||
public Boolean acceptAdNonResult(List<AdNonHarmonicResult> adNonHarmonicResultList, String code) {
|
||||
String adNonTableResult = "ad_non_harmonic_result_";
|
||||
DynamicTableNameHandler.setTableName(adNonTableResult +code);
|
||||
DynamicTableNameHandler.setTableName(adNonTableResult + code);
|
||||
|
||||
for(AdNonHarmonicResult item :adNonHarmonicResultList){
|
||||
for (AdNonHarmonicResult item : adNonHarmonicResultList) {
|
||||
adNonHarmonicService.remove(new LambdaQueryWrapper<AdNonHarmonicResult>()
|
||||
.eq(AdNonHarmonicResult::getMonitorId,item.getMonitorId())
|
||||
.eq(AdNonHarmonicResult::getSort,item.getSort())
|
||||
.eq(AdNonHarmonicResult::getScriptId,item.getScriptId())
|
||||
.eq(AdNonHarmonicResult::getMonitorId, item.getMonitorId())
|
||||
.eq(AdNonHarmonicResult::getSort, item.getSort())
|
||||
.eq(AdNonHarmonicResult::getScriptId, item.getScriptId())
|
||||
|
||||
);
|
||||
}
|
||||
adNonHarmonicService.saveBatch(adNonHarmonicResultList,100);
|
||||
adNonHarmonicService.saveBatch(adNonHarmonicResultList, 100);
|
||||
DynamicTableNameHandler.remove();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean acceptAdResult(List<AdHarmonicResult> adHarmonicResultList,String code) {
|
||||
public Boolean acceptAdResult(List<AdHarmonicResult> adHarmonicResultList, String code) {
|
||||
String adTableResult = "ad_harmonic_result_";
|
||||
DynamicTableNameHandler.setTableName(adTableResult +code);
|
||||
for(AdHarmonicResult item :adHarmonicResultList){
|
||||
DynamicTableNameHandler.setTableName(adTableResult + code);
|
||||
for (AdHarmonicResult item : adHarmonicResultList) {
|
||||
this.remove(new LambdaQueryWrapper<AdHarmonicResult>()
|
||||
.eq(AdHarmonicResult::getMonitorId,item.getMonitorId())
|
||||
.eq(AdHarmonicResult::getSort,item.getSort())
|
||||
.eq(AdHarmonicResult::getScriptId,item.getScriptId())
|
||||
.eq(AdHarmonicResult::getMonitorId, item.getMonitorId())
|
||||
.eq(AdHarmonicResult::getSort, item.getSort())
|
||||
.eq(AdHarmonicResult::getScriptId, item.getScriptId())
|
||||
|
||||
);
|
||||
}
|
||||
this.saveBatch(adHarmonicResultList,100);
|
||||
this.saveBatch(adHarmonicResultList, 100);
|
||||
DynamicTableNameHandler.remove();
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user