1.源参数下发增加装置下发参数
2.调整数据返回信息
This commit is contained in:
@@ -15,7 +15,6 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.security.Key;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -42,11 +41,22 @@ public class DetectionServiceImpl {
|
||||
* 开始处理指标类型
|
||||
* 一共20组数据,开始处理格式
|
||||
*/
|
||||
public Map<String, Boolean> text(List<DevData> dev, SourceIssue issue, DictDataEnum dataRule) {
|
||||
public Map<String, Integer> text(List<DevData> dev, SourceIssue issue, DictDataEnum dataRule) {
|
||||
Map<String, List<DevData>> devDataMap = dev.stream().collect(Collectors.groupingBy(DevData::getId));
|
||||
Map<String, Boolean> stringBooleanMap=new LinkedHashMap<>();
|
||||
Map<String, Integer> stringBooleanMap = new LinkedHashMap<>();
|
||||
devDataMap.forEach(((key, value) -> {
|
||||
stringBooleanMap.put(key, DetectionIndexProcessing(value, dataRule, issue));
|
||||
Integer num;
|
||||
Boolean b = DetectionIndexProcessing(value, dataRule, issue);
|
||||
if (ObjectUtil.isNull(b)) {
|
||||
if (b) {
|
||||
num = 1;
|
||||
} else {
|
||||
num = 2;
|
||||
}
|
||||
} else {
|
||||
num = 4;
|
||||
}
|
||||
stringBooleanMap.put(key, num);
|
||||
}));
|
||||
return stringBooleanMap;
|
||||
}
|
||||
@@ -64,41 +74,44 @@ public class DetectionServiceImpl {
|
||||
public Boolean DetectionIndexProcessing(List<DevData> dev, DictDataEnum dataRule, SourceIssue sourceIssue) {
|
||||
PqErrSysParam.DetectionParam param = new PqErrSysParam.DetectionParam();
|
||||
List<PqErrSysDtls> pqErrSysDtls = pqErrSysDtlsService.listPqErrSysDtlsByPqErrSysIdAndTypes(param);
|
||||
//判断取值是否在误差范围内
|
||||
return isQualified(dev, pqErrSysDtls, U, sourceIssue, dataRule);
|
||||
//获得对应的误差体系
|
||||
// switch (errSysEnum) {
|
||||
// case VOL:
|
||||
// return isQualified(dev, pqErrSysDtls, U, sourceIssue, dataRule);
|
||||
// case Freq:
|
||||
// return isQualified(dev, pqErrSysDtls, I, sourceIssue, dataRule);
|
||||
// case MSQI_U:
|
||||
// break;
|
||||
// case MSQI_I:
|
||||
// break;
|
||||
// case Flicker:
|
||||
// break;
|
||||
// case Harm_V:
|
||||
// isHarmQualified(dev, pqErrSysDtls, U, sourceIssue, dataRule);
|
||||
// break;
|
||||
// case Harm_I:
|
||||
// isHarmQualified(dev, pqErrSysDtls, I, sourceIssue, dataRule);
|
||||
// break;
|
||||
// case Harm_P:
|
||||
// break;
|
||||
// case InHarm_V:
|
||||
// isHarmQualified(dev, pqErrSysDtls, U, sourceIssue, dataRule);
|
||||
// break;
|
||||
// case InHarm_I:
|
||||
// isHarmQualified(dev, pqErrSysDtls, I, sourceIssue, dataRule);
|
||||
// break;
|
||||
// case CUR:
|
||||
// return isQualified(dev, pqErrSysDtls, F, sourceIssue, dataRule);
|
||||
// case Dip:
|
||||
// break;
|
||||
//
|
||||
// }
|
||||
// return null;
|
||||
switch (sourceIssue.getType()) {
|
||||
/**
|
||||
* 频率
|
||||
*/
|
||||
case "FREQ":
|
||||
return isQualified(dev, pqErrSysDtls, F, sourceIssue, dataRule, "FREQ");
|
||||
/**
|
||||
* 电压
|
||||
*/
|
||||
case "V":
|
||||
return isQualified(dev, pqErrSysDtls, U, sourceIssue, dataRule, "VRMS");
|
||||
/**
|
||||
* 电流
|
||||
*/
|
||||
case "I":
|
||||
return isQualified(dev, pqErrSysDtls, I, sourceIssue, dataRule, "IRMS");
|
||||
/**
|
||||
* 谐波类
|
||||
*/
|
||||
case "H":
|
||||
return isHarmQualified(dev, pqErrSysDtls, U, sourceIssue, dataRule, 2);
|
||||
/**
|
||||
* 功率
|
||||
*/
|
||||
case "P":
|
||||
break;
|
||||
/**
|
||||
* 闪变
|
||||
*/
|
||||
case "F":
|
||||
|
||||
/**
|
||||
* 暂态
|
||||
*/
|
||||
case "VOLTAGE":
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,14 +120,15 @@ public class DetectionServiceImpl {
|
||||
* @param dev
|
||||
* @param dataRule
|
||||
*/
|
||||
public Map<String, List<Double>> devListMap(List<DevData> dev, DictDataEnum dataRule) {
|
||||
public Map<String, List<Double>> devListMap(List<DevData> dev, DictDataEnum dataRule, String code) {
|
||||
//设置
|
||||
Map<String, List<Double>> map = new HashMap<>(3);
|
||||
List<Double> a = new ArrayList<>();
|
||||
List<Double> b = new ArrayList<>();
|
||||
List<Double> c = new ArrayList<>();
|
||||
List<Double> t = new ArrayList<>();
|
||||
List<DevData.SqlDataDTO> sqlDataDTOS = dev.stream().flatMap(x -> x.getSqlData().stream()).collect(Collectors.toList());
|
||||
List<DevData.SqlDataDTO> sqlDataDTOS = dev.stream().flatMap(x -> x.getSqlData().stream().filter(j -> code.equals(j.getDesc())))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(sqlDataDTOS)) {
|
||||
List<DevData.SqlDataDTO.ListDTO> list = sqlDataDTOS.stream().map(DevData.SqlDataDTO::getList).collect(Collectors.toList());
|
||||
a = list.stream()
|
||||
@@ -177,8 +191,8 @@ public class DetectionServiceImpl {
|
||||
* @param dataRule 数据处理原则
|
||||
* @return
|
||||
*/
|
||||
public Boolean isQualified(List<DevData> dev, List<PqErrSysDtls> pqErrSysDtls, String type, SourceIssue sourceIssue, DictDataEnum dataRule) {
|
||||
Map<String, List<Double>> map = devListMap(dev, dataRule);
|
||||
public Boolean isQualified(List<DevData> dev, List<PqErrSysDtls> pqErrSysDtls, String type, SourceIssue sourceIssue, DictDataEnum dataRule, String code) {
|
||||
Map<String, List<Double>> map = devListMap(dev, dataRule, code);
|
||||
Double fData = 1.0;
|
||||
if (U.equals(type)) {
|
||||
fData = sourceIssue.getFUn();
|
||||
@@ -224,10 +238,11 @@ public class DetectionServiceImpl {
|
||||
* @param type (电压还是电流)
|
||||
* @param sourceIssue 源下发所对应的参数
|
||||
* @param dataRule 数据处理原则
|
||||
* @param num 处理数组下标位数
|
||||
* @return
|
||||
*/
|
||||
public Boolean isHarmQualified(List<DevData> dev, List<PqErrSysDtls> pqErrSysDtls, String type, SourceIssue sourceIssue, DictDataEnum dataRule) {
|
||||
Map<String, Map<Integer, List<Double>>> devMap = devHarmListMap(dev, sourceIssue, dataRule);
|
||||
public Boolean isHarmQualified(List<DevData> dev, List<PqErrSysDtls> pqErrSysDtls, String type, SourceIssue sourceIssue, DictDataEnum dataRule, Integer num) {
|
||||
Map<String, Map<Integer, List<Double>>> devMap = devHarmListMap(dev, sourceIssue, dataRule, num);
|
||||
Double fData = 1.0;
|
||||
if (U.equals(type)) {
|
||||
fData = sourceIssue.getFUn();
|
||||
@@ -256,6 +271,45 @@ public class DetectionServiceImpl {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断值是否在误差范围内,有则进行判断否则则不进行计算(闪变)
|
||||
*
|
||||
* @param dev 处理过后的数据
|
||||
* @param pqErrSysDtls 误差体系
|
||||
* @param type (电压还是电流)
|
||||
* @param sourceIssue 源下发所对应的参数
|
||||
* @param dataRule 数据处理原则
|
||||
* @return
|
||||
*/
|
||||
public Boolean isFlickerQualified(List<DevData> dev, List<PqErrSysDtls> pqErrSysDtls, String type, SourceIssue sourceIssue, DictDataEnum dataRule) {
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断值是否在误差范围内,有则进行判断否则则不进行计算(暂态)
|
||||
*
|
||||
* @param dev 处理过后的数据
|
||||
* @param pqErrSysDtls 误差体系
|
||||
* @param type (电压还是电流)
|
||||
* @param sourceIssue 源下发所对应的参数
|
||||
* @param dataRule 数据处理原则
|
||||
* @return
|
||||
*/
|
||||
public Boolean isVoltageQualified(List<DevData> dev, List<PqErrSysDtls> pqErrSysDtls, String type, SourceIssue sourceIssue, DictDataEnum dataRule) {
|
||||
//电压幅值处理数据
|
||||
Map<String, List<Double>> MAG = devListMap(dev, dataRule, "MAG");
|
||||
//暂降时间处理数据
|
||||
Map<String, List<Double>> DUR = devListMap(dev, dataRule, "DUR");
|
||||
//理论上根据检测脚本,能知道误差体系,可以知道多个误差体系
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param pqErrSysDtls 误差体系
|
||||
* @param type U,I
|
||||
@@ -326,22 +380,22 @@ public class DetectionServiceImpl {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map<String, Map<Integer, List<Double>>> devHarmListMap(List<DevData> dev, SourceIssue sourceIssue, DictDataEnum dataRule) {
|
||||
public Map<String, Map<Integer, List<Double>>> devHarmListMap(List<DevData> dev, SourceIssue sourceIssue, DictDataEnum dataRule, Integer num) {
|
||||
List<Integer> harmNum = sourceIssue.getChannelList().stream()
|
||||
.flatMap(x -> x.getHarmList().stream().map(f -> f.getHarm()))
|
||||
.sorted().distinct().collect(Collectors.toList());
|
||||
Map<String, Map<Integer, List<Double>>> map = new HashMap<>(3);
|
||||
for (DevData devData : dev) {
|
||||
DevData.SqlDataHarmDTO fund = devData.getSqlDataHarm().stream().filter(x -> 1 == x.getNum()).collect(Collectors.toList()).stream().findFirst().get();
|
||||
DevData.SqlDataDTO fund = devData.getSqlData().stream().collect(Collectors.toList()).stream().findFirst().get();
|
||||
DevData.SqlDataHarmDTO harm = devData.getSqlDataHarm().stream().filter(x -> 49 == x.getNum()).collect(Collectors.toList()).stream().findFirst().get();
|
||||
if (ObjectUtil.isNotNull(fund)) {
|
||||
harmPut(TYPE_A, map, harmNum, harm, fund.getList().getA().get(0));
|
||||
harmPut(TYPE_B, map, harmNum, harm, fund.getList().getA().get(0));
|
||||
harmPut(TYPE_C, map, harmNum, harm, fund.getList().getA().get(0));
|
||||
harmPut(TYPE_A, map, harmNum, harm, String.valueOf(fund.getList().getA()), num);
|
||||
harmPut(TYPE_B, map, harmNum, harm, String.valueOf(fund.getList().getA()), num);
|
||||
harmPut(TYPE_C, map, harmNum, harm, String.valueOf(fund.getList().getA()), num);
|
||||
} else {
|
||||
harmPut(TYPE_A, map, harmNum, harm, "1.0");
|
||||
harmPut(TYPE_B, map, harmNum, harm, "1.0");
|
||||
harmPut(TYPE_C, map, harmNum, harm, "1.0");
|
||||
harmPut(TYPE_A, map, harmNum, harm, "1.0", num);
|
||||
harmPut(TYPE_B, map, harmNum, harm, "1.0", num);
|
||||
harmPut(TYPE_C, map, harmNum, harm, "1.0", num);
|
||||
}
|
||||
}
|
||||
map.forEach((typeKey, typeValue) -> {
|
||||
@@ -407,6 +461,7 @@ public class DetectionServiceImpl {
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -502,19 +557,19 @@ public class DetectionServiceImpl {
|
||||
* @param harm 基波信息
|
||||
* @param fund 2-50次谐波信息
|
||||
*/
|
||||
public void harmPut(String type, Map<String, Map<Integer, List<Double>>> map, List<Integer> harmNum, DevData.SqlDataHarmDTO harm, String fund) {
|
||||
public void harmPut(String type, Map<String, Map<Integer, List<Double>>> map, List<Integer> harmNum, DevData.SqlDataHarmDTO harm, String fund, Integer num) {
|
||||
if (map.containsKey(type)) {
|
||||
Map<Integer, List<Double>> integerListMap = map.get(type);
|
||||
for (Integer i : harmNum) {
|
||||
if (integerListMap.containsKey(i)) {
|
||||
if (type.equals("A")) {
|
||||
integerListMap.get(i).add(multiply(harm.getList().getA().get(i - 2), fund));
|
||||
integerListMap.get(i).add(multiply(harm.getList().getA().get(i - num), fund));
|
||||
}
|
||||
if (type.equals("B")) {
|
||||
integerListMap.get(i).add(multiply(harm.getList().getB().get(i - 2), fund));
|
||||
integerListMap.get(i).add(multiply(harm.getList().getB().get(i - num), fund));
|
||||
}
|
||||
if (type.equals("C")) {
|
||||
integerListMap.get(i).add(multiply(harm.getList().getC().get(i - 2), fund));
|
||||
integerListMap.get(i).add(multiply(harm.getList().getC().get(i - num), fund));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -523,13 +578,13 @@ public class DetectionServiceImpl {
|
||||
for (Integer i : harmNum) {
|
||||
List<Double> integerList = new ArrayList<>();
|
||||
if (type.equals("A")) {
|
||||
integerList.add(multiply(harm.getList().getA().get(i - 2), fund));
|
||||
integerList.add(multiply(harm.getList().getA().get(i - num), fund));
|
||||
}
|
||||
if (type.equals("B")) {
|
||||
integerList.add(multiply(harm.getList().getB().get(i - 2), fund));
|
||||
integerList.add(multiply(harm.getList().getB().get(i - num), fund));
|
||||
}
|
||||
if (type.equals("C")) {
|
||||
integerList.add(multiply(harm.getList().getC().get(i - 2), fund));
|
||||
integerList.add(multiply(harm.getList().getC().get(i - num), fund));
|
||||
}
|
||||
integerListMap.put(i, integerList);
|
||||
}
|
||||
|
||||
@@ -71,8 +71,11 @@ public class PqErrSysParam {
|
||||
@ApiModelProperty("所属误差体系ID")
|
||||
private String errorSysId;
|
||||
|
||||
@ApiModelProperty("检测脚本类型")
|
||||
private List<String> type;
|
||||
@ApiModelProperty("总检测脚本中的测试项序号")
|
||||
private Integer index;
|
||||
|
||||
@ApiModelProperty("所属检测脚本")
|
||||
private String scriptId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.njcn.gather.device.err.pojo.param.PqErrSysDtlsParam;
|
||||
import com.njcn.gather.device.err.pojo.param.PqErrSysParam;
|
||||
import com.njcn.gather.device.err.pojo.po.PqErrSysDtls;
|
||||
import com.njcn.gather.device.err.service.IPqErrSysDtlsService;
|
||||
import com.njcn.gather.device.script.service.IPqScriptCheckDataService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -27,6 +28,9 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqErrSysDtls> implements IPqErrSysDtlsService {
|
||||
|
||||
private final IPqScriptCheckDataService pqScriptCheckDataService;
|
||||
|
||||
|
||||
@Override
|
||||
public List<PqErrSysDtls> listPqErrSysDtlsByPqErrSysId(String pqErrSysId) {
|
||||
return this.lambdaQuery().eq(PqErrSysDtls::getErrorSysId, pqErrSysId).orderBy(true, true,PqErrSysDtls::getSort).list();
|
||||
@@ -65,9 +69,13 @@ public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqE
|
||||
|
||||
@Override
|
||||
public List<PqErrSysDtls> listPqErrSysDtlsByPqErrSysIdAndTypes(PqErrSysParam.DetectionParam param) {
|
||||
return this.list(new LambdaQueryWrapper<PqErrSysDtls>()
|
||||
.eq(PqErrSysDtls::getErrorSysId, param.getErrorSysId())
|
||||
.in(PqErrSysDtls::getErrorSysId, param.getType())
|
||||
);
|
||||
//根据检测脚本id和检测序号,查询出检测子项目
|
||||
|
||||
|
||||
// return this.list(new LambdaQueryWrapper<PqErrSysDtls>()
|
||||
// .eq(PqErrSysDtls::getErrorSysId, param.getErrorSysId())
|
||||
// .in(PqErrSysDtls::getErrorSysId, param.getType())
|
||||
// );
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.njcn.gather.device.script.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScriptCheckData;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: wr
|
||||
* @Date: 2024/12/27 9:29
|
||||
*/
|
||||
public interface PqScriptCheckDataMapper extends MPJBaseMapper<PqScriptCheckData> {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.gather.device.script.mapper.PqScriptCheckDataMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.gather.device.script.pojo.param;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class PqScriptCheckDataParam {
|
||||
|
||||
|
||||
@ApiModelProperty("检测脚本ID")
|
||||
private String scriptId;
|
||||
|
||||
@ApiModelProperty("总检测脚本中的测试项序号")
|
||||
private Integer index;
|
||||
|
||||
@ApiModelProperty("检测指标类型(true:展示名称 ,false展示id ,默认false)")
|
||||
private Boolean isValueTypeName=false;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.njcn.gather.device.script.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@TableName(value = "pq_script_checkdata")
|
||||
public class PqScriptCheckData implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 检测脚本参考设定值ID
|
||||
*/
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 检测脚本ID
|
||||
*/
|
||||
private String scriptId;
|
||||
|
||||
/**
|
||||
* 总检测脚本中的测试项序号
|
||||
*/
|
||||
private Integer index;
|
||||
|
||||
/**
|
||||
* 检测指标类型,与数据字典关联(例如电压有效值、谐波电压含有率等)
|
||||
*/
|
||||
private String valueType;
|
||||
|
||||
/**
|
||||
* 数据类型,来源于字典表,包括实时数据(3s)、分钟统计数据(1min/3min/5min/10min)等
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 相别,字典表
|
||||
*/
|
||||
private String phase;
|
||||
|
||||
/**
|
||||
* 值
|
||||
*/
|
||||
private Double value;
|
||||
|
||||
/**
|
||||
* (间)谐波次数
|
||||
*/
|
||||
@TableField("HarmNum")
|
||||
private Double harmNum;
|
||||
|
||||
/**
|
||||
* 状态:0-不启用 1-启用
|
||||
*/
|
||||
private Integer enable;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -24,6 +24,9 @@ public class SourceIssue {
|
||||
@JSONField(serialize = false)
|
||||
private Integer index;
|
||||
|
||||
@JSONField(serialize = false)
|
||||
private List<String> devValueTypeList;
|
||||
|
||||
/**
|
||||
* 检测类型
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.njcn.gather.device.script.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class PqScriptCheckDataVO implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 总检测脚本中的测试项序号
|
||||
*/
|
||||
private String valueTypeId;
|
||||
|
||||
/**
|
||||
* 检测指标类型,与数据字典关联(例如电压有效值、谐波电压含有率等)
|
||||
*/
|
||||
private String valueTypeCode;
|
||||
|
||||
/**
|
||||
* 数据类型,来源于字典表,包括实时数据(3s)、分钟统计数据(1min/3min/5min/10min)等
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.njcn.gather.device.script.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.script.pojo.param.PqScriptCheckDataParam;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScriptCheckData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: wr
|
||||
* @Date: 2024/12/27 9:29
|
||||
*/
|
||||
public interface IPqScriptCheckDataService extends IService<PqScriptCheckData> {
|
||||
|
||||
|
||||
/**
|
||||
* 获取检测指标类型
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
List<String> getValueType(PqScriptCheckDataParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.njcn.gather.device.script.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
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.gather.device.script.mapper.PqScriptCheckDataMapper;
|
||||
import com.njcn.gather.device.script.pojo.param.PqScriptCheckDataParam;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScriptCheckData;
|
||||
import com.njcn.gather.device.script.service.IPqScriptCheckDataService;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: wr
|
||||
* @Date: 2024/12/27 9:29
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PqScriptCheckDataServiceImpl extends ServiceImpl<PqScriptCheckDataMapper, PqScriptCheckData> implements IPqScriptCheckDataService {
|
||||
|
||||
|
||||
@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(PqScriptCheckData::getIndex, 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)){
|
||||
if (param.getIsValueTypeName()) {
|
||||
return pqScriptCheckData.stream().map(x -> x.getDataType() + "$" + x.getValueType()).collect(Collectors.toList());
|
||||
} else {
|
||||
return pqScriptCheckData.stream().map(PqScriptCheckData::getValueType).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.njcn.gather.device.script.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
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;
|
||||
@@ -10,10 +11,12 @@ import com.njcn.gather.device.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.script.mapper.PqScriptDtlsMapper;
|
||||
import com.njcn.gather.device.script.mapper.PqScriptMapper;
|
||||
import com.njcn.gather.device.script.pojo.param.PqScriptCheckDataParam;
|
||||
import com.njcn.gather.device.script.pojo.param.PqScriptIssueParam;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScript;
|
||||
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.IPqScriptCheckDataService;
|
||||
import com.njcn.gather.device.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -61,6 +64,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
|
||||
private final IPqDevService pqDevService;
|
||||
private final PqScriptMapper pqScriptMapper;
|
||||
private final IPqScriptCheckDataService pqScriptCheckDataService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@@ -141,7 +145,13 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
issue.setSourceId(param.getSourceId());
|
||||
issue.setType(freqDtls.getScriptType());
|
||||
issue.setIndex(freqDtls.getIndex());
|
||||
issue.setSubType(freqDtls.getScriptSubType().replace("Base", "NULL"));
|
||||
String scriptSubType = freqDtls.getScriptSubType();
|
||||
issue.setSubType(StrUtil.isBlank(scriptSubType)?scriptSubType:scriptSubType.replace("Base", "NULL"));
|
||||
PqScriptCheckDataParam checkDataParam = new PqScriptCheckDataParam();
|
||||
checkDataParam.setScriptId(freqDtls.getScriptId());
|
||||
checkDataParam.setIndex(freqDtls.getIndex());
|
||||
checkDataParam.setIsValueTypeName(true);
|
||||
issue.setDevValueTypeList(pqScriptCheckDataService.getValueType(checkDataParam));
|
||||
issue.setFUn(volt);
|
||||
issue.setFIn(curr);
|
||||
issue.setFFreq(freqDtls.getValue());
|
||||
@@ -204,10 +214,10 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
||||
if (isValueType) {
|
||||
for (PqScriptDtls pqScriptDtl : pqScriptDtls) {
|
||||
if (VOL.equals(pqScriptDtl.getValueType())) {
|
||||
pqScriptDtl.setValue(pqScriptDtl.getChagValue() * volt);
|
||||
pqScriptDtl.setValue(pqScriptDtl.getValue() * volt);
|
||||
}
|
||||
if (CUR.equals(pqScriptDtl.getValueType())) {
|
||||
pqScriptDtl.setValue(pqScriptDtl.getChagValue() * curr);
|
||||
pqScriptDtl.setValue(pqScriptDtl.getValue() * curr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
24
device/src/main/resources/mapper/PqScriptCheckdataMapper.xml
Normal file
24
device/src/main/resources/mapper/PqScriptCheckdataMapper.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="generator.mapper.PqScriptCheckdataMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.njcn.gather.device.script.pojo.po.PqScriptCheckData">
|
||||
<id property="id" column="Id" jdbcType="CHAR"/>
|
||||
<result property="scriptId" column="Script_Id" jdbcType="CHAR"/>
|
||||
<result property="index" column="Index" jdbcType="INTEGER"/>
|
||||
<result property="valueType" column="Value_Type" jdbcType="CHAR"/>
|
||||
<result property="dataType" column="Data_Type" jdbcType="CHAR"/>
|
||||
<result property="phase" column="Phase" jdbcType="CHAR"/>
|
||||
<result property="value" column="Value" jdbcType="FLOAT"/>
|
||||
<result property="harmnum" column="HarmNum" jdbcType="FLOAT"/>
|
||||
<result property="enable" column="Enable" jdbcType="TINYINT"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
Id,Script_Id,Index,
|
||||
Value_Type,Data_Type,Phase,
|
||||
Value,HarmNum,Enable
|
||||
</sql>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user