shudonghui 1 year ago
parent
commit
b352dd67fd

+ 23 - 6
sop-api/src/main/java/com/qmth/sop/server/api/ServiceAnalyseController.java

@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
 import javax.validation.constraints.Min;
+import java.text.DecimalFormat;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
@@ -109,7 +110,7 @@ public class ServiceAnalyseController {
     public Result role(
     public Result role(
             @ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId,
             @ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId,
             @ApiParam(value = "供应商", required = true) @RequestParam Long supplierId) {
             @ApiParam(value = "供应商", required = true) @RequestParam Long supplierId) {
-        List<Map<String, Object>> list = serviceAnalyseService.supplierRole(serviceUnitId,supplierId);
+        List<Map<String, Object>> list = serviceAnalyseService.supplierRole(serviceUnitId, supplierId);
         return ResultUtil.ok(list);
         return ResultUtil.ok(list);
     }
     }
 
 
@@ -138,7 +139,7 @@ public class ServiceAnalyseController {
         map.put("projectRoleQuota", serviceAnalyseService.findCrmAllocationSubTotal(serviceUnitId, regionId, null));
         map.put("projectRoleQuota", serviceAnalyseService.findCrmAllocationSubTotal(serviceUnitId, regionId, null));
         List<UserArchivesAllocationResult> crmAllocation = serviceAnalyseService.findCrmAllocation(serviceUnitId, regionId, supplierId);
         List<UserArchivesAllocationResult> crmAllocation = serviceAnalyseService.findCrmAllocation(serviceUnitId, regionId, supplierId);
         map.put("projectWait", crmAllocation.stream().filter(e -> e.getDistributed() < e.getQuota()).count());
         map.put("projectWait", crmAllocation.stream().filter(e -> e.getDistributed() < e.getQuota()).count());
-        map.put("regionCities", crmAllocation.stream().filter(e->e.getCity()!=null).collect(Collectors.groupingBy(UserArchivesAllocationResult::getCity)).size());
+        map.put("regionCities", crmAllocation.stream().filter(e -> e.getCity() != null).collect(Collectors.groupingBy(UserArchivesAllocationResult::getCity)).size());
         return ResultUtil.ok(map);
         return ResultUtil.ok(map);
     }
     }
 
 
@@ -147,10 +148,19 @@ public class ServiceAnalyseController {
      */
      */
     @ApiOperation(value = "项目调配完成进度")
     @ApiOperation(value = "项目调配完成进度")
     @RequestMapping(value = "/project/allocation", method = RequestMethod.POST)
     @RequestMapping(value = "/project/allocation", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "项目调配完成进度", response = Long.class)})
+    @ApiResponses({@ApiResponse(code = 200, message = "项目调配完成进度", response = Double.class)})
     public Result allocation(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId) {
     public Result allocation(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId) {
         List<UserArchivesAllocationResult> crmAllocation = serviceAnalyseService.findCrmAllocation(serviceUnitId, null, null);
         List<UserArchivesAllocationResult> crmAllocation = serviceAnalyseService.findCrmAllocation(serviceUnitId, null, null);
-        return ResultUtil.ok(crmAllocation.isEmpty() ? 0 : crmAllocation.stream().filter(e -> e.getUnDistributed()<=0).count() / crmAllocation.size());
+
+        double result = crmAllocation.isEmpty() ? 0.00 : (double) crmAllocation.stream().filter(e -> e.getUnDistributed() > 0).count() / crmAllocation.size();
+// 创建DecimalFormat对象,指定保留两位小数
+        DecimalFormat decimalFormat = new DecimalFormat("#0.00");
+// 使用DecimalFormat格式化浮点数结果,得到字符串形式的结果
+        String formattedResult = decimalFormat.format(result);
+// 输出格式化后的结果
+        System.out.println(formattedResult);
+        return ResultUtil.success(formattedResult);
+//        return ResultUtil.ok(crmAllocation.isEmpty() ? 0.00 : crmAllocation.stream().filter(e -> e.getUnDistributed()<=0).count() / crmAllocation.size());
     }
     }
 
 
     /**
     /**
@@ -158,12 +168,19 @@ public class ServiceAnalyseController {
      */
      */
     @ApiOperation(value = "人员配额完成进度")
     @ApiOperation(value = "人员配额完成进度")
     @RequestMapping(value = "/personnel/quota", method = RequestMethod.POST)
     @RequestMapping(value = "/personnel/quota", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "人员配额完成进度", response = Long.class)})
