增加正式监测流程,监测状态变更
This commit is contained in:
@@ -465,12 +465,12 @@ public class SocketDevResponseService {
|
||||
coefficientVO.setCIeData(String.valueOf(optionalIC));
|
||||
|
||||
if (XiNumberManager.stepNumber == 0 || XiNumberManager.stepNumber == 1) {
|
||||
Integer aXi = (int) ((2-(optionalA / devParameter.getDevVolt())) * 10000);
|
||||
Integer bXi = (int) ((2-(optionalB / devParameter.getDevVolt())) * 10000);
|
||||
Integer cXi = (int) ((2-(optionalC / devParameter.getDevVolt())) * 10000);
|
||||
Integer aIXi = (int) ((2-(optionalIA / devParameter.getDevCurr())) * 10000);
|
||||
Integer bIXi = (int) ((2-(optionalIB / devParameter.getDevCurr())) * 10000);
|
||||
Integer cIXi = (int) ((2-(optionalIC / devParameter.getDevCurr())) * 10000);
|
||||
Integer aXi = (int) ((2 - (optionalA / devParameter.getDevVolt())) * 10000);
|
||||
Integer bXi = (int) ((2 - (optionalB / devParameter.getDevVolt())) * 10000);
|
||||
Integer cXi = (int) ((2 - (optionalC / devParameter.getDevVolt())) * 10000);
|
||||
Integer aIXi = (int) ((2 - (optionalIA / devParameter.getDevCurr())) * 10000);
|
||||
Integer bIXi = (int) ((2 - (optionalIB / devParameter.getDevCurr())) * 10000);
|
||||
Integer cIXi = (int) ((2 - (optionalIC / devParameter.getDevCurr())) * 10000);
|
||||
|
||||
coefficientVO.setAVuXi(aXi.toString());
|
||||
coefficientVO.setBVuXi(bXi.toString());
|
||||
@@ -551,7 +551,6 @@ public class SocketDevResponseService {
|
||||
completeJudgment(param);
|
||||
|
||||
|
||||
|
||||
break;
|
||||
case UNPROCESSED_BUSINESS:
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||
@@ -592,14 +591,14 @@ public class SocketDevResponseService {
|
||||
}
|
||||
|
||||
|
||||
private void completeJudgment(PreDetectionParam param){
|
||||
if(successDevComm.size()+failDevComm.size() == FormalTestManager.devList.size() && successComm.size() + failComm.size() == FormalTestManager.monitorIdListComm.size()){
|
||||
private void completeJudgment(PreDetectionParam param) {
|
||||
if (successDevComm.size() + failDevComm.size() == FormalTestManager.devList.size() && successComm.size() + failComm.size() == FormalTestManager.monitorIdListComm.size()) {
|
||||
//全部装置返回
|
||||
if(!failDevComm.isEmpty()){
|
||||
if (!failDevComm.isEmpty()) {
|
||||
CnSocketUtil.quitSend(param);
|
||||
WebSocketVO<String> webSocketVO = new WebSocketVO<>();
|
||||
webSocketVO.setRequestId(SourceOperateCodeEnum.ERROR_FLOW_END.getValue());
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(),JSON.toJSONString(webSocketVO));
|
||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(webSocketVO));
|
||||
}
|
||||
successDevComm.clear();
|
||||
failDevComm.clear();
|
||||
@@ -648,7 +647,6 @@ public class SocketDevResponseService {
|
||||
completeJudgment(param);
|
||||
|
||||
|
||||
|
||||
} else if (socketDataMsg.getOperateCode().equals(SourceOperateCodeEnum.DEV_INIT_GATHER_03.getValue())) {
|
||||
successDevComm.add(socketDataMsg.getData().split(splitTag)[0]);
|
||||
successComm.add(socketDataMsg.getData());
|
||||
@@ -673,7 +671,7 @@ public class SocketDevResponseService {
|
||||
List<SourceIssue> sourceIssues;
|
||||
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())){
|
||||
if (param.getOperateType().equals(SourceOperateCodeEnum.RE_ERROR_TEST.getValue())) {
|
||||
//不合格项复检
|
||||
StorageParam storageParam = new StorageParam();
|
||||
storageParam.setCode(Integer.valueOf(param.getPlanCode()));
|
||||
@@ -681,7 +679,7 @@ public class SocketDevResponseService {
|
||||
List<Integer> indexes = adHarmonicService.getIndex(storageParam);
|
||||
issueParam.setIndexList(indexes);
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.COEFFICIENT_TEST.getValue());
|
||||
}else {
|
||||
} else {
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.FORMAL_TEST.getValue());
|
||||
}
|
||||
//正式检测
|
||||
@@ -694,7 +692,7 @@ public class SocketDevResponseService {
|
||||
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())) {
|
||||
} else if (SourceOperateCodeEnum.PRE_TEST.getValue().equals(param.getOperateType()) || SourceOperateCodeEnum.COEFFICIENT_TEST.getValue().equals(param.getOperateType())) {
|
||||
//预检测的相序检测 以及系数校验都需要进行相序检测
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.PHASE_TEST.getValue());
|
||||
sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||
@@ -873,15 +871,16 @@ public class SocketDevResponseService {
|
||||
|
||||
//FormalTestManager.devXiNumDataMap.put(devData.getId(),)
|
||||
|
||||
if(SocketManager.clockMap.containsKey(sourceIssue.getIndex())){
|
||||
SocketManager.clockMap.put(sourceIssue.getIndex(),0L);
|
||||
if (SocketManager.clockMap.containsKey(sourceIssue.getIndex())) {
|
||||
SocketManager.clockMap.put(sourceIssue.getIndex(), 0L);
|
||||
}
|
||||
|
||||
|
||||
if (successComm.size() == FormalTestManager.monitorIdListComm.size()) {
|
||||
//TODO 理论上遇到返回code10200的数量与监测点数量一致则认为数据返回结束,但是会存在缺失数据情况,例如有部分装置是没有暂降功能的
|
||||
System.out.println(sourceIssue.getType() + splitTag + sourceIssue.getIndex() + "当前测试小项读取数据已经全部结束。。。。。。。。。");
|
||||
|
||||
//修改装置为监测中
|
||||
iPqDevService.updateCheckState(param.getDevIds());
|
||||
//开启线程进行入库原始数据操作
|
||||
baseDataInsert(realDataXiList, sourceIssue, param, SocketManager.valueTypeMap);
|
||||
|
||||
@@ -940,9 +939,9 @@ public class SocketDevResponseService {
|
||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(xuMsg));
|
||||
} else {
|
||||
//TODO 是否最终检测完成需要推送给用户
|
||||
iPqDevService.updateResult(param.getDevIds(), param.getCode());
|
||||
CnSocketUtil.quitSend(param);
|
||||
}
|
||||
|
||||
successComm.clear();
|
||||
realDataXiList.clear();
|
||||
|
||||
@@ -977,7 +976,6 @@ public class SocketDevResponseService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 退出检测返回
|
||||
*/
|
||||
@@ -1157,7 +1155,7 @@ public class SocketDevResponseService {
|
||||
|
||||
List<PreDetection> pqDevList = iPqDevService.getDevInfo(param.getDevIds());
|
||||
FormalTestManager.devList = pqDevList;
|
||||
FormalTestManager.devMapMonitorNum = pqDevList.stream().collect(Collectors.toMap(PreDetection::getDevIP,it->it.getMonitorList().stream().map(PreDetection.MonitorListDTO::getLineId).collect(Collectors.toList())));
|
||||
FormalTestManager.devMapMonitorNum = pqDevList.stream().collect(Collectors.toMap(PreDetection::getDevIP, it -> it.getMonitorList().stream().map(PreDetection.MonitorListDTO::getLineId).collect(Collectors.toList())));
|
||||
FormalTestManager.monitorIdListComm = pqDevList.stream().flatMap(x -> x.getMonitorList().stream()).map(PreDetection.MonitorListDTO::getLineId).collect(Collectors.toList());
|
||||
|
||||
FormalTestManager.devNameMapComm = pqDevList.stream().collect(Collectors.toMap(PreDetection::getDevIP, PreDetection::getDevName));
|
||||
@@ -1175,7 +1173,7 @@ public class SocketDevResponseService {
|
||||
//字典树
|
||||
SocketManager.valueTypeMap = iPqScriptCheckDataService.getValueTypeMap(param.getScriptId());
|
||||
|
||||
if(param.getOperateType().equals(SourceOperateCodeEnum.COEFFICIENT_TEST.getValue())){
|
||||
if (param.getOperateType().equals(SourceOperateCodeEnum.COEFFICIENT_TEST.getValue())) {
|
||||
initXiManager(param);
|
||||
}
|
||||
}
|
||||
@@ -1204,7 +1202,7 @@ public class SocketDevResponseService {
|
||||
issueParam.setDevIds(param.getDevIds());
|
||||
issueParam.setScriptId(param.getScriptId());
|
||||
issueParam.setIsPhaseSequence(SourceOperateCodeEnum.COEFFICIENT_TEST.getValue());
|
||||
issueParam.setIndexList(Stream.of(-2,-3).collect(Collectors.toList()));
|
||||
issueParam.setIndexList(Stream.of(-2, -3).collect(Collectors.toList()));
|
||||
List<SourceIssue> sourceIssues = pqScriptDtlsService.listSourceIssue(issueParam);
|
||||
for (int j = 0; j < sourceIssues.size(); j++) {
|
||||
if (j == 0) {
|
||||
@@ -1290,7 +1288,7 @@ public class SocketDevResponseService {
|
||||
adHarmonicResult.setDataType("avg");
|
||||
|
||||
if (!DicDataEnum.HI.getCode().equals(sourceIssue.getType()) && !DicDataEnum.HSI.getCode().equals(sourceIssue.getType()) && !DicDataEnum.HP.getCode().equals(sourceIssue.getType())) {
|
||||
if(CollUtil.isNotEmpty(data.getSqlData())){
|
||||
if (CollUtil.isNotEmpty(data.getSqlData())) {
|
||||
DevData.SqlDataDTO.ListDTO vvv = data.getSqlData().get(0).getList();
|
||||
Double aV = vvv.getA();
|
||||
Double bV = vvv.getB();
|
||||
|
||||
@@ -286,11 +286,11 @@ public class SocketSourceResponseService {
|
||||
int readData;
|
||||
if(sourceIssue.getType().equals(DicDataEnum.F.getCode())){
|
||||
ignoreCount = 1;
|
||||
readData = 1;
|
||||
readData = 2;
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
|
||||
}else if(sourceIssue.getType().equals(DicDataEnum.HP.getCode())){
|
||||
ignoreCount = 2;
|
||||
readData = 3;
|
||||
readData = 5;
|
||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
|
||||
}else if(DicDataEnum.VOLTAGE.getCode().equals(sourceIssue.getType())){
|
||||
ignoreCount = 5;
|
||||
|
||||
@@ -39,6 +39,12 @@
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.83</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn.gather</groupId>
|
||||
<artifactId>storage</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@@ -171,4 +171,20 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* @return 归档成功返回true,否则返回false
|
||||
*/
|
||||
boolean documented(String id);
|
||||
|
||||
/**
|
||||
* 修改监测状态
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
boolean updateCheckState(List<String> ids);
|
||||
|
||||
|
||||
/**
|
||||
* 正式监测完成,修改中断状态
|
||||
* @param ids
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
boolean updateResult(List<String> ids,String code);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
@@ -24,6 +26,7 @@ import com.njcn.gather.device.monitor.pojo.po.PqMonitor;
|
||||
import com.njcn.gather.device.monitor.pojo.vo.PqMonitorExcel;
|
||||
import com.njcn.gather.device.monitor.service.IPqMonitorService;
|
||||
import com.njcn.gather.device.pojo.enums.*;
|
||||
import com.njcn.gather.storage.service.DetectionDataDealService;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
@@ -48,6 +51,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
|
||||
private final IDictDataService dictDataService;
|
||||
private final IPqMonitorService pqMonitorService;
|
||||
private final DetectionDataDealService detectionDataDealService;
|
||||
|
||||
|
||||
@Override
|
||||
public Page<PqDev> listPqDevs(PqDevParam.QueryParam queryParam) {
|
||||
@@ -414,7 +419,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
@Override
|
||||
public List<PreDetection> getDevInfo(List<String> devIds) {
|
||||
List<PreDetection> preDetections = this.baseMapper.selectDevInfo(devIds);
|
||||
if(devIds.size() != preDetections.size()){
|
||||
if (devIds.size() != preDetections.size()) {
|
||||
throw new BusinessException(DevResponseEnum.DEVICE_DIS_ERROR);
|
||||
}
|
||||
|
||||
@@ -451,6 +456,37 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateCheckState(List<String> ids) {
|
||||
if (CollUtil.isNotEmpty(ids)) {
|
||||
return this.update(new LambdaUpdateWrapper<PqDev>()
|
||||
.set(PqDev::getCheckState, CheckStateEnum.CHECKING.getValue())
|
||||
.in(PqDev::getId, ids));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateResult(List<String> ids,String code) {
|
||||
if(CollUtil.isNotEmpty(ids)){
|
||||
Map<String, Integer> result = detectionDataDealService.devResult(ids, code);
|
||||
List<PqDev> list = this.list(new LambdaQueryWrapper<PqDev>().in(PqDev::getId, ids));
|
||||
for (PqDev pqDev : list) {
|
||||
if(result.containsKey(pqDev.getId())){
|
||||
this.update(new LambdaUpdateWrapper<PqDev>()
|
||||
.set(PqDev::getReCheckNum, pqDev.getReCheckNum()+1)
|
||||
.set(PqDev::getCheckState, CheckStateEnum.CHECKED.getValue())
|
||||
.set(PqDev::getCheckResult, result.get(pqDev.getId()))
|
||||
.set(PqDev::getReportState, DevReportStateEnum.NOT_GENERATED.getValue())
|
||||
.eq(PqDev::getId, pqDev.getId()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取检测状态饼状图数据
|
||||
*
|
||||
|
||||
@@ -219,8 +219,8 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
queryWrapper.selectAll(PqScriptDtls.class)
|
||||
.selectAs(DictTree::getCode, PqScriptDtls::getScriptCode)
|
||||
.leftJoin(DictTree.class, DictTree::getId, PqScriptDtls::getScriptType)
|
||||
// .ge(PqScriptDtls::getIndex, 9)
|
||||
// .ge(PqScriptDtls::getIndex, 48)
|
||||
// .eq(PqScriptDtls::getIndex, 1)
|
||||
.le(PqScriptDtls::getIndex, 8)
|
||||
// .in(PqScriptDtls::getIndex, Arrays.asList(30,101,105))
|
||||
|
||||
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode());
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.njcn.gather.storage.pojo.po.AdHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface DetectionDataDealService extends IReplenishMybatisService<AdHarmonicResult> {
|
||||
|
||||
@@ -18,4 +19,12 @@ public interface DetectionDataDealService extends IReplenishMybatisService<AdHar
|
||||
Boolean acceptAdNonResult(List<AdNonHarmonicResult> adNonHarmonicResultList,String code);
|
||||
|
||||
Boolean acceptAdResult(List<AdHarmonicResult> adHarmonicResultList,String code);
|
||||
|
||||
/**
|
||||
* 根据终端id查询终端所有监测项目是否合格
|
||||
* @param ids
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
Map<String,Integer> devResult(List<String> ids,String code);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.njcn.gather.storage.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.njcn.db.mybatisplus.handler.DynamicTableNameHandler;
|
||||
import com.njcn.db.mybatisplus.service.impl.ReplenishMybatisServiceImpl;
|
||||
import com.njcn.gather.storage.mapper.DetectionDataDealMapper;
|
||||
@@ -13,7 +15,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -92,4 +94,57 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
|
||||
DynamicTableNameHandler.remove();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Integer> devResult(List<String> ids,String code) {
|
||||
List<AdNonHarmonicResult> noHarm=new ArrayList<>();
|
||||
for (String id : ids) {
|
||||
DynamicTableNameHandler.setTableName("ad_non_harmonic_result_" + code);
|
||||
noHarm.addAll(adNonHarmonicService.list( new LambdaQueryWrapper<AdNonHarmonicResult>()
|
||||
.like(AdNonHarmonicResult::getMonitorId,id)
|
||||
)) ;
|
||||
}
|
||||
DynamicTableNameHandler.remove();
|
||||
List<AdHarmonicResult> harm=new ArrayList<>();
|
||||
for (String id : ids) {
|
||||
DynamicTableNameHandler.setTableName("ad_harmonic_result_" + code);
|
||||
harm.addAll(this.list( new LambdaQueryWrapper<AdHarmonicResult>()
|
||||
.like(AdHarmonicResult::getMonitorId,id)
|
||||
)) ;
|
||||
}
|
||||
DynamicTableNameHandler.remove();
|
||||
Map<String, List<Integer>> noHarmMap = noHarm.stream().collect(Collectors.groupingBy(x -> x.getMonitorId().split("_")[0],
|
||||
Collectors.mapping(AdNonHarmonicResult::getResultFlag, Collectors.toList())));
|
||||
Map<String, List<Integer>> harmMap = harm.stream().collect(Collectors.groupingBy(x -> x.getMonitorId().split("_")[0],
|
||||
Collectors.mapping(AdHarmonicResult::getResultFlag, Collectors.toList())));
|
||||
Map<String, Integer> map=new HashMap<>(2);
|
||||
for (String id : ids) {
|
||||
List<Integer> resultFlags=new ArrayList<>();
|
||||
if(noHarmMap.containsKey(id)){
|
||||
resultFlags.addAll(noHarmMap.get(id));
|
||||
}
|
||||
if(harmMap.containsKey(id)){
|
||||
resultFlags.addAll(harmMap.get(id));
|
||||
}
|
||||
map.put(id,isResultFlag(resultFlags));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static Integer isResultFlag(List<Integer> resultFlags) {
|
||||
// 检测结果(0:不符合 1:符合 2:/[未检测无结果])
|
||||
resultFlags = resultFlags.stream().distinct().collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(resultFlags)) {
|
||||
if (resultFlags.size() > 1) {
|
||||
if (resultFlags.contains(4)) {
|
||||
return 2;
|
||||
} else if (resultFlags.contains(2)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return resultFlags.get(0);
|
||||
} else {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user