|
@@ -10,11 +10,9 @@ import com.gyee.common.util.JSONUtils;
|
|
|
import com.gyee.common.util.RestTemplateUtil;
|
|
|
import com.gyee.meteorological.init.CacheContext;
|
|
|
import com.gyee.meteorological.model.*;
|
|
|
-import com.gyee.meteorological.model.auto.Coordinate;
|
|
|
-import com.gyee.meteorological.model.auto.ProEconCoordinate;
|
|
|
-import com.gyee.meteorological.model.auto.ProEconMeteorological;
|
|
|
-import com.gyee.meteorological.model.auto.ProEconMeteorologicalfourdays;
|
|
|
+import com.gyee.meteorological.model.auto.*;
|
|
|
import com.gyee.meteorological.service.RedisService;
|
|
|
+import com.gyee.meteorological.service.auto.IProBasicPowerstationService;
|
|
|
import com.gyee.meteorological.service.auto.IProEconCoordinateService;
|
|
|
import com.gyee.meteorological.service.auto.IProEconMeteorologicalService;
|
|
|
import com.gyee.meteorological.service.auto.IProEconMeteorologicalfourdaysService;
|
|
@@ -53,6 +51,8 @@ public class CollectionService {
|
|
|
private IProEconMeteorologicalfourdaysService proEconMeteorologicalfourdaysService;
|
|
|
@Resource
|
|
|
private IProEconCoordinateService proEconCoordinateService;
|
|
|
+ @Resource
|
|
|
+ private IProBasicPowerstationService proBasicPowerstationService;
|
|
|
|
|
|
@Value("${meteorological.model}")
|
|
|
private String model;
|
|
@@ -79,18 +79,19 @@ public class CollectionService {
|
|
|
|
|
|
|
|
|
public void saveMeteorological() throws IOException {
|
|
|
+ List<ProBasicPowerstation> powerstations = proBasicPowerstationService.list().stream().filter(wp -> wp.getIsAble().equals(1) && wp.getLatitude()!=null && wp.getLongitude()!=null).collect(Collectors.toList());
|
|
|
List<ProEconCoordinate> proEconCoordinates = proEconCoordinateService.list().stream().filter(i->i.getIsOpen()!=null && i.getIsOpen().equals(1)).collect(Collectors.toList());
|
|
|
// String property = System.getProperty("user.dir");
|
|
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
- proEconCoordinates.stream().forEach(c->{
|
|
|
- String restUrl = url+"weather?units=metric&land=zh_cn&lat="+c.getLat()+"&lon="+c.getLon()+"&appid="+weatherkey;
|
|
|
+ powerstations.stream().forEach(c->{
|
|
|
+ String restUrl = url+"weather?units=metric&land=zh_cn&lat="+c.getLatitude()+"&lon="+c.getLongitude()+"&appid="+weatherkey;
|
|
|
String weatherStr = RestTemplateUtil.get(restUrl, null);
|
|
|
WeatherReal weatherReal = JSONObject.parseObject(weatherStr, new TypeReference<WeatherReal>() {
|
|
|
});
|
|
|
ProEconMeteorological proEconMeteorological = new ProEconMeteorological();
|
|
|
proEconMeteorological.setId(CommonUtils.getUUID());
|
|
|
- proEconMeteorological.setWindpowerstationId(c.getWindpowerstationId());
|
|
|
+ proEconMeteorological.setWindpowerstationId(c.getId());
|
|
|
|
|
|
if(null!=weatherReal.getMain()) {
|
|
|
Main main=weatherReal.getMain();
|
|
@@ -248,7 +249,7 @@ public class CollectionService {
|
|
|
proEconMeteorological.setDatetime(date);
|
|
|
|
|
|
QueryWrapper<ProEconMeteorological> qw = new QueryWrapper<>();
|
|
|
- qw.eq("windpowerstation_id",c.getWindpowerstationId());
|
|
|
+ qw.eq("windpowerstation_id",c.getId());
|
|
|
qw.eq("datetime",date);
|
|
|
List<ProEconMeteorological> list = proEconMeteorologicalService.list(qw);
|
|
|
if (StringUtils.isEmpty(list)){
|
|
@@ -262,8 +263,7 @@ public class CollectionService {
|
|
|
}
|
|
|
|
|
|
public void saveMeteorologicalFiveDay(){
|
|
|
-
|
|
|
- List<ProEconCoordinate> proEconCoordinates = proEconCoordinateService.list().stream().filter(i->i.getIsOpen()!=null && i.getIsOpen().equals(1)).collect(Collectors.toList());
|
|
|
+ List<ProBasicPowerstation> powerstations = proBasicPowerstationService.list().stream().filter(wp -> wp.getIsAble().equals(1) && wp.getLatitude()!=null && wp.getLongitude()!=null).collect(Collectors.toList());
|
|
|
// String property = System.getProperty("user.dir");
|
|
|
QueryWrapper<ProEconMeteorologicalfourdays> qw = new QueryWrapper<>();
|
|
|
qw.ge("datetime",DateUtils.getCurrentDate());
|
|
@@ -271,8 +271,8 @@ public class CollectionService {
|
|
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
List<ProEconMeteorologicalfourdays> resultList = new ArrayList<>();
|
|
|
- proEconCoordinates.stream().forEach(c->{
|
|
|
- String restUrl = url+"forecast?units=metric&land=zh_cn&lat="+c.getLat()+"&lon="+c.getLon()+"&appid="+weatherkey;
|
|
|
+ powerstations.stream().forEach(c->{
|
|
|
+ String restUrl = url+"forecast?units=metric&land=zh_cn&lat="+c.getLatitude()+"&lon="+c.getLongitude()+"&appid="+weatherkey;
|
|
|
String weatherStr = RestTemplateUtil.get(restUrl, null);
|
|
|
JsonRootBean jsonRootBean = JSONObject.parseObject(weatherStr, new TypeReference<JsonRootBean>() {
|
|
|
});
|
|
@@ -300,7 +300,7 @@ public class CollectionService {
|
|
|
Date date=DateUtils.parseLongToDate(weatherReal.getDt()*1000);
|
|
|
proEconMeteorological.setId(CommonUtils.getUUID());
|
|
|
proEconMeteorological.setDatetime(date);
|
|
|
- proEconMeteorological.setWindpowerstationId(c.getWindpowerstationId());
|
|
|
+ proEconMeteorological.setWindpowerstationId(c.getId());
|
|
|
proEconMeteorological.setVisibility(weatherReal.getVisibility());
|
|
|
//日出时间
|
|
|
proEconMeteorological.setSunrise(sunriseString);
|