优化部分代码
This commit is contained in:
@@ -1015,10 +1015,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
double timeDouble = Math.round(harmNum);
|
||||
int timeInt = (int) timeDouble;
|
||||
// 填充结果数据
|
||||
fillThreePhaseData(singleResult, timeInt, keyFillMap);
|
||||
if (!keyFillMap.get(ItemReportKeyEnum.ERROR_SCOPE.getKey()).equals("/")) {
|
||||
keyFillMapList.add(keyFillMap);
|
||||
}
|
||||
fillThreePhaseData(singleResult, timeInt, keyFillMap, scriptCode);
|
||||
keyFillMapList.add(keyFillMap);
|
||||
});
|
||||
if (CollUtil.isNotEmpty(keyFillMapList)) {
|
||||
// 按次数排序
|
||||
@@ -1045,10 +1043,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
||||
for (AdNonHarmonicResult adNonHarmonicResult : nonHarmList) {
|
||||
Map<String, String> keyFillMap = new HashMap<>(16);
|
||||
fillThreePhaseData(adNonHarmonicResult, null, keyFillMap);
|
||||
if (!keyFillMap.get(ItemReportKeyEnum.ERROR_SCOPE.getKey()).equals("/")) {
|
||||
keyFillMapList.add(keyFillMap);
|
||||
}
|
||||
fillThreePhaseData(adNonHarmonicResult, null, keyFillMap, scriptCode);
|
||||
keyFillMapList.add(keyFillMap);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(keyFillMapList)) {
|
||||
// 需要对所有的填充进行按误差范围分组
|
||||
@@ -1075,9 +1071,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
for (AdNonHarmonicResult adNonHarmonicResult : nonHarmList) {
|
||||
Map<String, String> keyFillMap = new HashMap<>(8);
|
||||
fillTPhaseData(adNonHarmonicResult, null, keyFillMap);
|
||||
if (!keyFillMap.get(ItemReportKeyEnum.ERROR_SCOPE.getKey()).equals("/")) {
|
||||
keyFillMapList.add(keyFillMap);
|
||||
}
|
||||
keyFillMapList.add(keyFillMap);
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(keyFillMapList)) {
|
||||
@@ -1120,7 +1114,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
* @param timeInt 谐波类需要传指定次数
|
||||
* @param keyFillMap 待填充的集合Map
|
||||
*/
|
||||
private void fillThreePhaseData(Object singleResult, Integer timeInt, Map<String, String> keyFillMap) {
|
||||
private void fillThreePhaseData(Object singleResult, Integer timeInt, Map<String, String> keyFillMap, String scriptCode) {
|
||||
DetectionData tempA = getResultData(singleResult, timeInt, PowerConstant.PHASE_A);
|
||||
DetectionData tempB = getResultData(singleResult, timeInt, PowerConstant.PHASE_B);
|
||||
DetectionData tempC = getResultData(singleResult, timeInt, PowerConstant.PHASE_C);
|
||||
@@ -1129,50 +1123,64 @@ public class ResultServiceImpl implements IResultService {
|
||||
testA = "/", testB = "/", testC = "/",
|
||||
errorA = "/", errorB = "/", errorC = "/",
|
||||
resultA = "/", resultB = "/", resultC = "/", result = "/",
|
||||
errorScope = "/", unit = "";
|
||||
errorScope = "/", unit = "", scriptDetail = "/";
|
||||
|
||||
if (Objects.nonNull(tempA) && (PowerConstant.DATA_RANGE.contains(tempA.getIsData()))) {
|
||||
standardA = PubUtils.doubleRoundStr(4, tempA.getResultData());
|
||||
testA = PubUtils.doubleRoundStr(4, tempA.getData());
|
||||
errorA = PubUtils.doubleRoundStr(4, tempA.getErrorData().doubleValue());
|
||||
resultA = tempA.getIsData() == 1 ? "合格" : "不合格";
|
||||
errorScope = tempA.getRadius();
|
||||
unit = tempA.getUnit();
|
||||
standard = PubUtils.doubleRoundStr(4, tempA.getResultData());
|
||||
if (Objects.nonNull(tempA)) {
|
||||
standardA = PubUtils.doubleRoundStr(4, tempA.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempA.getResultData());
|
||||
testA = PubUtils.doubleRoundStr(4, tempA.getData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempA.getData());
|
||||
if (Objects.nonNull(tempA.getErrorData())) {
|
||||
errorA = PubUtils.doubleRoundStr(4, tempA.getErrorData().doubleValue());
|
||||
}
|
||||
resultA = tempA.getIsData() == 1 ? "合格" : tempA.getIsData() == 0 ? "不合格" : "/";
|
||||
errorScope = tempA.getRadius() == null ? "/" : tempA.getRadius();
|
||||
unit = tempA.getUnit() == null ? "" : tempA.getUnit();
|
||||
standard = PubUtils.doubleRoundStr(4, tempA.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempA.getResultData());
|
||||
}
|
||||
if (Objects.nonNull(tempB) && (PowerConstant.DATA_RANGE.contains(tempB.getIsData()))) {
|
||||
standardB = PubUtils.doubleRoundStr(4, tempB.getResultData());
|
||||
testB = PubUtils.doubleRoundStr(4, tempB.getData());
|
||||
errorB = PubUtils.doubleRoundStr(4, tempB.getErrorData().doubleValue());
|
||||
resultB = tempB.getIsData() == 1 ? "合格" : "不合格";
|
||||
if (Objects.nonNull(tempB)) {
|
||||
standardB = PubUtils.doubleRoundStr(4, tempB.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempB.getResultData());
|
||||
testB = PubUtils.doubleRoundStr(4, tempB.getData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempB.getData());
|
||||
if (Objects.nonNull(tempB.getErrorData())) {
|
||||
errorB = PubUtils.doubleRoundStr(4, tempB.getErrorData().doubleValue());
|
||||
}
|
||||
resultB = tempB.getIsData() == 1 ? "合格" : tempB.getIsData() == 0 ? "不合格" : "/";
|
||||
if (errorScope.equals("/")) {
|
||||
errorScope = tempB.getRadius();
|
||||
errorScope = tempB.getRadius() == null ? "/" : tempB.getRadius();
|
||||
}
|
||||
if (StrUtil.isBlank(unit)) {
|
||||
unit = tempB.getUnit();
|
||||
unit = tempB.getUnit() == null ? "" : tempB.getUnit();
|
||||
}
|
||||
if (standard.equals("/")) {
|
||||
standard = PubUtils.doubleRoundStr(4, tempB.getResultData());
|
||||
standard = PubUtils.doubleRoundStr(4, tempB.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempB.getResultData());
|
||||
}
|
||||
}
|
||||
if (Objects.nonNull(tempC) && (PowerConstant.DATA_RANGE.contains(tempC.getIsData()))) {
|
||||
standardC = PubUtils.doubleRoundStr(4, tempC.getResultData());
|
||||
testC = PubUtils.doubleRoundStr(4, tempC.getData());
|
||||
errorC = PubUtils.doubleRoundStr(4, tempC.getErrorData().doubleValue());
|
||||
resultC = tempC.getIsData() == 1 ? "合格" : "不合格";
|
||||
if (Objects.nonNull(tempC)) {
|
||||
standardC = PubUtils.doubleRoundStr(4, tempC.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempC.getResultData());
|
||||
testC = PubUtils.doubleRoundStr(4, tempC.getData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempC.getData());
|
||||
if (Objects.nonNull(tempC.getErrorData())) {
|
||||
errorC = PubUtils.doubleRoundStr(4, tempC.getErrorData().doubleValue());
|
||||
}
|
||||
resultC = tempC.getIsData() == 1 ? "合格" : tempC.getIsData() == 0 ? "不合格" : "/";
|
||||
if (errorScope.equals("/")) {
|
||||
errorScope = tempC.getRadius();
|
||||
errorScope = tempC.getRadius() == null ? "/" : tempC.getRadius();
|
||||
}
|
||||
if (StrUtil.isBlank(unit)) {
|
||||
unit = tempC.getUnit();
|
||||
unit = tempC.getUnit() == null ? "" : tempC.getUnit();
|
||||
}
|
||||
if (standard.equals("/")) {
|
||||
standard = PubUtils.doubleRoundStr(4, tempC.getResultData());
|
||||
standard = PubUtils.doubleRoundStr(4, tempC.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempC.getResultData());
|
||||
}
|
||||
}
|
||||
if (scriptCode.equalsIgnoreCase("I")) {
|
||||
resultA = "/";
|
||||
resultB = "/";
|
||||
resultC = "/";
|
||||
}
|
||||
if (standardA.equals(standardB) && standardA.equals(standardC)) {
|
||||
standard = standardA;
|
||||
}
|
||||
// 处理脚本输出
|
||||
scriptDetail = dealScriptDetail(scriptCode, standard);
|
||||
keyFillMap.put(ItemReportKeyEnum.SCRIPT_DETAIL.getKey(), scriptDetail);
|
||||
// 标准值
|
||||
keyFillMap.put(ItemReportKeyEnum.STANDARD.getKey(), standard);
|
||||
keyFillMap.put(ItemReportKeyEnum.STANDARD_A.getKey(), standardA);
|
||||
@@ -1200,6 +1208,45 @@ public class ResultServiceImpl implements IResultService {
|
||||
keyFillMap.put(ItemReportKeyEnum.ERROR_SCOPE.getKey(), errorScope);
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对浙江杭州处理脚本输出细节,todo... 需要更改更合理的方式,现在算是写死的了部分
|
||||
* 目前浙江这边就是(间)谐波电压/电流
|
||||
*/
|
||||
private String dealScriptDetail(String scriptCode, String standard) {
|
||||
String scriptDetail = "";
|
||||
PowerIndexEnum powerIndexEnum = PowerIndexEnum.getByKey(scriptCode);
|
||||
if (powerIndexEnum != null) {
|
||||
switch (powerIndexEnum) {
|
||||
case HV:
|
||||
case HSV:
|
||||
// 注:基波电压幅值57.74V,基波频率50.0Hz。
|
||||
scriptDetail = "注:基波电压幅值57.74V,基波频率50.0Hz。";
|
||||
break;
|
||||
case HI:
|
||||
// 电流是幅值,需要与5A得出百分比
|
||||
try {
|
||||
String temp = PubUtils.doubleRoundStr(1, (Double.parseDouble(standard) / 5.0) * 100);
|
||||
scriptDetail = "注:基波电流幅值5.000A,基波频率50.0Hz,各次谐波电流含有率均为" + temp + "%。";
|
||||
} catch (Exception e) {
|
||||
log.error("dealScriptDetail error:{}", e);
|
||||
}
|
||||
break;
|
||||
case HSI:
|
||||
// 电流是幅值,需要与5A得出百分比
|
||||
try {
|
||||
String temp = PubUtils.doubleRoundStr(1, (Double.parseDouble(standard) / 5.0) * 100);
|
||||
scriptDetail = "注:基波电流幅值5.000A,基波频率50.0Hz,各次间谐波电流含有率均为" + temp + "%。";
|
||||
} catch (Exception e) {
|
||||
log.error("dealScriptDetail error:{}", e);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return scriptDetail;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* T相的相关数据处理,非暂态数据
|
||||
@@ -1212,13 +1259,15 @@ public class ResultServiceImpl implements IResultService {
|
||||
private void fillTPhaseData(Object singleResult, Integer timeInt, Map<String, String> keyFillMap) {
|
||||
String standard = "/", test = "/", error = "/", result = "/", errorScope = "/", unit = "";
|
||||
DetectionData tempT = getResultData(singleResult, timeInt, PowerConstant.PHASE_T);
|
||||
if (Objects.nonNull(tempT) && PowerConstant.DATA_RANGE.contains(tempT.getIsData())) {
|
||||
standard = PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
test = PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
error = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
result = tempT.getIsData() == 1 ? "合格" : "不合格";
|
||||
unit = tempT.getUnit();
|
||||
errorScope = tempT.getRadius();
|
||||
if (Objects.nonNull(tempT)) {
|
||||
standard = PubUtils.doubleRoundStr(4, tempT.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
test = PubUtils.doubleRoundStr(4, tempT.getData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
if (Objects.nonNull(tempT.getErrorData())) {
|
||||
error = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
}
|
||||
result = tempT.getIsData() == 1 ? "合格" : tempT.getIsData() == 0 ? "不合格" : "/";
|
||||
unit = tempT.getUnit() == null ? "" : tempT.getUnit();
|
||||
errorScope = tempT.getRadius() == null ? "/" : tempT.getRadius();
|
||||
}
|
||||
keyFillMap.put(ItemReportKeyEnum.STANDARD.getKey(), standard);
|
||||
keyFillMap.put(ItemReportKeyEnum.TEST.getKey(), test);
|
||||
@@ -1249,11 +1298,13 @@ public class ResultServiceImpl implements IResultService {
|
||||
DictTree temp = dictTreeService.getById(adType);
|
||||
if (temp.getCode().equalsIgnoreCase("MAG")) {
|
||||
// 特征幅值
|
||||
if (Objects.nonNull(tempT) && PowerConstant.DATA_RANGE.contains(tempT.getIsData())) {
|
||||
standardMag = PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
testMag = PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
errorMag = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
resultMag = tempT.getIsData() == 1 ? "合格" : "不合格";
|
||||
if (Objects.nonNull(tempT)) {
|
||||
standardMag = PubUtils.doubleRoundStr(4, tempT.getResultData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
testMag = PubUtils.doubleRoundStr(4, tempT.getData()) == null ? "/" : PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
if (Objects.nonNull(tempT.getErrorData())) {
|
||||
errorMag = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
}
|
||||
resultMag = tempT.getIsData() == 1 ? "合格" : tempT.getIsData() == 0 ? "不合格" : "/";
|
||||
unitMag = tempT.getUnit();
|
||||
errorScopeMag = tempT.getRadius();
|
||||
}
|
||||
@@ -1271,12 +1322,24 @@ public class ResultServiceImpl implements IResultService {
|
||||
}
|
||||
}
|
||||
}
|
||||
standardDur = PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
testDur = PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
errorDur = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
resultDur = tempT.getIsData() == 1 ? "合格" : "不合格";
|
||||
unitDur = tempT.getUnit();
|
||||
errorScopeDur = tempT.getRadius();
|
||||
if (Objects.nonNull(tempT.getResultData())) {
|
||||
standardDur = PubUtils.doubleRoundStr(4, tempT.getResultData());
|
||||
}
|
||||
if (Objects.nonNull(tempT.getData())) {
|
||||
testDur = PubUtils.doubleRoundStr(4, tempT.getData());
|
||||
}
|
||||
if (Objects.nonNull(tempT.getErrorData())) {
|
||||
testDur = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
||||
}
|
||||
if (Objects.nonNull(tempT.getIsData())) {
|
||||
resultDur = tempT.getIsData() == 1 ? "合格" : "不合格";
|
||||
}
|
||||
if (StrUtil.isNotBlank(tempT.getUnit())) {
|
||||
unitDur = tempT.getUnit();
|
||||
}
|
||||
if (StrUtil.isNotBlank(tempT.getRadius())) {
|
||||
errorScopeDur = tempT.getRadius();
|
||||
}
|
||||
if (timeUnit.equalsIgnoreCase("ms")) {
|
||||
// 如果是ms,上述的一些数据需要重新处理
|
||||
if (!standardDur.equalsIgnoreCase("/")) {
|
||||
|
||||
Reference in New Issue
Block a user