|
@@ -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
|