瀏覽代碼

关联清表接口新增是否关联到同项目下excelId相同的所有节点

lvy 1 月之前
父節點
當前提交
c211d8436e

+ 20 - 5
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java

@@ -499,7 +499,7 @@ public class ExcelTabController extends BladeController {
                     updateWrapper.in("p_key_id", Long.parseLong(pk_type[0]));
 
                     if (pk_type[1].equals("2")) {
-                        this.saveLinkeTab(excelTab.getId(), Long.parseLong(pk_type[0]));
+                        this.saveLinkeTab(excelTab.getId(), Long.parseLong(pk_type[0]), false);
                     }
 
                     updateWrapper.set("is_link_table", Integer.parseInt(pk_type[1]));
@@ -536,18 +536,19 @@ public class ExcelTabController extends BladeController {
             @ApiImplicitParam(name = "exceTabId", value = "清表id", required = true),
             @ApiImplicitParam(name = "tabId", value = "表Id", required = true),
     })
-    public R<List<ExceTabTreVO>> saveLinkeTab(Long exceTabId, Long tabId) throws IOException {
+    public R<List<ExceTabTreVO>> saveLinkeTab(Long exceTabId, Long tabId, Boolean updateAll) throws IOException {
         String file_path = FileUtils.getSysLocalFileUrl();
         // 关联 私有项目 wbs 数据信息
         WbsTreePrivate wbsTree = new WbsTreePrivate();
         wbsTree.setPKeyId(tabId);
         WbsTreePrivate aPrivate = wbsTreePrivateService.getOne(Condition.getQueryWrapper(wbsTree));
+        Long excelId = aPrivate.getExcelId();
         aPrivate.setExcelId(exceTabId);
         // 获取excel 基本信息
         ExcelTab excelTab = excelTabService.getById(exceTabId);
 
         UpdateWrapper<WbsTreePrivate> updateWrapper = new UpdateWrapper<>();
-        updateWrapper.in("p_key_id", tabId);
+//        updateWrapper.in("p_key_id", tabId);
         updateWrapper.set("is_link_table", 2);
         updateWrapper.set("node_name", excelTab.getName()); //关联清表后 表单名和清表一样
         updateWrapper.set("excel_id", exceTabId);
@@ -673,7 +674,18 @@ public class ExcelTabController extends BladeController {
             pupdate.set("excel_id", aPrivate.getPKeyId());
             wbsTreePrivateService.update(pupdate);
         }
-
+        List<Long> pKeyIds = null;
+        if (updateAll != null && updateAll && excelId != null) {
+            List<WbsTreePrivate> privateList = wbsTreePrivateService.list(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getExcelId, excelId).eq(WbsTreePrivate::getProjectId, aPrivate.getProjectId()));
+            if (privateList != null && !privateList.isEmpty()) {
+                pKeyIds = privateList.stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
+            }
+        }
+        if (pKeyIds == null) {
+            pKeyIds = new ArrayList<>();
+        }
+        pKeyIds.add(tabId);
+        updateWrapper.in("p_key_id", pKeyIds);
         wbsTreePrivateService.update(updateWrapper);
 
         //关联项目下所有的合同段
@@ -683,7 +695,10 @@ public class ExcelTabController extends BladeController {
         //关联清表后 表单名和清表一样
         aPrivate.setNodeName(excelTab.getName());
         aPrivate.setFullName(excelTab.getName());
-        wbsTreeContractService.updateAllNodeTabById(aPrivate);
+        pKeyIds.forEach( pKeyId -> {
+            aPrivate.setPKeyId(pKeyId);
+            wbsTreeContractService.updateAllNodeTabById(aPrivate);
+        });
 //        }
         return R.success("关联成功");
     }

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/ExcelTabClientImpl.java

@@ -508,7 +508,7 @@ public class ExcelTabClientImpl implements ExcelTabClient {
 
     @Override
     public void saveLinkTab(Long excelId, Long pKeyId) throws IOException {
-        excelTabController.saveLinkeTab(excelId,pKeyId);
+        excelTabController.saveLinkeTab(excelId,pKeyId, false);
     }
 
     @Override