| | |
| | | package cn.gistack.sm.sg.service.impl; |
| | | |
| | | import cn.gistack.sm.sg.DO.SgDeviceDO; |
| | | import cn.gistack.sm.sg.DO.SgGxDO; |
| | | import cn.gistack.sm.sg.DO.SgGxStepDO; |
| | | import cn.gistack.sm.sg.DO.SgProjectInfoDO; |
| | | import cn.gistack.sm.sg.DO.*; |
| | | import cn.gistack.sm.sg.DTO.ProjectSearchDTO; |
| | | import cn.gistack.sm.sg.VO.*; |
| | | import cn.gistack.sm.sg.excel.ProjectExcel; |
| | | import cn.gistack.sm.sg.mapper.SgGxStepMapper; |
| | | import cn.gistack.sm.sg.mapper.SgProgressReportMapper; |
| | | import cn.gistack.sm.sg.mapper.SgProjectInfoMapper; |
| | | import cn.gistack.sm.sg.service.SgProjectInfoService; |
| | | import cn.gistack.sm.sjztmd.entity.AttAdBase; |
| | | import cn.gistack.sm.sjztmd.service.IAttAdBaseService; |
| | | import cn.hutool.core.lang.copier.Copier; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | |
| | | private SgProjectInfoMapper sgProjectInfoMapper; |
| | | @Autowired |
| | | private IAttAdBaseService iAttAdBaseService; |
| | | |
| | | @Autowired |
| | | private SgProgressReportMapper sgProgressReportMapper; |
| | | |
| | | @Autowired |
| | | private SgGxStepMapper sgGxStepMapper; |
| | | |
| | | @Override |
| | | public IPage<SgProjectInfoDO> queryPageList(IPage<SgProjectInfoDO> page, ProjectSearchDTO searchDTO) { |
| | | List<SgProjectInfoDO> sgProjectInfoDOS = baseMapper.queryPageList(page,searchDTO); |
| | |
| | | */ |
| | | @Override |
| | | public List<SgProjectInfoDO> queryStepByProject(ProjectSearchDTO searchDTO) { |
| | | List<PreAcceVO> palist = new ArrayList<>(); |
| | | List<SgProjectInfoVO> list = sgProjectInfoMapper.queryStepByProject( searchDTO); |
| | | return getProjectProgress(list); |
| | | palist.add(handleQuery(25, list.get(0).getId())); |
| | | palist.add(handleQuery(26, list.get(0).getId())); |
| | | List<SgProjectInfoDO> projectProgress = getProjectProgress(list); |
| | | projectProgress.forEach(s->{ |
| | | s.setPreAcce(palist); |
| | | }); |
| | | |
| | | |
| | | return projectProgress; |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public List<SgProjectInfoVO> progressList(ProjectSearchDTO searchDTO) { |
| | | List<SgProjectInfoVO> list = new ArrayList<>(); |
| | | List<SgProjectInfoDO> projectProgress = getProjectProgress(sgProjectInfoMapper.queryStepByProject(searchDTO)); |
| | | List<SgProjectInfoDO> projectProgress = new ArrayList<>(); |
| | | if(!searchDTO.getAdCode().isEmpty()){ |
| | | projectProgress = getProjectProgress(sgProjectInfoMapper.queryStepByProject1(searchDTO)); |
| | | }else { |
| | | projectProgress = getProjectProgress(sgProjectInfoMapper.queryStepByProject(searchDTO)); |
| | | } |
| | | |
| | | if (CollectionUtils.isNotEmpty(projectProgress)){ |
| | | projectProgress.forEach(s->{ |
| | | SgProjectInfoVO sgProjectInfoVO = new SgProjectInfoVO(); |
| | |
| | | */ |
| | | @Override |
| | | public IPage<SgProjectInfoVO> progressPage(IPage<SgProjectInfoVO> page, ProjectSearchDTO searchDTO) { |
| | | List<SgProjectInfoVO> list = sgProjectInfoMapper.progressList(page, searchDTO); |
| | | List<SgProjectInfoVO> list = new ArrayList<>(); |
| | | if(!searchDTO.getAdCode().isEmpty()){ |
| | | list = sgProjectInfoMapper.progressList1(page, searchDTO); |
| | | }else { |
| | | list = sgProjectInfoMapper.progressList(page, searchDTO); |
| | | } |
| | | |
| | | List<Long> ids = list.stream().map(SgProjectInfoVO::getId).collect(Collectors.toList()); |
| | | searchDTO.setProjectIds(ids); |
| | | List<SgProjectInfoDO> projectProgress = getProjectProgress(sgProjectInfoMapper.queryStepByProject(searchDTO)); |
| | | List<SgProjectInfoDO> projectProgress = new ArrayList<>(); |
| | | if(!searchDTO.getAdCode().isEmpty()){ |
| | | projectProgress = getProjectProgress(sgProjectInfoMapper.queryStepByProject1(searchDTO)); |
| | | }else { |
| | | projectProgress = getProjectProgress(sgProjectInfoMapper.queryStepByProject(searchDTO)); |
| | | } |
| | | |
| | | if (CollectionUtils.isNotEmpty(projectProgress)){ |
| | | Map<Long, String> progressMap = projectProgress.stream().filter(s->s!=null && s.getProjectProgress() !=null).collect(Collectors.toMap(SgProjectInfoDO::getId, SgProjectInfoDO::getProjectProgress)); |
| | | list.forEach(s->{ |
| | |
| | | */ |
| | | |
| | | @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<>(); |
| | | List<SgStatisProVO> sgStatisProVOS; |
| | | |
| | | ProjectSearchDTO projectSearchDTO = new ProjectSearchDTO(); |
| | | |
| | | //片区 |
| | | if (ywxtAdDetail == null){ |
| | | if (ywxtAdDetail == null) { |
| | | sgStatisProVOS = sgProjectInfoMapper.getsgStatisticsZero(code); |
| | | sgStatisProVOS.forEach(s->{ |
| | | if (s.getCommenceNum() == 0) { |
| | | s.setProjectProgress("0%"); |
| | | s.setPcode("420000000000"); |
| | | s.setPname("湖北省"); |
| | | 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("420000000000"); |
| | | s.setPname("湖北省"); |
| | | s.setAdGrad("2"); |
| | | |
| | | }}); |
| | | return sgStatisProVOS; |
| | | } |
| | | //默认 |
| | | else if (ywxtAdDetail.getAdGrad().equals("1")) { |
| | | String getname = sgProjectInfoMapper.getname(code); |
| | | 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"); |
| | | |
| | | }}); |
| | | return sgStatisProVOS; |
| | | } |
| | | //区县 |
| | | updateProjectProgress(sgStatisProVOS, ywxtAdDetail.getPAdCode(), ywxtAdDetail.getPAdName(), "0"); |
| | | } else {//区县 |
| | | sgStatisProVOS = sgProjectInfoMapper.getsgStatisticsList(code); |
| | | sgStatisProVOS.forEach(s->{ |
| | | updateProjectProgress(sgStatisProVOS, ywxtAdDetail.getAdCode(), ywxtAdDetail.getAdName(), "3"); |
| | | } |
| | | return sgStatisProVOS; |
| | | } |
| | | |
| | | 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"); |
| | | }else { |
| | | List<String> ids = sgProjectInfoMapper.getProjectId("3",s.getCode()); |
| | | s.setPcode(pcode); |
| | | s.setPname(pname); |
| | | s.setAdGrad(adGrad); |
| | | } else { |
| | | 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()); |
| | | }); |
| | | }); |
| | | 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.getAdCode()); |
| | | s.setPname(ywxtAdDetail.getAdName()); |
| | | s.setAdGrad("3"); |
| | | }}); |
| | | return sgStatisProVOS; |
| | | |
| | | s.setProjectProgress(s.getCommenceNum() == 0? "0%" : bigDecimalPercent1); |
| | | 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); |
| | | |
| | | |
| | | List<String> ids = sgProjectInfoMapper.getProjectId(ywxtAdDetail==null?"0":ywxtAdDetail.getAdGrad(),code); |
| | | Map<String,Integer> mun = new HashMap<>(); |
| | | List<SgStatistccVO> sgdevices = sgProjectInfoMapper.getSgdevices(code,ywxtAdDetail==null?"0":ywxtAdDetail.getAdGrad()); |
| | | sgdevices.forEach(sgStatistccVO -> { |
| | | mun.put(sgStatistccVO.getTypeName(),sgStatistccVO.getDeviceNum()); |
| | | } |
| | | ); |
| | | Map<String,BigDecimal> bigDecimals = new HashMap<>(); |
| | | List<String> ids = sgProjectInfoMapper.getProjectId(ywxtAdDetail == null ? "0" : ywxtAdDetail.getAdGrad(), code); |
| | | Map<String, Integer> mun = new HashMap<>(); |
| | | List<SgStatistccVO> sgdevices = sgProjectInfoMapper.getSgdevices(code, ywxtAdDetail == null ? "0" : ywxtAdDetail.getAdGrad()); |
| | | sgdevices.forEach(sgStatistccVO -> { |
| | | mun.put(sgStatistccVO.getTypeName(), sgStatistccVO.getDeviceNum()); |
| | | } |
| | | ); |
| | | Map<String, BigDecimal> bigDecimals = new HashMap<>(); |
| | | ProjectSearchDTO projectSearchDTO = new ProjectSearchDTO(); |
| | | ids.forEach(id->{ |
| | | ids.forEach(id -> { |
| | | |
| | | projectSearchDTO.setProjectId(id); |
| | | List<SgProjectInfoVO> list =sgProjectInfoMapper.queryStepByProject(projectSearchDTO); |
| | | List<SgProjectInfoVO> list = sgProjectInfoMapper.queryStepByProject(projectSearchDTO); |
| | | List<SgProjectInfoDO> projectProgress = getProjectProgress(list); |
| | | projectProgress.forEach(p->{ |
| | | projectProgress.forEach(p -> { |
| | | |
| | | List<SgTypeVO> sgGxDOS = p.getSgGxDOS(); |
| | | sgGxDOS.forEach(sgTypeVO -> { |
| | | String typeProgress = sgTypeVO.getTypeProgress().replace("%", ""); |
| | | BigDecimal percentageBigDecimal = new BigDecimal(typeProgress).divide(new BigDecimal("100"),2, RoundingMode.HALF_UP); |
| | | bigDecimals.merge(sgTypeVO.getTypeName(),percentageBigDecimal,BigDecimal::add); |
| | | BigDecimal percentageBigDecimal = new BigDecimal(typeProgress).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP); |
| | | bigDecimals.merge(sgTypeVO.getTypeName(), percentageBigDecimal, BigDecimal::add); |
| | | }); |
| | | |
| | | }); |
| | |
| | | |
| | | 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)){ |
| | | if (sgStatistccVO.getTypeName().equals(name)) { |
| | | sgStatistccVO.setTypeProgress(getBigDecimalPercent(result)); |
| | | } |
| | | }); |
| | |
| | | |
| | | } |
| | | |
| | | // 处理查询和添加到列表的方法 |
| | | private PreAcceVO handleQuery( int stepIdForNull, Long programId) { |
| | | QueryWrapper<SgProgressReportDO> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("gx_step_id", stepIdForNull) |
| | | .eq("profram_id", programId); |
| | | SgProgressReportDO sgProgressReportDO = sgProgressReportMapper.selectOne(queryWrapper); |
| | | |
| | | PreAcceVO preAcceVO = new PreAcceVO(); |
| | | if (sgProgressReportDO!= null) { |
| | | preAcceVO.setId(sgProgressReportDO.getId().toString()); |
| | | preAcceVO.setName(sgProgressReportDO.getGxStepName()); |
| | | preAcceVO.setStatus((long) sgProgressReportDO.getStatus()); |
| | | preAcceVO.setProgramId(programId); |
| | | preAcceVO.setGxDeviceId(sgProgressReportDO.getGxDeviceId()); |
| | | preAcceVO.setGxStepId(sgProgressReportDO.getGxStepId()); |
| | | } else { |
| | | SgGxStepDO sgGxStepDO = sgGxStepMapper.selectById(stepIdForNull); |
| | | preAcceVO.setName(sgGxStepDO.getGxStepName()); |
| | | preAcceVO.setProgramId(programId); |
| | | preAcceVO.setGxDeviceId(stepIdForNull != 25? (long)998:(long)999); |
| | | preAcceVO.setGxStepId(sgGxStepDO.getId()); |
| | | |
| | | } |
| | | return preAcceVO; |
| | | |
| | | } |
| | | |
| | | } |