Kaynağa Gözat

构件跟踪改造

wangming 1 gün önce
ebeveyn
işleme
19d6282c61

+ 42 - 21
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxOutsideInspectionComponentTrackServiceImpl.java

@@ -2,16 +2,15 @@ package com.rongwei.bscommon.sys.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.rongwei.bscommon.sys.service.ZhcxItpProjectNodesService;
-import com.rongwei.bsentity.domain.ZhcxItpProjectNodesDo;
+import com.rongwei.bscommon.sys.utils.StrUtils;
 import com.rongwei.bsentity.domain.ZhcxOutsideInspectionComponentTrackDo;
 import com.rongwei.bscommon.sys.dao.ZhcxOutsideInspectionComponentTrackDao;
 import com.rongwei.bscommon.sys.service.ZhcxOutsideInspectionComponentTrackService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwei.bsentity.domain.ZhcxOutsideInspectionItpDo;
 import com.rongwei.rwcommon.utils.SecurityUtil;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -27,9 +26,6 @@ import java.util.List;
 @Service
 public class ZhcxOutsideInspectionComponentTrackServiceImpl extends ServiceImpl<ZhcxOutsideInspectionComponentTrackDao, ZhcxOutsideInspectionComponentTrackDo> implements ZhcxOutsideInspectionComponentTrackService {
 
-    @Autowired
-    private ZhcxItpProjectNodesService zhcxItpProjectNodesService;
-
     /**
      * 保存跟踪
      *
@@ -43,7 +39,30 @@ public class ZhcxOutsideInspectionComponentTrackServiceImpl extends ServiceImpl<
             return ;
         }
 
-        save(entity);
+        // 获取构件跟踪表数据,存在则只更新挂靠单位
+        LambdaQueryWrapper<ZhcxOutsideInspectionComponentTrackDo> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(ZhcxOutsideInspectionComponentTrackDo::getStructurename, itpDo.getStructurename())
+                .eq(ZhcxOutsideInspectionComponentTrackDo::getMachineno, itpDo.getMachineno())
+                .eq(ZhcxOutsideInspectionComponentTrackDo::getStructuremachineno, itpDo.getStructuremachineno())
+                .eq(ZhcxOutsideInspectionComponentTrackDo::getDeleted, "0")
+                .eq(ZhcxOutsideInspectionComponentTrackDo::getProjectid, itpDo.getProjectid());
+        List<ZhcxOutsideInspectionComponentTrackDo> trackDoList = list(queryWrapper);
+
+        //不存在,新增项目构件中总装与结构机号的关系
+        if(ObjectUtil.isEmpty(trackDoList)) {
+            save(entity);
+        } else { //存在的话更新总装和结构机号所对应分包商关系
+            final ZhcxOutsideInspectionComponentTrackDo trackDo = trackDoList.get(0);
+
+            final String unitIds = StrUtils.addIdAndDeduplicate(trackDo.getSubcontractorunitid(), itpDo.getSubcontractorunitid());
+            final String strctUnitIds = StrUtils.addIdAndDeduplicate(trackDo.getStructsubcontractorunitid(), itpDo.getSubcontractorunitid());
+            final LambdaUpdateWrapper<ZhcxOutsideInspectionComponentTrackDo> updateWrapper = Wrappers.lambdaUpdate();
+            updateWrapper.eq(ZhcxOutsideInspectionComponentTrackDo::getId, trackDo.getId())
+                    .set(ZhcxOutsideInspectionComponentTrackDo::getStructsubcontractorunitid, unitIds)
+                    .set(ZhcxOutsideInspectionComponentTrackDo::getSubcontractorunitid, strctUnitIds);
+            update(updateWrapper);
+        }
+
     }
 
     /**
@@ -106,6 +125,7 @@ public class ZhcxOutsideInspectionComponentTrackServiceImpl extends ServiceImpl<
 
         //分包商挂靠单位id
         entity.setSubcontractorunitid(itpDo.getSubcontractorunitid());
+        entity.setStructsubcontractorunitid(itpDo.getSubcontractorunitid());
     }
 
     /**
@@ -126,19 +146,19 @@ public class ZhcxOutsideInspectionComponentTrackServiceImpl extends ServiceImpl<
         }
 
         //报验点属性
-        LambdaQueryWrapper<ZhcxItpProjectNodesDo> tWrapper = Wrappers.lambdaQuery();
-        tWrapper.eq(ZhcxItpProjectNodesDo::getPid, itpDo.getStructureid())
-                .eq(ZhcxItpProjectNodesDo::getDeleted, "0")
-                .eq(ZhcxItpProjectNodesDo::getNodename, itpDo.getInspectioncontent().replace(itpDo.getStructurename().concat("-"), ""))
-                .eq(ZhcxItpProjectNodesDo::getProjectid, itpDo.getProjectid());
-        ZhcxItpProjectNodesDo nodesDo = zhcxItpProjectNodesService.getOne(tWrapper);
-        if(ObjectUtil.isNull(nodesDo)) {
-            return false;
-        }
-
-        if(ObjectUtil.isEmpty(nodesDo.getIsneedinput()) || !"true".equals(nodesDo.getIsneedinput())) {
-            return false;
-        }
+//        LambdaQueryWrapper<ZhcxItpProjectNodesDo> tWrapper = Wrappers.lambdaQuery();
+//        tWrapper.eq(ZhcxItpProjectNodesDo::getPid, itpDo.getStructureid())
+//                .eq(ZhcxItpProjectNodesDo::getDeleted, "0")
+//                .eq(ZhcxItpProjectNodesDo::getNodename, itpDo.getInspectioncontent().replace(itpDo.getStructurename().concat("-"), ""))
+//                .eq(ZhcxItpProjectNodesDo::getProjectid, itpDo.getProjectid());
+//        ZhcxItpProjectNodesDo nodesDo = zhcxItpProjectNodesService.getOne(tWrapper);
+//        if(ObjectUtil.isNull(nodesDo)) {
+//            return false;
+//        }
+//
+//        if(ObjectUtil.isEmpty(nodesDo.getIsneedinput()) || !"true".equals(nodesDo.getIsneedinput())) {
+//            return false;
+//        }
 
         //总装机号或者机构机号存在多选时,不存在添加校验跟踪
         if(itpDo.getMachineno().split(",").length > 1 || itpDo.getStructuremachineno().split(",").length > 1) {
@@ -170,8 +190,9 @@ public class ZhcxOutsideInspectionComponentTrackServiceImpl extends ServiceImpl<
         }
 
         //总装结构都能匹配到,不做再重复添加
+        // 但需要合并分包商挂靠单位
         if(zzFlag && jgFlag) {
-            return false;
+            return true;
         }
 
         //总装结构都不能匹配,需要添加

+ 58 - 2
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxOutsideInspectionItpServiceImpl.java

@@ -8,12 +8,14 @@ import cn.hutool.core.util.*;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.rongwei.bscommon.sys.dao.ZhcxInsideInspectionDao;
 import com.rongwei.bscommon.sys.dao.ZhcxOutsideInspectionItpDao;
 import com.rongwei.bscommon.sys.feign.BsPlatformService;
 import com.rongwei.bscommon.sys.service.*;
+import com.rongwei.bscommon.sys.utils.StrUtils;
 import com.rongwei.bscommon.sys.utils.ZhcxCommon;
 import com.rongwei.bsentity.domain.*;
 import com.rongwei.bsentity.dto.*;
@@ -902,6 +904,7 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
         List<ZhcxOutsideInspectionItpDo> updateList = new ArrayList<>();
         List<String> newItpIdList = new ArrayList<>();
         List<ZhcxOutsideInspectionComponentTrackDo> trackDos = new ArrayList<>();
+        List<ZhcxOutsideInspectionComponentTrackDo> updateTrackDos = new ArrayList<>();
 
         //操作记录
         List<ZhcxOutsideInspectionItpOperLogDo> logList = new ArrayList<>();
@@ -925,7 +928,32 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
                     //跟踪
                     ZhcxOutsideInspectionComponentTrackDo trackDo = inspectionComponentTrackService.getByItp(itpDo);
                     if(ObjectUtil.isNotNull(trackDo)) {
-                        trackDos.add(trackDo);
+
+                        LambdaQueryWrapper<ZhcxOutsideInspectionComponentTrackDo> queryWrapper = Wrappers.lambdaQuery();
+                        queryWrapper.eq(ZhcxOutsideInspectionComponentTrackDo::getStructurename, itpDo.getStructurename())
+                                .eq(ZhcxOutsideInspectionComponentTrackDo::getMachineno, itpDo.getMachineno())
+                                .eq(ZhcxOutsideInspectionComponentTrackDo::getStructuremachineno, itpDo.getStructuremachineno())
+                                .eq(ZhcxOutsideInspectionComponentTrackDo::getDeleted, "0")
+                                .eq(ZhcxOutsideInspectionComponentTrackDo::getProjectid, itpDo.getProjectid());
+                        List<ZhcxOutsideInspectionComponentTrackDo> trackDoList = inspectionComponentTrackService.list(queryWrapper);
+
+                        //不存在,新增项目构件中总装与结构机号的关系
+                        if(ObjectUtil.isEmpty(trackDoList)) {
+                            trackDos.add(trackDo);
+                        } else { //存在的话更新总装和结构机号所对应分包商关系
+                            final ZhcxOutsideInspectionComponentTrackDo trackEntity = trackDoList.get(0);
+
+                            final String unitIds = StrUtils.addIdAndDeduplicate(trackEntity.getSubcontractorunitid(), itpDo.getSubcontractorunitid());
+                            final String strctUnitIds = StrUtils.addIdAndDeduplicate(trackEntity.getStructsubcontractorunitid(), itpDo.getSubcontractorunitid());
+
+                            trackDo = new ZhcxOutsideInspectionComponentTrackDo();
+                            trackDo.setId(trackEntity.getId());
+                            trackDo.setSubcontractorunitid(unitIds);
+                            trackDo.setStructsubcontractorunitid(strctUnitIds);
+                            updateTrackDos.add(trackDo);
+                        }
+
+//                        trackDos.add(trackDo);
                     }
 
                     ZhcxOutsideInspectionItpOperLogDo itpLog = zhcxOutsideInspectionItpOperLogService
@@ -958,7 +986,31 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
                 //跟踪
                 ZhcxOutsideInspectionComponentTrackDo trackDo = inspectionComponentTrackService.getByItp(entity);
                 if(ObjectUtil.isNotNull(trackDo)) {
-                    trackDos.add(trackDo);
+//                    trackDos.add(trackDo);
+
+                    LambdaQueryWrapper<ZhcxOutsideInspectionComponentTrackDo> queryWrapper = Wrappers.lambdaQuery();
+                    queryWrapper.eq(ZhcxOutsideInspectionComponentTrackDo::getStructurename, itpDo.getStructurename())
+                            .eq(ZhcxOutsideInspectionComponentTrackDo::getMachineno, itpDo.getMachineno())
+                            .eq(ZhcxOutsideInspectionComponentTrackDo::getStructuremachineno, itpDo.getStructuremachineno())
+                            .eq(ZhcxOutsideInspectionComponentTrackDo::getDeleted, "0")
+                            .eq(ZhcxOutsideInspectionComponentTrackDo::getProjectid, itpDo.getProjectid());
+                    List<ZhcxOutsideInspectionComponentTrackDo> trackDoList = inspectionComponentTrackService.list(queryWrapper);
+
+                    //不存在,新增项目构件中总装与结构机号的关系
+                    if(ObjectUtil.isEmpty(trackDoList)) {
+                        trackDos.add(trackDo);
+                    } else { //存在的话更新总装和结构机号所对应分包商关系
+                        final ZhcxOutsideInspectionComponentTrackDo trackEntity = trackDoList.get(0);
+
+                        final String unitIds = StrUtils.addIdAndDeduplicate(trackEntity.getSubcontractorunitid(), itpDo.getSubcontractorunitid());
+                        final String strctUnitIds = StrUtils.addIdAndDeduplicate(trackEntity.getStructsubcontractorunitid(), itpDo.getSubcontractorunitid());
+
+                        trackDo = new ZhcxOutsideInspectionComponentTrackDo();
+                        trackDo.setId(trackEntity.getId());
+                        trackDo.setSubcontractorunitid(unitIds);
+                        trackDo.setStructsubcontractorunitid(strctUnitIds);
+                        updateTrackDos.add(trackDo);
+                    }
                 }
 
             }
@@ -978,6 +1030,10 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
             inspectionComponentTrackService.saveBatch(trackDos);
         }
 
+        if(ObjectUtil.isNotEmpty(updateTrackDos)) {
+            inspectionComponentTrackService.updateBatchById(updateTrackDos);
+        }
+
         //日志
         zhcxOutsideInspectionItpOperLogService.saveBatch(logList);
     }

+ 31 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/utils/StrUtils.java

@@ -0,0 +1,31 @@
+package com.rongwei.bscommon.sys.utils;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+public class StrUtils {
+
+    /**
+     * 向逗号分隔的ID字符串添加新ID并去重
+     * @param originalIds 原ID字符串,如 "1,2,3"
+     * @param newId 要添加的新ID
+     * @return 处理后的ID字符串
+     */
+    public static String addIdAndDeduplicate(String originalIds, String newId) {
+        // 处理空字符串情况
+        if (originalIds == null || originalIds.trim().isEmpty()) {
+            return newId;
+        }
+
+        // 分割原字符串为集合
+        Set<String> idSet = new HashSet<>(Arrays.asList(originalIds.split(",")));
+
+        // 添加新ID(HashSet会自动去重)
+        idSet.add(newId);
+
+        // 重新拼接成逗号分隔的字符串
+        return idSet.stream().collect(Collectors.joining(","));
+    }
+}

+ 24 - 0
business-entity/src/main/java/com/rongwei/bsentity/domain/ZhcxOutsideInspectionComponentTrackDo.java

@@ -108,5 +108,29 @@ public class ZhcxOutsideInspectionComponentTrackDo extends BaseDo {
     @TableField("SUBCONTRACTORUNITID")
     private String subcontractorunitid;
 
+    /**
+     * 分包商挂靠单位名称
+     */
+    @TableField("SUBCONTRACTORUNITNAME")
+    private String subcontractorunitname;
+
+    /**
+     * 结构分包商挂靠单位id
+     */
+    @TableField("STRUCTSUBCONTRACTORUNITID")
+    private String structsubcontractorunitid;
+
+    /**
+     * 结构分包商挂靠单位名称
+     */
+    @TableField("STRUCTSUBCONTRACTORUNITNAME")
+    private String structsubcontractorunitname;
+
+    /**
+     * 铭牌号
+     */
+    @TableField("NAMEPLATENUMBER")
+    private String nameplatenumber;
+
 
 }