优化数据源问题,删除检测脚本中值类型,由绑定检测计划中数据源来,获取是实时数据还是分钟数据

This commit is contained in:
wr
2025-04-29 11:36:04 +08:00
parent 4b41e2edd1
commit 2bdaabac6e
20 changed files with 83 additions and 144 deletions

View File

@@ -20,6 +20,12 @@ public class PqScriptCheckDataParam {
@ApiModelProperty("相别,字典表")
private String phase;
/**
* pq_script_checkdata 里dataType 删除,由根据计划中的数据源,来进行配置脚本增加扩展性
*/
@ApiModelProperty("数据类型,来源于字典表,包括实时数据(3s)、分钟统计数据(1min/3min/5min/10min)等")
private String dataType;
@ApiModelProperty("检测指标类型(true:code(I$real) false展示id 默认false)")
private Boolean isValueTypeName=false;

View File

@@ -84,11 +84,6 @@ public class PqScriptDtlsParam {
*/
private String pid;
/**
* 数据类型,来源于字典表,包括实时数据(3s)、分钟统计数据(1min/3min/5min/10min)等
*/
private String dataType;
/**
* 相别,字典表
*/

View File

@@ -23,7 +23,7 @@ public class PqScriptIssueParam {
@ApiModelProperty("终端id集合")
private List<String> devIds;
@ApiModelProperty()
@ApiModelProperty("校验步骤")
private String isPhaseSequence;
@ApiModelProperty("源id")

View File

@@ -39,10 +39,6 @@ public class PqScriptCheckData implements Serializable {
@TableField(exist = false)
private String valueTypeCode;
/**
* 数据类型,来源于字典表,包括实时数据(3s)、分钟统计数据(1min/3min/5min/10min)等
*/
private String dataType;
/**
* 相别,字典表

View File

@@ -50,6 +50,9 @@ public class SourceIssue {
@JSONField(serialize = false)
private List<String> devValueTypeList;
@JSONField(serialize = false)
private String dataType;
@JSONField(serialize = false)
private String desc;

View File

@@ -3,7 +3,6 @@ package com.njcn.gather.script.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
import com.njcn.gather.script.pojo.vo.PqScriptCheckDataVO;
import java.util.List;
import java.util.Map;

View File

@@ -1,7 +1,6 @@
package com.njcn.gather.script.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.gather.detection.pojo.param.DevPhaseSequenceParam;
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
import com.njcn.gather.script.pojo.param.PqScriptDtlsParam;
import com.njcn.gather.script.pojo.param.PqScriptIssueParam;
@@ -9,11 +8,9 @@ import com.njcn.gather.script.pojo.param.ScriptParam;
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.pojo.vo.PqScriptCheckDataVO;
import com.njcn.gather.script.pojo.vo.PqScriptDtlDataVO;
import java.util.List;
import java.util.Map;
/**
* @author caozehui

View File

@@ -2,19 +2,17 @@ package com.njcn.gather.script.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
import com.njcn.gather.detection.pojo.enums.DetectionResponseEnum;
import com.njcn.gather.script.mapper.PqScriptCheckDataMapper;
import com.njcn.gather.script.pojo.param.PqScriptCheckDataParam;
import com.njcn.gather.script.pojo.po.PqScriptCheckData;
import com.njcn.gather.script.pojo.po.PqScriptDtls;
import com.njcn.gather.script.pojo.vo.PqScriptCheckDataVO;
import com.njcn.gather.script.service.IPqScriptCheckDataService;
import com.njcn.gather.system.dictionary.mapper.DictTreeMapper;
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
@@ -36,61 +34,68 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor
public class PqScriptCheckDataServiceImpl extends ServiceImpl<PqScriptCheckDataMapper, PqScriptCheckData> implements IPqScriptCheckDataService {
private final String REAL="real$";
private final String SYMBOL="$";
private final DictTreeMapper dictTreeMapper;
@Override
public List<String> getValueType(PqScriptCheckDataParam param) {
MPJLambdaWrapper<PqScriptCheckData> queryWrapper = new MPJLambdaWrapper<>();
queryWrapper.selectAll(PqScriptCheckData.class)
.leftJoin(DictTree.class, DictTree::getId, PqScriptCheckData::getValueType)
.eq(PqScriptCheckData::getScriptId, param.getScriptId())
.eq(ObjectUtil.isNotNull(param.getIndex()),PqScriptCheckData::getScriptIndex, param.getIndex())
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode());
if (param.getIsValueTypeName()) {
queryWrapper.selectAs(DictTree::getCode, PqScriptCheckData::getValueType);
}
List<PqScriptCheckData> pqScriptCheckData = this.getBaseMapper().selectJoinList(PqScriptCheckData.class, queryWrapper);
if(CollUtil.isNotEmpty(pqScriptCheckData)){
String dataType = param.getDataType();
if(StrUtil.isNotBlank(dataType)){
String[] split = dataType.split(",");
if (split.length > 1) {
dataType = split[0];
}
MPJLambdaWrapper<PqScriptCheckData> queryWrapper = new MPJLambdaWrapper<>();
queryWrapper.selectAll(PqScriptCheckData.class)
.leftJoin(DictTree.class, DictTree::getId, PqScriptCheckData::getValueType)
.eq(PqScriptCheckData::getScriptId, param.getScriptId())
.eq(ObjectUtil.isNotNull(param.getIndex()), PqScriptCheckData::getScriptIndex, param.getIndex())
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode());
if (param.getIsValueTypeName()) {
List<String> checkData = pqScriptCheckData.stream().map(x -> x.getDataType() + "$" + x.getValueType()).distinct().collect(Collectors.toList());
String U = REAL + DetectionCodeEnum.U1.getCode();
if(!checkData.contains(U)){
if(checkData.contains(REAL+DetectionCodeEnum.V2_50.getCode())){
checkData.add(U);
queryWrapper.selectAs(DictTree::getCode, PqScriptCheckData::getValueType);
}
List<PqScriptCheckData> pqScriptCheckData = this.getBaseMapper().selectJoinList(PqScriptCheckData.class, queryWrapper);
if (CollUtil.isNotEmpty(pqScriptCheckData)) {
if (param.getIsValueTypeName()) {
final String finalDataType = dataType;
List<String> checkData = pqScriptCheckData.stream().map(x -> finalDataType + SYMBOL + x.getValueType()).distinct().collect(Collectors.toList());
String U = finalDataType + SYMBOL+ DetectionCodeEnum.U1.getCode();
if (!checkData.contains(U)) {
if (checkData.contains(finalDataType + SYMBOL + DetectionCodeEnum.V2_50.getCode())) {
checkData.add(U);
}
}
}
String I = REAL + DetectionCodeEnum.I1.getCode();
if(!checkData.contains(I)){
if(checkData.contains(REAL+DetectionCodeEnum.I2_50.getCode())){
checkData.add(I);
String I = finalDataType + SYMBOL + DetectionCodeEnum.I1.getCode();
if (!checkData.contains(I)) {
if (checkData.contains(finalDataType + SYMBOL + DetectionCodeEnum.I2_50.getCode())) {
checkData.add(I);
}
}
return checkData.stream().distinct().collect(Collectors.toList());
} else {
return pqScriptCheckData.stream().map(PqScriptCheckData::getValueType).distinct().collect(Collectors.toList());
}
return checkData.stream().distinct().collect(Collectors.toList());
} else {
return pqScriptCheckData.stream().map(PqScriptCheckData::getValueType).distinct().collect(Collectors.toList());
}
}
return new ArrayList<>();
}
@Override
public Map<String,String> getValueTypeMap(String scriptId) {
public Map<String, String> getValueTypeMap(String scriptId) {
LambdaQueryWrapper<PqScriptCheckData> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(PqScriptCheckData::getValueType)
.eq(PqScriptCheckData::getScriptId, scriptId)
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode());
List<PqScriptCheckData> pqScriptCheckData = this.baseMapper.selectList(queryWrapper);
if(CollUtil.isEmpty(pqScriptCheckData)){
// throw new BusinessException(CommonResponseEnum.FAIL,"测试脚本项暂无配置");
if (CollUtil.isEmpty(pqScriptCheckData)) {
throw new BusinessException(DetectionResponseEnum.SCRIPT_CHECK_DATA_NOT_EXIST);
}
List<String> valueTypeList = pqScriptCheckData.stream().map(PqScriptCheckData::getValueType).distinct().collect(Collectors.toList());
LambdaQueryWrapper<DictTree> dictTreeLambdaQueryWrapper = new LambdaQueryWrapper<>();
dictTreeLambdaQueryWrapper.in(DictTree::getId,valueTypeList).eq(DictTree::getState,DataStateEnum.DELETED.getCode());
dictTreeLambdaQueryWrapper.in(DictTree::getId, valueTypeList).eq(DictTree::getState, DataStateEnum.DELETED.getCode());
List<DictTree> dictTreeList = dictTreeMapper.selectList(dictTreeLambdaQueryWrapper);
Map<String,String> map = dictTreeList.stream().collect(Collectors.toMap(DictTree::getCode,DictTree::getId));
Map<String, String> map = dictTreeList.stream().collect(Collectors.toMap(DictTree::getCode, DictTree::getId));
return map;
}
@@ -111,16 +116,16 @@ public class PqScriptCheckDataServiceImpl extends ServiceImpl<PqScriptCheckDataM
LambdaQueryWrapper<PqScriptCheckData> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper
.eq(PqScriptCheckData::getScriptId, param.getScriptId())
.eq(ObjectUtil.isNotNull(param.getIndex()),PqScriptCheckData::getScriptIndex, param.getIndex())
.eq(ObjectUtil.isNotNull(param.getIndex()), PqScriptCheckData::getScriptIndex, param.getIndex())
.eq(PqScriptCheckData::getValueType, param.getValueType())
.eq(PqScriptCheckData::getPhase, param.getPhase())
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode());
PqScriptCheckData data = this.getBaseMapper().selectOne(queryWrapper);
if(ObjectUtil.isNotNull(data)){
if (ObjectUtil.isNotNull(data)) {
return data.getValue();
}
return null;
return null;
}
@Override

View File

@@ -11,13 +11,12 @@ import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
import com.njcn.gather.detection.pojo.param.DevPhaseSequenceParam;
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
import com.njcn.gather.device.pojo.enums.CommonEnum;
import com.njcn.gather.device.pojo.po.PqDev;
import com.njcn.gather.device.service.IPqDevService;
import com.njcn.gather.icd.pojo.po.PqIcdPath;
import com.njcn.gather.icd.service.IPqIcdPathService;
import com.njcn.gather.plan.mapper.AdPlanMapper;
import com.njcn.gather.plan.pojo.po.AdPlan;
import com.njcn.gather.script.mapper.PqScriptCheckDataMapper;
import com.njcn.gather.script.mapper.PqScriptDtlsMapper;
import com.njcn.gather.script.mapper.PqScriptMapper;
@@ -29,7 +28,6 @@ import com.njcn.gather.script.pojo.po.PqScript;
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.pojo.vo.PqScriptCheckDataVO;
import com.njcn.gather.script.pojo.vo.PqScriptDtlDataVO;
import com.njcn.gather.script.service.IPqScriptCheckDataService;
import com.njcn.gather.script.service.IPqScriptDtlsService;
@@ -91,7 +89,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
private final PqScriptCheckDataMapper pqScriptCheckDataMapper;
private final IDevTypeService devTypeService;
private final IDictTreeService dictTreeService;
private final IPqIcdPathService pqIcdPathService;
private final AdPlanMapper adPlanMapper;
@Override
@Transactional
@@ -134,6 +132,13 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
@Override
public List<SourceIssue> listSourceIssue(PqScriptIssueParam param) {
String dataType;
if (StrUtil.isNotBlank(param.getPlanId())) {
AdPlan plan = adPlanMapper.selectById(param.getPlanId());
dataType = plan.getDatasourceId();
} else {
dataType = "real";
}
List<SourceIssue> sourceIssues = new ArrayList<>();
Set<Double> voltSet = new HashSet<>(1);
Set<Double> currSet = new HashSet<>(1);
@@ -200,6 +205,13 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
checkDataParam.setScriptId(freqDtls.getScriptId());
checkDataParam.setIndex(freqDtls.getScriptIndex());
checkDataParam.setIsValueTypeName(true);
if(DicDataEnum.F.getCode().equals(issue.getType())||DicDataEnum.VOLTAGE.getCode().equals(issue.getType())){
checkDataParam.setDataType("avg");
issue.setDataType("avg");
}else {
checkDataParam.setDataType(dataType);
issue.setDataType(dataType);
}
issue.setDevValueTypeList(pqScriptCheckDataService.getValueType(checkDataParam));
issue.setDesc(ScriptDtlsDesc.getStringBuffer(value, true, isValueType).toString());
issue.setScriptId(freqDtls.getScriptId());
@@ -283,7 +295,6 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
data.setScriptId(sourceIssue.getScriptId());
data.setScriptIndex(i);
data.setValueType(checkData.getValueType());
data.setDataType(checkData.getDataType());
data.setPhase(checkData.getPhase());
data.setValue(checkData.getValue());
data.setHarmNum(checkData.getHarmNum());
@@ -439,10 +450,8 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
checkData.setErrorFlag(channelListDTO.getErrorFlag());
checkData.setEnable(channelListDTO.getEnable());
checkData.setPhase("T");
checkData.setDataType(channelListDTO.getDataType());
if (CollUtil.isNotEmpty(checkArchive)) {
checkData.setValue(checkArchive.get(0).getValue());
checkData.setDataType(checkArchive.get(0).getDataType());
} else {
checkData.setValue(sourceIssue.getFFreq());
}
@@ -472,7 +481,6 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
checkData.setErrorFlag(channelListDTO.getErrorFlag());
checkData.setEnable(channelListDTO.getEnable());
checkData.setValue(listDTO.getFPhase());
checkData.setDataType(channelListDTO.getDataType());
checkData.setValueType(channelListDTO.getValueType());
checkData.setPid(channelListDTO.getPid());
setCheckValue(checkArchive, checkData, listDTO);
@@ -610,7 +618,6 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
private void setCheck(List<PqScriptDtlsParam.CheckData> info, PqScriptDtlsParam.CheckData checkData, PqScriptDtlsParam.CheckData channelListDTO, List<PqScriptCheckData> checkArchive, PqScriptDtlsParam.ChannelListDTO listDTO) {
checkData.setPhase(listDTO.getChannelType().substring(1, 2).toUpperCase());
checkData.setDataType(channelListDTO.getDataType());
checkData.setValueType(channelListDTO.getValueType());
checkData.setPid(channelListDTO.getPid());
setCheckValue(checkArchive, checkData, listDTO);
@@ -725,7 +732,6 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
checkData.setErrorFlag(channelListDTO.getErrorFlag());
checkData.setEnable(channelListDTO.getEnable());
checkData.setPhase("T");
checkData.setDataType(channelListDTO.getDataType());
checkData.setValueType(channelListDTO.getValueType());
checkData.setPid(channelListDTO.getPid());
List<PqScriptDtlsParam.ChannelListDTO> channelA = list.stream().filter(x -> x.getChannelType().contains("a")).collect(Collectors.toList());
@@ -739,7 +745,6 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
}
if (CollUtil.isNotEmpty(checkArchive)) {
checkData.setValue(checkArchive.get(0).getValue());
checkData.setDataType(checkArchive.get(0).getDataType());
}
info.add(checkData);
}
@@ -758,13 +763,11 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
checkData.setErrorFlag(channelListDTO.getErrorFlag());
checkData.setEnable(channelListDTO.getEnable());
checkData.setPhase(listDTO.getChannelType().substring(1, 2).toUpperCase());
checkData.setDataType(channelListDTO.getDataType());
checkData.setValueType(channelListDTO.getValueType());
checkData.setPid(channelListDTO.getPid());
List<PqScriptCheckData> collect = checkArchive.stream().filter(x -> x.getPhase().equals(listDTO.getChannelType().substring(1, 2).toUpperCase())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(collect)) {
checkData.setValue(collect.get(0).getValue());
checkData.setDataType(collect.get(0).getDataType());
} else {
if (flyDeltaV) {
checkData.setValue(0.0);
@@ -794,7 +797,6 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
checkData.setEnable(channelListDTO.getEnable());
checkData.setValue(inharmModel.getFAmp());
checkData.setHarmNum(inharmModel.getInharm());
checkData.setDataType(channelListDTO.getDataType());
checkData.setValueType(channelListDTO.getValueType());
checkData.setPid(channelListDTO.getPid());
setCheckValue(checkArchive, checkData, listDTO);
@@ -809,7 +811,6 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
List<PqScriptCheckData> collect = checkArchive.stream().filter(x -> x.getPhase().equals(listDTO.getChannelType().substring(1, 2).toUpperCase())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(collect)) {
checkData.setValue(collect.get(0).getValue());
checkData.setDataType(collect.get(0).getDataType());
}
checkData.setPhase(listDTO.getChannelType().substring(1, 2).toUpperCase());
}
@@ -831,7 +832,6 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
checkData.setValue(harmModel.getFAmp());
checkData.setPhase(listDTO.getChannelType().substring(1, 2).toUpperCase());
checkData.setHarmNum(harmModel.getHarm());
checkData.setDataType(channelListDTO.getDataType());
checkData.setValueType(channelListDTO.getValueType());
checkData.setPid(channelListDTO.getPid());
setCheckValue(checkArchive, checkData, listDTO);

View File

@@ -8,7 +8,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.gather.plan.pojo.param.AdPlanParam;
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
import com.njcn.gather.script.mapper.PqScriptMapper;
import com.njcn.gather.script.pojo.param.PqScriptParam;