ouyj 2 달 전
부모
커밋
2cc2f69b4f
1개의 변경된 파일56개의 추가작업 그리고 11개의 파일을 삭제
  1. 56 11
      ygtx-gxt/src/main/java/com/ygtx/gxt/service/impl/GxtRepairOrderServiceImpl.java

+ 56 - 11
ygtx-gxt/src/main/java/com/ygtx/gxt/service/impl/GxtRepairOrderServiceImpl.java

@@ -2753,7 +2753,7 @@ public class GxtRepairOrderServiceImpl implements IGxtRepairOrderService
         }
 
         repairOrder.setRepairOrderPersonList(allPersons);
-        
+
         // 累加所有扣分记录的stopScore
         BigDecimal totalDeduction = BigDecimal.ZERO;
         for (GxtOrderScoreDetail detail : scoreDetails) {
@@ -2761,7 +2761,7 @@ public class GxtRepairOrderServiceImpl implements IGxtRepairOrderService
                 totalDeduction = totalDeduction.add(detail.getStopScore());
             }
         }
-        
+
         if (totalDeduction.compareTo(BigDecimal.ZERO) >= 0) {
             return; // 没有有效的扣分记录
         }
@@ -2769,7 +2769,7 @@ public class GxtRepairOrderServiceImpl implements IGxtRepairOrderService
         // 计算每人平均扣分
         int personCount = allPersons.size();
         BigDecimal perPersonDeduction = totalDeduction.divide(new BigDecimal(personCount), 10, BigDecimal.ROUND_HALF_UP);
-        
+
         // 根据小数位数决定最终结果
         if (perPersonDeduction.scale() > 6) {
             perPersonDeduction = perPersonDeduction.setScale(6, BigDecimal.ROUND_HALF_UP);
@@ -2777,34 +2777,34 @@ public class GxtRepairOrderServiceImpl implements IGxtRepairOrderService
 
         // 一次性更新所有人员
         List<GxtRepairOrderPerson> personsToUpdate = new ArrayList<>();
-        
+
         for (GxtRepairOrderPerson person : allPersons) {
             GxtRepairOrderPerson updatedPerson = new GxtRepairOrderPerson();
             updatedPerson.setId(person.getId());
-            
+
             // 正确累加停机扣分
             Double currentStopScore = person.getStopScore();
             Double newStopScore = (currentStopScore != null ? currentStopScore : 0.0) + perPersonDeduction.doubleValue();
             updatedPerson.setStopScore(newStopScore);
-            
+
             // 正确累加总分
             updatedPerson.setScore(person.getScore() != null ? person.getScore().add(perPersonDeduction) : perPersonDeduction);
-            
+
             updatedPerson.setUpdateBy(SecurityUtils.getLoginUser().getUser().getUserName());
             updatedPerson.setUpdateTime(new Date());
-            
+
             personsToUpdate.add(updatedPerson);
         }
-        
+
         // 批量更新人员得分
         updateRepairOrderPersonList(personsToUpdate);
-        
+
         // 逐条处理月度统计数据(保持时间准确性)
         for (GxtOrderScoreDetail detail : scoreDetails) {
             if (detail.getStopScore() != null && detail.getStopScore().compareTo(BigDecimal.ZERO) < 0) {
                 // 使用每条记录的实际创建时间
                 updateMonthlyScoreDataForStopScore(repairOrder, detail.getStopScore(), detail.getCreateTime());
-                
+
                 // 为这条记录添加个人明细
                 int detailPersonCount = allPersons.size();
                 BigDecimal detailPerPersonDeduction = detail.getStopScore().divide(new BigDecimal(detailPersonCount), 10, BigDecimal.ROUND_HALF_UP);
@@ -2816,6 +2816,51 @@ public class GxtRepairOrderServiceImpl implements IGxtRepairOrderService
         }
     }
 
+    public void completePendingOrderDeductionDataV0(GxtRepairOrder repairOrder) {
+        // 查询当前工单对应的GxtOrderScoreDetail且状态为1的数据(挂起状态)
+        GxtOrderScoreDetail queryDetail = new GxtOrderScoreDetail();
+        queryDetail.setOrderId(repairOrder.getId());
+        queryDetail.setOrderType(1); // 维修工单
+        queryDetail.setStatus(1); // 挂起状态
+        queryDetail.setScoreType(3); // 停机扣分
+
+        List<GxtOrderScoreDetail> scoreDetails = gxtOrderScoreDetailService.selectGxtOrderScoreDetailList(queryDetail);
+
+        if (scoreDetails == null || scoreDetails.isEmpty()) {
+            return; // 没有找到需要补全的扣分数据
+        }
+
+        // 针对每条GxtOrderScoreDetail记录分别处理
+        for (GxtOrderScoreDetail detail : scoreDetails) {
+            if (detail.getStopScore() == null || detail.getStopScore().compareTo(BigDecimal.ZERO) >= 0) {
+                continue; // 跳过无效或非负数的扣分记录
+            }
+
+            BigDecimal singleDeduction = detail.getStopScore();
+
+            // 获取工单所有人员列表
+            List<GxtRepairOrderPerson> allPersons = selectRepairOrderPersonListByOrderId(repairOrder.getId());
+
+            if (allPersons == null || allPersons.isEmpty()) {
+                continue; // 没有找到工单人员,跳过此条记录
+            }
+
+            repairOrder.setRepairOrderPersonList(allPersons);
+
+            // 计算每人扣分 = 单条扣分 ÷ 人员数量
+            int personCount = allPersons.size();
+            BigDecimal perPersonDeduction = singleDeduction.divide(new BigDecimal(personCount), 10, BigDecimal.ROUND_HALF_UP);
+
+            // 根据小数位数决定最终结果
+            if (perPersonDeduction.scale() > 6) {
+                perPersonDeduction = perPersonDeduction.setScale(6, BigDecimal.ROUND_HALF_UP);
+            }
+
+            // 更新每个人员的停机扣分
+            updatePersonStopScoreAndAddDetails(repairOrder, allPersons, perPersonDeduction, detail.getCreateTime());
+        }
+    }
+
     /**
      * 更新月度统计数据以反映停机扣分,使用工单归档时间确定月份
      *