Browse Source

Merge remote-tracking branch 'origin/master'

liuyc 2 years ago
parent
commit
deb43ec725

+ 17 - 7
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/CurrentNode.java

@@ -1,28 +1,38 @@
 package org.springblade.manager.vo;
 
 import lombok.Data;
+import org.springblade.manager.entity.WbsTreePrivate;
 
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
+import java.util.Optional;
 
 /**
  * @author yangyj
  * @Date 2022/12/31 16:34
- * @description TODO
+ * @description 当前工序或实验节点的上下文信息
  */
 @Data
 public class CurrentNode {
     /**流水号*/
     private Long pkId;
-    /**项目集id*/
-    private Long privateId;
-    /**wbs_tree的流水号 溯源*/
+    /**wtc的id,用来关联表*/
     private Long id;
-    /**父节点的树id,注意非流水号*/
+    /**合同段id*/
+    private Long contractId;
+    /**项目id*/
+    private Long projectId;
+    /**当前工序父节点的pkeyId*/
+    private Long parentPkeyId;
+    /**当前工序父节点的树id,注意非pkeyId*/
     private Long parentId;
-    /**用来构建树的id 父子*/
-    private Long relateId;
+    /**wbsInfoId,如果是私有引用,必须溯源公有*/
     private Long wbsId;
+    /**当前节点对应项目级的pkeyId*/
+    private Long wtpPkeyId;
+    /**wbs_tree的流水号 需要溯源*/
+    private Long wbsNodeId;
+
 
 }

+ 84 - 2
blade-service/blade-business/src/main/java/org/springblade/business/controller/NeiWaiYeProgressController.java

