Quellcode durchsuchen

整改清单查看功能开发

zhuang vor 9 Monaten
Ursprung
Commit
4482fa1450

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

@@ -49,4 +49,14 @@ public interface ZhcxProjectManageDao extends BaseMapper<ZhcxProjectManageDo> {
             "</where>" +
             "</script>")
     List<ZhcxProjectRectifyMachineVo> getListData(Map<String, Object> map);
+
+    @Select("<script>SELECT x.* FROM INCONTROL.ZHCX_PROJECT_RECTIFY_MACHINE x " +
+            "<where> " +
+            "<if test='batchId !=null'>" +
+            "AND x.BATCHID=#{batchId}" +
+            "</if>" +
+            " and x.STATUS is not null " +
+            "</where>" +
+            "</script>")
+    List<ZhcxProjectRectifyMachineVo> getRectifyListData(Map<String, Object> map);
 }

+ 2 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxProjectManageService.java

@@ -80,4 +80,6 @@ public interface ZhcxProjectManageService extends IService<ZhcxProjectManageDo>
     List<JSONObject> getWorkshop();
 
     List<ZhcxProjectRectifyMachineVo> getListData(Map<String, Object> map);
+
+    R getRectifyListData(Map<String, Object> map);
 }

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

@@ -1,6 +1,8 @@
 package com.rongwei.bscommon.sys.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ArrayUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSONArray;
@@ -18,10 +20,12 @@ import com.rongwei.bsentity.domain.*;
 import com.rongwei.bscommon.sys.dao.ZhcxProjectManageDao;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwei.bsentity.dto.RectifyDto;
+import com.rongwei.bsentity.dto.RectifyListDto;
 import com.rongwei.bsentity.dto.RectifyMachineDto;
 import com.rongwei.bsentity.dto.RectifyReportDto;
 import com.rongwei.bsentity.dto.project.*;
 import com.rongwei.bsentity.vo.ZhcxProjectRectifyMachineVo;
+import com.rongwei.bsentity.vo.ZhcxProjectRectifyVo;
 import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.base.exception.CustomException;
 import com.rongwei.rwcommon.utils.SecurityUtil;
@@ -32,8 +36,10 @@ import com.rongwei.rwcommoncomponent.file.service.SysFileItemService;
 import com.rongwei.rwcommonentity.commonservers.domain.SysFileItemDo;
 import io.swagger.models.auth.In;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.beanutils.BeanUtils;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cglib.beans.BeanCopier;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.Resource;
@@ -41,6 +47,7 @@ import org.springframework.stereotype.Service;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
+import java.lang.reflect.InvocationTargetException;
 import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
@@ -414,6 +421,99 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
         return zhcxProjectManageDao.getListData(map);
     }
 
