ENSO修改

This commit is contained in:
machao 2023-03-06 17:28:31 +08:00
parent d6a411e858
commit 9158979599
4 changed files with 60 additions and 40 deletions

View File

@ -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")

View File

@ -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

View File

@ -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<String> key = new ArrayList<>();
List<String> keyEn = new ArrayList<>();
List<Double> 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<MonitorCountryCorrespondingEntity> list = monitorMapper.countryCorresponding(region);
List<String> country = new ArrayList<>();
list.forEach(v->country.add(v.getCountry()));
list.forEach(v -> country.add(v.getCountry()));
List<String> key = new ArrayList<>();
List<String> keyEn = new ArrayList<>();
List<Double> value = new ArrayList<>();
List<ESNOImpactCountryVaiVo> 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<ESNOImpactSubzoneLineVo> list = ensoImpactMapper.subzoneVaiLine(type, region,start, end);
public PmKeyValueVo subzoneVaiLine(String type, String region, String start, String end) {
List<ESNOImpactSubzoneLineVo> list = ensoImpactMapper.subzoneVaiLine(type, region, start, end);
list.sort(Comparator.comparing(ESNOImpactSubzoneLineVo::getYear));
List<String> key = new ArrayList<>();
List<Double> 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<ENSOMonthEventEntity> list = ensoImpactMapper.ensoMonthEvent(type, zone);
List<ENSOMonthEventEntity> 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<String> key = new ArrayList<>();
List<Double> 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<String> events = Arrays.asList("厄尔尼诺东部型","厄尔尼诺中部型","拉尼娜东部型","拉尼娜中部型");
//List<String> events = Arrays.asList("厄尔尼诺东部型","厄尔尼诺中部型","拉尼娜东部型","拉尼娜中部型");
List<String> yearEEP = Arrays.asList("1982", "1986", "1991", "1997", "2002", "2006", "2014");
List<String> yearECP = Arrays.asList("1994", "2004", "2009", "2018");
List<String> yearLEP = Arrays.asList("1984", "1988", "1995", "2007", "2017", "2020");
List<String> yearLCP = Arrays.asList("1983", "1998", "2010");
List<List<String>> year = new ArrayList<>() {{
add(yearEEP);
add(yearECP);
add(yearLEP);
add(yearLCP);
}};
List<PmKeyValueVo> vo = new ArrayList<>();
events.forEach(v->{
List<ENSOYearEventCorrespondingEntity> list = ensoImpactMapper.ensoEventYearCorresponding(v);
List<String> year = new ArrayList<>();
list.forEach(e-> year.add(e.getYear()));
List<ENSOEventAnalysisEntity> ensoEventAnalysisEntities = ensoImpactMapper.ensoEventAnalysis(type, zone, year);
year.forEach(v -> {
//List<ENSOYearEventCorrespondingEntity> list = ensoImpactMapper.ensoEventYearCorresponding(v);
//List<String> year = new ArrayList<>();
List<String> key = new ArrayList<>();
List<Double> value = new ArrayList<>();
ensoEventAnalysisEntities.forEach(k->{
//list.forEach(e-> year.add(e.getYear()));
List<ENSOEventAnalysisEntity> 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));

View File

@ -135,7 +135,7 @@
</select>
<select id="ensoEventRate" resultMap="ENSO_Event_Rate">
select id,
type,
type,
zone,
event,
event_en,
@ -176,12 +176,11 @@
<select id="ensoEventAnalysis" resultMap="ENSO_Event_Analysis">
select id, year, type, zone, value
from enso_event_analysis
where year in
where type = #{type}
and zone =#{zone}
and year in
<foreach collection="year" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
and type = #{type}
and zone =#{zone}
</select>
</mapper>