@@ -16,6 +16,7 @@ import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.manager.entity.WbsTreeContract;
 import org.springblade.manager.feign.WbsTreeContractClient;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -40,13 +41,94 @@ public class NeiWaiYeProgressController {
 
     private final IConstructionLedgerService constructionLedgerService;
 
+    private final JdbcTemplate jdbcTemplate;
+
     /**
-     * 内外业进度
+     * 内外业进度 ,id为当前合同段id
      */
     @GetMapping("/neiWaiYeProgress")
     @ApiOperationSupport(order = 1)
     @ApiOperation(value = "内外业进度")
-    public R<List<NeiWaiYeProgressVO>> neiWaiYeProgress(@RequestParam String primaryKeyId, @RequestParam String contractId) {
+    public R<List<NeiWaiYeProgressVO>> neiWaiYeProgress(@RequestParam String primaryKeyId, @RequestParam String contractId,@RequestParam String contractIdRelation) {
+        if (StringUtils.isNotEmpty(primaryKeyId)) {
+            //判断primaryKeyId是唯一键还是泛用键
+            WbsTreeContract node = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(primaryKeyId);
+            if (node == null) {
+                //说明是监理合同段
+                node = this.wbsTreeContractClient.getContractWbsTreeByContractIdAndId(Long.parseLong(primaryKeyId), Long.parseLong(contractId));
+            }
+            Integer classFy = jdbcTemplate.queryForObject(" select contract_type from m_contract_info WHERE id = " + contractIdRelation, Integer.class);
+            //设置返回集合
+            List<NeiWaiYeProgressVO> result = new ArrayList<>();
+
+            //获取当前节点的子节点
+            List<WbsTreeContract> childList = this.wbsTreeContractClient.queryChildByParentId(node, "noeQueryTable", "");
+            //删除掉首件的
+            childList.removeIf(child -> child.getNodeType() != null && child.getNodeType() == 111);
+
+            //获取当前节点下的所有填报节点
+            List<QueryProcessDataVO> queryProcessDataVOList;
+            if (!new Integer("6").equals(node.getNodeType()) && !Arrays.asList("1,2,3,4".split(",")).contains(node.getMajorDataType().toString())) {
+                queryProcessDataVOList = this.informationQueryService.queryProcessDataByParentIdAndContractId(node.getId().toString(), classFy, contractId);
+            } else {
+                //填报节点
+                queryProcessDataVOList = this.informationQueryService.queryProcessDataByPrimaryKeyIdAndClassify(node.getPKeyId().toString(), classFy);
+                childList.clear();
+                //设置填报节点进集合中
+                childList.add(node);
+            }
+
+            if (queryProcessDataVOList != null && queryProcessDataVOList.size() > 0) {
+                //删除掉开工报告等节点
+                queryProcessDataVOList.removeIf(vo -> !new Integer("4").equals(vo.getMajorDataType()));
+                //循环子节点
+                for (WbsTreeContract child : childList) {
+                    //设置返回参数
+                    int amount = 0, neiYeSuccessAmount = 0, waiYeSuccessAmount = 0;
+
+                    //使用迭代器,减少之后的循环次数
+                    Iterator<QueryProcessDataVO> iterator = queryProcessDataVOList.iterator();
+                    while (iterator.hasNext()) {
+                        QueryProcessDataVO vo = iterator.next();
+                        //找到自己的子节点
+                        if (vo.getAncestors().contains(child.getId().toString()) || vo.getParentId().equals(child.getId().toString()) || vo.getPrimaryKeyId().equals(child.getPKeyId().toString())) {
+                            //统计内业数量(内业根据已审批的节点资料统计)
+                            if (new Integer("2").equals(vo.getStatus())) {
+                                neiYeSuccessAmount++;
+                            }
+                            //统计外业数量(外业根据当前填报节点是否已经生成一份施工日志为准(暂时))
+                            Integer logCount = this.contractLogWbsService.countContractLogBySelectPrimaryKeyIdsAndClassify(Func.toStrList(vo.getPrimaryKeyId()), 7);
+                            if (logCount != null && logCount > 0) {
+                                waiYeSuccessAmount++;
+                            } else {
+                                //检查是否填有对应的施工台账(以施工台账是否填写开工时间为准)
+                                ConstructionLedger ledger = this.constructionLedgerService.getOne(Wrappers.<ConstructionLedger>lambdaQuery().eq(ConstructionLedger::getWbsId, vo.getPrimaryKeyId()));
+                                if (ledger != null && ledger.getSiteStartTime() != null) {
+                                    waiYeSuccessAmount++;
+                                }
+                            }
+                            //统计总数
+                            amount++;
+                            iterator.remove();
+                        }
+                    }
+
+                    //添加返回结果
+                    result.add(new NeiWaiYeProgressVO(StringUtils.isNotEmpty(child.getFullName()) ? child.getFullName() : child.getNodeName(), amount, neiYeSuccessAmount, waiYeSuccessAmount));
+                }
+                return R.data(result);
+            }
+        }
+        return R.data(300, null, "未查询到数据");
+    }
+
+    /**
+     * 内外业进度- 原统计改为了2
+     */
+    @GetMapping("/neiWaiYeProgress2")
+    @ApiOperationSupport(order = 1)
+    @ApiOperation(value = "内外业进度")
+    public R<List<NeiWaiYeProgressVO>> neiWaiYeProgress2(@RequestParam String primaryKeyId, @RequestParam String contractId) {
         if (StringUtils.isNotEmpty(primaryKeyId)) {
             //判断primaryKeyId是唯一键还是泛用键
             WbsTreeContract node = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(primaryKeyId);

+ 60 - 56
blade-service/blade-manager/src/main/java/com/mixsmart/utils/FormulaUtils.java

@@ -157,68 +157,72 @@ public class FormulaUtils {
             /*无定位信息不写入*/
             return;
         }
-        /*一个单元格且存在多张,全部设置为自动拓展 20230816*/
-        if(fd.getCoordsList().size()==1&&fd.getValues().size()>1&&fd.getFormula()!=null){
-               fd.getFormula().setOutm(Formula.FULL);
-        }
-        /*写入前清空内容*/
-        fd.getValues().forEach(t->t.setValue(null));
-        if(data instanceof List){
-            List<Object> values = (List<Object>) data;
-            if(!nullOrBlank){
-               values=values.stream().filter(StringUtils::isNotEmpty).collect(Collectors.toList());
+        try {
+            /*一个单元格且存在多张,全部设置为自动拓展 20230816*/
+            if(fd.getCoordsList().size()==1&&fd.getValues().size()>1&&fd.getFormula()!=null){
+                fd.getFormula().setOutm(Formula.FULL);
             }
-            if(values.size()>fd.getValues().size()){
-                /*当生成的数据超过实际容量的时候,会自动追加页数*/
-                if(fd.getCoordsList().size()==1){
-                    if(values.stream().filter(CustomFunction::containsZH).anyMatch(e->e.toString().contains("\n"))){
-                        fd.getValues().get(0).setValue(values.stream().filter(Objects::nonNull).map(Object::toString).collect(Collectors.joining()));
+            /*写入前清空内容*/
+            fd.getValues().forEach(t->t.setValue(null));
+            if(data instanceof List){
+                List<Object> values = (List<Object>) data;
+                if(!nullOrBlank){
+                    values=values.stream().filter(StringUtils::isNotEmpty).collect(Collectors.toList());
+                }
+                if(values.size()>fd.getValues().size()){
+                    /*当生成的数据超过实际容量的时候,会自动追加页数*/
+                    if(fd.getCoordsList().size()==1){
+                        if(values.stream().filter(CustomFunction::containsZH).anyMatch(e->e.toString().contains("\n"))){
+                            fd.getValues().get(0).setValue(values.stream().filter(Objects::nonNull).map(Object::toString).collect(Collectors.joining()));
+                        }else{
+                            fd.getValues().get(0).setValue(values.stream().map(StringUtils::handleNull).collect(Collectors.joining("、")));
+                        }
                     }else{
-                        fd.getValues().get(0).setValue(values.stream().map(StringUtils::handleNull).collect(Collectors.joining("、")));
+                        // copy(fd,values);
+                        for(int n=0;n<fd.getValues().size();n++){
+                            fd.getValues().get(n).setValue(values.get(n));
+                        }
+                        List<Object> overList=values.stream().skip(fd.getValues().size()).collect(Collectors.toList());
+                        List<Coords> coordsList = fd.getCoordsList();
+                        int addPage=(int)Math.ceil((double)overList.size()/(double)coordsList.size());
+                        fd.setAddPages(addPage);
+                        ElementData last =fd.getValues().get(fd.getValues().size()-1);
+                        int indexBase=last.getIndex()+1;
+                        List<ElementData> addList= new ArrayList<>();
+                        for(int i=0;i<addPage;i++){
+                            for(int j=0;j<coordsList.size();j++){
+                                /*超页就尽管写进去,格式化阶段再加表*/
+                                Coords coords = coordsList.get(j);
+                                Object v=null;
+                                int st=i*coordsList.size()+j;
+                                if(st<overList.size()){
+                                    v= overList.get(st);
+                                }
+                                addList.add(new ElementData(indexBase+i,last.getGroupId(),v,coords.getX(),coords.getY()));
+                            }
+                        }
+                        fd.getValues().addAll(addList);
                     }
+
                 }else{
-                    // copy(fd,values);
-                    for(int n=0;n<fd.getValues().size();n++){
+                    for(int n=0;n<values.size();n++){
                         fd.getValues().get(n).setValue(values.get(n));
                     }
-                    List<Object> overList=values.stream().skip(fd.getValues().size()).collect(Collectors.toList());
-                    List<Coords> coordsList = fd.getCoordsList();
-                    int addPage=(int)Math.ceil((double)overList.size()/(double)coordsList.size());
-                    fd.setAddPages(addPage);
-                    ElementData last =fd.getValues().get(fd.getValues().size()-1);
-                    int indexBase=last.getIndex()+1;
-                    List<ElementData> addList= new ArrayList<>();
-                    for(int i=0;i<addPage;i++){
-                        for(int j=0;j<coordsList.size();j++){
-                            /*超页就尽管写进去,格式化阶段再加表*/
-                            Coords coords = coordsList.get(j);
-                            Object v=null;
-                            int st=i*coordsList.size()+j;
-                            if(st<overList.size()){
-                                v= overList.get(st);
-                            }
-                            addList.add(new ElementData(indexBase+i,last.getGroupId(),v,coords.getX(),coords.getY()));
-                        }
-                    }
-                    fd.getValues().addAll(addList);
                 }
-
             }else{
-                for(int n=0;n<values.size();n++){
-                    fd.getValues().get(n).setValue(values.get(n));
+                if(Formula.FULL.equals(fd.getFormula().getOutm())){
+                    /*填充策略*/
+                    fd.getValues().forEach(e->e.setValue(data));
+                }else{
+                    fd.getValues().get(0).setValue(data);
                 }
             }
-        }else{
-            if(Formula.FULL.equals(fd.getFormula().getOutm())){
-                /*填充策略*/
-                fd.getValues().forEach(e->e.setValue(data));
-            }else{
-                fd.getValues().get(0).setValue(data);
-            }
+            fd.setUpdate(1);
+        }catch (Exception e){
+            e.printStackTrace();
         }
-        fd.setUpdate(1);
     }
-    public static  List<TableInfo> getTableInfoList(JSONArray dataArray) {
+    /*public static  List<TableInfo> getTableInfoList(JSONArray dataArray) {
         if (dataArray != null && !dataArray.isEmpty()) {
             List<TableInfo> result = new ArrayList<>();
             for (int m = 0; m < dataArray.size(); m++) {
@@ -299,8 +303,8 @@ public class FormulaUtils {
             return result;
         }
         return null;
-    }
-
+    }*/
+/*
     public static void setFirstData(JSONObject dataInfo2, TableInfo tableInfo) {
         //huangjn 判断是否是首件
         if (dataInfo2.containsKey("isFirst")) {
@@ -334,9 +338,9 @@ public class FormulaUtils {
         }
     }
 
-    /**
+    *//**
      * 设置日志信息
-     */
+     *//*
     public static void setTheLogData(JSONObject dataInfo2, TableInfo tableInfo) {
         //huangjn 判断是否是日志
         if (dataInfo2.containsKey("isTheLog")) {
@@ -366,7 +370,7 @@ public class FormulaUtils {
             tableInfo.setBusinessId(dataInfo2.getString("id"));
         }
         //huangjn 每份填报数据的id,目前日志专用
-    }
+    }*/
 
     /**从元素名称中解析项目名称,细化项目匹配用*/
     public static  String parseItemName(String eName){
@@ -734,7 +738,7 @@ public class FormulaUtils {
             }
         }
     }
-    /*从方法参数中获取全部code*/
+    /**从方法参数中获取全部code*/
     public static List<String> getCodeList(String param){
         List<String> list = new ArrayList<>();
         if(StringUtils.isNotEmpty(param)){

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

@@ -107,7 +107,7 @@ public class WbsTreeContractClientImpl implements WbsTreeContractClient {
             return this.wbsTreeContractService.list(wrapper);
         } else {
             //.eq(WbsTreeContract::getType, "1")
-            return this.wbsTreeContractService.list(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getParentId, treeNode.getId()).eq(WbsTreeContract::getContractId, treeNode.getContractId()).eq(WbsTreeContract::getStatus, 1));
+            return this.wbsTreeContractService.list(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getParentId, treeNode.getId()).eq(WbsTreeContract::getContractId, treeNode.getContractId()).eq(WbsTreeContract::getStatus, 1).orderByAsc(WbsTreeContract::getSort).orderByAsc(WbsTreeContract::getFullName));
         }
     }
 

+ 7 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IFormulaService.java

@@ -3,6 +3,8 @@ package org.springblade.manager.service;
 import org.springblade.core.mp.base.BaseService;
 import org.springblade.manager.dto.FormData;
 import org.springblade.manager.entity.Formula;
+import org.springblade.manager.entity.WbsInfo;
+import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.manager.enums.ExecuteType;
 import org.springblade.manager.formula.KeyMapper;
 import org.springblade.manager.formula.impl.TableElementConverter;
@@ -55,4 +57,9 @@ public interface IFormulaService extends BaseService<Formula> {
     List<KeyMapper> getKeyMapperList(List<Long> ids, String projectId, String nodeId, ExecuteType executeType);
 
     Map<String, Object> getElementInfoByCodes(String codes);
+
+    /**根据wbs_tree_contract 的pkeyId查询项目级对应节点*/
+     WbsTreePrivate wtpId(Long pkeyId);
+    /**根据wbs_tree_private的pkeyId获取公共树*/
+    WbsTreePrivate getOriginWtp(Long pkeyId);
 }

+ 30 - 33
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -425,46 +425,43 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             e.printStackTrace();
         }
     }
-
+    /*当前工序节点上下文信息*/
     public CurrentNode createCurrentNode(WbsTreeContract wtc) {
         if (wtc != null) {
-            /*当前工序节点*/
-            CurrentNode currentNode = new CurrentNode();
-            currentNode.setPkId(wtc.getPKeyId());
-            currentNode.setParentId(wtc.getParentId());
-            currentNode.setWbsId(Long.parseLong(wtc.getWbsId()));
-            currentNode.setId(StringUtils.isNotEmpty(wtc.getOldId()) ? Long.valueOf(wtc.getOldId()) : wtc.getId());
-            currentNode.setRelateId(wtc.getId());
-            currentNode.setPrivateId(this.jdbcTemplate.queryForObject("select p_key_id from m_wbs_tree_private where id=" + currentNode.getId() + " and  project_id=" + wtc.getProjectId() + " and wbs_id=" + wtc.getWbsId() + " limit 1", Long.class));
-            return currentNode;
+            WbsTreePrivate wtp=this.formulaService.wtpId(wtc.getPKeyId());
+            WbsTreeContract parent = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getContractId,wtc.getContractId()).eq(WbsTreeContract::getId,wtc.getParentId()));
+            if(wtp!=null&&parent!=null) {
+                /*私有引用项目,需要溯源*/
+                WbsTreePrivate publicWtp = this.formulaService.getOriginWtp(wtp.getPKeyId());
+                CurrentNode currentNode = new CurrentNode();
+                currentNode.setPkId(wtc.getPKeyId());
+                currentNode.setId(wtc.getId());
+                currentNode.setContractId(Long.parseLong(wtc.getContractId()));
+                currentNode.setProjectId(Long.parseLong(wtc.getProjectId()));
+                currentNode.setParentPkeyId(parent.getPKeyId());
+                currentNode.setParentId(wtc.getParentId());
+                currentNode.setWbsId(Long.parseLong(publicWtp.getWbsId()));
+                currentNode.setWtpPkeyId(wtp.getPKeyId());
+                currentNode.setWbsNodeId(publicWtp.getId());
+                return currentNode;
+            }
         }
         return null;
     }
 
 
-    public <T extends BaseEntity> CurrentNode createCurrentNode(T entity) {
-        if (entity instanceof WbsTreeContract) {
-            WbsTreeContract wtc = (WbsTreeContract) entity;
-            /*当前工序节点*/
-            CurrentNode currentNode = new CurrentNode();
-            currentNode.setPkId(wtc.getPKeyId());
-            currentNode.setParentId(wtc.getParentId());
-            currentNode.setWbsId(Long.parseLong(wtc.getWbsId()));
-            currentNode.setId(StringUtils.isNotEmpty(wtc.getOldId()) ? Long.valueOf(wtc.getOldId()) : wtc.getId());
-            currentNode.setRelateId(wtc.getId());
-            currentNode.setPrivateId(this.jdbcTemplate.queryForObject("select p_key_id from m_wbs_tree_private where id=" + currentNode.getId() + " and  project_id=" + wtc.getProjectId() + " and wbs_id=" + wtc.getWbsId() + " limit 1", Long.class));
-            return currentNode;
-        } else if (entity instanceof WbsTreePrivate) {
-            WbsTreePrivate wtc = (WbsTreePrivate) entity;
-            /*当前工序节点*/
-            CurrentNode currentNode = new CurrentNode();
-            currentNode.setPkId(wtc.getPKeyId());
-            currentNode.setParentId(wtc.getParentId());
-            currentNode.setWbsId(Long.parseLong(wtc.getWbsId()));
-            currentNode.setId(wtc.getId()); //数据源
-            currentNode.setRelateId(wtc.getId());
-            currentNode.setPrivateId(wtc.getPKeyId());
-            return currentNode;
+    public CurrentNode  createCurrentNode( WbsTreePrivate wtp) {
+        if (wtp!=null) {
+                /*私有引用项目,需要溯源*/
+                WbsTreePrivate publicWtp = this.formulaService.getOriginWtp(wtp.getPKeyId());
+                CurrentNode currentNode = new CurrentNode();
+                currentNode.setPkId(wtp.getPKeyId());
+                currentNode.setId(wtp.getId());
+                currentNode.setProjectId(Long.parseLong(wtp.getProjectId()));
+                currentNode.setParentId(wtp.getParentId());
+                currentNode.setWbsId(Long.parseLong(publicWtp.getWbsId()));
+                currentNode.setWbsNodeId(wtp.getId());
+                return currentNode;
         }
         return null;
     }

+ 66 - 47
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java

@@ -79,6 +79,8 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
     private final IFormulaOptionService formulaOptionService;
     private final ITextdictInfoService textDictInfoService;
     private final IFormulaDataBlockService formulaDataBlockService;
+    private final IExcelTabService excelTabService;
+    private final IWbsInfoService wbsInfoService;
 
     private   TableElementConverter tec;
     public final static String WP="WP";
@@ -168,9 +170,11 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             /*表格名称*/
             List<AppWbsTreeContractVO> tableList =wbsTreeContractService.searchNodeAllTable(one.getPkId().toString(), "1", tec.getContractId().toString(),tec.getProjectId().toString());
             tec.constantMap.put(TABLE_LIST,tableList);
-            /*通过判断元素名称来确定,加入汇总公式延后执行*/
-            /*tec.constantMap.put("tableNames",tableList.stream().filter(e->StringUtils.isEquals(e.getIsBussShow(),1)).map(WbsTreeContract::getNodeName).collect(Collectors.toList()));*/
+            /*监表质量附件,过滤掉隐藏表格*/
+            tec.constantMap.put("tableNames",tableList.stream().filter(e->StringUtils.isEquals(e.getIsBussShow(),1)).map(WbsTreeContract::getNodeName).collect(Collectors.toList()));
+/*
             tec.constantMap.put("tableNames",tableList.stream().map(WbsTreeContract::getNodeName).collect(Collectors.toList()));
+*/
         }
     }
 
@@ -485,11 +489,11 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
     public Map<String,Object> getWpMap(CurrentNode currentNode){
         Map<String,Object> result = new HashMap<>(100);
         List<WbsParam> total = new ArrayList<>();
-        List<WbsParam> wpsPublic = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId,currentNode.getId()).eq(WbsParam::getType,1));
+        List<WbsParam> wpsPublic = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId,currentNode.getWbsNodeId()).eq(WbsParam::getType,1));
         if(Func.isNotEmpty(wpsPublic)){
             total.addAll(wpsPublic);
         }
-        List<WbsParam> wpsPrivate = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId,currentNode.getPrivateId()).eq(WbsParam::getType,1));
+        List<WbsParam> wpsPrivate = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId,currentNode.getWtpPkeyId()).eq(WbsParam::getType,1));
         if(Func.isNotEmpty(wpsPrivate)){
             total.addAll(wpsPrivate);
         }
