From 8dce9a3ac3d04150a8656219b32f0bdda445ab2c Mon Sep 17 00:00:00 2001
From: lizijie <lzjiiie@163.com>
Date: Mon, 14 Mar 2022 17:13:43 +0800
Subject: [PATCH] 环比数据接口修改

---
 screen-job/src/main/java/com/moral/api/service/impl/CityWeatherForecastServiceImpl.java |    9 +++++++--
 1 files changed, 7 insertions(+), 2 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..ef6d160 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,7 +48,9 @@
         QueryWrapper<CityConfigWeatherForecast> wrapper = new QueryWrapper<>();
         wrapper.select("city_code", "location_id").eq("is_delete", Constants.NOT_DELETE);
         List<CityConfigWeatherForecast> list = cityConfigWeatherForecastService.list(wrapper);
-        CityWeatherForecast cityWeatherForecast = new CityWeatherForecast();
+
+        List<CityWeatherForecast> cityWeatherForecasts = new ArrayList<>();
+
         for (CityConfigWeatherForecast cityConfigWeatherForecast : list) {
             Integer cityCode = cityConfigWeatherForecast.getCityCode();
             Integer locationId = cityConfigWeatherForecast.getLocationId();
@@ -58,12 +61,14 @@
                 String dayTime = fxTime.split("T")[0];
                 if (dayTime.equals(nextTime)) {
                     String hourTime = fxTime.substring(0, 17).replaceAll("T", " ");
+                    CityWeatherForecast cityWeatherForecast = new CityWeatherForecast();
                     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