screen-api/src/main/java/com/moral/api/controller/AqiController.java
@@ -1,7 +1,8 @@ package com.moral.api.controller; import com.moral.api.pojo.dto.cityAQI.BarChartOfPollutionLevelDTO; import com.moral.api.pojo.dto.cityAQI.PieChartOfPollutionLevelDTO; import com.moral.api.pojo.dto.cityAQI.BarChartOfPollutionLevelVO; import com.moral.api.pojo.dto.cityAQI.BarChartTableOfPollutionLevelVO; import com.moral.api.pojo.dto.cityAQI.PieChartOfPollutionLevelVO; import com.moral.api.pojo.form.aqi.QueryPieChartOfPollutionLevelForm; import com.moral.api.service.CityAqiDailyService; @@ -16,10 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.*; import javax.servlet.http.HttpServletRequest; @@ -106,14 +104,14 @@ return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); PieChartOfPollutionLevelDTO dto = cityAqiDailyService.queryPieChartOfPollutionLevels(form); return ResultMessage.ok(dto); PieChartOfPollutionLevelVO VO = cityAqiDailyService.queryPieChartOfPollutionLevels(form); return ResultMessage.ok(VO); } @GetMapping("test1") public ResultMessage test1(){ List<PieChartOfPollutionLevelDTO> dtos = new ArrayList<>(); PieChartOfPollutionLevelDTO dto = new PieChartOfPollutionLevelDTO(); List<PieChartOfPollutionLevelVO> dtos = new ArrayList<>(); PieChartOfPollutionLevelVO dto = new PieChartOfPollutionLevelVO(); dto.setTime("2021-11"); dto.setTotalDays(10); List<Map<String,Object>> list = new ArrayList<>(); @@ -154,7 +152,7 @@ list.add(map5); dto.setValues(list); PieChartOfPollutionLevelDTO dto1 = new PieChartOfPollutionLevelDTO(); PieChartOfPollutionLevelVO dto1 = new PieChartOfPollutionLevelVO(); dto1.setTime("2021-11"); List<Map<String,Object>> list1 = new ArrayList<>(); @@ -203,7 +201,7 @@ @GetMapping("queryBarChartOfPollutionLevel") public ResultMessage queryBarChartOfPollutionLevel(){ BarChartOfPollutionLevelDTO dto = new BarChartOfPollutionLevelDTO(); BarChartOfPollutionLevelVO dto = new BarChartOfPollutionLevelVO(); List<String> time = new ArrayList<>(); time.add("2021-10"); time.add("2021-11"); @@ -273,8 +271,8 @@ days6.add(0); days6.add(0); List<String> proportion6 = new ArrayList<>(); proportion6.add("20%"); proportion6.add("20%"); proportion6.add("0%"); proportion6.add("0%"); map6.put("days",days6); map6.put("proportion",proportion6); @@ -289,6 +287,35 @@ dto.setValues(values); return ResultMessage.ok(dto); } @GetMapping("queryBarChatTableOfPollutionLevel") public ResultMessage queryBarChatTableOfPollutionLevel(){ List<BarChartTableOfPollutionLevelVO> vos = new ArrayList<>(); BarChartTableOfPollutionLevelVO vo1 = new BarChartTableOfPollutionLevelVO(); BarChartTableOfPollutionLevelVO vo2 = new BarChartTableOfPollutionLevelVO(); vo1.setExcellent("4(40%)"); vo1.setGood("1(10%)"); vo1.setMild("1(10%)"); vo1.setMiddle("2(20%)"); vo1.setSerious("2(20%)"); vo1.setServer("0(0%)"); vo1.setTotal("10(100%)"); vo1.setTime("2021年10月"); vo2.setExcellent("6(60%)"); vo2.setGood("0(0%)"); vo2.setMild("0(0%)"); vo2.setMiddle("2(20%)"); vo2.setSerious("2(20%)"); vo2.setServer("0(0%)"); vo2.setTotal("10(100%)"); vo2.setTime("2021年11月"); vos.add(vo1); vos.add(vo2); return ResultMessage.ok(vos); } @GetMapping("provincialRanking") @@ -333,4 +360,5 @@ List<Map<String, Object>> response = cityAqiService.rankingDetails(params); return ResultMessage.ok(response); } } screen-api/src/main/java/com/moral/api/pojo/dto/cityAQI/BarChartOfPollutionLevelVO.java
File was renamed from screen-api/src/main/java/com/moral/api/pojo/dto/cityAQI/BarChartOfPollutionLevelDTO.java @@ -13,7 +13,7 @@ * @Version TODO **/ @Data public class BarChartOfPollutionLevelDTO { public class BarChartOfPollutionLevelVO { /*时间集合*/ List<String> time; @@ -21,6 +21,6 @@ * Map中有三个字段 * pollution表示污染等级 * days存放天数集合 * proportion存放天数占比*/ * proportion存放天数占比的集合*/ List<Map<String,Object>> values; } screen-api/src/main/java/com/moral/api/pojo/dto/cityAQI/BarChartTableOfPollutionLevelVO.java
New file @@ -0,0 +1,53 @@ package com.moral.api.pojo.dto.cityAQI; import lombok.Data; /** * @ClassName BarChartTableOfPollutionLevelVO * @Description 柱状图数据表格的VO * @Author 陈凯裕 * @Date 2021/11/22 9:05 * @Version TODO **/ @Data public class BarChartTableOfPollutionLevelVO { /* * 时间 * */ private String time; /* * 优 * */ private String excellent; /* * 良 * */ private String good; /* * 轻度污染 * */ private String mild; /* * 中度污染 * */ private String middle; /* * 重度污染 * */ private String serious; /* * 严重污染 * */ private String server; /* * 合计 * */ private String total; } screen-api/src/main/java/com/moral/api/pojo/dto/cityAQI/PieChartOfPollutionLevelVO.java
File was renamed from screen-api/src/main/java/com/moral/api/pojo/dto/cityAQI/PieChartOfPollutionLevelDTO.java @@ -13,7 +13,7 @@ * @Version TODO **/ @Data public class PieChartOfPollutionLevelDTO { public class PieChartOfPollutionLevelVO { /*时间格式yyyy-MM-dd 至 yyyy-MM-dd*/ private String time; screen-api/src/main/java/com/moral/api/service/CityAqiDailyService.java
@@ -2,7 +2,7 @@ import com.moral.api.entity.CityAqiDaily; import com.baomidou.mybatisplus.extension.service.IService; import com.moral.api.pojo.dto.cityAQI.PieChartOfPollutionLevelDTO; import com.moral.api.pojo.dto.cityAQI.PieChartOfPollutionLevelVO; import com.moral.api.pojo.form.aqi.QueryPieChartOfPollutionLevelForm; /** @@ -22,6 +22,6 @@ * @Author: 陈凯裕 * @Date: 2021/11/9 */ PieChartOfPollutionLevelDTO queryPieChartOfPollutionLevels(QueryPieChartOfPollutionLevelForm form); PieChartOfPollutionLevelVO queryPieChartOfPollutionLevels(QueryPieChartOfPollutionLevelForm form); } screen-api/src/main/java/com/moral/api/service/impl/CityAqiDailyServiceImpl.java
@@ -4,7 +4,7 @@ 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.cityAQI.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; @@ -32,7 +32,7 @@ CityAqiDailyMapper cityAqiDailyMapper; @Override public PieChartOfPollutionLevelDTO queryPieChartOfPollutionLevels(QueryPieChartOfPollutionLevelForm form) { public PieChartOfPollutionLevelVO queryPieChartOfPollutionLevels(QueryPieChartOfPollutionLevelForm form) { //取参 Integer regionCode = form.getRegionCode(); Date startDate = form.getStartDate(); @@ -93,10 +93,10 @@ totalDays+=days; } //封装返回对象 PieChartOfPollutionLevelDTO dto = new PieChartOfPollutionLevelDTO(); dto.setTime(time); dto.setValues(valueMap); dto.setTotalDays(totalDays); return dto; PieChartOfPollutionLevelVO VO = new PieChartOfPollutionLevelVO(); VO.setTime(time); VO.setValues(valueMap); VO.setTotalDays(totalDays); return VO; } }