@@ -884,7 +888,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                         data1.put("pkeyId",data.getPKeyId());
                         dataArray.add(data1);
                     }
-                    List<TableInfo> subTableInfo = FormulaUtils.getTableInfoList(dataArray);
+                    List<TableInfo> subTableInfo = this.excelTabService.getTableInfoList(dataArray);
                     TableInfo example = tec.getTableInfoList().get(0);
                     subTableInfo.forEach(e -> {
                         e.setToBeUpdated(true);
@@ -1239,31 +1243,55 @@ public  List<ElementData> setScale(Integer scale,List<ElementData> data){
         return Collections.emptyList();
     }
 
+    @Override
+    public WbsTreePrivate getOriginWtp(Long pkeyId) {
+        WbsTreePrivate wtp = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId,pkeyId));
+        int i=10;
+        WbsTreePrivate publicWtp = null;
+        while (i>0) {
+            WbsTreePrivate tmp=  this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, wtp.getWbsId()));
+            if (tmp == null) {
+                break;
+            }
+            publicWtp = tmp;
+            i--;
+        }
+        if(publicWtp!=null){
+            /*私有引用项目的wbsId其实是被复制的项目的根节点p_key_id,只有溯源才能找到真正的wbsId*/
+            wtp.setWbsId(publicWtp.getWbsId());
+        }
+       return wtp;
+    }
 
