shenyijian
2024-11-01 3fc0f776935df883ee0c8d89c572fc8855b791e8
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgProjectInfoServiceImpl.java
@@ -162,7 +162,7 @@
   public List<SgProjectInfoDO> queryStepByProject(ProjectSearchDTO searchDTO) {
      List<PreAcceVO>  palist = new ArrayList<>();
      List<SgProjectInfoVO> list = sgProjectInfoMapper.queryStepByProject( searchDTO);
      palist.add(handleQuery(25, list.get(0).getId()));
      palist.add(handleQuery(20, list.get(0).getId()));
      palist.add(handleQuery(26, list.get(0).getId()));
      List<SgProjectInfoDO> projectProgress = getProjectProgress(list);
      projectProgress.forEach(s->{
@@ -180,8 +180,11 @@
    */
   @NotNull
   public List<SgProjectInfoDO> getProjectProgress(List<SgProjectInfoVO> list) {
      List<SgProjectInfoVO> sortedList = list.stream()
         .sorted(Comparator.comparing(SgProjectInfoVO::getSort))
         .collect(Collectors.toList());
      //项目分组
      Map<Long, List<SgProjectInfoVO>> projectMap = list.stream().collect(Collectors.groupingBy(SgProjectInfoVO::getId));
      Map<Long, List<SgProjectInfoVO>> projectMap = sortedList.stream().collect(Collectors.groupingBy(SgProjectInfoVO::getId));
      List<SgProjectInfoDO> result = new ArrayList<>();
      for (Map.Entry<Long, List<SgProjectInfoVO>> entry : projectMap.entrySet()) {
         List<SgDeviceDO> allDevice = new ArrayList<>();
@@ -200,7 +203,7 @@
            if (CollectionUtils.isEmpty(ptyValue)){
               continue;
            }
            PtypeVO ptypeVO = PtypeVO.builder().pTypeName(ptyValue.get(0).getPtypeName()).build();
            PtypeVO ptypeVO = PtypeVO.builder().pTypeName(ptyValue.get(0).getPtypeName()).sort(ptyValue.get(0).getSort()).build();
            List<SgTypeVO> sgGxDOS = new ArrayList<>();
            //类型分组
            Map<String, List<SgProjectInfoVO>> GxMap = ptyValue.stream().filter(s->s.getDeviceType()!=null).collect(Collectors.groupingBy(SgProjectInfoVO::getDeviceType));
@@ -210,16 +213,18 @@
               if (CollectionUtils.isEmpty(gxList)){
                  continue;
               }
               SgTypeVO typeVO = SgTypeVO.builder().typeName(gxList.get(0).getTypeName()).build();
               gxList = gxList.stream().sorted(Comparator.comparing(SgProjectInfoVO::getPrice)).collect(Collectors.toList());
               SgTypeVO typeVO = SgTypeVO.builder().typeName(gxList.get(0).getTypeName()).sort(gxList.get(0).getDSort()).build();
               List<SgDeviceDO> deviceDOS = new ArrayList<>();
               //设备分组
               Map<Long, List<SgProjectInfoVO>> dMap = gxList.stream().collect(Collectors.groupingBy(SgProjectInfoVO::getDId));
               Map<Long, List<SgProjectInfoVO>> dMap = gxList.stream().filter(s->s.getDId()!=null).collect(Collectors.groupingBy(SgProjectInfoVO::getDId));
               for (Map.Entry<Long, List<SgProjectInfoVO>> device : dMap.entrySet()) {
                  Long dId = device.getKey();
                  List<SgProjectInfoVO> deList = device.getValue();
                  SgDeviceDO sgDeviceDO = new SgDeviceDO();
                  sgDeviceDO.setId(dId);
                  sgDeviceDO.setDeviceName(deList.get(0).getDeviceName());
                  sgDeviceDO.setPrice(deList.get(0).getPrice());
                  List<SgGxStepDO> stepDOS = deList.stream().filter(s -> s.getReportStatus() == null || (s.getReportStatus() != 4 && !(s.getReportStatus() == 3 && s.getResubmit() != 0))).map(s -> SgGxStepDO.builder().id(s.getStepId()).gxStepNum(s.getGxStepNum()).gxStepName(s.getGxStepName()).deviceId(s.getDId()).approvalStatus(s.getReportStatus()).build()).collect(Collectors.toList());
                  List<SgGxStepDO> stepOver = stepDOS.stream().filter(s -> s.getApprovalStatus() != null && s.getApprovalStatus() == 2).collect(Collectors.toList());
                  BigDecimal stepSize = BigDecimal.valueOf(stepDOS.size());
@@ -239,7 +244,8 @@
               double sum = deviceDOS.stream().mapToDouble(s -> Double.parseDouble(s.getProgress())).sum();
               BigDecimal deviceOver = BigDecimal.valueOf(sum);
               BigDecimal divideDevice = deviceOver.divide(deviceSize, 2, RoundingMode.HALF_UP);
               typeVO.setDeviceDOS(deviceDOS);
               List<SgDeviceDO> sortDeviceDOs = deviceDOS.stream().filter(s->s.getPrice()!=null).sorted(Comparator.comparing(SgDeviceDO::getPrice)).collect(Collectors.toList());
               typeVO.setDeviceDOS(sortDeviceDOs);
               typeVO.setTypeProgress(getBigDecimalPercent(divideDevice));
               typeVO.setProgress(divideDevice.toString());
               sgGxDOS.add(typeVO);
@@ -249,6 +255,7 @@
            BigDecimal sgGxOver = BigDecimal.valueOf(sum);
            BigDecimal divideSgGx = sgGxOver.divide(sgGxSize, 2, RoundingMode.HALF_UP);
            ptypeVO.setPTypeProgress(getBigDecimalPercent(divideSgGx));
            sgGxDOS = sgGxDOS.stream().sorted(Comparator.comparing(SgTypeVO::getSort)).collect(Collectors.toList());
            ptypeVO.setSgTypeVOS(sgGxDOS);
            pTypes.add(ptypeVO);
         }
@@ -257,7 +264,8 @@
            double sum = allDevice.stream().mapToDouble(s -> Double.parseDouble(s.getProgress())).sum();
            BigDecimal allDeviceOver = BigDecimal.valueOf(sum);
            BigDecimal allDivideDevice = allDeviceOver.divide(allDeviceSize, 2, RoundingMode.HALF_UP);
            sgProjectInfoDO.setPtypeVOS(pTypes);
            List<PtypeVO> sortPtpes = pTypes.stream().sorted(Comparator.comparing(PtypeVO::getSort)).collect(Collectors.toList());
            sgProjectInfoDO.setPtypeVOS(sortPtpes);
            sgProjectInfoDO.setProjectProgress( getBigDecimalPercent(allDivideDevice));
            sgProjectInfoDO.setProjectProgressNum(allDivideDevice);
         }
@@ -674,7 +682,7 @@
         SgGxStepDO sgGxStepDO = sgGxStepMapper.selectById(stepIdForNull);
         preAcceVO.setName(sgGxStepDO.getGxStepName());
         preAcceVO.setProgramId(programId);
         preAcceVO.setGxDeviceId(stepIdForNull != 25? (long)998:(long)999);
         preAcceVO.setGxDeviceId(stepIdForNull != 20? (long)998:(long)999);
         preAcceVO.setGxStepId(sgGxStepDO.getId());
      }