| | |
| | | import cn.gistack.sm.sg.DO.SgGxStepDO; |
| | | import cn.gistack.sm.sg.DO.SgProjectInfoDO; |
| | | import cn.gistack.sm.sg.DTO.ProjectSearchDTO; |
| | | import cn.gistack.sm.sg.VO.SgProjectInfoVO; |
| | | import cn.gistack.sm.sg.VO.SgTypeVO; |
| | | import cn.gistack.sm.sg.VO.*; |
| | | import cn.gistack.sm.sg.excel.ProjectExcel; |
| | | 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.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.StopWatch; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.MathContext; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | |
| | | public class SgProjectInfoServiceImpl extends ServiceImpl<SgProjectInfoMapper, SgProjectInfoDO> implements SgProjectInfoService { |
| | | @Autowired |
| | | private SgProjectInfoMapper sgProjectInfoMapper; |
| | | @Autowired |
| | | private IAttAdBaseService iAttAdBaseService; |
| | | @Override |
| | | public IPage<SgProjectInfoDO> queryPageList(IPage<SgProjectInfoDO> page, ProjectSearchDTO searchDTO) { |
| | | List<SgProjectInfoDO> sgProjectInfoDOS = baseMapper.queryPageList(page,searchDTO); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 项目统计饼状图 |
| | | * @param code |
| | | * @return |
| | | */ |
| | | @Override |
| | | public SgStatisticsVO getsgStatistics(String code) { |
| | | AttAdBase ywxtAdDetail = iAttAdBaseService.getYwxtAdDetail(code); |
| | | |
| | | if (ywxtAdDetail == null){ |
| | | return sgProjectInfoMapper.getSgstatiss("0",code); |
| | | } |
| | | return sgProjectInfoMapper.getSgstatiss(ywxtAdDetail.getAdGrad(),code); |
| | | } |
| | | |
| | | /** |
| | | * 项目统计表格 |
| | | * @param code |
| | | * @return |
| | | */ |
| | | |
| | | @Override |
| | | @Transactional |
| | | 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); |
| | | 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")) { |
| | | 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; |
| | | } |
| | | //区县 |
| | | sgStatisProVOS = sgProjectInfoMapper.getsgStatisticsList(code); |
| | | sgStatisProVOS.forEach(s->{ |
| | | 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()); |
| | | |
| | | 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.getAdCode()); |
| | | s.setPname(ywxtAdDetail.getAdName()); |
| | | s.setAdGrad("3"); |
| | | }}); |
| | | return sgStatisProVOS; |
| | | |
| | | } |
| | | |
| | | @Override |
| | | 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<>(); |
| | | ProjectSearchDTO projectSearchDTO = new ProjectSearchDTO(); |
| | | ids.forEach(id->{ |
| | | |
| | | projectSearchDTO.setProjectId(id); |
| | | List<SgProjectInfoVO> list =sgProjectInfoMapper.queryStepByProject(projectSearchDTO); |
| | | List<SgProjectInfoDO> projectProgress = getProjectProgress(list); |
| | | 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); |
| | | }); |
| | | |
| | | }); |
| | | |
| | | }); |
| | | |
| | | for (String name : bigDecimals.keySet()) { |
| | | |
| | | if (mun.containsKey(name)) { |
| | | |
| | | BigDecimal bigDecimal = bigDecimals.get(name); |
| | | Integer intValue = mun.get(name); |
| | | BigDecimal result = bigDecimal.divide(new BigDecimal(intValue), 2, BigDecimal.ROUND_HALF_UP); |
| | | |
| | | sgdevices.forEach(sgStatistccVO -> { |
| | | if(sgStatistccVO.getTypeName().equals(name)){ |
| | | sgStatistccVO.setTypeProgress(getBigDecimalPercent(result)); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| | | |
| | | return sgdevices; |
| | | } |
| | | |
| | | /** |
| | | * 获取百分比 |
| | | * @param bigDecimal |
| | | * @return |