diff --git a/detection/src/main/java/com/njcn/gather/monitor/service/IPqMonitorService.java b/detection/src/main/java/com/njcn/gather/monitor/service/IPqMonitorService.java index 869ccf8b..388f52f2 100644 --- a/detection/src/main/java/com/njcn/gather/monitor/service/IPqMonitorService.java +++ b/detection/src/main/java/com/njcn/gather/monitor/service/IPqMonitorService.java @@ -118,4 +118,11 @@ public interface IPqMonitorService extends IService { * @return */ boolean removeByDevId(String devId); + + /** + * 根据被检设备id和监测点编号获取监测点信息 + * @param id 被检设备id + * @param monitorNum 监测点编号 + */ + PqMonitor getByDevAndNum(String id, int monitorNum); } diff --git a/detection/src/main/java/com/njcn/gather/monitor/service/impl/PqMonitorServiceImpl.java b/detection/src/main/java/com/njcn/gather/monitor/service/impl/PqMonitorServiceImpl.java index dc3f56f2..82526229 100644 --- a/detection/src/main/java/com/njcn/gather/monitor/service/impl/PqMonitorServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/monitor/service/impl/PqMonitorServiceImpl.java @@ -432,4 +432,16 @@ public class PqMonitorServiceImpl extends ServiceImpl wrapper = new QueryWrapper<>(); + wrapper.eq("pq_monitor.Dev_Id", devId) + .eq("pq_monitor.Num", monitorNum); + List pqMonitors = this.list(wrapper); + if(CollUtil.isNotEmpty(pqMonitors)){ + return pqMonitors.get(0); + } + return null; + } } 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 a1bce574..3f2e278b 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 @@ -39,6 +39,8 @@ import com.njcn.gather.device.service.IPqDevService; import com.njcn.gather.device.service.IPqDevSubService; import com.njcn.gather.err.pojo.po.PqErrSys; import com.njcn.gather.err.service.IPqErrSysService; +import com.njcn.gather.monitor.pojo.po.PqMonitor; +import com.njcn.gather.monitor.service.IPqMonitorService; import com.njcn.gather.plan.pojo.enums.DataSourceEnum; import com.njcn.gather.plan.pojo.enums.PlanReportStateEnum; import com.njcn.gather.plan.pojo.po.AdPlan; @@ -179,6 +181,7 @@ public class PqReportServiceImpl extends ServiceImpl i private final ISysUserService sysUserService; private final IPqErrSysService pqErrSysService; private final IAdPlanTestConfigService adPlanTestConfigService; + private final IPqMonitorService pqMonitorService; @Resource private RestTemplateUtil restTemplateUtil; @@ -820,6 +823,13 @@ public class PqReportServiceImpl extends ServiceImpl i pqDevVO.getGdName() != null ? pqDevVO.getGdName() : "未知供电公司", pqDevVO.getSubName() != null ? pqDevVO.getSubName() : "未知电站", pqDevVO.getName() != null ? pqDevVO.getName() : "未知设备"); + // 判断是否需要在报告上输出水印 + String leader = baseModelDataMap.get(BaseReportKeyEnum.AUDIT_BY.getKey()); + String loginName = RequestUtil.getLoginNameByToken(); + SysUser user = sysUserService.getUserByLoginName(loginName); + if (!leader.equals(user.getName())) { + System.out.println("当前用户是审核人,需要添加水印为:非正式"); + } Docx4jUtil.cleanBlankPagesAndRedundantPageBreaks(baseModelDocument); baseModelDocument.save(new File(dirPath.concat(File.separator).concat(fileName))); this.updateDevAndPlanState(devId, devReportParam.getPlanId()); @@ -1157,7 +1167,7 @@ public class PqReportServiceImpl extends ServiceImpl i // 插入回路号前,先换个页 todoInsertList.add(Docx4jUtil.createPageBreakParagraph()); // 回路标题 - todoInsertList.add(getContrastLineTitle(contentMap, monitorNum, stepIndex, factory)); + todoInsertList.add(getContrastLineTitle(contentMap, monitorNum, stepIndex, factory, pqDevVO)); int scriptIndex = 1; for (ContrastTestResult contrastTestResult : contrastTestResults) { // 比如电压 V @@ -2016,7 +2026,7 @@ public class PqReportServiceImpl extends ServiceImpl i // 委托方 String delegate = pqDevVO.getDelegate(); if (StrUtil.isNotBlank(delegate)) { - DictData delegateDictData = dictDataService.getDictDataById(pqDevVO.getManufacturer()); + DictData delegateDictData = dictDataService.getDictDataById(pqDevVO.getDelegate()); if (ObjectUtil.isNotNull(delegateDictData)) { baseModelMap.put(BaseReportKeyEnum.DELEGATE.getKey(), delegateDictData.getName()); } else { @@ -2392,16 +2402,21 @@ public class PqReportServiceImpl extends ServiceImpl i /** * 创建回路标题到报告中 */ - private P getContrastLineTitle(Map> contentMap, int monitorNum, int index, ObjectFactory factory) { + private P getContrastLineTitle(Map> contentMap, int monitorNum, int index, ObjectFactory factory, PqDevVO pqDevVO) { + PqMonitor pqMonitor = pqMonitorService.getByDevAndNum(pqDevVO.getId(), monitorNum); + String monitorInfoName = ""; + if (StrUtil.isNotBlank(pqDevVO.getSubName()) && Objects.nonNull(pqMonitor)) { + monitorInfoName = "(" + pqDevVO.getSubName() + "-" + pqMonitor.getName() + ")"; + } List headingContents = contentMap.get(PowerIndexEnum.LINE_TITLE.getKey()); // 如果contentMap中有指定内容,创建大纲级别为2的标题 if (CollUtil.isNotEmpty(headingContents)) { - return Docx4jUtil.createTitle(factory, 2, index + ".测量回路" + monitorNum, + return Docx4jUtil.createTitle(factory, 2, index + ".测量回路" + monitorNum + monitorInfoName, "SimSun", 30, true); } // 没有模板配置时,创建默认样式段落 P titleParagraph = factory.createP(); - Docx4jUtil.createTitle(factory, titleParagraph, "测量回路" + monitorNum, + Docx4jUtil.createTitle(factory, titleParagraph, "测量回路" + monitorNum + monitorInfoName, 28, true); return titleParagraph; } diff --git a/tools/report-generator/src/main/java/com/njcn/gather/tools/report/util/Docx4jUtil.java b/tools/report-generator/src/main/java/com/njcn/gather/tools/report/util/Docx4jUtil.java index 5c3f48dc..5dedcbe1 100644 --- a/tools/report-generator/src/main/java/com/njcn/gather/tools/report/util/Docx4jUtil.java +++ b/tools/report-generator/src/main/java/com/njcn/gather/tools/report/util/Docx4jUtil.java @@ -5,6 +5,7 @@ import cn.hutool.core.text.StrPool; import cn.hutool.core.util.StrUtil; import lombok.Getter; import lombok.Setter; +import lombok.extern.slf4j.Slf4j; import org.docx4j.XmlUtils; import org.docx4j.openpackaging.packages.WordprocessingMLPackage; import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart; @@ -27,6 +28,7 @@ import java.util.Map; * @version 1.0 * @data 2025/3/26 13:47 */ +@Slf4j public class Docx4jUtil { /**