Browse Source

外部报验功能-构件跟踪

wangming 1 năm trước cách đây
mục cha
commit
f7f020196f

+ 16 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/dao/ZhcxOutsideInspectionComponentTrackDao.java

@@ -0,0 +1,16 @@
+package com.rongwei.bscommon.sys.dao;
+
+import com.rongwei.bsentity.domain.ZhcxOutsideInspectionComponentTrackDo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 外部报验-构件跟踪 Mapper 接口
+ * </p>
+ *
+ * @author wm
+ * @since 2024-02-05
+ */
+public interface ZhcxOutsideInspectionComponentTrackDao extends BaseMapper<ZhcxOutsideInspectionComponentTrackDo> {
+
+}

+ 32 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxOutsideInspectionComponentTrackService.java

@@ -0,0 +1,32 @@
+package com.rongwei.bscommon.sys.service;
+
+import com.rongwei.bsentity.domain.ZhcxOutsideInspectionComponentTrackDo;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwei.bsentity.domain.ZhcxOutsideInspectionItpDo;
+
+/**
+ * <p>
+ * 外部报验-构件跟踪 服务类
+ * </p>
+ *
+ * @author wm
+ * @since 2024-02-05
+ */
+public interface ZhcxOutsideInspectionComponentTrackService extends IService<ZhcxOutsideInspectionComponentTrackDo> {
+
+    /**
+     * 保存跟踪
+     *
+     * @param itpDo
+     */
+    void saveByItp(ZhcxOutsideInspectionItpDo itpDo);
+
+    /**
+     * 获取跟踪对象
+     *
+     * @param itpDo
+     * @return
+     */
+    ZhcxOutsideInspectionComponentTrackDo getByItp(ZhcxOutsideInspectionItpDo itpDo);
+
+}

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

@@ -0,0 +1,125 @@
+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.toolkit.Wrappers;
+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.stereotype.Service;
+
+/**
+ * <p>
+ * 外部报验-构件跟踪 服务实现类
+ * </p>
+ *
+ * @author wm
+ * @since 2024-02-05
+ */
+@Service
+public class ZhcxOutsideInspectionComponentTrackServiceImpl extends ServiceImpl<ZhcxOutsideInspectionComponentTrackDao, ZhcxOutsideInspectionComponentTrackDo> implements ZhcxOutsideInspectionComponentTrackService {
+
+    /**
+     * 保存跟踪
+     *
+     * @param itpDo
+     */
+    @Override
+    public void saveByItp(ZhcxOutsideInspectionItpDo itpDo) {
+        ZhcxOutsideInspectionComponentTrackDo entity = getByItp(itpDo);
+
+        if(ObjectUtil.isNull(entity)) {
+            return ;
+        }
+
+        save(entity);
+    }
+
+    /**
+     * 获取跟踪对象
+     *
+     * @param itpDo
+     * @return
+     */
+    @Override
+    public ZhcxOutsideInspectionComponentTrackDo getByItp(ZhcxOutsideInspectionItpDo itpDo) {
+
+        //校验
+        if(!checkSave(itpDo)) {
+            return null;
+        }
+
+        ZhcxOutsideInspectionComponentTrackDo entity = new ZhcxOutsideInspectionComponentTrackDo();
+        setSaveData(itpDo, entity);
+        return entity;
+    }
+
+    /**
+     * 设置保存数据
+     *
+     * @param itpDo
+     * @param entity
+     */
+    private void setSaveData(ZhcxOutsideInspectionItpDo itpDo, ZhcxOutsideInspectionComponentTrackDo entity) {
+        if(ObjectUtil.isNull(entity)) {
+            entity = new ZhcxOutsideInspectionComponentTrackDo();
+        }
+
+        entity.setId(SecurityUtil.getUUID());
+
+        entity.setDeleted("0");
+
+        //项目
+        entity.setProjectid(itpDo.getProjectid());
+        entity.setProjectcode(itpDo.getProjectcode());
+        entity.setProjectname(itpDo.getProjectname());
+
+        //构件
+        entity.setStructureid(itpDo.getStructureid());
+        entity.setStructurename(itpDo.getStructurename());
+
+        //报验点
+        entity.setInspectioncontentid(itpDo.getInspectioncontentid());
+        entity.setInspectioncontent(itpDo.getInspectioncontent());
+
+        //总装机号
+        entity.setProjectmachineid(itpDo.getProjectmachineid());
+        entity.setMachineno(itpDo.getMachineno());
+
+        //结构机号
+        entity.setStructuremachineid(itpDo.getStructuremachineid());
+        entity.setStructuremachineno(itpDo.getStructuremachineno());
+    }
+
+    /**
+     * 校验保存之前数据
+     *
+     * @param itpDo
+     * @return
+     */
+    private boolean checkSave(ZhcxOutsideInspectionItpDo itpDo) {
+        //总装机号或机构机号不存在,不保存跟踪
+        if(ObjectUtil.isNull(itpDo.getMachineno()) || ObjectUtil.isNull(itpDo.getStructuremachineno())) {
+            return false;
+        }
+
+        //构件或者报验点为空,不保存跟踪
+        if(ObjectUtil.isNull(itpDo.getStructurename()) || ObjectUtil.isNull(itpDo.getInspectioncontent())) {
+            return false;
+        }
+
+        //已保存的构件和报验点,不再重新保存
+        LambdaQueryWrapper<ZhcxOutsideInspectionComponentTrackDo> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(ZhcxOutsideInspectionComponentTrackDo::getStructurename, itpDo.getStructurename())
+                .eq(ZhcxOutsideInspectionComponentTrackDo::getInspectioncontent, itpDo.getInspectioncontent());
+        int count = count(queryWrapper);
+        if(count > 0) {
+            return false;
+        }
+
+        return true;
+    }
+}

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

