diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/yada/ENSOImpactController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/yada/ENSOImpactController.java index 02c397634..616cb406b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/yada/ENSOImpactController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/yada/ENSOImpactController.java @@ -2,10 +2,7 @@ package com.ruoyi.web.controller.yada; import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.system.domain_yada.entity.ENSOEventAnalysisEntity; -import com.ruoyi.system.domain_yada.entity.ENSOEventRateEntity; -import com.ruoyi.system.domain_yada.entity.ENSOMonthEventEntity; -import com.ruoyi.system.domain_yada.entity.ENSOYearUnusualRateEntity; +import com.ruoyi.system.domain_yada.entity.*; import com.ruoyi.system.domain_yada.vo.ENSOEventAnalysisVo; import com.ruoyi.system.domain_yada.vo.ESNOImpactSubzoneVo; import com.ruoyi.system.domain_yada.vo.PmKeyValueEnVo; @@ -71,6 +68,12 @@ public class ENSOImpactController { return AjaxResult.success(pmKeyValueVo); } + @RequestMapping(value = "/ensoYearEventCorresponding", method = {RequestMethod.GET}) + @ApiOperation(value = "年份与ENSO事件对应关系", httpMethod = "GET") + public AjaxResult ensoYearEventCorresponding(@RequestParam(value = "year") String year) { + ENSOYearEventCorrespondingEntity ensoYearEventCorrespondingEntity = ensoImpactService.ensoYearEventCorresponding(year); + return AjaxResult.success(ensoYearEventCorrespondingEntity); + } @RequestMapping(value = "/ensoEventRate", method = {RequestMethod.GET}) @ApiOperation(value = "四类ENSO事件空间分布统计", httpMethod = "GET") diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/ENSOImpactService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/ENSOImpactService.java index 7ef724b9e..c37b3d5d3 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/ENSOImpactService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/ENSOImpactService.java @@ -1,9 +1,6 @@ package com.ruoyi.system.service_yada; -import com.ruoyi.system.domain_yada.entity.ENSOEventAnalysisEntity; -import com.ruoyi.system.domain_yada.entity.ENSOEventRateEntity; -import com.ruoyi.system.domain_yada.entity.ENSOMonthEventEntity; -import com.ruoyi.system.domain_yada.entity.ENSOYearUnusualRateEntity; +import com.ruoyi.system.domain_yada.entity.*; import com.ruoyi.system.domain_yada.vo.*; import org.apache.ibatis.annotations.Param; @@ -52,6 +49,13 @@ public interface ENSOImpactService { */ PmKeyValueVo subzoneVaiLine(String type,String region,String start,String end); + /** + * 年份与ENSO事件对应关系 + * @param year + * @return + */ + ENSOYearEventCorrespondingEntity ensoYearEventCorresponding(String year); + /** * 四类ENSO事件空间分布统计 * @param type diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/impl/ENSOImpactImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/impl/ENSOImpactImpl.java index 357b9de5e..ca886d5af 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/impl/ENSOImpactImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service_yada/impl/ENSOImpactImpl.java @@ -5,7 +5,6 @@ import com.ruoyi.system.domain_yada.vo.*; import com.ruoyi.system.mapper_yada.ENSOImpactMapper; import com.ruoyi.system.mapper_yada.MonitorMapper; import com.ruoyi.system.service_yada.ENSOImpactService; -import org.apache.ibatis.ognl.ASTList; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -17,6 +16,7 @@ import java.util.stream.Collectors; /** * ENSO事件影响监测 + * * @author Mr.C */ @Service @@ -26,10 +26,9 @@ public class ENSOImpactImpl implements ENSOImpactService { @Resource private MonitorMapper monitorMapper; - @Override public ESNOImpactSubzoneVo subzonePie(String type, String year, String region) { - return ensoImpactMapper.subzonePie(type,year,region); + return ensoImpactMapper.subzonePie(type, year, region); } @Override @@ -38,42 +37,47 @@ public class ENSOImpactImpl implements ENSOImpactService { List key = new ArrayList<>(); List keyEn = new ArrayList<>(); List value = new ArrayList<>(); - list.forEach(v->{ + list.forEach(v -> { key.add(v.getRegion()); keyEn.add(v.getRegionEn()); value.add(Double.valueOf(v.getVai())); }); - 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 public PmKeyValueEnVo countryVai(String type, String year, String region) { List list = monitorMapper.countryCorresponding(region); List country = new ArrayList<>(); - list.forEach(v->country.add(v.getCountry())); + list.forEach(v -> country.add(v.getCountry())); List key = new ArrayList<>(); List keyEn = new ArrayList<>(); List value = new ArrayList<>(); List lists = ensoImpactMapper.countryVai(type, year, country); - lists.forEach(v->{ + lists.forEach(v -> { key.add(v.getCountry()); keyEn.add(v.getCountryEn()); value.add(Double.valueOf(v.getVai())); }); - return new PmKeyValueEnVo(key,keyEn,value); + return new PmKeyValueEnVo(key, keyEn, value); } @Override - public PmKeyValueVo subzoneVaiLine(String type,String region, String start, String end) { - List list = ensoImpactMapper.subzoneVaiLine(type, region,start, end); + public PmKeyValueVo subzoneVaiLine(String type, String region, String start, String end) { + List list = ensoImpactMapper.subzoneVaiLine(type, region, start, end); list.sort(Comparator.comparing(ESNOImpactSubzoneLineVo::getYear)); List key = new ArrayList<>(); List value = new ArrayList<>(); - list.forEach(v->{ + list.forEach(v -> { key.add(v.getYear()); value.add(Double.valueOf(v.getVai())); }); - return new PmKeyValueVo(key,value); + return new PmKeyValueVo(key, value); + } + + @Override + public ENSOYearEventCorrespondingEntity ensoYearEventCorresponding(String year) { + return ensoImpactMapper.ensoYearEventCorresponding(year); } @Override @@ -91,38 +95,48 @@ public class ENSOImpactImpl implements ENSOImpactService { public PmKeyValueVo ensoMonthEvent(String type, String zone) { List list = ensoImpactMapper.ensoMonthEvent(type, zone); List collect = list.stream() - .sorted(Comparator.comparing((ENSOMonthEventEntity e)-> Integer.valueOf(e.getYear())) - .thenComparing((ENSOMonthEventEntity e)-> Integer.valueOf(e.getMonth()))) + .sorted(Comparator.comparing((ENSOMonthEventEntity e) -> Integer.valueOf(e.getYear())) + .thenComparing((ENSOMonthEventEntity e) -> Integer.valueOf(e.getMonth()))) .collect(Collectors.toList()); List key = new ArrayList<>(); List value = new ArrayList<>(); - collect.forEach(v->{ - if("1".equals(v.getMonth())){ - key.add(v.getYear()+"-"+v.getMonth()); - }else { + collect.forEach(v -> { + if ("1".equals(v.getMonth())) { + key.add(v.getYear() + "-" + v.getMonth()); + } else { key.add(v.getMonth()); } value.add(Double.valueOf(v.getValue())); }); - return new PmKeyValueVo(key,value); + return new PmKeyValueVo(key, value); } @Override public ENSOEventAnalysisVo ensoEventAnalysis(String type, String zone) { - List events = Arrays.asList("厄尔尼诺东部型","厄尔尼诺中部型","拉尼娜东部型","拉尼娜中部型"); + //List events = Arrays.asList("厄尔尼诺东部型","厄尔尼诺中部型","拉尼娜东部型","拉尼娜中部型"); + List yearEEP = Arrays.asList("1982", "1986", "1991", "1997", "2002", "2006", "2014"); + List yearECP = Arrays.asList("1994", "2004", "2009", "2018"); + List yearLEP = Arrays.asList("1984", "1988", "1995", "2007", "2017", "2020"); + List yearLCP = Arrays.asList("1983", "1998", "2010"); + List> year = new ArrayList<>() {{ + add(yearEEP); + add(yearECP); + add(yearLEP); + add(yearLCP); + }}; List vo = new ArrayList<>(); - events.forEach(v->{ - List list = ensoImpactMapper.ensoEventYearCorresponding(v); - List year = new ArrayList<>(); - list.forEach(e-> year.add(e.getYear())); - List ensoEventAnalysisEntities = ensoImpactMapper.ensoEventAnalysis(type, zone, year); + year.forEach(v -> { + //List list = ensoImpactMapper.ensoEventYearCorresponding(v); + //List year = new ArrayList<>(); List key = new ArrayList<>(); List value = new ArrayList<>(); - ensoEventAnalysisEntities.forEach(k->{ + //list.forEach(e-> year.add(e.getYear())); + List ensoEventAnalysisEntities = ensoImpactMapper.ensoEventAnalysis(type, zone, v); + ensoEventAnalysisEntities.forEach(k -> { key.add(k.getYear()); value.add(Double.valueOf(k.getValue())); }); - vo.add(new PmKeyValueVo(key,value)); + vo.add(new PmKeyValueVo(key, value)); }); ENSOEventAnalysisVo ensoEventAnalysisVo = new ENSOEventAnalysisVo(); ensoEventAnalysisVo.setElninoEp(vo.get(0)); diff --git a/ruoyi-system/src/main/resources/mapper/system/ENSOImpactMapper.xml b/ruoyi-system/src/main/resources/mapper/system/ENSOImpactMapper.xml index 643e7e60e..f02b66b9a 100644 --- a/ruoyi-system/src/main/resources/mapper/system/ENSOImpactMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/ENSOImpactMapper.xml @@ -135,7 +135,7 @@ select id, year, type, zone, value from enso_event_analysis - where year in + where type = #{type} + and zone =#{zone} + and year in #{item} - and type = #{type} - and zone =#{zone} - \ No newline at end of file