Prechádzať zdrojové kódy

整改清单报表-兼容批次

zhuang 1 rok pred
rodič
commit
b679a857ac

+ 10 - 5
business-common/src/main/java/com/rongwei/bscommon/sys/dao/ZhcxProjectManageDao.java

@@ -2,11 +2,11 @@ package com.rongwei.bscommon.sys.dao;
 
 import com.rongwei.bsentity.domain.ZhcxProjectManageDo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.rongwei.bsentity.domain.ZhcxProjectRectifyMachineDo;
 import com.rongwei.bsentity.vo.ZhcxProjectRectifyMachineVo;
 import org.apache.ibatis.annotations.Select;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -18,12 +18,17 @@ import java.util.List;
  */
 public interface ZhcxProjectManageDao extends BaseMapper<ZhcxProjectManageDo> {
 
-    @Select("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 = #{prjid} AND x.DEPTID is not null and " +
-            "x.STATUS is not null ")
-    List<ZhcxProjectRectifyMachineVo> getListData(String prjid);
+            "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);
 }

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

@@ -198,30 +198,46 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
     @Override
     public R getRectifyReportData(Map<String, Object> map) {
         Object projectIdObj = map.get("projectId");
+        Object batchIdObj = map.get("batchId");
         if (ObjectUtil.isEmpty(projectIdObj)) {
-            return R.error("");
+            return R.error();
         }
         String projectId = (String) projectIdObj;
-        //整改清单
-        List<ZhcxProjectRectifyDo> rectifyDos = projectRectifyService.list(
-                Wrappers.<ZhcxProjectRectifyDo>lambdaQuery()
-                        .eq(ZhcxProjectRectifyDo::getPrjid, projectId)
-                        .eq(ZhcxProjectRectifyDo::getDeleted, "0"));
-
-        if (rectifyDos == null || rectifyDos.isEmpty()) {
-            return R.ok();
-        }
         //获取机号
         RectifyReportDto rectifyReportDto = new RectifyReportDto();
-        String machineno = rectifyDos.get(0).getMachineno();
+        List<ZhcxProjectRectifyMachineVo> list;
+        String machineno = "";
+        //整改清单
+        if (ObjectUtil.isEmpty(batchIdObj)) {
+            List<ZhcxProjectRectifyDo> rectifyDos = projectRectifyService.list(
+                    Wrappers.<ZhcxProjectRectifyDo>lambdaQuery()
+                            .eq(ZhcxProjectRectifyDo::getPrjid, projectId)
+                            .eq(ZhcxProjectRectifyDo::getDeleted, "0"));
+
+            if (rectifyDos == null || rectifyDos.isEmpty()) {
+                return R.ok();
+            }
+            machineno = rectifyDos.get(0).getMachineno();
+        }else{
+            //批次
+            String batchId = (String) batchIdObj;
+            ZhcxProjectManageRectifyBatchDo rectifyBatchDo =  projectManageRectifyBatchService.getById(batchId);
+            machineno = rectifyBatchDo.getMachineno();
+        }
         if (StringUtils.isBlank(machineno)) {
             return R.ok();
         }
 
         List<String> machineNoList = Arrays.asList(machineno.split(","));
+        Collections.sort(machineNoList, (s1, s2) -> {
+            // 提取数字部分并转换为整数进行比较
+            int num1 = Integer.parseInt(s1.replace("#", ""));
+            int num2 = Integer.parseInt(s2.replace("#", ""));
+            return Integer.compare(num1, num2);
+        });
         rectifyReportDto.setNoList(machineNoList);
 
-        List<ZhcxProjectRectifyMachineVo> list = this.getListData(rectifyDos.get(0).getPrjid());
+        list = this.getListData(map);
         // 根据一级部门分组
         Map<String, List<ZhcxProjectRectifyMachineVo>> groupFirstDeptList = list.stream()
                 .filter(e -> Objects.nonNull(e.getFirstdeptid()))
@@ -297,6 +313,7 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
         //基地外合计
         List<ZhcxProjectRectifyMachineVo> collect3 = list.stream()
                 .filter(e -> !"b0bd3ed27bfb4af08535c39f464b3d3a".equals(e.getDeptid())
+                        && !"55c58ffb9d9b486abdd0dcb073f9b451".equals(e.getDeptid())
                         && Objects.isNull(e.getFirstdeptid())).collect(Collectors.toList());
         RectifyDto outSideRectifyDto = new RectifyDto();
         outSideRectifyDto.setDeptid(null);
@@ -321,8 +338,8 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
         return R.ok(rectifyReportDto);
     }
 
-    private List<ZhcxProjectRectifyMachineVo> getListData(String prjid) {
-        return zhcxProjectManageDao.getListData(prjid);
+    private List<ZhcxProjectRectifyMachineVo> getListData(Map<String, Object> map) {
+        return zhcxProjectManageDao.getListData(map);
     }
 
     /**
@@ -349,7 +366,7 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
                             .collect(Collectors.toList());
 
                     Map<String, Long> statusCount = distinctEntities.stream()
-                            .collect(Collectors.groupingBy(ZhcxProjectRectifyMachineDo::getStatus, Collectors.counting()));
+                            .collect(Collectors.groupingBy(e-> e.getStatus().trim().toLowerCase(), Collectors.counting()));
 
                     int okCount = statusCount.getOrDefault("ok", 0L).intValue();
                     int tbcCount = statusCount.getOrDefault("√", 0L).intValue();