فهرست منبع

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java
liuyc 2 سال پیش
والد
کامیت
fd5bb9804e

+ 2 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/SignPfxFileController.java

@@ -446,10 +446,10 @@ public class SignPfxFileController extends BladeController {
 			if(StringUtils.isNotEmpty(oldData.getProjectContractRole()) && !vo.getProjectContractRole().trim().equals(oldData.getProjectContractRole().trim())){
 				//如果不匹配,先删除
 				this.signPfxDeputyService.update(Wrappers.<SignPfxDeputy>lambdaUpdate().set(SignPfxDeputy::getIsDeleted, 1).eq(SignPfxDeputy::getSignPfxFileId, vo.getId()));
+				//再重新生成
+				this.saveSignPfxDeputy(vo, false);
 			}
 
-			//再重新生成
-			this.saveSignPfxDeputy(vo, false);
 		}
 		return R.status(this.signPfxFileService.updateById(vo));
 	}

+ 107 - 102
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -329,11 +329,11 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 /*用来保存日志执行情况*/
                 StringBuilder log = new StringBuilder();
                 /*每次都是部分表单提交,保证跨节点跨表取数正常,其次是反向依赖的被动刷新*/
-                List<NodeTable> tableAll = createNodeTables(nodeId, tableInfoList.get(0).getContractId(), tableInfoList.get(0).getProjectId(), type);
+                List<NodeTable> tableAll = createNodeTables(nodeId,tableInfoList.get(0).getContractId(),tableInfoList.get(0).getProjectId(),type);
                 StopWatch stopWatch = new StopWatch();
-                List<KeyMapper> keyMappers = this.formulaService.getKeyMapperList(tableInfoList.stream().map(TableInfo::getPkeyId).filter(Func::isNotEmpty).map(Long::parseLong).collect(Collectors.toList()), tableInfoList.get(0).getProjectId(), String.valueOf(nodeId), type);
+                List<KeyMapper> keyMappers = this.formulaService.getKeyMapperList(tableInfoList.stream().map(TableInfo::getPkeyId).filter(Func::isNotEmpty).map(Long::parseLong).collect(Collectors.toList()), tableInfoList.get(0).getProjectId(), String.valueOf(nodeId),type);
                 if (Func.isNotEmpty(keyMappers)) {
-                    Map<String, Map<String, String>> coordinateMap = createCoordinateMap(keyMappers);
+                    Map<String, Map<String, String>> coordinateMap = createCoordinateMap(keyMappers,type);
                     stopWatch.start("公式处理");
                     List<Formula> formulas = this.formulaService.getFormulaList(keyMappers);
                     WbsTreeContract wtc = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, nodeId));
@@ -354,33 +354,38 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                     StaticLog.info("公式执行用时:{}", totalTime);
                     updateFormulaLog(log, wtc);
                 }
-            } catch (Exception e) {
+            }catch (Exception e){
                 e.printStackTrace();
             }
         }
     }
 
 