@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.rongwei.bscommon.sys.feign.SysNotifyFeginService;
 import com.rongwei.bscommon.sys.service.*;
 import com.rongwei.bscommon.sys.utils.ZhcxCommon;
+import com.rongwei.bsentity.domain.ZhcxOutsideInspectionComponentTrackDo;
 import com.rongwei.bsentity.domain.ZhcxOutsideInspectionItpDo;
 import com.rongwei.bscommon.sys.dao.ZhcxOutsideInspectionItpDao;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -79,6 +80,9 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
     @Autowired
     private SysFileItemService sysFileItemService;
 
+    @Autowired
+    private ZhcxOutsideInspectionComponentTrackService inspectionComponentTrackService;
+
     @Autowired
     private SysNotifyFeginService notifyFeginService;
     @Value("${temp.filepath:#{null}}")
@@ -110,72 +114,12 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
         //只有一个构件和报验点时
         //不需要拆单
         if(structureNames.length * inspectionContents.length <= 1) {
-
-            //生成空派单
-            genEmptyDispatch(id);
-
-            //存在报验单号,则不再生成
-            if(ObjectUtil.isNotEmpty(itpDo.getInspectioncode())) {
-                return ;
-            }
-            ZhcxOutsideInspectionItpDo updateEntity = new ZhcxOutsideInspectionItpDo();
-            updateEntity.setId(id);
-            updateEntity.setInspectioncode(genCode());
-            updateById(updateEntity);
+            saveSingle(itpDo);
             return ;
         }
 
