From f052b63c0428d4f3f723e9c729f19a62bfe3172e Mon Sep 17 00:00:00 2001 From: jinpengyong <jpy123456> Date: Thu, 20 Jan 2022 09:38:31 +0800 Subject: [PATCH] job定时任务修改入库逻辑 --- screen-job/src/main/java/com/moral/api/service/impl/CityWeatherForecastServiceImpl.java | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/screen-job/src/main/java/com/moral/api/service/impl/CityWeatherForecastServiceImpl.java b/screen-job/src/main/java/com/moral/api/service/impl/CityWeatherForecastServiceImpl.java index aa43f1a..feb87a3 100644 --- a/screen-job/src/main/java/com/moral/api/service/impl/CityWeatherForecastServiceImpl.java +++ b/screen-job/src/main/java/com/moral/api/service/impl/CityWeatherForecastServiceImpl.java @@ -15,6 +15,7 @@ import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; +import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; @@ -47,6 +48,8 @@ QueryWrapper<CityConfigWeatherForecast> wrapper = new QueryWrapper<>(); wrapper.select("city_code", "location_id").eq("is_delete", Constants.NOT_DELETE); List<CityConfigWeatherForecast> list = cityConfigWeatherForecastService.list(wrapper); + + List<CityWeatherForecast> cityWeatherForecasts = new ArrayList<>(); CityWeatherForecast cityWeatherForecast = new CityWeatherForecast(); for (CityConfigWeatherForecast cityConfigWeatherForecast : list) { Integer cityCode = cityConfigWeatherForecast.getCityCode(); @@ -61,9 +64,10 @@ cityWeatherForecast.setCityCode(cityCode); cityWeatherForecast.setTime(DateUtils.getDate(hourTime, DateUtils.yyyy_MM_dd_HH_EN)); cityWeatherForecast.setValue(JSONObject.toJSONString(hourlyMap)); - cityWeatherForecastMapper.insert(cityWeatherForecast); + cityWeatherForecasts.add(cityWeatherForecast); } } } + cityWeatherForecastMapper.insertCityWeatherForecast(cityWeatherForecasts); } } -- Gitblit v1.8.0