增加正式监测流程,监测状态变更
This commit is contained in:
@@ -551,7 +551,6 @@ public class SocketDevResponseService {
|
|||||||
completeJudgment(param);
|
completeJudgment(param);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case UNPROCESSED_BUSINESS:
|
case UNPROCESSED_BUSINESS:
|
||||||
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
|
||||||
@@ -648,7 +647,6 @@ public class SocketDevResponseService {
|
|||||||
completeJudgment(param);
|
completeJudgment(param);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else if (socketDataMsg.getOperateCode().equals(SourceOperateCodeEnum.DEV_INIT_GATHER_03.getValue())) {
|
} else if (socketDataMsg.getOperateCode().equals(SourceOperateCodeEnum.DEV_INIT_GATHER_03.getValue())) {
|
||||||
successDevComm.add(socketDataMsg.getData().split(splitTag)[0]);
|
successDevComm.add(socketDataMsg.getData().split(splitTag)[0]);
|
||||||
successComm.add(socketDataMsg.getData());
|
successComm.add(socketDataMsg.getData());
|
||||||
@@ -881,7 +879,8 @@ public class SocketDevResponseService {
|
|||||||
if (successComm.size() == FormalTestManager.monitorIdListComm.size()) {
|
if (successComm.size() == FormalTestManager.monitorIdListComm.size()) {
|
||||||
//TODO 理论上遇到返回code10200的数量与监测点数量一致则认为数据返回结束,但是会存在缺失数据情况,例如有部分装置是没有暂降功能的
|
//TODO 理论上遇到返回code10200的数量与监测点数量一致则认为数据返回结束,但是会存在缺失数据情况,例如有部分装置是没有暂降功能的
|
||||||
System.out.println(sourceIssue.getType() + splitTag + sourceIssue.getIndex() + "当前测试小项读取数据已经全部结束。。。。。。。。。");
|
System.out.println(sourceIssue.getType() + splitTag + sourceIssue.getIndex() + "当前测试小项读取数据已经全部结束。。。。。。。。。");
|
||||||
|
//修改装置为监测中
|
||||||
|
iPqDevService.updateCheckState(param.getDevIds());
|
||||||
//开启线程进行入库原始数据操作
|
//开启线程进行入库原始数据操作
|
||||||
baseDataInsert(realDataXiList, sourceIssue, param, SocketManager.valueTypeMap);
|
baseDataInsert(realDataXiList, sourceIssue, param, SocketManager.valueTypeMap);
|
||||||
|
|
||||||
@@ -940,9 +939,9 @@ public class SocketDevResponseService {
|
|||||||
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(xuMsg));
|
SocketManager.sendMsg(param.getUserPageId() + handlerSourceStr, JSON.toJSONString(xuMsg));
|
||||||
} else {
|
} else {
|
||||||
//TODO 是否最终检测完成需要推送给用户
|
//TODO 是否最终检测完成需要推送给用户
|
||||||
|
iPqDevService.updateResult(param.getDevIds(), param.getCode());
|
||||||
CnSocketUtil.quitSend(param);
|
CnSocketUtil.quitSend(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
successComm.clear();
|
successComm.clear();
|
||||||
realDataXiList.clear();
|
realDataXiList.clear();
|
||||||
|
|
||||||
@@ -977,7 +976,6 @@ public class SocketDevResponseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退出检测返回
|
* 退出检测返回
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -286,11 +286,11 @@ public class SocketSourceResponseService {
|
|||||||
int readData;
|
int readData;
|
||||||
if(sourceIssue.getType().equals(DicDataEnum.F.getCode())){
|
if(sourceIssue.getType().equals(DicDataEnum.F.getCode())){
|
||||||
ignoreCount = 1;
|
ignoreCount = 1;
|
||||||
readData = 1;
|
readData = 2;
|
||||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
|
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
|
||||||
}else if(sourceIssue.getType().equals(DicDataEnum.HP.getCode())){
|
}else if(sourceIssue.getType().equals(DicDataEnum.HP.getCode())){
|
||||||
ignoreCount = 2;
|
ignoreCount = 2;
|
||||||
readData = 3;
|
readData = 5;
|
||||||
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
|
socketMsg.setOperateCode(SourceOperateCodeEnum.DEV_DATA_REQUEST_01.getValue());
|
||||||
}else if(DicDataEnum.VOLTAGE.getCode().equals(sourceIssue.getType())){
|
}else if(DicDataEnum.VOLTAGE.getCode().equals(sourceIssue.getType())){
|
||||||
ignoreCount = 5;
|
ignoreCount = 5;
|
||||||
|
|||||||
@@ -39,6 +39,12 @@
|
|||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>1.2.83</version>
|
<version>1.2.83</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.njcn.gather</groupId>
|
||||||
|
<artifactId>storage</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -171,4 +171,20 @@ public interface IPqDevService extends IService<PqDev> {
|
|||||||
* @return 归档成功返回true,否则返回false
|
* @return 归档成功返回true,否则返回false
|
||||||
*/
|
*/
|
||||||
boolean documented(String id);
|
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.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
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.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
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.pojo.vo.PqMonitorExcel;
|
||||||
import com.njcn.gather.device.monitor.service.IPqMonitorService;
|
import com.njcn.gather.device.monitor.service.IPqMonitorService;
|
||||||
import com.njcn.gather.device.pojo.enums.*;
|
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.pojo.po.DictData;
|
||||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||||
import com.njcn.web.factory.PageFactory;
|
import com.njcn.web.factory.PageFactory;
|
||||||
@@ -48,6 +51,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
|
|
||||||
private final IDictDataService dictDataService;
|
private final IDictDataService dictDataService;
|
||||||
private final IPqMonitorService pqMonitorService;
|
private final IPqMonitorService pqMonitorService;
|
||||||
|
private final DetectionDataDealService detectionDataDealService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<PqDev> listPqDevs(PqDevParam.QueryParam queryParam) {
|
public Page<PqDev> listPqDevs(PqDevParam.QueryParam queryParam) {
|
||||||
@@ -451,6 +456,37 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
return false;
|
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)
|
queryWrapper.selectAll(PqScriptDtls.class)
|
||||||
.selectAs(DictTree::getCode, PqScriptDtls::getScriptCode)
|
.selectAs(DictTree::getCode, PqScriptDtls::getScriptCode)
|
||||||
.leftJoin(DictTree.class, DictTree::getId, PqScriptDtls::getScriptType)
|
.leftJoin(DictTree.class, DictTree::getId, PqScriptDtls::getScriptType)
|
||||||
// .ge(PqScriptDtls::getIndex, 9)
|
// .eq(PqScriptDtls::getIndex, 1)
|
||||||
// .ge(PqScriptDtls::getIndex, 48)
|
.le(PqScriptDtls::getIndex, 8)
|
||||||
// .in(PqScriptDtls::getIndex, Arrays.asList(30,101,105))
|
// .in(PqScriptDtls::getIndex, Arrays.asList(30,101,105))
|
||||||
|
|
||||||
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode());
|
.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 com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public interface DetectionDataDealService extends IReplenishMybatisService<AdHarmonicResult> {
|
public interface DetectionDataDealService extends IReplenishMybatisService<AdHarmonicResult> {
|
||||||
|
|
||||||
@@ -18,4 +19,12 @@ public interface DetectionDataDealService extends IReplenishMybatisService<AdHar
|
|||||||
Boolean acceptAdNonResult(List<AdNonHarmonicResult> adNonHarmonicResultList,String code);
|
Boolean acceptAdNonResult(List<AdNonHarmonicResult> adNonHarmonicResultList,String code);
|
||||||
|
|
||||||
Boolean acceptAdResult(List<AdHarmonicResult> adHarmonicResultList,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;
|
package com.njcn.gather.storage.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
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.handler.DynamicTableNameHandler;
|
||||||
import com.njcn.db.mybatisplus.service.impl.ReplenishMybatisServiceImpl;
|
import com.njcn.db.mybatisplus.service.impl.ReplenishMybatisServiceImpl;
|
||||||
import com.njcn.gather.storage.mapper.DetectionDataDealMapper;
|
import com.njcn.gather.storage.mapper.DetectionDataDealMapper;
|
||||||
@@ -13,7 +15,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,4 +94,57 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
|
|||||||
DynamicTableNameHandler.remove();
|
DynamicTableNameHandler.remove();
|
||||||
return true;
|
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