优化部分代码
This commit is contained in:
@@ -21,7 +21,7 @@ public interface PowerConstant {
|
|||||||
/**
|
/**
|
||||||
* T相指标
|
* T相指标
|
||||||
*/
|
*/
|
||||||
List<String> T_PHASE = Arrays.asList("VOLTAGE", "IMBV", "IMBA");
|
List<String> T_PHASE = Arrays.asList("VOLTAGE", "IMBV", "IMBA", "FREQ");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,7 +32,7 @@ public interface PowerConstant {
|
|||||||
/**
|
/**
|
||||||
* 没有次数的指标
|
* 没有次数的指标
|
||||||
*/
|
*/
|
||||||
List<String> NO_TIME = Arrays.asList("V", "I", "P", "VOLTAGE", "IMBV", "IMBA", "F");
|
List<String> NO_TIME = Arrays.asList("V", "I", "P", "VOLTAGE", "IMBV", "IMBA", "F", "FREQ");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 有数据范围
|
* 有数据范围
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public enum AffectEnum {
|
|||||||
BASE("base", "额定工作条件下的检测"),
|
BASE("base", "额定工作条件下的检测"),
|
||||||
VOL("vol", "电压对XX测量的影响"),
|
VOL("vol", "电压对XX测量的影响"),
|
||||||
FREQ("freq", "频率对XX测量的影响"),
|
FREQ("freq", "频率对XX测量的影响"),
|
||||||
HARM("single", "谐波对XX测量的影响");
|
HARM("harm", "谐波对XX测量的影响");
|
||||||
|
|
||||||
private String key;
|
private String key;
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ import org.docx4j.jaxb.Context;
|
|||||||
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
||||||
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
|
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
|
||||||
import org.docx4j.wml.*;
|
import org.docx4j.wml.*;
|
||||||
|
import org.docx4j.wml.CTTblLayoutType;
|
||||||
|
import org.docx4j.wml.STTblLayoutType;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@@ -85,6 +87,7 @@ import javax.xml.bind.JAXBElement;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigInteger;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@@ -604,6 +607,8 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
// 确保目录存在
|
// 确保目录存在
|
||||||
ensureDirectoryExists(dirPath);
|
ensureDirectoryExists(dirPath);
|
||||||
baseModelDocument.save(new File(dirPath.concat(File.separator).concat(pqDevVO.getCreateId()).concat(ReportConstant.DOCX)));
|
baseModelDocument.save(new File(dirPath.concat(File.separator).concat(pqDevVO.getCreateId()).concat(ReportConstant.DOCX)));
|
||||||
|
|
||||||
|
this.updateDevAndPlanState(devReportParam.getDevId(), devReportParam.getPlanId());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(ReportResponseEnum.GENERATE_REPORT_ERROR.getMessage(), e);
|
log.error(ReportResponseEnum.GENERATE_REPORT_ERROR.getMessage(), e);
|
||||||
throw new BusinessException(ReportResponseEnum.GENERATE_REPORT_ERROR);
|
throw new BusinessException(ReportResponseEnum.GENERATE_REPORT_ERROR);
|
||||||
@@ -809,7 +814,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
ObjectFactory factory = new ObjectFactory();
|
ObjectFactory factory = new ObjectFactory();
|
||||||
// 读取该计划的检测大项组装数据内容
|
// 读取该计划的检测大项组装数据内容
|
||||||
List<PqScriptDtlDataVO> pqScriptDtlsList = pqScriptDtlsService.getScriptDtlsDataList(devReportParam.getScriptId());
|
List<PqScriptDtlDataVO> pqScriptDtlsList = pqScriptDtlsService.getScriptDtlsDataList(devReportParam.getScriptId());
|
||||||
Map<String, List<PqScriptDtlDataVO>> scriptMap = pqScriptDtlsList.stream().collect(Collectors.groupingBy(PqScriptDtlDataVO::getScriptCode));
|
Map<String, List<PqScriptDtlDataVO>> scriptMap = pqScriptDtlsList.stream().collect(Collectors.groupingBy(PqScriptDtlDataVO::getScriptCode, LinkedHashMap::new, Collectors.toList()));
|
||||||
List<Object> allContent = detailModelDocument.getContent();
|
List<Object> allContent = detailModelDocument.getContent();
|
||||||
List<Docx4jUtil.HeadingContent> headingContents = Docx4jUtil.extractHeading5Contents(allContent);
|
List<Docx4jUtil.HeadingContent> headingContents = Docx4jUtil.extractHeading5Contents(allContent);
|
||||||
Map<String, List<Docx4jUtil.HeadingContent>> contentMap = headingContents.stream().collect(Collectors.groupingBy(Docx4jUtil.HeadingContent::getHeadingText, Collectors.toList()));
|
Map<String, List<Docx4jUtil.HeadingContent>> contentMap = headingContents.stream().collect(Collectors.groupingBy(Docx4jUtil.HeadingContent::getHeadingText, Collectors.toList()));
|
||||||
@@ -825,7 +830,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Map.Entry<String, List<PqScriptDtlDataVO>> next = iterator.next();
|
Map.Entry<String, List<PqScriptDtlDataVO>> next = iterator.next();
|
||||||
String scriptCode = next.getKey();
|
String scriptCode = next.getKey();
|
||||||
List<PqScriptDtlDataVO> checkckItemList = next.getValue();
|
List<PqScriptDtlDataVO> dtlScriptItemList = next.getValue();
|
||||||
List<Docx4jUtil.HeadingContent> tempContent = contentMap.get(scriptCode);
|
List<Docx4jUtil.HeadingContent> tempContent = contentMap.get(scriptCode);
|
||||||
// 获取需要填充keys,索引0对应的段落key,索引1对应的表格key
|
// 获取需要填充keys,索引0对应的段落key,索引1对应的表格key
|
||||||
List<List<String>> keys = Docx4jUtil.getFillKeys(tempContent);
|
List<List<String>> keys = Docx4jUtil.getFillKeys(tempContent);
|
||||||
@@ -849,14 +854,14 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
}
|
}
|
||||||
if (PowerConstant.TIME.contains(scriptCode)) {
|
if (PowerConstant.TIME.contains(scriptCode)) {
|
||||||
// 谐波类,以scriptIndex区分
|
// 谐波类,以scriptIndex区分
|
||||||
Map<Integer, List<PqScriptDtlDataVO>> scriptIndexMap = checkckItemList.stream().collect(Collectors.groupingBy(PqScriptDtlDataVO::getScriptIndex));
|
Map<Integer, List<PqScriptDtlDataVO>> scriptIndexMap = dtlScriptItemList.stream().collect(Collectors.groupingBy(PqScriptDtlDataVO::getScriptIndex));
|
||||||
for (List<PqScriptDtlDataVO> scriptDtlDataItem : scriptIndexMap.values()) {
|
for (List<PqScriptDtlDataVO> scriptDtlDataItem : scriptIndexMap.values()) {
|
||||||
singleTestResult = resultService.getFinalContent(scriptDtlDataItem, devReportParam.getPlanCode(), pqDevVO.getId(), lineNo, tableKeys);
|
singleTestResult = resultService.getFinalContent(scriptDtlDataItem, devReportParam.getPlanCode(), pqDevVO.getId(), lineNo, tableKeys);
|
||||||
position = fillContentInTemplate(singleTestResult.getDetail(), position, tempContent, factory, pKeyValueMap, tableKeys, paragraphs);
|
position = fillContentInTemplate(singleTestResult.getDetail(), position, tempContent, factory, pKeyValueMap, tableKeys, paragraphs);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 非谐波类
|
// 非谐波类
|
||||||
singleTestResult = resultService.getFinalContent(checkckItemList, devReportParam.getPlanCode(), pqDevVO.getId(), lineNo, tableKeys);
|
singleTestResult = resultService.getFinalContent(dtlScriptItemList, devReportParam.getPlanCode(), pqDevVO.getId(), lineNo, tableKeys);
|
||||||
position = fillContentInTemplate(singleTestResult.getDetail(), position, tempContent, factory, pKeyValueMap, tableKeys, paragraphs);
|
position = fillContentInTemplate(singleTestResult.getDetail(), position, tempContent, factory, pKeyValueMap, tableKeys, paragraphs);
|
||||||
}
|
}
|
||||||
if (Objects.nonNull(singleTestResult) && needFill) {
|
if (Objects.nonNull(singleTestResult) && needFill) {
|
||||||
@@ -942,13 +947,16 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
List<Object> rows = tbl.getContent();
|
List<Object> rows = tbl.getContent();
|
||||||
boolean isRow = Docx4jUtil.judgeTableCross(rows.get(0));
|
boolean isRow = Docx4jUtil.judgeTableCross(rows.get(0));
|
||||||
if (isRow) {
|
if (isRow) {
|
||||||
// 删除最后一行,这行用来填模板key的,无需展示
|
|
||||||
// 获取现有行的样式
|
// 获取现有行的样式
|
||||||
Tr existingRow = (Tr) tbl.getContent().get(rows.size() - 1);
|
Tr existingRow = (Tr) tbl.getContent().get(rows.size() - 1);
|
||||||
// 获取现有样式
|
// 获取现有样式
|
||||||
TrPr trPr = existingRow.getTrPr();
|
TrPr trPr = existingRow.getTrPr();
|
||||||
JAXBElement<Tc> element = (JAXBElement<Tc>) existingRow.getContent().get(0);
|
JAXBElement<Tc> element = (JAXBElement<Tc>) existingRow.getContent().get(0);
|
||||||
TcPr tcPr = element.getValue().getTcPr();
|
TcPr tcPr = element.getValue().getTcPr();
|
||||||
|
TblWidth cellWidth = factory.createTblWidth();
|
||||||
|
cellWidth.setType("dxa");
|
||||||
|
cellWidth.setW(BigInteger.valueOf(5000/tableKeys.size()));
|
||||||
|
tcPr.setTcW(cellWidth);
|
||||||
tbl.getContent().remove(existingRow);
|
tbl.getContent().remove(existingRow);
|
||||||
// 迭代增加行,需要填充的表格keys在tableKeys集合中
|
// 迭代增加行,需要填充的表格keys在tableKeys集合中
|
||||||
for (Map<String, String> stringStringMap : value1) {
|
for (Map<String, String> stringStringMap : value1) {
|
||||||
@@ -958,14 +966,16 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
} else {
|
} else {
|
||||||
// 纵向表格暂不考虑
|
// 纵向表格暂不考虑
|
||||||
}
|
}
|
||||||
// 插入段落
|
// 插入段落,处理下样式
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
paragraphs.add(position++, copiedTableElement);
|
paragraphs.add(position++, copiedTableElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 全部渲染完毕后,添加几个换行
|
// 全部渲染完毕后,添加几个换行
|
||||||
P p = factory.createP();
|
P p = factory.createP();
|
||||||
Docx4jUtil.addBr(factory, p, 2);
|
Docx4jUtil.addBr(factory, p, 1);
|
||||||
paragraphs.add(position++, p);
|
paragraphs.add(position++, p);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -517,6 +517,8 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
case VOLTAGE_MAG:
|
case VOLTAGE_MAG:
|
||||||
case VOLTAGE_DUR:
|
case VOLTAGE_DUR:
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,6 +598,8 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
case VOLTAGE_MAG:
|
case VOLTAGE_MAG:
|
||||||
case VOLTAGE_DUR:
|
case VOLTAGE_DUR:
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -687,6 +691,8 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
case VOLTAGE_MAG:
|
case VOLTAGE_MAG:
|
||||||
case VOLTAGE_DUR:
|
case VOLTAGE_DUR:
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -782,6 +788,8 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
List<PqScriptDtls> dip = dtls.stream().filter(x -> "Dip".equals(x.getValueType())).collect(Collectors.toList());
|
List<PqScriptDtls> dip = dtls.stream().filter(x -> "Dip".equals(x.getValueType())).collect(Collectors.toList());
|
||||||
dtlType.setScriptTypeName("频率=" + dipf.get(0).getValue() + ResultUnitEnum.FREQ.getUnit() + ",特征幅值=" + dip.get(0).getTransValue().intValue() + "%Un,持续时间=" + dip.get(0).getRetainTime().intValue() + "周波");
|
dtlType.setScriptTypeName("频率=" + dipf.get(0).getValue() + ResultUnitEnum.FREQ.getUnit() + ",特征幅值=" + dip.get(0).getTransValue().intValue() + "%Un,持续时间=" + dip.get(0).getRetainTime().intValue() + "周波");
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -954,382 +962,136 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
List<Integer> indexList = scriptDtlDataVOList.stream().map(PqScriptDtlDataVO::getScriptIndex).distinct().collect(Collectors.toList());
|
List<Integer> indexList = scriptDtlDataVOList.stream().map(PqScriptDtlDataVO::getScriptIndex).distinct().collect(Collectors.toList());
|
||||||
List<PqScriptCheckData> scriptCheckDataList = pqScriptCheckDataService.listCheckData(scriptId, indexList);
|
List<PqScriptCheckData> scriptCheckDataList = pqScriptCheckDataService.listCheckData(scriptId, indexList);
|
||||||
List<String> valueTypeList = scriptCheckDataList.stream().map(PqScriptCheckData::getValueType).distinct().collect(Collectors.toList());
|
List<String> valueTypeList = scriptCheckDataList.stream().map(PqScriptCheckData::getValueType).distinct().collect(Collectors.toList());
|
||||||
// 查询检测结果,区分下表。
|
// 稍作区分,暂态的脚本同一个scriptIndex可以有两个指标,其余脚本每个checkData的valueType对应一个指标结果
|
||||||
if (PowerConstant.TIME.contains(scriptCode)) {
|
if (PowerConstant.VOLTAGE.equalsIgnoreCase(scriptCode)) {
|
||||||
// 谐波的测试项,肯定是三相的,可能会存在多次的,本处要填充的key全集为:time、standard、standardA、standardB、standardC、testA、testB、testC、errorA、errorB、errorC、result
|
// 暂态的valueType通常只有2个,一个特征幅值,一个持续时间
|
||||||
// 查询结果数据,经过上层处理谐波类此处的scriptIndex确保只有一个
|
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
||||||
if (indexList.size() == 1 && valueTypeList.size() == 1) {
|
for (Integer sort : indexList) {
|
||||||
// 获取谐波数据
|
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, valueTypeList, Collections.singletonList(sort));
|
||||||
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, valueTypeList.get(0), indexList.get(0));
|
List<AdNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
|
||||||
AdHarmonicResult singleResult = adHarmonicService.getSingleResult(param);
|
if (CollUtil.isNotEmpty(nonHarmList)) {
|
||||||
// 注:如果ABC的标准值一致,则同步到standard中
|
Map<String, String> keyFillMap = new HashMap<>(16);
|
||||||
Map<Double, List<PqScriptCheckData>> checkDataHarmNumMap = scriptCheckDataList.stream().collect(Collectors.groupingBy(PqScriptCheckData::getHarmNum));
|
fillVoltagePhaseData(nonHarmList, keyFillMap, tableKeys);
|
||||||
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
|
||||||
checkDataHarmNumMap.forEach((harmNum, dtlsList) -> {
|
|
||||||
Map<String, String> keyFillMap = new HashMap<>();
|
|
||||||
// 次数需要区分谐波&间谐波
|
|
||||||
String time;
|
|
||||||
if (harmNum % 1 == 0) {
|
|
||||||
// 谐波,需要转为正数字符串
|
|
||||||
time = String.valueOf(harmNum.intValue());
|
|
||||||
} else {
|
|
||||||
// 间谐波,保留小数位转为字符串
|
|
||||||
time = String.format("%.1f", harmNum);
|
|
||||||
}
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.TIME.getKey(), time);
|
|
||||||
// 将间谐波次数取整1.5取2,2.5取3
|
|
||||||
double timeDouble = Math.round(harmNum);
|
|
||||||
int timeInt = (int) timeDouble;
|
|
||||||
DetectionData tempA = getResultData(singleResult, timeInt, PowerConstant.PHASE_A);
|
|
||||||
DetectionData tempB = getResultData(singleResult, timeInt, PowerConstant.PHASE_B);
|
|
||||||
DetectionData tempC = getResultData(singleResult, timeInt, PowerConstant.PHASE_C);
|
|
||||||
// 待填充Key
|
|
||||||
String standard = "/", standardA = "/", standardB = "/", standardC = "/",
|
|
||||||
testA = "/", testB = "/", testC = "/",
|
|
||||||
errorA = "/", errorB = "/", errorC = "/",
|
|
||||||
resultA = "/", resultB = "/", resultC = "/", result = "/",
|
|
||||||
errorScope = "/", unit = "";
|
|
||||||
|
|
||||||
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(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 (errorScope.equals("/")) {
|
|
||||||
errorScope = tempB.getRadius();
|
|
||||||
}
|
|
||||||
if (StrUtil.isBlank(unit)) {
|
|
||||||
unit = tempB.getUnit();
|
|
||||||
}
|
|
||||||
if (standard.equals("/")) {
|
|
||||||
standard = 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 (errorScope.equals("/")) {
|
|
||||||
errorScope = tempC.getRadius();
|
|
||||||
}
|
|
||||||
if (StrUtil.isBlank(unit)) {
|
|
||||||
unit = tempC.getUnit();
|
|
||||||
}
|
|
||||||
if (standard.equals("/")) {
|
|
||||||
standard = PubUtils.doubleRoundStr(4, tempC.getResultData());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (standardA.equals(standardB) && standardA.equals(standardC)) {
|
|
||||||
standard = standardA;
|
|
||||||
}
|
|
||||||
// 标准值
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.STANDARD.getKey(), standard);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.STANDARD_A.getKey(), standardA);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.STANDARD_B.getKey(), standardB);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.STANDARD_C.getKey(), standardC);
|
|
||||||
// 测试值
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.TEST_A.getKey(), testA);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.TEST_B.getKey(), testB);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.TEST_C.getKey(), testC);
|
|
||||||
// 误差值
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.ERROR_A.getKey(), errorA);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.ERROR_B.getKey(), errorB);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.ERROR_C.getKey(), errorC);
|
|
||||||
// 结果
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.RESULT_A.getKey(), resultA);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.RESULT_B.getKey(), resultB);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.RESULT_C.getKey(), resultC);
|
|
||||||
if (resultA.equals("不合格") || resultB.equals("不合格") || resultC.equals("不合格")) {
|
|
||||||
result = "不合格";
|
|
||||||
} else if (!resultA.equals("/") || !resultB.equals("/") || !resultC.equals("/")) {
|
|
||||||
result = "合格";
|
|
||||||
}
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.RESULT.getKey(), result);
|
|
||||||
errorScope = dealErrorScope(errorScope).concat(unit);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.ERROR_SCOPE.getKey(), errorScope);
|
|
||||||
keyFillMapList.add(keyFillMap);
|
keyFillMapList.add(keyFillMap);
|
||||||
});
|
|
||||||
// 按次数排序
|
|
||||||
PubUtils.sortByDoubleValue(keyFillMapList, ItemReportKeyEnum.TIME.getKey());
|
|
||||||
// 取出任意一次谐波数据的误差范围作为key
|
|
||||||
String titleScope = keyFillMapList.get(0).get(ItemReportKeyEnum.ERROR_SCOPE.getKey());
|
|
||||||
Map<String, List<Map<String, String>>> errorScoperMap = new HashMap<>();
|
|
||||||
errorScoperMap.put(titleScope, keyFillMapList);
|
|
||||||
List<Map<String, List<Map<String, String>>>> errorScoperMapList = new ArrayList<>();
|
|
||||||
errorScoperMapList.add(errorScoperMap);
|
|
||||||
finalContent.put(affectName, errorScoperMapList);
|
|
||||||
} else {
|
|
||||||
log.error("生成谐波类表格数据失败,脚本配置不支持,请核实。");
|
|
||||||
throw new BusinessException("生成谐波类表格数据失败,脚本配置不支持,请核实。");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 非谐波的需要区分是否为ABC相还是T相
|
|
||||||
if (PowerConstant.THREE_PHASE.contains(scriptCode)) {
|
|
||||||
if (valueTypeList.size() == 1) {
|
|
||||||
// 获取该三相的数据
|
|
||||||
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, valueTypeList, indexList);
|
|
||||||
List<AdNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
|
|
||||||
// 三相的数据通常包含:standard、standardA、standardB、standardC、testA、testB、testC、errorA、errorB、errorC、resultA、resultB、resultC、result、errorScope
|
|
||||||
if (CollUtil.isNotEmpty(nonHarmList)) {
|
|
||||||
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
|
||||||
for (AdNonHarmonicResult adNonHarmonicResult : nonHarmList) {
|
|
||||||
Map<String, String> keyFillMap = new HashMap<>(16);
|
|
||||||
DetectionData tempA = getResultData(adNonHarmonicResult, null, PowerConstant.PHASE_A);
|
|
||||||
DetectionData tempB = getResultData(adNonHarmonicResult, null, PowerConstant.PHASE_B);
|
|
||||||
DetectionData tempC = getResultData(adNonHarmonicResult, null, PowerConstant.PHASE_C);
|
|
||||||
// 待填充Key
|
|
||||||
String standard = "/", standardA = "/", standardB = "/", standardC = "/",
|
|
||||||
testA = "/", testB = "/", testC = "/",
|
|
||||||
errorA = "/", errorB = "/", errorC = "/",
|
|
||||||
resultA = "/", resultB = "/", resultC = "/", result = "/",
|
|
||||||
errorScope = "/", unit = "";
|
|
||||||
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(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 (errorScope.equals("/")) {
|
|
||||||
errorScope = tempB.getRadius();
|
|
||||||
}
|
|
||||||
if (StrUtil.isBlank(unit)) {
|
|
||||||
unit = tempB.getUnit();
|
|
||||||
}
|
|
||||||
if (standard.equals("/")) {
|
|
||||||
standard = 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 (errorScope.equals("/")) {
|
|
||||||
errorScope = tempC.getRadius();
|
|
||||||
}
|
|
||||||
if (StrUtil.isBlank(unit)) {
|
|
||||||
unit = tempC.getUnit();
|
|
||||||
}
|
|
||||||
if (standard.equals("/")) {
|
|
||||||
standard = PubUtils.doubleRoundStr(4, tempC.getResultData());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (standardA.equals(standardB) && standardA.equals(standardC)) {
|
|
||||||
standard = standardA;
|
|
||||||
}
|
|
||||||
// 标准值
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.STANDARD.getKey(), standard);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.STANDARD_A.getKey(), standardA);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.STANDARD_B.getKey(), standardB);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.STANDARD_C.getKey(), standardC);
|
|
||||||
// 测试值
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.TEST_A.getKey(), testA);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.TEST_B.getKey(), testB);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.TEST_C.getKey(), testC);
|
|
||||||
// 误差值
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.ERROR_A.getKey(), errorA);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.ERROR_B.getKey(), errorB);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.ERROR_C.getKey(), errorC);
|
|
||||||
// 结果
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.RESULT_A.getKey(), resultA);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.RESULT_B.getKey(), resultB);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.RESULT_C.getKey(), resultC);
|
|
||||||
if (resultA.equals("不合格") || resultB.equals("不合格") || resultC.equals("不合格")) {
|
|
||||||
result = "不合格";
|
|
||||||
} else if (!resultA.equals("/") || !resultB.equals("/") || !resultC.equals("/")) {
|
|
||||||
result = "合格";
|
|
||||||
}
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.RESULT.getKey(), result);
|
|
||||||
errorScope = dealErrorScope(errorScope).concat(unit);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.ERROR_SCOPE.getKey(), errorScope);
|
|
||||||
keyFillMapList.add(keyFillMap);
|
|
||||||
}
|
|
||||||
// 需要对所有的填充进行按误差范围分组
|
|
||||||
Map<String, List<Map<String, String>>> errorScoperMap = keyFillMapList.stream()
|
|
||||||
.collect(Collectors.groupingBy(map -> map.get(ItemReportKeyEnum.ERROR_SCOPE.getKey())));
|
|
||||||
// 分组后,还需要针对标准值进行一个升序
|
|
||||||
errorScoperMap.forEach((errorScope, maps) -> {
|
|
||||||
PubUtils.sortByDoubleValue(maps, ItemReportKeyEnum.STANDARD.getKey());
|
|
||||||
});
|
|
||||||
List<Map<String, List<Map<String, String>>>> errorList = new ArrayList<>();
|
|
||||||
errorList.add(errorScoperMap);
|
|
||||||
// 最后赋值返回
|
|
||||||
finalContent.put(affectName, errorList);
|
|
||||||
} else {
|
|
||||||
log.error("生成三相类表格数据失败,结果表数据丢失,请核实。");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.error("生成三相类表格数据失败,脚本配置不支持,请核实。");
|
|
||||||
throw new BusinessException("生成三相类表格数据失败,脚本配置不支持,请核实。");
|
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
// 非三相的还需要特殊处理下暂态的
|
// 需要对所有填充进行按误差范围分组
|
||||||
if (PowerConstant.VOLTAGE.equalsIgnoreCase(scriptCode)) {
|
Map<String, List<Map<String, String>>> errorScoperMap = keyFillMapList.stream()
|
||||||
// 暂态的valueType通常只有2个,一个特征幅值,一个持续时间
|
.collect(Collectors.groupingBy(map -> map.get(ItemReportKeyEnum.ERROR_SCOPE.getKey())));
|
||||||
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
// 分组后,还需要针对特征幅值标准值进行一个升序
|
||||||
for (Integer sort : indexList) {
|
errorScoperMap.forEach((errorScope, maps) -> {
|
||||||
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, valueTypeList, Collections.singletonList(sort));
|
PubUtils.sortByDoubleValue(maps, ItemReportKeyEnum.STANDARD_MAG.getKey());
|
||||||
List<AdNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
|
});
|
||||||
// 暂态的数据通常包含:standardMag、standardDur、testMag、testDur、errorMag、errorDur、resultMag、resultDur、result、errorScope、errorScopeMag、errorScopeDur
|
List<Map<String, List<Map<String, String>>>> errorList = new ArrayList<>();
|
||||||
if (CollUtil.isNotEmpty(nonHarmList)) {
|
errorList.add(errorScoperMap);
|
||||||
String standardMag = "/", standardDur = "/",
|
// 最后赋值返回
|
||||||
testMag = "/", testDur = "/",
|
finalContent.put(affectName, errorList);
|
||||||
errorMag = "/", errorDur = "/",
|
} else {
|
||||||
resultMag = "/", resultDur = "/", result,
|
for (String valueType : valueTypeList) {
|
||||||
errorScope, errorScopeMag = "/", errorScopeDur = "/",
|
if (PowerConstant.TIME.contains(scriptCode)) {
|
||||||
unitMag = "", unitDur = "";
|
// 查询结果数据,经过上层处理谐波类此处的scriptIndex确保只有一个
|
||||||
Map<String, String> keyFillMap = new HashMap<>(16);
|
if (indexList.size() == 1) {
|
||||||
for (AdNonHarmonicResult adNonHarmonicResult : nonHarmList) {
|
// 获取谐波数据
|
||||||
DetectionData tempT = getResultData(adNonHarmonicResult, null, PowerConstant.PHASE_T);
|
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, valueType, indexList.get(0));
|
||||||
// 需要判断adNonHarmonicResult是特征幅值还是持续时间
|
AdHarmonicResult singleResult = adHarmonicService.getSingleResult(param);
|
||||||
String adType = adNonHarmonicResult.getAdType();
|
// 注:如果ABC的标准值一致,则同步到standard中
|
||||||
DictTree temp = dictTreeService.getById(adType);
|
Map<Double, List<PqScriptCheckData>> checkDataHarmNumMap = scriptCheckDataList.stream().collect(Collectors.groupingBy(PqScriptCheckData::getHarmNum));
|
||||||
if (temp.getCode().equalsIgnoreCase("MAG")) {
|
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
||||||
// 特征幅值
|
checkDataHarmNumMap.forEach((harmNum, dtlsList) -> {
|
||||||
if (Objects.nonNull(tempT) && PowerConstant.DATA_RANGE.contains(tempT.getIsData())) {
|
Map<String, String> keyFillMap = new HashMap<>();
|
||||||
standardMag = PubUtils.doubleRoundStr(4, tempT.getResultData());
|
// 次数需要区分谐波&间谐波
|
||||||
testMag = PubUtils.doubleRoundStr(4, tempT.getData());
|
String time;
|
||||||
errorMag = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
if (harmNum % 1 == 0) {
|
||||||
resultMag = tempT.getIsData() == 1 ? "合格" : "不合格";
|
// 谐波,需要转为正数字符串
|
||||||
unitMag = tempT.getUnit();
|
time = String.valueOf(harmNum.intValue());
|
||||||
errorScopeMag = tempT.getRadius();
|
} else {
|
||||||
}
|
// 间谐波,保留小数位转为字符串
|
||||||
} else if (temp.getCode().equalsIgnoreCase("DUR")) {
|
time = String.format("%.1f", harmNum);
|
||||||
// 持续时间,需要注意时间单位处理,默认是秒
|
|
||||||
String timeUnit = "s";
|
|
||||||
for (String tableKey : tableKeys) {
|
|
||||||
if (tableKey.contains(ItemReportKeyEnum.STANDARD_DUR.getKey())) {
|
|
||||||
//截取单位
|
|
||||||
String[] tempStr = tableKey.split(StrPool.UNDERLINE);
|
|
||||||
if (tempStr.length > 1) {
|
|
||||||
if (tempStr[1].equalsIgnoreCase("ms")) {
|
|
||||||
timeUnit = "ms";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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 (timeUnit.equalsIgnoreCase("ms")) {
|
|
||||||
// 如果是ms,上述的一些数据需要重新处理
|
|
||||||
if (!standardDur.equalsIgnoreCase("/")) {
|
|
||||||
standardDur = PubUtils.doubleRoundStr(4, Double.parseDouble(standardDur) * 1000);
|
|
||||||
}
|
|
||||||
if (!testDur.equalsIgnoreCase("/")) {
|
|
||||||
testDur = PubUtils.doubleRoundStr(4, Double.parseDouble(testDur) * 1000);
|
|
||||||
}
|
|
||||||
if (!errorDur.equalsIgnoreCase("/")) {
|
|
||||||
errorDur = PubUtils.doubleRoundStr(4, Double.parseDouble(errorDur) * 1000);
|
|
||||||
}
|
|
||||||
if(!errorScopeDur.equalsIgnoreCase("/")){
|
|
||||||
if(errorScopeDur.contains("~")){
|
|
||||||
String[] tempStr = errorScopeDur.split("~");
|
|
||||||
errorScopeDur = PubUtils.doubleRoundStr(0, Double.parseDouble(tempStr[0]) * 1000).concat("~").concat(PubUtils.doubleRoundStr(0, Double.parseDouble(tempStr[1]) * 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unitDur = "ms";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
errorScopeMag = dealErrorScope(errorScopeMag).concat(unitMag);
|
keyFillMap.put(ItemReportKeyEnum.TIME.getKey(), time);
|
||||||
errorScopeDur = dealErrorScope(errorScopeDur).concat(unitDur);
|
// 将间谐波次数取整1.5取2,2.5取3
|
||||||
|
double timeDouble = Math.round(harmNum);
|
||||||
errorScope = "特征幅值:".concat(errorScopeMag).concat(StrPool.COMMA).concat("持续时间:").concat(errorScopeDur);
|
int timeInt = (int) timeDouble;
|
||||||
keyFillMap.put(ItemReportKeyEnum.ERROR_SCOPE.getKey(), errorScope);
|
// 填充结果数据
|
||||||
// 标准值
|
fillThreePhaseData(singleResult, timeInt, keyFillMap);
|
||||||
keyFillMap.put(ItemReportKeyEnum.STANDARD_MAG.getKey(), standardMag);
|
if(!keyFillMap.get(ItemReportKeyEnum.ERROR_SCOPE.getKey()).equals("/")){
|
||||||
keyFillMap.put(ItemReportKeyEnum.STANDARD_DUR.getKey(), standardDur);
|
keyFillMapList.add(keyFillMap);
|
||||||
// 测试值
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.TEST_MAG.getKey(), testMag);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.TEST_DUR.getKey(), testDur);
|
|
||||||
// 误差
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.ERROR_MAG.getKey(), errorMag);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.ERROR_DUR.getKey(), errorDur);
|
|
||||||
// 结果
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.RESULT_MAG.getKey(), resultMag);
|
|
||||||
keyFillMap.put(ItemReportKeyEnum.RESULT_DUR.getKey(), resultDur);
|
|
||||||
// 综合结果
|
|
||||||
result = resultMag;
|
|
||||||
if (!resultDur.equals("/") && result.equals("合格")) {
|
|
||||||
if (resultDur.equals("不合格")) {
|
|
||||||
result = "不合格";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
keyFillMap.put(ItemReportKeyEnum.RESULT.getKey(), result);
|
});
|
||||||
keyFillMapList.add(keyFillMap);
|
if(CollUtil.isNotEmpty(keyFillMapList)){
|
||||||
|
// 按次数排序
|
||||||
|
PubUtils.sortByDoubleValue(keyFillMapList, ItemReportKeyEnum.TIME.getKey());
|
||||||
|
// 取出任意一次谐波数据的误差范围作为key
|
||||||
|
String titleScope = keyFillMapList.get(0).get(ItemReportKeyEnum.ERROR_SCOPE.getKey());
|
||||||
|
Map<String, List<Map<String, String>>> errorScoperMap = new HashMap<>();
|
||||||
|
errorScoperMap.put(titleScope, keyFillMapList);
|
||||||
|
List<Map<String, List<Map<String, String>>>> errorScoperMapList = new ArrayList<>();
|
||||||
|
errorScoperMapList.add(errorScoperMap);
|
||||||
|
finalContent.put(affectName, errorScoperMapList);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log.error("生成谐波类表格数据失败,脚本配置不支持,请核实。");
|
||||||
|
throw new BusinessException("生成谐波类表格数据失败,脚本配置不支持,请核实。");
|
||||||
}
|
}
|
||||||
// 需要对所有填充进行按误差范围分组
|
|
||||||
Map<String, List<Map<String, String>>> errorScoperMap = keyFillMapList.stream()
|
|
||||||
.collect(Collectors.groupingBy(map -> map.get(ItemReportKeyEnum.ERROR_SCOPE.getKey())));
|
|
||||||
// 分组后,还需要针对特征幅值标准值进行一个升序
|
|
||||||
errorScoperMap.forEach((errorScope, maps) -> {
|
|
||||||
PubUtils.sortByDoubleValue(maps, ItemReportKeyEnum.STANDARD_MAG.getKey());
|
|
||||||
});
|
|
||||||
List<Map<String, List<Map<String, String>>>> errorList = new ArrayList<>();
|
|
||||||
errorList.add(errorScoperMap);
|
|
||||||
// 最后赋值返回
|
|
||||||
finalContent.put(affectName, errorList);
|
|
||||||
} else {
|
} else {
|
||||||
// 非三相且非暂态,通常只有一个数据,所以直接赋值即可
|
// 非谐波的需要区分是否为ABC相还是T相
|
||||||
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
if (PowerConstant.THREE_PHASE.contains(scriptCode)) {
|
||||||
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, valueTypeList, indexList);
|
// 获取该三相的数据
|
||||||
List<AdNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
|
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, Collections.singletonList(valueType), indexList);
|
||||||
if (CollUtil.isNotEmpty(nonHarmList)) {
|
List<AdNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
|
||||||
for (AdNonHarmonicResult adNonHarmonicResult : nonHarmList) {
|
if (CollUtil.isNotEmpty(nonHarmList)) {
|
||||||
String standard = "/", test = "/", error = "/", result = "/", errorScope = "/",unit = "";
|
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
||||||
Map<String, String> keyFillMap = new HashMap<>(8);
|
for (AdNonHarmonicResult adNonHarmonicResult : nonHarmList) {
|
||||||
DetectionData tempT = getResultData(adNonHarmonicResult, null, PowerConstant.PHASE_T);
|
Map<String, String> keyFillMap = new HashMap<>(16);
|
||||||
if (Objects.nonNull(tempT) && PowerConstant.DATA_RANGE.contains(tempT.getIsData())) {
|
fillThreePhaseData(adNonHarmonicResult, null, keyFillMap);
|
||||||
standard = PubUtils.doubleRoundStr(4, tempT.getResultData());
|
if(!keyFillMap.get(ItemReportKeyEnum.ERROR_SCOPE.getKey()).equals("/")){
|
||||||
test = PubUtils.doubleRoundStr(4, tempT.getData());
|
keyFillMapList.add(keyFillMap);
|
||||||
error = PubUtils.doubleRoundStr(4, tempT.getErrorData().doubleValue());
|
}
|
||||||
result = tempT.getIsData() == 1 ? "合格" : "不合格";
|
|
||||||
unit = tempT.getUnit();
|
|
||||||
errorScope = tempT.getRadius();
|
|
||||||
}
|
}
|
||||||
keyFillMap.put(ItemReportKeyEnum.STANDARD.getKey(), standard);
|
if(CollUtil.isNotEmpty(keyFillMapList)){
|
||||||
keyFillMap.put(ItemReportKeyEnum.TEST.getKey(), test);
|
// 需要对所有的填充进行按误差范围分组
|
||||||
keyFillMap.put(ItemReportKeyEnum.ERROR.getKey(), error);
|
Map<String, List<Map<String, String>>> errorScoperMap = keyFillMapList.stream()
|
||||||
keyFillMap.put(ItemReportKeyEnum.RESULT.getKey(), result);
|
.collect(Collectors.groupingBy(map -> map.get(ItemReportKeyEnum.ERROR_SCOPE.getKey())));
|
||||||
errorScope = dealErrorScope(errorScope).concat(unit);
|
// 分组后,还需要针对标准值进行一个升序
|
||||||
keyFillMap.put(ItemReportKeyEnum.ERROR_SCOPE.getKey(), errorScope);
|
errorScoperMap.forEach((errorScope, maps) -> {
|
||||||
keyFillMapList.add(keyFillMap);
|
PubUtils.sortByDoubleValue(maps, ItemReportKeyEnum.STANDARD.getKey());
|
||||||
|
});
|
||||||
|
List<Map<String, List<Map<String, String>>>> errorList = new ArrayList<>();
|
||||||
|
errorList.add(errorScoperMap);
|
||||||
|
// 最后赋值返回
|
||||||
|
finalContent.put(affectName, errorList);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.error("生成三相类表格数据失败,结果表数据丢失,请核实。");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 非三相且非暂态,通常只有一个数据,所以直接赋值即可
|
||||||
|
List<Map<String, String>> keyFillMapList = new ArrayList<>();
|
||||||
|
SingleNonHarmParam param = new SingleNonHarmParam(Integer.parseInt(planCode), devId, lineNo, Collections.singletonList(valueType), indexList);
|
||||||
|
List<AdNonHarmonicResult> nonHarmList = adNonHarmonicService.queryByCondition(param);
|
||||||
|
if (CollUtil.isNotEmpty(nonHarmList)) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(CollUtil.isNotEmpty(keyFillMapList)){
|
||||||
|
// 需要对所有填充进行按误差范围分组
|
||||||
|
Map<String, List<Map<String, String>>> errorScoperMap = keyFillMapList.stream()
|
||||||
|
.collect(Collectors.groupingBy(map -> map.get(ItemReportKeyEnum.ERROR_SCOPE.getKey())));
|
||||||
|
// 分组后,还需要针对特征幅值标准值进行一个升序
|
||||||
|
errorScoperMap.forEach((errorScope, maps) -> {
|
||||||
|
PubUtils.sortByDoubleValue(maps, ItemReportKeyEnum.STANDARD.getKey());
|
||||||
|
});
|
||||||
|
List<Map<String, List<Map<String, String>>>> errorList = new ArrayList<>();
|
||||||
|
errorList.add(errorScoperMap);
|
||||||
|
// 最后赋值返回
|
||||||
|
finalContent.put(affectName, errorList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 需要对所有填充进行按误差范围分组
|
|
||||||
Map<String, List<Map<String, String>>> errorScoperMap = keyFillMapList.stream()
|
|
||||||
.collect(Collectors.groupingBy(map -> map.get(ItemReportKeyEnum.ERROR_SCOPE.getKey())));
|
|
||||||
// 分组后,还需要针对特征幅值标准值进行一个升序
|
|
||||||
errorScoperMap.forEach((errorScope, maps) -> {
|
|
||||||
PubUtils.sortByDoubleValue(maps, ItemReportKeyEnum.STANDARD.getKey());
|
|
||||||
});
|
|
||||||
List<Map<String, List<Map<String, String>>>> errorList = new ArrayList<>();
|
|
||||||
errorList.add(errorScoperMap);
|
|
||||||
// 最后赋值返回
|
|
||||||
finalContent.put(affectName, errorList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1341,13 +1103,227 @@ public class ResultServiceImpl implements IResultService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回之前做下总结性判断
|
// 返回之前做下总结性判断
|
||||||
singleTestResult.setQualified(judgeQualified(finalContent));
|
singleTestResult.setQualified(judgeQualified(finalContent));
|
||||||
singleTestResult.setDetail(finalContent);
|
singleTestResult.setDetail(finalContent);
|
||||||
return singleTestResult;
|
return singleTestResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 三相的相关数据处理
|
||||||
|
* 包含:谐波、间谐波、电压、电流、功率、闪变
|
||||||
|
*
|
||||||
|
* @param singleResult 可能是谐波类,也有可能是电压电流,需要区分下结果
|
||||||
|
* @param timeInt 谐波类需要传指定次数
|
||||||
|
* @param keyFillMap 待填充的集合Map
|
||||||
|
*/
|
||||||
|
private void fillThreePhaseData(Object singleResult, Integer timeInt, Map<String, String> keyFillMap) {
|
||||||
|
DetectionData tempA = getResultData(singleResult, timeInt, PowerConstant.PHASE_A);
|
||||||
|
DetectionData tempB = getResultData(singleResult, timeInt, PowerConstant.PHASE_B);
|
||||||
|
DetectionData tempC = getResultData(singleResult, timeInt, PowerConstant.PHASE_C);
|
||||||
|
// 待填充Key
|
||||||
|
String standard = "/", standardA = "/", standardB = "/", standardC = "/",
|
||||||
|
testA = "/", testB = "/", testC = "/",
|
||||||
|
errorA = "/", errorB = "/", errorC = "/",
|
||||||
|
resultA = "/", resultB = "/", resultC = "/", result = "/",
|
||||||
|
errorScope = "/", unit = "";
|
||||||
|
|
||||||
|
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(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 (errorScope.equals("/")) {
|
||||||
|
errorScope = tempB.getRadius();
|
||||||
|
}
|
||||||
|
if (StrUtil.isBlank(unit)) {
|
||||||
|
unit = tempB.getUnit();
|
||||||
|
}
|
||||||
|
if (standard.equals("/")) {
|
||||||
|
standard = 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 (errorScope.equals("/")) {
|
||||||
|
errorScope = tempC.getRadius();
|
||||||
|
}
|
||||||
|
if (StrUtil.isBlank(unit)) {
|
||||||
|
unit = tempC.getUnit();
|
||||||
|
}
|
||||||
|
if (standard.equals("/")) {
|
||||||
|
standard = PubUtils.doubleRoundStr(4, tempC.getResultData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (standardA.equals(standardB) && standardA.equals(standardC)) {
|
||||||
|
standard = standardA;
|
||||||
|
}
|
||||||
|
// 标准值
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.STANDARD.getKey(), standard);
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.STANDARD_A.getKey(), standardA);
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.STANDARD_B.getKey(), standardB);
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.STANDARD_C.getKey(), standardC);
|
||||||
|
// 测试值
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.TEST_A.getKey(), testA);
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.TEST_B.getKey(), testB);
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.TEST_C.getKey(), testC);
|
||||||
|
// 误差值
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.ERROR_A.getKey(), errorA);
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.ERROR_B.getKey(), errorB);
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.ERROR_C.getKey(), errorC);
|
||||||
|
// 结果
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.RESULT_A.getKey(), resultA);
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.RESULT_B.getKey(), resultB);
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.RESULT_C.getKey(), resultC);
|
||||||
|
if (resultA.equals("不合格") || resultB.equals("不合格") || resultC.equals("不合格")) {
|
||||||
|
result = "不合格";
|
||||||
|
} else if (!resultA.equals("/") || !resultB.equals("/") || !resultC.equals("/")) {
|
||||||
|
result = "合格";
|
||||||
|
}
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.RESULT.getKey(), result);
|
||||||
|
errorScope = dealErrorScope(errorScope).concat(unit);
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.ERROR_SCOPE.getKey(), errorScope);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T相的相关数据处理,非暂态数据
|
||||||
|
* 包含:三相电压/电流不平衡度、频率,其中三相电压/电流实际ABC中存了正序/负序/零序电压
|
||||||
|
*
|
||||||
|
* @param singleResult 可能是谐波类,也有可能是电压电流,需要区分下结果
|
||||||
|
* @param timeInt 谐波类需要传指定次数
|
||||||
|
* @param keyFillMap 待填充的集合Map
|
||||||
|
*/
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.STANDARD.getKey(), standard);
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.TEST.getKey(), test);
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.ERROR.getKey(), error);
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.RESULT.getKey(), result);
|
||||||
|
errorScope = dealErrorScope(errorScope).concat(unit);
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.ERROR_SCOPE.getKey(), errorScope);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 针对暂态的数据填充
|
||||||
|
*
|
||||||
|
* @param nonHarmList 暂态的结果集
|
||||||
|
* @param keyFillMap 待填充的集合Map
|
||||||
|
* @param tableKeys 模板表格中的key
|
||||||
|
*/
|
||||||
|
private void fillVoltagePhaseData(List<AdNonHarmonicResult> nonHarmList, Map<String, String> keyFillMap, List<String> tableKeys) {
|
||||||
|
String standardMag = "/", standardDur = "/",
|
||||||
|
testMag = "/", testDur = "/",
|
||||||
|
errorMag = "/", errorDur = "/",
|
||||||
|
resultMag = "/", resultDur = "/", result,
|
||||||
|
errorScope, errorScopeMag = "/", errorScopeDur = "/",
|
||||||
|
unitMag = "", unitDur = "";
|
||||||
|
for (AdNonHarmonicResult adNonHarmonicResult : nonHarmList) {
|
||||||
|
DetectionData tempT = getResultData(adNonHarmonicResult, null, PowerConstant.PHASE_T);
|
||||||
|
// 需要判断adNonHarmonicResult是特征幅值还是持续时间
|
||||||
|
String adType = adNonHarmonicResult.getAdType();
|
||||||
|
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 ? "合格" : "不合格";
|
||||||
|
unitMag = tempT.getUnit();
|
||||||
|
errorScopeMag = tempT.getRadius();
|
||||||
|
}
|
||||||
|
} else if (temp.getCode().equalsIgnoreCase("DUR")) {
|
||||||
|
// 持续时间,需要注意时间单位处理,默认是秒
|
||||||
|
String timeUnit = "s";
|
||||||
|
for (String tableKey : tableKeys) {
|
||||||
|
if (tableKey.contains(ItemReportKeyEnum.STANDARD_DUR.getKey())) {
|
||||||
|
//截取单位
|
||||||
|
String[] tempStr = tableKey.split(StrPool.UNDERLINE);
|
||||||
|
if (tempStr.length > 1) {
|
||||||
|
if (tempStr[1].equalsIgnoreCase("ms")) {
|
||||||
|
timeUnit = "ms";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 (timeUnit.equalsIgnoreCase("ms")) {
|
||||||
|
// 如果是ms,上述的一些数据需要重新处理
|
||||||
|
if (!standardDur.equalsIgnoreCase("/")) {
|
||||||
|
standardDur = PubUtils.doubleRoundStr(4, Double.parseDouble(standardDur) * 1000);
|
||||||
|
}
|
||||||
|
if (!testDur.equalsIgnoreCase("/")) {
|
||||||
|
testDur = PubUtils.doubleRoundStr(4, Double.parseDouble(testDur) * 1000);
|
||||||
|
}
|
||||||
|
if (!errorDur.equalsIgnoreCase("/")) {
|
||||||
|
errorDur = PubUtils.doubleRoundStr(4, Double.parseDouble(errorDur) * 1000);
|
||||||
|
}
|
||||||
|
if (!errorScopeDur.equalsIgnoreCase("/")) {
|
||||||
|
if (errorScopeDur.contains("~")) {
|
||||||
|
String[] tempStr = errorScopeDur.split("~");
|
||||||
|
errorScopeDur = PubUtils.doubleRoundStr(0, Double.parseDouble(tempStr[0]) * 1000).concat("~").concat(PubUtils.doubleRoundStr(0, Double.parseDouble(tempStr[1]) * 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unitDur = "ms";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
errorScopeMag = dealErrorScope(errorScopeMag).concat(unitMag);
|
||||||
|
errorScopeDur = dealErrorScope(errorScopeDur).concat(unitDur);
|
||||||
|
|
||||||
|
errorScope = "特征幅值:".concat(errorScopeMag).concat(StrPool.COMMA).concat("持续时间:").concat(errorScopeDur);
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.ERROR_SCOPE.getKey(), errorScope);
|
||||||
|
// 标准值
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.STANDARD_MAG.getKey(), standardMag);
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.STANDARD_DUR.getKey(), standardDur);
|
||||||
|
// 测试值
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.TEST_MAG.getKey(), testMag);
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.TEST_DUR.getKey(), testDur);
|
||||||
|
// 误差
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.ERROR_MAG.getKey(), errorMag);
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.ERROR_DUR.getKey(), errorDur);
|
||||||
|
// 结果
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.RESULT_MAG.getKey(), resultMag);
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.RESULT_DUR.getKey(), resultDur);
|
||||||
|
// 综合结果
|
||||||
|
result = resultMag;
|
||||||
|
if (!resultDur.equals("/") && result.equals("合格")) {
|
||||||
|
if (resultDur.equals("不合格")) {
|
||||||
|
result = "不合格";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
keyFillMap.put(ItemReportKeyEnum.RESULT.getKey(), result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理下误差范围,如果正负数一致时调整为±的形式
|
* 处理下误差范围,如果正负数一致时调整为±的形式
|
||||||
* 数据库中一般形式为:-0.1155~0.1155
|
* 数据库中一般形式为:-0.1155~0.1155
|
||||||
|
|||||||
Reference in New Issue
Block a user