-        List<ZhcxOutsideInspectionItpDo> insertList = new ArrayList<>();
-        List<ZhcxOutsideInspectionItpSupervisionDispatchDo> insertDispatchList = new ArrayList<>();
-        List<ZhcxOutsideInspectionItpDo> updateList = new ArrayList<>();
-        List<String> newItpIdList = new ArrayList<>();
-
-        int count = -1;
-        for(int m = 0, n = structureNames.length; m < n; m++) {
-            for(String inspectionContent : inspectionContents) {
-                count++;
-
-                if(count == 0) { //第一个做修改
-                    itpDo.setStructurename(structureNames[m]);
-                    itpDo.setInspectioncontent(inspectionContent);
-                    itpDo.setInspectioncode(genCode());
-//                    itpDo.setStructureid(structureIds[m]);
-                    updateList.add(itpDo);
-
-                    //生成空派单数据
-                    genEmptyDispatch(id);
-                    continue;
-                }
-
-                ZhcxOutsideInspectionItpDo entity = new ZhcxOutsideInspectionItpDo();
-                BeanUtil.copyProperties(itpDo, entity);
-                entity.setStructurename(structureNames[m]);
-                entity.setInspectioncontent(inspectionContent);
-                entity.setId(SecurityUtil.getUUID());
-                entity.setInspectioncode(genCode());
-//                entity.setStructureid(structureIds[m]);
-                insertList.add(entity);
-                newItpIdList.add(entity.getId());
-
-                //空派单
-                ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchDo = new ZhcxOutsideInspectionItpSupervisionDispatchDo();
-                dispatchDo.setId(SecurityUtil.getUUID());
-                dispatchDo.setDeleted("0");
-                dispatchDo.setItpid(entity.getId());
-                insertDispatchList.add(dispatchDo);
-
-            }
-        }
-
-        //报验单明细
-        insertChildren(itpDo, newItpIdList);
-
-        //报验单
-        updateBatchById(updateList);
-        saveBatch(insertList);
-
-        //空派单数据
-        dispatchService.saveBatch(insertDispatchList);
+        //保存多个构件/报验点
+        saveMany(itpDo, structureNames, inspectionContents);
     }
 
     @Override
@@ -464,6 +408,106 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
 
     }
 
