| | |
| | | import com.estate.expert.admin.stat.report.builder.ReportBuilderBase; |
| | | import com.estate.expert.admin.stat.report.builder.SystemReportBuilder; |
| | | import com.estate.expert.admin.stat.report.data.DeviceReportData; |
| | | import com.estate.expert.admin.stat.report.data.impl.DaiguanDeviceFuzzyReportData; |
| | | import com.estate.expert.admin.stat.report.data.impl.DaiguanDeviceScoreReportData; |
| | | import com.estate.expert.admin.stat.report.data.impl.DeviceFuzzyReportData; |
| | | import com.estate.expert.admin.stat.report.data.impl.DeviceScoreReportData; |
| | | import com.estate.expert.admin.stat.report.data.impl.SystemFuzzyReportData; |
| | |
| | | @Slf4j |
| | | @Service |
| | | public class ReportServiceImpl implements ReportService { |
| | | |
| | | private static final String DAIGUAN_TECH_REMARK = "岱观科技"; |
| | | private static final String DAIGUAN_SYSTEM_TEMPLATE_FILE = "第三方评估报告new.docx"; |
| | | private static final String DAIGUAN_REMARK = "岱观科技"; |
| | | private static final String DAIGUAN_DEVICE_TEMPLATE_FILE = "设备风险评估报告new.docx"; |
| | | |
| | | @Resource |
| | | private ReportTemplateService reportTemplateService; |
| | |
| | | BizResultCode.BIZ_REPORT_TEMPLATE_NOT_EXIST.check(reportTemplate == null); |
| | | switch (reportTemplate.getType()) { |
| | | case ThirdPartyReport: |
| | | if (isDaiguanTechTemplate(reportTemplate)) { |
| | | return new SystemReportBuilder(userFileService, DAIGUAN_SYSTEM_TEMPLATE_FILE); |
| | | } |
| | | return new SystemReportBuilder(userFileService); |
| | | case DeviceReport: |
| | | if (DAIGUAN_REMARK.equals(reportTemplate.getRemark())) { |
| | | return new DeviceReportBuilder(userFileService, DAIGUAN_DEVICE_TEMPLATE_FILE); |
| | | } |
| | | return new DeviceReportBuilder(userFileService); |
| | | default: |
| | | throw new BizException(BizResultCode.BIZ_REPORT_TEMPLATE_TYPE_NOT_EXIST); |
| | |
| | | var clientId = project.getClient() != null ? project.getClient().getId() : null; |
| | | var problemFrequency = buildDeviceProblemFrequency(project.getId(), clientId); |
| | | |
| | | if (isDaiguanTemplate(reportTemplate)) { |
| | | return DaiguanDeviceFuzzyReportData.builder() |
| | | .reportId(evalFuzzyResult.getId()) |
| | | .deviceResMap(evalFuzzyResult.getDeviceResMap()) |
| | | .deviceHierarchy(hierarchy) |
| | | .template(reportTemplate) |
| | | .project(project) |
| | | .projectInfo(projectInfo) |
| | | .devices(devices) |
| | | .records(records) |
| | | .deviceProblemHazardCounts(problemFrequency.problemHazardCounts()) |
| | | .deviceCheckCounts(problemFrequency.deviceCheckCounts()) |
| | | .build() |
| | | .generate(); |
| | | } |
| | | |
| | | // 生成报告数据 |
| | | return DeviceFuzzyReportData.builder() |
| | | .reportId(evalFuzzyResult.getId()) |
| | |
| | | var clientId = project.getClient() != null ? project.getClient().getId() : null; |
| | | var problemFrequency = buildDeviceProblemFrequency(project.getId(), clientId); |
| | | |
| | | if (isDaiguanTemplate(reportTemplate)) { |
| | | return DaiguanDeviceScoreReportData.builder() |
| | | .reportId(evalFuzzyResult.getId()) |
| | | .deviceResMap(evalFuzzyResult.getDeviceResMap()) |
| | | .deviceScoreResMap(evalScoreResult.getDeviceResMap()) |
| | | .deviceHierarchy(hierarchy) |
| | | .template(reportTemplate) |
| | | .project(project) |
| | | .projectInfo(projectInfo) |
| | | .devices(devices) |
| | | .records(records) |
| | | .deviceProblemHazardCounts(problemFrequency.problemHazardCounts()) |
| | | .deviceCheckCounts(problemFrequency.deviceCheckCounts()) |
| | | .build() |
| | | .generate(); |
| | | } |
| | | |
| | | // 生成报告数据 |
| | | return DeviceScoreReportData.builder() |
| | | .reportId(evalFuzzyResult.getId()) |
| | |
| | | return taskIds; |
| | | } |
| | | |
| | | private boolean isDaiguanTemplate(ReportTemplate reportTemplate) { |
| | | return reportTemplate != null && DAIGUAN_REMARK.equals(reportTemplate.getRemark()); |
| | | } |
| | | |
| | | private boolean isDaiguanTechTemplate(ReportTemplate reportTemplate) { |
| | | if (reportTemplate == null || reportTemplate.getRemark() == null) { |
| | | return false; |
| | | } |
| | | return DAIGUAN_TECH_REMARK.equals(reportTemplate.getRemark().trim()); |
| | | } |
| | | |
| | | private long countProjectChecks(Integer projectId) { |
| | | if (projectId == null) { |
| | | return 0L; |