-    private List<NodeTable> createNodeTables(Long nodeId, String contractId, String projectId, ExecuteType type) {
-        List<NodeTable> tableAll = new ArrayList<>();
-        if (type.equals(ExecuteType.INSPECTION)) {
+    private  List<NodeTable> createNodeTables(Long nodeId,String contractId,String projectId,ExecuteType type){
+        List<NodeTable> tableAll =new ArrayList<>();
+        if(type.equals(ExecuteType.INSPECTION)){
             List<AppWbsTreeContractVO> treeNode = wbsTreeContractService.searchNodeAllTable(nodeId.toString(), "1", contractId, projectId);
-            tableAll = BeanUtil.copyProperties(treeNode, NodeTable.class);
-        } else if (type.equals(ExecuteType.TESTING)) {
+            tableAll = BeanUtil.copyProperties(treeNode,NodeTable.class);
+        }else if(type.equals(ExecuteType.TESTING)){
             List<WbsTreePrivateVO4> wbsTreePrivateVO4s = wbsTreePrivateService.searchNodeAllTable(nodeId.toString(), "1", "9", contractId, projectId, null, null);
-            tableAll = BeanUtil.copyProperties(wbsTreePrivateVO4s, NodeTable.class);
+             tableAll = BeanUtil.copyProperties(wbsTreePrivateVO4s,NodeTable.class);
         }
         return tableAll;
     }
 
-    private Map<String, Map<String, String>> createCoordinateMap(List<KeyMapper> keyMappers) {
-        Map<String, Map<String, String>> coordinateMap = new HashMap<>(keyMappers.size() * 2);
-        for (KeyMapper keyMapper : keyMappers) {
-            if (!coordinateMap.containsKey(keyMapper.getTableName())) {
-                WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
-                        .eq(WbsTreeContract::getPKeyId, keyMapper.getPkId()));
-                if (wbsTreeContract != null && Func.isNotBlank(wbsTreeContract.getHtmlUrl())) {
-                    coordinateMap.put(keyMapper.getTableName(), FormulaUtils.getElementCell(wbsTreeContract.getHtmlUrl()));
+    private Map<String, Map<String, String>> createCoordinateMap(List<KeyMapper> keyMappers,ExecuteType type) {
+        List<Long> pkeyIds = keyMappers.stream().map(KeyMapper::getPkId).distinct().collect(Collectors.toList());
+        Map<String, Map<String, String>> coordinateMap = new HashMap<>(pkeyIds.size() * 2);
+        if(pkeyIds.size()>0){
+            if(ExecuteType.TESTING.equals(type)){
+               List<WbsTreePrivate> list = wbsTreePrivateService.getBaseMapper().selectList(Wrappers.<WbsTreePrivate>query().lambda().in(WbsTreePrivate::getPKeyId,pkeyIds));
+               if(list.size()>0){
+                   list.forEach(e-> coordinateMap.computeIfAbsent(e.getInitTableName(), k -> FormulaUtils.getElementCell(e.getHtmlUrl())));
+               }
+            }else{
+                List<WbsTreeContract> list = wbsTreeContractService.getBaseMapper().selectList(Wrappers.<WbsTreeContract>query().lambda().in(WbsTreeContract::getPKeyId,pkeyIds));
+                if(list.size()>0){
+                    list.forEach(e-> coordinateMap.computeIfAbsent(e.getInitTableName(), k -> FormulaUtils.getElementCell(e.getHtmlUrl())));
                 }
             }
         }
@@ -548,7 +553,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 URL url = new URL(downloadUri);
                 String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
                 String filecode = SnowFlakeUtil.getId() + "";
-                String dataUrl = file_path + "/excel/" + filecode + ".pdf";
+                String dataUrl=file_path + "/excel/" + filecode + ".pdf";
                 java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();
                 connection.setRequestMethod("GET");
                 connection.setConnectTimeout(5 * 1000);
@@ -559,8 +564,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 String tabId = callback.getKey();
                 if (tabId == null) {
                     throw new Exception("excel为空");
-                } else {
-                    tabId = tabId.substring(0, tabId.lastIndexOf("_"));
+                }else{
+                    tabId = tabId.substring(0,tabId.lastIndexOf("_"));
                 }
                 //获取数据库信息
                 ExcelTab excelTab = baseMapper.selectById(Long.parseLong(tabId));
@@ -578,7 +583,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 excelTab.setFileUrl(bladeFile.getLink());
                 baseMapper.updateById(excelTab);
                 File file = new File(dataUrl);
-                if (file.exists()) {
+                if(file.exists()){
                     file.delete();
                 }
                 System.out.println("123456");
@@ -716,7 +721,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                         }
 
                         //获取上传的文件相关
-                        String sourceUrl = tableInfoList.get(0).getSourceUrl(),
+                            String sourceUrl = tableInfoList.get(0).getSourceUrl(),
                                 pdfUrl = tableInfoList.get(0).getPdfUrl(),
                                 firstFileName = tableInfoList.get(0).getFirstFileName();
 
@@ -956,7 +961,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             return dataMap;
         }
         File file1 = ResourceUtil.getFile(wbsTreeContract.getHtmlUrl());
-        if (file1.exists()) {
+        if(file1.exists()){
 
 
             FileInputStream fileInputStream = new FileInputStream(file1);
@@ -1014,102 +1019,102 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         // 匹配关联
         try {
             File file1 = ResourceUtil.getFile(wbsTreeContract.getHtmlUrl());
-            if (file1.exists()) {
+            if(file1.exists()){
 
-                String htmlString = IoUtil.readToString(new FileInputStream(file1));
-                Document doc = Jsoup.parse(htmlString);
-
-                // 解析
-                // 模糊匹配
-                Elements dwtitle = doc.select("el-input[placeholder~=.*承包单位]");
-                Elements sgtitle = doc.select("el-input[placeholder~=^施工单位]");
-                Elements sgtitle1 = doc.select("el-input[placeholder=安装单位]");
-                sgtitle.addAll(sgtitle1);
+            String htmlString = IoUtil.readToString(new FileInputStream(file1));
+            Document doc = Jsoup.parse(htmlString);
 
-                Elements htdtitle = doc.select("el-input[placeholder~=.*合同段.*]");
-                Elements htdtitle1 = doc.select("el-input[placeholder~=合同名称.*]");
-                htdtitle.addAll(htdtitle1);
+            // 解析
+            // 模糊匹配
+            Elements dwtitle = doc.select("el-input[placeholder~=.*承包单位]");
+            Elements sgtitle = doc.select("el-input[placeholder~=^施工单位]");
+            Elements sgtitle1 = doc.select("el-input[placeholder=安装单位]");
+            sgtitle.addAll(sgtitle1);
 
-                Elements jltitle = doc.select("el-input[placeholder~=监理单位.*]");
+            Elements htdtitle = doc.select("el-input[placeholder~=.*合同段.*]");
+            Elements htdtitle1 = doc.select("el-input[placeholder~=合同名称.*]");
+            htdtitle.addAll(htdtitle1);
 
-                Elements bhtitle = doc.select("el-input[placeholder~=^编号]");
-                Elements bhtitle1 = doc.select("el-input[placeholder~=合同编号.*]");
-                bhtitle.addAll(bhtitle1);
+            Elements jltitle = doc.select("el-input[placeholder~=监理单位.*]");
 
+            Elements bhtitle = doc.select("el-input[placeholder~=^编号]");
+            Elements bhtitle1 = doc.select("el-input[placeholder~=合同编号.*]");
+            bhtitle.addAll(bhtitle1);
 
-                Elements xmtitle = doc.select("el-input[placeholder~=^项目名称]");
 
+            Elements xmtitle = doc.select("el-input[placeholder~=^项目名称]");
 
-                // Elements title = doc.select("el-input[placeholder~=^编号]");
 
-                /**
-                 * 承包单位 承包单位、施工单位:引用施工单位名称 ,
-                 * 监理单位:引用监理单位名称
-                 * 合同段、所属建设项目(合同段):引用合同段编号
-                 *
-                 * 施工单位:施工单位 和 安装单位
-                 *
-                 */
-                ContractInfo contractInfo = contractInfoService.getById(wbsTreeContract.getContractId());
-                // 施工单位名称
-                if (dwtitle.size() >= 1) {
-                    int y = Integer.parseInt(dwtitle.attr("trindex"));
-                    if (y <= 10) {
-                        reData.put(dwtitle.attr("keyName"), contractInfo.getConstructionUnitName());
-                    }
+            // Elements title = doc.select("el-input[placeholder~=^编号]");
 
+            /**
+             * 承包单位 承包单位、施工单位:引用施工单位名称 ,
+             * 监理单位:引用监理单位名称
+             * 合同段、所属建设项目(合同段):引用合同段编号
+             *
+             * 施工单位:施工单位 和 安装单位
+             *
+             */
+            ContractInfo contractInfo = contractInfoService.getById(wbsTreeContract.getContractId());
+            // 施工单位名称
+            if (dwtitle.size() >= 1) {
+                int y = Integer.parseInt(dwtitle.attr("trindex"));
+                if (y <= 10) {
+                    reData.put(dwtitle.attr("keyName"), contractInfo.getConstructionUnitName());
                 }
-                if (sgtitle.size() >= 1) {
-                    int y = Integer.parseInt(sgtitle.attr("trindex"));
-                    if (y <= 10) {
-                        reData.put(sgtitle.attr("keyName"), contractInfo.getConstructionUnitName());
-                    }
+
+            }
+            if (sgtitle.size() >= 1) {
+                int y = Integer.parseInt(sgtitle.attr("trindex"));
+                if (y <= 10) {
+                    reData.put(sgtitle.attr("keyName"), contractInfo.getConstructionUnitName());
                 }
+            }
 
-                // 合同段名称
-                if (htdtitle.size() >= 1) {
-                    for (Element element : htdtitle) {
-                        int trindex = Integer.parseInt(element.attr("trindex"));
-                        if (trindex <= 8) {
-                            reData.put(element.attr("keyName"), contractInfo.getContractNumber());
-                        }
+            // 合同段名称
+            if (htdtitle.size() >= 1) {
+                for (Element element : htdtitle) {
+                    int trindex = Integer.parseInt(element.attr("trindex"));
+                    if (trindex <= 8) {
+                        reData.put(element.attr("keyName"), contractInfo.getContractNumber());
                     }
                 }
-                // 监理单位名称
-                if (jltitle.size() >= 1) {
+            }
+            // 监理单位名称
+            if (jltitle.size() >= 1) {
 
-                    for (Element element : jltitle) {
-                        int trindex = Integer.parseInt(element.attr("trindex"));
-                        if (trindex <= 10) {
-                            reData.put(element.attr("keyName"), contractInfo.getSupervisionUnitName());
-                        }
+                for (Element element : jltitle) {
+                    int trindex = Integer.parseInt(element.attr("trindex"));
+                    if (trindex <= 10) {
+                        reData.put(element.attr("keyName"), contractInfo.getSupervisionUnitName());
                     }
                 }
-                //获取父节点划分编号
-                WbsTreeContract node = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
-                        .eq(WbsTreeContract::getId, wbsTreeContract.getParentId())
-                        .eq(WbsTreeContract::getContractId, wbsTreeContract.getContractId()));
-                // 编号
-                if (bhtitle.size() >= 1 && contractInfo.getIsReferenceNumber() == 1) {
-                    for (Element element : bhtitle) {
-                        int trindex = Integer.parseInt(element.attr("trindex"));
-                        if (trindex <= 10) {
-                            reData.put(element.attr("keyName"), node.getPartitionCode() == null ? "" : node.getPartitionCode());
-                        }
+            }
+            //获取父节点划分编号
+            WbsTreeContract node = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
+                    .eq(WbsTreeContract::getId, wbsTreeContract.getParentId())
+                    .eq(WbsTreeContract::getContractId, wbsTreeContract.getContractId()));
+            // 编号
+            if (bhtitle.size() >= 1 && contractInfo.getIsReferenceNumber() == 1) {
+                for (Element element : bhtitle) {
+                    int trindex = Integer.parseInt(element.attr("trindex"));
+                    if (trindex <= 10) {
+                        reData.put(element.attr("keyName"), node.getPartitionCode() == null ? "" : node.getPartitionCode());
                     }
                 }
+            }
 
-                // 项目名称
-                if (xmtitle.size() >= 1) {
-                    for (Element element : xmtitle) {
-                        int trindex = Integer.parseInt(element.attr("trindex"));
-                        if (trindex <= 6) {
-                            ProjectInfo projectInfo = projectInfoService.getById(wbsTreeContract.getProjectId());
-                            reData.put(element.attr("keyName"), projectInfo.getProjectName());
-                        }
+            // 项目名称
+            if (xmtitle.size() >= 1) {
+                for (Element element : xmtitle) {
+                    int trindex = Integer.parseInt(element.attr("trindex"));
+                    if (trindex <= 6) {
+                        ProjectInfo projectInfo = projectInfoService.getById(wbsTreeContract.getProjectId());
+                        reData.put(element.attr("keyName"), projectInfo.getProjectName());
                     }
                 }
             }
+            }
         } catch (FileNotFoundException e) {
             e.printStackTrace();
         }
@@ -1170,7 +1175,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                                 String[] strings = StringUtils.strip(tabData[0], "[]").split(",");
 
                                 reData.put(key + "__" + tabData[1], strings);
-                            } else {
+                            }else {
                                 reData.put(key + "__" + tabData[1], tabData[0]);
                             }
                         }
@@ -1332,7 +1337,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                                                     x1 = 1;
                                                 }
                                                 String myData = DataInfo.get(val) + "";
-                                                if ((myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0) || (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0)) {
+                                                if ((myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0) || (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0)){
                                                     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
                                                     sdf.setTimeZone(TimeZone.getTimeZone("GTM+8"));
                                                     SimpleDateFormat formatStr = new SimpleDateFormat("yyyy年MM月dd日");
@@ -1356,13 +1361,13 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                                                     }
                                                 }
 
-                                                if (myData.indexOf("lang.String") >= 0) {
-                                                    String[] dataDate = (String[]) DataInfo.get(val);
-                                                    myData = dataDate[0] + " - " + dataDate[1].trim();
+                                                if(myData.indexOf("lang.String")>=0){
+                                                    String[]  dataDate = (String[]) DataInfo.get(val);
+                                                    myData = dataDate[0]+" - "+dataDate[1].trim();
                                                 }
 
                                                 //https:bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload/20220819/b53cb6700db369381e3b03d7737bcdec.jpg__16_1
-                                                if ((myData.indexOf("https") >= 0 || myData.indexOf("http") >= 0) && myData.indexOf("aliyuncs") >= 0) {
+                                                if ((myData.indexOf("https") >= 0 ||myData.indexOf("http") >= 0) && myData.indexOf("aliyuncs") >= 0) {
 
                                                     InputStream imageIn = CommonUtil.getOSSInputStream(myData);
 

+ 67 - 49
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java

@@ -1156,11 +1156,7 @@ public  List<ElementData> setScale(Integer scale,List<ElementData> data){
 
     private List<KeyMapper> listForContract(List<Long> ids,String projectId,String nodeId){
         String pkIds=ids.stream().map(String::valueOf).collect(Collectors.joining(","));
-        List<Map<String,Object>> listMap = this.jdbcTemplate.queryForList(" select a.init_table_name as tableName,a.p_key_id as pkId ,c.e_key as field,c.e_name as eName,c.id  as fieldId ,c.e_type eType , e_allow_deviation as eAllowDeviation  " +
-                "from m_wbs_tree_contract a " +
-                "inner join m_table_info b on a.init_table_name=b.tab_en_name " +
-                "INNER JOIN m_wbs_form_element c on b.id=c.f_id " +
-                "where a.p_key_id in("+pkIds+")  ORDER BY field(a.p_key_id,"+pkIds+")");
+        List<Map<String,Object>> listMap = listMap(ids,ExecuteType.INSPECTION);
         List<Long> nodeIds= this.jdbcTemplate.queryForList("select b.parent_id from m_wbs_tree_contract  a join m_wbs_tree_private b on a.is_type_private_pid=b.p_key_id where a.p_key_id in("+pkIds+")",Long.class);
         if(Func.isNotEmpty(listMap)){
             /*当前节点的某个元素存在多种作用域的公式,作用域范围越小优先级越高*/
@@ -1174,73 +1170,95 @@ public  List<ElementData> setScale(Integer scale,List<ElementData> data){
                     "from m_element_formula_mapping " +
                     "where element_id in(" + list.stream().map(KeyMapper::getFieldId).map(Func::toStr).collect(Collectors.joining(",")) + ") " +
                     "and is_deleted=0 " + " and ( scope<2 or (scope=2 and node_id in(" + nodeIdStr + ")) or (scope =10 and project_id = " + projectId + ") or (scope=20 and project_id =" + projectId + " and node_id in (" + nodeIdStr + ")))");
-            if(Func.isNotEmpty(efMap)){
-                Map<Long,List<Map<String,Object>>> efGroup= efMap.stream().collect(Collectors.groupingBy(e->Func.toLong(e.get("elementId"))));
-                list.forEach(e->{
-                    List<Map<String,Object>> tmp = efGroup.get(e.getFieldId());
-                    if(Func.isNotEmpty(tmp)){
-                        tmp.stream().max(Comparator.comparing(oo->Func.toInt(oo.get("scope")))).ifPresent(d->{
-                            e.setFormulaId(Func.toLong(d.get("formulaId")));
-                        });
-                    }
-                });
-            }
+            setFormula(list,efMap);
             /*节点参数公式*/
-            if(StringUtils.isNotEmpty(nodeId)){
-                /*存在工序节点id则检查节点参数*/
-                WbsTreeContract wtc = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId,nodeId));
-                if(wtc!=null){
-                    List<WbsParam> total = new ArrayList<>();
-                    WbsTreePrivate wtp = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getProjectId,wtc.getProjectId()).eq(WbsTreePrivate::getWbsId,wtc.getWbsId()).and(e->e.eq(WbsTreePrivate::getId,wtc.getId()).or().eq(WbsTreePrivate::getId,wtc.getOldId())));
-                    if(wtp!=null){
-                        List<WbsParam> wpsPrivate = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId,wtp.getPKeyId()));
-                        if(Func.isEmpty(wpsPrivate)){
-                            WbsTree wt = this.wbsTreeService.getOne(Wrappers.<WbsTree>lambdaQuery().and(e->e.eq(WbsTree::getId,wtc.getId()).or().eq(WbsTree::getId,wtc.getOldId())));
-                            if(wt!=null){
-                                List<WbsParam> wpsPublic = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId,wt.getId()));
-                                if(Func.isNotEmpty(wpsPublic)){
-                                    total.addAll(wpsPublic);
-                                }
+            setParamsFormula( nodeId,  list);
+            if(list.size()>0){
+                return list;
+            }
+        }
+        return Collections.emptyList();
+    }
+
+    private void setParamsFormula(String nodeId, List<KeyMapper> list){
+        if(StringUtils.isNotEmpty(nodeId)){
+            /*存在工序节点id则检查节点参数*/
+            WbsTreeContract wtc = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId,nodeId));
+            if(wtc!=null){
+                List<WbsParam> total = new ArrayList<>();
+                WbsTreePrivate wtp = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getProjectId,wtc.getProjectId()).eq(WbsTreePrivate::getWbsId,wtc.getWbsId()).and(e->e.eq(WbsTreePrivate::getId,wtc.getId()).or().eq(WbsTreePrivate::getId,wtc.getOldId())));
+                if(wtp!=null){
+                    List<WbsParam> wpsPrivate = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId,wtp.getPKeyId()));
+                    if(Func.isEmpty(wpsPrivate)){
+                        WbsTree wt = this.wbsTreeService.getOne(Wrappers.<WbsTree>lambdaQuery().and(e->e.eq(WbsTree::getId,wtc.getId()).or().eq(WbsTree::getId,wtc.getOldId())));
+                        if(wt!=null){
+                            List<WbsParam> wpsPublic = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId,wt.getId()));
+                            if(Func.isNotEmpty(wpsPublic)){
+                                total.addAll(wpsPublic);
                             }
-                        }else{
-                            total.addAll(wpsPrivate);
                         }
+                    }else{
+                        total.addAll(wpsPrivate);
                     }
-                    if(Func.isNotEmpty(total)){
-                        List<ElementFormulaMapping> mappingList =  this.elementFormulaMappingService.list(Wrappers.<ElementFormulaMapping>lambdaQuery().in(ElementFormulaMapping::getParamId,total.stream().map(WbsParam::getId).collect(Collectors.toList())));
-                        if(Func.isNotEmpty(mappingList)){
-                            list.forEach(e->{
-                                mappingList.stream().filter(m->StringUtils.isEquals(m.getElementId(),e.getFieldId())).findAny().ifPresent(d->{
-                                    e.setFormulaId(d.getFormulaId());
-                                });
+                }
+                if(Func.isNotEmpty(total)){
+                    List<ElementFormulaMapping> mappingList =  this.elementFormulaMappingService.list(Wrappers.<ElementFormulaMapping>lambdaQuery().in(ElementFormulaMapping::getParamId,total.stream().map(WbsParam::getId).collect(Collectors.toList())));
+                    if(Func.isNotEmpty(mappingList)){
+                        list.forEach(e->{
+                            mappingList.stream().filter(m->StringUtils.isEquals(m.getElementId(),e.getFieldId())).findAny().ifPresent(d->{
+                                e.setFormulaId(d.getFormulaId());
                             });
+                        });
 
-                        }
                     }
                 }
             }
+        }
+
+    }
+
+    private List<KeyMapper> listForPrivate(List<Long> ids,String projectId,String nodeId){
+        /**/
+        List<Map<String,Object>> listMap  = listMap(ids,ExecuteType.TESTING);
+        List<KeyMapper> list= listMap.stream().map(m->BeanUtil.toBean(m,KeyMapper.class)).collect(Collectors.toList());
+        if(Func.isNotEmpty(listMap)){
+            List<Map<String,Object>> efMap= this.jdbcTemplate.queryForList("select element_id elementId,formula_id formulaId,scope " +
+                    "from m_element_formula_mapping " +
+                    "where element_id in(" + list.stream().map(KeyMapper::getFieldId).distinct().map(Func::toStr).collect(Collectors.joining(",")) + ") " +
+                    "and is_deleted=0 " + " and ( scope<2 or (scope =10 and project_id = " + projectId + ") )");
+             setFormula(list,efMap);
             if(list.size()>0){
-                return list;
+                return  list;
             }
         }
         return Collections.emptyList();
     }
 
-    private List<KeyMapper> listForPrivate(List<Long> ids,String projectId,String nodeId){
-        /**/
+
+    private List<Map<String,Object>>   listMap(List<Long> ids,ExecuteType type){
         String pkIds=ids.stream().map(String::valueOf).collect(Collectors.joining(","));
-        List<Map<String,Object>> listMap = this.jdbcTemplate.queryForList(" select a.init_table_name as tableName,a.p_key_id as pkId ,c.e_key as field,c.e_name as eName,c.id  as fieldId ,c.e_type eType , e_allow_deviation as eAllowDeviation  " +
-                "from m_wbs_tree_private a " +
+        String tableName=ExecuteType.INSPECTION.equals(type)?"m_wbs_tree_contract":"m_wbs_tree_private";
+        return this.jdbcTemplate.queryForList(" select a.init_table_name as tableName,a.p_key_id as pkId ,c.e_key as field,c.e_name as eName,c.id  as fieldId ,c.e_type eType , e_allow_deviation as eAllowDeviation  " +
+                "from "+tableName+" a " +
                 "inner join m_table_info b on a.init_table_name=b.tab_en_name " +
                 "INNER JOIN m_wbs_form_element c on b.id=c.f_id " +
                 "where a.p_key_id in("+pkIds+")  ORDER BY field(a.p_key_id,"+pkIds+")");
-        if(Func.isNotEmpty(listMap)){
+    }
 
+    private void setFormula(List<KeyMapper> list,List<Map<String,Object>> efMap){
+        if(Func.isNotEmpty(efMap)){
+            Map<Long,List<Map<String,Object>>> efGroup= efMap.stream().collect(Collectors.groupingBy(e->Func.toLong(e.get("elementId"))));
+            list.forEach(e->{
+                List<Map<String,Object>> tmp = efGroup.get(e.getFieldId());
+                if(Func.isNotEmpty(tmp)){
+                    tmp.stream().max(Comparator.comparing(oo->Func.toInt(oo.get("scope")))).ifPresent(d->{
+                        e.setFormulaId(Func.toLong(d.get("formulaId")));
+                    });
+                }
+            });
         }
-        return Collections.emptyList();
     }
 
-
     @Override
     public List<Formula> getFormulaList(List<KeyMapper> keyMapperList) {
         if(Func.isNotEmpty(keyMapperList)){