| | |
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Collection;
|
| | | import java.util.Collections;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | |
| | | import com.moral.entity.Area;
|
| | | import com.moral.entity.AreaNames;
|
| | | import com.moral.entity.City;
|
| | | import com.moral.entity.Device;
|
| | | import com.moral.entity.MonitorPoint;
|
| | | import com.moral.entity.Organization;
|
| | | import com.moral.entity.Province;
|
| | | import com.moral.mapper.AreaMapper;
|
| | | import com.moral.mapper.CityMapper;
|
| | | import com.moral.mapper.DeviceMapper;
|
| | | import com.moral.mapper.ForecastWeatherMapper;
|
| | | import com.moral.mapper.HangzhouAqiMapper;
|
| | | import com.moral.mapper.HistoryHourlyMapper;
|
| | | import com.moral.mapper.MonitorPointMapper;
|
| | | import com.moral.mapper.ProvinceMapper;
|
| | | import com.moral.mapper.RealTimeWeatherMapper;
|
| | | import com.moral.mapper.RealWeatherMapper;
|
| | | import com.moral.service.OrganizationService;
|
| | | import com.moral.service.WeatherService;
|
| | |
|
| | |
| | | private ProvinceMapper provinceMapper;
|
| | |
|
| | | @Resource
|
| | | private RealTimeWeatherMapper realTimeWeatherMapper;
|
| | | private RealWeatherMapper realWeatherMapper;
|
| | |
|
| | | @Resource
|
| | | private DeviceMapper deviceMapper;
|
| | |
|
| | | @Resource
|
| | | private HistoryHourlyMapper historyHourlyMapper;
|
| | |
|
| | | @Override
|
| | | public Map<String, Object> getWeatherDataByRegion(Map<String, Object> parameters) {
|
| | |
| | |
|
| | | @Override
|
| | | public List<Map<String, Object>> getForecastAndReal(Map<String, Object> parameters) throws ParseException {
|
| | | parameters.put("typeFormat", "%Y-%m-%d %H:%i:%s");
|
| | | String monitorPointId = parameters.get("monitorPointId").toString();
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
| | | String time = parameters.get("time").toString() + " 00:00:00";
|
| | |
| | | String nextDay = sdf.format(c.getTime());
|
| | | parameters.put("start", sdf.parse(time));
|
| | | parameters.put("end", sdf.parse(nextDay));
|
| | | MonitorPoint monitorPoint = monitorPointMapper.selectByPrimaryKey(Integer.valueOf(monitorPointId));
|
| | |
|
| | | //List<Map<String, Object>> forecastList = forecastWeatherMapper.getForecastHour(parameters);
|
| | |
|
| | | if (monitorPoint.getAreaCode() == null) {
|
| | | parameters.put("cityCode", monitorPoint.getCityCode());
|
| | | } else {
|
| | | parameters.put("cityCode", monitorPoint.getAreaCode());
|
| | | }
|
| | | List<Map<String, Object>> aqiList = hangzhouAqiMapper.getAqiDataByAreaCode(parameters);
|
| | | List<Map<String, Object>> forecastList = forecastWeatherMapper.getForecastHour(parameters);
|
| | |
|
| | | MonitorPoint monitorPoint = monitorPointMapper.selectByPrimaryKey(Integer.valueOf(monitorPointId));
|
| | | parameters.put("areaCode", monitorPoint.getAreaCode());
|
| | | String sensors = "O3C";
|
| | | String sensor1 = "O3";
|
| | | parameters.put("sensors", sensors);
|
| | | parameters.put("sensors1", sensor1);
|
| | | parameters.put("sensors2", sensor1);
|
| | | List<Map<String, Object>> aqiList = hangzhouAqiMapper.getAqiDataByAreaCode(parameters);
|
| | | if (aqiList.size() == 0) {
|
| | | parameters.put("areaCode", monitorPoint.getCityCode());
|
| | | parameters.put("cityCode", monitorPoint.getCityCode());
|
| | | aqiList = hangzhouAqiMapper.getAqiDataByAreaCode(parameters);
|
| | | }
|
| | |
|
| | | for (Map<String, Object> map : aqiList) {
|
| | | String O3 = map.get("O3").toString().replace("\"", "");
|
| | | map.put("O3", O3);
|
| | |
| | | }
|
| | | map.put("time", Integer.valueOf(hour));
|
| | | values.add("");
|
| | | values.add(aqiMap.get(sensor1).toString());
|
| | | values.add(aqiMap.get("O3").toString());
|
| | | map.put("values", values);
|
| | | resultList.add(map);
|
| | | }
|
| | |
| | | hour = "24";
|
| | | }
|
| | | map.put("time", Integer.valueOf(hour));
|
| | | values.add(forecastMap.get("result").toString().replace("\"", ""));
|
| | | if (forecastMap.get("result") != null) {
|
| | | values.add(forecastMap.get("result").toString().replace("\"", ""));
|
| | | } else {
|
| | | values.add("");
|
| | | }
|
| | | values.add("");
|
| | | map.put("values", values);
|
| | | resultList.add(map);
|
| | |
| | | hour = "24";
|
| | | }
|
| | | map.put("time", Integer.valueOf(hour));
|
| | | values.add(forecastMap.get("result").toString().replace("\"", ""));
|
| | | if (forecastMap.get("result") != null) {
|
| | | values.add(forecastMap.get("result").toString().replace("\"", ""));
|
| | | } else {
|
| | | values.add("");
|
| | | }
|
| | | for (Map<String, Object> aqiMap : aqiList) {
|
| | | if (forecastMap.get("time").equals(aqiMap.get("time"))) {
|
| | | values.add(aqiMap.get(sensor1).toString());
|
| | | values.add(aqiMap.get("O3").toString());
|
| | | }
|
| | | }
|
| | | map.put("values", values);
|
| | |
| | |
|
| | | @Override
|
| | | public List<Map<String, Object>> getWeatherData(Map<String, Object> parameters) throws ParseException {
|
| | | parameters.put("typeFormat", "%Y-%m-%d %H:%i:%s");
|
| | | String cityName = parameters.get("city").toString();
|
| | | Area area = areaMapper.getAreaByName(cityName);
|
| | | MonitorPoint monitorPoint;
|
| | | Integer areaCode = 0;
|
| | | Integer cityCode = 0;
|
| | | Integer parentCode = 0;
|
| | | Integer code = 0;
|
| | | String name = "";
|
| | | if (area == null) {
|
| | | City city = cityMapper.getCityByName(cityName);
|
| | | if (city == null) {
|
| | | Province province = provinceMapper.getProvinceByName(cityName);
|
| | | Integer provinceCode = province.getProvinceCode();
|
| | | monitorPoint = monitorPointMapper.getFirstMonitorPointByProvinceCode(provinceCode);
|
| | | parameters.put("areaCode", provinceCode);
|
| | | parameters.put("city", province.getProvinceName());
|
| | | code = province.getProvinceCode();
|
| | | name = province.getProvinceName();
|
| | | } else {
|
| | | cityCode = city.getCityCode();
|
| | | monitorPoint = monitorPointMapper.getFirstMonitorPointByCityCode(cityCode);
|
| | | parameters.put("areaCode", cityCode);
|
| | | parameters.put("city", city.getCityName());
|
| | | code = city.getCityCode();
|
| | | parentCode = city.getProvinceCode();
|
| | | name = city.getCityName();
|
| | | }
|
| | | } else {
|
| | | areaCode = area.getAreaCode();
|
| | | monitorPoint = monitorPointMapper.getFirstMonitorPointByAreaCode(areaCode);
|
| | | cityCode = area.getCityCode();
|
| | | parameters.put("areaCode", areaCode);
|
| | | parameters.put("city", area.getAreaName());
|
| | | code = area.getAreaCode();
|
| | | parentCode = area.getCityCode();
|
| | | name = area.getAreaName();
|
| | | }
|
| | | if (monitorPoint == null) {
|
| | | return new ArrayList<>();
|
| | | }
|
| | | parameters.put("monitorPointId", monitorPoint.getId());
|
| | |
|
| | | parameters.put("cityCode", code);
|
| | | parameters.put("name", name);
|
| | | parameters.put("areaCode", code);
|
| | |
|
| | |
|
| | | String time = parameters.get("time").toString();
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
| | | Calendar c = Calendar.getInstance();
|
| | | c.setTime(sdf.parse(time));
|
| | | c.add(Calendar.HOUR_OF_DAY, 1);
|
| | | Date start = c.getTime();
|
| | | c.add(Calendar.DAY_OF_MONTH, 1);
|
| | | Date end = c.getTime();
|
| | | parameters.put("start", start);
|
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
| | | Date now = new Date();
|
| | | Date selectTime = sdf1.parse(time + " 01:00:00");
|
| | | Calendar cal = Calendar.getInstance();
|
| | | cal.setTime(selectTime);
|
| | | cal.add(Calendar.DAY_OF_MONTH, 1);
|
| | | Date end = cal.getTime();
|
| | | cal.setTime(sdf.parse(time));
|
| | | cal.add(Calendar.DAY_OF_MONTH, -1);
|
| | | String beforeDay = sdf.format(cal.getTime());
|
| | | parameters.put("start", selectTime);
|
| | | parameters.put("end", end);
|
| | | List<Map<String, Object>> forecastList = forecastWeatherMapper.getForecast(parameters);
|
| | | List<Map<String, Object>> aqiList = hangzhouAqiMapper.getAqi(parameters);
|
| | | if (aqiList.size() == 0) {
|
| | | parameters.put("areaCode", cityCode);
|
| | | aqiList = hangzhouAqiMapper.getAqi(parameters);
|
| | | }
|
| | | List<Map<String, Object>> list1 = new ArrayList<>();
|
| | | for (Map<String, Object> map : aqiList) {
|
| | | Map<String, Object> hashMap = new HashMap<>();
|
| | | hashMap.put("time", map.get("time"));
|
| | | Map<String, Object> jsonMap = (Map<String, Object>) JSONObject.parse(map.get("json").toString());
|
| | | hashMap.putAll(jsonMap);
|
| | | hashMap.put("city", parameters.get("city").toString());
|
| | | list1.add(hashMap);
|
| | | }
|
| | |
|
| | | List<Map<String, Object>> realTimeList = realTimeWeatherMapper.getRealTimeWeather(parameters);
|
| | | List<Map<String, Object>> realList = new ArrayList<>();
|
| | | for (Map<String, Object> map : realTimeList) {
|
| | | Map<String, Object> hashMap = new HashMap<>();
|
| | | hashMap.put("time", map.get("time"));
|
| | | hashMap.put("type", "实际");
|
| | | hashMap.put("city", parameters.get("city").toString());
|
| | | Map<String, Object> jsonMap = (Map<String, Object>) JSONObject.parse(map.get("json").toString());
|
| | | hashMap.putAll(jsonMap);
|
| | | realList.add(hashMap);
|
| | | }
|
| | |
|
| | | for (Map<String, Object> realTimeMap : realList) {
|
| | | for (Map<String, Object> aqiMap : list1) {
|
| | | if (aqiMap.get("time").equals(realTimeMap.get("time"))) {
|
| | | realTimeMap.putAll(aqiMap);
|
| | | if (forecastList.size() == 0) {
|
| | | parameters.put("cityCode", parentCode);
|
| | | forecastList = forecastWeatherMapper.getForecast(parameters);
|
| | | if (forecastList.size() == 0) {
|
| | | List<Area> areaList = areaMapper.getAreaByCityCode(code);
|
| | | for (Area area1 : areaList) {
|
| | | parameters.put("cityCode", area1.getAreaCode());
|
| | | forecastList = forecastWeatherMapper.getForecast(parameters);
|
| | | if (forecastList.size() != 0) {
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | List<Map<String, Object>> foreList = new ArrayList<>();
|
| | | for (Map<String, Object> forecastMap : forecastList) {
|
| | | Map<String, Object> jsonMap = (Map<String, Object>) JSONObject.parse(forecastMap.get("json").toString());
|
| | | Map<String, Object> hashMap = new HashMap<>();
|
| | | hashMap.put("temp", jsonMap.get("tem"));
|
| | | hashMap.put("windDir", jsonMap.get("win"));
|
| | | hashMap.put("windLevel", jsonMap.get("win_speed"));
|
| | | hashMap.put("condition", jsonMap.get("wea"));
|
| | | hashMap.put("time", forecastMap.get("time").toString());
|
| | | hashMap.put("type", "预测");
|
| | | hashMap.put("city", parameters.get("city").toString());
|
| | | hashMap.put("TVOC", "");
|
| | | hashMap.put("altitude", "");
|
| | | hashMap.put("vegetation", "");
|
| | | hashMap.put("AQI", "");
|
| | | hashMap.put("SO2C", "");
|
| | | hashMap.put("NO2C", "");
|
| | | hashMap.put("COC", "");
|
| | | hashMap.put("O3C", "");
|
| | | hashMap.put("PM25C", "");
|
| | | hashMap.put("PM10C", "");
|
| | | hashMap.put("city", parameters.get("name").toString());
|
| | | if (sdf.parse(time).getTime() <= now.getTime()) {
|
| | | hashMap.put("fxTime", (beforeDay + " 15:00").substring(5, 16));
|
| | | } else {
|
| | | String format = sdf1.format(now).split(" ")[0];
|
| | | Date date1 = sdf1.parse(format + " 07:00:00");
|
| | | Date date2 = sdf1.parse(format + " 15:00:00");
|
| | | if (now.getTime() > date2.getTime()) {
|
| | | hashMap.put("fxTime", (beforeDay + " 15:00").substring(5, 16));
|
| | | } else if (now.getTime() > date1.getTime() && (now.getTime() < date2.getTime() || now.getTime() == date2.getTime())) {
|
| | | hashMap.put("fxTime", (beforeDay + " 07:00").substring(5, 16));
|
| | | }
|
| | | }
|
| | | Map<String, Object> jsonMap = (Map<String, Object>) JSONObject.parse(forecastMap.get("json").toString());
|
| | | hashMap.putAll(jsonMap);
|
| | | foreList.add(hashMap);
|
| | | }
|
| | |
|
| | | List<Map<String, Object>> resultList = new ArrayList<>();
|
| | | for (Map<String, Object> foreMap : foreList) {
|
| | | for (Map<String, Object> realMap : realList) {
|
| | | String ftime = foreMap.get("time").toString();
|
| | | Date endTime = sdf1.parse(ftime);
|
| | | cal.setTime(endTime);
|
| | | cal.add(Calendar.HOUR, -6);
|
| | | Date startTime = cal.getTime();
|
| | | Map<String, Object> hashMap = new HashMap<>();
|
| | | hashMap.put("start", startTime);
|
| | | hashMap.put("end", endTime);
|
| | | hashMap.put("cityCode", Integer.valueOf(parameters.get("cityCode").toString()));
|
| | | Map<String, Object> precip6HourMap = forecastWeatherMapper.getPrecip6Hour(hashMap);
|
| | | foreMap.put("precip6", "");
|
| | | if (precip6HourMap != null) {
|
| | | foreMap.put("precip6", precip6HourMap.get("precip6").toString());
|
| | | }
|
| | | }
|
| | |
|
| | | List<Map<String, Object>> aqiList = hangzhouAqiMapper.getAqi(parameters);
|
| | | if (aqiList.size() == 0) {
|
| | | parameters.put("areaCode", parentCode);
|
| | | aqiList = hangzhouAqiMapper.getAqi(parameters);
|
| | | }
|
| | |
|
| | | List<Map<String, Object>> realAqilist = new ArrayList<>();
|
| | | for (Map<String, Object> aqiMap : aqiList) {
|
| | | Map<String, Object> hashMap = new HashMap<>();
|
| | | hashMap.put("time", aqiMap.get("time"));
|
| | | Map<String, Object> jsonMap = (Map<String, Object>) JSONObject.parse(aqiMap.get("json").toString());
|
| | | hashMap.putAll(jsonMap);
|
| | | hashMap.put("city", parameters.get("name").toString());
|
| | | realAqilist.add(hashMap);
|
| | | }
|
| | |
|
| | | for (Map<String, Object> map : realAqilist) {
|
| | | Date endTime = sdf1.parse(map.get("time").toString());
|
| | | cal.setTime(endTime);
|
| | | cal.add(Calendar.HOUR, -8);
|
| | | Date startTime = cal.getTime();
|
| | | Map<String, Object> hashMap = new HashMap<>();
|
| | | hashMap.put("areaCode", Integer.valueOf(parameters.get("areaCode").toString()));
|
| | | hashMap.put("start", startTime);
|
| | | hashMap.put("end", endTime);
|
| | | Map<String, Object> O3Map = hangzhouAqiMapper.getAvgO3EightHours(hashMap);
|
| | | map.put("O3_8H", O3Map.get("O3_8H").toString());
|
| | | if (O3Map.get("O3C_8H") != null) {
|
| | | map.put("O3C_8H", O3Map.get("O3C_8H").toString());
|
| | | }
|
| | | }
|
| | |
|
| | | //光照
|
| | | String ac = parameters.get("areaCode").toString();
|
| | | Map<String, Object> params = new HashMap<>();
|
| | | if (ac.endsWith("00")) {
|
| | | params.put("cityCode", Integer.valueOf(ac));
|
| | | } else {
|
| | | params.put("areaCode", Integer.valueOf(ac));
|
| | | }
|
| | | List<MonitorPoint> monitorList = monitorPointMapper.getMonitorList(params);
|
| | |
|
| | | List<Integer> pointList = new ArrayList<>();
|
| | | for (MonitorPoint point : monitorList) {
|
| | | Integer pointId = point.getId();
|
| | | pointList.add(pointId);
|
| | | }
|
| | |
|
| | | List<Device> deviceList = deviceMapper.getDeviceListByMonitorPointIds(pointList);
|
| | | List<String> macList = new ArrayList<>();
|
| | | List<Map<String, Object>> beamList = new ArrayList<>();
|
| | | if (deviceList.size() != 0) {
|
| | | for (Device device : deviceList) {
|
| | | String mac = device.getMac();
|
| | | macList.add(mac);
|
| | | }
|
| | |
|
| | | parameters.put("macs", macList);
|
| | | beamList = historyHourlyMapper.getBeamByMacs(parameters);
|
| | | }
|
| | |
|
| | | List<Map<String, Object>> realList = realWeatherMapper.getRealWeather(parameters);
|
| | | List<Map<String, Object>> realWeatherList = new ArrayList<>();
|
| | | for (Map<String, Object> realMap : realList) {
|
| | | Map<String, Object> hashMap = new HashMap<>();
|
| | | hashMap.put("time", realMap.get("time"));
|
| | | Map<String, Object> jsonMap = (Map<String, Object>) JSONObject.parse(realMap.get("json").toString());
|
| | | hashMap.putAll(jsonMap);
|
| | | hashMap.put("city", parameters.get("name").toString());
|
| | | realWeatherList.add(hashMap);
|
| | | }
|
| | |
|
| | | for (Map<String, Object> realMap : realWeatherList) {
|
| | | String rtime = realMap.get("time").toString();
|
| | | for (Map<String, Object> beamMap : beamList) {
|
| | | String btime = beamMap.get("time").toString();
|
| | | if (btime.equals(rtime)) {
|
| | | realMap.put("beam", Math.floor((Double) beamMap.get("beam")));
|
| | | }
|
| | | }
|
| | |
|
| | | Date endTime = sdf1.parse(rtime);
|
| | | cal.setTime(endTime);
|
| | | cal.add(Calendar.HOUR, -6);
|
| | | Date startTime = cal.getTime();
|
| | | Map<String, Object> hashMap = new HashMap<>();
|
| | | hashMap.put("cityCode", Integer.valueOf(parameters.get("areaCode").toString()));
|
| | | hashMap.put("start", startTime);
|
| | | hashMap.put("end", endTime);
|
| | |
|
| | | Map<String, Object> precip6HourMap = realWeatherMapper.getPrecip6Hour(hashMap);
|
| | |
|
| | | if (precip6HourMap != null) {
|
| | | realMap.put("precip6", precip6HourMap.get("precip6").toString());
|
| | | }
|
| | | }
|
| | |
|
| | | List<Map<String, Object>> list = new ArrayList<>();
|
| | | for (int i = 0; i < 24; i++) {
|
| | | list.add(null);
|
| | | }
|
| | |
|
| | | for (Map<String, Object> map : realWeatherList) {
|
| | | Integer t1 = Integer.valueOf(map.get("time").toString().split(" ")[1].split(":")[0]);
|
| | | if (t1 == 0) {
|
| | | list.set(list.size() - 1, map);
|
| | | } else {
|
| | | list.set(t1 - 1, map);
|
| | | }
|
| | | }
|
| | |
|
| | | for (Map<String, Object> map : realAqilist) {
|
| | | Integer t1 = Integer.valueOf(map.get("time").toString().split(" ")[1].split(":")[0]);
|
| | | if (t1 == 0) {
|
| | | Map<String, Object> map1 = list.get(list.size() - 1);
|
| | | if (map1 == null) {
|
| | | list.set(list.size() - 1, map);
|
| | | } else {
|
| | | map1.putAll(map);
|
| | | list.set(list.size() - 1, map1);
|
| | | }
|
| | | } else {
|
| | | Map<String, Object> map1 = list.get(t1 - 1);
|
| | | if (map1 == null) {
|
| | | list.set(t1 - 1, map);
|
| | | } else {
|
| | | map1.putAll(map);
|
| | | list.set(t1 - 1, map1);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | list.removeAll(Collections.singleton(null));
|
| | | for (Map<String, Object> map : list) {
|
| | | map.put("type", "实测");
|
| | | map.put("city", parameters.get("name").toString());
|
| | | }
|
| | |
|
| | | List<Map<String, Object>> resultList = new ArrayList<>();
|
| | |
|
| | | for (Map<String, Object> foreMap : foreList) {
|
| | | for (Map<String, Object> realMap : list) {
|
| | | if (foreMap.get("time").equals(realMap.get("time"))) {
|
| | | resultList.add(foreMap);
|
| | | resultList.add(realMap);
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | for (int i = realList.size(); i < forecastList.size(); i++) {
|
| | | for (int i = list.size(); i < foreList.size(); i++) {
|
| | | Map<String, Object> map = foreList.get(i);
|
| | | resultList.add(map);
|
| | | Map<String, Object> hashMap = new HashMap<>();
|
| | | hashMap.put("time", map.get("time").toString());
|
| | | hashMap.put("type", "实际");
|
| | | hashMap.put("type", "实测");
|
| | | hashMap.put("city", parameters.get("city").toString());
|
| | | resultList.add(hashMap);
|
| | | }
|
| | |
|
| | | for (Map<String, Object> map : resultList) {
|
| | | String date = map.get("time").toString().substring(0, 16);
|
| | | map.put("time", date);
|
| | | if (map.get("AQI") != null) {
|
| | | String aqi = map.get("AQI").toString().split("\\.")[0];
|
| | | map.put("AQI", aqi);
|
| | | }
|
| | | if (map.get("precip") != null) {
|
| | | String aqi = map.get("precip").toString();
|
| | | if (aqi.equals("0.0")) {
|
| | | map.put("precip", "");
|
| | | }
|
| | | }
|
| | | if (map.get("precip6") != null) {
|
| | | String aqi = map.get("precip6").toString();
|
| | | if (aqi.equals("0.0")) {
|
| | | map.put("precip6", "");
|
| | | }
|
| | | }
|
| | | }
|
| | | return resultList;
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public void updateForecastWeather(Map<String, Object> parameters) {
|
| | | List<Integer> list = new ArrayList<>();
|
| | | List<Map<String, Object>> resultList = new ArrayList<>();
|
| | | for (int i = 0; i < 48; i++) {
|
| | | list.add(i);
|
| | | resultList.add(null);
|
| | | }
|
| | | for (Integer s : list) {
|
| | | Map<String, Object> map = new HashMap<>();
|
| | | for (String key : parameters.keySet()) {
|
| | | String replace = key.split("\\[")[0];
|
| | | if (replace.equals(s + "")) {
|
| | | String ss = key.split("\\[")[1].replace("]", "");
|
| | | map.put(ss, parameters.get(key).toString());
|
| | | }
|
| | | }
|
| | | resultList.set(s, map);
|
| | | }
|
| | | for (Map<String, Object> map : resultList) {
|
| | | if (map.get("type").equals("预测")) {
|
| | | String time = map.get("time").toString() + ":00";
|
| | | Map<String, Object> hashMap = new HashMap<>();
|
| | | hashMap.put("time", time);
|
| | | String cityName = map.get("city").toString();
|
| | | Area area = areaMapper.getAreaByName(cityName);
|
| | | if (area == null) {
|
| | | City city = cityMapper.getCityByName(cityName);
|
| | | if (city == null) {
|
| | | Province province = provinceMapper.getProvinceByName(cityName);
|
| | | if (province == null) {
|
| | | return;
|
| | | } else {
|
| | | hashMap.put("cityCode", province.getProvinceCode());
|
| | | }
|
| | | } else {
|
| | | Integer cityCode = city.getCityCode();
|
| | | hashMap.put("cityCode", cityCode);
|
| | | }
|
| | | } else {
|
| | | Integer areaCode = area.getAreaCode();
|
| | | hashMap.put("cityCode", areaCode);
|
| | | }
|
| | |
|
| | | Map<String, Object> jsonMap = new HashMap<>();
|
| | | for (String key : map.keySet()) {
|
| | | if (!key.equals("city") && !key.equals("time") && !key.equals("type") && !key.equals("fxTime")) {
|
| | | String value = map.get(key).toString();
|
| | | jsonMap.put(key, value);
|
| | | }
|
| | | }
|
| | | hashMap.put("json", JSONObject.toJSONString(jsonMap));
|
| | | forecastWeatherMapper.updateForecastWeather(hashMap);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|