소스 검색

整改清单报表

zhuang 1 년 전
부모
커밋
1c92df41d6
1개의 변경된 파일18개의 추가작업 그리고 9개의 파일을 삭제
  1. 18 9
      business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxProjectManageServiceImpl.java

+ 18 - 9
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxProjectManageServiceImpl.java

@@ -146,25 +146,32 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
     public R getRectifyReportData(Map<String, Object> map) {
         Object projectIdObj = map.get("projectId");
         if(ObjectUtil.isEmpty(projectIdObj)){
-            return R.error();
+            return R.error("");
         }
         String projectId = (String) projectIdObj;
         LambdaQueryWrapper<ZhcxProjectRectifyDo> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.and(i -> i.eq(ZhcxProjectRectifyDo::getPrjid, projectId));
         queryWrapper.and(i -> i.eq(ZhcxProjectRectifyDo::getDeleted, "0"));
-        ZhcxProjectRectifyDo zhcxProjectRectifyDo = projectRectifyService.getOne(queryWrapper);
-        if (zhcxProjectRectifyDo != null) {
+        List<ZhcxProjectRectifyDo> rectifyDos = projectRectifyService.list(queryWrapper);
+        if (rectifyDos != null && rectifyDos.size() > 0) {
             RectifyReportDto rectifyReportDto = new RectifyReportDto();
-            String machineno = zhcxProjectRectifyDo.getMachineno();
+            String machineno = rectifyDos.get(0).getMachineno();
             if (StringUtils.isNotBlank(machineno)) {
                 List<String> machineNoList = Arrays.asList(machineno .split(","));
                 //这里要存机号列表
                 rectifyReportDto.setNoList(machineNoList);
                 QueryWrapper<ZhcxProjectRectifyMachineDo> wrapper = new QueryWrapper<>();
-                wrapper.eq("PRJID", zhcxProjectRectifyDo.getPrjid());
+                wrapper.eq("PRJID", rectifyDos.get(0).getPrjid());
+                wrapper.isNotNull("DEPTID");
+                wrapper.isNotNull("STATUS");
                 List<ZhcxProjectRectifyMachineDo> list = projectRectifyMachineService.list(wrapper);
+                //根据施工部门分组
                 Map<String, List<ZhcxProjectRectifyMachineDo>> groupDeptList
                         = list.stream().collect(Collectors.groupingBy(ZhcxProjectRectifyMachineDo::getDeptname));
+                //根据一级部门分组
+                Map<String, List<ZhcxProjectRectifyMachineDo>> groupFirstDeptList
+                        = list.stream().filter(e -> Objects.nonNull(e.getFirstdeptname()))
+                        .collect(Collectors.groupingBy(ZhcxProjectRectifyMachineDo::getFirstdeptname));
                 List<RectifyDto> rectifyDtoList = new ArrayList<>();
                 groupDeptList.forEach((k, v) ->{
                     RectifyDto rectifyDto = new RectifyDto();
@@ -172,6 +179,7 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
                     rectifyDto.setFirstdeptname(v.get(0).getFirstdeptname());
                     rectifyDto.setDeptid(v.get(0).getDeptid());
                     rectifyDto.setDeptname(v.get(0).getDeptname());
+                    //根据机号分组
                     Map<String, List<ZhcxProjectRectifyMachineDo>> groupMachineList
                             = v.stream().collect(Collectors.groupingBy(ZhcxProjectRectifyMachineDo::getMachineno));
                     List<RectifyMachineDto> rectifyMachineDtoList = new ArrayList<>();
@@ -193,13 +201,14 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
                         int x = collect.getOrDefault("X", 0L).intValue();
                         rectifyMachine.setUnfinishedCount(x);
                         //完成率1
-                        int rateOne = divideAndRoundUp(ok + i,v2.size());
-                        rectifyMachine.setFinishRateOne(rateOne+"%");
+                        int rateOne = divideAndRoundUp((ok + i),v2.size());
+                         rectifyMachine.setFinishRateOne(rateOne+"%");
                         //完成率2
-                        int rateTwo = divideAndRoundUp(x,v2.size());
+                        int rateTwo = divideAndRoundUp(ok,v2.size());
                         rectifyMachine.setFinishRateTwo(rateTwo+"%");
                         rectifyMachineDtoList.add(rectifyMachine);
                     });
+
                     rectifyDto.setData(rectifyMachineDtoList);
                     rectifyDtoList.add(rectifyDto);
                 });
@@ -216,7 +225,7 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
             throw new IllegalArgumentException("Denominator cannot be zero");
         }
 
-        return (int) Math.ceil((double) numerator / denominator);
+        return (int) Math.round((double) numerator*100 / denominator);
     }
 
     /**