国家查询优化

This commit is contained in:
machao 2022-11-10 15:24:08 +08:00
parent 7d7c0dafd1
commit 448aa856e9
9 changed files with 81 additions and 44 deletions

View File

@ -68,6 +68,7 @@ public class MonitorController {
return AjaxResult.success(pmKeyValueEnVo); return AjaxResult.success(pmKeyValueEnVo);
} }
@RequestMapping(value = "/keqi", method = {RequestMethod.GET}) @RequestMapping(value = "/keqi", method = {RequestMethod.GET})
@ApiOperation(value = "各地理亚区平均KEQI分布", httpMethod = "GET") @ApiOperation(value = "各地理亚区平均KEQI分布", httpMethod = "GET")
public AjaxResult keqi(@RequestParam(value = "region") String region, public AjaxResult keqi(@RequestParam(value = "region") String region,
@ -91,6 +92,7 @@ public class MonitorController {
return AjaxResult.success(pmKeyValueEnVo); return AjaxResult.success(pmKeyValueEnVo);
} }
@RequestMapping(value = "/eqiAsiaLine", method = {RequestMethod.GET}) @RequestMapping(value = "/eqiAsiaLine", method = {RequestMethod.GET})
@ApiOperation(value = "各地理亚区平均EQI分布折线图", httpMethod = "GET") @ApiOperation(value = "各地理亚区平均EQI分布折线图", httpMethod = "GET")
public AjaxResult eqiAsiaLine(@RequestParam(value = "region") String region, public AjaxResult eqiAsiaLine(@RequestParam(value = "region") String region,

View File

@ -115,7 +115,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.antMatchers("/*/api-docs").anonymous() .antMatchers("/*/api-docs").anonymous()
.antMatchers("/druid/**").anonymous() .antMatchers("/druid/**").anonymous()
// // 除上面外的所有请求全部需要鉴权认证 // // 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated() //.anyRequest().authenticated()
.and() .and()
.headers().frameOptions().disable(); .headers().frameOptions().disable();
httpSecurity.logout().logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler); httpSecurity.logout().logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler);

View File

@ -45,9 +45,9 @@ public interface ESNOImpactMapper {
* @param country * @param country
* @return * @return
*/ */
ESNOImpactCountryVaiVo countryVai(@Param("type") String type, List<ESNOImpactCountryVaiVo> countryVai(@Param("type") String type,
@Param("year") String year, @Param("year") String year,
@Param("country") String country); @Param("country") List<String> country);
/** /**
* 各地理亚区时间VAI * 各地理亚区时间VAI

View File

@ -46,8 +46,8 @@ public interface MonitorMapper {
* @param country * @param country
* @return * @return
*/ */
MonitorEQICountryEntity eqiCountry(@Param("year") String year, List<MonitorEQICountryEntity> eqiCountry(@Param("year") String year,
@Param("country") String country); @Param("country") List<String>country);
/** /**
* 各地理亚区平均KEQI分布 * 各地理亚区平均KEQI分布
@ -71,7 +71,7 @@ public interface MonitorMapper {
* @param country 国家 * @param country 国家
* @return * @return
*/ */
MonitorKEQICountryRateEntity keqiCountryRate(@Param("country") String country); List<MonitorKEQICountryRateEntity> keqiCountryRate(@Param("country") List<String> country);
/** /**
* 各地理亚区平均EQI分布折线图 * 各地理亚区平均EQI分布折线图

View File

@ -51,6 +51,7 @@ public interface MonitorService {
*/ */
PmKeyValueEnVo eqiCountry(String year, String region, String type); PmKeyValueEnVo eqiCountry(String year, String region, String type);
/** /**
* 各地理亚区平均KEQI分布 * 各地理亚区平均KEQI分布
* *

View File

@ -46,13 +46,16 @@ public class ESNOImpactImpl implements ESNOImpactService {
@Override @Override
public PmKeyValueEnVo countryVai(String type, String year, String region) { public PmKeyValueEnVo countryVai(String type, String year, String region) {
List<MonitorCountryCorrespondingEntity> list = monitorMapper.countryCorresponding(region); List<MonitorCountryCorrespondingEntity> list = monitorMapper.countryCorresponding(region);
List<String> country = new ArrayList<>();
list.forEach(v->country.add(v.getCountry()));
List<String> key = new ArrayList<>(); List<String> key = new ArrayList<>();
List<String> keyEn = new ArrayList<>(); List<String> keyEn = new ArrayList<>();
List<Double> value = new ArrayList<>(); List<Double> value = new ArrayList<>();
list.forEach(v->{ List<ESNOImpactCountryVaiVo> lists = esnoImpactMapper.countryVai(type, year, country);
lists.forEach(v->{
key.add(v.getCountry()); key.add(v.getCountry());
keyEn.add(v.getCountryEn()); keyEn.add(v.getCountryEn());
value.add(Double.valueOf(esnoImpactMapper.countryVai(type, year, v.getCountry()).getVai())); value.add(Double.valueOf(v.getVai()));
}); });
return new PmKeyValueEnVo(key,keyEn,value); return new PmKeyValueEnVo(key,keyEn,value);
} }

View File

@ -5,12 +5,9 @@ import com.ruoyi.system.domain_yada.vo.PmKeyValueEnVo;
import com.ruoyi.system.domain_yada.vo.PmKeyValueVo; import com.ruoyi.system.domain_yada.vo.PmKeyValueVo;
import com.ruoyi.system.mapper_yada.MonitorMapper; import com.ruoyi.system.mapper_yada.MonitorMapper;
import com.ruoyi.system.service_yada.MonitorService; import com.ruoyi.system.service_yada.MonitorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.yaml.snakeyaml.Yaml;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
@ -48,62 +45,85 @@ public class MonitorImpl implements MonitorService {
List<String> key = new ArrayList<>(); List<String> key = new ArrayList<>();
List<String> keyEn = new ArrayList<>(); List<String> keyEn = new ArrayList<>();
List<Double> value = new ArrayList<>(); List<Double> value = new ArrayList<>();
list.forEach(v -> {
key.add(v.getRegion());
keyEn.add(v.getRegionEn());
});
switch (type) { switch (type) {
case FOREST: case FOREST:
list.forEach(v -> value.add(Double.valueOf(v.getForest()))); list.forEach(v -> {
key.add(v.getRegion());
keyEn.add(v.getRegionEn());
value.add(Double.valueOf(v.getForest()));
});
break; break;
case SHRUB: case SHRUB:
list.forEach(v -> value.add(Double.valueOf(v.getShrub()))); list.forEach(v -> {
key.add(v.getRegion());
keyEn.add(v.getRegionEn());
value.add(Double.valueOf(v.getShrub()));
});
break; break;
case GRASS: case GRASS:
list.forEach(v -> value.add(Double.valueOf(v.getGrass()))); list.forEach(v -> {
key.add(v.getRegion());
keyEn.add(v.getRegionEn());
value.add(Double.valueOf(v.getGrass()));
});
break; break;
case FARMLAND: case FARMLAND:
list.forEach(v -> value.add(Double.valueOf(v.getFarmland()))); list.forEach(v -> {
key.add(v.getRegion());
keyEn.add(v.getRegionEn());
value.add(Double.valueOf(v.getFarmland()));
});
break; break;
case MOUNTAIN: case MOUNTAIN:
list.forEach(v -> value.add(Double.valueOf(v.getMountain()))); list.forEach(v -> {
key.add(v.getRegion());
keyEn.add(v.getRegionEn());
value.add(Double.valueOf(v.getMountain()));
});
break; break;
case ALL: case ALL:
list.forEach(v -> value.add(Double.valueOf(v.getAll()))); list.forEach(v -> {
key.add(v.getRegion());
keyEn.add(v.getRegionEn());
value.add(Double.valueOf(v.getAll()));
});
break; break;
default: default:
} }
return new PmKeyValueEnVo(key.subList(0,7), keyEn.subList(0,7), value.subList(0,7)); return new PmKeyValueEnVo(key.subList(0,7), keyEn.subList(0,7), value.subList(0,7));
} }
@Override @Override
public PmKeyValueEnVo eqiCountry(String year, String region, String type) { public PmKeyValueEnVo eqiCountry(String year, String region, String type) {
List<MonitorCountryCorrespondingEntity> list = monitorMapper.countryCorresponding(region); List<MonitorCountryCorrespondingEntity> list = monitorMapper.countryCorresponding(region);
List<String> country = new ArrayList<>();
list.forEach(v->country.add(v.getCountry()));
List<String> key = new ArrayList<>(); List<String> key = new ArrayList<>();
List<String> keyEn = new ArrayList<>(); List<String> keyEn = new ArrayList<>();
List<Double> value = new ArrayList<>(); List<Double> value = new ArrayList<>();
for (MonitorCountryCorrespondingEntity monitorCountryCorrespondingEntity : list) { List<MonitorEQICountryEntity> lists = monitorMapper.eqiCountry(year, country);
String country = monitorCountryCorrespondingEntity.getCountry(); for (MonitorEQICountryEntity entity : lists) {
key.add(monitorMapper.eqiCountry(year, country).getCountry()); key.add(entity.getCountry());
keyEn.add(monitorMapper.eqiCountry(year, country).getCountryEn()); keyEn.add(entity.getCountryEn());
switch (type) { switch (type) {
case FOREST: case FOREST:
value.add(Double.valueOf(monitorMapper.eqiCountry(year, country).getForestEQI())); value.add(Double.valueOf(entity.getForestEQI()));
break; break;
case SHRUB: case SHRUB:
value.add(Double.valueOf(monitorMapper.eqiCountry(year, country).getShrubEQI())); value.add(Double.valueOf(entity.getShrubEQI()));
break; break;
case GRASS: case GRASS:
value.add(Double.valueOf(monitorMapper.eqiCountry(year, country).getGrassEQI())); value.add(Double.valueOf(entity.getGrassEQI()));
break; break;
case FARMLAND: case FARMLAND:
value.add(Double.valueOf(monitorMapper.eqiCountry(year, country).getFarmlandEQI())); value.add(Double.valueOf(entity.getFarmlandEQI()));
break; break;
case MOUNTAIN: case MOUNTAIN:
value.add(Double.valueOf(monitorMapper.eqiCountry(year, country).getMountainEQI())); value.add(Double.valueOf(entity.getMountainEQI()));
break; break;
case ALL: case ALL:
value.add(Double.valueOf(monitorMapper.eqiCountry(year, country).getAllEQI())); value.add(Double.valueOf(entity.getAllEQI()));
break; break;
default: default:
} }
@ -153,31 +173,33 @@ public class MonitorImpl implements MonitorService {
@Override @Override
public PmKeyValueEnVo keqiCountryRate(String region, String type) { public PmKeyValueEnVo keqiCountryRate(String region, String type) {
List<MonitorCountryCorrespondingEntity> list = monitorMapper.countryCorresponding(region); List<MonitorCountryCorrespondingEntity> list = monitorMapper.countryCorresponding(region);
List<String> country = new ArrayList<>();
list.forEach(v->country.add(v.getCountry()));
List<String> key = new ArrayList<>(); List<String> key = new ArrayList<>();
List<String> keyEn = new ArrayList<>(); List<String> keyEn = new ArrayList<>();
List<Double> value = new ArrayList<>(); List<Double> value = new ArrayList<>();
for (MonitorCountryCorrespondingEntity monitorCountryCorrespondingEntity : list) { List<MonitorKEQICountryRateEntity> lists = monitorMapper.keqiCountryRate(country);
String country = monitorCountryCorrespondingEntity.getCountry(); for (MonitorKEQICountryRateEntity entity : lists) {
key.add(monitorMapper.keqiCountryRate(country).getCountry()); key.add(entity.getCountry());
keyEn.add(monitorMapper.keqiCountryRate(country).getCountryEn()); keyEn.add(entity.getCountryEn());
switch (type) { switch (type) {
case FOREST: case FOREST:
value.add(monitorMapper.keqiCountryRate(country).getForest()); value.add(entity.getForest());
break; break;
case SHRUB: case SHRUB:
value.add(monitorMapper.keqiCountryRate(country).getShrub()); value.add(entity.getShrub());
break; break;
case GRASS: case GRASS:
value.add(monitorMapper.keqiCountryRate(country).getGrass()); value.add(entity.getGrass());
break; break;
case FARMLAND: case FARMLAND:
value.add(monitorMapper.keqiCountryRate(country).getFarmland()); value.add(entity.getFarmland());
break; break;
case MOUNTAIN: case MOUNTAIN:
value.add(monitorMapper.keqiCountryRate(country).getMountain()); value.add(entity.getMountain());
break; break;
case ALL: case ALL:
value.add(monitorMapper.keqiCountryRate(country).getAll()); value.add(entity.getAll());
break; break;
default: default:
} }

View File

@ -49,7 +49,10 @@
from esno_impact_country from esno_impact_country
where type = #{type} where type = #{type}
and year = #{year} and year = #{year}
and country = #{country} and country in
<foreach collection="country" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</select> </select>
<select id="subzoneVaiLine" resultMap="ESNO_Impact_Subzone_Line"> <select id="subzoneVaiLine" resultMap="ESNO_Impact_Subzone_Line">

View File

@ -150,7 +150,10 @@
mec.mountain_pixel mec.mountain_pixel
from monitor_eqi_country mec from monitor_eqi_country mec
where mec.year = #{year} where mec.year = #{year}
and mec.country = #{country} and mec.country in
<foreach collection="country" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</select> </select>
<select id="keqi" resultMap="Monitor_KEQI"> <select id="keqi" resultMap="Monitor_KEQI">
@ -192,7 +195,10 @@
cast((cast(mkcr.farmland as decimal)*100) as decimal(10,2)) as farmland, cast((cast(mkcr.farmland as decimal)*100) as decimal(10,2)) as farmland,
cast((cast(mkcr.mountain as decimal)*100) as decimal(10,2)) as mountain cast((cast(mkcr.mountain as decimal)*100) as decimal(10,2)) as mountain
from monitor_keqi_country_rate mkcr from monitor_keqi_country_rate mkcr
where mkcr.country = #{country} where mkcr.country in
<foreach collection="country" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</select> </select>
<select id="eqiAsiaLine" resultMap="Monitor_EQI_Asia"> <select id="eqiAsiaLine" resultMap="Monitor_EQI_Asia">