Sfoglia il codice sorgente

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

lvy 1 mese fa
parent
commit
3a6f70a16a

+ 21 - 29
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java

@@ -510,7 +510,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]));
@@ -547,18 +547,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 Exception {
+    public R<List<ExceTabTreVO>> saveLinkeTab(Long exceTabId, Long tabId, Boolean updateAll) throws Exception {
         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);
@@ -688,7 +689,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);
 
         //关联项目下所有的合同段
@@ -698,7 +710,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("关联成功");
     }
@@ -2121,31 +2136,8 @@ public class ExcelTabController extends BladeController {
                     }
                     // 组装电签设置
                     Elements dqids = table.getElementsByAttribute("dqid");
-                    // 电签组装2
-                    String dqSql = "select e_key,GROUP_CONCAT(DISTINCT concat('*✹',id)) ids from u_sign_key_role_info where tab_en_name='" + tableNode.getInitTableName() + "' GROUP BY e_key";
-                    List<Map<String, Object>> mapList = jdbcTemplate.queryForList(dqSql);
-                    if(mapList!=null && mapList.size()>0){
-                        for(Map<String, Object> map : mapList) {
-                            Elements elementsBy = table.getElementsByAttributeValueStarting("keyname", map.get("e_key") + "_");
-                            if(elementsBy!=null && elementsBy.size()>0){
-                                for(Element element : elementsBy){
-                                    String dqIds = (String) map.get("ids");
-                                    dqIds = dqIds.replace(",","");
-                                    dqIds = dqIds.substring(1);
-                                    element.attr("sign_type", dqIds);
-                                    dqids.add(element);
-                                }
-                            }
-
-                        }
-                    }
                     for (Element element : dqids) {
-                        String dqid="";
-                        if(element.hasAttr("sign_type")){
-                            dqid = element.attr("sign_type");
-                        }else{
-                            dqid = element.attr("dqid");
-                        }
+                        String dqid = element.attr("dqid");
                         Elements x11 = element.getElementsByAttribute("x1");
                         if (x11 != null && x11.size() >= 1) {
                             Element element1 = x11.get(x11.size() - 1);

+ 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 Exception {
-        excelTabController.saveLinkeTab(excelId,pKeyId);
+        excelTabController.saveLinkeTab(excelId,pKeyId, false);
     }
 
     @Override