| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.moral.api.entity.CityAqiDaily; |
| | | import com.moral.api.mapper.CityAqiDailyMapper; |
| | | import com.moral.api.pojo.dto.dataDisplay.PieChartOfPollutionLevelDTO; |
| | | import com.moral.api.pojo.dto.cityAQI.PieChartOfPollutionLevelVO; |
| | | import com.moral.api.pojo.form.aqi.QueryPieChartOfPollutionLevelForm; |
| | | import com.moral.api.service.CityAqiDailyService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | CityAqiDailyMapper cityAqiDailyMapper; |
| | | |
| | | @Override |
| | | public PieChartOfPollutionLevelDTO queryPieChartOfPollutionLevels(QueryPieChartOfPollutionLevelForm form) { |
| | | public PieChartOfPollutionLevelVO queryPieChartOfPollutionLevels(QueryPieChartOfPollutionLevelForm form) { |
| | | //取参 |
| | | Integer regionCode = form.getRegionCode(); |
| | | Date startDate = form.getStartDate(); |
| | |
| | | List<Map<String,Object>> valueMap = new ArrayList<>(); |
| | | Set<Map.Entry<String, Integer>> entries = pollutionDaysMap.entrySet(); |
| | | Iterator<Map.Entry<String, Integer>> iterator = entries.iterator(); |
| | | Integer totalDays = 0; |
| | | while(iterator.hasNext()){ |
| | | Map.Entry<String, Integer> entry = iterator.next(); |
| | | Map<String,Object> pollutionMap = new HashMap<>(); |
| | |
| | | pollutionMap.put("pollution",pollution); |
| | | pollutionMap.put("days",days); |
| | | valueMap.add(pollutionMap); |
| | | totalDays+=days; |
| | | } |
| | | //封装返回对象 |
| | | PieChartOfPollutionLevelDTO dto = new PieChartOfPollutionLevelDTO(); |
| | | dto.setTime(time); |
| | | dto.setValues(valueMap); |
| | | return dto; |
| | | PieChartOfPollutionLevelVO VO = new PieChartOfPollutionLevelVO(); |
| | | VO.setTime(time); |
| | | VO.setValues(valueMap); |
| | | VO.setTotalDays(totalDays); |
| | | return VO; |
| | | } |
| | | } |