|
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import io.swagger.annotations.*;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -1501,10 +1502,11 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
needCopyNodeAndTabMap.put("tab:" + needCopyNodeRoot.getPKeyId(), addChildNodesTables);
|
|
|
|
|
|
//结果集
|
|
|
- List<WbsTreeContract> addNodeList = new ArrayList<>();//节点
|
|
|
- List<WbsTreeContract> addTabList = new ArrayList<>(); //表单
|
|
|
- List<WbsTreeContract> asyncWbsTreeNodes = new ArrayList<>(); //redis同步信息
|
|
|
- Set<WbsTreeContract> addChildNodesTablesOldAll = new HashSet<>(addChildNodesTables);//表单附件数据源
|
|
|
+ List<WbsTreeContract> addNodeList = new ArrayList<>();//新增节点
|
|
|
+ List<WbsTreeContract> addTabList = new ArrayList<>(); //新增表单
|
|
|
+ List<WbsTreeContract> asyncWbsTreeNodes = new ArrayList<>(); //redis同步节点
|
|
|
+ Set<WbsTreeContract> addChildNodesTablesOldAll = new HashSet<>(addChildNodesTables);//数据源表附件
|
|
|
+ Set<WbsTreeContract> addNewFileTabs = new HashSet<>(addChildNodesTables);//新增到目标表附件
|
|
|
List<String> resultTablesData = new ArrayList<>();//表单数据
|
|
|
|
|
|
//创建线程池,默认设置4个线程
|
|
@@ -1538,7 +1540,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
//1.2 选择同父级的同级节点,只复制数据
|
|
|
} else if (needCopyNode.getParentId().equals(toCopyNode.getParentId())) {
|
|
|
//构造数据
|
|
|
- this.addCopyTabData(needCopyNode, toCopyNode, finalTabOwner, resultTablesData, addTabList, vo.getIsCopyData());
|
|
|
+ this.addCopyTabData(needCopyNode, toCopyNode, finalTabOwner, resultTablesData, addTabList, vo.getIsCopyData(), addNewFileTabs);
|
|
|
}
|
|
|
|
|
|
//TODO 跨节点复制
|
|
@@ -1580,7 +1582,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
//2.2 如果点击选择的是当前复制节点本身的同等级节点,那么就只复制数据。(如果是跨节点,类型相同的情况下,只复制数据),且var=false,表示没有进行到跨节点新增的逻辑,只是跨节点复制数据
|
|
|
if (needCopyNode.getNodeType().equals(toCopyNode.getNodeType()) && !needCopyNode.getParentId().equals(toCopyNode.getParentId()) && !var) {
|
|
|
//构造数据
|
|
|
- this.addCopyTabData(needCopyNode, toCopyNode, finalTabOwner, resultTablesData, addTabList, vo.getIsCopyData());
|
|
|
+ this.addCopyTabData(needCopyNode, toCopyNode, finalTabOwner, resultTablesData, addTabList, vo.getIsCopyData(), addNewFileTabs);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1611,17 +1613,23 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
//复制新增节点
|
|
|
row = wbsTreeContractClient.saveBatch(nodes);
|
|
|
}
|
|
|
+
|
|
|
if (tabs.size() > 0) {
|
|
|
//复制新增表
|
|
|
row = wbsTreeContractClient.saveBatch(tabs);
|
|
|
- if (addChildNodesTablesOldAll.size() > 0 && vo.getIsCopyData() == 1) {
|
|
|
- //复制新增表附件
|
|
|
- this.addCopyTabFile(tabs, addChildNodesTablesOldAll);
|
|
|
- }
|
|
|
}
|
|
|
- if (resultTablesData.size() > 0) {
|
|
|
+
|
|
|
+ if (addNewFileTabs.size() > 0 && addChildNodesTablesOldAll.size() > 0 && vo.getIsCopyData() == 1) {
|
|
|
+ //复制新增表附件
|
|
|
+ this.addCopyTabFile(tabs, addChildNodesTablesOldAll);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (resultTablesData.size() > 0 && vo.getIsCopyData() == 1) {
|
|
|
//复制新增表数据
|
|
|
- jdbcTemplate.execute(StringUtils.join(resultTablesData, ""));
|
|
|
+ List<List<String>> partition = Lists.partition(resultTablesData, 20);
|
|
|
+ for (List<String> strings : partition) {
|
|
|
+ jdbcTemplate.execute(StringUtils.join(strings, ""));
|
|
|
+ }
|
|
|
}
|
|
|
if (row && asyncWbsTreeNodes.size() > 0) {
|
|
|
//更新redis缓存
|
|
@@ -1691,7 +1699,6 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
file.setId(SnowFlakeUtil.getId());
|
|
|
});
|
|
|
resultFileData.addAll(tab);
|
|
|
- //修改文件状态
|
|
|
if (ObjectUtil.isNotEmpty(tabOld) && tabOld.getTabFileType() == 2) {
|
|
|
updatePKeyIds.add(tabNew.getPKeyId());
|
|
|
}
|
|
@@ -1703,7 +1710,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
//入库
|
|
|
tableFileClient.saveBatch(resultFileData);
|
|
|
if (updatePKeyIds.size() > 0) {
|
|
|
- //修改文件状态
|
|
|
+ //修改表的文件按钮状态
|
|
|
wbsTreeContractClient.updateTabFileTypeByPkeyIds(updatePKeyIds);
|
|
|
}
|
|
|
}
|
|
@@ -1713,28 +1720,25 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
/**
|
|
|
* 新增复制的数据
|
|
|
*/
|
|
|
- private void addCopyTabData(WbsTreeContract needCopyNode, WbsTreeContract toCopyNode, String tabOwner, List<String> resultTablesData, List<WbsTreeContract> addChildNodesTablesAll, Integer isCopyData) {
|
|
|
+ private void addCopyTabData(WbsTreeContract needCopyNode, WbsTreeContract toCopyNode, String tabOwner, List<String> resultTablesData, List<WbsTreeContract> addChildNodesTablesAll, Integer isCopyData, Set<WbsTreeContract> addNewFileTabs) {
|
|
|
List<WbsTreeContract> wbsTreeContractsNeed = Collections.singletonList(needCopyNode);
|
|
|
List<WbsTreeContract> wbsTreeContractsTo = Collections.singletonList(toCopyNode);
|
|
|
List<WbsTreeContract> needCopyNodeTabs = this.getChildNodesTables(wbsTreeContractsNeed, needCopyNode.getContractId());
|
|
|
List<WbsTreeContract> toCopyNodeTabs = this.getChildNodesTables(wbsTreeContractsTo, needCopyNode.getContractId());
|
|
|
+ Map<String, WbsTreeContract> toCopyNodeTabsMaps = toCopyNodeTabs.stream().collect(Collectors.toMap(obj -> obj.getNodeName() + "-" + obj.getHtmlUrl(), Function.identity()));
|
|
|
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;
|
|
|
- }
|
|
|
+ if (ObjectUtil.isNotEmpty(needTab.getHtmlUrl())) {
|
|
|
+ String pKey = needTab.getNodeName() + "-" + needTab.getHtmlUrl();
|
|
|
+ //获取目标表对象
|
|
|
+ WbsTreeContract toCopyNodeTab = toCopyNodeTabsMaps.get(pKey);
|
|
|
+ //如果存在,只复制数据
|
|
|
+ if (toCopyNodeTab != null) {
|
|
|
Long oldPKeyId = needTab.getPKeyId();
|
|
|
-
|
|
|
//表单所属方,只有勾选了对应的所属方权限才复制数据;勾选了复制数据才能复制,否则只是创建节点、表
|
|
|
if (tabOwner.contains(needTab.getTableOwner()) && isCopyData == 1) {
|
|
|
-
|
|
|
//目标表obj对象,文件附件使用
|
|
|
- addChildNodesTablesAll.add(toCopyNodeTab);
|
|
|
-
|
|
|
+ addNewFileTabs.add(toCopyNodeTab);
|
|
|
//获取实体表列对象
|
|
|
List<QueryProcessDataVO> nodeTabColOneTab = informationQueryService.getNodeChildTabColsAllByTabName(needTab.getInitTableName());
|
|
|
//转化为map
|
|
@@ -1753,6 +1757,52 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
resultTablesData.add(copyDataSql.toString());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ } else if (ObjectUtil.isNotEmpty(needTab.getIsCopeTab()) && (new Integer(2).equals(needTab.getIsCopeTab()) || new Integer(3).equals(needTab.getIsCopeTab()))) {
|
|
|
+ //如果不存在,则获新增复制的表,toCopyNodeTab == null && getIsCopeTab != null && =2为复制表、=3为频率表
|
|
|
+ WbsTreeContract objTab = BeanUtil.copyProperties(needTab, WbsTreeContract.class);
|
|
|
+ if (objTab != null) {
|
|
|
+ Long oldPKeyId = needTab.getPKeyId();
|
|
|
+ Long tabId = SnowFlakeUtil.getId();
|
|
|
+ objTab.setId(tabId);
|
|
|
+ objTab.setParentId(toCopyNode.getId());
|
|
|
+ objTab.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ //初始化是否显示表格,默认显示
|
|
|
+ objTab.setIsBussShow(1);
|
|
|
+ //初始化表格是否上传附件,默认未上传
|
|
|
+ objTab.setTabFileType(1);
|
|
|
+ //初始化单表是否可以预览,默认不能
|
|
|
+ objTab.setIsTabPdf(1);
|
|
|
+ //初始化PDF路径
|
|
|
+ objTab.setPdfUrl(null);
|
|
|
+ objTab.setCreateTime(new Date());
|
|
|
+ //获取当前复制的表的sort
|
|
|
+ objTab.setSort(ObjectUtils.isNotEmpty(needTab.getSort()) ? needTab.getSort() : 0);
|
|
|
+
|
|
|
+ //复制表
|
|
|
+ addChildNodesTablesAll.add(objTab);
|
|
|
+
|
|
|
+ //表单所属方,只有勾选了对应的所属方权限才复制数据;勾选了复制数据才能复制,否则只是创建节点、表
|
|
|
+ if (tabOwner.contains(objTab.getTableOwner()) && isCopyData == 1) {
|
|
|
+ //获取实体表列对象
|
|
|
+ List<QueryProcessDataVO> nodeTabColOneTab = informationQueryService.getNodeChildTabColsAllByTabName(objTab.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 = objTab.getInitTableName();
|
|
|
+ String col = nodeTabColsMap.get(tableName);
|
|
|
+ String colVal = nodeTabColsMap.get(tableName);
|
|
|
+ colVal = colVal.replaceAll("id,p_key_id,", "'" + SnowFlakeUtil.getId() + "' as id,'" + objTab.getPKeyId() + "' as p_key_id,");
|
|
|
+ //delete SQL (先删除旧数据,再新增)
|
|
|
+ String delSql = "delete from " + tableName + " where p_key_id = " + objTab.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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1835,7 +1885,10 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
String col = nodeTabColsMap.get(tableName);
|
|
|
String colVal = nodeTabColsMap.get(tableName);
|
|
|
colVal = colVal.replaceAll("id,p_key_id,", "'" + SnowFlakeUtil.getId() + "' as id,'" + obj.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("' ;");
|
|
|
+ //delete SQL (先删除旧数据,再新增)
|
|
|
+ String delSql = "delete from " + tableName + " where p_key_id = " + obj.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());
|
|
|
}
|
|
|
}
|
|
@@ -1924,7 +1977,10 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
String col = queryProcessDataVO.getAncestors();
|
|
|
String colVal = queryProcessDataVO.getAncestors();
|
|
|
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("' ;");
|
|
|
+ //delete SQL (先删除旧数据,再新增)
|
|
|
+ String delSql = "delete from " + tableName + " where p_key_id = " + needTab.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());
|
|
|
}
|
|
|
}
|
|
@@ -2419,7 +2475,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
private void currentNodeAllParent(StringBuilder nodeName, WbsTreeContract currentNode) {
|
|
|
if (!"0".equals(String.valueOf(currentNode.getParentId()))) {
|
|
|
//如果父节点不是0说明没到顶层
|
|
|
- WbsTreeContract parentNode = this.wbsTreeContractClient.queryCurrentNodeAllParent(Long.parseLong(currentNode.getContractId()), currentNode.getParentId());
|
|
|
+ WbsTreeContract parentNode = jdbcTemplate.query("select full_name,node_name from m_wbs_tree_contract where is_deleted = 0 and contract_id = " + currentNode.getContractId() + " and id = " + currentNode.getParentId(), new BeanPropertyRowMapper<>(WbsTreeContract.class)).stream().findAny().orElse(null);
|
|
|
if (parentNode != null) {
|
|
|
nodeName.append("-").append(StringUtils.isNotEmpty(parentNode.getFullName()) ? parentNode.getFullName() : parentNode.getNodeName());
|
|
|
this.currentNodeAllParent(nodeName, parentNode);
|
|
@@ -2445,7 +2501,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
this.currentNodeAllParent(parentNodeName, removeNode);
|
|
|
|
|
|
//查询所有子节点
|
|
|
- List<WbsTreeContract> removeNodeList = this.wbsTreeContractClient.queryCurrentNodeAllChild(Long.parseLong(removeNode.getContractId()), removeNode.getId());
|
|
|
+ List<WbsTreeContract> removeNodeList = jdbcTemplate.query("select p_key_id,type from m_wbs_tree_contract where is_deleted = 0 and contract_id = " + removeNode.getContractId() + " and ancestors like '%" + removeNode.getId() + "%'", new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
//获取pKeyId
|
|
|
List<Long> removeList = removeNodeList.stream().map(WbsTreeContract::getPKeyId).distinct().collect(Collectors.toList());
|
|
|
//拼接
|
|
@@ -2453,7 +2509,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
//删除掉表格
|
|
|
removeNodeList.removeIf(tree -> tree.getType() != null && new Integer("2").equals(tree.getType()));
|
|
|
//获取被删除节点名称
|
|
|
- String nodeName = StringUtils.isNotEmpty(removeNode.getFullName()) ? removeNode.getFullName() : removeNode.getNodeName() + "," + removeNodeList.stream().map(wbs -> StringUtils.isNotEmpty(wbs.getFullName()) ? wbs.getFullName() : wbs.getNodeName()).collect(Collectors.joining());
|
|
|
+ //String nodeName = StringUtils.isNotEmpty(removeNode.getFullName()) ? removeNode.getFullName() : removeNode.getNodeName() + "," + removeNodeList.stream().map(wbs -> StringUtils.isNotEmpty(wbs.getFullName()) ? wbs.getFullName() : wbs.getNodeName()).collect(Collectors.joining());
|
|
|
|
|
|
//获取当前节点下所有填报节点
|
|
|
List<QueryProcessDataVO> queryProcess = new ArrayList<>();
|
|
@@ -2468,7 +2524,6 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
if (queryProcess != null && queryProcess.size() > 0) {
|
|
|
//检查这些填报节点是否存在已经审批或已经上报的节点,如果存在则不允许删除
|
|
|
List<QueryProcessDataVO> approvalList = queryProcess.stream().filter(vo -> new Integer("2").equals(vo.getStatus()) && vo.getInformationQueryId() != null).collect(Collectors.toList());
|
|
|
- //
|
|
|
List<QueryProcessDataVO> runTaskList = queryProcess.stream().filter(vo -> new Integer("1").equals(vo.getStatus()) && vo.getInformationQueryId() != null).collect(Collectors.toList());
|
|
|
if (approvalList.size() > 0 || runTaskList.size() > 0) {
|
|
|
//说明存在已经审批或已经上报的节点,不允许删除
|
|
@@ -2495,7 +2550,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
//保存进回收站
|
|
|
this.recycleBinClient.saveDelBusinessData(idArray, StringUtils.isNotEmpty(removeNode.getFullName()) ? removeNode.getFullName() : removeNode.getNodeName(), 2, parentNodeName.toString(), removeNode.getProjectId(), removeNode.getContractId());
|
|
|
Boolean aBoolean = this.wbsTreeContractClient.removeContractTreeNode(idArray);
|
|
|
- // 更新redis
|
|
|
+ //更新redis
|
|
|
this.informationQueryService.AsyncWbsTree(removeNode.getParentId() + "", removeNode.getParentId() + "", removeNode.getContractId(), "", "1");
|
|
|
return R.data(aBoolean);
|
|
|
}
|