yxm
2024-07-09 4eb1fe4a08e94c809ba513e0604ecd560e186f56
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgProjectInfoServiceImpl.java
@@ -208,103 +208,57 @@
    */
   @Override
   @Transactional
   @Transactional(rollbackFor = Exception.class)
   public List<SgStatisProVO> getsgStatisticsList(String code) {
      AttAdBase ywxtAdDetail = iAttAdBaseService.getYwxtAdDetail(code);
      List<SgStatisProVO>  sgStatisProVOS;
      List<BigDecimal> bigDecimals = new ArrayList<>();
      ProjectSearchDTO projectSearchDTO = new ProjectSearchDTO();
      //片区
      if (ywxtAdDetail == null){
         sgStatisProVOS = sgProjectInfoMapper.getsgStatisticsZero(code);
         String getname = sgProjectInfoMapper.getname(code);
         sgStatisProVOS.forEach(s->{
            if (s.getCommenceNum() == 0) {
               s.setProjectProgress("0%");
               s.setPcode(code);
               s.setPname(getname);
               s.setAdGrad("2");
            }else {
               List<String> ids =  sgProjectInfoMapper.getProjectId("2",s.getCode());
               ids.forEach(id->{
                  projectSearchDTO.setProjectId(id);
                  List<SgProjectInfoVO> list =sgProjectInfoMapper.queryStepByProject(projectSearchDTO);
                  getProjectProgress(list).forEach(ss->{
                     bigDecimals.add(ss.getProjectProgressNum());
                  });
               });
               BigDecimal reduce = bigDecimals.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
               String bigDecimalPercent1 = getBigDecimalPercent(reduce.divide(BigDecimal.valueOf(s.getProjectSum()), 2, RoundingMode.HALF_UP));
               s.setProjectProgress(s.getCommenceNum()==0?"0%": bigDecimalPercent1);
               s.setPcode(code);
               s.setPname(getname);
               s.setAdGrad("2");
            }});
      return sgStatisProVOS;
      }
      //默认
      else  if (ywxtAdDetail.getAdGrad().equals("1")) {
         updateProjectProgress(sgStatisProVOS, code, getname, "2");
      } else if (ywxtAdDetail.getAdGrad().equals("1")) {//默认
         sgStatisProVOS = sgProjectInfoMapper.getsgStatisticsOne(code);
         sgStatisProVOS.forEach(s->{
            if (s.getCommenceNum() == 0) {
               s.setProjectProgress("0%");
               s.setPcode(ywxtAdDetail.getPAdCode());
               s.setPname(ywxtAdDetail.getPAdName());
               s.setAdGrad("0");
            }else {
            List<String> ids =  sgProjectInfoMapper.getProjectId(ywxtAdDetail.getAdGrad(),s.getCode());
               ids.forEach(id->{
                  projectSearchDTO.setProjectId(id);
                  List<SgProjectInfoVO> list =sgProjectInfoMapper.queryStepByProject(projectSearchDTO);
                  getProjectProgress(list).forEach(ss->{
                     bigDecimals.add(ss.getProjectProgressNum());
                  });
               });
               BigDecimal reduce = bigDecimals.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
               String bigDecimalPercent1 = getBigDecimalPercent(reduce.divide(BigDecimal.valueOf(s.getProjectSum()), 2, RoundingMode.HALF_UP));
               s.setProjectProgress(s.getCommenceNum()==0?"0%": bigDecimalPercent1);
               s.setPcode(ywxtAdDetail.getPAdCode());
               s.setPname(ywxtAdDetail.getPAdName());
               s.setAdGrad("0");
         }});
         updateProjectProgress(sgStatisProVOS, ywxtAdDetail.getPAdCode(), ywxtAdDetail.getPAdName(), "0");
      } else {//区县
         sgStatisProVOS = sgProjectInfoMapper.getsgStatisticsList(code);
         updateProjectProgress(sgStatisProVOS, ywxtAdDetail.getAdCode(), ywxtAdDetail.getAdName(), "3");
      }
         return sgStatisProVOS;
      }
      //区县
         sgStatisProVOS = sgProjectInfoMapper.getsgStatisticsList(code);
      sgStatisProVOS.forEach(s->{
   private void updateProjectProgress(List<SgStatisProVO> sgStatisProVOS, String pcode, String pname, String adGrad) {
      ProjectSearchDTO projectSearchDTO = new ProjectSearchDTO();
      for (SgStatisProVO s : sgStatisProVOS) {
         if (s.getCommenceNum() == 0) {
            s.setProjectProgress("0%");
            s.setPcode(ywxtAdDetail.getAdCode());
            s.setPname(ywxtAdDetail.getAdName());
            s.setAdGrad("3");
            s.setPcode(pcode);
            s.setPname(pname);
            s.setAdGrad(adGrad);
         }else {
            List<String> ids =  sgProjectInfoMapper.getProjectId("3",s.getCode());
            List<String> ids = sgProjectInfoMapper.getProjectId(adGrad, s.getCode());
            List<BigDecimal> bigDecimals = new ArrayList<>();
            ids.forEach(id->{
            for (String id : ids) {
               projectSearchDTO.setProjectId(id);
               List<SgProjectInfoVO> list =sgProjectInfoMapper.queryStepByProject(projectSearchDTO);
               getProjectProgress(list).forEach(ss->{
                  bigDecimals.add(ss.getProjectProgressNum());
               });
            });
               getProjectProgress(list).forEach(ss -> bigDecimals.add(ss.getProjectProgressNum()));
            }
            BigDecimal reduce = bigDecimals.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
            String bigDecimalPercent1 = getBigDecimalPercent(reduce.divide(BigDecimal.valueOf(s.getProjectSum()), 2, RoundingMode.HALF_UP));
            s.setProjectProgress(s.getCommenceNum()==0?"0%": bigDecimalPercent1);
            s.setPcode(ywxtAdDetail.getAdCode());
            s.setPname(ywxtAdDetail.getAdName());
            s.setAdGrad("3");
         }});
      return sgStatisProVOS;
            s.setPcode(pcode);
            s.setPname(pname);
            s.setAdGrad(adGrad);
         }
      }
   }
   @Override
   @Transactional(rollbackFor = Exception.class)
   public List<SgStatistccVO> getsgStatisticscc(String code) {
      AttAdBase ywxtAdDetail = iAttAdBaseService.getYwxtAdDetail(code);
@@ -342,7 +296,7 @@
            BigDecimal bigDecimal = bigDecimals.get(name);
            Integer intValue = mun.get(name);
               BigDecimal result = bigDecimal.divide(new BigDecimal(intValue), 2, BigDecimal.ROUND_HALF_UP);
            BigDecimal result = bigDecimal.divide(new BigDecimal(intValue), 2, RoundingMode.HALF_UP);
            sgdevices.forEach(sgStatistccVO -> {
               if(sgStatistccVO.getTypeName().equals(name)){