Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -7,19 +7,15 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
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.param.SimulateDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketMsg;
|
||||
import com.njcn.gather.detection.service.PreDetectionService;
|
||||
import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
|
||||
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.cilent.NettyClient;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettyDevClientHandler;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettySourceClientHandler;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
@@ -54,9 +50,6 @@ public class PreDetectionController extends BaseController {
|
||||
private final SocketDevResponseService socketDevResponseService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 开始检测
|
||||
*/
|
||||
@@ -64,12 +57,48 @@ public class PreDetectionController extends BaseController {
|
||||
@OperateInfo
|
||||
@ApiOperation("开始检测")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<String> startPreTest(@RequestBody @Validated PreDetectionParam param){
|
||||
public HttpResult<String> startPreTest(@RequestBody @Validated PreDetectionParam param) {
|
||||
String methodDescribe = getMethodDescribe("startPreTest");
|
||||
preDetectionService.sourceCommunicationCheck(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@PostMapping("/ytxCheckSimulate")
|
||||
@OperateInfo
|
||||
@ApiOperation("模拟检测-通讯校验")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<String> ytxCheckSimulate(@RequestBody @Validated SimulateDetectionParam param) {
|
||||
String methodDescribe = getMethodDescribe("ytxCheckSimulate");
|
||||
preDetectionService.ytxCheckSimulate(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟检测
|
||||
*/
|
||||
@PostMapping("/startSimulateTest")
|
||||
@OperateInfo
|
||||
@ApiOperation("模拟检测")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<String> startTestSimulate(@RequestBody @Validated SimulateDetectionParam param) {
|
||||
String methodDescribe = getMethodDescribe("startTestSimulate");
|
||||
preDetectionService.sendScript(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭检测
|
||||
*/
|
||||
@PostMapping("/closeSimulateTest")
|
||||
@OperateInfo
|
||||
@ApiOperation("停止模拟检测")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<String> closeSimulateTest(@RequestBody @Validated SimulateDetectionParam param) {
|
||||
String methodDescribe = getMethodDescribe("closeSimulateTest");
|
||||
preDetectionService.closeTestSimulate(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭检测
|
||||
*/
|
||||
@@ -77,7 +106,7 @@ public class PreDetectionController extends BaseController {
|
||||
@OperateInfo
|
||||
@ApiOperation("关闭检测")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<String> closeCheck(@RequestBody @Validated PreDetectionParam param){
|
||||
public HttpResult<String> closeCheck(@RequestBody @Validated PreDetectionParam param) {
|
||||
String methodDescribe = getMethodDescribe("closeCheck");
|
||||
preDetectionService.closeCheck(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
@@ -90,7 +119,7 @@ public class PreDetectionController extends BaseController {
|
||||
@OperateInfo
|
||||
@ApiOperation("下一步检测")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<String> nextScript(@RequestBody @Validated PreDetectionParam param){
|
||||
public HttpResult<String> nextScript(@RequestBody @Validated PreDetectionParam param) {
|
||||
String methodDescribe = getMethodDescribe("nextScript");
|
||||
preDetectionService.nextScript(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
@@ -104,7 +133,7 @@ public class PreDetectionController extends BaseController {
|
||||
@OperateInfo
|
||||
@ApiOperation("系数校验")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<String> coefficientCheck(@RequestBody PreDetectionParam param){
|
||||
public HttpResult<String> coefficientCheck(@RequestBody PreDetectionParam param) {
|
||||
String methodDescribe = getMethodDescribe("coefficientCheck");
|
||||
preDetectionService.coefficientCheck(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
@@ -118,7 +147,7 @@ public class PreDetectionController extends BaseController {
|
||||
@OperateInfo
|
||||
@ApiOperation("暂停检测")
|
||||
@ApiImplicitParam(name = "param", value = "参数", required = true)
|
||||
public HttpResult<String> temStopTest(){
|
||||
public HttpResult<String> temStopTest() {
|
||||
String methodDescribe = getMethodDescribe("temStopTest");
|
||||
preDetectionService.temStopTest();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
@@ -131,14 +160,13 @@ public class PreDetectionController extends BaseController {
|
||||
@OperateInfo
|
||||
@ApiOperation("重新开始检测")
|
||||
@ApiImplicitParam(name = "param", value = "参数", required = true)
|
||||
public HttpResult<String> restartTemTest(@RequestBody PreDetectionParam param){
|
||||
public HttpResult<String> restartTemTest(@RequestBody PreDetectionParam param) {
|
||||
String methodDescribe = getMethodDescribe("restartTemTest");
|
||||
preDetectionService.restartTemTest(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 测试
|
||||
*/
|
||||
@@ -146,13 +174,11 @@ public class PreDetectionController extends BaseController {
|
||||
@OperateInfo
|
||||
@ApiOperation("测试")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<String> startTest(@RequestBody PreDetectionParam param){
|
||||
public HttpResult<String> startTest(@RequestBody PreDetectionParam param) {
|
||||
String methodDescribe = getMethodDescribe("startTest");
|
||||
//preDetectionService.startTest(param);
|
||||
|
||||
|
||||
|
||||
|
||||
List<PreDetection> pqDevList = iPqDevService.getDevInfo(param.getDevIds());
|
||||
XiNumberManager.xiDevList = pqDevList;
|
||||
String s = param.getUserPageId() + "_Dev";
|
||||
@@ -160,9 +186,9 @@ public class PreDetectionController extends BaseController {
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.Coefficient_Check.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DATA_CHNFACTOR$01.getValue());
|
||||
PreDetection preDetection = pqDevList.get(0);
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("devIP",preDetection.getDevIP());
|
||||
map.put("chnNum",preDetection.getDevChns());
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("devIP", preDetection.getDevIP());
|
||||
map.put("chnNum", preDetection.getDevChns());
|
||||
socketMsg.setData(JSON.toJSONString(map));
|
||||
|
||||
|
||||
@@ -170,7 +196,6 @@ public class PreDetectionController extends BaseController {
|
||||
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -61,7 +61,11 @@ public class SocketSourceResponseService {
|
||||
switch (enumByCode) {
|
||||
//源初始化
|
||||
case YJC_YTXJY:
|
||||
detectionDev(param, socketDataMsg);
|
||||
if (ObjectUtil.isNotNull(param.getPlanId())) {
|
||||
detectionDev(param, socketDataMsg);
|
||||
} else {
|
||||
System.out.println("模拟检测-源初始化成功");
|
||||
}
|
||||
break;
|
||||
//相序检测
|
||||
case YJC_XUJY:
|
||||
@@ -69,7 +73,11 @@ public class SocketSourceResponseService {
|
||||
break;
|
||||
//正式检测
|
||||
case FORMAL_REAL:
|
||||
senParamToDev(param, socketDataMsg);
|
||||
if (ObjectUtil.isNotNull(param.getPlanId())) {
|
||||
senParamToDev(param, socketDataMsg);
|
||||
} else {
|
||||
handleSimulateTest(param, socketDataMsg);
|
||||
}
|
||||
break;
|
||||
//系数校验
|
||||
case Coefficient_Check:
|
||||
@@ -84,8 +92,34 @@ public class SocketSourceResponseService {
|
||||
} else {
|
||||
System.out.println("fggggggggggggggggggggg" + enumByCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理模拟检测时,通信模块返回报文
|
||||
*
|
||||
* @param param
|
||||
* @param socketDataMsg
|
||||
*/
|
||||
private void handleSimulateTest(PreDetectionParam param, SocketDataMsg socketDataMsg) {
|
||||
SourceResponseCodeEnum dictDataEnumByCode = SourceResponseCodeEnum.getDictDataEnumByCode(socketDataMsg.getCode());
|
||||
if (ObjectUtil.isNotNull(dictDataEnumByCode)) {
|
||||
switch (dictDataEnumByCode) {
|
||||
case SUCCESS:
|
||||
System.out.println("模拟检测-源成功执行脚本");
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
break;
|
||||
default:
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(socketDataMsg.getRequestId());
|
||||
socketMsg.setOperateCode(socketDataMsg.getOperateCode());
|
||||
socketMsg.setData(dictDataEnumByCode.getMessage());
|
||||
WebServiceManager.sendMsg(param.getUserPageId(), JSON.toJSONString(socketMsg));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ public enum SourceOperateCodeEnum {
|
||||
YJC_XYJY("yjc_xyjy", "协议校验"),
|
||||
YJC_XUJY("YJC_xujy", "相序校验"),
|
||||
FORMAL_REAL("formal_real","正式检测"),
|
||||
// SIMULATE_REAL("simulate_real","模拟检测"),
|
||||
Coefficient_Check("Coefficient_Check","系数校验"),
|
||||
QUITE("quit","关闭设备通讯初始化"),
|
||||
QUITE_SOURCE("close_source","关闭源通讯"),
|
||||
@@ -74,6 +75,7 @@ public enum SourceOperateCodeEnum {
|
||||
TEST_TEM_START("6","继续检测"),
|
||||
TEST_STOP("7","停止检测"),
|
||||
RE_ERROR_TEST("8","不合格项复检"),
|
||||
SIMULATE_TEST("9","模拟检测"),
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.njcn.gather.detection.pojo.param;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-03-06
|
||||
*/
|
||||
@Data
|
||||
public class SimulateDetectionParam {
|
||||
|
||||
/**
|
||||
* 操作类型 9.模拟检测
|
||||
*/
|
||||
private String operateType = "9";
|
||||
|
||||
|
||||
/**
|
||||
* 用户功能组成唯一标识 zhangsan_test
|
||||
*/
|
||||
private String userPageId;
|
||||
|
||||
/**
|
||||
* 检测脚本Id
|
||||
*/
|
||||
private String scriptId;
|
||||
|
||||
private Integer scriptIndex;
|
||||
|
||||
/**
|
||||
* 源id
|
||||
*/
|
||||
private String sourceId;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.njcn.gather.detection.service;
|
||||
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
|
||||
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
||||
|
||||
|
||||
/**
|
||||
@@ -13,7 +13,8 @@ public interface PreDetectionService {
|
||||
|
||||
/**
|
||||
* 源通讯校验socket入参拼接
|
||||
* @param param
|
||||
*
|
||||
* @param param
|
||||
* @Author: wr
|
||||
* @Date: 2024/12/11 13:26
|
||||
*/
|
||||
@@ -33,6 +34,26 @@ public interface PreDetectionService {
|
||||
|
||||
void closeCheck(PreDetectionParam param);
|
||||
|
||||
void nextScript(PreDetectionParam param);
|
||||
void nextScript(PreDetectionParam param);
|
||||
|
||||
/**
|
||||
* 模拟测试-源通讯校验
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void ytxCheckSimulate(SimulateDetectionParam param);
|
||||
|
||||
/**
|
||||
* 模拟测试-向源发送脚本
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void sendScript(SimulateDetectionParam param);
|
||||
|
||||
/**
|
||||
* 模拟测试-停止
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void closeTestSimulate(SimulateDetectionParam param);
|
||||
}
|
||||
|
||||
@@ -11,29 +11,28 @@ import com.njcn.gather.detection.handler.SocketSourceResponseService;
|
||||
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.param.SimulateDetectionParam;
|
||||
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.SocketManager;
|
||||
import com.njcn.gather.detection.util.socket.WebServiceManager;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettyDevClientHandler;
|
||||
import com.njcn.gather.detection.util.socket.cilent.NettySourceClientHandler;
|
||||
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.source.pojo.po.SourceInitialize;
|
||||
import com.njcn.gather.source.service.IPqSourceService;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlanSource;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import io.netty.channel.Channel;
|
||||
@@ -42,7 +41,10 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -53,6 +55,8 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
|
||||
private final String source = "_Source";
|
||||
private final String dev = "_Dev";
|
||||
private final String stepTag = "&&";
|
||||
private final String handlerSourceStr = "_Source";
|
||||
|
||||
private final IPqDevService iPqDevService;
|
||||
private final IDictDataService dictDataService;
|
||||
@@ -154,6 +158,30 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendYtxSocketSimulate(PreDetectionParam param) {
|
||||
//AdPlan plan = iAdPlanService.getById(param.getPlanId());
|
||||
//AdPlanSource planSource = adPlanSourceService.getOne(new LambdaQueryWrapper<AdPlanSource>().eq(AdPlanSource::getPlanId, param.getPlanId()));
|
||||
//param.setSourceId(planSource.getSourceId());
|
||||
//param.setScriptId(plan.getScriptId());
|
||||
//param.setErrorSysId(plan.getErrorSysId());
|
||||
//param.setCode(String.valueOf(plan.getCode()));
|
||||
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(param.getSourceId());
|
||||
param.setSourceId(sourceParam.getSourceId());
|
||||
WebServiceManager.addPreDetectionParam(param);
|
||||
if (ObjectUtil.isNotNull(sourceParam)) {
|
||||
//开始组装socket报文请求头
|
||||
//socketDevResponseService.initList(param);
|
||||
//socketSourceResponseService.initList(param);
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.YJC_YTXJY.getValue());
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.INIT_GATHER.getValue());
|
||||
socketMsg.setData(JSON.toJSONString(sourceParam));
|
||||
NettyClient.socketClient(ip, port, param, JSON.toJSONString(socketMsg), new NettySourceClientHandler(param, sourceResponseService));
|
||||
} else {
|
||||
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean startTest(PreDetectionParam param) {
|
||||
@@ -183,12 +211,12 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
SocketManager.sendMsg(param.getUserPageId() + source, JSON.toJSONString(xuMsg));
|
||||
} else {
|
||||
//TODO 是否最终检测完成需要推送给用户
|
||||
PqScriptCheckDataParam checkDataParam=new PqScriptCheckDataParam();
|
||||
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
|
||||
checkDataParam.setScriptId(param.getScriptId());
|
||||
checkDataParam.setIsValueTypeName(false);
|
||||
List<String> valueType = iPqScriptCheckDataService.getValueType(checkDataParam);
|
||||
|
||||
iPqDevService.updateResult(param.getDevIds(), valueType,param.getCode());
|
||||
iPqDevService.updateResult(param.getDevIds(), valueType, param.getCode());
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
|
||||
@@ -229,8 +257,78 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void ytxCheckSimulate(SimulateDetectionParam param) {
|
||||
PreDetectionParam preDetectionParam = new PreDetectionParam();
|
||||
preDetectionParam.setSourceId(param.getSourceId());
|
||||
preDetectionParam.setUserPageId(param.getUserPageId());
|
||||
|
||||
specialDealSimulate(preDetectionParam);
|
||||
|
||||
// String code = dictDataService.getDictDataById(param.getPattern()).getCode();
|
||||
// DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code);
|
||||
// switch (dictDataEnumByCode) {
|
||||
// case DIGITAL:
|
||||
// case SIMULATE:
|
||||
// sendYtxSocketSimulate(preDetectionParam);
|
||||
// break;
|
||||
// case CONTRAST:
|
||||
// break;
|
||||
// default:
|
||||
// throw new BusinessException(DetectionResponseEnum.PLAN_PATTERN_NOT);
|
||||
// }
|
||||
sendYtxSocketSimulate(preDetectionParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendScript(SimulateDetectionParam param) {
|
||||
// Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
|
||||
// if (Objects.isNull(channel) || !channel.isActive()) {
|
||||
// // 进行源通信连接
|
||||
// PreDetectionParam preDetectionParam = new PreDetectionParam();
|
||||
// preDetectionParam.setSourceId(param.getSourceId());
|
||||
// preDetectionParam.setUserPageId(param.getUserPageId());
|
||||
// this.sendYtxSocketSimulate(preDetectionParam);
|
||||
// }
|
||||
//组装源控制脚本
|
||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||
//issueParam.setPlanId(param.getPlanId());
|
||||
issueParam.setSourceId(param.getSourceId());
|
||||
//issueParam.setDevIds(param.getDevIds());
|
||||
issueParam.setScriptId(param.getScriptId());
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.SIMULATE_TEST.getValue());
|
||||
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||
sourceIssues = sourceIssues.stream()
|
||||
.filter(s -> s.getIndex().equals(param.getScriptIndex()))
|
||||
.sorted(Comparator.comparing(SourceIssue::getIndex))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
SourceIssue sourceIssue = sourceIssues.get(0);
|
||||
List<String> comm = sourceIssue.getDevValueTypeList();
|
||||
System.out.println("向装置下发的参数ddd>>>>>>>>" + comm);
|
||||
|
||||
SocketMsg<String> socketMsg = new SocketMsg<>();
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
|
||||
socketMsg.setRequestId(SourceOperateCodeEnum.FORMAL_REAL.getValue() + stepTag + sourceIssue.getType());
|
||||
socketMsg.setData(JSON.toJSONString(sourceIssues.get(0)));
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(socketMsg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeTestSimulate(SimulateDetectionParam param) {
|
||||
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(param.getSourceId());
|
||||
PreDetectionParam preDetectionParam = new PreDetectionParam();
|
||||
preDetectionParam.setSourceId(sourceParam.getSourceId());
|
||||
preDetectionParam.setUserPageId(param.getUserPageId());
|
||||
CnSocketUtil.quitSendSource(preDetectionParam);
|
||||
WebServiceManager.removePreDetectionParam();
|
||||
|
||||
SocketManager.removeUser(param.getUserPageId() + source);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对重复发起或者异常发起的检测进行关闭源操作
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
private void specialDeal(PreDetectionParam param) {
|
||||
@@ -240,7 +338,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
System.out.println("发送关闭源指令。。。。。。。。");
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
}
|
||||
if(Objects.nonNull(channelDev) && channelDev.isActive()){
|
||||
if (Objects.nonNull(channelDev) && channelDev.isActive()) {
|
||||
System.out.println("发送关闭设备通讯指令。。。。。。。。");
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
@@ -248,7 +346,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
try {
|
||||
Thread.sleep(4000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
|
||||
SocketManager.removeUser(param.getUserPageId() + source);
|
||||
@@ -261,14 +359,38 @@ public class PreDetectionServiceImpl implements PreDetectionService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 对重复发起或者异常发起的检测进行关闭源操作-模拟检测
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
private void specialDealSimulate(PreDetectionParam param) {
|
||||
Channel channel = SocketManager.getChannelByUserId(param.getUserPageId() + source);
|
||||
if (Objects.nonNull(channel) && channel.isActive()) {
|
||||
System.out.println("发送关闭源指令。。。。。。。。");
|
||||
CnSocketUtil.quitSendSource(param);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(4000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
SocketManager.removeUser(param.getUserPageId() + source);
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验
|
||||
*/
|
||||
private void commCheck(PreDetectionParam param){
|
||||
private void commCheck(PreDetectionParam param) {
|
||||
List<PqDev> pqDevList = iPqDevService.listByIds(param.getDevIds());
|
||||
List<String> ipList = pqDevList.stream().map(PqDev::getIp).distinct().collect(Collectors.toList());
|
||||
if(ipList.size()!=param.getDevIds().size()){
|
||||
if (ipList.size() != param.getDevIds().size()) {
|
||||
throw new BusinessException(DetectionResponseEnum.PLAN_DEV_IP_HAS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class MsgUtil {
|
||||
return JSON.toJSONString(socketDataMsg);
|
||||
}
|
||||
|
||||
public List<DevData> toList(List<AdNonHarmonicResult> nonHarm, List<AdHarmonicResult> harm) {
|
||||
public static List<DevData> toList(List<AdNonHarmonicResult> nonHarm, List<AdHarmonicResult> harm) {
|
||||
List<DevData> info = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(nonHarm)) {
|
||||
if (CollUtil.isNotEmpty(nonHarm)) {
|
||||
@@ -85,8 +85,8 @@ public class MsgUtil {
|
||||
noHarmMap.forEach((key, value) -> {
|
||||
String[] split = key.split("_");
|
||||
DevData data = new DevData();
|
||||
data.setTime(split[1]);
|
||||
data.setId(split[0]);
|
||||
data.setTime(split[2]);
|
||||
data.setId(split[0]+"_"+split[1]);
|
||||
List<DevData.SqlDataDTO> sqlDataDTOS = new ArrayList<>();
|
||||
DevData.SqlDataDTO sqlDataDTO;
|
||||
for (AdNonHarmonicResult result : value) {
|
||||
@@ -129,8 +129,8 @@ public class MsgUtil {
|
||||
} else {
|
||||
String[] split = key.split("_");
|
||||
DevData data = new DevData();
|
||||
data.setTime(split[1]);
|
||||
data.setId(split[0]);
|
||||
data.setTime(split[2]);
|
||||
data.setId(split[0]+"_"+split[1]);
|
||||
data.setSqlDataHarm(sqlDataDTOS);
|
||||
info.add(data);
|
||||
}
|
||||
@@ -142,7 +142,7 @@ public class MsgUtil {
|
||||
|
||||
}
|
||||
|
||||
private List<String> reflectHarmonicValue(String phase, AdHarmonicResult adHarmonicResult) {
|
||||
private static List<String> reflectHarmonicValue(String phase, AdHarmonicResult adHarmonicResult) {
|
||||
List<String> info = new ArrayList<>();
|
||||
for (int i = 2; i < 50; i++) {
|
||||
String fieldName = phase + "Value" + i;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.gather.detection.util.socket;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.vo.WebSocketVO;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
||||
@@ -24,6 +25,8 @@ public class WebServiceManager {
|
||||
//key:页面 value:channel
|
||||
private static final Map<String, Channel> userSessions = new ConcurrentHashMap<>();
|
||||
|
||||
// 检测参数。key固定为preDetectionParam, value:检测参数
|
||||
private static final Map<String, PreDetectionParam> preDetectionParamMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static void addUser(String userId, Channel channel) {
|
||||
userSessions.put(userId, channel);
|
||||
@@ -66,5 +69,15 @@ public class WebServiceManager {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void addPreDetectionParam(PreDetectionParam preDetectionParam) {
|
||||
preDetectionParamMap.put("preDetectionParam", preDetectionParam);
|
||||
}
|
||||
public static PreDetectionParam getPreDetectionParam() {
|
||||
return preDetectionParamMap.get("preDetectionParam");
|
||||
}
|
||||
public static void removePreDetectionParam() {
|
||||
preDetectionParamMap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,15 @@
|
||||
package com.njcn.gather.detection.util.socket.web;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.util.socket.CnSocketUtil;
|
||||
import com.njcn.gather.detection.util.socket.SocketManager;
|
||||
import com.njcn.gather.detection.util.socket.WebServiceManager;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
||||
import io.netty.handler.timeout.IdleStateEvent;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
/**
|
||||
@@ -73,6 +67,7 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
|
||||
|
||||
/**
|
||||
* 根据用户地址获取用户名 ws://127.0.0.1:7777/hello?name=aa
|
||||
*
|
||||
* @param url
|
||||
* @return
|
||||
*/
|
||||
@@ -112,7 +107,7 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerRemoved(ChannelHandlerContext ctx){
|
||||
public void handlerRemoved(ChannelHandlerContext ctx) {
|
||||
// 假设用户 ID 是从某个地方获取的,这里简单示例为 "userId"
|
||||
System.out.println("weoSocket客户端退出: " + ctx.channel().id());
|
||||
WebServiceManager.removeChannel(ctx.channel().id().toString());
|
||||
@@ -124,9 +119,14 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
|
||||
System.out.println("weoSocket断线" + ctx.channel().id());
|
||||
ctx.close();
|
||||
|
||||
PreDetectionParam param = new PreDetectionParam();
|
||||
param.setUserPageId("cdf");
|
||||
CnSocketUtil.quitSend(param);
|
||||
PreDetectionParam preDetectionParam = WebServiceManager.getPreDetectionParam();
|
||||
if (ObjectUtil.isNotNull(preDetectionParam)) {
|
||||
CnSocketUtil.quitSendSource(preDetectionParam); // 能否在这里关闭源socket连接?
|
||||
} else {
|
||||
preDetectionParam = new PreDetectionParam();
|
||||
preDetectionParam.setUserPageId("cdf");
|
||||
CnSocketUtil.quitSend(preDetectionParam);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -86,4 +86,16 @@ public class ResultController extends BaseController {
|
||||
|
||||
resultService.exportRawData(queryParam);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/changeErrorSystem")
|
||||
@ApiOperation("更换误差体系")
|
||||
@ApiImplicitParam(name = "param", value = "修改参数", required = true)
|
||||
public HttpResult<Object> changeErrorSystem(@RequestBody ResultParam.ChangeErrorSystemParam param) {
|
||||
String methodDescribe = getMethodDescribe("changeErrorSystem");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
|
||||
resultService.changeErrorSystem(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,4 +64,28 @@ public class ResultParam {
|
||||
// 通道号,当为-1时,表示查询所有通道号,否则只查询指定通道号
|
||||
private String chnNum;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class ChangeErrorSystemParam {
|
||||
@ApiModelProperty(value = "检测计划Id", required = true)
|
||||
@NotBlank(message = DevValidMessage.PLAN_ID_NOT_NULL)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PLAN_ID_FORMAT_ERROR)
|
||||
private String planId;
|
||||
|
||||
@ApiModelProperty(value = "脚本Id", required = true)
|
||||
@NotBlank(message = DevValidMessage.SCRIPT_ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.SCRIPT_ID_FORMAT_ERROR)
|
||||
private String scriptId;
|
||||
|
||||
@ApiModelProperty(value = "误差体系Id", required = true)
|
||||
@NotBlank(message = DevValidMessage.ERROR_SYS_ID_NOT_BLANK)
|
||||
private String errorSysId;
|
||||
|
||||
@ApiModelProperty(value = "设备Id", required = true)
|
||||
@NotBlank(message = DevValidMessage.DEV_ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.DEV_ID_FORMAT_ERROR)
|
||||
private String deviceId;
|
||||
|
||||
private Integer code;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,4 +45,11 @@ public interface IResultService {
|
||||
* @param param
|
||||
*/
|
||||
void exportRawData(ResultParam param);
|
||||
|
||||
/**
|
||||
* 更换误差体系
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void changeErrorSystem(ResultParam.ChangeErrorSystemParam param);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,12 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.po.DevData;
|
||||
import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
|
||||
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
@@ -20,23 +26,30 @@ import com.njcn.gather.result.pojo.vo.ResultVO;
|
||||
import com.njcn.gather.result.pojo.vo.TreeDataVO;
|
||||
import com.njcn.gather.result.service.IResultService;
|
||||
import com.njcn.gather.script.mapper.PqScriptMapper;
|
||||
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
|
||||
import com.njcn.gather.script.pojo.po.PqScriptDtls;
|
||||
import com.njcn.gather.script.pojo.po.SourceIssue;
|
||||
import com.njcn.gather.script.service.IPqScriptCheckDataService;
|
||||
import com.njcn.gather.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.script.util.ScriptDtlsDesc;
|
||||
import com.njcn.gather.storage.mapper.TableGenMapper;
|
||||
import com.njcn.gather.storage.pojo.param.StorageParam;
|
||||
import com.njcn.gather.storage.pojo.po.AdBaseResult;
|
||||
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.vo.RawDataVO;
|
||||
import com.njcn.gather.storage.service.AdHarmonicService;
|
||||
import com.njcn.gather.storage.service.AdNonHarmonicService;
|
||||
import com.njcn.gather.system.config.pojo.po.SysTestConfig;
|
||||
import com.njcn.gather.system.config.service.ISysTestConfigService;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||
import com.njcn.web.utils.ExcelUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
@@ -60,6 +73,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
private final PqScriptMapper scriptMapper;
|
||||
private final IDictTreeService dictTreeService;
|
||||
private final IPqScriptCheckDataService pqScriptCheckDataService;
|
||||
private final TableGenMapper tableGenMapper;
|
||||
private final DetectionServiceImpl detectionServiceImpl;
|
||||
|
||||
/**
|
||||
* 谐波类code,取树形字典表中的code
|
||||
@@ -127,10 +142,10 @@ public class ResultServiceImpl implements IResultService {
|
||||
.eq(StrUtil.isNotBlank(param.getScriptId()), PqScriptDtls::getScriptId, param.getScriptId())
|
||||
.eq(StrUtil.isNotBlank(param.getScriptType()), PqScriptDtls::getScriptType, param.getScriptType())
|
||||
.ne(PqScriptDtls::getScriptIndex, -1)
|
||||
.eq(StrUtil.isNotBlank(param.getDevId()),PqScriptDtls::getEnable, DataStateEnum.ENABLE.getCode())
|
||||
.eq(StrUtil.isNotBlank(param.getDevId()), PqScriptDtls::getEnable, DataStateEnum.ENABLE.getCode())
|
||||
);
|
||||
Map<Integer, Set<Integer>> resultMap = new HashMap<>(5);
|
||||
if(StrUtil.isNotBlank(param.getDevId())){
|
||||
if (StrUtil.isNotBlank(param.getDevId())) {
|
||||
List<AdBaseResult> allResultList = new ArrayList<>();
|
||||
List<Integer> indexList = new ArrayList<>();
|
||||
if (StrUtil.isNotBlank(param.getScriptType())) {
|
||||
@@ -176,7 +191,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
subTypeMap.forEach((subKey, subValue) -> {
|
||||
if (!"VOLTAGE".equals(dictTree.getCode())) {
|
||||
TreeDataVO subType = new TreeDataVO();
|
||||
subType.setScriptTypeName(!subName.containsKey(subKey)?"":subName.get(subKey).replace("XX", dictTree.getName()));
|
||||
subType.setScriptTypeName(!subName.containsKey(subKey) ? "" : subName.get(subKey).replace("XX", dictTree.getName()));
|
||||
subType.setScriptTypeCode(subKey);
|
||||
LinkedHashMap<Integer, List<PqScriptDtls>> indexMap = subValue.stream()
|
||||
.sorted(Comparator.comparing(PqScriptDtls::getScriptIndex))
|
||||
@@ -213,13 +228,13 @@ public class ResultServiceImpl implements IResultService {
|
||||
.collect(Collectors.groupingBy(PqScriptDtls::getScriptSubType, LinkedHashMap::new, Collectors.toList()));
|
||||
if (CollUtil.isNotEmpty(subSingleTypeMap)) {
|
||||
TreeDataVO subType = new TreeDataVO();
|
||||
subType.setScriptTypeName(!subName.containsKey("Single")?"":subName.get("Single").replace("XX", dictTree.getName()));
|
||||
subType.setScriptTypeName(!subName.containsKey("Single") ? "" : subName.get("Single").replace("XX", dictTree.getName()));
|
||||
subType.setScriptTypeCode(dictTree.getCode());
|
||||
//单影响量下频率准测量集合
|
||||
List<TreeDataVO> subSingleList = new ArrayList<>();
|
||||
subSingleTypeMap.forEach((subKey, subValue) -> {
|
||||
TreeDataVO treeDataVO = new TreeDataVO();
|
||||
treeDataVO.setScriptTypeName(!subName.containsKey(subKey)?"":subName.get(subKey).replace("XX", dictTree.getName()));
|
||||
treeDataVO.setScriptTypeName(!subName.containsKey(subKey) ? "" : subName.get(subKey).replace("XX", dictTree.getName()));
|
||||
treeDataVO.setScriptTypeCode(subKey);
|
||||
List<TreeDataVO> subTypeList = new ArrayList<>();
|
||||
|
||||
@@ -272,7 +287,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
.collect(Collectors.toList());
|
||||
TreeDataVO vo = new TreeDataVO();
|
||||
vo.setScriptTypeName(name);
|
||||
vo.setScriptTypeCode("Base_"+start+"_"+end);
|
||||
vo.setScriptTypeCode("Base_" + start + "_" + end);
|
||||
TreeDataVO dlt;
|
||||
for (PqScriptDtls dtls : dip) {
|
||||
dlt = new TreeDataVO();
|
||||
@@ -839,6 +854,13 @@ public class ResultServiceImpl implements IResultService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void changeErrorSystem(ResultParam.ChangeErrorSystemParam param) {
|
||||
this.createTempResultTable(param.getCode() + "");
|
||||
this.insertTempResultTable(param.getPlanId(), param.getScriptId(), param.getCode() + "", param.getErrorSysId(), param.getDeviceId());
|
||||
}
|
||||
|
||||
private Integer conform(Set<Integer> numbers) {
|
||||
if (CollUtil.isNotEmpty(numbers)) {
|
||||
if (numbers.size() > 1) {
|
||||
@@ -859,4 +881,105 @@ public class ResultServiceImpl implements IResultService {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拷贝结果表
|
||||
*
|
||||
* @param code
|
||||
*/
|
||||
private void createTempResultTable(String code) {
|
||||
tableGenMapper.genAdHarmonicTable("drop table if exists AD_Non_Harmonic_Result_" + code + "_temp,AD_Harmonic_Result_" + code + "_temp");
|
||||
tableGenMapper.genAdNonHarmonicResultTable(code + "_temp");
|
||||
StringBuilder A = new StringBuilder();
|
||||
StringBuilder B = new StringBuilder();
|
||||
StringBuilder C = new StringBuilder();
|
||||
for (int i = 1; i <= 50; i++) {
|
||||
if (i == 1) {
|
||||
A.append("A_Value_").append(i).append(" json NULL COMMENT 'A相基波',");
|
||||
B.append("B_Value_").append(i).append(" json NULL COMMENT 'B相基波',");
|
||||
C.append("C_Value_").append(i).append(" json NULL COMMENT 'C相基波',");
|
||||
} else {
|
||||
A.append("A_Value_").append(i).append(" json NULL COMMENT '").append(i).append("次A相谐波',");
|
||||
B.append("B_Value_").append(i).append(" json NULL COMMENT '").append(i).append("次B相谐波',");
|
||||
C.append("C_Value_").append(i).append(" json NULL COMMENT '").append(i).append("次C相谐波',");
|
||||
}
|
||||
}
|
||||
String sql1 = "CREATE TABLE if not exists AD_Harmonic_Result_" + code + "_temp (\n" +
|
||||
" Monitor_Id CHAR(60) NOT NULL COMMENT '监测点Id',\n" +
|
||||
" Time_Id DATETIME NULL COMMENT '时间',\n" +
|
||||
" Script_Id CHAR(32) NOT NULL COMMENT '检测脚本子表Id,字典表',\n" +
|
||||
" Sort int(5) NOT NULL COMMENT '总检测脚本中的测试项序号',\n" +
|
||||
" AD_Type CHAR(32) NOT NULL COMMENT '检测指标,字典表',\n" +
|
||||
" Data_Type CHAR(32) NOT NULL COMMENT '数据指标,只有数据源为分钟统计时候才会使用(最大、最小、平均、CP95,默认平均值),字典表',\n" +
|
||||
" Result_Flag int(1) NOT NULL COMMENT '1合格 2不合格 4无法处理',\n" +
|
||||
A + B + C +
|
||||
" PRIMARY KEY (Monitor_Id, Script_Id, Sort, AD_Type)\n" +
|
||||
") COMMENT='监测数据表';";
|
||||
tableGenMapper.genAdHarmonicTable(sql1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改拷贝后的结果表(根据误差体系修改)
|
||||
*
|
||||
* @param planId
|
||||
* @param code
|
||||
* @param errorSysId
|
||||
* @param devId
|
||||
*/
|
||||
private void insertTempResultTable(String planId, String scriptId, String code, String errorSysId, String devId) {
|
||||
PreDetectionParam param = new PreDetectionParam();
|
||||
param.setCode(code);
|
||||
param.setErrorSysId(errorSysId);
|
||||
param.setDevIds(Arrays.asList(devId));
|
||||
param.setCode(code+"_temp");
|
||||
|
||||
Map<String, String> devIdMapComm = new HashMap<>();
|
||||
PqDev dev = pqDevService.getById(devId);
|
||||
devIdMapComm.put(devId,devId);
|
||||
|
||||
SysTestConfig oneConfig = sysTestConfigService.getOneConfig();
|
||||
DictDataEnum dataRule;
|
||||
if (ObjectUtil.isNotNull(oneConfig)) {
|
||||
dataRule = DictDataEnum.getDictDataEnumByCode(oneConfig.getDataRule());
|
||||
} else {
|
||||
dataRule = DictDataEnum.AT_WILL_VALUE;
|
||||
}
|
||||
|
||||
List<AdNonHarmonicResult> allNonHarmonicRawData = adNonHarmonicService.listAll(code, devId);
|
||||
LinkedHashMap<Integer, List<AdNonHarmonicResult>> map = allNonHarmonicRawData.stream().sorted(Comparator.comparing(AdNonHarmonicResult::getSort))
|
||||
.collect(Collectors.groupingBy(AdNonHarmonicResult::getSort, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
PqScriptIssueParam issueParam = new PqScriptIssueParam();
|
||||
issueParam.setPlanId(planId);
|
||||
// issueParam.setSourceId();
|
||||
// issueParam.setScriptType();
|
||||
// issueParam.setScriptSubType();
|
||||
|
||||
issueParam.setDevIds(Arrays.asList(devId));
|
||||
issueParam.setScriptId(scriptId);
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.FORMAL_TEST.getValue());
|
||||
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||
|
||||
sourceIssues.forEach(sourceIssue -> {
|
||||
List<DevData> realDataXiList = MsgUtil.toList(map.get(sourceIssue.getIndex()), null);
|
||||
for (int i = 0; i < realDataXiList.size(); i++) {
|
||||
DevData devData = realDataXiList.get(i);
|
||||
List<DevData.SqlDataDTO> sqlData = devData.getSqlData();
|
||||
if(CollUtil.isNotEmpty(sqlData)){
|
||||
for (int j = 0; j < sqlData.size(); j++) {
|
||||
DevData.SqlDataDTO sqlDataDTO = sqlData.get(j);
|
||||
String desc = sqlDataDTO.getDesc();
|
||||
if(StrUtil.isNotBlank(desc)){
|
||||
DictTree dictTree = dictTreeService.getById(desc);
|
||||
if (ObjectUtil.isNotNull(dictTree)) {
|
||||
sqlDataDTO.setDesc(dictTree.getCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
detectionServiceImpl.processing(realDataXiList, param, devIdMapComm, sourceIssue, dataRule);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
if (devFly) {
|
||||
//校验终端额定电压电流是否相同
|
||||
List<PqDev> list = pqDevService.list(new LambdaQueryWrapper<PqDev>()
|
||||
.eq(PqDev::getPlanId, param.getPlanId())
|
||||
.eq(StrUtil.isNotBlank(param.getPlanId()), PqDev::getPlanId, param.getPlanId())
|
||||
.in(PqDev::getId, param.getDevIds())
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user