jinpengyong
2020-10-23 2c42977a1a38e4f079c5c44fe51a46c27b865f80
增加天气城市配置表,优化相关接口
5 files renamed
7 files deleted
1 files modified
761 ■■■■ changed files
src/main/java/com/moral/entity/ForecastWeather.java 14 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/RealWeather.java 14 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/ForecastWeatherMapper.java 13 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/WeatherMapper.java 11 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/RealWeatherService.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/WeatherService.java 4 ●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/RealWeatherDailyImpl.java 10 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/RealWeatherServiceImpl.java 219 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/WeatherServiceImpl.java 349 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/task/RealWeatherInsertTask.java 31 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/task/WeatherInsertTask.java 22 ●●●● patch | view | raw | blame | history
src/main/resources/mapper/ForecastWeatherMapper.xml 30 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/WeatherMapper.xml 35 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/ForecastWeather.java
File was deleted
src/main/java/com/moral/entity/RealWeather.java
File was deleted
src/main/java/com/moral/mapper/ForecastWeatherMapper.java
File was deleted
src/main/java/com/moral/mapper/WeatherMapper.java
File was renamed from src/main/java/com/moral/mapper/RealWeatherMapper.java
@@ -3,7 +3,15 @@
import java.util.List;
import java.util.Map;
public interface RealWeatherMapper {
public interface WeatherMapper {
    List<Map<String, Object>> getCityWeatherConfig();
    int insertForecastWeather(List<Map<String,Object>> list);
    void deleteByTime(Map<String,Object> parameters);
    String getBeam(Map<String,Object> parameters);
    int insertRealWeather(List<Map<String, Object>> list);
@@ -22,5 +30,4 @@
    List<String> getSampleFromHistoryWeather(Map<String, Object> params);
    List<String> getSampleFromRealWeather(Map<String, Object> params);
}
src/main/java/com/moral/service/RealWeatherService.java
File was deleted
src/main/java/com/moral/service/WeatherService.java
File was renamed from src/main/java/com/moral/service/ForecastWeatherService.java
@@ -2,10 +2,12 @@
import java.text.ParseException;
public interface ForecastWeatherService {
public interface WeatherService {
    int insertForecastWeatherNew() throws ParseException;
    int insertForecastWeather() throws ParseException;
    int insertRealWeather() throws ParseException;
}
src/main/java/com/moral/service/impl/RealWeatherDailyImpl.java
@@ -28,7 +28,7 @@
import com.moral.mapper.MonitorPointMapper;
import com.moral.mapper.ProvinceMapper;
import com.moral.mapper.RealWeatherDailyMapper;
import com.moral.mapper.RealWeatherMapper;
import com.moral.mapper.WeatherMapper;
import com.moral.service.RealWeatherDailyService;
import com.moral.util.Dom4jUtils;
@@ -48,7 +48,7 @@
    private ProvinceMapper provinceMapper;
    @Resource
    private RealWeatherMapper realWeatherMapper;
    private WeatherMapper weatherMapper;
    @Resource
    private RealWeatherDailyMapper realWeatherDailyMapper;
@@ -158,7 +158,7 @@
            Map<String, Object> dailyMap = (Map<String, Object>) JSONObject.parse(string);
            //温度平均值
            dailyMap.remove("date");
            Map<String, Object> dayData = realWeatherMapper.getDayData(map);
            Map<String, Object> dayData = weatherMapper.getDayData(map);
            for (String key : dayData.keySet()) {
                if (!key.equals("precip")) {
                    dayData.put(key, String.valueOf(Math.round(Double.valueOf(dayData.get(key).toString()))));
@@ -202,12 +202,12 @@
            }
            //最低温,最高温时间点
            Map<String, Object> timeMaxTemp = realWeatherMapper.getTimeMaxTemp(map);
            Map<String, Object> timeMaxTemp = weatherMapper.getTimeMaxTemp(map);
            String hour1 = timeMaxTemp.get("time").toString().substring(11, 13);
            System.out.println(hour1);
            dayData.put("maxTempTime", hour1);
            Map<String, Object> timeMinTemp = realWeatherMapper.getTimeMinTemp(map);
            Map<String, Object> timeMinTemp = weatherMapper.getTimeMinTemp(map);
            String hour2 = timeMinTemp.get("time").toString().substring(11, 13);
            dayData.put("minTempTime", hour2);
            System.out.println(hour2);
src/main/java/com/moral/service/impl/RealWeatherServiceImpl.java
File was deleted
src/main/java/com/moral/service/impl/WeatherServiceImpl.java
File was renamed from src/main/java/com/moral/service/impl/ForecastWeatherServiceImpl.java
@@ -8,54 +8,33 @@
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
import org.dom4j.Element;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import com.alibaba.fastjson.JSONObject;
import com.moral.entity.Area;
import com.moral.entity.City;
import com.moral.entity.MonitorPoint;
import com.moral.entity.Province;
import com.moral.mapper.AQIMapper;
import com.moral.mapper.AreaMapper;
import com.moral.mapper.CityMapper;
import com.moral.mapper.DeviceMapper;
import com.moral.mapper.ForecastWeatherMapper;
import com.moral.mapper.WeatherMapper;
import com.moral.mapper.HistoryHourlyMapper;
import com.moral.mapper.MonitorPointMapper;
import com.moral.mapper.ProvinceMapper;
import com.moral.mapper.RealWeatherMapper;
import com.moral.service.ForecastWeatherService;
import com.moral.util.Dom4jUtils;
import com.moral.service.WeatherService;
@Service
public class ForecastWeatherServiceImpl implements ForecastWeatherService {
public class WeatherServiceImpl implements WeatherService {
    @Resource
    private ForecastWeatherMapper forecastWeatherMapper;
    private WeatherMapper weatherMapper;
    @Resource
    private MonitorPointMapper monitorPointMapper;
    @Resource
    private AreaMapper areaMapper;
    @Resource
    private CityMapper cityMapper;
    @Resource
    private ProvinceMapper provinceMapper;
    @Resource
    private RealWeatherMapper realWeatherMapper;
    @Resource
    private AQIMapper aqiMapper;
@@ -79,114 +58,19 @@
        c.add(Calendar.DAY_OF_MONTH, 1);
        String nextNextDay = sdf.format(c.getTime()) + " 00";
        RestTemplate restTemplate = new RestTemplate();
        List<MonitorPoint> monitorPointList = monitorPointMapper.getMonitorPointList();
        Set<Map<String, Object>> hashSet = new HashSet<>();
        for (MonitorPoint monitorPoint : monitorPointList) {
            Map<String, Object> hashMap = new HashMap<>();
            Integer areaCode = monitorPoint.getAreaCode();
            Integer cityCode = monitorPoint.getCityCode();
            Integer provinceCode = monitorPoint.getProvinceCode();
            String parentName;
            String name1;
            Integer code;
            Integer parentCode;
            if (areaCode != null) {
                Area area = areaMapper.getAreaByAreaCode(areaCode);
                City city = cityMapper.getCityByCityCode(cityCode);
                name1 = area.getAreaName();
                parentName = city.getCityName();
                parentCode = cityCode;
                code = areaCode;
                if ("市辖区".equals(name1)) {
                    name1 = parentName;
                    Province province = provinceMapper.getProvinceByProvinceCode(provinceCode);
                    parentName = province.getProvinceName();
                    parentCode = provinceCode;
                    code = cityCode;
                }
            } else {
                if (cityCode != null) {
                    City city = cityMapper.getCityByCityCode(cityCode);
                    name1 = city.getCityName();
                    code = cityCode;
                    Province province = provinceMapper.getProvinceByProvinceCode(provinceCode);
                    parentName = province.getProvinceName();
                    parentCode = provinceCode;
                    if ("市辖区".equals(name1)) {
                        name1 = parentName;
                        code = provinceCode;
                    }
                } else {
                    code = provinceCode;
                    Province province = provinceMapper.getProvinceByProvinceCode(provinceCode);
                    name1 = province.getProvinceName();
                    parentCode = provinceCode;
                    parentName = name1;
                }
            }
            hashMap.put("name1", name1);
            hashMap.put("parentName", parentName);
            hashMap.put("cityCode", code);
            hashMap.put("parentCode", parentCode);
            hashSet.add(hashMap);
        }
        Map<String, Object> smap = new HashMap<>();
        smap.put("name1", "苏州市");
        smap.put("parentName", "江苏省");
        smap.put("cityCode", 320500);
        smap.put("parentCode", 320000);
        hashSet.add(smap);
        Map<String, Object> bmap = new HashMap<>();
        bmap.put("name1", "北京市");
        bmap.put("parentName", "北京市");
        bmap.put("cityCode", 110000);
        bmap.put("parentCode", 110000);
        hashSet.add(bmap);
        List<Map<String, Object>> cityList = weatherMapper.getCityWeatherConfig();
        cityList.clear();
        Map<String, Object> cz = new HashMap<>();
        Set<Map<String, Object>> set = new HashSet<>();
        cz.put("name1", "沧州市");
        cz.put("parentName", "河北省");
        cz.put("cityCode", 130900);
        cz.put("parentCode", 130000);
        set.add(cz);
        cz.put("cityId", 101090701);
        cityList.add(cz);
        Map<String, Object> ks = new HashMap<>();
        ks.put("name1", "昆山市");
        ks.put("parentName", "苏州市");
        ks.put("cityCode", 320583);
        ks.put("parentCode", 320500);
        set.add(ks);
        List<Element> elements = Dom4jUtils.readDocument();
        String cityID;
        for (Map<String, Object> map : set) {
            String name1 = map.get("name1").toString();
            for (Element element : elements) {
                String name2 = element.element("name").getText();
                String parentName = map.get("parentName").toString();
                if (name2.equals("大丰市")) {
                    name2 = "大丰区";
                }
                if (name1.equals(name2)) {
                    cityID = element.element("Fweathercn").getText();
                    map.put("cityID", cityID);
                    break;
                }
                if (name2.endsWith(name1)) {
                    if (name2.startsWith(parentName)) {
                        cityID = element.element("Fweathercn").getText();
                        map.put("cityID", cityID);
                        break;
                    }
                }
            }
        }
        ks.put("cityId", 101190404);
        cityList.add(ks);
        int count = 0;
        for (Map<String, Object> map : set) {
            String id = map.get("cityID").toString();
        for (Map<String, Object> map : cityList) {
            String id = map.get("cityId").toString();
            Map<String, Object> dataMap = restTemplate.getForObject("https://api.heweather.net/v7/weather/72h?key=da05c6c4852d4f7aa3364a9236ee9e26&gzip=n&location={1}", Map.class, id);
            if (dataMap == null) {
                return count;
@@ -243,7 +127,6 @@
                    condition = "50";
                }
                hourlyMap.put("condition", condition);
                String hour = fxTime.split(" ")[0];
                String hour1 = fxTime.split(":")[0];
                if (hour.equals(nextDay)) {
@@ -274,7 +157,7 @@
        //前45天分割时间
        c.add(Calendar.DAY_OF_MONTH, -30);
        Date slicedTime2 = c.getTime();
        for (Map<String, Object> map : set) {
        for (Map<String, Object> map : cityList) {
            String cityCode = map.get("cityCode").toString();
            ArrayList<Map<String, Object>> dataList = (ArrayList<Map<String, Object>>) map.get("data");
            for (Map<String, Object> dataMap : dataList) {
@@ -349,9 +232,9 @@
                Map<String, Object> params = new HashMap<>();
                params.put("cityCode", cityCode);
                params.put("time", sdf1.parse(time));
                String beam = forecastWeatherMapper.getBeam(params);
                String beam = weatherMapper.getBeam(params);
                if (beam != null) {
                    dataMap.put("beam",beam.replace("\"",""));
                    dataMap.put("beam", beam.replace("\"", ""));
                }
                resultMap.put("cityCode", cityCode);
                resultMap.put("time", time);
@@ -359,13 +242,13 @@
                resultList.add(resultMap);
            }
            Map<String, Object> parameters = new HashMap<>();
            parameters.put("start",sdf1.parse(nextDay + " 01:00:00"));
            parameters.put("start", sdf1.parse(nextDay + " 01:00:00"));
            c.setTime(sdf1.parse(nextDay + " 01:00:00"));
            c.add(Calendar.DAY_OF_MONTH, 1);
            parameters.put("end", c.getTime());
            parameters.put("cityCode", cityCode);
            forecastWeatherMapper.deleteByTime(parameters);
            count = count + forecastWeatherMapper.insertForecastWeather(resultList);
            weatherMapper.deleteByTime(parameters);
            count = count + weatherMapper.insertForecastWeather(resultList);
        }
        return count;
    }
@@ -375,10 +258,10 @@
        if (years.size() > 0) {
            for (Integer year : years) {
                params.put("timeUnits", year);
                samples.addAll(realWeatherMapper.getSampleFromHistoryWeather(params));
                samples.addAll(weatherMapper.getSampleFromHistoryWeather(params));
            }
        }
        samples.addAll(realWeatherMapper.getSampleFromRealWeather(params));
        samples.addAll(weatherMapper.getSampleFromRealWeather(params));
        return samples;
    }
@@ -440,8 +323,6 @@
                } else {
                    values = getSample(params, years);
                }
                if (values.size() == 0) {
                    hours.add(params.get("sHour").toString());
                    hours.add(params.get("eHour").toString());
@@ -473,96 +354,14 @@
        String nextNextDay = sdf.format(c.getTime()) + " 00";
        Date end = sdf1.parse(sdf.format(c.getTime()) + " 01:00:00");
        RestTemplate restTemplate = new RestTemplate();
        List<MonitorPoint> monitorPointList = monitorPointMapper.getMonitorPointList();
        Set<Map<String, Object>> hashSet = new HashSet<>();
        for (MonitorPoint monitorPoint : monitorPointList) {
            Map<String, Object> hashMap = new HashMap<>();
            Integer areaCode = monitorPoint.getAreaCode();
            Integer cityCode = monitorPoint.getCityCode();
            Integer provinceCode = monitorPoint.getProvinceCode();
            String parentName = "";
            String name1 = "";
            Integer code = 0;
            Integer parentCode = 0;
            if (areaCode != null) {
                Area area = areaMapper.getAreaByAreaCode(areaCode);
                City city = cityMapper.getCityByCityCode(cityCode);
                name1 = area.getAreaName();
                parentName = city.getCityName();
                parentCode = city.getCityCode();
                code = areaCode;
                if ("市辖区".equals(name1)) {
                    name1 = parentName;
                    Province province = provinceMapper.getProvinceByProvinceCode(provinceCode);
                    parentName = province.getProvinceName();
                    parentCode = province.getProvinceCode();
                    code = cityCode;
                }
            } else {
                City city = cityMapper.getCityByCityCode(cityCode);
                name1 = city.getCityName();
                Province province = provinceMapper.getProvinceByProvinceCode(provinceCode);
                parentName = province.getProvinceName();
                code = cityCode;
                parentCode = province.getProvinceCode();
                if ("市辖区".equals(name1)) {
                    name1 = parentName;
                    parentName = "";
                    code = provinceCode;
                }
            }
            hashMap.put("name1", name1);
            hashMap.put("parentName", parentName);
            hashMap.put("cityCode", code);
            hashMap.put("parentCode", parentCode);
            hashSet.add(hashMap);
        }
        Map<String, Object> bmap = new HashMap<>();
        bmap.put("name1", "北京市");
        bmap.put("parentName", "北京市");
        bmap.put("cityCode", 110000);
        bmap.put("parentCode", 110000);
        hashSet.add(bmap);
        Map<String, Object> smap = new HashMap<>();
        smap.put("name1", "苏州市");
        smap.put("parentName", "江苏省");
        smap.put("cityCode", 320500);
        smap.put("parentCode", 320000);
        hashSet.add(smap);
        List<Element> elements = Dom4jUtils.readDocument();
        String cityID = "101190404";
        for (Map<String, Object> map : hashSet) {
            String name1 = map.get("name1").toString();
            for (Element element : elements) {
                String name2 = element.element("name").getText();
                String parentName = map.get("parentName").toString();
                if (name2.equals("大丰市")) {
                    name2 = "大丰区";
                }
                if (name1.equals(name2)) {
                    cityID = element.element("Fweathercn").getText();
                    map.put("cityID", cityID);
                    break;
                }
                if (name2.endsWith(name1)) {
                    if (name2.startsWith(parentName)) {
                        cityID = element.element("Fweathercn").getText();
                        map.put("cityID", cityID);
                        break;
                    }
                }
            }
        }
        c.setTime(new Date());
        Date endTime = sdf.parse(sdf.format(c.getTime()));
        c.add(Calendar.MONTH, -2);
        Date startTime = sdf.parse(sdf.format(c.getTime()));
        int count = 0;
        for (Map<String, Object> map : hashSet) {
            String id = map.get("cityID").toString();
        List<Map<String, Object>> cityList = weatherMapper.getCityWeatherConfig();
        for (Map<String, Object> map : cityList) {
            String id = map.get("cityId").toString();
            Map<String, Object> dataMap = restTemplate.getForObject("https://api.heweather.net/v7/weather/72h?key=da05c6c4852d4f7aa3364a9236ee9e26&gzip=n&location={1}", Map.class, id);
            if (dataMap == null) {
                return count;
@@ -627,9 +426,18 @@
            map.put("data", nextDayList);
        }
        for (Map<String, Object> map : hashSet) {
        for (Map<String, Object> map : cityList) {
            List<Map<String, Object>> resultList = new ArrayList<>();
            String cityCode = map.get("cityCode").toString();
            String parentCode = "";
            if (cityCode.endsWith("0000")) {
                parentCode = cityCode;
            } else if (cityCode.endsWith("00")) {
                parentCode = cityCode.substring(0, cityCode.length() - 4) + "0000";
            } else {
                parentCode = cityCode.substring(0, cityCode.length() - 2) + "00";
            }
            map.put("parentCode", parentCode);
            map.put("startTime", startTime);
            map.put("endTime", endTime);
            map.put("typeFormat", "%Y-%m-%d %H:%i:%s");
@@ -651,7 +459,10 @@
            } else {
                pointList = monitorPointMapper.getMonitorList(params);
            }
            List<String> macList = deviceMapper.getMacsByMonitorPointIds(pointList);
            List<String> macList = new ArrayList<>();
            if (pointList.size() != 0) {
                macList = deviceMapper.getMacsByMonitorPointIds(pointList);
            }
            if (macList.size() != 0) {
                map.put("macs", macList);
            }
@@ -675,7 +486,7 @@
                    value = 0;
                }
                map.put("condition", value);
                List<Map<String, Object>> tempAndCloudList = realWeatherMapper.getTempAndCloud(map);
                List<Map<String, Object>> tempAndCloudList = weatherMapper.getTempAndCloud(map);
                List<String> times = new ArrayList<>();
                for (Map<String, Object> tempAndCloudMap : tempAndCloudList) {
                    times.add(tempAndCloudMap.get("time").toString());
@@ -725,8 +536,8 @@
                double sum1 = 0.0;//
                double sum2 = 0.0;
                double cloudSum = 0.0;//温度和
                double beamSum = 0.0;//O3和
                double cloudSum = 0.0;//总云量和
                double beamSum = 0.0;//光照和
                double sum3 = 0.0;//
                double sum4 = 0.0;
                int size = tempAndCloudList.size();
@@ -797,9 +608,85 @@
            parameters.put("start", start);
            parameters.put("end", end);
            parameters.put("cityCode", cityCode);
            forecastWeatherMapper.deleteByTime(parameters);
            count = count + forecastWeatherMapper.insertForecastWeather(resultList);
            weatherMapper.deleteByTime(parameters);
            count = count + weatherMapper.insertForecastWeather(resultList);
        }
        return count;
    }
    @Override
    public int insertRealWeather() throws ParseException {
        DecimalFormat df = new DecimalFormat("0.0");
        Calendar c = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH");
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date now = sdf1.parse(sdf.format(c.getTime()) + ":00:00");
        RestTemplate restTemplate = new RestTemplate();
        List<Map<String, Object>> cityList = weatherMapper.getCityWeatherConfig();
        int count = 0;
        for (Map<String, Object> map : cityList) {
            String id = map.get("cityId").toString();
            Map<String, Object> dataMap = restTemplate.getForObject("https://api.heweather.net/v7/weather/now?key=da05c6c4852d4f7aa3364a9236ee9e26&gzip=n&location={1}", Map.class, id);
            if (dataMap == null) {
                return count;
            }
            String json = JSONObject.toJSONString(dataMap);
            dataMap = (Map<String, Object>) JSONObject.parse(json);
            Map<String, Object> nowMap = (Map<String, Object>) dataMap.get("now");
            map.put("data", nowMap);
        }
        List<Map<String, Object>> resultList = new ArrayList<>();
        for (Map<String, Object> map : cityList) {
            Map<String, Object> resultMap = new HashMap<>();
            resultMap.put("cityCode", map.get("cityCode").toString());
            resultMap.put("time", now);
            Map<String, Object> jsonMap = (Map<String, Object>) map.get("data");
            //风速km/h->m/s
            Double windSpeed = Double.valueOf(jsonMap.get("windSpeed").toString());
            windSpeed = windSpeed * 1000 / 3600;
            jsonMap.put("windSpeed", df.format(windSpeed));
            jsonMap.remove("obsTime");
            jsonMap.remove("icon");
            String text = jsonMap.get("text").toString();
            String condition;
            if ("晴".equals(text)) {
                condition = "100";
            } else if ("雾".equals(text)) {
                condition = "90";
            } else if ("多云".equals(text)) {
                condition = "80";
            } else if ("霾".equals(text)) {
                condition = "70";
            } else if ("阴".equals(text) || "扬沙".equals(text) || "浮尘".equals(text) || "".equals(text)) {
                condition = "60";
            } else if ("阵雨".equals(text)) {
                condition = "45";
            } else if ("雷阵雨".equals(text)) {
                condition = "40";
            } else if ("雷阵雨转小雨".equals(text) || "阵雨转小雨".equals(text)) {
                condition = "30";
            } else if ("小雨".equals(text)) {
                condition = "20";
            } else if ("雨".equals(text)) {
                condition = "10";
            } else if ("雷阵雨转中雨".equals(text)) {
                condition = "5";
            } else if ("雷阵雨转大雨".equals(text)) {
                condition = "4";
            } else if ("中雨".equals(text) || "大雨".equals(text) || "暴雨".equals(text)
                    || "小雪".equals(text) || "中雪".equals(text) || "大雪".equals(text)
                    || "雨夹雪".equals(text) || "雨夹雪(伴有冰雹)".equals(text) || "暴雪".equals(text)
            ) {
                condition = "0";
            } else {
                condition = "50";
            }
            jsonMap.put("condition", condition);
            resultMap.put("json", JSONObject.toJSONString(jsonMap));
            resultList.add(resultMap);
        }
        weatherMapper.deleteRealWeather(sdf1.format(now));
        return weatherMapper.insertRealWeather(resultList);
    }
}
src/main/java/com/moral/task/RealWeatherInsertTask.java
File was deleted
src/main/java/com/moral/task/WeatherInsertTask.java
File was renamed from src/main/java/com/moral/task/ForecastWeatherInsertTask.java
@@ -8,20 +8,30 @@
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.moral.service.ForecastWeatherService;
import com.moral.service.WeatherService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
@Component
public class ForecastWeatherInsertTask {
    private static transient Logger logger = LoggerFactory.getLogger(ForecastWeatherInsertTask.class);
public class WeatherInsertTask {
    private static transient Logger logger = LoggerFactory.getLogger(WeatherInsertTask.class);
    @Resource
    private ForecastWeatherService forecastWeatherService;
    private WeatherService weatherService;
    @XxlJob("realWeatherHour")
    public ReturnT insertRealWeather(String param) throws ParseException {
        int count = weatherService.insertRealWeather();
        if (count > 0) {
            return new ReturnT(200, "插入成功");
        }else {
            return new ReturnT(500, "插入失败");
        }
    }
    @XxlJob("forecastWeatherHour")
    public ReturnT insertForecastWeather(String param) throws ParseException {
        int count = forecastWeatherService.insertForecastWeather();
        int count = weatherService.insertForecastWeather();
        if (count > 0) {
            return new ReturnT(200, "插入成功");
        }else {
@@ -31,7 +41,7 @@
    @XxlJob("forecastWeatherHourNew")
    public ReturnT insertForecastWeatherNew(String param) throws ParseException {
        int count = forecastWeatherService.insertForecastWeatherNew();
        int count = weatherService.insertForecastWeatherNew();
        if (count > 0) {
            return new ReturnT(200, "插入成功");
        }else {
src/main/resources/mapper/ForecastWeatherMapper.xml
File was deleted
src/main/resources/mapper/WeatherMapper.xml
File was renamed from src/main/resources/mapper/RealWeatherMapper.xml
@@ -1,9 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.moral.mapper.RealWeatherMapper">
    <resultMap id="BaseResultMap" type="com.moral.entity.RealWeather">
        <id column="city_code" property="cityCode" jdbcType="INTEGER"/>
    </resultMap>
<mapper namespace="com.moral.mapper.WeatherMapper">
    <select id="getCityWeatherConfig" resultType="java.util.Map">
        select city_code AS cityCode,
        city_id AS cityId
        from city_weather_config
    </select>
    <insert id="insertForecastWeather">
        insert into
        forecast_weather
        values
        <foreach collection="list" item="item" separator=",">
            (#{item.cityCode},#{item.time},#{item.json})
        </foreach>
    </insert>
    <delete id="deleteByTime">
        delete from forecast_weather
        where
        time >= #{start}
        AND time <![CDATA[<]]> #{end}
        and city_code=#{cityCode}
    </delete>
    <select id="getBeam" resultType="java.lang.String">
        select json->'$.beam' as 'beam'
        from forecast_weather
        where time=#{time}
        and city_code=#{cityCode}
    </select>
    <insert id="insertRealWeather">
        insert into
        real_weather