fix(equipment): 修复设备健康等级计算异常
- 增加对设备使用年限、原始价值和安装日期的空值检查- 如果上述字段为空,则将健康等级设为"wfjs"(未计算) - 优化了健康等级计算逻辑,增加了空值处理 - 在设备列表中添加健康等级状态的字典文本显示
正在显示
2 个修改的文件
包含
32 行增加
和
22 行删除
... | @@ -526,6 +526,7 @@ public class EquipmentController { | ... | @@ -526,6 +526,7 @@ public class EquipmentController { |
526 | Map<String, String> equipmentStatusVal2KeyMap = EquipmentUtils.convertFunc("equipmentStatus", false); | 526 | Map<String, String> equipmentStatusVal2KeyMap = EquipmentUtils.convertFunc("equipmentStatus", false); |
527 | Map<String, String> maintenanceCycleUnitVal2KeyMap = key2ValueService.dictKey2Val("loop_unit", false); | 527 | Map<String, String> maintenanceCycleUnitVal2KeyMap = key2ValueService.dictKey2Val("loop_unit", false); |
528 | Map<String, String> installVal2KeyMap = key2ValueService.dictKey2Val("equipment-installWay", false); | 528 | Map<String, String> installVal2KeyMap = key2ValueService.dictKey2Val("equipment-installWay", false); |
529 | Map<String, String> healthVal2KeyMap = key2ValueService.dictKey2Val("equipment_health_status", false); | ||
529 | // 封装结果 | 530 | // 封装结果 |
530 | Page<Map<String, Map<String, Object>>> resPage = new Page<>(equipmentDTO.getPageNo(), equipmentDTO.getPageSize()); | 531 | Page<Map<String, Map<String, Object>>> resPage = new Page<>(equipmentDTO.getPageNo(), equipmentDTO.getPageSize()); |
531 | resPage.setTotal(mapPage.getTotal()); | 532 | resPage.setTotal(mapPage.getTotal()); |
... | @@ -557,6 +558,8 @@ public class EquipmentController { | ... | @@ -557,6 +558,8 @@ public class EquipmentController { |
557 | resMap.get(keys[0]).put(keys[1] + "_dictText", maintenanceCycleUnitVal2KeyMap.get(ConvertUtils.getString(value))); | 558 | resMap.get(keys[0]).put(keys[1] + "_dictText", maintenanceCycleUnitVal2KeyMap.get(ConvertUtils.getString(value))); |
558 | } else if ("installWay".equals(keys[1])) { | 559 | } else if ("installWay".equals(keys[1])) { |
559 | resMap.get(keys[0]).put(keys[1] + "_dictText", installVal2KeyMap.get(ConvertUtils.getString(value))); | 560 | resMap.get(keys[0]).put(keys[1] + "_dictText", installVal2KeyMap.get(ConvertUtils.getString(value))); |
561 | } else if ("equipmentHealthStatus".equals(keys[1])) { | ||
562 | resMap.get(keys[0]).put(keys[1] + "_dictText", healthVal2KeyMap.get(ConvertUtils.getString(value))); | ||
560 | } | 563 | } |
561 | } | 564 | } |
562 | resPage.getRecords().add(resMap); | 565 | resPage.getRecords().add(resMap); | ... | ... |
... | @@ -43,29 +43,36 @@ public class EquipHealthLevelJob implements Job { | ... | @@ -43,29 +43,36 @@ public class EquipHealthLevelJob implements Job { |
43 | //workingLife 使用年限、originalValue 购置价格、installDate 安装日期 | 43 | //workingLife 使用年限、originalValue 购置价格、installDate 安装日期 |
44 | List<EquipmentInfo> list = equipmentInfoService.getEquipmentList(); | 44 | List<EquipmentInfo> list = equipmentInfoService.getEquipmentList(); |
45 | for (EquipmentInfo equipmentInfo : list){ | 45 | for (EquipmentInfo equipmentInfo : list){ |
46 | double performanceScore = 100.00;//性能得分 | 46 | |
47 | double faultScore = 100.00;//故障得分 | 47 | if(ConvertUtils.isEmpty(equipmentInfo.getWorkingLife())|| |
48 | double maintainScore = 100.00;//维护得分 | 48 | ConvertUtils.isEmpty(equipmentInfo.getOriginalValue())|| |
49 | double useYearScore = 100.00;//使用年限得分 | 49 | ConvertUtils.isEmpty(equipmentInfo.getInstallDate())){ |
50 | //性能分数 | 50 | equipmentInfo.setEquipmentHealthLevel(""); |
51 | if(ConvertUtils.isNotEmpty(equipmentInfo.getPerformanceScore())){ | 51 | equipmentInfo.setEquipmentHealthStatus("wfjs"); |
52 | performanceScore = Double.valueOf(equipmentInfo.getPerformanceScore()); | 52 | }else{ |
53 | double performanceScore = 100.00;//性能得分 | ||
54 | double faultScore = 100.00;//故障得分 | ||
55 | double maintainScore = 100.00;//维护得分 | ||
56 | double useYearScore = 100.00;//使用年限得分 | ||
57 | //性能分数 | ||
58 | if(ConvertUtils.isNotEmpty(equipmentInfo.getPerformanceScore())){ | ||
59 | performanceScore = Double.valueOf(equipmentInfo.getPerformanceScore()); | ||
60 | } | ||
61 | performanceScore = DoubleOperaUtils.bigDecimalRound(qzMap.get("xnzb")/100.00 * performanceScore,2); | ||
62 | //故障分数 | ||
63 | faultScore = getFaultScore(equipmentInfo.getGzCount(),qzMap.get("gzl")/100.00); | ||
64 | //维护分数 | ||
65 | maintainScore = getMaintainScore(equipmentInfo.getMaintenanceCost(), equipmentInfo.getOriginalValue(),qzMap.get("whcb")/100.00); | ||
66 | //使用年限分数 | ||
67 | useYearScore = getUseYearScore(equipmentInfo.getWorkingLife(),equipmentInfo.getInstallDate(),today,qzMap.get("synx")/100.00); | ||
68 | //计算总分 | ||
69 | double score = DoubleOperaUtils.bigDecimalRound(performanceScore + faultScore + maintainScore + useYearScore,2); | ||
70 | equipmentInfo.setEquipmentHealthLevel(String.valueOf(score)); | ||
71 | |||
72 | //判断score在statusValueMap的key值的哪个区间,返回对应的value | ||
73 | String statusValue = getEquipmentHealthStatus(score,statusValueMap); | ||
74 | equipmentInfo.setEquipmentHealthStatus(statusValue); | ||
53 | } | 75 | } |
54 | performanceScore = DoubleOperaUtils.bigDecimalRound(qzMap.get("xnzb")/100.00 * performanceScore,2); | ||
55 | //故障分数 | ||
56 | faultScore = getFaultScore(equipmentInfo.getGzCount(),qzMap.get("gzl")/100.00); | ||
57 | //维护分数 | ||
58 | maintainScore = getMaintainScore(equipmentInfo.getMaintenanceCost(), equipmentInfo.getOriginalValue(),qzMap.get("whcb")/100.00); | ||
59 | //使用年限分数 | ||
60 | useYearScore = getUseYearScore(equipmentInfo.getWorkingLife(),equipmentInfo.getInstallDate(),today,qzMap.get("synx")/100.00); | ||
61 | //计算总分 | ||
62 | double score = performanceScore + faultScore + maintainScore + useYearScore; | ||
63 | equipmentInfo.setEquipmentHealthLevel(String.valueOf(score)); | ||
64 | |||
65 | //判断score在statusValueMap的key值的哪个区间,返回对应的value | ||
66 | String statusValue = getEquipmentHealthStatus(score,statusValueMap); | ||
67 | |||
68 | equipmentInfo.setEquipmentHealthStatus(statusValue); | ||
69 | equipmentInfoService.updateById(equipmentInfo); | 76 | equipmentInfoService.updateById(equipmentInfo); |
70 | } | 77 | } |
71 | 78 | ... | ... |
-
请 注册 或 登录 后发表评论