Просмотр исходного кода

整改查看 --处理施工 责任多部门情况

zhuang 8 месяцев назад
Родитель
Сommit
cb8a68e53e

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

@@ -505,7 +505,21 @@ public class ZhcxProjectManageServiceImpl extends ServiceImpl<ZhcxProjectManageD
             ZhcxProjectRectifyVo vo = new ZhcxProjectRectifyVo();
             //copier.copy(rectify, vo, null);
             BeanUtil.copyProperties(rectify, vo);
-            vo.setData(machineVos == null ? new ArrayList<>() : machineVos);
+            // 如果 machineVos 不为空,按机号合并部门
+            if (machineVos != null) {
+                List<ZhcxProjectRectifyMachineVo> mergedMachineVos = machineVos.stream()
+                        .collect(Collectors.toMap(
+                                ZhcxProjectRectifyMachineVo::getMachineno,
+                                voItem -> voItem, // 初始对象
+                                ZhcxProjectRectifyMachineVo::merge // 使用自定义方法合并对象
+                        ))
+                        .values().stream().collect(Collectors.toList());
+
+                vo.setData(mergedMachineVos);
+            } else {
+                vo.setData(new ArrayList<>());
+            }
+            //vo.setData(machineVos == null ? new ArrayList<>() : machineVos);
             list.add(vo);
         });
         list.forEach(ev -> {

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

@@ -3,6 +3,7 @@ package com.rongwei.bsentity.vo;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.rongwei.bsentity.domain.ZhcxProjectRectifyMachineDo;
 import lombok.Data;
+import org.springframework.beans.BeanUtils;
 
 import java.util.Date;
 
@@ -19,6 +20,17 @@ public class ZhcxProjectRectifyMachineVo extends ZhcxProjectRectifyMachineDo {
     public ZhcxProjectRectifyMachineVo(String no) {
         this.setMachineno(no);
     }
-
+    public ZhcxProjectRectifyMachineVo() {}
+
+    // 静态方法:复制对象并合并部门
+    public static ZhcxProjectRectifyMachineVo merge(ZhcxProjectRectifyMachineVo existing, ZhcxProjectRectifyMachineVo replacement) {
+        ZhcxProjectRectifyMachineVo merged = new ZhcxProjectRectifyMachineVo();
+        // 使用 Spring BeanUtils 复制属性
+        BeanUtils.copyProperties(existing, merged);
+        // 合并部门
+        merged.setDeptname(existing.getDeptname() + "、" + replacement.getDeptname());
+        merged.setDutydeptname(existing.getDutydeptname() + "、" + replacement.getDutydeptname());
+        return merged;
+    }
     //private Integer outsidedeptsort;
 }