| | |
| | | import java.util.Collections;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.LinkedHashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.apache.jasper.compiler.JspUtil;
|
| | | import org.dom4j.Element;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.util.ObjectUtils;
|
| | |
| | | @Override
|
| | | public List<Map<String, Object>> getWeatherData(Map<String, Object> parameters) throws ParseException {
|
| | | parameters.put("typeFormat", "%Y-%m-%d %H:%i:%s");
|
| | | if (parameters.get("city") == null) {
|
| | | return new ArrayList<Map<String, Object>>();
|
| | | }
|
| | | String cityName = parameters.get("city").toString();
|
| | | Area area = areaMapper.getAreaByName(cityName);
|
| | | Integer code;
|
| | |
| | | String time = parameters.get("time").toString();
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
| | | SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH");
|
| | | Date now = new Date();
|
| | | Date selectTime = sdf1.parse(time + " 01:00:00");
|
| | | Calendar cal = Calendar.getInstance();
|
| | |
| | | parameters.put("end", end);
|
| | | Integer fcode = 0;
|
| | | List<Map<String, Object>> forecastList = forecastWeatherMapper.getForecast(parameters);
|
| | |
|
| | | if (forecastList.size() == 0) {
|
| | | List<Area> areaList = areaMapper.getAreaByCityCode(code);
|
| | | for (Area area1 : areaList) {
|
| | |
| | | }
|
| | |
|
| | | String ac = parameters.get("cityCode").toString();
|
| | | if(name.equals("沧州市")){
|
| | | ac="130900";
|
| | | }
|
| | | List<Map<String, Object>> aqiList = hangzhouAqiMapper.getAqi(parameters);
|
| | | if (aqiList.size() == 0) {
|
| | | parameters.put("cityCode", code);
|
| | |
| | | } else {
|
| | | params.put("areaCode", Integer.valueOf(ac));
|
| | | }
|
| | | List<MonitorPoint> monitorList = monitorPointMapper.getMonitorList(params);
|
| | |
|
| | | List<MonitorPoint> monitorList = monitorPointMapper.getMonitorList(params);
|
| | | List<Integer> pointList = new ArrayList<>();
|
| | | for (MonitorPoint point : monitorList) {
|
| | | Integer pointId = point.getId();
|
| | |
| | |
|
| | | List<Map<String, Object>> resultList = new ArrayList<>();
|
| | |
|
| | | if (foreList.size() == 0) {
|
| | | for (Map<String, Object> map : realWeatherList) {
|
| | | Map<String,Object> hashMap=new LinkedHashMap<>();
|
| | | hashMap.put("time",map.get("time").toString());
|
| | | hashMap.put("type","预测");
|
| | | hashMap.put("city",map.get("city").toString());
|
| | | foreList.add(hashMap);
|
| | | }
|
| | | }
|
| | |
|
| | | for (Map<String, Object> foreMap : foreList) {
|
| | | for (Map<String, Object> realMap : list) {
|
| | | if (foreMap.get("time").equals(realMap.get("time"))) {
|
| | |
| | | if (nowHour < 8) {
|
| | | return resultList;
|
| | | }
|
| | |
|
| | | if (nowMinute >= 46) {
|
| | | nowHour = nowHour + 1;
|
| | | cal.setTime(now);
|
| | | cal.add(Calendar.HOUR_OF_DAY, 1);
|
| | | format = sdf1.format(cal.getTime()).substring(0, 13) + ":00:00";
|
| | | }
|
| | |
|
| | | for (Map<String, Object> resultMap : resultList) {
|
| | | if (resultMap.get("type").equals("实测")) {
|
| | | if (sdf.parse(time).getTime() == sdf.parse(sdf.format(now)).getTime()) {
|
| | |
| | | hashMap.put("end", endTime);
|
| | | if (rhour == 0) {
|
| | | rhour = 24;
|
| | | }
|
| | |
|
| | | if (nowMinute >= 46) {
|
| | | nowHour = nowHour + 1;
|
| | | }
|
| | |
|
| | | if (rhour == nowHour) {
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Map<String, Object>> getWeatherDataByDay(Map<String, Object> parameters) throws ParseException {
|
| | | String selectTime = parameters.get("time").toString();
|
| | | String cityName = parameters.get("city").toString();
|
| | | Area area = areaMapper.getAreaByName(cityName);
|
| | | Integer code;
|
| | | String name;
|
| | | if (area == null) {
|
| | | City city = cityMapper.getCityByName(cityName);
|
| | | if (city == null) {
|
| | | Province province = provinceMapper.getProvinceByName(cityName);
|
| | | code = province.getProvinceCode();
|
| | | name = province.getProvinceName();
|
| | | } else {
|
| | | code = city.getCityCode();
|
| | | name = city.getCityName();
|
| | | }
|
| | | } else {
|
| | | code = area.getAreaCode();
|
| | | name = area.getAreaName();
|
| | | }
|
| | |
|
| | | parameters.put("cityCode", code);
|
| | | parameters.put("name", name);
|
| | | return null;
|
| | | }
|
| | |
|
| | | }
|