From 96f4881285fde6d5e7de5d6ee0575c9c7e5189a6 Mon Sep 17 00:00:00 2001 From: machao <1550409116@qq.com> Date: Wed, 9 Nov 2022 15:25:03 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=BC=E5=90=88=E7=9B=91=E6=B5=8B=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E5=AD=97=E6=AE=B5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/yada/MonitorController.java | 73 ++++--- .../framework/config/SecurityConfig.java | 2 +- .../entity/MonitorKEQIAsiaRateEntity.java | 39 ++-- .../entity/MonitorKEQICountryRateEntity.java | 39 ++-- .../system/mapper_yada/MonitorMapper.java | 25 ++- .../system/service_yada/MonitorService.java | 39 +++- .../system/service_yada/impl/MonitorImpl.java | 201 ++++++++++++++++-- .../resources/mapper/system/MonitorMapper.xml | 40 +++- 8 files changed, 345 insertions(+), 113 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/yada/MonitorController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/yada/MonitorController.java index a525bfb76..0517af24c 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/yada/MonitorController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/yada/MonitorController.java @@ -2,6 +2,8 @@ package com.ruoyi.web.controller.yada; import com.ruoyi.common.core.domain.AjaxResult; 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.service_yada.MonitorService; import io.swagger.annotations.Api; @@ -42,61 +44,62 @@ public class MonitorController { @RequestMapping(value = "/eqiGrading", method = {RequestMethod.GET}) @ApiOperation(value = "亚大区域地理亚区EQI分级", httpMethod = "GET") public AjaxResult eqiGrading(@RequestParam(value = "year") String year, + @RequestParam(value = "type") String type, @RequestParam(value = "region") String region) { - List list = monitorService.eqiGrading(year, region); - if (list.isEmpty()) { - return AjaxResult.error("未查找到信息"); - } - return AjaxResult.success(list); + MonitorEQIGradingEntity monitorEQIGradingEntity = monitorService.eqiGrading(year, type, region); + return AjaxResult.success(monitorEQIGradingEntity); } @RequestMapping(value = "/eqiAsia", method = {RequestMethod.GET}) @ApiOperation(value = "地理亚区平均EQI分布", httpMethod = "GET") - public AjaxResult eqiAsia(@RequestParam(value = "year") String year) { - List list = monitorService.eqiAsia(year); - if (list.isEmpty()) { - return AjaxResult.error("未查找到信息"); - } - return AjaxResult.success(list); + public AjaxResult eqiAsia(@RequestParam(value = "year") String year, + @RequestParam(value = "type") String type) { + PmKeyValueEnVo pmKeyValueEnVo = monitorService.eqiAsia(year, type); + return AjaxResult.success(pmKeyValueEnVo); } @RequestMapping(value = "/eqiCountry", method = {RequestMethod.GET}) @ApiOperation(value = "各国家平均EQI分布", httpMethod = "GET") public AjaxResult eqiCountry(@RequestParam(value = "year") String year, - @RequestParam(value = "region") String region) { - List list = monitorService.eqiCountry(year, region); - if (list.isEmpty()) { - return AjaxResult.error("未查找到信息"); - } - return AjaxResult.success(list); + @RequestParam(value = "region") String region, + @RequestParam(value = "type") String type) { + PmKeyValueEnVo pmKeyValueEnVo = monitorService.eqiCountry(year, region, type); + + return AjaxResult.success(pmKeyValueEnVo); } @RequestMapping(value = "/keqi", method = {RequestMethod.GET}) @ApiOperation(value = "各地理亚区平均KEQI分布", httpMethod = "GET") - public AjaxResult keqi(@RequestParam(value = "region") String region) { - List list = monitorService.keqi(region); - if (list.isEmpty()) { - return AjaxResult.error("未查找到信息"); - } - return AjaxResult.success(list); + public AjaxResult keqi(@RequestParam(value = "region") String region, + @RequestParam(value = "type") String type) { + MonitorKEQIEntity keqi = monitorService.keqi(type, region); + return AjaxResult.success(keqi); } @RequestMapping(value = "/keqiAsiaRate", method = {RequestMethod.GET}) @ApiOperation(value = "各地理亚区平均KEQI变化率", httpMethod = "GET") - public AjaxResult keqiAsiaRate() { - List list = monitorService.keqiAsiaRate(); - if (list.isEmpty()) { - return AjaxResult.error("未查找到信息"); - } - return AjaxResult.success(list); + public AjaxResult keqiAsiaRate(@RequestParam(value = "type") String type) { + PmKeyValueEnVo pmKeyValueEnVo = monitorService.keqiAsiaRate(type); + return AjaxResult.success(pmKeyValueEnVo); } + @RequestMapping(value = "/keqiCountryRate", method = {RequestMethod.GET}) @ApiOperation(value = "各国平均KEQI变化率", httpMethod = "GET") - public AjaxResult keqiCountryRate(@RequestParam(value = "region") String region) { - List list = monitorService.keqiCountryRate(region); - if (list.isEmpty()) { - return AjaxResult.error("未查找到信息"); - } - return AjaxResult.success(list); + public AjaxResult keqiCountryRate(@RequestParam(value = "region") String region, + @RequestParam(value = "type") String type) { + PmKeyValueEnVo pmKeyValueEnVo = monitorService.keqiCountryRate(region, type); + return AjaxResult.success(pmKeyValueEnVo); } + + @RequestMapping(value = "/eqiAsiaLine", method = {RequestMethod.GET}) + @ApiOperation(value = "各地理亚区平均EQI分布折线图", httpMethod = "GET") + public AjaxResult eqiAsiaLine(@RequestParam(value = "region") String region, + @RequestParam(value = "type") String type, + @RequestParam(value = "start") String start, + @RequestParam(value = "end") String end) { + PmKeyValueVo pmKeyValueVo = monitorService.eqiAsiaLine(region, type, start, end); + return AjaxResult.success(pmKeyValueVo); + } + + } 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 b31f0f5f6..b58af4f19 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/MonitorKEQIAsiaRateEntity.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/MonitorKEQIAsiaRateEntity.java index 1625f9e3a..6faa1f256 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/MonitorKEQIAsiaRateEntity.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/MonitorKEQIAsiaRateEntity.java @@ -14,23 +14,23 @@ public class MonitorKEQIAsiaRateEntity { private String regionEn; - private BigDecimal vegetation; + private Double vegetation; - private BigDecimal forest; + private Double forest; - private BigDecimal shrub; + private Double shrub; - private BigDecimal grass; + private Double grass; - private BigDecimal farmland; + private Double farmland; - private BigDecimal mountain; + private Double mountain; public MonitorKEQIAsiaRateEntity() { } - public MonitorKEQIAsiaRateEntity(Integer id, String region, String regionEn, BigDecimal vegetation, BigDecimal forest, BigDecimal shrub, BigDecimal grass, BigDecimal farmland, BigDecimal mountain) { + public MonitorKEQIAsiaRateEntity(Integer id, String region, String regionEn, Double vegetation, Double forest, Double shrub, Double grass, Double farmland, Double mountain) { this.id = id; this.region = region; this.regionEn = regionEn; @@ -94,7 +94,7 @@ public class MonitorKEQIAsiaRateEntity { * 获取 * @return vegetation */ - public BigDecimal getVegetation() { + public Double getVegetation() { return vegetation; } @@ -102,7 +102,7 @@ public class MonitorKEQIAsiaRateEntity { * 设置 * @param vegetation */ - public void setVegetation(BigDecimal vegetation) { + public void setVegetation(Double vegetation) { this.vegetation = vegetation; } @@ -110,7 +110,7 @@ public class MonitorKEQIAsiaRateEntity { * 获取 * @return forest */ - public BigDecimal getForest() { + public Double getForest() { return forest; } @@ -118,7 +118,7 @@ public class MonitorKEQIAsiaRateEntity { * 设置 * @param forest */ - public void setForest(BigDecimal forest) { + public void setForest(Double forest) { this.forest = forest; } @@ -126,7 +126,7 @@ public class MonitorKEQIAsiaRateEntity { * 获取 * @return shrub */ - public BigDecimal getShrub() { + public Double getShrub() { return shrub; } @@ -134,7 +134,7 @@ public class MonitorKEQIAsiaRateEntity { * 设置 * @param shrub */ - public void setShrub(BigDecimal shrub) { + public void setShrub(Double shrub) { this.shrub = shrub; } @@ -142,7 +142,7 @@ public class MonitorKEQIAsiaRateEntity { * 获取 * @return grass */ - public BigDecimal getGrass() { + public Double getGrass() { return grass; } @@ -150,7 +150,7 @@ public class MonitorKEQIAsiaRateEntity { * 设置 * @param grass */ - public void setGrass(BigDecimal grass) { + public void setGrass(Double grass) { this.grass = grass; } @@ -158,7 +158,7 @@ public class MonitorKEQIAsiaRateEntity { * 获取 * @return farmland */ - public BigDecimal getFarmland() { + public Double getFarmland() { return farmland; } @@ -166,7 +166,7 @@ public class MonitorKEQIAsiaRateEntity { * 设置 * @param farmland */ - public void setFarmland(BigDecimal farmland) { + public void setFarmland(Double farmland) { this.farmland = farmland; } @@ -174,7 +174,7 @@ public class MonitorKEQIAsiaRateEntity { * 获取 * @return mountain */ - public BigDecimal getMountain() { + public Double getMountain() { return mountain; } @@ -182,11 +182,10 @@ public class MonitorKEQIAsiaRateEntity { * 设置 * @param mountain */ - public void setMountain(BigDecimal mountain) { + public void setMountain(Double mountain) { this.mountain = mountain; } - @Override public String toString() { return "MonitorKEQIAsiaRateEntity{id = " + id + ", region = " + region + ", regionEn = " + regionEn + ", vegetation = " + vegetation + ", forest = " + forest + ", shrub = " + shrub + ", grass = " + grass + ", farmland = " + farmland + ", mountain = " + mountain + "}"; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/MonitorKEQICountryRateEntity.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/MonitorKEQICountryRateEntity.java index e8ff0ac5a..bfdc878f5 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/MonitorKEQICountryRateEntity.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain_yada/entity/MonitorKEQICountryRateEntity.java @@ -13,23 +13,23 @@ public class MonitorKEQICountryRateEntity { private String countryEn; - private BigDecimal all; + private Double all; - private BigDecimal forest; + private Double forest; - private BigDecimal shrub; + private Double shrub; - private BigDecimal grass; + private Double grass; - private BigDecimal farmland; + private Double farmland; - private BigDecimal mountain; + private Double mountain; public MonitorKEQICountryRateEntity() { } - public MonitorKEQICountryRateEntity(Integer id, String country, String countryEn, BigDecimal all, BigDecimal forest, BigDecimal shrub, BigDecimal grass, BigDecimal farmland, BigDecimal mountain) { + public MonitorKEQICountryRateEntity(Integer id, String country, String countryEn, Double all, Double forest, Double shrub, Double grass, Double farmland, Double mountain) { this.id = id; this.country = country; this.countryEn = countryEn; @@ -93,7 +93,7 @@ public class MonitorKEQICountryRateEntity { * 获取 * @return all */ - public BigDecimal getAll() { + public Double getAll() { return all; } @@ -101,7 +101,7 @@ public class MonitorKEQICountryRateEntity { * 设置 * @param all */ - public void setAll(BigDecimal all) { + public void setAll(Double all) { this.all = all; } @@ -109,7 +109,7 @@ public class MonitorKEQICountryRateEntity { * 获取 * @return forest */ - public BigDecimal getForest() { + public Double getForest() { return forest; } @@ -117,7 +117,7 @@ public class MonitorKEQICountryRateEntity { * 设置 * @param forest */ - public void setForest(BigDecimal forest) { + public void setForest(Double forest) { this.forest = forest; } @@ -125,7 +125,7 @@ public class MonitorKEQICountryRateEntity { * 获取 * @return shrub */ - public BigDecimal getShrub() { + public Double getShrub() { return shrub; } @@ -133,7 +133,7 @@ public class MonitorKEQICountryRateEntity { * 设置 * @param shrub */ - public void setShrub(BigDecimal shrub) { + public void setShrub(Double shrub) { this.shrub = shrub; } @@ -141,7 +141,7 @@ public class MonitorKEQICountryRateEntity { * 获取 * @return grass */ - public BigDecimal getGrass() { + public Double getGrass() { return grass; } @@ -149,7 +149,7 @@ public class MonitorKEQICountryRateEntity { * 设置 * @param grass */ - public void setGrass(BigDecimal grass) { + public void setGrass(Double grass) { this.grass = grass; } @@ -157,7 +157,7 @@ public class MonitorKEQICountryRateEntity { * 获取 * @return farmland */ - public BigDecimal getFarmland() { + public Double getFarmland() { return farmland; } @@ -165,7 +165,7 @@ public class MonitorKEQICountryRateEntity { * 设置 * @param farmland */ - public void setFarmland(BigDecimal farmland) { + public void setFarmland(Double farmland) { this.farmland = farmland; } @@ -173,7 +173,7 @@ public class MonitorKEQICountryRateEntity { * 获取 * @return mountain */ - public BigDecimal getMountain() { + public Double getMountain() { return mountain; } @@ -181,11 +181,10 @@ public class MonitorKEQICountryRateEntity { * 设置 * @param mountain */ - public void setMountain(BigDecimal mountain) { + public void setMountain(Double mountain) { this.mountain = mountain; } - @Override public String toString() { return "MonitorKEQICountryRateEntity{id = " + id + ", country = " + country + ", countryEn = " + countryEn + ", all = " + all + ", forest = " + forest + ", shrub = " + shrub + ", grass = " + grass + ", farmland = " + farmland + ", mountain = " + mountain + "}"; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper_yada/MonitorMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper_yada/MonitorMapper.java index 1a4738702..a731a6f91 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper_yada/MonitorMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper_yada/MonitorMapper.java @@ -22,15 +22,18 @@ public interface MonitorMapper { /** * 亚大区域地理亚区EQI分级 - * @param year 年份 + * + * @param year 年份 * @param region 区域 * @return */ - List eqiGrading(@Param("year") String year, - @Param("region") String region); + MonitorEQIGradingEntity eqiGrading(@Param("year") String year, + @Param("type") String type, + @Param("region") String region); /** * 各地理亚区平均EQI分布 + * * @param year * @return */ @@ -38,6 +41,7 @@ public interface MonitorMapper { /** * 各国家平均EQI分布 + * * @param year * @param country * @return @@ -47,22 +51,35 @@ public interface MonitorMapper { /** * 各地理亚区平均KEQI分布 + * * @param region * @return */ - List keqi(@Param("region") String region); + MonitorKEQIEntity keqi(@Param("type") String type, + @Param("region") String region); /** * 各地理亚区平均KEQI变化率 + * * @return */ List keqiAsiaRate(); /** * 各国平均KEQI变化率 + * * @param country 国家 * @return */ MonitorKEQICountryRateEntity keqiCountryRate(@Param("country") String country); + + /** + * 各地理亚区平均EQI分布折线图 + * @param region + * @return + */ + List eqiAsiaLine(@Param("region") String region, + @Param("start") String start, + @Param("end") String end); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/MonitorService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/MonitorService.java index 8be72ebd5..bca0544b1 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/MonitorService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/MonitorService.java @@ -1,12 +1,15 @@ package com.ruoyi.system.service_yada; import com.ruoyi.system.domain_yada.entity.*; +import com.ruoyi.system.domain_yada.vo.PmKeyValueEnVo; +import com.ruoyi.system.domain_yada.vo.PmKeyValueVo; import org.apache.ibatis.annotations.Param; import java.util.List; /** * 亚大综合监测 + * * @author Mr.C */ public interface MonitorService { @@ -14,6 +17,7 @@ public interface MonitorService { /** * 亚大区域地理亚区与国家对应关系 + * * @param region 区域 * @return */ @@ -21,44 +25,63 @@ public interface MonitorService { /** * 亚大区域地理亚区EQI分级 - * @param year 年份 + * + * @param year 年份 * @param region 区域 * @return */ - List eqiGrading(String year,String region); + MonitorEQIGradingEntity eqiGrading(String year, String type, String region); /** * 各地理亚区平均EQI分布 + * * @param year 年份 + * @param type 植被类型 * @return */ - List eqiAsia(String year); + PmKeyValueEnVo eqiAsia(String year, String type); /** * 各国家平均EQI分布 - * @param year 年份 + * + * @param year 年份 * @param region 区域 + * @param type 植被类型 * @return */ - List eqiCountry(String year ,String region); + PmKeyValueEnVo eqiCountry(String year, String region, String type); /** * 各地理亚区平均KEQI分布 + * * @param region 区域 * @return */ - List keqi(@Param("region") String region); + MonitorKEQIEntity keqi(String type, String region); /** * 各地理亚区平均KEQI变化率 + * * @return */ - List keqiAsiaRate(); + PmKeyValueEnVo keqiAsiaRate(String type); /** * 各国平均KEQI变化率 + * * @param region 区域 * @return */ - List keqiCountryRate(@Param("region") String region); + PmKeyValueEnVo keqiCountryRate(String region, String type); + + /** + * 各地理亚区平均EQI分布折线图 + * + * @param region + * @param type + * @param start + * @param end + * @return + */ + PmKeyValueVo eqiAsiaLine(String region, String type, String start, String end); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/impl/MonitorImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/impl/MonitorImpl.java index bd5fce664..4cf8512eb 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/impl/MonitorImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/impl/MonitorImpl.java @@ -1,6 +1,8 @@ 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.mapper_yada.MonitorMapper; import com.ruoyi.system.service_yada.MonitorService; import org.springframework.beans.factory.annotation.Autowired; @@ -8,15 +10,25 @@ import org.springframework.stereotype.Service; import org.yaml.snakeyaml.Yaml; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; /** - *亚大综合监测 + * 亚大综合监测 + * * @author Mr.C */ @Service public class MonitorImpl implements MonitorService { + private static final String FOREST = "forest"; + private static final String SHRUB = "shrub"; + private static final String GRASS = "grass"; + private static final String FARMLAND = "farmland"; + private static final String MOUNTAIN = "mountain"; + private static final String ALL = "all"; + @Resource private MonitorMapper monitorMapper; @@ -26,44 +38,199 @@ public class MonitorImpl implements MonitorService { } @Override - public List eqiGrading(String year, String region) { - return monitorMapper.eqiGrading(year, region); + public MonitorEQIGradingEntity eqiGrading(String year, String type, String region) { + return monitorMapper.eqiGrading(year, type, region); } @Override - public List eqiAsia(String year) { - return monitorMapper.eqiAsia(year); + public PmKeyValueEnVo eqiAsia(String year, String type) { + List list = monitorMapper.eqiAsia(year); + List key = new ArrayList<>(); + List keyEn = new ArrayList<>(); + List value = new ArrayList<>(); + list.forEach(v -> { + key.add(v.getRegion()); + keyEn.add(v.getRegionEn()); + }); + switch (type) { + case FOREST: + list.forEach(v -> value.add(Double.valueOf(v.getForest()))); + break; + case SHRUB: + list.forEach(v -> value.add(Double.valueOf(v.getShrub()))); + break; + case GRASS: + list.forEach(v -> value.add(Double.valueOf(v.getGrass()))); + break; + case FARMLAND: + list.forEach(v -> value.add(Double.valueOf(v.getFarmland()))); + break; + case MOUNTAIN: + list.forEach(v -> value.add(Double.valueOf(v.getMountain()))); + break; + case ALL: + list.forEach(v -> value.add(Double.valueOf(v.getAll()))); + break; + default: + } + return new PmKeyValueEnVo(key, keyEn, value); } @Override - public List eqiCountry(String year, String region) { + public PmKeyValueEnVo eqiCountry(String year, String region, String type) { List list = monitorMapper.countryCorresponding(region); - List lists = new ArrayList<>(); + List key = new ArrayList<>(); + List keyEn = new ArrayList<>(); + List value = new ArrayList<>(); for (MonitorCountryCorrespondingEntity monitorCountryCorrespondingEntity : list) { String country = monitorCountryCorrespondingEntity.getCountry(); - lists.add(monitorMapper.eqiCountry(year, country)); + key.add(monitorMapper.eqiCountry(year, country).getCountry()); + keyEn.add(monitorMapper.eqiCountry(year, country).getCountryEn()); + switch (type) { + case FOREST: + value.add(Double.valueOf(monitorMapper.eqiCountry(year, country).getForestEQI())); + break; + case SHRUB: + value.add(Double.valueOf(monitorMapper.eqiCountry(year, country).getShrubEQI())); + break; + case GRASS: + value.add(Double.valueOf(monitorMapper.eqiCountry(year, country).getGrassEQI())); + break; + case FARMLAND: + value.add(Double.valueOf(monitorMapper.eqiCountry(year, country).getFarmlandEQI())); + break; + case MOUNTAIN: + value.add(Double.valueOf(monitorMapper.eqiCountry(year, country).getMountainEQI())); + break; + case ALL: + value.add(Double.valueOf(monitorMapper.eqiCountry(year, country).getAllEQI())); + break; + default: + } } - return lists; + return new PmKeyValueEnVo(key, keyEn, value); } @Override - public List keqi(String region) { - return monitorMapper.keqi(region); + public MonitorKEQIEntity keqi(String type, String region) { + return monitorMapper.keqi(type, region); } @Override - public List keqiAsiaRate() { - return monitorMapper.keqiAsiaRate(); + public PmKeyValueEnVo keqiAsiaRate(String type) { + List list = monitorMapper.keqiAsiaRate(); + List key = new ArrayList<>(); + List keyEn = new ArrayList<>(); + List value = new ArrayList<>(); + list.forEach(v -> { + key.add(v.getRegion()); + keyEn.add(v.getRegionEn()); + }); + switch (type) { + case FOREST: + list.forEach(v -> value.add(v.getForest())); + break; + case SHRUB: + list.forEach(v -> value.add(v.getShrub())); + break; + case GRASS: + list.forEach(v -> value.add(v.getGrass())); + break; + case FARMLAND: + list.forEach(v -> value.add(v.getFarmland())); + break; + case MOUNTAIN: + list.forEach(v -> value.add(v.getMountain())); + break; + case ALL: + list.forEach(v -> value.add(v.getVegetation())); + break; + default: + } + return new PmKeyValueEnVo(key, keyEn, value); } @Override - public List keqiCountryRate(String region) { + public PmKeyValueEnVo keqiCountryRate(String region, String type) { List list = monitorMapper.countryCorresponding(region); - List lists = new ArrayList<>(); + List key = new ArrayList<>(); + List keyEn = new ArrayList<>(); + List value = new ArrayList<>(); for (MonitorCountryCorrespondingEntity monitorCountryCorrespondingEntity : list) { - lists.add(monitorMapper.keqiCountryRate(monitorCountryCorrespondingEntity.getCountry())); + String country = monitorCountryCorrespondingEntity.getCountry(); + key.add(monitorMapper.keqiCountryRate(country).getCountry()); + keyEn.add(monitorMapper.keqiCountryRate(country).getCountryEn()); + switch (type) { + case FOREST: + value.add(monitorMapper.keqiCountryRate(country).getForest()); + break; + case SHRUB: + value.add(monitorMapper.keqiCountryRate(country).getShrub()); + break; + case GRASS: + value.add(monitorMapper.keqiCountryRate(country).getGrass()); + break; + case FARMLAND: + value.add(monitorMapper.keqiCountryRate(country).getFarmland()); + break; + case MOUNTAIN: + value.add(monitorMapper.keqiCountryRate(country).getMountain()); + break; + case ALL: + value.add(monitorMapper.keqiCountryRate(country).getAll()); + break; + default: + } } - return lists; + return new PmKeyValueEnVo(key, keyEn, value); + } + + @Override + public PmKeyValueVo eqiAsiaLine(String region, String type,String start ,String end) { + List list = monitorMapper.eqiAsiaLine(region,start,end); + list.sort(Comparator.comparing(MonitorEQIAsiaEntity::getYear)); + List key = new ArrayList<>(); + List value = new ArrayList<>(); + switch (type) { + case FOREST: + list.forEach(v -> { + key.add(v.getYear()); + value.add(Double.valueOf(v.getForest())); + }); + break; + case SHRUB: + list.forEach(v -> { + key.add(v.getYear()); + value.add(Double.valueOf(v.getShrub())); + }); + break; + case GRASS: + list.forEach(v -> { + key.add(v.getYear()); + value.add(Double.valueOf(v.getGrass())); + }); + break; + case FARMLAND: + list.forEach(v -> { + key.add(v.getYear()); + value.add(Double.valueOf(v.getFarmland())); + }); + break; + case MOUNTAIN: + list.forEach(v -> { + key.add(v.getYear()); + value.add(Double.valueOf(v.getMountain())); + }); + break; + case ALL: + list.forEach(v -> { + key.add(v.getYear()); + value.add(Double.valueOf(v.getAll())); + }); + break; + default: + } + return new PmKeyValueVo(key,value); } } diff --git a/ruoyi-system/src/main/resources/mapper/system/MonitorMapper.xml b/ruoyi-system/src/main/resources/mapper/system/MonitorMapper.xml index a4dfb77b4..4137e7891 100644 --- a/ruoyi-system/src/main/resources/mapper/system/MonitorMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/MonitorMapper.xml @@ -111,6 +111,7 @@ select id, year, type, region, region_en, excellent, good, middle, low, poor from monitor_eqi_grading where year = #{year} + and type = #{type} and region = #{region} @@ -163,19 +164,20 @@ slight_rise, significant_rise from monitor_keqi - where region = #{region} + where type = #{type} + and region = #{region} @@ -183,7 +185,7 @@ select mkcr.id, mkcr.country, mkcr.country_en, - cast((cast(mkcr.all as decimal)*100) as decimal(10,2)) as all, + cast((cast(mkcr.all as decimal) * 100) as decimal(10, 2)) as all, cast((cast(mkcr.forest as decimal)*100) as decimal(10,2)) as forest, cast((cast(mkcr.shrub as decimal)*100) as decimal(10,2)) as shrub, cast((cast(mkcr.grass as decimal)*100) as decimal(10,2)) as grass, @@ -192,4 +194,26 @@ from monitor_keqi_country_rate mkcr where mkcr.country = #{country} + + \ No newline at end of file