shenyijian
2024-06-21 f20611265f7d34fd4fbcdfdaff6cb9cccd0b25fc
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/service/impl/SgProjectInfoServiceImpl.java
@@ -11,6 +11,7 @@
import cn.gistack.sm.sg.service.SgProjectInfoService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
@@ -54,7 +55,8 @@
         if (CollectionUtils.isEmpty(value)){
            continue;
         }
         SgProjectInfoDO sgProjectInfoDO = SgProjectInfoDO.builder().id(porId).projectName(value.get(0).getProjectName()).build();
         SgProjectInfoVO sgProjectInfoVO = value.get(0);
         SgProjectInfoDO sgProjectInfoDO = SgProjectInfoDO.builder().id(porId).status(sgProjectInfoVO.getProjectStatus()).projectName(sgProjectInfoVO.getProjectName()).build();
         List<SgTypeVO> sgGxDOS = new ArrayList<>();
         //类型分组
         Map<String, List<SgProjectInfoVO>> GxMap = value.stream().filter(s->s.getDeviceType()!=null).collect(Collectors.groupingBy(SgProjectInfoVO::getDeviceType));
@@ -74,7 +76,8 @@
               SgDeviceDO sgDeviceDO = new SgDeviceDO();
               sgDeviceDO.setId(dId);
               sgDeviceDO.setDeviceName(deList.get(0).getDeviceName());
               sgDeviceDO.setStepDOList(deList.stream().map(s->SgGxStepDO.builder().gxStepName(s.getGxStepName()).approvalStatus(s.getSTATUS()).build()).collect(Collectors.toList()));
               sgDeviceDO.setStatus(   deList.get(0).getDeviceStatus());
               sgDeviceDO.setStepDOList(deList.stream().map(s->SgGxStepDO.builder().id(s.getReportId()).gxStepNum(s.getGxStepNum()).gxStepName(s.getGxStepName()).deviceId(s.getDId()).approvalStatus(s.getReportStatus()).build()).collect(Collectors.toList()));
               deviceDOS.add(sgDeviceDO);
            }
            typeVO.setDeviceDOS(deviceDOS);
@@ -105,7 +108,7 @@
            v1 = BigDecimal.valueOf(overList.size());
         }
         BigDecimal v2 = BigDecimal.valueOf(deviceList.size());
         BigDecimal percentage = v1.divide(v2).multiply(new BigDecimal("100"));
         BigDecimal percentage = v1.divide(v2,2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
         // 如果不需要保留小数位,可以设置一个scale为0
         BigDecimal percentageRounded = percentage.setScale(0, RoundingMode.HALF_UP);
         sgProjectInfoVO.setProgressName(percentageRounded+"%");
@@ -117,7 +120,16 @@
   @Override
   public Map<String, Long> projectCount(ProjectSearchDTO searchDTO) {
      Map<String, Long> map  = new HashMap<>();
      List<SgProjectInfoDO> list = new LambdaQueryChainWrapper<>(sgProjectInfoMapper).list();
      LambdaQueryChainWrapper<SgProjectInfoDO> wrapper = new LambdaQueryChainWrapper<>(sgProjectInfoMapper);
      String projectName = searchDTO.getProjectName();
      Integer status = searchDTO.getStatus();
      if (StringUtils.isNotBlank(projectName)){
         wrapper.like(SgProjectInfoDO::getProjectName,searchDTO.getProjectName());
      }
      if (status!=null){
         wrapper.eq(SgProjectInfoDO::getStatus,searchDTO.getStatus());
      }
      List<SgProjectInfoDO> list = wrapper.list();
      List<SgProjectInfoDO> pending = list.stream().filter(s -> s.getStatus() == 0).collect(Collectors.toList());
      List<SgProjectInfoDO> progress = list.stream().filter(s -> s.getStatus() == 1).collect(Collectors.toList());
      List<SgProjectInfoDO> over = list.stream().filter(s -> s.getStatus() == 2).collect(Collectors.toList());