|
@@ -44,6 +44,7 @@ import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
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.utils.Func;
|
|
|
import org.springblade.evisa.feign.EVisaClient;
|
|
|
import org.springblade.evisa.vo.CertBeanVO;
|
|
@@ -57,6 +58,7 @@ import org.springblade.manager.vo.WbsTreeContractTreeVOS;
|
|
|
import org.springblade.system.entity.DictBiz;
|
|
|
import org.springblade.system.feign.IDictBizClient;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springblade.business.service.IInformationQueryService;
|
|
@@ -101,6 +103,103 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
|
|
|
private final EVisaClient eVisaClient;
|
|
|
|
|
|
+ private final JdbcTemplate jdbcTemplate;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 复制节点填报数据
|
|
|
+ */
|
|
|
+ @PostMapping("/copyContractNodeSubmitBusinessData")
|
|
|
+ @ApiOperationSupport(order = 25)
|
|
|
+ @ApiOperation(value = "复制节点填报数据")
|
|
|
+ public R<Boolean> copyContractNodeSubmitBusinessData(@RequestBody CopyContractTreeNodeVO copyVO){
|
|
|
+ if(StringUtils.isNotEmpty(copyVO.getNeedCopyPrimaryKeyId()) && copyVO.getCopyBatchToPaths().size() > 0){
|
|
|
+ //获取被复制节点的表格
|
|
|
+ List<WbsTreeContract> tableList = this.wbsTreeContractClient.queryChildByParentId(this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(copyVO.getNeedCopyPrimaryKeyId()), "queryTable");
|
|
|
+ if(tableList != null && 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());
|
|
|
+ if(tableBusinessData.size() > 0){
|
|
|
+ //设置参数
|
|
|
+ List<List<Map<String, Object>>> list;
|
|
|
+ if(tableBusinessDataMap.containsKey(treeContract.getId().toString())){
|
|
|
+ list = tableBusinessDataMap.get(treeContract.getId().toString());
|
|
|
+ } else {
|
|
|
+ list = new ArrayList<>();
|
|
|
+ }
|
|
|
+ list.add(tableBusinessData);
|
|
|
+ tableBusinessDataMap.put(treeContract.getId().toString(), list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取数据写入的节点信息
|
|
|
+ List<CopyContractTreeNodeVO.CopyBatch> batchPathList = copyVO.getCopyBatchToPaths();
|
|
|
+ //新增数据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)
|
|
|
+ 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){
|
|
|
+ if(StringUtils.isNotEmpty(remainTable.getInitTableName())){
|
|
|
+ //获取主键
|
|
|
+ String id = StringUtils.isNotEmpty(remainTable.getOldId()) ? remainTable.getOldId() : remainTable.getId().toString();
|
|
|
+ if(tableBusinessDataMap.containsKey(id)){
|
|
|
+ //获取对应表格的数据
|
|
|
+ Iterator<List<Map<String, Object>>> oneLevelIterator = tableBusinessDataMap.get(id).iterator();
|
|
|
+ while (oneLevelIterator.hasNext()){
|
|
|
+ List<Map<String, Object>> dataMapList = oneLevelIterator.next();
|
|
|
+ Iterator<Map<String, Object>> iterator = dataMapList.iterator();
|
|
|
+
|
|
|
+ while (iterator.hasNext()){
|
|
|
+ Map<String, Object> map = iterator.next();
|
|
|
+ map.remove("id");
|
|
|
+ map.remove("p_key_id");
|
|
|
+ //拼接sql
|
|
|
+ StringBuilder sql = new StringBuilder("insert into " + remainTable.getInitTableName() + " (id, p_key_id");
|
|
|
+ StringBuilder valueSql = new StringBuilder(" values (" + SnowFlakeUtil.getId() + "," + remainTable.getPKeyId());
|
|
|
+ //循环需要复制的数据
|
|
|
+ for(Map.Entry<String, Object> mapEntry : map.entrySet()){
|
|
|
+ sql.append(",").append(mapEntry.getKey());
|
|
|
+ if(mapEntry.getValue() == null){
|
|
|
+ valueSql.append(",").append(mapEntry.getValue());
|
|
|
+ } else {
|
|
|
+ valueSql.append(",'").append(mapEntry.getValue()).append("'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //生成最终sql
|
|
|
+ saveSqlList.add(sql.append(")").append(valueSql).append(")").toString());
|
|
|
+ iterator.remove();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if(dataMapList.size() <= 0){
|
|
|
+ oneLevelIterator.remove();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //保存数据
|
|
|
+ JsonUtil.toJson(saveSqlList);
|
|
|
+ if(saveSqlList.size() > 0){
|
|
|
+ for(String sql : saveSqlList){
|
|
|
+ this.jdbcTemplate.execute(sql);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.data(300, false, "被复制节点未找到业务数据");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 单个废除
|
|
|
*/
|
|
@@ -156,6 +255,18 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
+ } else {
|
|
|
+ //查询表格
|
|
|
+ List<WbsTreeContract> tableList = this.wbsTreeContractClient.queryChildByParentId(this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(primaryKeyId), "queryTable");
|
|
|
+ if(tableList != null && tableList.size() > 0){
|
|
|
+ for(WbsTreeContract table : tableList){
|
|
|
+ if(new Integer("2").equals(table.getIsTabPdf())){
|
|
|
+ //这些表格中,但凡有一个能够预览,就开放预览
|
|
|
+ status = "2";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return R.data(status);
|
|
@@ -385,7 +496,10 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
//设置旧ID
|
|
|
newData.setOldId(node.getId().toString());
|
|
|
//设置新ID
|
|
|
- newData.setId(oldToNewIdMap.containsKey(node.getId()) ? oldToNewIdMap.get(node.getId()) : SnowFlakeUtil.getId());
|
|
|
+ if(new Integer("1").equals(node.getType())){
|
|
|
+ //如果是节点类型才重塑ID
|
|
|
+ newData.setId(oldToNewIdMap.containsKey(node.getId()) ? oldToNewIdMap.get(node.getId()) : SnowFlakeUtil.getId());
|
|
|
+ }
|
|
|
//设置父节点ID
|
|
|
if(vo.getNeedCopyPrimaryKeyId().equals(node.getPKeyId().toString())){
|
|
|
//找到复制的节点,将parentId更改为 parent.getId()
|
|
@@ -432,7 +546,9 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
//重塑primaryKeyId
|
|
|
newData.setPKeyId(SnowFlakeUtil.getId());
|
|
|
//设置新ID
|
|
|
- newData.setId(oldToNewIdMap.containsKey(node.getId()) ? oldToNewIdMap.get(node.getId()) : SnowFlakeUtil.getId());
|
|
|
+ if(new Integer("1").equals(node.getType())){
|
|
|
+ newData.setId(oldToNewIdMap.containsKey(node.getId()) ? oldToNewIdMap.get(node.getId()) : SnowFlakeUtil.getId());
|
|
|
+ }
|
|
|
//设置父节点ID
|
|
|
if(vo.getNeedCopyPrimaryKeyId().equals(node.getPKeyId().toString())){
|
|
|
//找到复制的节点,将parentId更改为 parent.getId()
|