| | |
| | | */ |
| | | |
| | | @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); |
| | | 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"); |
| | | |
| | | }}); |
| | | 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)); |
| | | } |
| | | }); |