jinpengyong
2020-08-13 f0ebb071ac4828e1a5b55eccbba8d8dd9a4d80ad
src/main/java/com/moral/service/impl/WeatherServiceImpl.java
@@ -13,6 +13,7 @@
import javax.annotation.Resource;
import org.apache.jasper.compiler.JspUtil;
import org.dom4j.Element;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
@@ -233,8 +234,8 @@
                    hour = "24";
                }
                map.put("time", Integer.valueOf(hour));
                if (forecastMap.get("result") != null) {
                    values.add(forecastMap.get("result").toString().replace("\"", ""));
                if (forecastMap.get("O3") != null) {
                    values.add(forecastMap.get("O3").toString().replace("\"", ""));
                } else {
                    values.add("");
                }
@@ -251,8 +252,8 @@
                    hour = "24";
                }
                map.put("time", Integer.valueOf(hour));
                if (forecastMap.get("result") != null) {
                    values.add(forecastMap.get("result").toString().replace("\"", ""));
                if (forecastMap.get("O3") != null) {
                    values.add(forecastMap.get("O3").toString().replace("\"", ""));
                } else {
                    values.add("");
                }
@@ -312,22 +313,22 @@
        String beforeDay = sdf.format(cal.getTime());
        parameters.put("start", selectTime);
        parameters.put("end", end);
        Integer fcode=0;
        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) {
                if (area1 != null) {
                    parameters.put("cityCode", area1.getAreaCode());
                    fcode=area1.getAreaCode();
                    fcode = area1.getAreaCode();
                    forecastList = forecastWeatherMapper.getForecast(parameters);
                    if (forecastList.size() != 0) {
                        break;
                    }
                }
            }
        }else {
            fcode= Integer.valueOf(parameters.get("cityCode").toString());
        } else {
            fcode = Integer.valueOf(parameters.get("cityCode").toString());
        }
        List<Map<String, Object>> foreList = new ArrayList<>();
@@ -338,15 +339,18 @@
            hashMap.put("TVOC", "");
            hashMap.put("altitude", "");
            hashMap.put("vegetation", "");
            hashMap.put("river", "");
            hashMap.put("AQI", "");
            hashMap.put("SO2C", "");
            hashMap.put("NO2C", "");
            hashMap.put("COC", "");
            hashMap.put("O3C", "");
            if (forecastMap.get("O3C") == null) {
                hashMap.put("O3C", "");
            }
            hashMap.put("PM25C", "");
            hashMap.put("PM10C", "");
            hashMap.put("city", parameters.get("name").toString());
            hashMap.put("code",fcode);
            hashMap.put("code", fcode);
            if (sdf.parse(time).getTime() <= now.getTime()) {
                hashMap.put("fxTime", (beforeDay + " 15:00").substring(5, 16));
            } else {
@@ -437,17 +441,34 @@
        }
        List<Device> deviceList = deviceMapper.getDeviceListByMonitorPointIds(pointList);
        List<String> macList = new ArrayList<>();
        List<String> macList1 = new ArrayList<>();
        List<Map<String, Object>> beamList = new ArrayList<>();
        List<Map<String, Object>> tvocList = new ArrayList<>();
        if (deviceList.size() != 0) {
            for (Device device : deviceList) {
                String mac = device.getMac();
                macList.add(mac);
                macList.add(device.getMac());
            }
            parameters.put("macs", macList);
            beamList = historyHourlyMapper.getBeamByMacs(parameters);
            Map<String, Object> map = new HashMap<>();
            if (name.equals("沧州市")) {
                List<Integer> list = new ArrayList<>();
                list.add(48);
                List<Device> pointIds = deviceMapper.getDeviceListByMonitorPointIds(list);
                for (Device device : pointIds) {
                    if (device.getId() != 1075) {
                        macList1.add(device.getMac());
                    }
                }
            } else {
                macList1 = macList;
            }
            map.put("macs", macList1);
            map.put("start", parameters.get("start"));
            map.put("end", parameters.get("end"));
            tvocList = historyHourlyMapper.getTVOCByMacs(map);
        }
        List<Map<String, Object>> realList = realWeatherMapper.getRealWeather(parameters);
        List<Map<String, Object>> realWeatherList = new ArrayList<>();
        for (Map<String, Object> realMap : realList) {
@@ -482,6 +503,14 @@
            if (precip6HourMap != null) {
                realMap.put("precip6", precip6HourMap.get("precip6").toString());
            }
            for (Map<String, Object> tvocMap : tvocList) {
                String ttime = tvocMap.get("time").toString();
                if (ttime.equals(rtime)) {
                    realMap.put("TVOC", tvocMap.get("TVOC").toString());
                }
            }
        }
        List<Map<String, Object>> list = new ArrayList<>();
@@ -568,7 +597,7 @@
                map.put("SO2C", map.get("SO2").toString());
            }
            if ((!map.containsKey("NO2C")) && map.containsKey("NO2")) {
                map.put("SO2C", map.get("SO2").toString());
                map.put("NO2C", map.get("NO2").toString());
            }
            if ((!map.containsKey("O3C")) && map.containsKey("O3")) {
                map.put("O3C", map.get("O3").toString());
@@ -576,8 +605,8 @@
            if ((!map.containsKey("COC")) && map.containsKey("CO")) {
                map.put("COC", map.get("CO").toString());
            }
            if ((!map.containsKey("PM25C")) && map.containsKey("PM25")) {
                map.put("PM25C", map.get("PM25").toString());
            if ((!map.containsKey("PM25C")) && map.containsKey("PM2_5")) {
                map.put("PM25C", map.get("PM2_5").toString());
            }
            if ((!map.containsKey("PM10C")) && map.containsKey("PM10")) {
                map.put("PM10C", map.get("PM10").toString());
@@ -612,10 +641,10 @@
                String time = map.get("time").toString() + ":00";
                Map<String, Object> hashMap = new HashMap<>();
                hashMap.put("time", time);
                hashMap.put("cityCode",Integer.valueOf(map.get("code").toString()));
                hashMap.put("cityCode", Integer.valueOf(map.get("code").toString()));
                Map<String, Object> jsonMap = new HashMap<>();
                for (String key : map.keySet()) {
                    if (!key.equals("city") && !key.equals("time") && !key.equals("type") && !key.equals("fxTime")&&!key.equals("code")) {
                    if (!key.equals("city") && !key.equals("time") && !key.equals("type") && !key.equals("fxTime") && !key.equals("code")) {
                        String value = map.get(key).toString();
                        jsonMap.put(key, value);
                    }