| | |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.TreeMap; |
| | | |
| | | /** |
| | |
| | | protected Map<Integer, FuzzyResult> deviceResMap; |
| | | |
| | | TreeRoot<HierarchyData> deviceHierarchy; |
| | | |
| | | Map<String, Long> deviceProblemHazardCounts; |
| | | |
| | | Map<String, Long> deviceProblemCheckCounts; |
| | | |
| | | /** |
| | | * 生成报告数据 |
| | |
| | | // 检查问题列:默认为问题备注,当问题备注为空时,填写问题描述(与安全报告一致) |
| | | info.put("检查问题", StringUtils.hasText(record.getRemark()) ? record.getRemark() : record.getProblem().getDescription()); |
| | | info.put("隐患等级", record.getLevel().getDesc()); |
| | | info.put("同类隐患出现频次", getDeviceProblemHazardCount(record)); |
| | | info.put("检查频次", getDeviceProblemCheckCount(record)); |
| | | var subItem = buildRecordDetail(record); |
| | | subItem.put("项目级别", errorNode(record).getName()); |
| | | info.put("问题详情", subItem); |
| | |
| | | return result; |
| | | } |
| | | |
| | | private long getDeviceProblemHazardCount(ErrorRecord record) { |
| | | if (deviceProblemHazardCounts == null) { |
| | | return 0L; |
| | | } |
| | | return deviceProblemHazardCounts.getOrDefault(buildDeviceProblemKey(record), 0L); |
| | | } |
| | | |
| | | private long getDeviceProblemCheckCount(ErrorRecord record) { |
| | | if (deviceProblemCheckCounts == null) { |
| | | return 0L; |
| | | } |
| | | return deviceProblemCheckCounts.getOrDefault(buildDeviceProblemKey(record), 0L); |
| | | } |
| | | |
| | | private String buildDeviceProblemKey(ErrorRecord record) { |
| | | Integer deviceId = record != null && record.getDevice() != null ? record.getDevice().getId() : null; |
| | | Integer problemId = record != null && record.getProblem() != null ? record.getProblem().getId() : null; |
| | | return buildDeviceProblemKey(deviceId, problemId); |
| | | } |
| | | |
| | | public static String buildDeviceProblemKey(Integer deviceId, Integer problemId) { |
| | | return Objects.toString(deviceId, "") + "::" + Objects.toString(problemId, ""); |
| | | } |
| | | |
| | | /** |
| | | * 构建设备记录 |
| | | * @param device 设备 |