|
@@ -1,7 +1,5 @@
|
|
|
package org.springblade.business.controller;
|
|
|
|
|
|
-import cn.hutool.core.lang.hash.Hash;
|
|
|
-import com.alibaba.excel.util.DateUtils;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -28,12 +26,9 @@ import org.springblade.business.service.*;
|
|
|
import org.springblade.business.socket.WebSocket;
|
|
|
import org.springblade.business.utils.FileUtils;
|
|
|
import org.springblade.business.vo.*;
|
|
|
-import org.springblade.common.constant.BusinessConstant;
|
|
|
import org.springblade.common.constant.CommonConstant;
|
|
|
-import org.springblade.common.constant.LauncherConstant;
|
|
|
import org.springblade.common.utils.CommonUtil;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
-import org.springblade.core.cache.utils.CacheUtil;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
@@ -41,10 +36,7 @@ import org.springblade.core.oss.model.BladeFile;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.node.ForestNodeMerger;
|
|
|
-import org.springblade.core.tool.utils.DateUtil;
|
|
|
-import org.springblade.core.tool.utils.Func;
|
|
|
-import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
-import org.springblade.core.tool.utils.StringUtil;
|
|
|
+import org.springblade.core.tool.utils.*;
|
|
|
import org.springblade.evisa.feign.EVisaClient;
|
|
|
import org.springblade.evisa.vo.CertBeanVO;
|
|
|
import org.springblade.manager.entity.*;
|
|
@@ -56,11 +48,6 @@ import org.springblade.system.entity.DictBiz;
|
|
|
import org.springblade.system.feign.IDictBizClient;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.cache.annotation.CacheEvict;
|
|
|
-import org.springframework.cache.annotation.CachePut;
|
|
|
-import org.springframework.cache.annotation.Cacheable;
|
|
|
-import org.springframework.cache.annotation.Caching;
|
|
|
-import org.springframework.data.redis.core.RedisConnectionUtils;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
@@ -73,8 +60,6 @@ import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
|
|
|
-
|
|
|
/**
|
|
|
* 资料填报及查询控制器
|
|
|
*
|
|
@@ -918,7 +903,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
@ApiOperation(value = "批量打印")
|
|
|
public R<String> batchPrint(@RequestParam String ids) {
|
|
|
//判断是否未生成文件
|
|
|
- List<String> list = Arrays.asList(ids.split(","));
|
|
|
+ String[] list = ids.split(",");
|
|
|
for (String s : list) {
|
|
|
if (StringUtils.isBlank(s)) {
|
|
|
return R.fail("选择的资料未生成文件");
|
|
@@ -980,7 +965,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
public R<String> batchDownloadFileToZip(String ids, HttpServletResponse response) {
|
|
|
if (StringUtils.isNotEmpty(ids)) {
|
|
|
//判断是否未生成文件
|
|
|
- List<String> list = Arrays.asList(ids.split(","));
|
|
|
+ String[] list = ids.split(",");
|
|
|
for (String s : list) {
|
|
|
if (StringUtils.isBlank(s)) {
|
|
|
return R.fail("选择的资料未生成文件");
|
|
@@ -1339,104 +1324,556 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
@ApiOperationSupport(order = 15)
|
|
|
@ApiOperation(value = "复制节点(新)")
|
|
|
public R<Boolean> copyContractTreeNode(@RequestBody CopyContractTreeNodeVO vo) {
|
|
|
- //首先查询需要复制的节点及其下级所有子节点的信息
|
|
|
- WbsTreeContract needCopyNode = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(vo.getNeedCopyPrimaryKeyId());
|
|
|
- // 获取当前节点的所有子节点
|
|
|
- String vocational = SnowFlakeUtil.getId() + "";
|
|
|
- //新增施工台账
|
|
|
- List<WbsTreeContract> saveList = new ArrayList<>();
|
|
|
- List<ConstructionLedger> saveLedger = new ArrayList<>();
|
|
|
- // 获取附件
|
|
|
- List<WbsTreeContract> nodeChildAll = informationQueryService.getNodeChildAllByNodeId(needCopyNode.getId() + "", needCopyNode.getContractId(), vo.getNeedCopyPrimaryKeyId());
|
|
|
- // 获取实体表列对象
|
|
|
- List<QueryProcessDataVO> nodeTabCols = informationQueryService.getNodeChildTabColsAllByNodeId(needCopyNode.getId() + "", needCopyNode.getContractId());
|
|
|
- // 转化为map
|
|
|
- Map<String, String> nodeTabColsMap = nodeTabCols.stream().collect(Collectors.toMap(QueryProcessDataVO::getQueryType, QueryProcessDataVO::getAncestors, (key1, key2) -> key2));
|
|
|
- StringBuilder copeSql = new StringBuilder();
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(vo.getNeedCopyPrimaryKeyId())) {
|
|
|
- WbsTreeContract parent = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(vo.getParentPrimaryKeyId());
|
|
|
- //重塑关键信息
|
|
|
- Map<Long, Long> oldToNewIdMap = new HashMap<>();
|
|
|
- //节点信息
|
|
|
- Map<String, WbsTreeContract> nodeMap = new HashMap<>();
|
|
|
- nodeChildAll.forEach(node -> {
|
|
|
- oldToNewIdMap.put(node.getId(), SnowFlakeUtil.getId());
|
|
|
- nodeMap.put(node.getId().toString(), node);
|
|
|
- });
|
|
|
+ //TODO 单份复制
|
|
|
+ if (("1").equals(vo.getCopyType())) {
|
|
|
+ //首先查询需要复制的节点及其下级所有子节点的信息
|
|
|
+ WbsTreeContract needCopyNode = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(vo.getNeedCopyPrimaryKeyId());
|
|
|
+ // 获取当前节点的所有子节点
|
|
|
+ String vocational = SnowFlakeUtil.getId() + "";
|
|
|
+ //新增施工台账
|
|
|
+ List<WbsTreeContract> saveList = new ArrayList<>();
|
|
|
+ List<ConstructionLedger> saveLedger = new ArrayList<>();
|
|
|
+ // 获取附件
|
|
|
+ List<WbsTreeContract> nodeChildAll = informationQueryService.getNodeChildAllByNodeId(needCopyNode.getId() + "", needCopyNode.getContractId(), vo.getNeedCopyPrimaryKeyId());
|
|
|
+ // 获取实体表列对象
|
|
|
+ List<QueryProcessDataVO> nodeTabCols = informationQueryService.getNodeChildTabColsAllByNodeId(needCopyNode.getId() + "", needCopyNode.getContractId());
|
|
|
+ // 转化为map
|
|
|
+ Map<String, String> nodeTabColsMap = nodeTabCols.stream().collect(Collectors.toMap(QueryProcessDataVO::getQueryType, QueryProcessDataVO::getAncestors, (key1, key2) -> key2));
|
|
|
+ StringBuilder copeSql = new StringBuilder();
|
|
|
|
|
|
- //todo 单份复制
|
|
|
- nodeChildAll.forEach(node -> {
|
|
|
- WbsTreeContract newData = new WbsTreeContract();
|
|
|
- BeanUtils.copyProperties(node, newData);
|
|
|
+ if (StringUtils.isNotEmpty(vo.getNeedCopyPrimaryKeyId())) {
|
|
|
+ WbsTreeContract parent = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(vo.getParentPrimaryKeyId());
|
|
|
//重塑关键信息
|
|
|
- //重塑primaryKeyId
|
|
|
- newData.setPKeyId(SnowFlakeUtil.getId());
|
|
|
- //设置旧ID
|
|
|
- if (StringUtils.isNotEmpty(node.getOldId())) {
|
|
|
- newData.setOldId(node.getOldId());
|
|
|
- } else {
|
|
|
- newData.setOldId(node.getId().toString());
|
|
|
+ Map<Long, Long> oldToNewIdMap = new HashMap<>();
|
|
|
+ //节点信息
|
|
|
+ Map<String, WbsTreeContract> nodeMap = new HashMap<>();
|
|
|
+ nodeChildAll.forEach(node -> {
|
|
|
+ oldToNewIdMap.put(node.getId(), SnowFlakeUtil.getId());
|
|
|
+ nodeMap.put(node.getId().toString(), node);
|
|
|
+ });
|
|
|
+
|
|
|
+ nodeChildAll.forEach(node -> {
|
|
|
+ WbsTreeContract newData = new WbsTreeContract();
|
|
|
+ BeanUtils.copyProperties(node, newData);
|
|
|
+ //重塑关键信息
|
|
|
+ //重塑primaryKeyId
|
|
|
+ newData.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ //设置旧ID
|
|
|
+ if (StringUtils.isNotEmpty(node.getOldId())) {
|
|
|
+ newData.setOldId(node.getOldId());
|
|
|
+ } else {
|
|
|
+ newData.setOldId(node.getId().toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置新ID
|
|
|
+ if (new Integer("1").equals(node.getType())) {
|
|
|
+ //如果是节点类型才重塑ID
|
|
|
+ newData.setId(oldToNewIdMap.containsKey(node.getId()) ? oldToNewIdMap.get(node.getId()) : SnowFlakeUtil.getId());
|
|
|
+ //划分编号
|
|
|
+ newData.setPartitionCode(StringUtils.isNotEmpty(vo.getPartitionCode()) ? vo.getPartitionCode() : null);
|
|
|
+ }
|
|
|
+ //设置父节点ID
|
|
|
+ if (vo.getNeedCopyPrimaryKeyId().equals(node.getPKeyId().toString())) {
|
|
|
+ //找到复制的节点,将parentId更改为 parent.getId()
|
|
|
+ newData.setParentId(parent.getId());
|
|
|
+ //设置新名称
|
|
|
+ newData.setNodeName(vo.getNeedCopyNodeName());
|
|
|
+ newData.setFullName(vo.getNeedCopyNodeName());
|
|
|
+ } else {
|
|
|
+ newData.setParentId(oldToNewIdMap.containsKey(node.getParentId()) ? oldToNewIdMap.get(node.getParentId()) : SnowFlakeUtil.getId());
|
|
|
+ }
|
|
|
+ newData.setCreateTime(new Date());
|
|
|
+ newData.setUpdateTime(new Date());
|
|
|
+ //初始化是否显示表格,默认显示
|
|
|
+ newData.setIsBussShow(1);
|
|
|
+ //初始化表格是否上传附件,默认未上传
|
|
|
+ newData.setTabFileType(1);
|
|
|
+ //初始化单表是否可以预览,默认不能
|
|
|
+ newData.setIsTabPdf(1);
|
|
|
+ //初始化PDF路径
|
|
|
+ newData.setPdfUrl(null);
|
|
|
+ newData.setCreateUser(AuthUtil.getUserId());
|
|
|
+ //重塑父节点关联关系
|
|
|
+ this.restoreParent(newData, oldToNewIdMap);
|
|
|
+ //保存到集合中
|
|
|
+ saveList.add(newData);
|
|
|
+ if (new Integer("6").equals(node.getNodeType())) {
|
|
|
+ //生成施工日志
|
|
|
+ this.createLedger(newData, saveLedger, nodeMap, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 组织复制值Sql
|
|
|
+ if (nodeTabColsMap != null && node.getType() == 2) {
|
|
|
+ String tableName = newData.getInitTableName();
|
|
|
+ String col = nodeTabColsMap.get(tableName);
|
|
|
+ String colVal = nodeTabColsMap.get(tableName);
|
|
|
+ colVal = colVal.replaceAll("id,p_key_id,", "'" + SnowFlakeUtil.getId() + "' as id,'" + newData.getPKeyId() + "' as p_key_id,");
|
|
|
+ copeSql.append("insert into " + tableName + " (" + col + ") select " + colVal + " from " + tableName + " where p_key_id='" + node.getPKeyId() + "' ;");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //保存节点信息
|
|
|
+ R<Boolean> booleanR = this.saveOrCopyNodeTree(saveList, saveLedger, 32, needCopyNode);
|
|
|
+
|
|
|
+ //复制数据逻辑
|
|
|
+ if (nodeTabColsMap != null && copeSql.length() >= 10) {
|
|
|
+ jdbcTemplate.execute(copeSql.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取父节点信息
|
|
|
+ informationQueryService.AsyncWbsTree(needCopyNode.getParentId() + "", needCopyNode.getParentId() + "", needCopyNode.getContractId(), "", "1");
|
|
|
+ return booleanR;
|
|
|
+
|
|
|
+ /** TODO 多份复制
|
|
|
+ * @Author liuYC
|
|
|
+ * @Date 2023年4月10日18:06:53
|
|
|
+ * @Description
|
|
|
+ * 解析复制节点位置信息:
|
|
|
+ * 1:同节点复制(同一个父级下)
|
|
|
+ * 1.1 如果点击选择的是当前复制节点的父级,那么就新增一个当前需要复制的节点-新的子级-新的表-新的表数据(根据所属方查询对应数据)。
|
|
|
+ * 1.2 如果点击选择的是当前复制节点的同级节点(自己本身节点是无法点击进行复制的),那么复制对应表数据,如果没有对应表,那么跳过。
|
|
|
+ * 2:跨节点复制(不同父级下)
|
|
|
+ * 2.1 如果点击选择的是其他父级节点的父级,那么新增一个新的当前选择的复制的节点-新的表-新的表数据(根据所属方查询对应数据)。
|
|
|
+ * 2.2 如果点击选择的是当前复制节点本身的同等级节点,那么复制对应表数据,如果没有对应表,那么跳过。
|
|
|
+ */
|
|
|
+ } else if (("2").equals(vo.getCopyType())) {
|
|
|
+ //获取需要复制到的位置节点信息的集合
|
|
|
+ List<CopyContractTreeNodeVO.CopyBatch> copyBatches = vo.getCopyBatchToPaths();
|
|
|
+ if (copyBatches.size() > 0) {
|
|
|
+ //获取当前需要复制到的位置节点信息,判断同节点复制或跨节点复制
|
|
|
+ List<Long> toCopyNodePKeyIds = copyBatches.stream().map(CopyContractTreeNodeVO.CopyBatch::getPrimaryKeyId).map(Long::valueOf).collect(Collectors.toList());
|
|
|
+ List<WbsTreeContract> toCopyNodes = new ArrayList<>();
|
|
|
+ String contractId = "";
|
|
|
+ //选择的复制节点PKeyId可能一样(选择相同节点复制),所以循环分开查询
|
|
|
+ for (Long toCopyNodePKeyId : toCopyNodePKeyIds) {
|
|
|
+ WbsTreeContract toCopyNode = wbsTreeContractClient.queryContractTreeNodeByPKeyId(toCopyNodePKeyId);
|
|
|
+ toCopyNodes.add(toCopyNode);
|
|
|
+ if (StringUtils.isEmpty(contractId)) {
|
|
|
+ contractId = toCopyNode.getContractId();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- //设置新ID
|
|
|
- if (new Integer("1").equals(node.getType())) {
|
|
|
- //如果是节点类型才重塑ID
|
|
|
- newData.setId(oldToNewIdMap.containsKey(node.getId()) ? oldToNewIdMap.get(node.getId()) : SnowFlakeUtil.getId());
|
|
|
- //划分编号
|
|
|
- newData.setPartitionCode(StringUtils.isNotEmpty(vo.getPartitionCode()) ? vo.getPartitionCode() : null);
|
|
|
+ //结果集
|
|
|
+ List<WbsTreeContract> addChildNodesAll = new ArrayList<>();
|
|
|
+ List<WbsTreeContract> addChildNodesTablesAll = new ArrayList<>();
|
|
|
+ Set<WbsTreeContract> addChildNodesTablesOldAll = new HashSet<>();
|
|
|
+ List<String> resultTablesData = new ArrayList<>();
|
|
|
+
|
|
|
+ //表单所属方
|
|
|
+ String tabOwner = "";
|
|
|
+ if (("1,2").equals(vo.getClassifyType()) || ("2,1").equals(vo.getClassifyType())) {
|
|
|
+ tabOwner = "1,2,3,4,5,6";
|
|
|
+ } else if (("1").equals(vo.getClassifyType())) {
|
|
|
+ tabOwner = "1,2,3";
|
|
|
+ } else if (("2").equals(vo.getClassifyType())) {
|
|
|
+ tabOwner = "4,5,6";
|
|
|
}
|
|
|
- //设置父节点ID
|
|
|
- if (vo.getNeedCopyPrimaryKeyId().equals(node.getPKeyId().toString())) {
|
|
|
- //找到复制的节点,将parentId更改为 parent.getId()
|
|
|
- newData.setParentId(parent.getId());
|
|
|
- //设置新名称
|
|
|
- newData.setNodeName(vo.getNeedCopyNodeName());
|
|
|
- newData.setFullName(vo.getNeedCopyNodeName());
|
|
|
- } else {
|
|
|
- newData.setParentId(oldToNewIdMap.containsKey(node.getParentId()) ? oldToNewIdMap.get(node.getParentId()) : SnowFlakeUtil.getId());
|
|
|
+
|
|
|
+ //解析位置信息,进行复制数据构造
|
|
|
+ if (toCopyNodes.size() == copyBatches.size()) {
|
|
|
+ for (int i = 0; i < toCopyNodes.size(); i++) {
|
|
|
+ //首先查询需要复制的节点的信息
|
|
|
+ WbsTreeContract needCopyNode = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(vo.getNeedCopyPrimaryKeyId());
|
|
|
+ WbsTreeContract toCopyNode = toCopyNodes.get(i);
|
|
|
+ CopyContractTreeNodeVO.CopyBatch toCopyVO = copyBatches.get(i);
|
|
|
+
|
|
|
+ if (toCopyNode != null && toCopyVO != null && needCopyNode != null) {
|
|
|
+ //TODO 同节点复制
|
|
|
+ if (new Integer(1).equals(toCopyVO.getIsSameNode())) {
|
|
|
+ //1.1 选择当前节点的父级节点,新增
|
|
|
+ if (needCopyNode.getParentId().equals(toCopyNode.getId())) {
|
|
|
+ toCopyNode.setNodeName(toCopyVO.getNodeName());
|
|
|
+ toCopyNode.setPartitionCode(toCopyVO.getPartitionCode());
|
|
|
+
|
|
|
+ //获取需要复制的所有子节点
|
|
|
+ List<WbsTreeContract> addChildNodes = this.getChildNodes(needCopyNode);
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty(addChildNodes) || addChildNodes.size() == 0) {
|
|
|
+ //最下层级节点复制
|
|
|
+ addChildNodes = new ArrayList<>();
|
|
|
+ addChildNodes.add(needCopyNode);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取所有复制的表
|
|
|
+ List<WbsTreeContract> addChildNodesTables = this.getChildNodesTables(addChildNodes, toCopyNode.getContractId());
|
|
|
+
|
|
|
+ //复制数据源表,文件附件用
|
|
|
+ List<WbsTreeContract> oldTab = BeanUtil.copyProperties(addChildNodesTables, WbsTreeContract.class);
|
|
|
+ addChildNodesTablesOldAll.addAll(oldTab);
|
|
|
+
|
|
|
+ //构造新的节点、表、数据
|
|
|
+ this.addCopyNodesAndTabsBuildData(addChildNodes, addChildNodesTables, needCopyNode, toCopyNode, resultTablesData, 1, tabOwner, vo.getIsCopyData());
|
|
|
+
|
|
|
+ //返回结果集
|
|
|
+ addChildNodesAll.addAll(addChildNodes);
|
|
|
+ addChildNodesTablesAll.addAll(addChildNodesTables);
|
|
|
+
|
|
|
+ //1.2 选择同父级的同级节点,只复制数据
|
|
|
+ } else if (needCopyNode.getParentId().equals(toCopyNode.getParentId())) {
|
|
|
+ //构造数据
|
|
|
+ this.addCopyTabData(needCopyNode, toCopyNode, tabOwner, resultTablesData, addChildNodesTablesOldAll, addChildNodesTablesAll, vo.getIsCopyData());
|
|
|
+ }
|
|
|
+
|
|
|
+ //TODO 跨节点复制
|
|
|
+ } else if (new Integer(0).equals(toCopyVO.getIsSameNode())) {
|
|
|
+ //获取需要复制节点的上级
|
|
|
+ WbsTreeContract parentNodeNeed = wbsTreeContractClient.getContractWbsTreeByContractIdAndId(needCopyNode.getParentId(), Long.parseLong(needCopyNode.getContractId()));
|
|
|
+
|
|
|
+ //2.1 选择的父级的同级的父级节点,新增(当复制节点父级与选择复制到的位置节点的父级id相同时,表示跨节点)
|
|
|
+ if (parentNodeNeed != null && parentNodeNeed.getParentId().equals(toCopyNode.getParentId())) {
|
|
|
+ toCopyNode.setNodeName(toCopyVO.getNodeName());
|
|
|
+ toCopyNode.setPartitionCode(toCopyVO.getPartitionCode());
|
|
|
+
|
|
|
+ //获取需要复制的所有子节点
|
|
|
+ List<WbsTreeContract> addChildNodes = this.getChildNodes(needCopyNode);
|
|
|
+
|
|
|
+ //最下层级节点复制
|
|
|
+ if (ObjectUtil.isEmpty(addChildNodes) || addChildNodes.size() == 0) {
|
|
|
+ addChildNodes = new ArrayList<>();
|
|
|
+ addChildNodes.add(needCopyNode);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取所有复制的表
|
|
|
+ List<WbsTreeContract> addChildNodesTables = this.getChildNodesTables(addChildNodes, toCopyNode.getContractId());
|
|
|
+
|
|
|
+ //复制数据源表,文件附件用
|
|
|
+ List<WbsTreeContract> oldTab = BeanUtil.copyProperties(addChildNodesTables, WbsTreeContract.class);
|
|
|
+ addChildNodesTablesOldAll.addAll(oldTab);
|
|
|
+
|
|
|
+ //构造新的节点、表、数据
|
|
|
+ this.addCopyNodesAndTabsBuildData(addChildNodes, addChildNodesTables, needCopyNode, toCopyNode, resultTablesData, 0, tabOwner, vo.getIsCopyData());
|
|
|
+
|
|
|
+ //返回结果集
|
|
|
+ addChildNodesAll.addAll(addChildNodes);
|
|
|
+ addChildNodesTablesAll.addAll(addChildNodesTables);
|
|
|
+
|
|
|
+ //2.2 如果点击选择的是当前复制节点本身的同等级节点,那么就只复制数据。(如果是跨节点,类型相同的情况下,只复制数据)
|
|
|
+ } else if (needCopyNode.getNodeType().equals(toCopyNode.getNodeType()) && !needCopyNode.getParentId().equals(toCopyNode.getParentId())) {
|
|
|
+ //构造数据
|
|
|
+ this.addCopyTabData(needCopyNode, toCopyNode, tabOwner, resultTablesData, addChildNodesTablesOldAll, addChildNodesTablesAll, vo.getIsCopyData());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- newData.setCreateTime(new Date());
|
|
|
- newData.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ //节点
|
|
|
+ if (addChildNodesAll.size() > 0) {
|
|
|
+ wbsTreeContractClient.saveBatch(addChildNodesAll);
|
|
|
+ //更新redis缓存
|
|
|
+ Map<Long, List<WbsTreeContract>> collect = addChildNodesAll.stream().filter(f -> new Integer(1).equals(f.getType()) && ObjectUtil.isNotEmpty(f.getParentId())).collect(Collectors.groupingBy(WbsTreeContract::getParentId));
|
|
|
+ for (Map.Entry<Long, List<WbsTreeContract>> longListEntry : collect.entrySet()) {
|
|
|
+ informationQueryService.AsyncWbsTree("", longListEntry.getKey().toString(), contractId, "", "1");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //元素表
|
|
|
+ if (addChildNodesTablesAll.size() > 0) {
|
|
|
+ wbsTreeContractClient.saveBatch(addChildNodesTablesAll);
|
|
|
+
|
|
|
+ //表单文件附件
|
|
|
+ if (addChildNodesTablesOldAll.size() > 0 && vo.getIsCopyData() == 1) {
|
|
|
+ this.addCopyTabFile(addChildNodesTablesAll, addChildNodesTablesOldAll);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //实体表数据
|
|
|
+ if (resultTablesData.size() > 0) {
|
|
|
+ jdbcTemplate.execute(StringUtils.join(resultTablesData, ""));
|
|
|
+ }
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.fail("操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增复制的表单文件
|
|
|
+ */
|
|
|
+ @Async
|
|
|
+ public void addCopyTabFile(List<WbsTreeContract> addChildNodesTables, Set<WbsTreeContract> addChildNodesTablesOld) {
|
|
|
+ //获取所有数据源附件文件
|
|
|
+ List<Long> tabFileIds = addChildNodesTablesOld.stream().distinct().map(WbsTreeContract::getPKeyId).collect(Collectors.toList());
|
|
|
+ Map<String, List<TableFile>> tableFileOldMap = tableFileClient.getTabFilesByTabIds(StringUtils.join(tabFileIds, ",")).stream().collect(Collectors.groupingBy(TableFile::getTabId));
|
|
|
+ if (tableFileOldMap != null && tableFileOldMap.size() > 0) {
|
|
|
+ List<TableFile> resultFileData = new ArrayList<>();
|
|
|
+ for (WbsTreeContract tabOld : addChildNodesTablesOld) {
|
|
|
+ for (WbsTreeContract tabNew : addChildNodesTables) {
|
|
|
+ //获取对应表
|
|
|
+ if (tabOld.getNodeName().equals(tabNew.getNodeName()) && (ObjectUtil.isNotEmpty(tabOld.getHtmlUrl()) && ObjectUtil.isNotEmpty(tabNew.getHtmlUrl()) && tabOld.getHtmlUrl().equals(tabNew.getHtmlUrl()))) {
|
|
|
+ //构建文件数据
|
|
|
+ List<TableFile> tab = tableFileOldMap.get(tabOld.getPKeyId() + "");
|
|
|
+ if (tab != null && tab.size() > 0) {
|
|
|
+ tab.forEach(file -> {
|
|
|
+ file.setTabId(tabNew.getPKeyId() + "");
|
|
|
+ file.setId(SnowFlakeUtil.getId());
|
|
|
+ });
|
|
|
+ resultFileData.addAll(tab);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (resultFileData.size() > 0) {
|
|
|
+ tableFileClient.saveBatch(resultFileData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增复制的数据
|
|
|
+ */
|
|
|
+ private void addCopyTabData(WbsTreeContract needCopyNode, WbsTreeContract toCopyNode, String tabOwner, List<String> resultTablesData, Set<WbsTreeContract> addChildNodesTablesOldAll, List<WbsTreeContract> addChildNodesTablesAll, Integer isCopyData) {
|
|
|
+ List<WbsTreeContract> wbsTreeContractsNeed = Collections.singletonList(needCopyNode);
|
|
|
+ List<WbsTreeContract> wbsTreeContractsTo = Collections.singletonList(toCopyNode);
|
|
|
+ List<WbsTreeContract> needCopyNodeTabs = getChildNodesTables(wbsTreeContractsNeed, needCopyNode.getContractId());
|
|
|
+ List<WbsTreeContract> toCopyNodeTabs = getChildNodesTables(wbsTreeContractsTo, needCopyNode.getContractId());
|
|
|
+ if (needCopyNodeTabs.size() > 0) {
|
|
|
+ for (WbsTreeContract needTab : needCopyNodeTabs) {
|
|
|
+ for (WbsTreeContract toCopyNodeTab : toCopyNodeTabs) {
|
|
|
+ //获取相同表单 nodeName 、HtmlUrl相同
|
|
|
+ if (needTab.getNodeName().equals(toCopyNodeTab.getNodeName()) && (ObjectUtil.isNotEmpty(needTab.getHtmlUrl()) && ObjectUtil.isNotEmpty(toCopyNodeTab.getHtmlUrl()) && needTab.getHtmlUrl().equals(toCopyNodeTab.getHtmlUrl()))) {
|
|
|
+ if (StringUtils.isEmpty(needTab.getInitTableName())) {
|
|
|
+ //没有对应实体表,跳过
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Long oldPKeyId = needTab.getPKeyId();
|
|
|
+
|
|
|
+ //表单所属方,只有勾选了对应的所属方权限才复制数据;勾选了复制数据才能复制,否则只是创建节点、表
|
|
|
+ if (tabOwner.contains(needTab.getTableOwner()) && isCopyData == 1) {
|
|
|
+
|
|
|
+ //源表obj对象,文件附件使用
|
|
|
+ addChildNodesTablesOldAll.add(needTab);
|
|
|
+ if (!needTab.getTabFileType().equals(toCopyNodeTab.getTabFileType())) {
|
|
|
+ toCopyNodeTab.setTabFileType(needTab.getTabFileType()); //已上传
|
|
|
+ }
|
|
|
+ //目标表obj对象,文件附件使用
|
|
|
+ addChildNodesTablesAll.add(toCopyNodeTab);
|
|
|
+
|
|
|
+ //获取实体表列对象
|
|
|
+ List<QueryProcessDataVO> nodeTabColOneTab = informationQueryService.getNodeChildTabColsAllByTabName(needTab.getInitTableName());
|
|
|
+ //转化为map
|
|
|
+ Map<String, String> nodeTabColsMap = nodeTabColOneTab.stream().collect(Collectors.toMap(QueryProcessDataVO::getQueryType, QueryProcessDataVO::getAncestors, (key1, key2) -> key2));
|
|
|
+ //组织复制表的数据的sql
|
|
|
+ if (nodeTabColsMap.size() > 0) {
|
|
|
+ StringBuilder copyDataSql = new StringBuilder();
|
|
|
+ String tableName = needTab.getInitTableName();
|
|
|
+ String col = nodeTabColsMap.get(tableName);
|
|
|
+ String colVal = nodeTabColsMap.get(tableName);
|
|
|
+ colVal = colVal.replaceAll("id,p_key_id,", "'" + SnowFlakeUtil.getId() + "' as id,'" + toCopyNodeTab.getPKeyId() + "' as p_key_id,");
|
|
|
+ //delete SQL (先删除旧数据,再新增)
|
|
|
+ String delSql = "delete from " + tableName + " where p_key_id = " + toCopyNodeTab.getPKeyId() + " ; ";
|
|
|
+ //insert into SQL
|
|
|
+ copyDataSql.append(delSql).append("insert into ").append(tableName).append(" (").append(col).append(") select ").append(colVal).append(" from ").append(tableName).append(" where p_key_id='").append(oldPKeyId).append("' ;");
|
|
|
+ resultTablesData.add(copyDataSql.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增复制的节点、表的数据构造
|
|
|
+ */
|
|
|
+ private void addCopyNodesAndTabsBuildData(List<WbsTreeContract> needNodes, List<WbsTreeContract> needTabs, WbsTreeContract needCopyNode, WbsTreeContract toCopyNode, List<String> resultTablesData, Integer isSameNode, String tabOwner, Integer isCopyData) {
|
|
|
+ int var = 0;
|
|
|
+ if (needNodes.size() == 1) {
|
|
|
+ //判断是否为最下级节点
|
|
|
+ WbsTreeContract wbsTreeContract = needNodes.stream().filter(f -> f.getPKeyId().equals(needCopyNode.getPKeyId())).findAny().orElse(null);
|
|
|
+ if (wbsTreeContract != null) {
|
|
|
+ var = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //最下层级节点复制
|
|
|
+ if (var == 1) {
|
|
|
+ //构造节点
|
|
|
+ Long id = SnowFlakeUtil.getId();
|
|
|
+ for (WbsTreeContract needNode : needNodes) {
|
|
|
+ if (isSameNode == 0) {
|
|
|
+ //跨节点复制,更改父级id
|
|
|
+ needNode.setParentId(toCopyNode.getId());
|
|
|
+ }
|
|
|
+ needNode.setOldId(needNode.getId() + "");
|
|
|
+ needNode.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ needNode.setId(id);
|
|
|
+ needNode.setNodeName(toCopyNode.getNodeName());
|
|
|
+ needNode.setFullName(toCopyNode.getNodeName());
|
|
|
+ needNode.setPartitionCode(toCopyNode.getPartitionCode());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //构造当前节点下所有元素表
|
|
|
+ for (WbsTreeContract needTab : needTabs) {
|
|
|
+ if (StringUtils.isEmpty(needTab.getInitTableName())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Long oldPKeyId = needTab.getPKeyId();
|
|
|
+
|
|
|
+ Long tabId = SnowFlakeUtil.getId();
|
|
|
+ needTab.setAncestors(needTab.getAncestors().replace(needTab.getParentId().toString(), id.toString()));
|
|
|
+ needTab.setId(tabId);
|
|
|
+ needTab.setParentId(id);
|
|
|
+ needTab.setPKeyId(SnowFlakeUtil.getId());
|
|
|
//初始化是否显示表格,默认显示
|
|
|
- newData.setIsBussShow(1);
|
|
|
+ needTab.setIsBussShow(1);
|
|
|
//初始化表格是否上传附件,默认未上传
|
|
|
- newData.setTabFileType(1);
|
|
|
+ needTab.setTabFileType(1);
|
|
|
//初始化单表是否可以预览,默认不能
|
|
|
- newData.setIsTabPdf(1);
|
|
|
+ needTab.setIsTabPdf(1);
|
|
|
//初始化PDF路径
|
|
|
- newData.setPdfUrl(null);
|
|
|
- newData.setCreateUser(AuthUtil.getUserId());
|
|
|
- //重塑父节点关联关系
|
|
|
- this.restoreParent(newData, oldToNewIdMap);
|
|
|
- //保存到集合中
|
|
|
- saveList.add(newData);
|
|
|
- if (new Integer("6").equals(node.getNodeType())) {
|
|
|
- //生成施工日志
|
|
|
- this.createLedger(newData, saveLedger, nodeMap, null);
|
|
|
+ needTab.setPdfUrl(null);
|
|
|
+
|
|
|
+ //表单所属方,只有勾选了对应的所属方权限才复制数据;勾选了复制数据才能复制,否则只是创建节点、表
|
|
|
+ if (tabOwner.contains(needTab.getTableOwner()) && isCopyData == 1) {
|
|
|
+ //获取实体表列对象
|
|
|
+ List<QueryProcessDataVO> nodeTabColOneTab = informationQueryService.getNodeChildTabColsAllByTabName(needTab.getInitTableName());
|
|
|
+ //转化为map
|
|
|
+ Map<String, String> nodeTabColsMap = nodeTabColOneTab.stream().collect(Collectors.toMap(QueryProcessDataVO::getQueryType, QueryProcessDataVO::getAncestors, (key1, key2) -> key2));
|
|
|
+ //组织复制表的数据的sql
|
|
|
+ if (nodeTabColsMap.size() > 0) {
|
|
|
+ StringBuilder copyDataSql = new StringBuilder();
|
|
|
+ String tableName = needTab.getInitTableName();
|
|
|
+ String col = nodeTabColsMap.get(tableName);
|
|
|
+ String colVal = nodeTabColsMap.get(tableName);
|
|
|
+ colVal = colVal.replaceAll("id,p_key_id,", "'" + SnowFlakeUtil.getId() + "' as id,'" + needTab.getPKeyId() + "' as p_key_id,");
|
|
|
+ copyDataSql.append("insert into ").append(tableName).append(" (").append(col).append(") select ").append(colVal).append(" from ").append(tableName).append(" where p_key_id='").append(oldPKeyId).append("' ;");
|
|
|
+ resultTablesData.add(copyDataSql.toString());
|
|
|
+ }
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- // 组织复制值Sql
|
|
|
- if (nodeTabColsMap != null && node.getType() == 2) {
|
|
|
- String tableName = newData.getInitTableName();
|
|
|
- String col = nodeTabColsMap.get(tableName);
|
|
|
- String colVal = nodeTabColsMap.get(tableName);
|
|
|
- colVal = colVal.replaceAll("id,p_key_id,", "'" + SnowFlakeUtil.getId() + "' as id,'" + newData.getPKeyId() + "' as p_key_id,");
|
|
|
- copeSql.append("insert into " + tableName + " (" + col + ") select " + colVal + " from " + tableName + " where p_key_id='" + node.getPKeyId() + "' ;");
|
|
|
+ } else { //多层级节点复制
|
|
|
+ //根节点id
|
|
|
+ Long toCopyNodeOldId = toCopyNode.getId();
|
|
|
+ toCopyNode.setId(SnowFlakeUtil.getId());
|
|
|
+
|
|
|
+ Map<Long, Long> parentIdToId = new HashMap<>();
|
|
|
+ Map<Long, List<WbsTreeContract>> tabMap = needTabs.stream().collect(Collectors.groupingBy(WbsTreeContract::getParentId));
|
|
|
+
|
|
|
+ for (WbsTreeContract node : needNodes) {
|
|
|
+ Long oldId = node.getId();
|
|
|
+ //构造节点
|
|
|
+ Long newParentId;
|
|
|
+ if (parentIdToId.size() > 0) {
|
|
|
+ //去数据源节点获取父级id对应的新id,设置成重设后的新的父级id
|
|
|
+ newParentId = parentIdToId.get(node.getParentId());
|
|
|
+ } else {
|
|
|
+ //根节点
|
|
|
+ newParentId = toCopyNode.getId();
|
|
|
}
|
|
|
- });
|
|
|
+ if (ObjectUtils.isEmpty(newParentId)) {
|
|
|
+ newParentId = toCopyNode.getId();
|
|
|
+ }
|
|
|
+ node.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ node.setOldId(node.getId().toString());
|
|
|
+ Long id = SnowFlakeUtil.getId();
|
|
|
+ //数据源节点的老id与新的id的Map,作为下一级的节点的父级id的替换
|
|
|
+ parentIdToId.put(node.getId(), id);
|
|
|
+ //重设祖级id
|
|
|
+ node.setAncestors(node.getAncestors().replace(node.getParentId().toString(), id.toString()));
|
|
|
+ //重设Id
|
|
|
+ node.setId(id);
|
|
|
+ node.setParentId(newParentId);
|
|
|
+
|
|
|
+ //构造当前节点下所有元素表
|
|
|
+ List<WbsTreeContract> tabs = tabMap.get(oldId);
|
|
|
+ //构造节点下的表
|
|
|
+ if (tabs != null && tabs.size() > 0) {
|
|
|
+ for (WbsTreeContract needTab : tabs) {
|
|
|
+ if (StringUtils.isEmpty(needTab.getInitTableName())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Long oldPKeyId = needTab.getPKeyId();
|
|
|
+
|
|
|
+ Long tabId = SnowFlakeUtil.getId();
|
|
|
+ needTab.setAncestors(needTab.getAncestors().replace(needTab.getParentId().toString(), id.toString()));
|
|
|
+ needTab.setId(tabId);
|
|
|
+ needTab.setParentId(id);
|
|
|
+ needTab.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ //初始化是否显示表格,默认显示
|
|
|
+ needTab.setIsBussShow(1);
|
|
|
+ //初始化表格是否上传附件,默认未上传
|
|
|
+ needTab.setTabFileType(1);
|
|
|
+ //初始化单表是否可以预览,默认不能
|
|
|
+ needTab.setIsTabPdf(1);
|
|
|
+ //初始化PDF路径
|
|
|
+ needTab.setPdfUrl(null);
|
|
|
+
|
|
|
+ //表单所属方,只有勾选了对应的所属方权限才复制数据;勾选了复制数据才能复制,否则只是创建节点、表
|
|
|
+ if (tabOwner.contains(needTab.getTableOwner()) && isCopyData == 1) {
|
|
|
+ //获取实体表列对象
|
|
|
+ List<QueryProcessDataVO> nodeTabColOneTab = informationQueryService.getNodeChildTabColsAllByTabName(needTab.getInitTableName());
|
|
|
+ //转化为map
|
|
|
+ Map<String, String> nodeTabColsMap = nodeTabColOneTab.stream().collect(Collectors.toMap(QueryProcessDataVO::getQueryType, QueryProcessDataVO::getAncestors, (key1, key2) -> key2));
|
|
|
+ //组织复制表的数据的sql
|
|
|
+ if (nodeTabColsMap.size() > 0) {
|
|
|
+ StringBuilder copyDataSql = new StringBuilder();
|
|
|
+ String tableName = needTab.getInitTableName();
|
|
|
+ String col = nodeTabColsMap.get(tableName);
|
|
|
+ String colVal = nodeTabColsMap.get(tableName);
|
|
|
+ colVal = colVal.replaceAll("id,p_key_id,", "'" + SnowFlakeUtil.getId() + "' as id,'" + needTab.getPKeyId() + "' as p_key_id,");
|
|
|
+ copyDataSql.append("insert into ").append(tableName).append(" (").append(col).append(") select ").append(colVal).append(" from ").append(tableName).append(" where p_key_id='").append(oldPKeyId).append("' ;");
|
|
|
+ resultTablesData.add(copyDataSql.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //添加根节点
|
|
|
+ toCopyNode.setOldId(needCopyNode.getId() + "");
|
|
|
+ if (isSameNode == 1) {
|
|
|
+ //同节点
|
|
|
+ toCopyNode.setParentId(needCopyNode.getParentId());
|
|
|
+ } else {
|
|
|
+ //跨节点
|
|
|
+ toCopyNode.setParentId(toCopyNodeOldId);
|
|
|
+ }
|
|
|
+ toCopyNode.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ toCopyNode.setNodeName(toCopyNode.getNodeName());
|
|
|
+ toCopyNode.setFullName(toCopyNode.getNodeName());
|
|
|
+ toCopyNode.setPartitionCode(toCopyNode.getPartitionCode());
|
|
|
+ needNodes.add(toCopyNode);
|
|
|
}
|
|
|
- //保存节点信息
|
|
|
- R<Boolean> booleanR = this.saveOrCopyNodeTree(saveList, saveLedger, 32, needCopyNode);
|
|
|
+ }
|
|
|
|
|
|
- //复制数据逻辑
|
|
|
- if (nodeTabColsMap != null && copeSql.length() >= 10) {
|
|
|
- jdbcTemplate.execute(copeSql.toString());
|
|
|
+ /**
|
|
|
+ * 获取所有子级节点
|
|
|
+ */
|
|
|
+ private List<WbsTreeContract> getChildNodes(WbsTreeContract obj) {
|
|
|
+ if (obj != null) {
|
|
|
+ List<WbsTreeContract> wbsTreeContracts = Collections.singletonList(obj);
|
|
|
+ List<WbsTreeContract> result = new ArrayList<>();
|
|
|
+ this.recursionGetChildNodes(wbsTreeContracts, result, obj.getContractId());
|
|
|
+ if (result.size() > 0) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
- //获取父节点信息
|
|
|
- informationQueryService.AsyncWbsTree(needCopyNode.getParentId() + "", needCopyNode.getParentId() + "", needCopyNode.getContractId(), "", "1");
|
|
|
- return booleanR;
|
|
|
+ /**
|
|
|
+ * 递归获取所有子级节点
|
|
|
+ */
|
|
|
+ private void recursionGetChildNodes(List<WbsTreeContract> list, List<WbsTreeContract> result, String contractId) {
|
|
|
+ List<Long> ids = list.stream().map(WbsTreeContract::getId).collect(Collectors.toList());
|
|
|
+ if (ids.size() > 0) {
|
|
|
+ List<WbsTreeContract> query = jdbcTemplate.query("select * from m_wbs_tree_contract where type = 1 and parent_id in(" + StringUtils.join(ids, ",") + ") and status = 1 and is_deleted = 0 and contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
+ if (query.size() > 0) {
|
|
|
+ result.addAll(query);
|
|
|
+ recursionGetChildNodes(query, result, contractId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取所有子级下的表
|
|
|
+ */
|
|
|
+ private List<WbsTreeContract> getChildNodesTables(List<WbsTreeContract> list, String contractId) {
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
+ List<Long> parentIds = list.stream().map(WbsTreeContract::getId).collect(Collectors.toList());
|
|
|
+ return jdbcTemplate.query("select * from m_wbs_tree_contract where type = 2 and is_deleted = 0 and status = 1 and parent_id in(" + StringUtils.join(parentIds, ",") + ") and contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1619,17 +2056,6 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
newData.setPdfUrl(null);
|
|
|
|
|
|
//获取当前所有复制的节点的最大sort
|
|
|
- /*String sql = "select sort from m_wbs_tree_contract where contract_id = '" + node.getContractId() + "' and (id = '" + node.getId() + "' or old_id = '" + node.getId() + "')";
|
|
|
- List<WbsTreeContract> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
- List<Integer> collect = query.stream().filter(f -> ObjectUtils.isNotEmpty(f.getSort())).collect(Collectors.toList()).stream().map(WbsTreeContract::getSort).collect(Collectors.toList());
|
|
|
- Integer max = 1;
|
|
|
- if (collect.size() > 0) {
|
|
|
- max = collect.stream().reduce(collect.get(0), Integer::max);
|
|
|
- } else {
|
|
|
- max = 1;
|
|
|
- }
|
|
|
- //设置sort
|
|
|
- newData.setSort(max);*/
|
|
|
newData.setSort(ObjectUtils.isNotEmpty(node.getSort()) ? node.getSort() : 0);
|
|
|
|
|
|
//重塑父节点关联关系
|
|
@@ -1676,7 +2102,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
/**
|
|
|
* 生成施工日志记录
|
|
|
*/
|
|
|
- private void createLedger(WbsTreeContract newData, List<ConstructionLedger> saveLedger, Map<String, WbsTreeContract> contractNodeMap, Map<String, WbsTreePrivate> projectNodeMap) {
|
|
|
+ private void createLedger(WbsTreeContract
|
|
|
+ newData, List<ConstructionLedger> saveLedger, Map<String, WbsTreeContract> contractNodeMap, Map<String, WbsTreePrivate> projectNodeMap) {
|
|
|
//工序,需要新增施工台账
|
|
|
ConstructionLedger ledger = new ConstructionLedger();
|
|
|
//获取这个节点的原始信息
|
|
@@ -1730,7 +2157,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
* @param parentList 父节点集合
|
|
|
* @param childList 保存集合
|
|
|
*/
|
|
|
- private void foreachQueryChildContract(List<WbsTreeContract> parentList, List<WbsTreeContract> childList, Map<String, List<WbsTreeContract>> contractAllNodeMap) {
|
|
|
+ private void foreachQueryChildContract
|
|
|
+ (List<WbsTreeContract> parentList, List<WbsTreeContract> childList, Map<String, List<WbsTreeContract>> contractAllNodeMap) {
|
|
|
parentList.forEach(parent -> {
|
|
|
List<WbsTreeContract> childs;
|
|
|
if (contractAllNodeMap.containsKey(parent.getId().toString())) {
|
|
@@ -1771,7 +2199,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
@ApiImplicitParam(name = "wbsType", value = "模板类型, 1质检,2试验", required = true),
|
|
|
@ApiImplicitParam(name = "contractId", value = "合同段ID", required = true)
|
|
|
})
|
|
|
- public R<List<WbsTreeContractTreeVOS>> queryMappingStructureTree(@RequestParam String parentId, @RequestParam String contractId, @RequestParam String contractIdRelation) {
|
|
|
+ public R<List<WbsTreeContractTreeVOS>> queryMappingStructureTree(@RequestParam String
|
|
|
+ parentId, @RequestParam String contractId, @RequestParam String contractIdRelation) {
|
|
|
List<WbsTreeContractTreeVOS> result = this.informationQueryService.queryContractTree(parentId, contractId, contractIdRelation, null);
|
|
|
if (result.size() == 1) {
|
|
|
//只有一个子节点,继续向下
|
|
@@ -1823,7 +2252,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
@ApiImplicitParam(name = "nodeName", value = "节点的title", required = true),
|
|
|
@ApiImplicitParam(name = "partitionCode", value = "划分编号")
|
|
|
})
|
|
|
- public R<Boolean> updateContractNodeParameter(@RequestParam Long pKeyId, @RequestParam String nodeName, @RequestParam String partitionCode) {
|
|
|
+ public R<Boolean> updateContractNodeParameter(@RequestParam Long pKeyId, @RequestParam String
|
|
|
+ nodeName, @RequestParam String partitionCode) {
|
|
|
WbsTreeContract node = new WbsTreeContract();
|
|
|
node.setPKeyId(pKeyId);
|
|
|
node.setNodeName(nodeName);
|
|
@@ -2133,7 +2563,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
return booleanR;
|
|
|
}
|
|
|
|
|
|
- private List<WbsTreePrivate> unifiedCode(List<AddContractTreeNodeVO.Node> allSelectedNodeList, WbsTreeContract treeContract) {
|
|
|
+ private List<WbsTreePrivate> unifiedCode
|
|
|
+ (List<AddContractTreeNodeVO.Node> allSelectedNodeList, WbsTreeContract treeContract) {
|
|
|
//获取主键
|
|
|
List<String> halfSelectedList = allSelectedNodeList.stream().map(AddContractTreeNodeVO.Node::getPrimaryKeyId).distinct().collect(Collectors.toList());
|
|
|
//查询数据
|
|
@@ -2145,7 +2576,9 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
}
|
|
|
|
|
|
@NotNull
|
|
|
- private R<Boolean> saveOrCopyNodeTree(List<WbsTreeContract> saveList, List<ConstructionLedger> saveLedger, Integer operationType, WbsTreeContract currentNode) {
|
|
|
+ private R<Boolean> saveOrCopyNodeTree
|
|
|
+ (List<WbsTreeContract> saveList, List<ConstructionLedger> saveLedger, Integer
|
|
|
+ operationType, WbsTreeContract currentNode) {
|
|
|
|
|
|
if (saveList.size() > 0) {
|
|
|
StringBuilder str = new StringBuilder();
|
|
@@ -2199,7 +2632,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
/**
|
|
|
* 处理半选集合
|
|
|
*/
|
|
|
- private void disposeHalfSelectList(@RequestBody WbsTreeContract treeContract, List<AddContractTreeNodeVO.Node> allSelectedNodeList, List<WbsTreePrivate> selectedNodeList) {
|
|
|
+ private void disposeHalfSelectList(@RequestBody WbsTreeContract
|
|
|
+ treeContract, List<AddContractTreeNodeVO.Node> allSelectedNodeList, List<WbsTreePrivate> selectedNodeList) {
|
|
|
if (allSelectedNodeList != null && allSelectedNodeList.size() > 0) {
|
|
|
//获取主键
|
|
|
List<String> allSelectedList = allSelectedNodeList.stream().map(AddContractTreeNodeVO.Node::getPrimaryKeyId).distinct().collect(Collectors.toList());
|
|
@@ -2245,7 +2679,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
@ApiImplicitParam(name = "projectId", value = "项目ID"),
|
|
|
@ApiImplicitParam(name = "id", value = "点击节点ID")
|
|
|
})
|
|
|
- public R<List<WbsTreeContractTreeVOS>> queryWbsTreePrivateByProjectIdAndId(@RequestParam String projectId, @RequestParam String id) {
|
|
|
+ public R<List<WbsTreeContractTreeVOS>> queryWbsTreePrivateByProjectIdAndId(@RequestParam String
|
|
|
+ projectId, @RequestParam String id) {
|
|
|
List<WbsTreeContractTreeVOS> result = new ArrayList<>();
|
|
|
|
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
@@ -2268,6 +2703,44 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
return R.data(result);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 懒加载项目级工程划分树
|
|
|
+ *
|
|
|
+ * @param contractId 合同段ID
|
|
|
+ * @param id 节点ID
|
|
|
+ * @return 结果集
|
|
|
+ */
|
|
|
+ @PostMapping("/queryWbsTreeContractByContractIdAndId")
|
|
|
+ @ApiOperationSupport(order = 9)
|
|
|
+ @ApiOperation(value = "懒加载合同段工程划分树")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "contractId", value = "合同段ID"),
|
|
|
+ @ApiImplicitParam(name = "id", value = "点击节点ID")
|
|
|
+ })
|
|
|
+ public R<List<WbsTreeContractTreeVOS>> queryWbsTreeContractByContractIdAndId(@RequestParam String contractId, @RequestParam String id) {
|
|
|
+ List<WbsTreeContractTreeVOS> result = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotEmpty(id)) {
|
|
|
+ WbsTreeContractTreeVOS vos = new WbsTreeContractTreeVOS();
|
|
|
+ WbsTreeContract wbsTreeContract = this.wbsTreeContractClient.queryWbsTreeContractById(contractId, Long.parseLong(id));
|
|
|
+ if (wbsTreeContract != null) {
|
|
|
+ //设置参数
|
|
|
+ vos.setId(wbsTreeContract.getId());
|
|
|
+ vos.setKey(wbsTreeContract.getId().toString());
|
|
|
+ vos.setPrimaryKeyId(wbsTreeContract.getPKeyId().toString());
|
|
|
+ vos.setParentId(wbsTreeContract.getParentId());
|
|
|
+ vos.setTitle(wbsTreeContract.getNodeName());
|
|
|
+ vos.setType(wbsTreeContract.getType());
|
|
|
+ vos.setWbsType(wbsTreeContract.getWbsType());
|
|
|
+ //设置子级
|
|
|
+ vos.setChildren(this.wbsTreeContractClient.queryWbsTreeContractTreeLazy(contractId, Long.parseLong(id)));
|
|
|
+ //添加进结果集合中
|
|
|
+ result.add(vos);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.data(result);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取与当前节点平级的项目级节点
|
|
|
*
|
|
@@ -2419,7 +2892,9 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
@ApiImplicitParam(name = "parentId", value = "父节点,为空则查询第一级节点"),
|
|
|
@ApiImplicitParam(name = "contractId", value = "合同段ID", required = true)
|
|
|
})
|
|
|
- public R<List<WbsTreeContractTreeVOS>> queryStandingBookContractWbsTree(@RequestParam String primaryKeyId, @RequestParam String parentId, @RequestParam String contractId, @RequestParam String contractIdRelation) {
|
|
|
+ public R<List<WbsTreeContractTreeVOS>> queryStandingBookContractWbsTree(@RequestParam String
|
|
|
+ primaryKeyId, @RequestParam String parentId, @RequestParam String contractId, @RequestParam String
|
|
|
+ contractIdRelation) {
|
|
|
if (StringUtils.isNotEmpty(primaryKeyId)) {
|
|
|
parentId = primaryKeyId;
|
|
|
}
|
|
@@ -2510,7 +2985,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
@ApiImplicitParam(name = "parentId", value = "父节点,为空则查询第一级节点"),
|
|
|
@ApiImplicitParam(name = "contractId", value = "合同段ID", required = true)
|
|
|
})
|
|
|
- public R<List<WbsTreeContractTreeVOS>> queryContractWbsTreeByFirstInfo(@RequestParam String parentId, @RequestParam String contractId, @RequestParam String contractIdRelation) {
|
|
|
+ public R<List<WbsTreeContractTreeVOS>> queryContractWbsTreeByFirstInfo(@RequestParam String
|
|
|
+ parentId, @RequestParam String contractId, @RequestParam String contractIdRelation) {
|
|
|
List<WbsTreeContractTreeVOS> rootTreeNode = informationQueryService.queryContractTree(parentId, contractId, contractIdRelation, null);
|
|
|
//查询被标记为首件的数据
|
|
|
rootTreeNode = rootTreeNode.stream().filter(WbsTreeContractTreeVOS::getIsFirst).collect(Collectors.toList());
|