+    @Override
+    public WbsTreePrivate wtpId(Long pkeyId){
+       WbsTreeContract wtc = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId,pkeyId));
+       while (wtc.getOldId()!=null){
+           wtc = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getId,wtc.getOldId()).eq(WbsTreeContract::getProjectId,wtc.getProjectId()).last(" limit 1 "));
+       }
+       return this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getId,wtc.getId()).eq(WbsTreePrivate::getProjectId,wtc.getProjectId()));
+    }
     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 = listMap(ids,ExecuteType.INSPECTION);
-        Map<String,Object> wtpMap= this.jdbcTemplate.queryForMap("select b.id parentId,b.wbs_id wbsId from m_wbs_tree_contract  a join m_wbs_tree_private b on (a.id=b.id or a.old_id=b.id ) where a.p_key_id ="+nodeId+" and b.project_id="+projectId+" limit 1");
+        WbsTreePrivate wtp =wtpId(Long.parseLong(nodeId));
+        //Map<String,Object> wtpMap= this.jdbcTemplate.queryForMap("select b.id parentId,b.wbs_id wbsId from  m_wbs_tree_private b where is_deleted=0 and id="+originId+" and project_id="+projectId);
         if(Func.isNotEmpty(listMap)){
             /*当前节点的某个元素存在多种作用域的公式,作用域范围越小优先级越高*/
             List<KeyMapper> list= listMap.stream().map(m->BeanUtil.toBean(m,KeyMapper.class)).collect(Collectors.toList());
-            String nodeIdStr= StringUtils.handleNull(wtpMap.get("parentId"));
-            if(Func.isBlank(nodeIdStr)){
-                /*暂时这么处理,严格上说要查找到项目级对应的节点*/
-                nodeIdStr="''";
-            }
-            String wbsId =StringUtils.handleNull(wtpMap.get("wbsId"));
-            if(Func.isBlank(wbsId)){
-                /*暂时这么处理,严格上说要查找到项目级对应的节点*/
-                wbsId="''";
-            }
+            /*项目级*/
+            Long nodeIdPrivate= wtp.getId();
+            WbsTreePrivate origin =getOriginWtp(wtp.getPKeyId());
+            String wbsId =StringUtils.handleNull(origin.getPKeyId());
+            /*Wbs对应的节点*/
+            Long nodeIdWbs=origin.getId();
             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).map(Func::toStr).collect(Collectors.joining(",")) + ") " +
