|
@@ -31,7 +31,6 @@ 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.tool.api.R;
|
|
|
-import org.springblade.core.tool.jackson.JsonUtil;
|
|
|
import org.springblade.core.tool.node.ForestNodeMerger;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.evisa.feign.EVisaClient;
|
|
@@ -230,8 +229,10 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
@ApiOperation(value = "复制节点填报数据")
|
|
|
public R<Boolean> copyContractNodeSubmitBusinessData(@RequestBody CopyContractTreeNodeVO copyVO){
|
|
|
if(StringUtils.isNotEmpty(copyVO.getNeedCopyPrimaryKeyId()) && copyVO.getCopyBatchToPaths().size() > 0){
|
|
|
+ //查询被复制节点
|
|
|
+ WbsTreeContract wbsTreeContract = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(copyVO.getNeedCopyPrimaryKeyId());
|
|
|
//获取被复制节点的表格
|
|
|
- List<WbsTreeContract> tableList = this.wbsTreeContractClient.queryChildByParentId(this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(copyVO.getNeedCopyPrimaryKeyId()), "queryTable", "");
|
|
|
+ List<WbsTreeContract> tableList = this.wbsTreeContractClient.queryChildByParentId(wbsTreeContract, "queryTable", "");
|
|
|
if(tableList != null && tableList.size() > 0){
|
|
|
//获取合同段信息
|
|
|
ContractInfo contract = this.contractClient.getContractById(Long.parseLong(tableList.get(0).getContractId()));
|
|
@@ -240,9 +241,10 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
String removeString = new Integer("1").equals(contract.getContractType()) ? "1,2,3" : "5,6,7";
|
|
|
//删除掉不符合条件的数据
|
|
|
tableList.removeIf(table -> Arrays.asList(removeString.split(",")).contains(table.getTableType().toString()));
|
|
|
- }
|
|
|
- if(tableList.size() <= 0){
|
|
|
- return R.data(300, false, "当前合同段已开启数据隔离,当前节点下未找到符合复制条件的数据");
|
|
|
+
|
|
|
+ if(tableList.size() <= 0){
|
|
|
+ return R.data(300, false, "当前合同段已开启数据隔离,当前节点下未找到符合复制条件的数据");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//获取表格的业务数据
|
|
@@ -264,13 +266,22 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
|
|
|
//获取数据写入的节点信息
|
|
|
List<CopyContractTreeNodeVO.CopyBatch> batchPathList = copyVO.getCopyBatchToPaths();
|
|
|
+ //删除数据SQL
|
|
|
+ List<String> removeSqlList = new ArrayList<>();
|
|
|
//新增数据SQL
|
|
|
List<String> saveSqlList = new ArrayList<>();
|
|
|
for(CopyContractTreeNodeVO.CopyBatch copyBatch : batchPathList){
|
|
|
//获取表格信息
|
|
|
List<WbsTreeContract> copyToTableList = this.wbsTreeContractClient.queryChildByParentId(this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(copyBatch.getPrimaryKeyId()), "queryTable", "");
|
|
|
if(copyToTableList != null && copyToTableList.size() > 0){
|
|
|
- //检测是否表格是否存在差异(如果存在oldId则优先使用这个字段,不存在时才使用id)
|
|
|
+ //首先,记录数据删除sql
|
|
|
+ for(WbsTreeContract table : copyToTableList){
|
|
|
+ if(StringUtils.isNotEmpty(table.getInitTableName())){
|
|
|
+ removeSqlList.add("delete from " + table.getInitTableName() + " where p_key_id = " + table.getPKeyId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //其次,检测是否表格是否存在差异(如果存在oldId则优先使用这个字段,不存在时才使用id)
|
|
|
List<WbsTreeContract> remainTableList = copyToTableList.stream().filter(toTable -> tableBusinessDataMap.containsKey(StringUtils.isNotEmpty(toTable.getOldId()) ? toTable.getOldId() : toTable.getId().toString())).collect(Collectors.toList());
|
|
|
//循环有数据的表格
|
|
|
for(WbsTreeContract remainTable : remainTableList){
|
|
@@ -315,8 +326,14 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //保存数据
|
|
|
- JsonUtil.toJson(saveSqlList);
|
|
|
+ //删除原本填写的数据
|
|
|
+ if(removeSqlList.size() > 0){
|
|
|
+ for(String sql : removeSqlList){
|
|
|
+ this.jdbcTemplate.execute(sql);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //保存新获取的数据
|
|
|
if(saveSqlList.size() > 0){
|
|
|
for(String sql : saveSqlList){
|
|
|
this.jdbcTemplate.execute(sql);
|
|
@@ -1163,7 +1180,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
newData.setOldId(half.getId().toString());
|
|
|
//设置合同段等信息
|
|
|
newData.setWbsType(treeContract.getWbsType());
|
|
|
- newData.setContractId(vo.getContractId());
|
|
|
+ newData.setContractId(treeContract.getContractId());
|
|
|
newData.setContractIdRelation(treeContract.getContractIdRelation());
|
|
|
newData.setContractType(treeContract.getContractType());
|
|
|
newData.setCreateTime(new Date());
|