正式检测解决部分误差体系计算问题
This commit is contained in:
@@ -1271,19 +1271,22 @@ 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())) {
|
||||
DevData.SqlDataDTO.ListDTO vvv = data.getSqlData().get(0).getList();
|
||||
Double aV = vvv.getA();
|
||||
Double bV = vvv.getB();
|
||||
Double cV = vvv.getC();
|
||||
if (Objects.nonNull(aV)) {
|
||||
adHarmonicResult.setAValue1(String.format("%.7f", aV));
|
||||
}
|
||||
if (Objects.nonNull(bV)) {
|
||||
adHarmonicResult.setBValue1(String.format("%.7f", bV));
|
||||
}
|
||||
if (Objects.nonNull(cV)) {
|
||||
adHarmonicResult.setCValue1(String.format("%.7f", cV));
|
||||
if(CollUtil.isNotEmpty(data.getSqlData())){
|
||||
DevData.SqlDataDTO.ListDTO vvv = data.getSqlData().get(0).getList();
|
||||
Double aV = vvv.getA();
|
||||
Double bV = vvv.getB();
|
||||
Double cV = vvv.getC();
|
||||
if (Objects.nonNull(aV)) {
|
||||
adHarmonicResult.setAValue1(String.format("%.7f", aV));
|
||||
}
|
||||
if (Objects.nonNull(bV)) {
|
||||
adHarmonicResult.setBValue1(String.format("%.7f", bV));
|
||||
}
|
||||
if (Objects.nonNull(cV)) {
|
||||
adHarmonicResult.setCValue1(String.format("%.7f", cV));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DevData.SqlDataHarmDTO.ListDTO tem = sqlDataDTO.getList();
|
||||
|
||||
@@ -270,6 +270,10 @@ public class DetectionServiceImpl {
|
||||
if (I.equals(type)) {
|
||||
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> 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);
|
||||
@@ -389,6 +393,7 @@ public class DetectionServiceImpl {
|
||||
//暂降时间处理数据
|
||||
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> 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::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 {
|
||||
Double percent;
|
||||
if (I.equals(type)) {
|
||||
percent = fData * 0.01;
|
||||
} else {
|
||||
percent = 1.0;
|
||||
}
|
||||
if (1 == num) {
|
||||
issueHarmMap = sourceIssue.getChannelList().stream()
|
||||
.filter(x -> (type + phase.toLowerCase()).equals(x.getChannelType()))
|
||||
.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 {
|
||||
issueHarmMap = sourceIssue.getChannelList().stream()
|
||||
.filter(x -> (type + phase.toLowerCase()).equals(x.getChannelType()))
|
||||
.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<>();
|
||||
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(),
|
||||
multiply(x.getEndValue(), fData, x.getConditionType()),
|
||||
startRadiusEnd(x.getEndValue(), fData, value, x.getConditionType()),
|
||||
x.getEndFlag(),
|
||||
value)).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(errSysDtls)) {
|
||||
@@ -642,11 +652,10 @@ public class DetectionServiceImpl {
|
||||
|
||||
if (ObjectUtil.isNotNull(errSysDtl)) {
|
||||
PqErrSysDtls errSys = BeanUtil.copyProperties(errSysDtl, PqErrSysDtls.class);
|
||||
if (0 == errSys.getErrorValueType()) {
|
||||
errSys.setMaxErrorValue(multiply(errSys.getMaxErrorValue(), fData, 0));
|
||||
}
|
||||
errSys.setMaxErrorValue(maxErrorMultiply(errSys.getMaxErrorValue(), fData, issueHarmMap.get(harm), errSys.getErrorValueType()));
|
||||
Double v = issueHarmMap.get(harm);
|
||||
data.setResultData(v);
|
||||
data.setRadius(-errSysDtl.getMaxErrorValue() + "~" + errSysDtl.getMaxErrorValue());
|
||||
setDetection(dataRule, harmDataList, errSys, data, v);
|
||||
}
|
||||
info.add(data);
|
||||
@@ -770,9 +779,9 @@ public class DetectionServiceImpl {
|
||||
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(),
|
||||
multiply(x.getEndValue(), data, x.getConditionType()),
|
||||
startRadiusEnd(x.getEndValue(), data, channelData, x.getConditionType()),
|
||||
x.getEndFlag(),
|
||||
channelData)).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(errSysDtls)) {
|
||||
@@ -791,9 +800,7 @@ public class DetectionServiceImpl {
|
||||
isData(dataRule, qualifiedList, detectionData, qualifiedList);
|
||||
}
|
||||
} else {
|
||||
if (0 == errSysDtl.getErrorValueType()) {
|
||||
errSysDtl.setMaxErrorValue(multiply(errSysDtl.getMaxErrorValue(), data, 0));
|
||||
}
|
||||
errSysDtl.setMaxErrorValue(maxErrorMultiply(errSysDtl.getMaxErrorValue(), data, channelData, errSysDtl.getErrorValueType()));
|
||||
detectionData.setResultData(channelData);
|
||||
detectionData.setRadius(-errSysDtl.getMaxErrorValue() + "~" + errSysDtl.getMaxErrorValue());
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
@@ -855,14 +862,16 @@ public class DetectionServiceImpl {
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal devSubtractChannelData(Double devData, Double channelData, Integer errorValueType) {
|
||||
if (devData != 0) {
|
||||
if (devData - channelData != 0) {
|
||||
switch (errorValueType) {
|
||||
case 2:
|
||||
return BigDecimal.valueOf(devData - channelData)
|
||||
.divide(BigDecimal.valueOf(devData), 4, RoundingMode.HALF_UP);
|
||||
case 3:
|
||||
//下发的谐波电压幅值,返回的是谐波电压含有率,拿(含有率值*基波 - 源下发对应谐波值幅值)/下发的幅值
|
||||
return BigDecimal.valueOf(devData - channelData)
|
||||
.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);
|
||||
}
|
||||
@@ -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))
|
||||
.setScale(4, RoundingMode.HALF_UP).doubleValue();
|
||||
} else {
|
||||
if (ObjectUtil.isNotNull(devData)) {
|
||||
return BigDecimal.valueOf(devData).doubleValue();
|
||||
} else {
|
||||
return devData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于计算误差体系的范围的
|
||||
*
|
||||
* @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();
|
||||
case 1:
|
||||
return BigDecimal.valueOf(value).multiply(BigDecimal.valueOf(harmData))
|
||||
.setScale(4, RoundingMode.HALF_UP).doubleValue();
|
||||
default:
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return devData;
|
||||
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;
|
||||
}
|
||||
|
||||
public Double multiply(String devData, String channelData) {
|
||||
BigDecimal volValue = new BigDecimal(devData);
|
||||
BigDecimal result = volValue.multiply(new BigDecimal(channelData).setScale(4, RoundingMode.HALF_UP));
|
||||
return result.doubleValue();
|
||||
// BigDecimal result = volValue.multiply(new BigDecimal(channelData).setScale(4, RoundingMode.HALF_UP));
|
||||
return volValue.doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user