-                    "and is_deleted=0 " + " and (scope=0 or (scope=1 and wbs_id="+wbsId+") or(scope=2  and wbs_id="+wbsId+" and node_id="+nodeIdStr+")or (scope =10 and project_id = " + projectId + ") or (scope=20 and project_id =" + projectId + " and node_id=" +nodeIdStr +"))");
+                    "and is_deleted=0 " + " and (scope=0 or (scope=1 and wbs_id="+wbsId+") or(scope=2  and wbs_id="+wbsId+" and node_id="+nodeIdWbs+")or (scope =10 and project_id = " + projectId + ") or (scope=20 and project_id =" + projectId + " and node_id=" +nodeIdPrivate +"))");
             setFormula(list,efMap);
             /*节点参数公式*/
-            setParamsFormula( nodeId,  list);
+            setParamsFormula( wtp.getPKeyId(),origin.getId(),  list);
             if(list.size()>0){
                 return list;
             }
@@ -1271,39 +1299,30 @@ public  List<ElementData> setScale(Integer scale,List<ElementData> data){
         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);
-                    }
-                }
-                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 void setParamsFormula(Long privatePkeyId,Long wbsNodeId, List<KeyMapper> list){
+        if(StringUtils.isNotEmpty(privatePkeyId,wbsNodeId)){
+            List<WbsParam> total = new ArrayList<>();
+            List<WbsParam> wpsPublic = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId,wbsNodeId));
+            /*同时获取WBS和 项目级的节点参数,如果存在同名则项目级覆盖WBS*/
+            if(Func.isNotEmpty(wpsPublic)){
+                total.addAll(wpsPublic);
+            }
+            List<WbsParam> wpsPrivate = this.wpService.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId,privatePkeyId));
+            if(Func.isNotEmpty(wpsPrivate)){
+                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());
                         });
+                    });
 
-                    }
                 }
             }
+
         }
 
     }