正式检测解决部分误差体系计算问题
This commit is contained in:
@@ -1271,6 +1271,7 @@ public class SocketDevResponseService {
|
|||||||
adHarmonicResult.setDataType("avg");
|
adHarmonicResult.setDataType("avg");
|
||||||
|
|
||||||
if (!DicDataEnum.HI.getCode().equals(sourceIssue.getType()) && !DicDataEnum.HSI.getCode().equals(sourceIssue.getType()) && !DicDataEnum.HP.getCode().equals(sourceIssue.getType())) {
|
if (!DicDataEnum.HI.getCode().equals(sourceIssue.getType()) && !DicDataEnum.HSI.getCode().equals(sourceIssue.getType()) && !DicDataEnum.HP.getCode().equals(sourceIssue.getType())) {
|
||||||
|
if(CollUtil.isNotEmpty(data.getSqlData())){
|
||||||
DevData.SqlDataDTO.ListDTO vvv = data.getSqlData().get(0).getList();
|
DevData.SqlDataDTO.ListDTO vvv = data.getSqlData().get(0).getList();
|
||||||
Double aV = vvv.getA();
|
Double aV = vvv.getA();
|
||||||
Double bV = vvv.getB();
|
Double bV = vvv.getB();
|
||||||
@@ -1286,6 +1287,8 @@ public class SocketDevResponseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
DevData.SqlDataHarmDTO.ListDTO tem = sqlDataDTO.getList();
|
DevData.SqlDataHarmDTO.ListDTO tem = sqlDataDTO.getList();
|
||||||
List<String> a = tem.getA();
|
List<String> a = tem.getA();
|
||||||
List<String> b = tem.getB();
|
List<String> b = tem.getB();
|
||||||
|
|||||||
@@ -270,6 +270,10 @@ public class DetectionServiceImpl {
|
|||||||
if (I.equals(type)) {
|
if (I.equals(type)) {
|
||||||
fData = sourceIssue.getFIn();
|
fData = sourceIssue.getFIn();
|
||||||
}
|
}
|
||||||
|
if (P.equals(type)) {
|
||||||
|
fData = sourceIssue.getFIn() * sourceIssue.getFUn()*0.01;
|
||||||
|
}
|
||||||
|
|
||||||
List<DetectionData> integerBooleanA = harmRangeComparison(pqErrSysDtls, type, TYPE_A, sourceIssue, dataRule, devMap.get(TYPE_A), fData, num);
|
List<DetectionData> integerBooleanA = harmRangeComparison(pqErrSysDtls, type, TYPE_A, sourceIssue, dataRule, devMap.get(TYPE_A), fData, num);
|
||||||
List<DetectionData> integerBooleanB = harmRangeComparison(pqErrSysDtls, type, TYPE_B, sourceIssue, dataRule, devMap.get(TYPE_B), fData, num);
|
List<DetectionData> integerBooleanB = harmRangeComparison(pqErrSysDtls, type, TYPE_B, sourceIssue, dataRule, devMap.get(TYPE_B), fData, num);
|
||||||
List<DetectionData> integerBooleanC = harmRangeComparison(pqErrSysDtls, type, TYPE_C, sourceIssue, dataRule, devMap.get(TYPE_C), fData, num);
|
List<DetectionData> integerBooleanC = harmRangeComparison(pqErrSysDtls, type, TYPE_C, sourceIssue, dataRule, devMap.get(TYPE_C), fData, num);
|
||||||
@@ -389,6 +393,7 @@ public class DetectionServiceImpl {
|
|||||||
//暂降时间处理数据
|
//暂降时间处理数据
|
||||||
Map<String, List<Double>> dur = devListMap(dev, dataRule, DUR);
|
Map<String, List<Double>> dur = devListMap(dev, dataRule, DUR);
|
||||||
//理论上根据检测脚本,能知道误差体系,可以知道多个误差体系
|
//理论上根据检测脚本,能知道误差体系,可以知道多个误差体系
|
||||||
|
//暂态电压下多少就是多少
|
||||||
List<PqErrSysDtls> magErrList = pqErrSysDtls.stream().filter(x -> MAG.equals(x.getScriptCode())).collect(Collectors.toList());
|
List<PqErrSysDtls> magErrList = pqErrSysDtls.stream().filter(x -> MAG.equals(x.getScriptCode())).collect(Collectors.toList());
|
||||||
List<PqErrSysDtls> durErrList = pqErrSysDtls.stream().filter(x -> DUR.equals(x.getScriptCode())).collect(Collectors.toList());
|
List<PqErrSysDtls> durErrList = pqErrSysDtls.stream().filter(x -> DUR.equals(x.getScriptCode())).collect(Collectors.toList());
|
||||||
|
|
||||||
@@ -604,27 +609,32 @@ public class DetectionServiceImpl {
|
|||||||
.eq(PqScriptCheckData::getPhase, phase)
|
.eq(PqScriptCheckData::getPhase, phase)
|
||||||
.eq(PqScriptCheckData::getScriptId, sourceIssue.getScriptId())
|
.eq(PqScriptCheckData::getScriptId, sourceIssue.getScriptId())
|
||||||
);
|
);
|
||||||
issueHarmMap = checkData.stream().collect(Collectors.toMap(PqScriptCheckData::getHarmNum, PqScriptCheckData::getValue));
|
issueHarmMap = checkData.stream().collect(Collectors.toMap(PqScriptCheckData::getHarmNum, x -> x.getValue() * fData));
|
||||||
} else {
|
} else {
|
||||||
|
Double percent;
|
||||||
|
if (I.equals(type)) {
|
||||||
|
percent = fData * 0.01;
|
||||||
|
} else {
|
||||||
|
percent = 1.0;
|
||||||
|
}
|
||||||
if (1 == num) {
|
if (1 == num) {
|
||||||
issueHarmMap = sourceIssue.getChannelList().stream()
|
issueHarmMap = sourceIssue.getChannelList().stream()
|
||||||
.filter(x -> (type + phase.toLowerCase()).equals(x.getChannelType()))
|
.filter(x -> (type + phase.toLowerCase()).equals(x.getChannelType()))
|
||||||
.flatMap(x -> x.getInharmList().stream())
|
.flatMap(x -> x.getInharmList().stream())
|
||||||
.collect(Collectors.toMap(SourceIssue.ChannelListDTO.InharmModel::getInharm, x -> x.getFApm()));
|
.collect(Collectors.toMap(SourceIssue.ChannelListDTO.InharmModel::getInharm, x -> x.getFAmp() * percent));
|
||||||
} else {
|
} else {
|
||||||
issueHarmMap = sourceIssue.getChannelList().stream()
|
issueHarmMap = sourceIssue.getChannelList().stream()
|
||||||
.filter(x -> (type + phase.toLowerCase()).equals(x.getChannelType()))
|
.filter(x -> (type + phase.toLowerCase()).equals(x.getChannelType()))
|
||||||
.flatMap(x -> x.getHarmList().stream())
|
.flatMap(x -> x.getHarmList().stream())
|
||||||
.collect(Collectors.toMap(SourceIssue.ChannelListDTO.HarmModel::getHarm, x -> x.getFApm()));
|
.collect(Collectors.toMap(SourceIssue.ChannelListDTO.HarmModel::getHarm, x -> x.getFAmp() * percent));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Map<Double, PqErrSysDtls> errSysDtlMap = new LinkedHashMap<>();
|
Map<Double, PqErrSysDtls> errSysDtlMap = new LinkedHashMap<>();
|
||||||
issueHarmMap.forEach((key, value) -> {
|
issueHarmMap.forEach((key, value) -> {
|
||||||
//获得误差体系
|
//获得误差体系
|
||||||
List<PqErrSysDtls> errSysDtls = pqErrSysDtls.stream().filter(x -> rangeComparison(multiply(x.getStartValue(), fData, x.getConditionType()),
|
List<PqErrSysDtls> errSysDtls = pqErrSysDtls.stream().filter(x -> rangeComparison(startRadiusEnd(x.getStartValue(), fData, value, x.getConditionType()),
|
||||||
x.getStartFlag(),
|
x.getStartFlag(),
|
||||||
multiply(x.getEndValue(), fData, x.getConditionType()),
|
startRadiusEnd(x.getEndValue(), fData, value, x.getConditionType()),
|
||||||
x.getEndFlag(),
|
x.getEndFlag(),
|
||||||
value)).collect(Collectors.toList());
|
value)).collect(Collectors.toList());
|
||||||
if (CollUtil.isNotEmpty(errSysDtls)) {
|
if (CollUtil.isNotEmpty(errSysDtls)) {
|
||||||
@@ -642,11 +652,10 @@ public class DetectionServiceImpl {
|
|||||||
|
|
||||||
if (ObjectUtil.isNotNull(errSysDtl)) {
|
if (ObjectUtil.isNotNull(errSysDtl)) {
|
||||||
PqErrSysDtls errSys = BeanUtil.copyProperties(errSysDtl, PqErrSysDtls.class);
|
PqErrSysDtls errSys = BeanUtil.copyProperties(errSysDtl, PqErrSysDtls.class);
|
||||||
if (0 == errSys.getErrorValueType()) {
|
errSys.setMaxErrorValue(maxErrorMultiply(errSys.getMaxErrorValue(), fData, issueHarmMap.get(harm), errSys.getErrorValueType()));
|
||||||
errSys.setMaxErrorValue(multiply(errSys.getMaxErrorValue(), fData, 0));
|
|
||||||
}
|
|
||||||
Double v = issueHarmMap.get(harm);
|
Double v = issueHarmMap.get(harm);
|
||||||
data.setResultData(v);
|
data.setResultData(v);
|
||||||
|
data.setRadius(-errSysDtl.getMaxErrorValue() + "~" + errSysDtl.getMaxErrorValue());
|
||||||
setDetection(dataRule, harmDataList, errSys, data, v);
|
setDetection(dataRule, harmDataList, errSys, data, v);
|
||||||
}
|
}
|
||||||
info.add(data);
|
info.add(data);
|
||||||
@@ -770,9 +779,9 @@ public class DetectionServiceImpl {
|
|||||||
detectionData.setIsData(4);
|
detectionData.setIsData(4);
|
||||||
//先根据源所下发的数据,是否在误差体系范围内在则可以进行误差体系判断
|
//先根据源所下发的数据,是否在误差体系范围内在则可以进行误差体系判断
|
||||||
//获得误差体系
|
//获得误差体系
|
||||||
List<PqErrSysDtls> errSysDtls = pqErrSysDtls.stream().filter(x -> rangeComparison(multiply(x.getStartValue(), data, x.getConditionType()),
|
List<PqErrSysDtls> errSysDtls = pqErrSysDtls.stream().filter(x -> rangeComparison(startRadiusEnd(x.getStartValue(), data, channelData, x.getConditionType()),
|
||||||
x.getStartFlag(),
|
x.getStartFlag(),
|
||||||
multiply(x.getEndValue(), data, x.getConditionType()),
|
startRadiusEnd(x.getEndValue(), data, channelData, x.getConditionType()),
|
||||||
x.getEndFlag(),
|
x.getEndFlag(),
|
||||||
channelData)).collect(Collectors.toList());
|
channelData)).collect(Collectors.toList());
|
||||||
if (CollUtil.isNotEmpty(errSysDtls)) {
|
if (CollUtil.isNotEmpty(errSysDtls)) {
|
||||||
@@ -791,9 +800,7 @@ public class DetectionServiceImpl {
|
|||||||
isData(dataRule, qualifiedList, detectionData, qualifiedList);
|
isData(dataRule, qualifiedList, detectionData, qualifiedList);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (0 == errSysDtl.getErrorValueType()) {
|
errSysDtl.setMaxErrorValue(maxErrorMultiply(errSysDtl.getMaxErrorValue(), data, channelData, errSysDtl.getErrorValueType()));
|
||||||
errSysDtl.setMaxErrorValue(multiply(errSysDtl.getMaxErrorValue(), data, 0));
|
|
||||||
}
|
|
||||||
detectionData.setResultData(channelData);
|
detectionData.setResultData(channelData);
|
||||||
detectionData.setRadius(-errSysDtl.getMaxErrorValue() + "~" + errSysDtl.getMaxErrorValue());
|
detectionData.setRadius(-errSysDtl.getMaxErrorValue() + "~" + errSysDtl.getMaxErrorValue());
|
||||||
if (CollUtil.isNotEmpty(list)) {
|
if (CollUtil.isNotEmpty(list)) {
|
||||||
@@ -855,14 +862,16 @@ public class DetectionServiceImpl {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public BigDecimal devSubtractChannelData(Double devData, Double channelData, Integer errorValueType) {
|
public BigDecimal devSubtractChannelData(Double devData, Double channelData, Integer errorValueType) {
|
||||||
if (devData != 0) {
|
if (devData - channelData != 0) {
|
||||||
switch (errorValueType) {
|
switch (errorValueType) {
|
||||||
case 2:
|
case 2:
|
||||||
return BigDecimal.valueOf(devData - channelData)
|
//下发的谐波电压幅值,返回的是谐波电压含有率,拿(含有率值*基波 - 源下发对应谐波值幅值)/下发的幅值
|
||||||
.divide(BigDecimal.valueOf(devData), 4, RoundingMode.HALF_UP);
|
|
||||||
case 3:
|
|
||||||
return BigDecimal.valueOf(devData - channelData)
|
return BigDecimal.valueOf(devData - channelData)
|
||||||
.divide(BigDecimal.valueOf(channelData), 4, RoundingMode.HALF_UP);
|
.divide(BigDecimal.valueOf(channelData), 4, RoundingMode.HALF_UP);
|
||||||
|
case 3:
|
||||||
|
//下发的谐波电压幅值,返回的是谐波电压含有率,拿(含有率值*基波 - 源下发对应谐波值幅值)/装置返回值
|
||||||
|
return BigDecimal.valueOf(devData - channelData)
|
||||||
|
.divide(BigDecimal.valueOf(devData), 4, RoundingMode.HALF_UP);
|
||||||
}
|
}
|
||||||
return BigDecimal.valueOf(devData - channelData);
|
return BigDecimal.valueOf(devData - channelData);
|
||||||
}
|
}
|
||||||
@@ -875,28 +884,63 @@ public class DetectionServiceImpl {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double multiply(Double devData, Double channelData, Integer type) {
|
/**
|
||||||
if (ObjectUtil.isNotNull(devData)) {
|
* 用于计算误差体系的范围的
|
||||||
if (0 == type) {
|
*
|
||||||
return BigDecimal.valueOf(devData).multiply(BigDecimal.valueOf(channelData))
|
* @param value 误差值
|
||||||
|
* @param ratedData 额定值
|
||||||
|
* @param harmData 谐波下发值(百分数->含油率)
|
||||||
|
* @param type 误差值类型
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Double startRadiusEnd(Double value, Double ratedData, Double harmData, Integer type) {
|
||||||
|
if (ObjectUtil.isNotNull(value)) {
|
||||||
|
switch (type) {
|
||||||
|
case 0:
|
||||||
|
return BigDecimal.valueOf(value).multiply(BigDecimal.valueOf(ratedData))
|
||||||
.setScale(4, RoundingMode.HALF_UP).doubleValue();
|
.setScale(4, RoundingMode.HALF_UP).doubleValue();
|
||||||
} else {
|
case 1:
|
||||||
if (ObjectUtil.isNotNull(devData)) {
|
return BigDecimal.valueOf(value).multiply(BigDecimal.valueOf(harmData))
|
||||||
return BigDecimal.valueOf(devData).doubleValue();
|
.setScale(4, RoundingMode.HALF_UP).doubleValue();
|
||||||
} else {
|
default:
|
||||||
return devData;
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于计算最大误差值的范围的
|
||||||
|
*
|
||||||
|
* @param errorValue 误差值
|
||||||
|
* @param ratedData 额定值
|
||||||
|
* @param harmData 谐波下发值(百分数->含油率)
|
||||||
|
* @param type 误差值类型
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Double maxErrorMultiply(Double errorValue, Double ratedData, Double harmData, Integer type) {
|
||||||
|
if (ObjectUtil.isNotNull(errorValue)) {
|
||||||
|
switch (type) {
|
||||||
|
case 0:
|
||||||
|
return BigDecimal.valueOf(errorValue).multiply(BigDecimal.valueOf(ratedData))
|
||||||
|
.setScale(4, RoundingMode.HALF_UP).doubleValue();
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
return BigDecimal.valueOf(errorValue).multiply(BigDecimal.valueOf(harmData))
|
||||||
|
.setScale(4, RoundingMode.HALF_UP).doubleValue();
|
||||||
|
default:
|
||||||
|
return errorValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
return errorValue;
|
||||||
return devData;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double multiply(String devData, String channelData) {
|
public Double multiply(String devData, String channelData) {
|
||||||
BigDecimal volValue = new BigDecimal(devData);
|
BigDecimal volValue = new BigDecimal(devData);
|
||||||
BigDecimal result = volValue.multiply(new BigDecimal(channelData).setScale(4, RoundingMode.HALF_UP));
|
// BigDecimal result = volValue.multiply(new BigDecimal(channelData).setScale(4, RoundingMode.HALF_UP));
|
||||||
return result.doubleValue();
|
return volValue.doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -173,8 +173,8 @@ public class SourceIssue {
|
|||||||
/**
|
/**
|
||||||
* 谐波含有率
|
* 谐波含有率
|
||||||
*/
|
*/
|
||||||
@JSONField(name = "fApm", ordinal = 2)
|
@JSONField(name = "fAmp", ordinal = 2)
|
||||||
private Double fApm;
|
private Double fAmp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 谐波相角
|
* 谐波相角
|
||||||
@@ -200,8 +200,8 @@ public class SourceIssue {
|
|||||||
/**
|
/**
|
||||||
* 间谐波含有率
|
* 间谐波含有率
|
||||||
*/
|
*/
|
||||||
@JSONField(name = "fApm", ordinal = 2)
|
@JSONField(name = "fAmp", ordinal = 2)
|
||||||
private Double fApm;
|
private Double fAmp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 间谐波相角
|
* 间谐波相角
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
*/
|
*/
|
||||||
Map<Integer, List<PqScriptDtls>> scriptDtlsMap = pqScriptDtls.stream()
|
Map<Integer, List<PqScriptDtls>> scriptDtlsMap = pqScriptDtls.stream()
|
||||||
.sorted(Comparator.comparing(PqScriptDtls::getIndex))
|
.sorted(Comparator.comparing(PqScriptDtls::getIndex))
|
||||||
.collect(Collectors.groupingBy(PqScriptDtls::getIndex));
|
.collect(Collectors.groupingBy(PqScriptDtls::getIndex, LinkedHashMap::new, Collectors.toList()));
|
||||||
scriptDtlsMap.forEach((key, value) -> {
|
scriptDtlsMap.forEach((key, value) -> {
|
||||||
/**
|
/**
|
||||||
* 分组获取有多少小类
|
* 分组获取有多少小类
|
||||||
@@ -216,7 +216,10 @@ 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)
|
||||||
// .eq(PqScriptDtls::getIndex, 48)
|
// .ge(PqScriptDtls::getIndex, 14)
|
||||||
|
// .ge(PqScriptDtls::getIndex, 30)
|
||||||
|
// .eq(PqScriptDtls::getIndex, 30)
|
||||||
|
|
||||||
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode());
|
.eq(PqScriptCheckData::getEnable, DataStateEnum.ENABLE.getCode());
|
||||||
if (isPhaseSequence.equals(CommonEnum.PHASE_TEST.getValue())) {
|
if (isPhaseSequence.equals(CommonEnum.PHASE_TEST.getValue())) {
|
||||||
//相序
|
//相序
|
||||||
@@ -372,7 +375,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
for (PqScriptDtls pqScriptDtls : phaseHarmVList) {
|
for (PqScriptDtls pqScriptDtls : phaseHarmVList) {
|
||||||
harmModel = new SourceIssue.ChannelListDTO.HarmModel();
|
harmModel = new SourceIssue.ChannelListDTO.HarmModel();
|
||||||
harmModel.setHarm(pqScriptDtls.getHarmNum().doubleValue());
|
harmModel.setHarm(pqScriptDtls.getHarmNum().doubleValue());
|
||||||
harmModel.setFApm(pqScriptDtls.getValue());
|
harmModel.setFAmp(pqScriptDtls.getValue());
|
||||||
harmModel.setFPhase(pqScriptDtls.getAngle());
|
harmModel.setFPhase(pqScriptDtls.getAngle());
|
||||||
info.add(harmModel);
|
info.add(harmModel);
|
||||||
}
|
}
|
||||||
@@ -391,7 +394,7 @@ public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqS
|
|||||||
for (PqScriptDtls pqScriptDtls : phaseHarmVList) {
|
for (PqScriptDtls pqScriptDtls : phaseHarmVList) {
|
||||||
inHarmModel = new SourceIssue.ChannelListDTO.InharmModel();
|
inHarmModel = new SourceIssue.ChannelListDTO.InharmModel();
|
||||||
inHarmModel.setInharm(pqScriptDtls.getHarmNum());
|
inHarmModel.setInharm(pqScriptDtls.getHarmNum());
|
||||||
inHarmModel.setFApm(pqScriptDtls.getValue());
|
inHarmModel.setFAmp(pqScriptDtls.getValue());
|
||||||
inHarmModel.setFPhase(pqScriptDtls.getAngle());
|
inHarmModel.setFPhase(pqScriptDtls.getAngle());
|
||||||
info.add(inHarmModel);
|
info.add(inHarmModel);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user