+    @ApiResponses({@ApiResponse(code = 200, message = "人员配额完成进度", response = Double.class)})
     public Result quota(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId) {
     public Result quota(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId) {
         List<UserArchivesAllocationResult> list = serviceAnalyseService.findCrmAllocation(serviceUnitId, null, null);
         List<UserArchivesAllocationResult> list = serviceAnalyseService.findCrmAllocation(serviceUnitId, null, null);
         int quota = list.stream().mapToInt(UserArchivesAllocationResult::getQuota).sum();
         int quota = list.stream().mapToInt(UserArchivesAllocationResult::getQuota).sum();
         int distributed = list.stream().mapToInt(UserArchivesAllocationResult::getDistributed).sum();
         int distributed = list.stream().mapToInt(UserArchivesAllocationResult::getDistributed).sum();
-        return ResultUtil.ok(quota == 0 ? 0 : distributed / quota);
+        double result = quota == 0 ? 0 : (double) distributed / quota;
+// 创建DecimalFormat对象,指定保留两位小数
+        DecimalFormat decimalFormat = new DecimalFormat("#0.00");
+// 使用DecimalFormat格式化浮点数结果,得到字符串形式的结果
+        String formattedResult = decimalFormat.format(result);
+// 输出格式化后的结果
+        System.out.println(formattedResult);
+        return ResultUtil.success(formattedResult);
     }
     }
 
 
     /**
     /**

+ 6 - 6
sop-business/src/main/java/com/qmth/sop/business/service/impl/SopAnalyseServiceImpl.java

@@ -64,15 +64,15 @@ public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopIn
         //已完成派单数
         //已完成派单数
         map.put("finishCrmNum", v.stream().collect(Collectors.groupingBy(map1 -> map1.get("crm_no"))).values().stream().filter(list1 -> list1.stream().allMatch(map1 -> "FINISH".equals(map1.get("sopStatus"))) || list1.stream().allMatch(map1 -> "FINISH".equals(map1.get("status")))).count());
         map.put("finishCrmNum", v.stream().collect(Collectors.groupingBy(map1 -> map1.get("crm_no"))).values().stream().filter(list1 -> list1.stream().allMatch(map1 -> "FINISH".equals(map1.get("sopStatus"))) || list1.stream().allMatch(map1 -> "FINISH".equals(map1.get("status")))).count());
         //违规数
         //违规数
-        map.put("violationNum", v.stream().filter(map1 -> map1.get("did") != null).collect(Collectors.groupingBy(map1 -> map1.get("did"))).size());
+        map.put("violationNum", v.stream().filter(map1 -> map1.get("vid") != null).collect(Collectors.groupingBy(map1 -> map1.get("vid"))).size());
         //已关闭违规数
         //已关闭违规数
-        map.put("finishViolationNum", v.stream().filter(map1 -> map1.get("did") != null && "CLOSE".equals(map1.get("dstatus"))).count());
+        map.put("finishViolationNum", v.stream().filter(map1 -> map1.get("vid") != null && "CLOSE".equals(map1.get("vstatus"))).collect(Collectors.groupingBy(map1 -> map1.get("vid"))).size());
         //延期数
         //延期数
-        map.put("delayNum", v.stream().filter(map1 -> map1.get("vid") != null).collect(Collectors.groupingBy(map1 -> map1.get("vid"))).size());
+        map.put("delayNum", v.stream().filter(map1 -> map1.get("did") != null).collect(Collectors.groupingBy(map1 -> map1.get("did"))).size());
         //已关闭延期数
         //已关闭延期数
-        map.put("finishDelayNum", v.stream().filter(map1 -> map1.get("vid") != null && "CLOSE".equals(map1.get("vstatus"))).count());
-        Double processViolationTime = v.stream().filter(map1 -> map1.get("ddiff") != null).mapToDouble(map1 -> Double.parseDouble(map1.get("ddiff").toString())).sum();
-        Double processDelayTime = v.stream().filter(map1 -> map1.get("vdiff") != null).mapToDouble(map1 -> Double.parseDouble(map1.get("vdiff").toString())).sum();
+        map.put("finishDelayNum", v.stream().filter(map1 -> map1.get("did") != null && "CLOSE".equals(map1.get("dstatus"))).collect(Collectors.groupingBy(map1 -> map1.get("vid"))).size());
+        Double processViolationTime = v.stream().filter(map1 -> map1.get("vdiff") != null).mapToDouble(map1 -> Double.parseDouble(map1.get("vdiff").toString())).sum();
+        Double processDelayTime = v.stream().filter(map1 -> map1.get("ddiff") != null).mapToDouble(map1 -> Double.parseDouble(map1.get("ddiff").toString())).sum();
         //平均处理时限分钟
         //平均处理时限分钟
         int total = (Integer.parseInt(map.get("finishViolationNum").toString()) + Integer.parseInt(map.get("finishDelayNum").toString()));
         int total = (Integer.parseInt(map.get("finishViolationNum").toString()) + Integer.parseInt(map.get("finishDelayNum").toString()));
         map.put("avgMinutes", total == 0 ? 0 : (processViolationTime + processDelayTime) / total);
         map.put("avgMinutes", total == 0 ? 0 : (processViolationTime + processDelayTime) / total);