From 7abcaefeb1b59c08ca80cba571d96c13aaefdc12 Mon Sep 17 00:00:00 2001 From: hongawen <83944980@qq.com> Date: Thu, 27 Nov 2025 20:03:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9B=9E=E8=B7=AF=E9=A2=9D?= =?UTF-8?q?=E5=AE=9A=E7=94=B5=E6=B5=81=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/PqReportServiceImpl.java | 49 +++++++++++++++++-- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java b/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java index 40a2f0c7..08e9fd3e 100644 --- a/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/report/service/impl/PqReportServiceImpl.java @@ -1167,6 +1167,7 @@ public class PqReportServiceImpl extends ServiceImpl i Integer monitorNum = next.getKey(); // 线路下的指标数据 List contrastTestResults = next.getValue(); + PqMonitor pqMonitor = pqMonitorService.getByDevAndNum(pqDevVO.getId(), monitorNum); // 插入回路号前,先换个页 todoInsertList.add(Docx4jUtil.createPageBreakParagraph()); // 回路标题 @@ -1181,7 +1182,7 @@ public class PqReportServiceImpl extends ServiceImpl i // 根据code获取对应需要填充的内容 List tempContent = contentMap.get(scriptCode); // 需要区分下谐波类和非谐波类 - List tempList = fillContentInTemplateContrast(tempContent, factory, contrastTestResult); + List tempList = fillContentInTemplateContrast(tempContent, factory, contrastTestResult, pqMonitor); todoInsertList.addAll(tempList); scriptIndex++; } @@ -1637,7 +1638,7 @@ public class PqReportServiceImpl extends ServiceImpl i * * @return */ - private List fillContentInTemplateContrast(List tempContent, ObjectFactory factory, ContrastTestResult contrastTestResult) { + private List fillContentInTemplateContrast(List tempContent, ObjectFactory factory, ContrastTestResult contrastTestResult, PqMonitor pqMonitor) { List todoInsertList = new ArrayList<>(); Docx4jUtil.HeadingContent headingContent = tempContent.get(0); List tableKeys = Docx4jUtil.getTableFillKeys(tempContent); @@ -1751,9 +1752,47 @@ public class PqReportServiceImpl extends ServiceImpl i // 纵向表格暂不考虑 } - // 如果存在特殊说明,在表格后添加一个段落 - if (StrUtil.isNotBlank(contrastTestResult.getSpecialCase())) { - P specialCaseP = Docx4jUtil.createSpecialCaseParagraph(factory, contrastTestResult.getSpecialCase()); + StringBuilder description = new StringBuilder(); + if (contrastTestResult.getScriptCode().equalsIgnoreCase("I")) { + // 获取该通道的额定电流 + String ct = pqMonitor.getCt(); + // 理论上ct是 xxx:xxx的格式。比如10:1,100:5 + if (ct.indexOf(":") > 0) { + String[] ctArray = ct.split(":"); + description.append("注:当前回路额定电流为:").append(ctArray[1]).append("A。"); + } + } else if (contrastTestResult.getScriptCode().equalsIgnoreCase("V")) { + // 获取该通道的额定电压 + String pt = pqMonitor.getPt(); + // 理论上pt是 xxx:xxx的格式。比如380:380,10000:100 + if (pt.indexOf(":") > 0) { + String[] ptArray = pt.split(":"); + // 电压需要特殊处理下,处理为相电压值 + String voltage = ptArray[1]; + if (voltage.equalsIgnoreCase("100")) { + voltage = "57.74"; + } else if (voltage.equalsIgnoreCase("380")) { + voltage = "220"; + } else { + // 其他场景下就除以根号3 + double result = Double.parseDouble(voltage) / Math.sqrt(3); + voltage = doubleRound(2, result); + } + description.append("注:当前回路额定电流为:").append(voltage).append("V。"); + } + } + + // 如果存在特殊说明,在表格后添加一个段落 如果有电压和电流需要把额定电压和电流标注进来 pqMonitor + if (StrUtil.isNotBlank(contrastTestResult.getSpecialCase()) || StrUtil.isNotBlank(description.toString())) { + P specialCaseP; + if (StrUtil.isNotBlank(description.toString())) { + if (StrUtil.isNotBlank(contrastTestResult.getSpecialCase())) { + description.append(contrastTestResult.getSpecialCase().replace("注:", "")); + } + specialCaseP = Docx4jUtil.createSpecialCaseParagraph(factory, description.toString()); + } else { + specialCaseP = Docx4jUtil.createSpecialCaseParagraph(factory, contrastTestResult.getSpecialCase()); + } todoInsertList.add(specialCaseP); } }