Browse Source

私有wbs节点基础信息同步、bug问题等

liuyc 2 năm trước cách đây
mục cha
commit
7ee86c76f4

+ 27 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ContractInfoController.java

@@ -15,6 +15,7 @@ import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.manager.dto.FindAllUserByConditionDTO;
 import org.springblade.manager.dto.SaveUserInfoByProjectDTO;
 import org.springblade.manager.dto.WbsTreeContractDTO;
@@ -435,6 +436,32 @@ public class ContractInfoController extends BladeController {
         return R.fail(200, "未查询到信息");
     }
 
+    /**
+     * 查询合同段树-全加载
+     */
+    @GetMapping("/tree-all")
+    @ApiOperationSupport(order = 19)
+    @ApiOperation(value = "查询合同段私有Wbs节点树形结构", notes = "传入wbsId,项目id,合同段id")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "wbsId", value = "wbsId", required = true),
+            @ApiImplicitParam(name = "项目id", value = "projectId", required = true),
+            @ApiImplicitParam(name = "合同段id", value = "contractId", required = true)
+    })
+    public R treeAll(String wbsId, String projectId, String contractId) {
+        List<WbsTreeContractVO> tree = contractInfoService.tree3(wbsId, projectId, contractId);
+        if (tree != null && tree.size() > 0) {
+            ContractInfo contractInfo = contractInfoService.getBaseMapper().selectById(contractId);
+            for (WbsTreeContractVO wbsTreeContractVO : tree) {
+                if (ObjectUtil.isNotEmpty(wbsTreeContractVO.getParentId()) && 0L == wbsTreeContractVO.getParentId()) {
+                    wbsTreeContractVO.setTitle(contractInfo.getContractName());
+                    break;
+                }
+            }
+            return R.data(tree);
+        }
+        return R.fail(200, "未查询到信息");
+    }
+
     /**
      * 查询合同段私有Wbs节点树形结构 --- 试验关联工程节点树
      */

+ 10 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ProjectInfoController.java

@@ -224,4 +224,14 @@ public class ProjectInfoController extends BladeController {
         return R.data(result);
     }
 
+    /**
+     * 同步节点树基本信息到项目下的合同段
+     */
+    @PostMapping("/sync-node-info")
+    @ApiOperationSupport(order = 14)
+    @ApiOperation(value = "同步节点树基本信息到项目下的合同段", notes = "传入节点pKeyId")
+    public R<Object> syncNodeInfo(@RequestParam Long pKeyId) {
+        return R.status(wbsTreeService.syncNodeInfo(pKeyId));
+    }
+
 }

+ 4 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ContractInfoMapper.java

@@ -84,4 +84,8 @@ public interface ContractInfoMapper extends BaseMapper<ContractInfo> {
     @Select("select quality_node_id from u_trial_self_quality_project where self_id = #{selfId}")
     List<String> queryList(@Param("selfId") String selfId);
 
+    List<WbsTreeContractVO> tree5(@Param("wbsId") Long wbsId,
+                                  @Param("projectId") Long projectId,
+                                  @Param("contractId") Long contractId);
+
 }

+ 34 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ContractInfoMapper.xml

@@ -409,4 +409,38 @@
         </foreach>
     </select>
 
+    <select id="tree5" resultMap="treeNodeResultMap2">
+        SELECT
+        d.p_key_id AS "primaryKeyId",
+        d.wbs_type AS "wbsType",
+        d.id,
+        d.parent_id AS "parentId",
+        IFNULL(if(length(trim(full_name)) > 0, full_name, node_name),node_name) AS title,
+        d.node_name AS "nodeName",
+        d.full_name AS "fullName",
+        d.import_matching_info AS "importMatchingInfo",
+        d.type AS "type",
+        d.node_type AS "nodeType",
+        d.id AS "value",
+        d.id AS "key",
+        partition_code,
+        old_id,
+        sort
+        FROM m_wbs_tree_contract d
+        WHERE
+        d.is_deleted = 0
+        AND d.status = 1
+        AND d.type = 1
+        <if test="wbsId!=null and wbsId!=''">
+            and wbs_id = #{wbsId}
+        </if>
+        <if test="projectId !=null and projectId!=''">
+            and project_id = #{projectId}
+        </if>
+        <if test="contractId!=null and contractId!=''">
+            and contract_id = #{contractId}
+        </if>
+        ORDER BY d.sort
+    </select>
+
 </mapper>

+ 2 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IContractInfoService.java

