Browse Source

工时计算

wuhb 3 months ago
parent
commit
8bc934c140

+ 6 - 2
ygtx-gxt/src/main/java/com/ygtx/gxt/service/impl/GxtOrderHourServiceImpl.java

@@ -22,6 +22,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -220,7 +222,7 @@ public class GxtOrderHourServiceImpl implements IGxtOrderHourService {
         for (OrderScoreInfo order : orderList) {
             // 使用专门计算作业时长的方法
             double hours = calculateWorkHours(order);
-            totalHours += hours;
+
             
             if (order.getOrderType() == 2) { // 维保工单
                 maintenanceHours += hours;
@@ -230,7 +232,9 @@ public class GxtOrderHourServiceImpl implements IGxtOrderHourService {
                 repairCount++;
             }
         }
-        
+        totalHours = BigDecimal.valueOf(maintenanceHours).setScale(2, RoundingMode.HALF_UP)
+                .add(BigDecimal.valueOf(repairHours).setScale(2, RoundingMode.HALF_UP))
+                .doubleValue();
         statistics.put("totalHours", totalHours);
         statistics.put("maintenanceHours", maintenanceHours);
         statistics.put("repairHours", repairHours);