+    //private static final BeanCopier copier = BeanCopier.create(ZhcxProjectRectifyDo.class, ZhcxProjectRectifyVo.class, false);
+    @Override
+    public R getRectifyListData(Map<String, Object> map) {
+        Object batchIdObj = map.get("batchId");
+        if (ObjectUtil.isEmpty(batchIdObj)) {
+            return R.error();
+        }
+        String batchId = (String) batchIdObj;
+        List<ZhcxProjectRectifyVo> list = new ArrayList<>();
+        RectifyListDto rectifyListDto = new RectifyListDto();
+        List<ZhcxProjectRectifyDo> rectifyDos = projectRectifyService.list(
+                Wrappers.<ZhcxProjectRectifyDo>lambdaQuery()
+                        .eq(ZhcxProjectRectifyDo::getBatchid, batchId)
+                        .eq(ZhcxProjectRectifyDo::getDeleted, "0"));
+        List<ZhcxProjectRectifyMachineVo> listData = zhcxProjectManageDao.getRectifyListData(map);
+        ZhcxProjectManageRectifyBatchDo rectifyBatchDo =  projectManageRectifyBatchService.getById(batchId);
+        String machineno = rectifyBatchDo.getMachineno();
+        List<String> machineNoList = Arrays.asList(machineno.split(","));
+        Collections.sort(machineNoList, (sort1, sort2) -> {
+
+            String projectCode1 = null;
+            String projectCode2 = null;
+            String sort1Temp;
+            String sort2Temp;
+            if(sort1.contains("-")) {
+                final String[] split = sort1.split("-");
+                projectCode1 = split[0];
+                sort1Temp = split[1];
+            } else {
+                sort1Temp = sort1;
+            }
+
+            if(sort2.contains("-")) {
+                final String[] split = sort2.split("-");
+                projectCode2 = split[0];
+                sort2Temp = split[1];
+            } else {
+                sort2Temp =  sort2;
+            }
+
+            // 提取数字部分并转换为整数进行比较
+            int sort1Int = Integer.parseInt(sort1Temp.replace("#", ""));
+            int sort2Int = Integer.parseInt(sort2Temp.replace("#", ""));
+
+            if(ObjectUtil.isEmpty(projectCode1) && ObjectUtil.isEmpty(projectCode2)) {
+                return sort1Int - sort2Int;
+            }
+
+            if(ObjectUtil.isEmpty(projectCode1) && ObjectUtil.isNotEmpty(projectCode2)) {
+                return -1;
+            }
+
+            if(ObjectUtil.isNotEmpty(projectCode1) && ObjectUtil.isEmpty(projectCode2)) {
+                return 1;
+            }
+
+            if(ObjectUtil.isNotEmpty(projectCode1) && ObjectUtil.isNotEmpty(projectCode2)) {
+                if(projectCode1.equals(projectCode2)) {
+                    return sort1Int - sort2Int;
+                } else {
+                    return projectCode1.compareTo(projectCode2);
+                }
+            }
+            return sort1Int - sort2Int;
+        });
+        rectifyListDto.setNoList(machineNoList);
+        //根据整改清单id 分组
+        Map<String, List<ZhcxProjectRectifyMachineVo>> collect =
+                listData.stream().filter(item -> Objects.nonNull(item.getRectifyid()))
+                        .collect(Collectors.groupingBy(ZhcxProjectRectifyMachineVo::getRectifyid));
+        rectifyDos.forEach(rectify -> {
+            String id = rectify.getId();
+            List<ZhcxProjectRectifyMachineVo> machineVos = collect.get(id);
+            ZhcxProjectRectifyVo vo = new ZhcxProjectRectifyVo();
+            //copier.copy(rectify, vo, null);
+            BeanUtil.copyProperties(rectify, vo);
+            vo.setData(machineVos == null ? new ArrayList<>() : machineVos);
+            list.add(vo);
+        });
+        list.forEach(ev -> {
+            machineNoList.forEach(no -> {
+                if (ev.getData().stream().noneMatch(data -> data.getMachineno().equals(no))) {
+                    ev.getData().add(new ZhcxProjectRectifyMachineVo(no));
+                }
+                String format = DateUtil.format(ev.getReqdate(), "yyyy-MM-dd");
+                ev.setReqDateFmt(format);
+            });
+            ev.getData().sort(Comparator.comparingInt(a -> machineNoList.indexOf(a.getMachineno())));
+        });
+        rectifyListDto.setData(list);
+        return R.ok(rectifyListDto);
+    }
+
     /**
      * 根据机号和动态传入参数分组 统计
      * @param machines

+ 24 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/RectifyListDto.java

@@ -0,0 +1,24 @@
+package com.rongwei.bsentity.dto;
+
+import com.rongwei.bsentity.vo.ZhcxProjectRectifyVo;
+import lombok.*;
+
+import java.util.List;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class RectifyListDto {
+
+    /**
+     * 机号列表
+     */
+    private List<String> noList;
+    /**
+     * 整改数据列表
+     */
+    private List<ZhcxProjectRectifyVo> data;
+
+}

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

@@ -10,5 +10,9 @@ public class ZhcxProjectRectifyMachineVo extends ZhcxProjectRectifyMachineDo {
 
     private Integer firstdeptsort;
 
+    public ZhcxProjectRectifyMachineVo(String no) {
+        this.setMachineno(no);
+    }
+
     //private Integer outsidedeptsort;
 }

+ 14 - 0
business-entity/src/main/java/com/rongwei/bsentity/vo/ZhcxProjectRectifyVo.java

@@ -0,0 +1,14 @@
+package com.rongwei.bsentity.vo;
+
+import com.rongwei.bsentity.domain.ZhcxProjectRectifyDo;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class ZhcxProjectRectifyVo extends ZhcxProjectRectifyDo {
+
+    private List<ZhcxProjectRectifyMachineVo> data;
+
+    private String reqDateFmt;
+}

+ 8 - 0
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxProjectManageController.java

@@ -130,6 +130,14 @@ public class ZhcxProjectManageController {
         R r = service.getRectifyReportData(map);
         return r;
     }
+
+    @PostMapping("/getRectifyListData")
+    @ApiOperation("获取整改清单数据")
+    public R getRectifyListData(@RequestBody Map<String,Object> map) {
+        R r = service.getRectifyListData(map);
+        return r;
+    }
+
     @PostMapping("/exportRectifyReportData")
     @ApiOperation("导出整改报表数据")
     public void exportRectifyReportData(@RequestBody Map<String,Object> map, HttpServletResponse response) {