+    /**
+     * 保存多条构件,报验点
+     *
+     * @param itpDo
+     * @param structureNames
+     * @param inspectionContents
+     */
+    private void saveMany(ZhcxOutsideInspectionItpDo itpDo, String[] structureNames, String[] inspectionContents) {
+        List<ZhcxOutsideInspectionItpDo> insertList = new ArrayList<>();
+        List<ZhcxOutsideInspectionItpSupervisionDispatchDo> insertDispatchList = new ArrayList<>();
+        List<ZhcxOutsideInspectionItpDo> updateList = new ArrayList<>();
+        List<String> newItpIdList = new ArrayList<>();
+        List<ZhcxOutsideInspectionComponentTrackDo> trackDos = new ArrayList<>();
+
+        int count = -1;
+        for(int m = 0, n = structureNames.length; m < n; m++) {
+            for(String inspectionContent : inspectionContents) {
+                count++;
+
+                if(count == 0) { //第一个做修改
+                    itpDo.setStructurename(structureNames[m]);
+                    itpDo.setInspectioncontent(inspectionContent);
+                    itpDo.setInspectioncode(genCode());
+//                    itpDo.setStructureid(structureIds[m]);
+                    updateList.add(itpDo);
+
+                    //生成空派单数据
+                    genEmptyDispatch(itpDo.getId());
+
+                    //跟踪
+                    ZhcxOutsideInspectionComponentTrackDo trackDo = inspectionComponentTrackService.getByItp(itpDo);
+                    if(ObjectUtil.isNotNull(trackDo)) {
+                        trackDos.add(trackDo);
+                    }
+                    continue;
+                }
+
+                ZhcxOutsideInspectionItpDo entity = new ZhcxOutsideInspectionItpDo();
+                BeanUtil.copyProperties(itpDo, entity);
+                entity.setStructurename(structureNames[m]);
+                entity.setInspectioncontent(inspectionContent);
+                entity.setId(SecurityUtil.getUUID());
+                entity.setInspectioncode(genCode());
+//                entity.setStructureid(structureIds[m]);
+                insertList.add(entity);
+                newItpIdList.add(entity.getId());
+
+                //空派单
+                ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchDo = new ZhcxOutsideInspectionItpSupervisionDispatchDo();
+                dispatchDo.setId(SecurityUtil.getUUID());
+                dispatchDo.setDeleted("0");
+                dispatchDo.setItpid(entity.getId());
+                insertDispatchList.add(dispatchDo);
+
+                //跟踪
+                ZhcxOutsideInspectionComponentTrackDo trackDo = inspectionComponentTrackService.getByItp(entity);
+                if(ObjectUtil.isNotNull(trackDo)) {
+                    trackDos.add(trackDo);
+                }
+
+            }
+        }
+
+        //报验单明细
+        insertChildren(itpDo, newItpIdList);
+
+        //报验单
+        updateBatchById(updateList);
+        saveBatch(insertList);
+
+        //空派单数据
+        dispatchService.saveBatch(insertDispatchList);
+
+        if(ObjectUtil.isNotEmpty(trackDos)) {
+            inspectionComponentTrackService.saveBatch(trackDos);
+        }
+    }
+
+    /**
+     * 保存单条构件,报验点
+     *
+     * @param itpDo
+     */
+    private void saveSingle(ZhcxOutsideInspectionItpDo itpDo) {
+        //生成空派单
+        genEmptyDispatch(itpDo.getId());
+
+        //构件跟踪
+        inspectionComponentTrackService.saveByItp(itpDo);
+
+        //存在报验单号,则不再生成
+        if(ObjectUtil.isNotEmpty(itpDo.getInspectioncode())) {
+            return ;
+        }
+        ZhcxOutsideInspectionItpDo updateEntity = new ZhcxOutsideInspectionItpDo();
+        updateEntity.setId(itpDo.getId());
+        updateEntity.setInspectioncode(genCode());
+        updateById(updateEntity);
+    }
+
     /**
      * 生成派单
      * 1、校验是否已存在

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

@@ -0,0 +1,99 @@
+package com.rongwei.bsentity.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.rongwei.rwcommon.base.BaseDo;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 外部报验-构件跟踪
+ * </p>
+ *
+ * @author wm
+ * @since 2024-02-05
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Accessors(chain = true)
+@TableName("ZHCX_OUTSIDE_INSPECTION_COMPONENT_TRACK")
+public class ZhcxOutsideInspectionComponentTrackDo extends BaseDo {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 主键
+     */
+    @TableField("ID")
+    private String id;
+    /**
+     * 租户ID
+     */
+    @TableField("TENANTID")
+    private String tenantid;
+    /**
+     * 扩展预留
+     */
+    @TableField("ROPTION")
+    private String roption;
+    /**
+     * 项目id
+     */
+    @TableField("PROJECTID")
+    private String projectid;
+    /**
+     * 项目工号
+     */
+    @TableField("PROJECTCODE")
+    private String projectcode;
+    /**
+     * 项目名称
+     */
+    @TableField("PROJECTNAME")
+    private String projectname;
+    /**
+     * 构建Id
+     */
+    @TableField("STRUCTUREID")
+    private String structureid;
+    /**
+     * 构件名称
+     */
+    @TableField("STRUCTURENAME")
+    private String structurename;
+    /**
+     * 报验内容id
+     */
+    @TableField("INSPECTIONCONTENTID")
+    private String inspectioncontentid;
+    /**
+     * 报验内容
+     */
+    @TableField("INSPECTIONCONTENT")
+    private String inspectioncontent;
+    /**
+     * 项目机号id
+     */
+    @TableField("PROJECTMACHINEID")
+    private String projectmachineid;
+    /**
+     * 机号
+     */
+    @TableField("MACHINENO")
+    private String machineno;
+    /**
+     * 结构项目机号id
+     */
+    @TableField("STRUCTUREMACHINEID")
+    private String structuremachineid;
+    /**
+     * 结构机号
+     */
+    @TableField("STRUCTUREMACHINENO")
+    private String structuremachineno;
+
+
+}