|
@@ -1,25 +1,11 @@
|
|
|
package com.gyee.frame.service.weather;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.alibaba.fastjson.TypeReference;
|
|
|
import com.gyee.frame.common.cache.RedisUtils;
|
|
|
-import com.gyee.frame.common.conf.V2Config;
|
|
|
-import com.gyee.frame.common.spring.InitialRunner;
|
|
|
-import com.gyee.frame.model.auto.Line;
|
|
|
-import com.gyee.frame.model.auto.Project;
|
|
|
-import com.gyee.frame.model.auto.Windpowerstation;
|
|
|
-import com.gyee.frame.model.custom.weather.*;
|
|
|
-import com.gyee.frame.util.MathUtil;
|
|
|
-import com.gyee.frame.util.StringUtils;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.web.client.HttpClientErrorException;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -37,280 +23,280 @@ public class WeatherDay5Service {
|
|
|
|
|
|
Map<String,Object> result=new HashMap<>();
|
|
|
java.util.List<Map<String,Object>> lsmap=new ArrayList<>();
|
|
|
-
|
|
|
-
|
|
|
- if(StringUtils.notEmp(id))
|
|
|
- {
|
|
|
-
|
|
|
- if (InitialRunner.wpmap.containsKey(id)) {
|
|
|
- Windpowerstation wp = InitialRunner.wpmap.get(id);
|
|
|
-
|
|
|
- id=wp.getId();
|
|
|
-
|
|
|
-
|
|
|
- } else if (InitialRunner.pjmap.containsKey(id)) {
|
|
|
- Project pj = InitialRunner.pjmap.get(id);
|
|
|
- Windpowerstation wp = InitialRunner.wpmap.get(pj.getWindpowerstationid());
|
|
|
- id=wp.getId();
|
|
|
- } else if (InitialRunner.lnmap.containsKey(id)) {
|
|
|
- Line ln = InitialRunner.lnmap.get(id);
|
|
|
- Project pj = InitialRunner.pjmap.get(ln.getProjectid());
|
|
|
- Windpowerstation wp = InitialRunner.wpmap.get(pj.getWindpowerstationid());
|
|
|
- id=wp.getId();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- String weatherStr =null;
|
|
|
- JsonRootBean jsonRootBean = null;
|
|
|
-
|
|
|
- try {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- StringBuilder sb=new StringBuilder();
|
|
|
- sb.append(V2Config.getWeatherurl()).append("/meteorological/datas?");
|
|
|
-
|
|
|
- if(id.equals("0") || id.equals("-1") || id.equals("-2"))
|
|
|
- {
|
|
|
- sb.append("&wpid=").append(V2Config.getWeatherqygs());
|
|
|
- }else {
|
|
|
- sb.append("&wpid=").append(id);
|
|
|
- }
|
|
|
-
|
|
|
- sb.append("&model=forecast");
|
|
|
-
|
|
|
- String url=String.valueOf(sb);
|
|
|
-
|
|
|
- ResponseEntity<JSONObject> resp = restTemplate.getForEntity(url, JSONObject.class);
|
|
|
-
|
|
|
- if(StringUtils.notEmp(resp.getBody()))
|
|
|
- {
|
|
|
- weatherStr = resp.getBody().toJSONString();
|
|
|
- }else
|
|
|
- {
|
|
|
- weatherStr = "";
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- jsonRootBean = JSONObject.parseObject(weatherStr, new TypeReference<JsonRootBean>(){});
|
|
|
-
|
|
|
-
|
|
|
- } catch (HttpClientErrorException exception) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
- if(StringUtils.notEmp(jsonRootBean))
|
|
|
- {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if(null!=jsonRootBean && null!=jsonRootBean.getList() && !jsonRootBean.getList().isEmpty())
|
|
|
- {
|
|
|
-
|
|
|
- for(List weatherReal:jsonRootBean.getList())
|
|
|
- {
|
|
|
- Map<String,Object> map=new HashMap<>();
|
|
|
-
|
|
|
- map.put("time",weatherReal.getDt()*1000);
|
|
|
-
|
|
|
- double qxd=weatherReal.getVisibility();
|
|
|
- map.put("qxd", MathUtil.twoBit(qxd/1000));
|
|
|
-
|
|
|
- if(null!=weatherReal.getMain())
|
|
|
- {
|
|
|
- Main main=weatherReal.getMain();
|
|
|
- map.put("wd",main.getTemp());
|
|
|
- map.put("dqyl",main.getPressure());
|
|
|
- map.put("sd",main.getHumidity());
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if(null!=weatherReal.getClouds())
|
|
|
- {
|
|
|
- Clouds clouds=weatherReal.getClouds();
|
|
|
-
|
|
|
- map.put("yunliang",clouds.getAll());
|
|
|
- }
|
|
|
-
|
|
|
- if(null!=weatherReal.getSys())
|
|
|
- {
|
|
|
- Sys sys=weatherReal.getSys();
|
|
|
- if(StringUtils.notEmp(sys.getSunrise()))
|
|
|
- {
|
|
|
- Date date=new Date(sys.getSunrise()*1000);
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
|
|
|
-
|
|
|
- map.put("richushijian", "05:56");
|
|
|
-
|
|
|
- }
|
|
|
- if(StringUtils.notEmp(sys.getSunset()))
|
|
|
- {
|
|
|
- Date date=new Date(sys.getSunset()*1000);
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
|
|
|
-
|
|
|
- map.put("riluoshijian", "20:05");
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(null!=weatherReal.getWind())
|
|
|
- {
|
|
|
- Wind wind=weatherReal.getWind();
|
|
|
- map.put("fs",wind.getSpeed());
|
|
|
-
|
|
|
- if(StringUtils.notEmp(wind.getDeg()))
|
|
|
- {
|
|
|
- double fx=wind.getDeg();
|
|
|
-
|
|
|
- map.put("fx",fx);
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+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
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if(null!=weatherReal.getWeather() && !weatherReal.getWeather().isEmpty())
|
|
|
- {
|
|
|
- Weather weather=weatherReal.getWeather().get(0);
|
|
|
-
|
|
|
- String icon=weather.getIcon();
|
|
|
-
|
|
|
- if (StringUtils.notEmp(icon))
|
|
|
- {
|
|
|
- if(icon.equals("01d") || icon.equals("01n"))
|
|
|
- {
|
|
|
- map.put("tqmc","晴");
|
|
|
- map.put("tqtp","01");
|
|
|
- }else if(icon.equals("02d") || icon.equals("02n"))
|
|
|
- {
|
|
|
- map.put("tqmc","少云");
|
|
|
- map.put("tqtp","02");
|
|
|
- }else if(icon.equals("03d") || icon.equals("03n"))
|
|
|
- {
|
|
|
- map.put("tqmc","多云");
|
|
|
- map.put("tqtp","06");
|
|
|
- }else if(icon.equals("04d") || icon.equals("04n"))
|
|
|
- {
|
|
|
- map.put("tqmc","阴");
|
|
|
- map.put("tqtp","07");
|
|
|
- }else if(icon.equals("09d") || icon.equals("09n"))
|
|
|
- {
|
|
|
- map.put("tqmc","阵雨");
|
|
|
- map.put("tqtp","13");
|
|
|
- }else if(icon.equals("10d") || icon.equals("10n"))
|
|
|
- {
|
|
|
- map.put("tqmc","雨");
|
|
|
- map.put("tqtp","18");
|
|
|
- }else if(icon.equals("11d") || icon.equals("11n"))
|
|
|
- {
|
|
|
- map.put("tqmc","雷雨");
|
|
|
- map.put("tqtp","15");
|
|
|
- }else if(icon.equals("13d") || icon.equals("13n"))
|
|
|
- {
|
|
|
- map.put("tqmc","雪");
|
|
|
- map.put("tqtp","19");
|
|
|
- }else if(icon.equals("50d") || icon.equals("50n"))
|
|
|
- {
|
|
|
- map.put("tqmc","雾");
|
|
|
- map.put("tqtp","32");
|
|
|
- }else
|
|
|
- {
|
|
|
- map.put("description","晴");
|
|
|
- map.put("tqtp","01");
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- lsmap.add(map);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
result.put("ls",lsmap);
|
|
|
return result;
|