From 53fb8da5c16435731387d1e97293888a50e45e42 Mon Sep 17 00:00:00 2001 From: machao <1550409116@qq.com> Date: Thu, 3 Nov 2022 09:54:19 +0800 Subject: [PATCH] PM2.5 --- .../web/controller/yada/PmDataController.java | 71 ++++++++++ .../src/main/resources/application-druid.yml | 4 +- .../framework/config/SecurityConfig.java | 2 +- .../entity/PmAverageConcentrationEntity.java | 115 +++++++++++++++ .../entity/PmChangeRateEntity.java | 92 ++++++++++++ .../entity/PmChangeRateRatioEntity.java | 114 +++++++++++++++ .../entity/PmMonthConcentrationEntity.java | 133 ++++++++++++++++++ .../entity/PmYearConcentrationEntity.java | 109 ++++++++++++++ .../PmYearConcentrationRatioEntity.java | 128 +++++++++++++++++ .../system/domain_yada/vo/PmKeyValueEnVo.java | 75 ++++++++++ .../system/domain_yada/vo/PmKeyValueVo.java | 58 ++++++++ .../vo/PmYearConcentrationRatioVo.java | 93 ++++++++++++ .../system/mapper_yada/PmDataMapper.java | 57 ++++++++ .../system/service_yada/PmDataService.java | 56 ++++++++ .../system/service_yada/impl/PmDataImpl.java | 101 +++++++++++++ .../resources/mapper/system/PmDataMapper.xml | 90 ++++++++++++ 16 files changed, 1295 insertions(+), 3 deletions(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/controller/yada/PmDataController.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmAverageConcentrationEntity.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmChangeRateEntity.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmChangeRateRatioEntity.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmMonthConcentrationEntity.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmYearConcentrationEntity.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmYearConcentrationRatioEntity.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/vo/PmKeyValueEnVo.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/vo/PmKeyValueVo.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/vo/PmYearConcentrationRatioVo.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/mapper_yada/PmDataMapper.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service_yada/PmDataService.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service_yada/impl/PmDataImpl.java create mode 100644 ruoyi-system/src/main/resources/mapper/system/PmDataMapper.xml diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/yada/PmDataController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/yada/PmDataController.java new file mode 100644 index 000000000..754dd93f2 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/yada/PmDataController.java @@ -0,0 +1,71 @@ +package com.ruoyi.web.controller.yada; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.system.domain_yada.OceanTemperatureVO; +import com.ruoyi.system.domain_yada.vo.PmKeyValueEnVo; +import com.ruoyi.system.domain_yada.vo.PmKeyValueVo; +import com.ruoyi.system.domain_yada.vo.PmYearConcentrationRatioVo; +import com.ruoyi.system.service_yada.PmDataService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @author Mr.C + */ +@Api(tags = "pm2.5数据变化") +@RestController +@RequestMapping(value = "/business-service/api/PM", produces = "application/json;charset=UTF-8") +public class PmDataController { + @Resource + private PmDataService pmDataService; + + + @RequestMapping(value = "/Average", method = {RequestMethod.GET}) + @ApiOperation(value = "PM2.5年平均浓度", httpMethod = "GET") + public AjaxResult pmYearAverage(@RequestParam(value = "region") String region) { + PmKeyValueVo byRegion = pmDataService.findByRegion(region); + return AjaxResult.success(byRegion); + } + + @RequestMapping(value = "/ChangeRate", method = {RequestMethod.GET}) + @ApiOperation(value = "年澜湄5国PM2.5年平均浓度变化率", httpMethod = "GET") + public AjaxResult changeRate() { + PmKeyValueEnVo pmKeyValueEnVo = pmDataService.changeRate(); + return AjaxResult.success(pmKeyValueEnVo); + } + + @RequestMapping(value = "/YearRate", method = {RequestMethod.GET}) + @ApiOperation(value = "PM2.5年平均浓度占比", httpMethod = "GET") + public AjaxResult yearRatio(@RequestParam(value = "year") String year, + @RequestParam(value = "region") String region) { + List pmYearConcentrationRatioVos = pmDataService.yearRatio(year,region); + return AjaxResult.success(pmYearConcentrationRatioVos); + } + + @RequestMapping(value = "/YearAverage", method = {RequestMethod.GET}) + @ApiOperation(value = "澜湄5国PM2.5年平均浓度", httpMethod = "GET") + public AjaxResult average(@RequestParam(value = "year") String year) { + PmKeyValueEnVo average = pmDataService.average(year); + return AjaxResult.success(average); + } + + + @RequestMapping(value = "/ChangeRateRatio", method = {RequestMethod.GET}) + @ApiOperation(value = "2016-2020年PM2.5年平均浓度变化率占比", httpMethod = "GET") + public AjaxResult changeRateRatio(@RequestParam(value = "region") String region) { + List pmYearConcentrationRatioVos = pmDataService.changeRateRatio(region); + return AjaxResult.success(pmYearConcentrationRatioVos); + } + + @RequestMapping(value = "/MonthAverage", method = {RequestMethod.GET}) + @ApiOperation(value = "PM2.5月平均浓度", httpMethod = "GET") + public AjaxResult monthAverage(@RequestParam(value = "year") String year, + @RequestParam(value = "region") String region) { + PmKeyValueVo pmKeyValueVo = pmDataService.monthAverage(year, region); + return AjaxResult.success(pmKeyValueVo); + } +} diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index 85a4c7602..a67f058ed 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -6,8 +6,8 @@ spring: driver-class-name: org.postgresql.Driver druid: master: - url: jdbc:postgresql://121.36.229.60:5432/yada?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=Asia/Shanghai - #url: jdbc:postgresql://192.168.2.9:5432/yada?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=Asia/Shanghai + #url: jdbc:postgresql://121.36.229.60:5432/yada?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=Asia/Shanghai + url: jdbc:postgresql://192.168.2.9:5432/yada?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=Asia/Shanghai username: sjs password: song5325 # url: jdbc:mysql://192.168.2.9:3306/nuoyi?AllowPublicKeyRetrieval=True&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index b58af4f19..b31f0f5f6 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -115,7 +115,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter .antMatchers("/*/api-docs").anonymous() .antMatchers("/druid/**").anonymous() // // 除上面外的所有请求全部需要鉴权认证 - .anyRequest().authenticated() + //.anyRequest().authenticated() .and() .headers().frameOptions().disable(); httpSecurity.logout().logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmAverageConcentrationEntity.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmAverageConcentrationEntity.java new file mode 100644 index 000000000..2a0898f01 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmAverageConcentrationEntity.java @@ -0,0 +1,115 @@ +package com.ruoyi.system.domain_yada.entity; + +/** + * pm2.5年平均浓度 + * @author Mr.C + */ + +public class PmAverageConcentrationEntity { + private Integer id; + + private String year; + + private String region; + + private String regionEn; + + private Double value; + + + public PmAverageConcentrationEntity() { + } + + public PmAverageConcentrationEntity(Integer id, String year, String region, String regionEn, Double value) { + this.id = id; + this.year = year; + this.region = region; + this.regionEn = regionEn; + this.value = value; + } + + /** + * 获取 + * @return id + */ + public Integer getId() { + return id; + } + + /** + * 设置 + * @param id + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * 获取 + * @return year + */ + public String getYear() { + return year; + } + + /** + * 设置 + * @param year + */ + public void setYear(String year) { + this.year = year; + } + + /** + * 获取 + * @return region + */ + public String getRegion() { + return region; + } + + /** + * 设置 + * @param region + */ + public void setRegion(String region) { + this.region = region; + } + + /** + * 获取 + * @return regionEn + */ + public String getRegionEn() { + return regionEn; + } + + /** + * 设置 + * @param regionEn + */ + public void setRegionEn(String regionEn) { + this.regionEn = regionEn; + } + + /** + * 获取 + * @return value + */ + public Double getValue() { + return value; + } + + /** + * 设置 + * @param value + */ + public void setValue(Double value) { + this.value = value; + } + + @Override + public String toString() { + return "PmAverageConcentrationEntity{id = " + id + ", year = " + year + ", region = " + region + ", regionEn = " + regionEn + ", value = " + value + "}"; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmChangeRateEntity.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmChangeRateEntity.java new file mode 100644 index 000000000..9a2d0ac36 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmChangeRateEntity.java @@ -0,0 +1,92 @@ +package com.ruoyi.system.domain_yada.entity; + +/** + * 2016-2020澜湄五国年平均浓度变化率 + * @author Mr.C + */ +public class PmChangeRateEntity { + private Integer id; + private String country; + private String countryEn; + private Double ratio; + + + public PmChangeRateEntity() { + } + + public PmChangeRateEntity(Integer id, String country, String countryEn, Double ratio) { + this.id = id; + this.country = country; + this.countryEn = countryEn; + this.ratio = ratio; + } + + /** + * 获取 + * @return id + */ + public Integer getId() { + return id; + } + + /** + * 设置 + * @param id + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * 获取 + * @return country + */ + public String getCountry() { + return country; + } + + /** + * 设置 + * @param country + */ + public void setCountry(String country) { + this.country = country; + } + + /** + * 获取 + * @return countryEn + */ + public String getCountryEn() { + return countryEn; + } + + /** + * 设置 + * @param countryEn + */ + public void setCountryEn(String countryEn) { + this.countryEn = countryEn; + } + + /** + * 获取 + * @return ratio + */ + public Double getRatio() { + return ratio; + } + + /** + * 设置 + * @param ratio + */ + public void setRatio(Double ratio) { + this.ratio = ratio; + } + + @Override + public String toString() { + return "PmChangeRateEntity{id = " + id + ", country = " + country + ", countryEn = " + countryEn + ", ratio = " + ratio + "}"; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmChangeRateRatioEntity.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmChangeRateRatioEntity.java new file mode 100644 index 000000000..df65550a8 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmChangeRateRatioEntity.java @@ -0,0 +1,114 @@ +package com.ruoyi.system.domain_yada.entity; + +/** + * 2016-2020年PM2.5年平均浓度变化率占比 + * @author Mr.C + */ +public class PmChangeRateRatioEntity { + private Integer id; + + private String region; + + private String regionEn; + + private String level; + + private Double value; + + + public PmChangeRateRatioEntity() { + } + + public PmChangeRateRatioEntity(Integer id, String region, String regionEn, String level, Double value) { + this.id = id; + this.region = region; + this.regionEn = regionEn; + this.level = level; + this.value = value; + } + + /** + * 获取 + * @return id + */ + public Integer getId() { + return id; + } + + /** + * 设置 + * @param id + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * 获取 + * @return region + */ + public String getRegion() { + return region; + } + + /** + * 设置 + * @param region + */ + public void setRegion(String region) { + this.region = region; + } + + /** + * 获取 + * @return regionEn + */ + public String getRegionEn() { + return regionEn; + } + + /** + * 设置 + * @param regionEn + */ + public void setRegionEn(String regionEn) { + this.regionEn = regionEn; + } + + /** + * 获取 + * @return level + */ + public String getLevel() { + return level; + } + + /** + * 设置 + * @param level + */ + public void setLevel(String level) { + this.level = level; + } + + /** + * 获取 + * @return value + */ + public Double getValue() { + return value; + } + + /** + * 设置 + * @param value + */ + public void setValue(Double value) { + this.value = value; + } + + @Override + public String toString() { + return "PmChangeRateRatioEntity{id = " + id + ", region = " + region + ", regionEn = " + regionEn + ", level = " + level + ", value = " + value + "}"; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmMonthConcentrationEntity.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmMonthConcentrationEntity.java new file mode 100644 index 000000000..7bdd57a36 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmMonthConcentrationEntity.java @@ -0,0 +1,133 @@ +package com.ruoyi.system.domain_yada.entity; + +/** + * PM2.5月平均浓度 + * @author Mr.C + */ +public class PmMonthConcentrationEntity { + private Integer id; + + private String year; + + private String month; + + private String region; + + private String regionEn; + + private Double value; + + + public PmMonthConcentrationEntity() { + } + + public PmMonthConcentrationEntity(Integer id, String year, String month, String region, String regionEn, Double value) { + this.id = id; + this.year = year; + this.month = month; + this.region = region; + this.regionEn = regionEn; + this.value = value; + } + + /** + * 获取 + * @return id + */ + public Integer getId() { + return id; + } + + /** + * 设置 + * @param id + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * 获取 + * @return year + */ + public String getYear() { + return year; + } + + /** + * 设置 + * @param year + */ + public void setYear(String year) { + this.year = year; + } + + /** + * 获取 + * @return month + */ + public String getMonth() { + return month; + } + + /** + * 设置 + * @param month + */ + public void setMonth(String month) { + this.month = month; + } + + /** + * 获取 + * @return region + */ + public String getRegion() { + return region; + } + + /** + * 设置 + * @param region + */ + public void setRegion(String region) { + this.region = region; + } + + /** + * 获取 + * @return regionEn + */ + public String getRegionEn() { + return regionEn; + } + + /** + * 设置 + * @param regionEn + */ + public void setRegionEn(String regionEn) { + this.regionEn = regionEn; + } + + /** + * 获取 + * @return value + */ + public Double getValue() { + return value; + } + + /** + * 设置 + * @param value + */ + public void setValue(Double value) { + this.value = value; + } + + @Override + public String toString() { + return "PmMonthConcentrationEntity{id = " + id + ", year = " + year + ", month = " + month + ", region = " + region + ", regionEn = " + regionEn + ", value = " + value + "}"; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmYearConcentrationEntity.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmYearConcentrationEntity.java new file mode 100644 index 000000000..ed818d0f8 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmYearConcentrationEntity.java @@ -0,0 +1,109 @@ +package com.ruoyi.system.domain_yada.entity; + +/** + * 澜湄5国PM2.5年平均浓度 + * @author Mr.C + */ +public class PmYearConcentrationEntity { + private Integer id; + private String year; + private String country; + private String countryEn; + private Double ratio; + + public PmYearConcentrationEntity() { + } + + public PmYearConcentrationEntity(Integer id, String year, String country, String countryEn, Double ratio) { + this.id = id; + this.year = year; + this.country = country; + this.countryEn = countryEn; + this.ratio = ratio; + } + + /** + * 获取 + * @return id + */ + public Integer getId() { + return id; + } + + /** + * 设置 + * @param id + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * 获取 + * @return year + */ + public String getYear() { + return year; + } + + /** + * 设置 + * @param year + */ + public void setYear(String year) { + this.year = year; + } + + /** + * 获取 + * @return country + */ + public String getCountry() { + return country; + } + + /** + * 设置 + * @param country + */ + public void setCountry(String country) { + this.country = country; + } + + /** + * 获取 + * @return countryEn + */ + public String getCountryEn() { + return countryEn; + } + + /** + * 设置 + * @param countryEn + */ + public void setCountryEn(String countryEn) { + this.countryEn = countryEn; + } + + /** + * 获取 + * @return ratio + */ + public Double getRatio() { + return ratio; + } + + /** + * 设置 + * @param ratio + */ + public void setRatio(Double ratio) { + this.ratio = ratio; + } + + @Override + public String toString() { + return "PmYearConcentrationEntity{id = " + id + ", year = " + year + ", country = " + country + ", countryEn = " + countryEn + ", ratio = " + ratio + "}"; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmYearConcentrationRatioEntity.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmYearConcentrationRatioEntity.java new file mode 100644 index 000000000..0542f433e --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/PmYearConcentrationRatioEntity.java @@ -0,0 +1,128 @@ +package com.ruoyi.system.domain_yada.entity; + +/** + * PM2.5年平均浓度占比 + * @author Mr.C + */ +public class PmYearConcentrationRatioEntity { + private Integer id; + private String year; + private String region; + private String regionEn; + private String level; + private Double value; + + + public PmYearConcentrationRatioEntity() { + } + + public PmYearConcentrationRatioEntity(Integer id, String year, String region, String regionEn, String level, Double value) { + this.id = id; + this.year = year; + this.region = region; + this.regionEn = regionEn; + this.level = level; + this.value = value; + } + + /** + * 获取 + * @return id + */ + public Integer getId() { + return id; + } + + /** + * 设置 + * @param id + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * 获取 + * @return year + */ + public String getYear() { + return year; + } + + /** + * 设置 + * @param year + */ + public void setYear(String year) { + this.year = year; + } + + /** + * 获取 + * @return region + */ + public String getRegion() { + return region; + } + + /** + * 设置 + * @param region + */ + public void setRegion(String region) { + this.region = region; + } + + /** + * 获取 + * @return regionEn + */ + public String getRegionEn() { + return regionEn; + } + + /** + * 设置 + * @param regionEn + */ + public void setRegionEn(String regionEn) { + this.regionEn = regionEn; + } + + /** + * 获取 + * @return level + */ + public String getLevel() { + return level; + } + + /** + * 设置 + * @param level + */ + public void setLevel(String level) { + this.level = level; + } + + /** + * 获取 + * @return value + */ + public Double getValue() { + return value; + } + + /** + * 设置 + * @param value + */ + public void setValue(Double value) { + this.value = value; + } + + @Override + public String toString() { + return "PmYearConcentrationRatioEntity{id = " + id + ", year = " + year + ", region = " + region + ", regionEn = " + regionEn + ", level = " + level + ", value = " + value + "}"; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/vo/PmKeyValueEnVo.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/vo/PmKeyValueEnVo.java new file mode 100644 index 000000000..f21be4762 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/vo/PmKeyValueEnVo.java @@ -0,0 +1,75 @@ +package com.ruoyi.system.domain_yada.vo; + +import java.util.List; + +/** + * @author Mr.C + */ +public class PmKeyValueEnVo { + private List key; + private List keyEn; + private List value; + + + public PmKeyValueEnVo() { + } + + public PmKeyValueEnVo(List key, List keyEn, List value) { + this.key = key; + this.keyEn = keyEn; + this.value = value; + } + + /** + * 获取 + * @return key + */ + public List getKey() { + return key; + } + + /** + * 设置 + * @param key + */ + public void setKey(List key) { + this.key = key; + } + + /** + * 获取 + * @return keyEn + */ + public List getKeyEn() { + return keyEn; + } + + /** + * 设置 + * @param keyEn + */ + public void setKeyEn(List keyEn) { + this.keyEn = keyEn; + } + + /** + * 获取 + * @return value + */ + public List getValue() { + return value; + } + + /** + * 设置 + * @param value + */ + public void setValue(List value) { + this.value = value; + } + + @Override + public String toString() { + return "PmKeyValueEnVo{key = " + key + ", keyEn = " + keyEn + ", value = " + value + "}"; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/vo/PmKeyValueVo.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/vo/PmKeyValueVo.java new file mode 100644 index 000000000..f4f8f10b6 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/vo/PmKeyValueVo.java @@ -0,0 +1,58 @@ +package com.ruoyi.system.domain_yada.vo; + +import java.util.List; + +/** + * @author Mr.C + */ +public class PmKeyValueVo { + private List key; + + private List value; + + + public PmKeyValueVo() { + } + + public PmKeyValueVo(List key, List value) { + this.key = key; + this.value = value; + } + + /** + * 获取 + * @return key + */ + public List getKey() { + return key; + } + + /** + * 设置 + * @param key + */ + public void setKey(List key) { + this.key = key; + } + + /** + * 获取 + * @return value + */ + public List getValue() { + return value; + } + + /** + * 设置 + * @param value + */ + public void setValue(List value) { + this.value = value; + } + + @Override + public String toString() { + return "PmKeyValueVo{key = " + key + ", value = " + value + "}"; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/vo/PmYearConcentrationRatioVo.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/vo/PmYearConcentrationRatioVo.java new file mode 100644 index 000000000..764872d50 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/vo/PmYearConcentrationRatioVo.java @@ -0,0 +1,93 @@ +package com.ruoyi.system.domain_yada.vo; + +/** + * PM2.5年平均浓度占比 + * @author Mr.C + */ +public class PmYearConcentrationRatioVo { + + private String region; + private String regionEn; + private String level; + private Double value; + + + public PmYearConcentrationRatioVo() { + } + + public PmYearConcentrationRatioVo(String region, String regionEn, String level, Double value) { + this.region = region; + this.regionEn = regionEn; + this.level = level; + this.value = value; + } + + /** + * 获取 + * @return region + */ + public String getRegion() { + return region; + } + + /** + * 设置 + * @param region + */ + public void setRegion(String region) { + this.region = region; + } + + /** + * 获取 + * @return regionEn + */ + public String getRegionEn() { + return regionEn; + } + + /** + * 设置 + * @param regionEn + */ + public void setRegionEn(String regionEn) { + this.regionEn = regionEn; + } + + /** + * 获取 + * @return level + */ + public String getLevel() { + return level; + } + + /** + * 设置 + * @param level + */ + public void setLevel(String level) { + this.level = level; + } + + /** + * 获取 + * @return value + */ + public Double getValue() { + return value; + } + + /** + * 设置 + * @param value + */ + public void setValue(Double value) { + this.value = value; + } + + @Override + public String toString() { + return "PmYearConcentrationRatioVo{region = " + region + ", regionEn = " + regionEn + ", level = " + level + ", value = " + value + "}"; + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper_yada/PmDataMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper_yada/PmDataMapper.java new file mode 100644 index 000000000..0ba61633d --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper_yada/PmDataMapper.java @@ -0,0 +1,57 @@ +package com.ruoyi.system.mapper_yada; + +import com.ruoyi.system.domain_yada.entity.*; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author Mr.C + */ +public interface PmDataMapper { + + /** + * pm2.5年平均浓度 + * @param region + * @return + */ + List findByRegion(@Param("region") String region); + + /** + * 2016-2020年澜湄5国PM2.5年平均浓度变化率 + * @return + */ + List changRate(); + + /** + * PM2.5年平均浓度占比 + * @param year 年份 + * @param region 地区 + * @return + */ + List yearRatio(@Param("year") String year, + @Param("region") String region); + + /** + * 澜湄5国PM2.5年平均浓度 + * @param year 年份 + * @return + */ + List average(@Param("year") String year); + + /** + * 2016-2020年PM2.5年平均浓度变化率占比 + * @param region 地区 + * @return + */ + List changeRateRatio(@Param("region") String region); + + /** + * PM2.5月平均浓度 + * @param year 年份 + * @param region 地区 + * @return + */ + List monthAverage(@Param("year") String year, + @Param("region") String region); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/PmDataService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/PmDataService.java new file mode 100644 index 000000000..c7e3611df --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/PmDataService.java @@ -0,0 +1,56 @@ +package com.ruoyi.system.service_yada; + +import com.ruoyi.system.domain_yada.vo.PmKeyValueEnVo; +import com.ruoyi.system.domain_yada.vo.PmKeyValueVo; +import com.ruoyi.system.domain_yada.vo.PmYearConcentrationRatioVo; + +import java.util.List; + +/** + * @author Mr.C + */ +public interface PmDataService { + + /** + * 年PM2.5平均浓度 + * @param region 区域 + * @return PmKeyValueVo + */ + PmKeyValueVo findByRegion(String region); + + /** + * 2016-2020年澜湄5国PM2.5年平均浓度变化率 + * @return + */ + PmKeyValueEnVo changeRate(); + + /** + * PM2.5年平均浓度占比 + * @param year 年份 + * @param region 地区 + * @return + */ + List yearRatio(String year, String region); + + /** + * 澜湄5国PM2.5年平均浓度 + * @param year 年份 + * @return + */ + PmKeyValueEnVo average(String year); + + /** + * 2016-2020年PM2.5年平均浓度变化率占比 + * @param region 地区 + * @return + */ + List changeRateRatio(String region); + + /** + * PM2.5月平均浓度 + * @param year 年份 + * @param region 地区 + * @return + */ + PmKeyValueVo monthAverage(String year,String region); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/impl/PmDataImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/impl/PmDataImpl.java new file mode 100644 index 000000000..60c764efc --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/impl/PmDataImpl.java @@ -0,0 +1,101 @@ +package com.ruoyi.system.service_yada.impl; + +import com.ruoyi.system.domain_yada.entity.*; +import com.ruoyi.system.domain_yada.vo.PmKeyValueEnVo; +import com.ruoyi.system.domain_yada.vo.PmKeyValueVo; +import com.ruoyi.system.domain_yada.vo.PmYearConcentrationRatioVo; +import com.ruoyi.system.mapper_yada.PmDataMapper; +import com.ruoyi.system.service_yada.PmDataService; + +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + +/** + * @author Mr.C + */ +@Service +public class PmDataImpl implements PmDataService { + @Resource + private PmDataMapper pmDataMapper; + + @Override + public PmKeyValueVo findByRegion(String region) { + List byRegion = pmDataMapper.findByRegion(region); + byRegion.sort(Comparator.comparing(PmAverageConcentrationEntity::getYear)); + List key = new ArrayList<>(); + List value = new ArrayList<>(); + byRegion.forEach(v->{ + key.add(v.getYear()); + value.add(v.getValue()); + }); + return new PmKeyValueVo(key,value); + } + + @Override + public PmKeyValueEnVo changeRate() { + List pmChangeRateEntities = pmDataMapper.changRate(); + List key = new ArrayList<>(); + List keyEn = new ArrayList<>(); + List value = new ArrayList<>(); + pmChangeRateEntities.forEach(v->{ + key.add(v.getCountry()); + keyEn.add(v.getCountryEn()); + value.add(v.getRatio()); + }); + return new PmKeyValueEnVo(key,keyEn,value); + } + + @Override + public List yearRatio(String year, String region) { + List list = pmDataMapper.yearRatio(year, region); + List lists = new ArrayList<>(); + list.forEach(v->{ + PmYearConcentrationRatioVo vo = new PmYearConcentrationRatioVo(v.getRegion(),v.getRegionEn(),v.getLevel(),v.getValue()); + lists.add(vo); + }); + return lists; + } + + @Override + public PmKeyValueEnVo average(String year) { + List average = pmDataMapper.average(year); + List key = new ArrayList<>(); + List keyEn = new ArrayList<>(); + List value = new ArrayList<>(); + average.forEach(v->{ + key.add(v.getCountry()); + keyEn.add(v.getCountryEn()); + value.add(v.getRatio()); + }); + return new PmKeyValueEnVo(key,keyEn,value); + } + + @Override + public List changeRateRatio(String region) { + List list = pmDataMapper.changeRateRatio(region); + List lists = new ArrayList<>(); + list.forEach(v->{ + PmYearConcentrationRatioVo vo = new PmYearConcentrationRatioVo(v.getRegion(),v.getRegionEn(), v.getLevel(), v.getValue()); + lists.add(vo); + }); + + return lists; + } + + @Override + public PmKeyValueVo monthAverage(String year, String region) { + List list = pmDataMapper.monthAverage(year, region); + list.sort(Comparator.comparing(PmMonthConcentrationEntity::getId)); + List key = new ArrayList<>(); + List value = new ArrayList<>(); + list.forEach(v->{ + key.add(v.getMonth()); + value.add(v.getValue()); + }); + return new PmKeyValueVo(key,value); + } +} diff --git a/ruoyi-system/src/main/resources/mapper/system/PmDataMapper.xml b/ruoyi-system/src/main/resources/mapper/system/PmDataMapper.xml new file mode 100644 index 000000000..1821b5690 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/system/PmDataMapper.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +