Jelajahi Sumber

客户端资料查询处-搜索后数量统计不对

qianxb 2 tahun lalu
induk
melakukan
61347380a1

+ 9 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/feign/InformationQueryClient.java

@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 
 import java.util.List;
+import java.util.Map;
 
 @FeignClient(value =
         BusinessConstant.APPLICATION_WEATHER_NAME
@@ -25,6 +26,14 @@ public interface InformationQueryClient {
     @PostMapping(API_PREFIX + "/queryFirstBusinessDataByFirstId")
     JSONObject queryFirstBusinessDataByFirstId(@RequestParam String firstId);
 
+    /**
+     * 获取当前合同树和所有已填报表信息
+     * @param contractId
+     * @return
+     */
+    @PostMapping(API_PREFIX + "/getTreeAllTable")
+    Map<String,Long> getTreeAllTable(@RequestParam String contractId);
+
     /**
      * 保存填报时新增或修改填报资料记录表数据
      *

+ 2 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/WbsTreeContractVO.java

@@ -62,6 +62,8 @@ public class WbsTreeContractVO extends WbsTreeContract implements INode<WbsTreeC
     @JsonInclude(JsonInclude.Include.NON_EMPTY)
     private Boolean hasChildren;
 
+    private Long submitCounts;
+
     public WbsTreeContractVO() {
     }
 

+ 6 - 0
blade-service/blade-business/src/main/java/org/springblade/business/feignClient/InformationQueryClientImpl.java

@@ -13,6 +13,7 @@ import org.springblade.common.utils.SnowFlakeUtil;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
+import java.util.Map;
 
 @RestController
 @AllArgsConstructor
@@ -36,6 +37,11 @@ public class InformationQueryClientImpl implements InformationQueryClient {
 
         return null;
     }
+    //获取当前合同树和所有已填报表信息
+    @Override
+    public Map<String, Long> getTreeAllTable(String contractId) {
+        return iInformationQueryService.getTreeAllTable(contractId);
+    }
 
     @Override
     public String saveOrUpdateInformationQueryData(String wbsId, String tableId,

+ 4 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/IInformationQueryService.java

@@ -27,6 +27,7 @@ import org.springblade.manager.entity.WbsTreeContract;
 import org.springblade.manager.vo.WbsTreeContractTreeVOS;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  *  服务类
@@ -109,4 +110,7 @@ public interface IInformationQueryService extends BaseService<InformationQuery>
 
     void updateBatchByPKeyId(List<WbsTreeContract> result);
 
+    //获取当前合同所有填报表
+	public Map<String, Long> getTreeAllTable(String contractId);
+
 }

+ 73 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/InformationQueryServiceImpl.java

@@ -22,7 +22,9 @@ import org.springblade.core.secure.BladeUser;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.utils.DateUtil;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.manager.entity.ContractInfo;
 import org.springblade.manager.entity.WbsTreeContract;
+import org.springblade.manager.feign.ContractClient;
 import org.springblade.manager.feign.WbsTreeContractClient;
 import org.springblade.manager.vo.WbsTreeContractTreeVOS;
 import org.springblade.resource.feign.NewIOSSClient;
@@ -61,6 +63,8 @@ public class InformationQueryServiceImpl extends BaseServiceImpl<InformationQuer
 
     private final IContractLogService contractLogService;
 
+    private final ContractClient contractClient;
+
     @Override
     public List<String> queryBusinessTableData(String formDataId) {
         //获取具体业务数据
@@ -547,4 +551,73 @@ public class InformationQueryServiceImpl extends BaseServiceImpl<InformationQuer
         linkList.forEach(link -> vo.setWaitingUserList(link.getTaskUserName(), new Integer("999").equals(link.getEVisaStatus()) ? 999 : new Integer("2").equals(link.getStatus()) ? 2 : new Integer("3").equals(link.getStatus()) && new Integer("1").equals(link.getInitiative()) ? 3 : 1));
     }
 
+    /**
+     * 获取当前合同所有填报表
+     */
+    public Map<String, Long> getTreeAllTable(String contractId){
+        //总数据
+        List<WbsTreeContractTreeVOS> list = new ArrayList<>();
+        this.getAllTable("",contractId,list);
+        Map<String,Long> map = new HashMap<>();
+        list.stream().forEach(li->map.put(li.getId()+"",li.getSubmitCounts()));
+        return map;
+    }
+    /**
+     * 递归调用获取合同所有填报表
+     */
+    public void getAllTable(String parentId,String contractId, List<WbsTreeContractTreeVOS> list){
+        List<WbsTreeContractTreeVOS> vos = this.queryContractTree(parentId, contractId, "", "1");
+        if (vos != null && vos.size() > 0){
+            vos = vos.stream().filter(vo->vo.getSubmitCounts()!=0).collect(Collectors.toList());
+            list.addAll(vos);
+            for (WbsTreeContractTreeVOS vo : vos) {
+                this.getAllTable(vo.getId()+"",contractId,list);
+            }
+        }
+    }
+    /**
+     * 查询合同段划分树公共代码
+     */
+    private List<WbsTreeContractTreeVOS> queryContractTree(String parentId, String contractId, String contractIdRelation, String classifyType) {
+        List<WbsTreeContractTreeVOS> rootTreeNode;
+
+        //获取合同段,检查是否是监理合同段
+        ContractInfo contractInfo = this.contractClient.getContractById(Long.parseLong(contractId));
+        if (new Integer("2").equals(contractInfo.getContractType()) || new Integer("3").equals(contractInfo.getContractType())) {
+            //监理/业主合同段,需要获取关联的施工方合同段根节点数据
+            List<String> contractIds = new ArrayList<>();
+            if (StringUtils.isEmpty(parentId)) {
+                contractIds = this.contractClient.getProcessContractByJLContractId(contractId);
+            } else {
+                contractIds.add(contractIdRelation);
+            }
+            if (contractIds.size() > 0) {
+                if (StringUtils.isNotEmpty(parentId)) {
+                    //子节点
+                    rootTreeNode = this.queryContractTreeSupervision(contractIds, parentId, Integer.parseInt(classifyType));
+                } else {
+                    //根节点
+                    rootTreeNode = this.queryContractTreeSupervision(contractIds, "0", Integer.parseInt(classifyType));
+
+                    //设置根节点数量统计
+                    for (WbsTreeContractTreeVOS root : rootTreeNode) {
+                        List<WbsTreeContractTreeVOS> rootZi = this.queryContractTreeSupervision(Func.toStrList(root.getContractIdRelation()), root.getId().toString(), Integer.parseInt(classifyType));
+                        List<Long> collect = rootZi.stream().map(WbsTreeContractTreeVOS::getSubmitCounts).collect(Collectors.toList());
+                        Long reduce = collect.stream().reduce(0L, Long::sum);
+                        root.setSubmitCounts(reduce);
+                    }
+                }
+
+            } else {
+                rootTreeNode = new ArrayList<>();
+            }
+
+        } else {
+            //施工合同段
+            rootTreeNode = this.queryContractTree(contractId, StringUtils.isNotEmpty(parentId) ? parentId : "0", 1);
+        }
+
+        return rootTreeNode;
+    }
+
 }

+ 17 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ContractInfoServiceImpl.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.AllArgsConstructor;
+import org.springblade.business.feign.InformationQueryClient;
 import org.springblade.common.utils.BaiduApiUtil;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.log.exception.ServiceException;
@@ -51,6 +52,7 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
     private final WbsTreeContractMapper wbsTreeContractMapper;
     private final JdbcTemplate jdbcTemplate;
     private final IUserClient iUserClient;
+    private final InformationQueryClient informationQueryClient;
 
     @Override
     public List<String> getProcessContractByJLContractId(String contractId) {
@@ -131,6 +133,21 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
     @Override
     public List<WbsTreeContractVO> tree3(String wbsId, String projectId, String contractId) {
         List<WbsTreeContractVO> wbsTreeContractVOS = baseMapper.tree5(Long.parseLong(wbsId), Long.parseLong(projectId), Long.parseLong(contractId));
+        //获取所有已填报信息
+        Map<String, Long> allTable = informationQueryClient.getTreeAllTable(contractId);
+        Set<String> keySet = allTable.keySet();
+        for (String key : keySet) {
+            for (WbsTreeContractVO vo : wbsTreeContractVOS) {
+                if (key.equals(vo.getId()+"")){
+                    vo.setSubmitCounts(allTable.get(key));
+                }
+            }
+        }
+        wbsTreeContractVOS.stream().forEach(wtc->{
+            if (wtc.getSubmitCounts() == null){
+                wtc.setSubmitCounts(0L);
+            }
+        });
         return buildWbsTreeByStream(wbsTreeContractVOS);
     }