浏览代码

整改清单报表调整

zhuang 11 月之前
父节点
当前提交
3851c8cc94

+ 16 - 4
business-common/src/main/java/com/rongwei/bscommon/sys/dao/ZhcxProjectManageDao.java

@@ -18,11 +18,23 @@ import java.util.Map;
  */
 public interface ZhcxProjectManageDao extends BaseMapper<ZhcxProjectManageDo> {
 
-    @Select("<script>SELECT so.SORT AS DEPTSORT,so2.SORT AS FIRSTDEPTSORT,di.SORT AS OUTSIDEDEPTSORT," +
+//    @Select("<script>SELECT so.SORT AS DEPTSORT,so2.SORT AS FIRSTDEPTSORT,di.SORT AS OUTSIDEDEPTSORT," +
+//            "x.* FROM INCONTROL.ZHCX_PROJECT_RECTIFY_MACHINE x " +
+//            "LEFT JOIN SYS_ORGANIZATION so ON x.DEPTID = so.ID " +
+//            "LEFT JOIN SYS_ORGANIZATION so2 ON x.FIRSTDEPTID  = so2.ID " +
+//            "LEFT JOIN SYS_DICT di ON x.DEPTID = di.ID AND DICTTYPE = 'rectification_organization' " +
+//            "where x.PRJID = #{projectId} " +
+//            "<if test='batchId !=null'>" +
+//            "AND x.BATCHID=#{batchId}" +
+//            "</if>" +
+//            "AND x.DEPTID is not null and " +
+//            "x.STATUS is not null " +
+//            "</script>")
+//    List<ZhcxProjectRectifyMachineVo> getListData(Map<String, Object> map);
+    @Select("<script>SELECT di.SORT AS DEPTSORT,di2.SORT AS FIRSTDEPTSORT," +
             "x.* FROM INCONTROL.ZHCX_PROJECT_RECTIFY_MACHINE x " +
-            "LEFT JOIN SYS_ORGANIZATION so ON x.DEPTID = so.ID " +
-            "LEFT JOIN SYS_ORGANIZATION so2 ON x.FIRSTDEPTID  = so2.ID " +
-            "LEFT JOIN SYS_DICT di ON x.DEPTID = di.ID AND DICTTYPE = 'rectification_organization' " +
+            "LEFT JOIN SYS_DICT di ON x.DEPTID = di.ID AND di.DICTTYPE = 'rectification_organization' " +
+            "LEFT JOIN SYS_DICT di2 ON x.FIRSTDEPTID  = di2.ID AND di.DICTTYPE = 'rectification_organization' " +
             "where x.PRJID = #{projectId} " +
             "<if test='batchId !=null'>" +
             "AND x.BATCHID=#{batchId}" +

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

@@ -246,49 +246,64 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
         Map<String, List<ZhcxProjectRectifyMachineVo>> groupFirstDeptList = list.stream()
                 .filter(e -> Objects.nonNull(e.getFirstdeptid()))
                 .collect(Collectors.groupingBy(ZhcxProjectRectifyMachineVo::getFirstdeptname));
-        //汇总一级部门数据
+        //汇总一级部门数据包括自身的数据
         List<RectifyDto> firstDeptRectifyList = new ArrayList<>();
         groupFirstDeptList.forEach((firstDeptName, machines) -> {
             RectifyDto rectifyDto = new RectifyDto();
             rectifyDto.setFirstdeptsort(machines.get(0).getFirstdeptsort());
             rectifyDto.setFirstdeptid(machines.get(0).getFirstdeptid());
             rectifyDto.setFirstdeptname(machines.get(0).getFirstdeptname());
+            //自身的部门数据设值和一级部门一致 参与汇总
+            //rectifyDto.setDeptsort(machines.get(0).getFirstdeptsort());
+            rectifyDto.setDeptid(machines.get(0).getFirstdeptid());
+            rectifyDto.setDeptname(machines.get(0).getFirstdeptname());
+            rectifyDto.setIfoutsidebase(machines.get(0).getIfoutsidebase());
             rectifyDto.setData(createRectifyMachineDtoList(machines, ZhcxProjectRectifyMachineVo::getFirstdeptid));
             firstDeptRectifyList.add(rectifyDto);
         });
 
-        // 根据施工部门分组
+        // 根据施工部门分组 过滤一级部门和施工部门相同的 此为上面汇总一级部门数据
         Map<String, List<ZhcxProjectRectifyMachineVo>> groupDeptList = list.stream()
+                .filter(e -> Objects.nonNull(e.getFirstdeptid())
+                        && !e.getFirstdeptid().equals(e.getDeptid()))
                 .collect(Collectors.groupingBy(ZhcxProjectRectifyMachineVo::getDeptname));
 
         List<RectifyDto> rectifyDtoList = new ArrayList<>();
-        Set<String> processedFirstDeptIds = new HashSet<>();
+        rectifyDtoList.addAll(firstDeptRectifyList);
+        //Set<String> processedFirstDeptIds = new HashSet<>();
         //汇总施工部门数据
         groupDeptList.forEach((deptName, machines) -> {
             String firstDeptId = machines.get(0).getFirstdeptid();
-            if (processedFirstDeptIds.add(firstDeptId)) {
-                List<RectifyDto> collect = firstDeptRectifyList.stream()
-                        .filter(ev -> ev.getFirstdeptid().equals(firstDeptId))
-                        .collect(Collectors.toList());
-                rectifyDtoList.addAll(collect);
-            }
+//            if (processedFirstDeptIds.add(firstDeptId)) {
+//                List<RectifyDto> collect = firstDeptRectifyList.stream()
+//                        .filter(ev -> ev.getFirstdeptid().equals(firstDeptId))
+//                        .collect(Collectors.toList());
+//                rectifyDtoList.addAll(collect);
+//            }
 
             RectifyDto rectifyDto = new RectifyDto();
             rectifyDto.setFirstdeptsort(machines.get(0).getFirstdeptsort());
             rectifyDto.setFirstdeptid(firstDeptId);
             rectifyDto.setFirstdeptname(machines.get(0).getFirstdeptname());
             rectifyDto.setDeptsort(machines.get(0).getDeptsort());
-            rectifyDto.setOutsidedeptsort(machines.get(0).getOutsidedeptsort());
+            //rectifyDto.setOutsidedeptsort(machines.get(0).getOutsidedeptsort());
             rectifyDto.setDeptid(machines.get(0).getDeptid());
             rectifyDto.setDeptname(deptName);
+            rectifyDto.setIfoutsidebase(machines.get(0).getIfoutsidebase());
             rectifyDto.setData(createRectifyMachineDtoList(machines,ZhcxProjectRectifyMachineDo::getDeptid));
             rectifyDtoList.add(rectifyDto);
         });
         //排序
         //rectifyDtoList.sort(Comparator.comparing(RectifyDto::getFirstdeptid, Comparator.nullsLast(String::compareTo)));
         rectifyDtoList.sort((d1, d2) -> {
+            int ifoutsidebase1 = "inside".equals(d1.getIfoutsidebase()) ? 0 : 1;
+            int ifoutsidebase2 = "inside".equals(d2.getIfoutsidebase()) ? 0 : 1;
+            int ifoutsideBaseCompare = Integer.compare(ifoutsidebase1, ifoutsidebase2);
+            if (ifoutsideBaseCompare != 0) {
+                return ifoutsideBaseCompare;
+            }
             // 先按一级部门排序,空的排到最后
-            int firstDeptCompare = Comparator.comparing(RectifyDto::getFirstdeptsort, Comparator.nullsLast(Integer::compareTo)).compare(d1, d2);
+            int firstDeptCompare = Comparator.comparing(RectifyDto::getFirstdeptsort, Comparator.nullsFirst(Integer::compareTo)).compare(d1, d2);
             if (firstDeptCompare != 0) {
                 return firstDeptCompare;
             }
@@ -297,28 +312,33 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
             if (secondDeptCompare != 0) {
                 return secondDeptCompare;
             }
+            return 0;
             // 最后按基地外排序
-            return Comparator.comparing(RectifyDto::getOutsidedeptsort, Comparator.nullsLast(Integer::compareTo)).compare(d1, d2);
+            //return Comparator.comparing(RectifyDto::getOutsidedeptsort, Comparator.nullsLast(Integer::compareTo)).compare(d1, d2);
         });
         //基地内合计
+//        List<ZhcxProjectRectifyMachineVo> collect = list.stream()
+//                .filter(e -> Objects.nonNull(e.getFirstdeptid())).collect(Collectors.toList());
         List<ZhcxProjectRectifyMachineVo> collect = list.stream()
-                .filter(e -> Objects.nonNull(e.getFirstdeptid())).collect(Collectors.toList());
-        //长兴基地 大车行走配套事业部
-        List<String> deptIds = Arrays.asList("b0bd3ed27bfb4af08535c39f464b3d3a"
-                ,"55c58ffb9d9b486abdd0dcb073f9b451");
-        List<ZhcxProjectRectifyMachineVo> collect2 = list.stream()
-                .filter(e -> deptIds.contains(e.getDeptid())).collect(Collectors.toList());
-        collect.addAll(collect2);
+                .filter(e -> "inside".equals(e.getIfoutsidebase())).collect(Collectors.toList());
+//        //长兴基地 大车行走配套事业部
+//        List<String> deptIds = Arrays.asList("b0bd3ed27bfb4af08535c39f464b3d3a"
+//                ,"55c58ffb9d9b486abdd0dcb073f9b451");
+//        List<ZhcxProjectRectifyMachineVo> collect2 = list.stream()
+//                .filter(e -> deptIds.contains(e.getDeptid())).collect(Collectors.toList());
+//        collect.addAll(collect2);
         RectifyDto rectifyDto = new RectifyDto();
         rectifyDto.setDeptid(null);
         rectifyDto.setDeptname("基地内合计");
         rectifyDto.setData(createRectifyMachineDtoList(collect,null));
         rectifyDtoList.add(rectifyDto);
         //基地外合计
+//        List<ZhcxProjectRectifyMachineVo> collect3 = list.stream()
+//                .filter(e -> !"b0bd3ed27bfb4af08535c39f464b3d3a".equals(e.getDeptid())
+//                        && !"55c58ffb9d9b486abdd0dcb073f9b451".equals(e.getDeptid())
+//                        && Objects.isNull(e.getFirstdeptid())).collect(Collectors.toList());
         List<ZhcxProjectRectifyMachineVo> collect3 = list.stream()
-                .filter(e -> !"b0bd3ed27bfb4af08535c39f464b3d3a".equals(e.getDeptid())
-                        && !"55c58ffb9d9b486abdd0dcb073f9b451".equals(e.getDeptid())
-                        && Objects.isNull(e.getFirstdeptid())).collect(Collectors.toList());
+                .filter(e -> "outside".equals(e.getIfoutsidebase())).collect(Collectors.toList());
         RectifyDto outSideRectifyDto = new RectifyDto();
         outSideRectifyDto.setDeptid(null);
         outSideRectifyDto.setDeptname("基地外合计");
@@ -599,7 +619,8 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
                 // 设置颜色
                 for (int j = colIndex; j < colIndex + 6; j++) {
                     Style cellStyle = cells.get(rowIndex, j).getStyle();
-                    if (StringUtils.isNotBlank(row.getDeptid())) {
+                    if ((StringUtils.isNotBlank(row.getDeptid()) && !row.getDeptid().equals(row.getFirstdeptid())) ||
+                            "outside".equals(row.getIfoutsidebase()) ) {
                         cellStyle.setForegroundColor(COLORS[colorIndex % 2]);
                     }else if(StringUtils.isBlank(row.getDeptid())
                             && StringUtils.isBlank(row.getFirstdeptid())
@@ -635,9 +656,10 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
         Style style = cells.get(rowIndex, 1).getStyle();
         style.setPattern(BackgroundType.SOLID);
         //车间颜色
-        if(StringUtils.isNotBlank(row.getDeptid()) && StringUtils.isNotBlank(row.getFirstdeptid())){
+        if(StringUtils.isNotBlank(row.getDeptid()) && StringUtils.isNotBlank(row.getFirstdeptid())
+                && !row.getDeptid().equals(row.getFirstdeptid()) && "inside".equals(row.getIfoutsidebase())){
             style.setForegroundColor(COLORS[3]);
-        }else if(StringUtils.isNotBlank(row.getDeptid()) && StringUtils.isBlank(row.getFirstdeptid())){
+        }else if("outside".equals(row.getIfoutsidebase())){
             //基地外颜色
             style.setForegroundColor(COLORS[4]);
         }else if(StringUtils.isBlank(row.getDeptid()) && StringUtils.isBlank(row.getFirstdeptid())

+ 2 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/RectifyDto.java

@@ -43,4 +43,6 @@ public class RectifyDto {
     private Integer firstdeptsort;
     @JsonIgnore
     private Integer outsidedeptsort;
+
+    private String ifoutsidebase;
 }

+ 1 - 1
business-entity/src/main/java/com/rongwei/bsentity/vo/ZhcxProjectRectifyMachineVo.java

@@ -10,5 +10,5 @@ public class ZhcxProjectRectifyMachineVo extends ZhcxProjectRectifyMachineDo {
 
     private Integer firstdeptsort;
 
-    private Integer outsidedeptsort;
+    //private Integer outsidedeptsort;
 }