@@ -44,6 +44,8 @@ public interface IContractInfoService extends BaseService<ContractInfo> {
 
     List<WbsTreeContractVO> tree2(String wbsId, String projectId, String contractId);
 
+    List<WbsTreeContractVO> tree3(String wbsId, String projectId, String contractId);
+
     List<WbsTreeContractVO2> treeTwo(String projectId);
 
     List<WbsTreeContractTreeVO> queryContractWbsTreeByContractIdAndType(String contractId, Integer wbsType, String parentId);

+ 3 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IWbsTreeService.java

@@ -40,7 +40,7 @@ public interface IWbsTreeService extends BaseService<WbsTree> {
 
     boolean importWbsTree(MultipartFile excelFile, WbsTree wbsTreeFu, WbsTree wbsTree1) throws IOException;
 
-    Boolean submitWbsTreeInProject(WbsTreeContractDTO pawDTO);
+    boolean submitWbsTreeInProject(WbsTreeContractDTO pawDTO);
 
     WbsTreeAllListVO findWbsTreeList(Integer type);
 
@@ -72,4 +72,6 @@ public interface IWbsTreeService extends BaseService<WbsTree> {
 
     boolean submitFullName(String id, String fullNames);
 
+    boolean syncNodeInfo(Long pKeyId);
+
 }

+ 55 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ContractInfoServiceImpl.java

@@ -10,6 +10,7 @@ import org.springblade.common.utils.BaiduApiUtil;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.tool.node.ForestNodeMerger;
+import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.manager.dto.FindAllUserByConditionDTO;
 import org.springblade.manager.dto.SaveUserInfoByProjectDTO;
 import org.springblade.manager.entity.*;
@@ -23,6 +24,8 @@ import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.system.user.entity.User;
 import org.springblade.system.user.vo.UserContractInfoVO;
 import org.springblade.system.user.vo.UserVO2;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springframework.transaction.annotation.Transactional;
@@ -38,7 +41,9 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
     private final ContractInfoMapper contractInfoMapper;
     private final ProjectContractAreaMapper projectContractAreaMapper;
     private final SaveUserInfoByProjectMapper saveUserInfoByProjectMapper;
+    private final SaveUserInfoByProjectServiceImpl saveUserInfoByProjectService;
     private final WbsTreeContractMapper wbsTreeContractMapper;
+    private final JdbcTemplate jdbcTemplate;
 
     @Override
     public List<String> getProcessContractByJLContractId(String contractId) {
@@ -116,6 +121,12 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
         return contractInfoMapper.deleteFile(url);
     }
 
+    @Override
+    public List<WbsTreeContractVO> tree3(String wbsId, String projectId, String contractId) {
+        List<WbsTreeContractVO> wbsTreeContractVOS = baseMapper.tree5(Long.parseLong(wbsId), Long.parseLong(projectId), Long.parseLong(contractId));
+        return buildWbsTreeByStream(wbsTreeContractVOS);
+    }
+
     @Override
     public List<WbsTreeContractVO> tree(String wbsId, String projectId, String contractId) {
         List<WbsTreeContractVO> wbsTreeContractVOS = baseMapper.tree2(Long.parseLong(wbsId), Long.parseLong(projectId), Long.parseLong(contractId), null, null, null);
@@ -158,13 +169,13 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
 
     @Transactional(rollbackFor = Exception.class)
     public boolean saveAndUpdateContract(ContractInfoVO contractInfo) {
-        if (contractInfo.getId() == null) {
+        if (contractInfo.getId() == null) { //新增
             List<ContractInfo> contractInfos = baseMapper.selectList(Wrappers.<ContractInfo>query().lambda()
                     .eq(ContractInfo::getContractName, contractInfo.getContractName())
                     .eq(ContractInfo::getPId, contractInfo.getPId())
             );
             if (contractInfos.size() > 0) {
-                throw new ServiceException("合同段名称已存在当前项目下,请重新输入");
+                throw new ServiceException("当前项目下已存在该合同段名称,请重新输入");
             }
             if (StringUtils.isEmpty(String.valueOf(contractInfo.getContractType()))) {
                 throw new ServiceException("合同类型不能为空");
@@ -172,18 +183,51 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
 
             boolean row = saveOrUpdate(contractInfo);
 
+            //监理、总监办
             if (contractInfo.getContractType().equals(2) || contractInfo.getContractType().equals(3)) {
                 if (contractInfo.getIdList().size() > 0) {
                     List<WbsTreeContractVO3> infos = contractInfo.getIdList();
                     infos.forEach(info -> {
+                        //新增关联记录信息
                         baseMapper.insertContractRelationJLYZ(SnowFlakeUtil.getId(), contractInfo.getId(), info.getContractId());
                     });
+
+                    /*//把当前监理合同段中的人员同步到质检合同段中去
+                    List<String> recordContractIds = infos.stream().map(WbsTreeContractVO3::getContractId).collect(Collectors.toList());
+
+                    List<SaveUserInfoByProjectDTO> userRoleInfoListSG = new ArrayList<>();
+
+                    //查询当前监理合同段所有用户角色信息
+                    String sql1 = "select * from m_project_assignment_user where contract_id = " + contractInfo.getId() + " and post_id is null and status = 1 and is_deleted = 0";
+                    List<SaveUserInfoByProjectDTO> userRoleInfoJL = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(SaveUserInfoByProjectDTO.class));
+
+                    for (String recordContractId : recordContractIds) {
+                        String sql2 = "select * from m_project_assignment_user where contract_id = " + recordContractId + " and post_id is null and status = 1 and is_deleted = 0";
+                        List<SaveUserInfoByProjectDTO> userRoleInfoSG = jdbcTemplate.query(sql2, new BeanPropertyRowMapper<>(SaveUserInfoByProjectDTO.class));
+                        userRoleInfoListSG.addAll(userRoleInfoSG);
+                    }
+
+                    Iterator<SaveUserInfoByProjectDTO> jlInfo = userRoleInfoJL.iterator();
+                    while (jlInfo.hasNext()){
+                        SaveUserInfoByProjectDTO jl = jlInfo.next();
+                        for (SaveUserInfoByProjectDTO sg : userRoleInfoListSG) {
+                            if (jl.getUserId().equals(sg.getUserId())){
+                                //移除在施工合同段中已经存在的人员信息
+                                jlInfo.remove();
+                            }
+                        }
+                    }*/
+
                 }
+
+                //中西试验室
+            } else if (contractInfo.getContractType().equals(4)) {
+                //TODO
             }
 
             return submitContractRelevantInfo(row, contractInfo);
 
-        } else {
+        } else { //编辑
             List<ContractInfo> contractInfos = baseMapper.selectList(Wrappers.<ContractInfo>query().lambda()
                     .eq(ContractInfo::getContractName, contractInfo.getContractName())
                     .eq(ContractInfo::getPId, contractInfo.getPId())
@@ -194,6 +238,7 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
             }
             boolean row = saveOrUpdate(contractInfo);
 
+            //监理、总监办
             if (contractInfo.getContractType().equals(2) || contractInfo.getContractType().equals(3)) {
                 List<WbsTreeContractVO3> idList = contractInfo.getIdList();
 
@@ -208,6 +253,13 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
                         baseMapper.insertContractRelationJLYZ(SnowFlakeUtil.getId(), contractInfo.getId(), ids);
                     });
                 }
+
+                //删除当前合同段下的关联的施工合同段对应的合同段人员
+                //String sql = "delete from m_project_assignment_user where contract_id = " + contractInfo.getId() + " and post_id is null and status = 1 and is_deleted = 0";
+
+                //中西试验室
+            } else if (contractInfo.getContractType().equals(4)) {
+                //TODO
             }
 
             return submitContractRelevantInfo(row, contractInfo);

+ 30 - 5
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeServiceImpl.java

@@ -53,6 +53,7 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
     private final WbsTreePrivateMapper wbsTreePrivateMapper;
     private final WbsTreePrivateServiceImpl wbsTreePrivateService;
     private final ProjectInfoMapper projectInfoMapper;
+    private final WbsTreeContractServiceImpl wbsTreeContractService;
     private final WbsTreeContractMapper wbsTreeContractMapper;
     private final ContractInfoMapper contractInfoMapper;
     private final TextdictInfoServiceImpl textDictInfoService;
@@ -305,6 +306,31 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
         return false;
     }
 
+    @Override
+    public boolean syncNodeInfo(Long pKeyId) {
+        //当项目节点
+        WbsTreePrivate wbsTreePrivate = wbsTreePrivateService.getBaseMapper().selectOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, pKeyId).eq(WbsTreePrivate::getStatus, 1));
+
+        //获取当前项目下所有合同段引用过该节点的信息
+        List<WbsTreeContract> wbsTreeContracts = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery()
+                .eq(WbsTreeContract::getProjectId, wbsTreePrivate.getProjectId())
+                .eq(WbsTreeContract::getWbsId, wbsTreePrivate.getWbsId())
+                .eq(WbsTreeContract::getStatus, 1)
+                .and(obj -> obj.eq(WbsTreeContract::getId, wbsTreePrivate.getId()).or().eq(WbsTreeContract::getOldId, wbsTreePrivate.getId()))
+        );
+
+        List<Long> pIds = wbsTreeContracts.stream().map(WbsTreeContract::getPKeyId).collect(Collectors.toList());
+
+        wbsTreeContractService.update(Wrappers.<WbsTreeContract>lambdaUpdate()
+                .set(WbsTreeContract::getNodeName, wbsTreePrivate.getNodeName())
+                .set(WbsTreeContract::getNodeType, wbsTreePrivate.getNodeType())
+                .set(WbsTreeContract::getMajorDataType, wbsTreePrivate.getMajorDataType())
+                .in(WbsTreeContract::getPKeyId, pIds)
+        );
+
+        return true;
+    }
+
 
     @Override
     public List<WbsNodeTableVO> selectByNodeTable(String id) {
@@ -455,8 +481,7 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
-    public Boolean submitWbsTreeInProject(WbsTreeContractDTO pawDTO) {
+    public boolean submitWbsTreeInProject(WbsTreeContractDTO pawDTO) {
         try {
             if (StringUtils.isEmpty(pawDTO.getWbsId())) {
                 throw new ServiceException("请正确选择一个wbs模板");
@@ -654,7 +679,7 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                         List<Long> pIdsDL = wbsTreePrivates.stream().filter(f -> f.getType().equals(10) || f.getType().equals(2)).collect(Collectors.toList()).stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
                         String pKeyIds = StringUtils.join(pIdsDL, ",");
                         String sql = "select `id`,`name`,`type`,tab_id,col_key,sig_role_id,is_deleted,sig_role_name,col_name,pyzbx,pyzby from m_textdict_info where tab_id in (" + pKeyIds + ") and is_deleted = 0";
-                        List<TextdictInfo> textDictInfosAll = jdbcTemplate.query(sql, new BeanPropertyRowMapper<TextdictInfo>(TextdictInfo.class));
+                        List<TextdictInfo> textDictInfosAll = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TextdictInfo.class));
 
                         for (WbsTreePrivate wbsTreePrivate : wbsTreePrivates) {
                             if (wbsTreePrivate.getType() == 1 || wbsTreePrivate.getType() == 2) {
@@ -899,7 +924,7 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
             List<Long> pIdsDL = wbsTreePrivateOldTables.stream().filter(f -> f.getType().equals(10) || f.getType().equals(2)).collect(Collectors.toList()).stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
             String ids = StringUtils.join(pIdsDL, ",");
             String sql = "select `id`,`name`,`type`,tab_id,col_key,sig_role_id,is_deleted,sig_role_name,col_name,pyzbx,pyzby from m_textdict_info where tab_id in (" + ids + ") and is_deleted = 0";
-            List<TextdictInfo> textDictInfos = jdbcTemplate.query(sql, new BeanPropertyRowMapper<TextdictInfo>(TextdictInfo.class));
+            List<TextdictInfo> textDictInfos = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TextdictInfo.class));
 
             for (WbsTreePrivate wbsTreePrivate : wbsTreePrivateOldTables) {
                 //私有引用-电签匹配数据、默认信息数据,根据元素表pKeyId,获取电签位置匹配信息、编辑默认信息
@@ -931,7 +956,7 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
             List<Long> pIdsDLNew = wbsTreePrivateNewTables.stream().filter(f -> f.getType().equals(10) || f.getType().equals(2)).collect(Collectors.toList()).stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
             String ids = StringUtils.join(pIdsDLNew, ",");
             String sql = "select `id`,`name`,`type`,tab_id,col_key,sig_role_id,is_deleted,sig_role_name,col_name,pyzbx,pyzby from m_textdict_info where tab_id in (" + ids + ") and is_deleted = 0";
-            List<TextdictInfo> textDictInfosNew = jdbcTemplate.query(sql, new BeanPropertyRowMapper<TextdictInfo>(TextdictInfo.class));
+            List<TextdictInfo> textDictInfosNew = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TextdictInfo.class));
 
             Iterator<TextdictInfo> iterator = insertData.iterator();
             while (iterator.hasNext()) {