代码调整

This commit is contained in:
2025-01-09 20:02:02 +08:00
parent d91960700b
commit f2cfc383fd
8 changed files with 63 additions and 13 deletions

View File

@@ -95,7 +95,7 @@ public class PreDetectionController extends BaseController {
/**
* 重新开始检测
*/
@GetMapping("/restartTemTest")
@PostMapping("/restartTemTest")
@OperateInfo
@ApiOperation("重新开始检测")
@ApiImplicitParam(name = "param", value = "参数", required = true)

View File

@@ -20,8 +20,10 @@ import com.njcn.gather.device.script.pojo.param.PqScriptIssueParam;
import com.njcn.gather.device.script.pojo.po.SourceIssue;
import com.njcn.gather.device.script.service.IPqScriptCheckDataService;
import com.njcn.gather.device.script.service.IPqScriptDtlsService;
import com.njcn.gather.storage.pojo.param.StorageParam;
import com.njcn.gather.storage.pojo.po.AdHarmonicResult;
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
import com.njcn.gather.storage.service.AdHarmonicService;
import com.njcn.gather.storage.service.DetectionDataDealService;
import com.njcn.gather.system.config.pojo.po.SysTestConfig;
import com.njcn.gather.system.config.service.ISysTestConfigService;
@@ -75,6 +77,7 @@ public class SocketDevResponseService {
private final ISysRegResService iSysRegResService;
private final IPqScriptCheckDataService iPqScriptCheckDataService;
private final ISysTestConfigService sysTestConfigService;
private final AdHarmonicService adHarmonicService;
private final ExecutorService executorPool = Executors.newFixedThreadPool(10);
@@ -668,9 +671,20 @@ public class SocketDevResponseService {
successDevComm.clear();
socketMsg.setOperateCode(SourceOperateCodeEnum.OPER_GATHER.getValue());
List<SourceIssue> sourceIssues;
if (SourceOperateCodeEnum.FORMAL_TEST.getValue().equals(param.getOperateType())) {
if (SourceOperateCodeEnum.FORMAL_TEST.getValue().equals(param.getOperateType()) || SourceOperateCodeEnum.RE_ERROR_TEST.getValue().equals(param.getOperateType())) {
if(param.getOperateType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())){
//不合格项复检
StorageParam storageParam = new StorageParam();
storageParam.setCode(Integer.valueOf(param.getPlanCode()));
storageParam.setScriptId(param.getScriptId());
List<Integer> indexes = adHarmonicService.getIndex(storageParam);
issueParam.setIndexList(indexes);
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.COEFFICIENT_TEST.getValue());
}else {
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.FORMAL_TEST.getValue());
}
//正式检测
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.FORMAL_TEST.getValue());
sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
sourceIssues = sourceIssues.stream().sorted(Comparator.comparing(SourceIssue::getIndex)).collect(Collectors.toList());
SocketManager.addSourceList(sourceIssues);

View File

@@ -168,8 +168,22 @@ public class SocketSourceResponseService {
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case SOURCE_CONNECTION_ERROR:
CnSocketUtil.quitSendSource(param);
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case CONTROLLED_SOURCE_ERROR:
CnSocketUtil.quitSendSource(param);
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case TEST_ITEM_PARSING_ERROR:
CnSocketUtil.quitSendSource(param);
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
case SOURCE_CONTROL_ERROR:
CnSocketUtil.quitSendSource(param);
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
break;
default:
socketMsg = new SocketMsg<>();
socketMsg.setRequestId(socketDataMsg.getRequestId());

View File

@@ -44,7 +44,7 @@ public enum SourceOperateCodeEnum {
*/
YJC_YTXJY("yjc_ytxjy", "源通讯检测"),
YJC_SBTXJY("yjc_sbtxjy", "设备通讯检测"),
YJC_XYJY("yjc_xyjy", "预检测_协议校验"),
YJC_XYJY("yjc_xyjy", "协议校验"),
YJC_XUJY("YJC_xujy", "相序校验"),
FORMAL_REAL("formal_real","正式检测_获取实时数据"),
FORMAL_STATISTIC("formal_statistic","正式检测_获取统计数据"),
@@ -73,6 +73,7 @@ public enum SourceOperateCodeEnum {
TEST_TEM_STOP("5","临时停止"),
TEST_TEM_START("6","继续检测"),
TEST_STOP("7","停止检测"),
RE_ERROR_TEST("8","不合格项复检"),
/**

View File

@@ -5,6 +5,8 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.handler.SocketDevResponseService;
import com.njcn.gather.detection.handler.SocketSourceResponseService;
@@ -22,6 +24,9 @@ import com.njcn.gather.detection.util.socket.SocketManager;
import com.njcn.gather.detection.util.socket.cilent.NettyClient;
import com.njcn.gather.detection.util.socket.cilent.NettySourceClientHandler;
import com.njcn.gather.device.device.service.IPqDevService;
import com.njcn.gather.device.script.pojo.param.PqScriptIssueParam;
import com.njcn.gather.device.script.pojo.po.PqScriptCheckData;
import com.njcn.gather.device.script.pojo.po.PqScriptDtls;
import com.njcn.gather.device.script.pojo.po.SourceIssue;
import com.njcn.gather.device.script.service.IPqScriptDtlsService;
import com.njcn.gather.device.source.pojo.po.PqSource;
@@ -31,7 +36,10 @@ 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.storage.pojo.param.StorageParam;
import com.njcn.gather.storage.service.AdHarmonicService;
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.IDictDataService;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFutureListener;
@@ -39,6 +47,7 @@ import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
@@ -58,6 +67,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
private final SocketDevResponseService socketDevResponseService;
private final SocketSourceResponseService socketSourceResponseService;
private final AdHarmonicService adHarmonicService;
@Value("${socket.source.ip:192.168.1.136}")
@@ -78,10 +88,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
查询计划什么模式的(除了对比式,其他都是一个计划对应一个源)
*/
AdPlan plan = iAdPlanService.getById(param.getPlanId());
param.setSourceId(plan.getDatasourceId());
if (ObjectUtil.isNotNull(plan)) {
plan.setErrorSysId(plan.getId());
param.setCode(String.valueOf(plan.getCode()));
String code = dictDataService.getDictDataById(plan.getPattern()).getCode();
DictDataEnum dictDataEnumByCode = DictDataEnum.getDictDataEnumByCode(code);
switch (dictDataEnumByCode) {
@@ -127,7 +134,12 @@ public class PreDetectionServiceImpl implements PreDetectionService {
private void sendYtxSocket(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()));
if (ObjectUtil.isNotNull(planSource)) {
SourceInitialize sourceParam = pqSourceService.getSourceInitializeParam(planSource.getSourceId());
if (ObjectUtil.isNotNull(sourceParam)) {
@@ -138,7 +150,7 @@ public class PreDetectionServiceImpl implements PreDetectionService {
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, JSON.toJSONString(msg), new NettySourceClientHandler(param, sourceResponseService));
} else {
throw new BusinessException(DetectionResponseEnum.SOURCE_INFO_NOT);

View File

@@ -28,4 +28,6 @@ public class PqScriptIssueParam {
@ApiModelProperty("源id")
private String sourceId;
private List<Integer> indexList;
}

View File

@@ -124,7 +124,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
if (voltSet.size() == 1 && currSet.size() == 1) {
Double volt = voltSet.stream().collect(Collectors.toList()).stream().findFirst().get();
Double curr = currSet.stream().collect(Collectors.toList()).stream().findFirst().get();
List<PqScriptDtls> pqScriptDtls = this.pqScriptDtls(param.getScriptId(), param.getIsPhaseSequence(), volt, curr);
List<PqScriptDtls> pqScriptDtls = this.pqScriptDtls(param.getScriptId(), param.getIsPhaseSequence(), volt, curr,param.getIndexList());
if (CollUtil.isNotEmpty(pqScriptDtls)) {
/**
* 1.获取全部检测点脚本
@@ -200,6 +200,9 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
return sourceIssues;
}
@Override
public List<Integer> getIndexList(String scriptType, String scriptId) {
MPJLambdaWrapper<PqScriptDtls> wrapper = new MPJLambdaWrapper<>();
@@ -210,7 +213,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
return this.getBaseMapper().selectJoinList(PqScriptDtls.class, wrapper).stream().map(PqScriptDtls::getIndex).collect(Collectors.toList());
}
private List<PqScriptDtls> pqScriptDtls(String scriptId, String isPhaseSequence, Double volt, Double curr) {
public List<PqScriptDtls> pqScriptDtls(String scriptId, String isPhaseSequence, Double volt, Double curr,List<Integer> indexList) {
List<PqScriptDtls> pqScriptDtls;
MPJLambdaWrapper<PqScriptDtls> queryWrapper = new MPJLambdaWrapper<>();
queryWrapper.selectAll(PqScriptDtls.class)
@@ -228,7 +231,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
pqScriptDtls = this.list(queryWrapper);
}else if(isPhaseSequence.equals(CommonEnum.COEFFICIENT_TEST.getValue())){
//系数
queryWrapper.in(PqScriptDtls::getIndex, Stream.of(-2,-3).collect(Collectors.toList()))
queryWrapper.in(PqScriptDtls::getIndex, indexList)
.eq(PqScriptDtls::getEnable, 1);
pqScriptDtls = this.list(queryWrapper);
} else {

View File

@@ -173,13 +173,17 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
String prefixNon = "ad_non_harmonic_result_";
DynamicTableNameHandler.setTableName(prefix + param.getCode());
LambdaQueryWrapper<AdHarmonicResult> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.select(AdHarmonicResult::getSort).eq(AdHarmonicResult::getResultFlag, 2);
lambdaQueryWrapper.select(AdHarmonicResult::getSort)
.eq(AdHarmonicResult::getResultFlag, 2)
.eq(AdHarmonicResult::getScriptId,param.getScriptId());
List<AdHarmonicResult> adHarmonicResultList = this.list(lambdaQueryWrapper);
List<Integer> indexes = new ArrayList<>(adHarmonicResultList.stream().map(AdHarmonicResult::getSort).collect(Collectors.toList()));
DynamicTableNameHandler.setTableName(prefixNon + param.getCode());
LambdaQueryWrapper<AdNonHarmonicResult> resultLambdaQueryWrapper = new LambdaQueryWrapper<>();
resultLambdaQueryWrapper.select(AdNonHarmonicResult::getSort).eq(AdNonHarmonicResult::getResultFlag,2);
resultLambdaQueryWrapper.select(AdNonHarmonicResult::getSort)
.eq(AdNonHarmonicResult::getResultFlag,2)
.eq(AdNonHarmonicResult::getScriptId,param.getScriptId());;
List<AdNonHarmonicResult> nonHarmonicResults = adNonHarmonicMapper.selectList(resultLambdaQueryWrapper);
indexes.addAll(nonHarmonicResults.stream().map(AdNonHarmonicResult::getSort).collect(Collectors.toList()));