|
@@ -34,7 +34,6 @@ import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
-import org.springblade.core.secure.utils.SecureUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.node.ForestNodeMerger;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
@@ -42,10 +41,7 @@ import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
import org.springblade.evisa.feign.EVisaClient;
|
|
|
import org.springblade.evisa.vo.CertBeanVO;
|
|
|
import org.springblade.manager.entity.*;
|
|
|
-import org.springblade.manager.feign.ContractClient;
|
|
|
-import org.springblade.manager.feign.ProjectClient;
|
|
|
-import org.springblade.manager.feign.WbsTreeContractClient;
|
|
|
-import org.springblade.manager.feign.WbsTreePrivateClient;
|
|
|
+import org.springblade.manager.feign.*;
|
|
|
import org.springblade.manager.vo.WbsTreeContractTreeVOS;
|
|
|
import org.springblade.resource.feign.NewIOSSClient;
|
|
|
import org.springblade.system.cache.ParamCache;
|
|
@@ -61,7 +57,6 @@ import org.springblade.core.boot.ctrl.BladeController;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -110,6 +105,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
|
|
|
private final WebSocket webSocket;
|
|
|
|
|
|
+ private final TableFileClient tableFileClient;
|
|
|
+
|
|
|
/**
|
|
|
* 获取文件题名
|
|
|
*/
|
|
@@ -352,7 +349,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
@ApiOperationSupport(order = 25)
|
|
|
@ApiOperation(value = "复制节点填报数据")
|
|
|
public R<Boolean> copyContractNodeSubmitBusinessData(@RequestBody CopyContractTreeNodeVO copyVO) {
|
|
|
- if (StringUtils.isNotEmpty(copyVO.getClassify())) {
|
|
|
+ if (StringUtils.isEmpty(copyVO.getClassify())) {
|
|
|
throw new ServiceException("请选择至少一个所属方");
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(copyVO.getNeedCopyPrimaryKeyId()) && copyVO.getCopyBatchToPaths().size() > 0) {
|
|
@@ -369,11 +366,15 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //获取被复制节点下的表格,根据所属方
|
|
|
- String sqlContractNode = "select * from m_wbs_tree_contract where parent_id = " + wbsTreeContract.getId() + " and contract_id = " + wbsTreeContract.getContractId() + " and table_owner in(" + tabOwner + ") and is_deleted = 0";
|
|
|
+ //获取被复制节点下的表格(源表格),根据所属方
|
|
|
+ String sqlContractNode = "select * from m_wbs_tree_contract where parent_id = " + wbsTreeContract.getId() + " and contract_id = " + wbsTreeContract.getContractId() + " and table_owner in(" + tabOwner + ") and is_deleted = 0 and type = 2";
|
|
|
List<WbsTreeContract> tableList = jdbcTemplate.query(sqlContractNode, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
+
|
|
|
+ //新增的表信息
|
|
|
+ List<WbsTreeContract> copyTableInfos = new ArrayList<>();
|
|
|
+
|
|
|
if (tableList.size() > 0) {
|
|
|
- //获取表格的业务数据
|
|
|
+ //获取源数据
|
|
|
Map<String, List<List<Map<String, Object>>>> tableBusinessDataMap = new HashMap<>();
|
|
|
for (WbsTreeContract treeContract : tableList) {
|
|
|
List<Map<String, Object>> tableBusinessData = this.jdbcTemplate.queryForList("select * from " + treeContract.getInitTableName() + " where p_key_id = " + treeContract.getPKeyId());
|
|
@@ -396,45 +397,36 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
List<String> removeSqlList = new ArrayList<>();
|
|
|
//新增数据SQL
|
|
|
List<String> saveSqlList = new ArrayList<>();
|
|
|
+
|
|
|
for (CopyContractTreeNodeVO.CopyBatch copyBatch : batchPathList) {
|
|
|
//获取选择的节点信息
|
|
|
WbsTreeContract selectNode = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(copyBatch.getPrimaryKeyId());
|
|
|
|
|
|
- //获取合同段信息
|
|
|
- ContractInfo contract = this.contractClient.getContractById(Long.parseLong(selectNode.getContractId()));
|
|
|
-
|
|
|
//实际获取的数据
|
|
|
Map<String, List<List<Map<String, Object>>>> currentDataMap = new HashMap<>();
|
|
|
- if (new Integer("1").equals(contract.getIsCopyData())) {
|
|
|
- //说明开启数据复制限制,根据合同段类型判断哪些数据是能够被复制的
|
|
|
- String removeString = new Integer("1").equals(contract.getContractType()) ? "1,2,3" : "5,6,7";
|
|
|
- //找符合条件的表格
|
|
|
- List<WbsTreeContract> tables = tableList.stream().filter(tree -> Arrays.asList(removeString.split(",")).contains(tree.getTableOwner())).distinct().collect(Collectors.toList());
|
|
|
- if (tables.size() <= 0) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- for (WbsTreeContract node : tables) {
|
|
|
- if (tableBusinessDataMap.containsKey(node.getId().toString()) && !currentDataMap.containsKey(node.getId().toString())) {
|
|
|
- currentDataMap.put(node.getId().toString(), tableBusinessDataMap.get(node.getId().toString()));
|
|
|
- }
|
|
|
+
|
|
|
+ //根据源表,解析对应的的表
|
|
|
+ for (WbsTreeContract node : tableList) {
|
|
|
+ if (tableBusinessDataMap.containsKey(node.getId().toString()) && !currentDataMap.containsKey(node.getId().toString())) {
|
|
|
+ currentDataMap.put(node.getId().toString(), tableBusinessDataMap.get(node.getId().toString()));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//获取表格信息
|
|
|
List<WbsTreeContract> copyToTableList = this.wbsTreeContractClient.queryChildByParentId(selectNode, "queryTable", "");
|
|
|
- if (copyToTableList != null && copyToTableList.size() > 0) {
|
|
|
- //首先,记录数据删除sql
|
|
|
- for (WbsTreeContract table : copyToTableList) {
|
|
|
- if (StringUtils.isNotEmpty(table.getInitTableName())) {
|
|
|
- removeSqlList.add("delete from " + table.getInitTableName() + " where p_key_id = " + table.getPKeyId());
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- //其次,检测是否表格是否存在差异(如果存在oldId则优先使用这个字段,不存在时才使用id)
|
|
|
+ if (copyToTableList != null && copyToTableList.size() > 0) {
|
|
|
+ //检测是否表格是否存在差异(如果存在oldId则优先使用这个字段,不存在时才使用id)
|
|
|
List<WbsTreeContract> remainTableList = copyToTableList.stream().filter(toTable -> currentDataMap.containsKey(StringUtils.isNotEmpty(toTable.getOldId()) ? toTable.getOldId() : toTable.getId().toString())).collect(Collectors.toList());
|
|
|
+
|
|
|
//循环有数据的表格
|
|
|
for (WbsTreeContract remainTable : remainTableList) {
|
|
|
if (StringUtils.isNotEmpty(remainTable.getInitTableName())) {
|
|
|
+ //附件信息ids
|
|
|
+ copyTableInfos.add(remainTable);
|
|
|
+ //数据删除sql,做覆盖操作
|
|
|
+ removeSqlList.add("delete from " + remainTable.getInitTableName() + " where p_key_id = " + remainTable.getPKeyId());
|
|
|
+
|
|
|
//获取主键
|
|
|
String id = StringUtils.isNotEmpty(remainTable.getOldId()) ? remainTable.getOldId() : remainTable.getId().toString();
|
|
|
if (currentDataMap.containsKey(id)) {
|
|
@@ -462,9 +454,9 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
}
|
|
|
//生成最终sql
|
|
|
saveSqlList.add(sql.append(")").append(valueSql).append(")").toString());
|
|
|
- iterator.remove();
|
|
|
break;
|
|
|
}
|
|
|
+
|
|
|
if (dataMapList.size() <= 0) {
|
|
|
oneLevelIterator.remove();
|
|
|
}
|
|
@@ -475,7 +467,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //删除原本填写的数据
|
|
|
+ //删除原本填写的数据,覆盖
|
|
|
if (removeSqlList.size() > 0) {
|
|
|
for (String sql : removeSqlList) {
|
|
|
this.jdbcTemplate.execute(sql);
|
|
@@ -488,8 +480,39 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
this.jdbcTemplate.execute(sql);
|
|
|
}
|
|
|
}
|
|
|
- return R.data(true);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //复制附件信息
|
|
|
+ for (WbsTreeContract sourceDataObj : tableList) {
|
|
|
+ if (sourceDataObj.getTabFileType() == 2) {
|
|
|
+ //获取源表中的附件信息
|
|
|
+ String sql = "select * from m_table_file where is_deleted = 0 and type = 2 and tab_id =" + sourceDataObj.getPKeyId();
|
|
|
+ List<TableFile> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TableFile.class));
|
|
|
+ if (query.size() > 0) {
|
|
|
+ Iterator<WbsTreeContract> iterator = copyTableInfos.iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ WbsTreeContract next = iterator.next();
|
|
|
+ if (sourceDataObj.getNodeName().equals(next.getNodeName())) { //如果原表的nodeName=复制节点表的nodeName,那么获取原表附件信息
|
|
|
+ //删除复制节点下对应表的附件信息,覆盖
|
|
|
+ String del = "delete from m_table_file where tab_id = '" + next.getPKeyId() + "'";
|
|
|
+ jdbcTemplate.execute(del);
|
|
|
+
|
|
|
+ //新增源数据附件到复制节点下对应表中
|
|
|
+ tableFileClient.saveBatchFile(query, next.getPKeyId());
|
|
|
+
|
|
|
+ //修改复制节点下对应表的按钮状态
|
|
|
+ String updateStatus = "update m_wbs_tree_contract set tab_file_type = " + sourceDataObj.getTabFileType() + " ,is_tab_pdf = " + sourceDataObj.getIsTabPdf() + " ,pdf_url = '" + sourceDataObj.getPdfUrl() + "' ,is_buss_show = " + sourceDataObj.getIsBussShow() + " where p_key_id = " + next.getPKeyId();
|
|
|
+ jdbcTemplate.execute(updateStatus);
|
|
|
+
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ return R.data(true);
|
|
|
}
|
|
|
|
|
|
return R.data(300, false, "被复制节点未找到业务数据");
|
|
@@ -1095,7 +1118,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
newData.setPKeyId(SnowFlakeUtil.getId());
|
|
|
//设置旧ID
|
|
|
if (StringUtils.isNotEmpty(node.getOldId())) {
|
|
|
- newData.setOldId(node.getOldId().toString());
|
|
|
+ newData.setOldId(node.getOldId());
|
|
|
} else {
|
|
|
newData.setOldId(node.getId().toString());
|
|
|
}
|
|
@@ -1126,6 +1149,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
//初始化PDF路径
|
|
|
newData.setPdfUrl(null);
|
|
|
newData.setCreateUser(AuthUtil.getUserId());
|
|
|
+ //划分编号
|
|
|
+ newData.setPartitionCode(StringUtils.isNotEmpty(node.getPartitionCode()) ? node.getPartitionCode() : 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() + "')";
|
|
@@ -1199,6 +1224,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
newData.setIsTabPdf(1);
|
|
|
//初始化PDF路径
|
|
|
newData.setPdfUrl(null);
|
|
|
+ //划分编号
|
|
|
+ newData.setPartitionCode(StringUtils.isNotEmpty(copyBatch.getPartitionCode()) ? copyBatch.getPartitionCode() : 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() + "')";
|