|
@@ -26,7 +26,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 服务实现类
|
|
|
+ * 服务实现类
|
|
|
* </p>
|
|
|
*
|
|
|
* @author gfhd
|
|
@@ -42,6 +42,7 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
|
|
|
/**
|
|
|
* 由于mybatis-plus存储的中文乱码
|
|
|
* 采用原生写法
|
|
|
+ *
|
|
|
* @param list
|
|
|
* @return
|
|
|
*/
|
|
@@ -50,13 +51,13 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
|
|
|
KuduTable kuduTable = kuduConfig.kuduClient.openTable("impala::gyee_sample_kudu.windspeedforecastshortterm");
|
|
|
KuduSession kuduSession = kuduConfig.kuduSession();
|
|
|
int i = 0;
|
|
|
- for (Windspeedforecastshortterm boj : list){
|
|
|
+ for (Windspeedforecastshortterm boj : list) {
|
|
|
Insert insert = kuduTable.newInsert();
|
|
|
// 获取Row对象,设置插入的值
|
|
|
PartialRow row = insert.getRow();
|
|
|
row.addObject("id", SnowFlakeUtil.generateIdL());
|
|
|
- long time = boj.getCalctime().getTime()+28800000;
|
|
|
- row.addObject("calctime", time*1000);
|
|
|
+ long time = boj.getCalctime().getTime() + 28800000;
|
|
|
+ row.addObject("calctime", time * 1000);
|
|
|
row.addObject("forecasttype", boj.getForecasttype());
|
|
|
row.addObject("stationid", boj.getStationid());
|
|
|
row.addObject("projectid", boj.getProjectid());
|
|
@@ -74,7 +75,7 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
|
|
|
|
|
|
// 先不提交kudu
|
|
|
kuduSession.apply(insert);
|
|
|
- i ++;
|
|
|
+ i++;
|
|
|
if (i % kuduConfig.getCount() == 0)
|
|
|
kuduSession.flush(); //批量写入kudu
|
|
|
}
|
|
@@ -94,16 +95,16 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
|
|
|
|
|
|
@Override
|
|
|
public JSONObject getContrast(String stationid, Date starttime, Date endtime, int timescale) {
|
|
|
- Date dateStartQntq = DateUtil.dateTimeAddYear(starttime,-1);
|
|
|
- Date dateEndQntq = DateUtil.dateTimeAddYear(endtime,-1);
|
|
|
+ Date dateStartQntq = DateUtil.dateTimeAddYear(starttime, -1);
|
|
|
+ Date dateEndQntq = DateUtil.dateTimeAddYear(endtime, -1);
|
|
|
|
|
|
//list1短期 list2超短期 list3去年同期短期 list4去年同期超短期
|
|
|
- List<Windspeedforecastshortterm> list1 = getShortterm(stationid,starttime,endtime);
|
|
|
- List<Windspeedforecastspshortterm> list2 = getSpShortterm(stationid,starttime,endtime,timescale);
|
|
|
- List<Windspeedforecastshortterm> list3 = getShortterm(stationid,dateStartQntq,dateEndQntq);
|
|
|
- List<Windspeedforecastspshortterm> list4 = getSpShortterm(stationid,dateStartQntq,dateEndQntq,timescale);
|
|
|
+ List<Windspeedforecastshortterm> list1 = getShortterm(stationid, starttime, endtime);
|
|
|
+ List<Windspeedforecastspshortterm> list2 = getSpShortterm(stationid, starttime, endtime, timescale);
|
|
|
+ List<Windspeedforecastshortterm> list3 = getShortterm(stationid, dateStartQntq, dateEndQntq);
|
|
|
+ List<Windspeedforecastspshortterm> list4 = getSpShortterm(stationid, dateStartQntq, dateEndQntq, timescale);
|
|
|
List<WindspeedforecastContrast> windspeedforecastContrasts = new ArrayList<>();
|
|
|
- list1.forEach(l->{
|
|
|
+ list1.forEach(l -> {
|
|
|
WindspeedforecastContrast wsfcc = new WindspeedforecastContrast();
|
|
|
wsfcc.setCalctime(l.getCalctime());
|
|
|
wsfcc.setActualpower(l.getActualpower());
|
|
@@ -112,25 +113,31 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
|
|
|
wsfcc.setForecastwindspeed(l.getForecastwindspeed());
|
|
|
windspeedforecastContrasts.add(wsfcc);
|
|
|
});
|
|
|
- Map<Date, WindspeedforecastContrast> contrastMap = windspeedforecastContrasts.stream().collect(Collectors.toMap(WindspeedforecastContrast::getCalctime, Function.identity(),(key1,key2)->key2));
|
|
|
+ Map<Date, WindspeedforecastContrast> contrastMap = windspeedforecastContrasts.stream().collect(Collectors.toMap(WindspeedforecastContrast::getCalctime, Function.identity(), (key1, key2) -> key2));
|
|
|
|
|
|
- list2.forEach(l-> {
|
|
|
+ list2.forEach(l -> {
|
|
|
WindspeedforecastContrast wsfcc = contrastMap.get(l.getCalctime());
|
|
|
- wsfcc.setForecastpowersp(l.getForecastpower());
|
|
|
- wsfcc.setForecastwindspeedsp(l.getForecastwindspeed());
|
|
|
+ if (wsfcc != null) {
|
|
|
+ wsfcc.setForecastpowersp(l.getForecastpower());
|
|
|
+ wsfcc.setForecastwindspeedsp(l.getForecastwindspeed());
|
|
|
+ }
|
|
|
});
|
|
|
//给年份加一年,然后匹配
|
|
|
- list3.forEach(l-> {
|
|
|
- WindspeedforecastContrast wsfcc = contrastMap.get(DateUtil.dateTimeAddYear(l.getCalctime(),1));
|
|
|
- wsfcc.setActualpowertq(l.getActualpower());
|
|
|
- wsfcc.setForecastpowertq(l.getForecastpower());
|
|
|
- wsfcc.setActualwindspeedtq(l.getActualwindspeed());
|
|
|
- wsfcc.setForecastwindspeedtq(l.getForecastwindspeed());
|
|
|
+ list3.forEach(l -> {
|
|
|
+ WindspeedforecastContrast wsfcc = contrastMap.get(DateUtil.dateTimeAddYear(l.getCalctime(), 1));
|
|
|
+ if (wsfcc != null) {
|
|
|
+ wsfcc.setActualpowertq(l.getActualpower());
|
|
|
+ wsfcc.setForecastpowertq(l.getForecastpower());
|
|
|
+ wsfcc.setActualwindspeedtq(l.getActualwindspeed());
|
|
|
+ wsfcc.setForecastwindspeedtq(l.getForecastwindspeed());
|
|
|
+ }
|
|
|
});
|
|
|
- list4.forEach(l-> {
|
|
|
- WindspeedforecastContrast wsfcc = contrastMap.get(DateUtil.dateTimeAddYear(l.getCalctime(),1));
|
|
|
- wsfcc.setForecastpowersptq(l.getForecastpower());
|
|
|
- wsfcc.setForecastwindspeedsptq(l.getForecastwindspeed());
|
|
|
+ list4.forEach(l -> {
|
|
|
+ WindspeedforecastContrast wsfcc = contrastMap.get(DateUtil.dateTimeAddYear(l.getCalctime(), 1));
|
|
|
+ if (wsfcc != null) {
|
|
|
+ wsfcc.setForecastpowersptq(l.getForecastpower());
|
|
|
+ wsfcc.setForecastwindspeedsptq(l.getForecastwindspeed());
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
//根据时间排序
|
|
@@ -145,7 +152,7 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
|
|
|
private List<Windspeedforecastshortterm> getShortterm(String stationid, Date dateStart, Date dateEnd) {
|
|
|
QueryWrapper<Windspeedforecastshortterm> wrapper = new QueryWrapper<>();
|
|
|
wrapper.eq("stationid", stationid)
|
|
|
- .eq("algorithmmodel","风电_极限学习机_功率_中国大陆")
|
|
|
+ .eq("algorithmmodel", "风电_极限学习机_功率_中国大陆")
|
|
|
.between("calctime", dateStart, dateEnd).orderByDesc("calctime");
|
|
|
return baseMapper.selectList(wrapper);
|
|
|
}
|
|
@@ -153,7 +160,7 @@ public class WindspeedforecastshorttermServiceImpl extends ServiceImpl<Windspeed
|
|
|
/**
|
|
|
* 超短期功率
|
|
|
*/
|
|
|
- private List<Windspeedforecastspshortterm> getSpShortterm(String stationid, Date dateStart, Date dateEnd,int timescale) {
|
|
|
+ private List<Windspeedforecastspshortterm> getSpShortterm(String stationid, Date dateStart, Date dateEnd, int timescale) {
|
|
|
QueryWrapper<Windspeedforecastspshortterm> wrapper = new QueryWrapper<>();
|
|
|
wrapper.eq("stationid", stationid)
|
|
|
.between("calctime", dateStart, dateEnd)
|