Browse Source

更新报表

jihs 4 years ago
parent
commit
1e5d52815a

+ 0 - 1
src/main/java/org/jeecg/common/dto/report/ProStatisticsThreeRespDTO.java

@@ -50,7 +50,6 @@ public class ProStatisticsThreeRespDTO {
     @Getter
     @Setter
     private String key;
-    @JsonInclude(JsonInclude.Include.NON_NULL)
     private List<ProStatisticsThreeRespDTO> childeren;
 
     public ProStatisticsThreeRespDTO() {

+ 12 - 4
src/main/java/org/jeecg/common/dto/report/ProStatisticsTwoRespDTO.java

@@ -39,6 +39,13 @@ public class ProStatisticsTwoRespDTO {
     @Setter
     @Getter
     private String mileId;
+    /**
+     * @desc 里程碑名称
+     */
+    @JsonIgnore
+    @Setter
+    @Getter
+    private String mileName;
     /**
      * @desc 里程碑金额
      */
@@ -59,14 +66,15 @@ public class ProStatisticsTwoRespDTO {
     public ProStatisticsTwoRespDTO() {
     }
 
-    public ProStatisticsTwoRespDTO(ProjectManageArchivesAndBusiness business, String proMember, String parentId) {
+    public ProStatisticsTwoRespDTO(ProjectManageArchivesAndBusiness business, String parentId) {
         this.id = business.getId();
         this.key = business.getId();
         this.coArchivesName = business.getPlanName();
         this.title = business.getPlanName();
         this.parentId = parentId;
-        this.proMember = proMember;
+//        this.proMember = proMember;
         this.isLeaf = false;
+        this.children = null;
     }
 
     public String getId() {
@@ -109,11 +117,11 @@ public class ProStatisticsTwoRespDTO {
         this.parentId = parentId;
     }
 
-    public Boolean getLeaf() {
+    public Boolean getIsLeaf() {
         return isLeaf;
     }
 
-    public void setLeaf(Boolean leaf) {
+    public void setIsLeaf(Boolean leaf) {
         isLeaf = leaf;
     }
 

+ 48 - 38
src/main/java/org/jeecg/modules/report/service/impl/ProReportServiceImpl.java

@@ -39,6 +39,7 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
    * @Author jihaosen
@@ -173,82 +174,93 @@ public class ProReportServiceImpl implements ProReportService {
      * @desc 配置收付款线条数据
      */
     private void setSecondChildren(List<ProjectManageArchivesAndBusiness> businesses, ProStatisticsRespDTO respDTO, Map<String, String> CoLineMap,
-        List<ProjectManageBusinessOther> otherList, Map<String, List<ProjectManageArchivesAndBusiness>> otherMap, Map<String, List<ProWorkLogic>> logicMap,
+        List<ProjectManageBusinessOther> otherList, Map<String, List<ProjectManageArchivesAndBusiness>> businessMap, Map<String, List<ProWorkLogic>> logicMap,
         Map<String, List<ProWorkMilestone>> milestoneMap,  Map<String, List<PurchaseDataDTO>> purchaseDataMap, Map<String, List<SlipAllListDTO>> slipMap) {
         List<ProStatisticsTwoRespDTO> list = Lists.newArrayList();
-        //i: 1代表实施, 2代表开发, 3代表服务
+
+        //i: 1代表实施, 2代表开发, 3代表服务, 4,代表其他
         for(int i = 1; i <=4 ; i++) {
             if(!CollectionUtils.isEmpty(businesses)){
                 List<ProjectManageArchivesAndBusiness> businesseses = selectSecondChildren(i, businesses);
+
                 if(!CollectionUtils.isEmpty(businesseses)){
                     for(ProjectManageArchivesAndBusiness business : businesseses){
                         //只处理收款计划
                         if(business.getPlanType() == 3){
-                            break;
+                            continue;
+                        }
+                        //处理其他数据
+                        if(i == 4){
+                            ProStatisticsTwoRespDTO twoRespDTO = new ProStatisticsTwoRespDTO(business, respDTO.getId());
+                            //处理回款计划
+                            twoRespDTO.setChildren(null);
+                            twoRespDTO.setIsLeaf(true);
+                            list.add(twoRespDTO);
+                            continue;
                         }
 
+                        ProStatisticsTwoRespDTO twoRespDTO = new ProStatisticsTwoRespDTO(business, respDTO.getId());
                         if(StringUtils.isNotBlank(business.getMileId1())){
-                            ProStatisticsTwoRespDTO twoRespDTO = new ProStatisticsTwoRespDTO(business, MeberDepartEnum.match(i).getName(), respDTO.getId());
                             twoRespDTO.setCoArchivesCode(CoLineMap.get(business.getPlanId()));
                             twoRespDTO.setMileId(business.getMileId1());
-                            List<ProjectManageArchivesAndBusiness> others = otherMap.get("3&"+business.getPlanId());
+                            twoRespDTO.setMileName(business.getMilestone1());
+                            List<ProjectManageArchivesAndBusiness> others = businessMap.get("3&"+business.getPlanId());
                             if(!CollectionUtils.isEmpty(others)){
                                 twoRespDTO.setMileCoPrice(others.get(0).getPrice1());
                             }
 
                             twoRespDTO.setMilePrice(business.getPrice1());
-
                             setThreeChildren(twoRespDTO, otherList, i, logicMap, milestoneMap, purchaseDataMap, slipMap);
-                            list.add(twoRespDTO);
+
                         }
                         if(StringUtils.isNotBlank(business.getMileId2())){
-                            ProStatisticsTwoRespDTO twoRespDTO = new ProStatisticsTwoRespDTO(business, MeberDepartEnum.match(i).getName(), respDTO.getId());
                             twoRespDTO.setCoArchivesCode(CoLineMap.get(business.getPlanId()));
                             twoRespDTO.setMileId(business.getMileId2());
-                            List<ProjectManageArchivesAndBusiness> others = otherMap.get("3&"+business.getPlanId());
+                            twoRespDTO.setMileName(business.getMilestone2());
+                            List<ProjectManageArchivesAndBusiness> others = businessMap.get("3&"+business.getPlanId());
                             if(!CollectionUtils.isEmpty(others)){
                                 twoRespDTO.setMileCoPrice(others.get(0).getPrice2());
                             }
                             setThreeChildren(twoRespDTO, otherList, i, logicMap, milestoneMap, purchaseDataMap, slipMap);
-                            list.add(twoRespDTO);
                         }
                         if(StringUtils.isNotBlank(business.getMileId3())){
-                            ProStatisticsTwoRespDTO twoRespDTO = new ProStatisticsTwoRespDTO(business, MeberDepartEnum.match(i).getName(), respDTO.getId());
                             twoRespDTO.setCoArchivesCode(CoLineMap.get(business.getPlanId()));
                             twoRespDTO.setMileId(business.getMileId3());
                             twoRespDTO.setMilePrice(business.getPrice3());
-                            List<ProjectManageArchivesAndBusiness> others = otherMap.get("3&"+business.getPlanId());
+                            twoRespDTO.setMileName(business.getMilestone3());
+                            List<ProjectManageArchivesAndBusiness> others = businessMap.get("3&"+business.getPlanId());
                             if(!CollectionUtils.isEmpty(others)){
                                 twoRespDTO.setMileCoPrice(others.get(0).getPrice3());
                             }
                             setThreeChildren(twoRespDTO, otherList, i, logicMap, milestoneMap, purchaseDataMap, slipMap);
-                            list.add(twoRespDTO);
                         }
                         if(StringUtils.isNotBlank(business.getMileId4())){
-                            ProStatisticsTwoRespDTO twoRespDTO = new ProStatisticsTwoRespDTO(business, MeberDepartEnum.match(i).getName(), respDTO.getId());
                             twoRespDTO.setCoArchivesCode(CoLineMap.get(business.getPlanId()));
                             twoRespDTO.setMileId(business.getMileId4());
-                            List<ProjectManageArchivesAndBusiness> others = otherMap.get("3&"+business.getPlanId());
+                            twoRespDTO.setMileName(business.getMilestone4());
+                            List<ProjectManageArchivesAndBusiness> others = businessMap.get("3&"+business.getPlanId());
                             if(!CollectionUtils.isEmpty(others)) {
                                 twoRespDTO.setMileCoPrice(others.get(0).getPrice4());
                             }
                             setThreeChildren(twoRespDTO, otherList, i, logicMap, milestoneMap, purchaseDataMap, slipMap);
-                            list.add(twoRespDTO);
                         }
                         if(StringUtils.isNotBlank(business.getMileId5())){
-                            ProStatisticsTwoRespDTO twoRespDTO = new ProStatisticsTwoRespDTO(business, MeberDepartEnum.match(i).getName(), respDTO.getId());
                             twoRespDTO.setCoArchivesCode(CoLineMap.get(business.getPlanId()));
                             twoRespDTO.setMileId(business.getMileId5());
                             twoRespDTO.setMilePrice(business.getPrice5());
-                            List<ProjectManageArchivesAndBusiness> others = otherMap.get("3&"+business.getPlanId());
+                            twoRespDTO.setMileName(business.getMilestone5());
+                            List<ProjectManageArchivesAndBusiness> others = businessMap.get("3&"+business.getPlanId());
                             if(!CollectionUtils.isEmpty(others)) {
-
                                 twoRespDTO.setMileCoPrice(others.get(0).getPrice5());
                             }
                             setThreeChildren(twoRespDTO, otherList, i, logicMap, milestoneMap, purchaseDataMap, slipMap);
-                            list.add(twoRespDTO);
                         }
 
+                        if(CollectionUtils.isEmpty(twoRespDTO.getChildren())){
+                            twoRespDTO.setIsLeaf(true);
+                            twoRespDTO.setChildren(null);
+                        }
+                        list.add(twoRespDTO);
                     }
                 }
 
@@ -271,7 +283,7 @@ public class ProReportServiceImpl implements ProReportService {
 
         List<ProStatisticsThreeRespDTO> respDTOS = Lists.newArrayList();
         //计划类型 1.商务 2.实施 3.开发 4.服务
-         ++i;
+         i++;
          for(ProjectManageBusinessOther other : otherList){
              if(other.getPlanType() == i && other.getMuilesId().equals(twoRespDTO.getMileId())){
                  ProStatisticsThreeRespDTO threeRespDTO = new ProStatisticsThreeRespDTO(other, twoRespDTO);
@@ -289,7 +301,6 @@ public class ProReportServiceImpl implements ProReportService {
                      for(ProWorkMilestone proWorkMilestone : proWorkMilestones){
                          if(proWorkMilestone.getMileId().equals(other.getMuilesId())){
                              threeRespDTO.setMileRealEndtDate(proWorkMilestone.getConfirmTime());
-                             break;
                          }
                      }
                  }
@@ -301,7 +312,6 @@ public class ProReportServiceImpl implements ProReportService {
                          if(twoRespDTO.getCoArchivesName().equals(purchaseDataDTO.getCoArchivesName()) &&
                                  threeRespDTO.getMilesName().equals(purchaseDataDTO.getProArchivesMilestone())) {
                              threeRespDTO.setMileInvoice(purchaseDataDTO.getCoPrice());
-                             break;
                          }
                      }
                  }
@@ -324,7 +334,6 @@ public class ProReportServiceImpl implements ProReportService {
                                  slipAllListDTO.getProArchivesMilestone().equals(threeRespDTO.getMilesName())) {
                              threeRespDTO.setMileRealCollecion(slipAllListDTO.getCoPrvice());
                          }
-                         break;
                      }
                  }
                  //里程碑实际收款 (收款单)
@@ -335,19 +344,21 @@ public class ProReportServiceImpl implements ProReportService {
                                  slipAllListDTO.getProArchivesMilestone().equals(threeRespDTO.getMilesName())) {
                              threeRespDTO.setMileRealPayment(slipAllListDTO.getCoPrvice());
                          }
-                         break;
                      }
                  }
                  threeRespDTO.setIsLeaf(true);
                  threeRespDTO.setChilderen(null);
 
+
                  respDTOS.add(threeRespDTO);
-             } else {
-                 twoRespDTO.setLeaf(true);
-                 twoRespDTO.setChildren(null);
              }
          }
-        twoRespDTO.setChildren(CollectionUtils.isEmpty(respDTOS)? null : respDTOS);
+
+         if(CollectionUtils.isEmpty(twoRespDTO.getChildren())){
+             twoRespDTO.setChildren(CollectionUtils.isEmpty(respDTOS)? null : respDTOS);
+             return;
+         }
+        twoRespDTO.setChildren(CollectionUtils.isEmpty(respDTOS)? null : Stream.concat(respDTOS.stream(), twoRespDTO.getChildren().stream()).collect(Collectors.toList()));
     }
 
 
@@ -357,11 +368,14 @@ public class ProReportServiceImpl implements ProReportService {
         switch(i){
             //代表实施
             case 1:
-                return businesses.stream().filter(t -> t.getPlanName().indexOf("实施") == -1).collect(Collectors.toList());
+                return businesses.stream().filter(t -> t.getPlanName().indexOf("实施") != -1).collect(Collectors.toList());
             case 2:
-                return businesses.stream().filter(t -> t.getPlanName().indexOf("开发") == -1).collect(Collectors.toList());
+                return businesses.stream().filter(t -> t.getPlanName().indexOf("开发") != -1).collect(Collectors.toList());
             case 3:
-                return businesses.stream().filter(t -> t.getPlanName().indexOf("服务") == -1).collect(Collectors.toList());
+                return businesses.stream().filter(t -> t.getPlanName().indexOf("服务") != -1).collect(Collectors.toList());
+            case 4:
+                return businesses.stream().filter(t -> t.getPlanName().indexOf("实施") == -1 && t.getPlanName().indexOf("开发") == -1
+                && t.getPlanName().indexOf("服务") == -1).collect(Collectors.toList());
         }
 
            return null;
@@ -372,15 +386,11 @@ public class ProReportServiceImpl implements ProReportService {
       */
      private List<ProjectManageArchivesAndBusiness> getBusinessData(String id) {
          QueryWrapper<ProjectManageArchivesAndBusiness> queryWrapper = new QueryWrapper<>();
-         Integer[] planTypeArr = {1, 2};
+         Integer[] planTypeArr = {1, 3};
          queryWrapper.eq("del_flag", "0").eq("pro_archives_id", id).in("plan_type", planTypeArr);
+         queryWrapper.orderByAsc("plan_type");
          List<ProjectManageArchivesAndBusiness> list = projectManageArchivesAndBusinessService.list(queryWrapper);
          return list;
      }
-
-    public static void main(String[] args) {
-                String[] str = {"a", "b", null, "3"};
-                System.out.println(String.join(",", Arrays.asList(str).stream().filter(t -> StringUtils.isNotBlank(t)).collect(Collectors.toList())));
-    }
  }