diff --git a/detection/src/main/java/com/njcn/gather/device/pojo/po/PqDev.java b/detection/src/main/java/com/njcn/gather/device/pojo/po/PqDev.java index 98a9a007..8b137ff4 100644 --- a/detection/src/main/java/com/njcn/gather/device/pojo/po/PqDev.java +++ b/detection/src/main/java/com/njcn/gather/device/pojo/po/PqDev.java @@ -195,6 +195,9 @@ public class PqDev extends BaseEntity implements Serializable { @TableField("Check_Time") private LocalDateTime checkTime; + @TableField("Check_By") + private String checkBy; + @TableField("Preinvestment_Plan") private String preinvestmentPlan; diff --git a/detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java b/detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java index f7cda0ba..eca0de80 100644 --- a/detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/device/service/impl/PqDevServiceImpl.java @@ -43,6 +43,7 @@ import com.njcn.gather.type.service.IDevTypeService; import com.njcn.web.factory.PageFactory; import com.njcn.web.utils.ExcelUtil; import com.njcn.web.utils.PoiUtil; +import com.njcn.web.utils.RequestUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; @@ -515,6 +516,7 @@ public class PqDevServiceImpl extends ServiceImpl implements .set(PqDev::getReCheckNum, i) .set(PqDev::getCheckState, checkState) .set(PqDev::getCheckResult, result.get(pqDev.getId())) + .set(PqDev::getCheckBy, RequestUtil.getUserName()) .set(PqDev::getCheckTime, LocalDateTime.now()) .set(PqDev::getReportState, DevReportStateEnum.NOT_GENERATED.getValue()) .eq(PqDev::getId, pqDev.getId())); diff --git a/detection/src/main/java/com/njcn/gather/plan/mapper/AdPlanMapper.java b/detection/src/main/java/com/njcn/gather/plan/mapper/AdPlanMapper.java index 1ecbdf81..f6fab33c 100644 --- a/detection/src/main/java/com/njcn/gather/plan/mapper/AdPlanMapper.java +++ b/detection/src/main/java/com/njcn/gather/plan/mapper/AdPlanMapper.java @@ -3,6 +3,7 @@ package com.njcn.gather.plan.mapper; import com.github.yulichang.base.MPJBaseMapper; import com.njcn.gather.plan.pojo.po.AdPlan; import com.njcn.gather.report.pojo.po.PqReport; +import org.apache.ibatis.annotations.Param; /** * @author caozehui @@ -17,7 +18,7 @@ public interface AdPlanMapper extends MPJBaseMapper { * @param version * @return */ - String getReportIdByNameAndVersion(String name, String version); + String getReportIdByNameAndVersion(@Param("name") String name, @Param("version") String version); /** * 根据id获取报告模板 diff --git a/detection/src/main/java/com/njcn/gather/plan/pojo/param/AdPlanParam.java b/detection/src/main/java/com/njcn/gather/plan/pojo/param/AdPlanParam.java index 4e0d480f..0073f95b 100644 --- a/detection/src/main/java/com/njcn/gather/plan/pojo/param/AdPlanParam.java +++ b/detection/src/main/java/com/njcn/gather/plan/pojo/param/AdPlanParam.java @@ -66,10 +66,10 @@ public class AdPlanParam { private Integer associateReport; @ApiModelProperty(value = "报告模板名称") - private String reportName; + private String reportTemplateName; @ApiModelProperty(value = "报告模板版本") - private String reportVersion; + private String reportTemplateVersion; /** * 分页查询实体 diff --git a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java index 51f6aebb..06ffea64 100644 --- a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java @@ -149,7 +149,7 @@ public class AdPlanServiceImpl extends ServiceImpl impleme adPlan.setCode(this.generateCode()); if (param.getAssociateReport() == 1) { - String reportId = this.baseMapper.getReportIdByNameAndVersion(param.getReportName(), param.getReportVersion()); + String reportId = this.baseMapper.getReportIdByNameAndVersion(param.getReportTemplateName(), param.getReportTemplateVersion()); if (StrUtil.isNotBlank(reportId)) { adPlan.setReportTemplateId(reportId); } @@ -180,7 +180,7 @@ public class AdPlanServiceImpl extends ServiceImpl impleme AdPlan plan2 = new AdPlan(); if (param.getAssociateReport() == 1) { - String reportId = this.baseMapper.getReportIdByNameAndVersion(param.getReportName(), param.getReportVersion()); + String reportId = this.baseMapper.getReportIdByNameAndVersion(param.getReportTemplateName(), param.getReportTemplateVersion()); if (StrUtil.isNotBlank(reportId)) { plan2.setReportTemplateId(reportId); } @@ -200,7 +200,7 @@ public class AdPlanServiceImpl extends ServiceImpl impleme throw new BusinessException(PlanResponseEnum.CANNOT_CHANGE_REPORT_WHEN_CHECKING); } if (param.getAssociateReport() == 1) { - String reportId = this.baseMapper.getReportIdByNameAndVersion(param.getReportName(), param.getReportVersion()); + String reportId = this.baseMapper.getReportIdByNameAndVersion(param.getReportTemplateName(), param.getReportTemplateVersion()); if (!reportId.equals(plan1.getReportTemplateId())) { throw new BusinessException(PlanResponseEnum.CANNOT_CHANGE_REPORT_WHEN_CHECKING); } diff --git a/detection/src/main/java/com/njcn/gather/report/pojo/DevReportParam.java b/detection/src/main/java/com/njcn/gather/report/pojo/DevReportParam.java index 5604d63b..e09e8769 100644 --- a/detection/src/main/java/com/njcn/gather/report/pojo/DevReportParam.java +++ b/detection/src/main/java/com/njcn/gather/report/pojo/DevReportParam.java @@ -19,6 +19,16 @@ public class DevReportParam implements Serializable { */ private String planId; + /** + * 计划所对应的表code + */ + private String planCode; + + /** + * 脚本ID + */ + private String scriptId; + /** * 被检设备ID */ diff --git a/detection/src/main/java/com/njcn/gather/report/pojo/enums/ReportResponseEnum.java b/detection/src/main/java/com/njcn/gather/report/pojo/enums/ReportResponseEnum.java index 29cd309f..691bff7c 100644 --- a/detection/src/main/java/com/njcn/gather/report/pojo/enums/ReportResponseEnum.java +++ b/detection/src/main/java/com/njcn/gather/report/pojo/enums/ReportResponseEnum.java @@ -14,7 +14,11 @@ public enum ReportResponseEnum { REPORT_REPEATED("A012003", "已存在相同版本、相同名称的报告"), FILE_NOT_NULL("A012004", "上传的文件不能为空"), DELETE_BOUND_REPORT_ERROR("A012005", "已被计划绑定模板的报告不能删除"), - FILE_NAME_SAME_ERROR("A012006", "文件名不能相同"); + FILE_NAME_SAME_ERROR("A012006", "文件名不能相同"), + DEVICE_NOT_EXIST("A012007", "请检查装置是否存在!"), + DEVICE_TYPE_NOT_EXIST("A012008", "设备类型缺失,请联系管理员!"), + REPORT_TEMPLATE_NOT_EXIST("A012009", "报告模板缺失,请联系管理员!"), + NO_CHECK_DATA("A012010", "没有检测数据,无法生成报告!"); private String code; private String message; diff --git a/detection/src/main/java/com/njcn/gather/report/pojo/po/CellEntity.java b/detection/src/main/java/com/njcn/gather/report/pojo/po/CellEntity.java new file mode 100644 index 00000000..c53cbfd2 --- /dev/null +++ b/detection/src/main/java/com/njcn/gather/report/pojo/po/CellEntity.java @@ -0,0 +1,22 @@ +package com.njcn.gather.report.pojo.po; + +import lombok.AllArgsConstructor; +import lombok.Data; + +/** + * @author caozehui + * @data 2025-03-21 + */ +@Data +@AllArgsConstructor +public class CellEntity { + + private String cellValue; + + private String width; + + private int rowSpan; + + private int colSpan; + +} diff --git a/detection/src/main/java/com/njcn/gather/report/pojo/vo/PqReportVO.java b/detection/src/main/java/com/njcn/gather/report/pojo/vo/PqReportVO.java index 539249a6..de171365 100644 --- a/detection/src/main/java/com/njcn/gather/report/pojo/vo/PqReportVO.java +++ b/detection/src/main/java/com/njcn/gather/report/pojo/vo/PqReportVO.java @@ -46,7 +46,7 @@ public class PqReportVO { @Data public static class FileVO{ - private String fileName; + private String name; private String url; } 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 a86b8753..7317a375 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 @@ -19,6 +19,7 @@ import com.njcn.gather.detection.pojo.vo.DetectionData; import com.njcn.gather.device.pojo.enums.DevReportStateEnum; import com.njcn.gather.device.pojo.vo.PqDevVO; import com.njcn.gather.device.service.IPqDevService; +import com.njcn.gather.err.service.IPqErrSysDtlsService; import com.njcn.gather.plan.pojo.enums.PlanReportStateEnum; import com.njcn.gather.plan.pojo.po.AdPlan; import com.njcn.gather.plan.service.IAdPlanService; @@ -26,28 +27,37 @@ import com.njcn.gather.report.mapper.PqReportMapper; import com.njcn.gather.report.pojo.DevReportParam; import com.njcn.gather.report.pojo.enums.ReportResponseEnum; import com.njcn.gather.report.pojo.param.ReportParam; +import com.njcn.gather.report.pojo.po.CellEntity; import com.njcn.gather.report.pojo.po.PqReport; import com.njcn.gather.report.pojo.vo.PqReportVO; import com.njcn.gather.report.service.IPqReportService; import com.njcn.gather.report.utils.WordUtil; +import com.njcn.gather.result.pojo.param.ResultParam; +import com.njcn.gather.result.pojo.vo.ResultVO; +import com.njcn.gather.result.service.IResultService; import com.njcn.gather.script.pojo.po.PqScriptCheckData; import com.njcn.gather.script.pojo.po.PqScriptDtls; import com.njcn.gather.script.service.IPqScriptCheckDataService; import com.njcn.gather.script.service.IPqScriptDtlsService; import com.njcn.gather.storage.pojo.param.SingleNonHarmParam; +import com.njcn.gather.storage.pojo.po.AdBaseResult; import com.njcn.gather.storage.pojo.po.AdHarmonicResult; import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult; +import com.njcn.gather.storage.pojo.vo.RawResultDataVO; import com.njcn.gather.storage.service.AdHarmonicService; import com.njcn.gather.storage.service.AdNonHarmonicService; import com.njcn.gather.system.dictionary.pojo.po.DictData; +import com.njcn.gather.system.dictionary.pojo.po.DictTree; import com.njcn.gather.system.dictionary.service.IDictDataService; +import com.njcn.gather.system.dictionary.service.IDictTreeService; +import com.njcn.gather.system.pojo.enums.DicDataEnum; import com.njcn.gather.type.pojo.po.DevType; import com.njcn.gather.type.service.IDevTypeService; import com.njcn.web.factory.PageFactory; -import com.njcn.web.utils.RequestUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.poi.xwpf.usermodel.XWPFDocument; +import org.apache.poi.xwpf.usermodel.*; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.ClassPathResource; @@ -65,6 +75,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * @author makejava @@ -75,6 +86,7 @@ import java.util.stream.Collectors; @RequiredArgsConstructor public class PqReportServiceImpl extends ServiceImpl implements IPqReportService { + private static final int TWIPS_PER_INCH = 1440; @Value("${report.template:D:\\template}") private String templatePath; @@ -98,6 +110,12 @@ public class PqReportServiceImpl extends ServiceImpl i private final IDevTypeService devTypeService; + private final IDictTreeService dictTreeService; + + private final IPqErrSysDtlsService pqErrSysDtlsService; + + private final IResultService resultService; + @Override public Page list(ReportParam.QueryParam queryParam) { QueryWrapper wrapper = new QueryWrapper<>(); @@ -111,12 +129,12 @@ public class PqReportServiceImpl extends ServiceImpl i BeanUtils.copyProperties(pqReport, pqReportVO); PqReportVO.FileVO baseFileVo = new PqReportVO.FileVO(); - baseFileVo.setFileName(pqReport.getBasePath().substring(pqReport.getBasePath().lastIndexOf(File.separator) + 1)); + baseFileVo.setName(pqReport.getBasePath().substring(pqReport.getBasePath().lastIndexOf(File.separator) + 1)); baseFileVo.setUrl(pqReport.getBasePath()); pqReportVO.setBaseFileVO(baseFileVo); PqReportVO.FileVO detailFileVo = new PqReportVO.FileVO(); - detailFileVo.setFileName(pqReport.getBasePath().substring(pqReport.getBasePath().lastIndexOf(File.separator) + 1)); + detailFileVo.setName(pqReport.getBasePath().substring(pqReport.getBasePath().lastIndexOf(File.separator) + 1)); detailFileVo.setUrl(pqReport.getBasePath()); pqReportVO.setDetailFileVO(detailFileVo); @@ -138,12 +156,12 @@ public class PqReportServiceImpl extends ServiceImpl i BeanUtils.copyProperties(pqReport, pqReportVO); PqReportVO.FileVO baseFileVo = new PqReportVO.FileVO(); - baseFileVo.setFileName(pqReport.getBasePath().substring(pqReport.getBasePath().lastIndexOf(File.separator) + 1)); + baseFileVo.setName(pqReport.getBasePath().substring(pqReport.getBasePath().lastIndexOf(File.separator) + 1)); baseFileVo.setUrl(pqReport.getBasePath()); pqReportVO.setBaseFileVO(baseFileVo); PqReportVO.FileVO detailFileVo = new PqReportVO.FileVO(); - detailFileVo.setFileName(pqReport.getDetailPath().substring(pqReport.getDetailPath().lastIndexOf(File.separator) + 1)); + detailFileVo.setName(pqReport.getDetailPath().substring(pqReport.getDetailPath().lastIndexOf(File.separator) + 1)); detailFileVo.setUrl(pqReport.getDetailPath()); pqReportVO.setDetailFileVO(detailFileVo); @@ -159,7 +177,7 @@ public class PqReportServiceImpl extends ServiceImpl i pqReport.setState(DataStateEnum.ENABLE.getCode()); // 上传文件 - this.uploadFile(reportParam, pqReport); + this.uploadFile(reportParam, pqReport, true); return this.save(pqReport); } @@ -171,7 +189,7 @@ public class PqReportServiceImpl extends ServiceImpl i BeanUtils.copyProperties(reportParam, pqReport); // 上传文件 - this.uploadFile(reportParam, pqReport); + this.uploadFile(reportParam, pqReport, false); return this.updateById(pqReport); } @@ -193,7 +211,7 @@ public class PqReportServiceImpl extends ServiceImpl i @Override public List listAllName() { List result = this.lambdaQuery() - .eq(PqReport::getState, DataStateEnum.ENABLE.getCode()).list().stream().map(PqReport::getName).collect(Collectors.toList()); + .eq(PqReport::getState, DataStateEnum.ENABLE.getCode()).list().stream().map(PqReport::getName).distinct().collect(Collectors.toList()); return result; } @@ -210,8 +228,9 @@ public class PqReportServiceImpl extends ServiceImpl i * * @param reportParam * @param pqReport + * @param isAdd */ - private void uploadFile(ReportParam reportParam, PqReport pqReport) { + private void uploadFile(ReportParam reportParam, PqReport pqReport, Boolean isAdd) { String uploadDir = templatePath + File.separator + reportParam.getName() + File.separator + reportParam.getVersion() + File.separator; //校验文件后缀 @@ -268,7 +287,9 @@ public class PqReportServiceImpl extends ServiceImpl i throw new BusinessException(ReportResponseEnum.FILE_UPLOAD_FAILED); } } else { - throw new BusinessException(ReportResponseEnum.FILE_NOT_NULL); + if (isAdd) { + throw new BusinessException(ReportResponseEnum.FILE_NOT_NULL); + } } } @@ -306,7 +327,7 @@ public class PqReportServiceImpl extends ServiceImpl i @Override public void generateReport(DevReportParam devReportParam) { AdPlan plan = adPlanService.getById(devReportParam.getPlanId()); - if (ObjectUtil.isNotNull(plan.getReportTemplateId())) { + if (StrUtil.isNotBlank(plan.getReportTemplateId())) { this.generateReportByPlan(plan, devReportParam); } else { // 根据设备类型找到报告模板 @@ -364,16 +385,16 @@ public class PqReportServiceImpl extends ServiceImpl i // 根据设备类型找到报告模板 PqDevVO pqDevVO = iPqDevService.getPqDevById(devReportParam.getDevId()); if (Objects.isNull(pqDevVO)) { - throw new BusinessException("请检查装置是否存在!"); + throw new BusinessException(ReportResponseEnum.DEVICE_NOT_EXIST); } // 获取设备型号 DevType devType = devTypeService.getById(pqDevVO.getDevType()); if (Objects.isNull(devType)) { - throw new BusinessException("设备类型缺失,请联系管理员!"); + throw new BusinessException(ReportResponseEnum.DEVICE_TYPE_NOT_EXIST); } - PqReport report = this.lambdaQuery().eq(PqReport::getId, plan.getAssociateReport()).eq(PqReport::getState, DataStateEnum.ENABLE.getCode()).one(); + PqReport report = this.lambdaQuery().eq(PqReport::getId, plan.getReportTemplateId()).eq(PqReport::getState, DataStateEnum.ENABLE.getCode()).one(); if (Objects.isNull(report)) { - throw new BusinessException("报告模板缺失,请联系管理员!"); + throw new BusinessException(ReportResponseEnum.REPORT_TEMPLATE_NOT_EXIST); } FileSystemResource resource = new FileSystemResource(report.getBasePath()); @@ -383,7 +404,7 @@ public class PqReportServiceImpl extends ServiceImpl i // 处理基础模版中的信息 dealBaseModel(baseModelDocument, pqDevVO, devType); // 处理数据页中的信息 - dealDataModel(baseModelDocument, devReportParam, pqDevVO); + dealDataModelZJ(baseModelDocument, devReportParam, pqDevVO); // 处理需要输出的目录地址 基础路径+设备类型+装置编号.docx // 最终文件输出的路径 String dirPath = reportPath.concat(File.separator).concat(devType.getName()); @@ -422,7 +443,6 @@ public class PqReportServiceImpl extends ServiceImpl i adPlanService.update(updateWrapper); } - @Override public void downloadReport(DevReportParam devReportParam, HttpServletResponse response) { PqDevVO pqDevVO = iPqDevService.getPqDevById(devReportParam.getDevId()); @@ -476,9 +496,10 @@ public class PqReportServiceImpl extends ServiceImpl i Map baseModelMap = new HashMap<>(16); // 获取设备型号 baseModelMap.put("${devType}", devType.getName()); + baseModelMap.put("${device_type}", devType.getName()); // 调试人员,todo... 待咨询曹泽辉如何获取当前用户信息,目前先写死 - String userName = RequestUtil.getUserName(); - baseModelMap.put("${userName}", userName); + //String userName = RequestUtil.getUserName(); + baseModelMap.put("${userName}", pqDevVO.getCheckBy()); // 调试日期 if (pqDevVO.getCheckTime() != null) { baseModelMap.put("${testDate}", DateUtil.format(pqDevVO.getCheckTime(), DatePattern.CHINESE_DATE_PATTERN)); @@ -503,6 +524,17 @@ public class PqReportServiceImpl extends ServiceImpl i baseModelMap.put("${count}", pqDevVO.getDevChns().toString()); + DictData dictData = dictDataService.getDictDataById(pqDevVO.getManufacturer()); + if (ObjectUtil.isNotNull(dictData)) { + baseModelMap.put("${manufacturer}", dictData.getName()); + } else { + baseModelMap.put("${manufacturer}", "未知"); + } + baseModelMap.put("${sample_id}", pqDevVO.getSampleId()); + baseModelMap.put("${arrived_date}", String.valueOf(pqDevVO.getArrivedDate())); + baseModelMap.put("${check_date}", String.valueOf(pqDevVO.getCheckTime()).substring(0, 10)); + baseModelMap.put("${tested_by}", pqDevVO.getCheckBy()); + // 替换模板中的信息,避免信息丢失,段落和表格均参与替换 WordUtil.replacePlaceholdersInParagraphs(baseModelDocument, baseModelMap); WordUtil.replacePlaceholdersInTables(baseModelDocument, baseModelMap); @@ -516,15 +548,15 @@ public class PqReportServiceImpl extends ServiceImpl i * @param devReportParam 查询参数 */ private void dealDataModel(XWPFDocument baseModelDocument, DevReportParam devReportParam, PqDevVO pqDevVO) throws IOException { - AdPlan adPlan = adPlanService.getById(devReportParam.getPlanId()); - String scriptId = adPlan.getScriptId(); + //AdPlan adPlan = adPlanService.getById(devReportParam.getPlanId()); + //String scriptId = adPlan.getScriptId(); Integer devChns = pqDevVO.getDevChns(); for (int i = 1; i <= devChns; i++) { ClassPathResource resource = new ClassPathResource("/model/report_table.docx"); XWPFDocument dataModelDocumentTemp = new XWPFDocument(resource.getInputStream()); SingleNonHarmParam singleNonHarmParam = new SingleNonHarmParam(); - singleNonHarmParam.setPlanCode(adPlan.getCode()); + singleNonHarmParam.setPlanCode(Integer.valueOf(devReportParam.getPlanCode())); singleNonHarmParam.setDevId(pqDevVO.getId()); singleNonHarmParam.setChannelNo(i); @@ -678,6 +710,490 @@ public class PqReportServiceImpl extends ServiceImpl i } } + private void dealDataModelZJ(XWPFDocument baseModelDocument, DevReportParam devReportParam, PqDevVO pqDevVO) { + List nonHarmonicResultList = adNonHarmonicService.get(devReportParam.getScriptId(), null, devReportParam.getDevId(), "-1", devReportParam.getPlanCode()); + List harmonicResultList = adHarmonicService.get(devReportParam.getScriptId(), null, devReportParam.getDevId(), "-1", devReportParam.getPlanCode()); + if (CollectionUtil.isEmpty(nonHarmonicResultList) && CollectionUtil.isEmpty(harmonicResultList)) { + throw new BusinessException(ReportResponseEnum.NO_CHECK_DATA); + } + + List allBaseResultList = Stream.concat(nonHarmonicResultList.stream(), harmonicResultList.stream()) + .sorted(Comparator.comparing(AdBaseResult::getSort)).collect(Collectors.toList()); + LinkedHashMap> chnResultMap = allBaseResultList.stream().sorted(Comparator.comparing(AdBaseResult::getSort)) + .collect(Collectors.groupingBy( + (obj) -> obj.getMonitorId().substring(obj.getMonitorId().lastIndexOf("_") + 1), + LinkedHashMap::new, + Collectors.toList())); + + for (int i = 1; i <= pqDevVO.getDevChns(); i++) { + XWPFParagraph paragraph = baseModelDocument.createParagraph(); + paragraph.setAlignment(ParagraphAlignment.LEFT); + XWPFRun run = paragraph.createRun(); + run.setFontFamily("宋体"); + run.setBold(true); + run.setFontSize(14); + run.setText("测量回路" + i); + + List chnResultList = chnResultMap.get(String.valueOf(i)); + +// // 排除电压相角、电压偏差、电流相角 +// list1 = list1.stream().filter(obj -> !"e8bbfaad7a3fa343d3c46d345fb45fa3".equals(obj.getAdType())) +// .filter(obj -> !"148faabd2630aaac0b70be8609075f69".equals(obj.getAdType())) +// .filter(obj -> !"fdffc6b5dfdc8751b9fde9b599b8ea51".equals(obj.getAdType())).collect(Collectors.toList()); + + + Map> checkMap = this.getCheckMap(chnResultList); + for (String key : checkMap.keySet()) { + Set indexSet = checkMap.get(key); + generateTitleAndTableZJ(baseModelDocument, String.valueOf(i), key, devReportParam, indexSet); + } + } + + + //generateNonHarmABCTableHeaderZJ(baseModelDocument); + XWPFTable table = baseModelDocument.getTables().get(2); + for (int i = 1; i <= 3; i++) { + XWPFTableRow row = table.createRow(); + for (int j = 0; j < 8; j++) { + row.getCell(j).setText("1.00"); + row.getCell(j).setWidth("12.5%"); + row.getCell(j).setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER); + row.getCell(j).getParagraphs().get(0).setAlignment(ParagraphAlignment.CENTER); + if (j == 0) { + row.getCell(j).setWidth("15.0%"); + } + if (j == 7) { + row.getCell(j).setWidth("10.0%"); + } + } + } + } + + /** + * 获取map。 key为 检测大项code_大项ID ,value为大检测项下的所有index。 + * + * @param list + */ + private Map> getCheckMap(List list) { + Map> checkMap = new LinkedHashMap<>(); + for (int i = 0; i < list.size(); i++) { + AdBaseResult adBaseResult = list.get(i); + DictTree dictTree = dictTreeService.getById(adBaseResult.getAdType()); + DictTree parentDictTree = dictTreeService.getById(dictTree.getPid()); + if (ObjectUtil.isNotNull(parentDictTree)) { + String key = parentDictTree.getCode(); + checkMap.putIfAbsent(key + "_" + parentDictTree.getId(), new TreeSet<>()); + checkMap.get(key + "_" + parentDictTree.getId()).add(adBaseResult.getSort()); + } + } + return checkMap; + } + + + /** + * 浙江电科院版-动态生成标题和表格 + * + * @param baseModelDocument + * @param devNum + * @param key + * @param devReportParam + * @param indexSet + */ + private void generateTitleAndTableZJ(XWPFDocument baseModelDocument, String devNum, String key, DevReportParam devReportParam, Set indexSet) { + boolean isHarm = key.contains(DicDataEnum.HV.getCode()) || key.contains(DicDataEnum.HI.getCode()) || key.contains(DicDataEnum.HSV.getCode()) || key.contains(DicDataEnum.HSV.getCode()); + Map> radiusMap = getRadiusMap(devNum, key, devReportParam, indexSet, isHarm); + + for (String radius : radiusMap.keySet()) { + XWPFParagraph paragraph = baseModelDocument.createParagraph(); + paragraph.setAlignment(ParagraphAlignment.LEFT); + XWPFRun run = paragraph.createRun(); + run.setFontFamily("宋体"); + run.setBold(true); + run.setFontSize(12); + if (isHarm) { + run.setText(key.split("_")[0] + "测量准确度(最大允许误差:±" + radius.split("_")[1] + ")"); + } else { + run.setText(key.split("_")[0] + "测量准确度(最大允许误差:±" + radius + ")"); + } + XWPFTable table = generateTableHeaderZJ(baseModelDocument, DicDataEnum.getEnumByCode(key.split("_")[0])); + + // 填写数据 +// for (RawResultDataVO rawResultDataVO : radiusMap.get(radius)) { +// +// } + + } + } + + /** + * 获取同一个检测大项下不同的误差范围,及其检测结果 + * + * @param devNum + * @param key + * @param devReportParam + * @param indexSet + * @return + */ + private Map> getRadiusMap(String devNum, String key, DevReportParam devReportParam, Set indexSet, boolean isHarm) { + Map> raiusMap = new LinkedHashMap<>(); + ResultParam param = new ResultParam(); + param.setScriptId(devReportParam.getScriptId()); + param.setDevId(devReportParam.getDevId()); + param.setDevNum(devNum); + param.setCode(devReportParam.getPlanCode()); + String[] split = key.split("_"); + param.setScriptType(split[1]); + for (Integer index : indexSet) { + param.setIndex(index); + ResultVO resultVO = resultService.resultDataForReport(param); + Map resultData = resultVO.getResultData(); + if (CollectionUtil.isNotEmpty(resultData)) { + if (DicDataEnum.V.getCode().equals(split[0]) || DicDataEnum.I.getCode().equals(split[0])) { + // 排除电压相角、电压偏差、电流相角 + resultData.remove("电压相角"); + resultData.remove("电压偏差"); + resultData.remove("电流相角"); + } + resultData.values().stream().findFirst().ifPresent(obj -> { + String radius = obj.getRadius(); + String unit = obj.getUnit(); + if (StrUtil.isNotBlank(radius)) { + if (isHarm) { + raiusMap.put(index + "_" + radius.split("~")[1] + unit, resultData.values().stream().collect(Collectors.toList())); + } else { + raiusMap.put(radius.split("~")[1] + unit, resultData.values().stream().collect(Collectors.toList())); + } + } + }); + } + } + return raiusMap; + } + + /** + * 浙江电科院版-生成表格头部 + * + * @param doc + * @param checkItem 区分不同的表头 + * @return 生成的表格 + */ + private XWPFTable generateTableHeaderZJ(XWPFDocument doc, DicDataEnum checkItem) { + List> rows = new ArrayList<>(); + List row = null; + switch (checkItem) { + case FREQ: // 用于 频率 + row = new ArrayList<>(); + row.add(new CellEntity("给定值(HZ)", "25.0%", 1, 1)); + row.add(new CellEntity("测试值(HZ)", "25.0%", 1, 1)); + row.add(new CellEntity("误差(HZ)", "25.0%", 1, 1)); + row.add(new CellEntity("结论", "25.0%", 1, 1)); + rows.add(row); + break; + case V: // 用于 电压 + row = new ArrayList<>(); + row.add(new CellEntity("给定值(V)", "15.0%", 2, 1)); + row.add(new CellEntity("测试值(V)", "12.5%", 1, 3)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("误差(%)", "12.5%", 1, 3)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("结论", "10.0%", 2, 1)); + rows.add(row); + + row = new ArrayList<>(); + row.add(new CellEntity("", "15.0%", 1, 1)); + row.add(new CellEntity("L1", "12.5%", 1, 1)); + row.add(new CellEntity("L2", "12.5%", 1, 1)); + row.add(new CellEntity("L3", "12.5%", 1, 1)); + row.add(new CellEntity("L1", "12.5%", 1, 1)); + row.add(new CellEntity("L2", "12.5%", 1, 1)); + row.add(new CellEntity("L3", "12.5%", 1, 1)); + row.add(new CellEntity("", "10.0%", 1, 1)); + rows.add(row); + break; + case I: // 用于 电流 + row = new ArrayList<>(); + row.add(new CellEntity("给定值(A)", "15.0%", 2, 1)); + row.add(new CellEntity("测试值(A)", "12.5%", 1, 3)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("误差(%)", "12.5%", 1, 3)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("结论", "10.0%", 2, 1)); + rows.add(row); + + row = new ArrayList<>(); + row.add(new CellEntity("", "15.0%", 1, 1)); + row.add(new CellEntity("L1", "12.5%", 1, 1)); + row.add(new CellEntity("L2", "12.5%", 1, 1)); + row.add(new CellEntity("L3", "12.5%", 1, 1)); + row.add(new CellEntity("L1", "12.5%", 1, 1)); + row.add(new CellEntity("L2", "12.5%", 1, 1)); + row.add(new CellEntity("L3", "12.5%", 1, 1)); + row.add(new CellEntity("", "10.0%", 1, 1)); + rows.add(row); + break; + case IMBV:// 用于 负序电压不平衡度、负序电流不平衡度 + case IMBA: + row = new ArrayList<>(); + row.add(new CellEntity("给定值(%)", "25.0%", 1, 1)); + row.add(new CellEntity("测试值(%)", "25.0%", 1, 1)); + row.add(new CellEntity("误差(%)", "25.0%", 1, 1)); + row.add(new CellEntity("结论", "25.0%", 1, 1)); + rows.add(row); + break; + case F: // 用于 短时闪变 + row = new ArrayList<>(); + row.add(new CellEntity("给定值", "15.0%", 2, 1)); + row.add(new CellEntity("测试值", "12.5%", 1, 3)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("误差(%)", "12.5%", 1, 3)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("结论", "10.0%", 2, 1)); + rows.add(row); + + row = new ArrayList<>(); + row.add(new CellEntity("", "15.0%", 1, 1)); + row.add(new CellEntity("L1", "12.5%", 1, 1)); + row.add(new CellEntity("L2", "12.5%", 1, 1)); + row.add(new CellEntity("L3", "12.5%", 1, 1)); + row.add(new CellEntity("L1", "12.5%", 1, 1)); + row.add(new CellEntity("L2", "12.5%", 1, 1)); + row.add(new CellEntity("L3", "12.5%", 1, 1)); + row.add(new CellEntity("", "10.0%", 1, 1)); + rows.add(row); + break; + case HV: // 用于 谐波电压 + row = new ArrayList<>(); + row.add(new CellEntity("谐波次数", "7.0%", 2, 1)); + row.add(new CellEntity("谐波电压给定值(%)", "10.0%", 2, 1)); + row.add(new CellEntity("测试值(%)", "12.5%", 1, 3)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("误差(%)", "12.5%", 1, 3)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("结论", "8.0%", 2, 1)); + rows.add(row); + + row = new ArrayList<>(); + row.add(new CellEntity("", "7.0%", 1, 1)); + row.add(new CellEntity("", "10.0%", 1, 1)); + row.add(new CellEntity("L1", "12.5%", 1, 1)); + row.add(new CellEntity("L2", "12.5%", 1, 1)); + row.add(new CellEntity("L3", "12.5%", 1, 1)); + row.add(new CellEntity("L1", "12.5%", 1, 1)); + row.add(new CellEntity("L2", "12.5%", 1, 1)); + row.add(new CellEntity("L3", "12.5%", 1, 1)); + row.add(new CellEntity("", "8.0%", 1, 1)); + rows.add(row); + break; + case HI: // 用于 谐波电流 + row = new ArrayList<>(); + row.add(new CellEntity("谐波次数", "8.0%", 2, 1)); + row.add(new CellEntity("谐波电流给定值(A)", "10.0%", 2, 1)); + row.add(new CellEntity("测试值(A)", "12.5%", 1, 3)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("误差(%)", "12.5%", 1, 3)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("结论", "7.0%", 2, 1)); + rows.add(row); + + row = new ArrayList<>(); + row.add(new CellEntity("", "8.0%", 1, 1)); + row.add(new CellEntity("", "10.0%", 1, 1)); + row.add(new CellEntity("L1", "12.5%", 1, 1)); + row.add(new CellEntity("L2", "12.5%", 1, 1)); + row.add(new CellEntity("L3", "12.5%", 1, 1)); + row.add(new CellEntity("L1", "12.5%", 1, 1)); + row.add(new CellEntity("L2", "12.5%", 1, 1)); + row.add(new CellEntity("L3", "12.5%", 1, 1)); + row.add(new CellEntity("", "7.0%", 1, 1)); + rows.add(row); + break; + case HSV: // 用于 间谐波电压 + row = new ArrayList<>(); + row.add(new CellEntity("间谐波次数", "8.0%", 2, 1)); + row.add(new CellEntity("间谐波电压给定值(%)", "10.0%", 2, 1)); + row.add(new CellEntity("测试值(%)", "12.5%", 1, 3)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("误差(%)", "12.5%", 1, 3)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("结论", "7.0%", 2, 1)); + rows.add(row); + + row = new ArrayList<>(); + row.add(new CellEntity("", "8.0%", 1, 1)); + row.add(new CellEntity("", "10.0%", 1, 1)); + row.add(new CellEntity("L1", "12.5%", 1, 1)); + row.add(new CellEntity("L2", "12.5%", 1, 1)); + row.add(new CellEntity("L3", "12.5%", 1, 1)); + row.add(new CellEntity("L1", "12.5%", 1, 1)); + row.add(new CellEntity("L2", "12.5%", 1, 1)); + row.add(new CellEntity("L3", "12.5%", 1, 1)); + row.add(new CellEntity("", "7.0%", 1, 1)); + rows.add(row); + break; + case HSI: // 用于 间谐波电流 + row = new ArrayList<>(); + row.add(new CellEntity("间谐波次数", "8.0%", 2, 1)); + row.add(new CellEntity("间谐波电流给定值(A)", "10.0%", 2, 1)); + row.add(new CellEntity("测试值(A)", "12.5%", 1, 3)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("误差(%)", "12.5%", 1, 3)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("", "12.5%", 1, 1)); + row.add(new CellEntity("结论", "7.0%", 2, 1)); + rows.add(row); + + row = new ArrayList<>(); + row.add(new CellEntity("", "8.0%", 1, 1)); + row.add(new CellEntity("", "10.0%", 1, 1)); + row.add(new CellEntity("L1", "12.5%", 1, 1)); + row.add(new CellEntity("L2", "12.5%", 1, 1)); + row.add(new CellEntity("L3", "12.5%", 1, 1)); + row.add(new CellEntity("L1", "12.5%", 1, 1)); + row.add(new CellEntity("L2", "12.5%", 1, 1)); + row.add(new CellEntity("L3", "12.5%", 1, 1)); + row.add(new CellEntity("", "7.0%", 1, 1)); + rows.add(row); + break; + case VOLTAGE: // 用于 电压暂降、暂升及短时中断 + row = new ArrayList<>(); + row.add(new CellEntity("给定值", "16.0%", 1, 2)); + row.add(new CellEntity("", "16.0%", 1, 1)); + row.add(new CellEntity("测试值", "16.0%", 1, 2)); + row.add(new CellEntity("", "16.0%", 1, 1)); + row.add(new CellEntity("误差", "16.0%", 1, 2)); + row.add(new CellEntity("", "16.0%", 1, 1)); + rows.add(row); + + row = new ArrayList<>(); + row.add(new CellEntity("特征幅值(%)", "16.0%", 1, 1)); + row.add(new CellEntity("持续时间(ms)", "16.0%", 1, 1)); + row.add(new CellEntity("特征幅值(%)", "16.0%", 1, 1)); + row.add(new CellEntity("持续时间(ms)", "16.0%", 1, 1)); + row.add(new CellEntity("特征幅值(%)", "16.0%", 1, 1)); + row.add(new CellEntity("持续时间(ms)", "16.0%", 1, 1)); + rows.add(row); + break; + default: + break; + } + + + return generateTableHeader(doc, rows); + } + + /** + * 动态生成表格头部 + * + * @param doc + * @param rows 表头数据 + * @return 生成的表格 + */ + private XWPFTable generateTableHeader(XWPFDocument doc, List> rows) { + XWPFTable table = doc.createTable(rows.size(), rows.get(0).size()); + table.setTableAlignment(TableRowAlign.CENTER); + table.setWidth("100%"); + + CTTblGrid grid = table.getCTTbl().addNewTblGrid(); + for (int i = 0; i < rows.get(0).size(); i++) { + grid.addNewGridCol(); + } + for (int i = 0; i < rows.size(); i++) { + XWPFTableRow row = table.getRow(i); + row.setHeight((int) (1 / 2.54 * TWIPS_PER_INCH)); + + for (int j = 0; j < rows.get(i).size(); j++) { + CellEntity cellEntity = rows.get(i).get(j); + row.getCell(j).setText(cellEntity.getCellValue()); + row.getCell(j).setWidth(cellEntity.getWidth()); + setHeaderCellStyle(row.getCell(j)); + + if (cellEntity.getColSpan() > 1) { + mergeCellsHorizontal(table, i, j, j + cellEntity.getColSpan() - 1); + } + if (cellEntity.getRowSpan() > 1) { + mergeCellsVertically(table, j, i, i + cellEntity.getRowSpan() - 1); + } + } + } + return table; + } + + public CTTcPr getTcPr(XWPFTableCell cell) { + return cell.getCTTc().isSetTcPr() ? cell.getCTTc().getTcPr() : cell.getCTTc().addNewTcPr(); + } + + /** + * word单元格列合并(合并列) + * + * @param table + * @param row + * @param fromCol + * @param toCol + */ + public void mergeCellsHorizontal(XWPFTable table, int row, int fromCol, int toCol) { + for (int colIndex = fromCol; colIndex <= toCol; colIndex++) { + XWPFTableCell cell = table.getRow(row).getCell(colIndex); + CTTcPr tcPr = getTcPr(cell); + CTHMerge hMerge = tcPr.addNewHMerge(); + if (colIndex == fromCol) { + hMerge.setVal(STMerge.RESTART); + } else { + hMerge.setVal(STMerge.CONTINUE); + } + } + } + + /** + * word单元格行合并(合并行) + * + * @param table + * @param col + * @param fromRow + * @param toRow + */ + public void mergeCellsVertically(XWPFTable table, int col, int fromRow, int toRow) { + for (int rowIndex = fromRow; rowIndex <= toRow; rowIndex++) { + XWPFTableCell cell = table.getRow(rowIndex).getCell(col); + CTTcPr tcPr = getTcPr(cell); + CTVMerge vMerge = tcPr.addNewVMerge(); + if (rowIndex == fromRow) { + vMerge.setVal(STMerge.RESTART); + } else { + vMerge.setVal(STMerge.CONTINUE); + } + } + } + + public void setHeaderCellStyle(XWPFTableCell cell) { + cell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER); + XWPFParagraph xwpfParagraph = cell.getParagraphs().get(0); + xwpfParagraph.setAlignment(ParagraphAlignment.CENTER); +// System.out.println("Paragraph text: " + xwpfParagraph.getText()); +// List runs = xwpfParagraph.getRuns(); +// runs.get(0).setBold(true); +// runs.get(0).setFontSize(10); +// String text = runs.get(0).getText(0); +// if (StrUtil.isNotBlank(text) && Pattern.matches("^[A-Za-z0-9]+$", text)) { +// runs.get(0).setFontFamily("Arial"); +// } else { +// runs.get(0).setFontFamily("宋体"); +// } + } + + private void specialDealVoltage(Map dataModelMap, String symbol) { String value = dataModelMap.get(symbol); if (Objects.nonNull(value) && !value.equals("/")) { diff --git a/detection/src/main/java/com/njcn/gather/result/service/IResultService.java b/detection/src/main/java/com/njcn/gather/result/service/IResultService.java index baa07e60..ead8e881 100644 --- a/detection/src/main/java/com/njcn/gather/result/service/IResultService.java +++ b/detection/src/main/java/com/njcn/gather/result/service/IResultService.java @@ -39,6 +39,14 @@ public interface IResultService { */ ResultVO resultData(ResultParam param); + /** + * 展示结果数据(用于生成报告) + * + * @param param + * @return + */ + ResultVO resultDataForReport(ResultParam param); + /** * 导出原始数据 diff --git a/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java b/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java index 6e260f7c..5e2dde66 100644 --- a/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/result/service/impl/ResultServiceImpl.java @@ -807,6 +807,37 @@ public class ResultServiceImpl implements IResultService { return resultVO; } + @Override + public ResultVO resultDataForReport(ResultParam param) { + StorageParam storage = new StorageParam(); + storage.setIndex(param.getIndex()); + storage.setScriptId(param.getScriptId()); + storage.setDevId(param.getDevId()); + storage.setDevNum(param.getDevNum()); + storage.setCode(param.getCode()); + DictTree dictTree = dictTreeService.getById(param.getScriptType()); + List harmNum = new ArrayList<>(); + if (HARMONIC_TYPE_CODE.contains(dictTree.getCode())) { + List list = pqScriptCheckDataService.list(new MPJLambdaWrapper() + .distinct() + .select(PqScriptCheckData::getHarmNum) + .eq(PqScriptCheckData::getScriptId, param.getScriptId()) + .isNotNull(PqScriptCheckData::getHarmNum) + .eq(PqScriptCheckData::getScriptIndex, param.getIndex()) + ); + harmNum = list.stream().sorted(Comparator.comparing(PqScriptCheckData::getHarmNum)) + .map(PqScriptCheckData::getHarmNum).distinct().collect(Collectors.toList()); + } + ResultVO resultVO = new ResultVO(); + if (CollUtil.isEmpty(harmNum)) { + resultVO.setResultData(adNonHarmonicService.listNonHarmResultData(storage)); + } else { + storage.setHarmNum(harmNum); + resultVO.setResultData(adHarmonicService.listHarmResultData(storage)); + } + return resultVO; + } + @Override public void exportRawData(ResultParam param) { StorageParam storage = new StorageParam(); @@ -977,10 +1008,10 @@ public class ResultServiceImpl implements IResultService { dataRule = DictDataEnum.AT_WILL_VALUE; } - List allNonHarmonicRawData = adNonHarmonicService.listAll(oldCode, devId); + List allNonHarmonicRawData = adNonHarmonicService.listAll(scriptId, oldCode, devId); LinkedHashMap> nonHarmonicMap = allNonHarmonicRawData.stream().sorted(Comparator.comparing(AdNonHarmonicResult::getSort)) .collect(Collectors.groupingBy(AdNonHarmonicResult::getSort, LinkedHashMap::new, Collectors.toList())); - List allHarmonicRawData = adHarmonicService.lisAll(oldCode, devId); + List allHarmonicRawData = adHarmonicService.listAll(scriptId, oldCode, devId); LinkedHashMap> harmonicMap = allHarmonicRawData.stream().sorted(Comparator.comparing(AdHarmonicResult::getSort)) .collect(Collectors.groupingBy(AdHarmonicResult::getSort, LinkedHashMap::new, Collectors.toList())); diff --git a/storage/src/main/java/com/njcn/gather/storage/pojo/param/SingleNonHarmParam.java b/storage/src/main/java/com/njcn/gather/storage/pojo/param/SingleNonHarmParam.java index 565db804..fe93f8b7 100644 --- a/storage/src/main/java/com/njcn/gather/storage/pojo/param/SingleNonHarmParam.java +++ b/storage/src/main/java/com/njcn/gather/storage/pojo/param/SingleNonHarmParam.java @@ -1,8 +1,10 @@ package com.njcn.gather.storage.pojo.param; +import io.swagger.models.auth.In; import lombok.Data; import java.io.Serializable; +import java.util.List; /** * @author hongawen @@ -39,4 +41,6 @@ public class SingleNonHarmParam implements Serializable { */ private Integer sort; + private List sortList; + } diff --git a/storage/src/main/java/com/njcn/gather/storage/pojo/po/AdBaseResult.java b/storage/src/main/java/com/njcn/gather/storage/pojo/po/AdBaseResult.java index 01989832..fb39cd8c 100644 --- a/storage/src/main/java/com/njcn/gather/storage/pojo/po/AdBaseResult.java +++ b/storage/src/main/java/com/njcn/gather/storage/pojo/po/AdBaseResult.java @@ -27,4 +27,9 @@ public class AdBaseResult { * 0.不合格 1.合格 */ private Integer resultFlag; + + /** + * 检测指标,字典表 + */ + private String adType; } diff --git a/storage/src/main/java/com/njcn/gather/storage/service/AdHarmonicService.java b/storage/src/main/java/com/njcn/gather/storage/service/AdHarmonicService.java index 2178778d..630c0ec8 100644 --- a/storage/src/main/java/com/njcn/gather/storage/service/AdHarmonicService.java +++ b/storage/src/main/java/com/njcn/gather/storage/service/AdHarmonicService.java @@ -38,27 +38,30 @@ public interface AdHarmonicService extends IService { /** * 查询结果数据 + * * @param param * @return */ - Map listHarmResultData(StorageParam param) ; + Map listHarmResultData(StorageParam param); /** * 获取索引 + * * @param param * @param isExculdePhaseAngle 是否排除电压相角、电流相角 * @return */ - List getIndex(StorageParam param,Boolean isExculdePhaseAngle); + List getIndex(StorageParam param, Boolean isExculdePhaseAngle); AdHarmonicResult getSingleResult(SingleNonHarmParam singleNonHarmParam); /** * 获取所有谐波原始数据 * + * @param scriptId * @param code - * @param devId 设备ID + * @param devId 设备ID * @return */ - List lisAll(String code, String devId); + List listAll(String scriptId, String code, String devId); } diff --git a/storage/src/main/java/com/njcn/gather/storage/service/AdNonHarmonicService.java b/storage/src/main/java/com/njcn/gather/storage/service/AdNonHarmonicService.java index a9ada8f2..ea5c53b4 100644 --- a/storage/src/main/java/com/njcn/gather/storage/service/AdNonHarmonicService.java +++ b/storage/src/main/java/com/njcn/gather/storage/service/AdNonHarmonicService.java @@ -49,9 +49,10 @@ public interface AdNonHarmonicService extends IService { /** * 获取所有原始数据 + * @param scriptId * @param code * @param devId * @return */ - List listAll(String code,String devId); + List listAll(String scriptId,String code,String devId); } diff --git a/storage/src/main/java/com/njcn/gather/storage/service/impl/AdHarmonicServiceImpl.java b/storage/src/main/java/com/njcn/gather/storage/service/impl/AdHarmonicServiceImpl.java index 121659d3..ed0d8e78 100644 --- a/storage/src/main/java/com/njcn/gather/storage/service/impl/AdHarmonicServiceImpl.java +++ b/storage/src/main/java/com/njcn/gather/storage/service/impl/AdHarmonicServiceImpl.java @@ -239,11 +239,11 @@ public class AdHarmonicServiceImpl extends ServiceImpl lisAll(String code, String devId) { + public List listAll(String scriptId, String code, String devId) { String prefix = "ad_harmonic_" + code; DynamicTableNameHandler.setTableName(prefix); MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(); - wrapper.likeRight(AdHarmonicResult::getMonitorId, devId); + wrapper.eq(AdHarmonicResult::getScriptId, scriptId).likeRight(AdHarmonicResult::getMonitorId, devId); List results = this.getBaseMapper().selectJoinList(AdHarmonicResult.class, wrapper); DynamicTableNameHandler.remove(); return results; diff --git a/storage/src/main/java/com/njcn/gather/storage/service/impl/AdNonHarmonicServiceImpl.java b/storage/src/main/java/com/njcn/gather/storage/service/impl/AdNonHarmonicServiceImpl.java index 47fb9d4b..5aea7ea8 100644 --- a/storage/src/main/java/com/njcn/gather/storage/service/impl/AdNonHarmonicServiceImpl.java +++ b/storage/src/main/java/com/njcn/gather/storage/service/impl/AdNonHarmonicServiceImpl.java @@ -154,11 +154,12 @@ public class AdNonHarmonicServiceImpl extends ServiceImpl listAll(String code, String devId) { + public List listAll(String scriptId, String code, String devId) { String prefix = "ad_non_harmonic_" + code; DynamicTableNameHandler.setTableName(prefix); MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(); - wrapper.likeRight(AdNonHarmonicResult::getMonitorId, devId); + wrapper.eq(AdNonHarmonicResult::getScriptId, scriptId) + .likeRight(AdNonHarmonicResult::getMonitorId, devId); List results = this.getBaseMapper().selectJoinList(AdNonHarmonicResult.class, wrapper); DynamicTableNameHandler.remove(); return results; diff --git a/system/src/main/java/com/njcn/gather/system/pojo/enums/DicDataEnum.java b/system/src/main/java/com/njcn/gather/system/pojo/enums/DicDataEnum.java index 45a54b77..1c478ddb 100644 --- a/system/src/main/java/com/njcn/gather/system/pojo/enums/DicDataEnum.java +++ b/system/src/main/java/com/njcn/gather/system/pojo/enums/DicDataEnum.java @@ -37,4 +37,13 @@ public enum DicDataEnum { this.code = code; this.message = message; } + + public static DicDataEnum getEnumByCode(String code) { + for (DicDataEnum e : DicDataEnum.values()) { + if (e.getCode().equals(code)) { + return e; + } + } + return null; + } }