From 0ce061d9ed37a6c25fff70e4734fa8cc8747237c Mon Sep 17 00:00:00 2001 From: cjl <276999030@qq.com> Date: Wed, 26 Jul 2023 19:45:09 +0800 Subject: [PATCH] fix: 部分提交 --- screen-job/src/main/java/com/moral/api/service/impl/CityWeatherForecastServiceImpl.java | 23 +++++++++++++++++++++-- 1 files changed, 21 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..b8d827f 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; @@ -39,6 +40,8 @@ @Autowired private CityWeatherForecastMapper cityWeatherForecastMapper; + + //���������������������������������������������������������������������������������72������������������ @Override public void insertCityWeatherForecast() { Date nextDay = DateUtils.addDays(new Date(), 1); @@ -47,7 +50,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 +63,26 @@ 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); + } + + public static void main(String[] args) { + String time = "20221231"; + long currentMils = DateUtils.getDate(time, DateUtils.yyyyMMdd_EN).getTime(); + + long startMils = DateUtils.getDate("2022", DateUtils.yyyy).getTime(); + long mss = currentMils - startMils; + long days = mss / (1000 * 60 * 60 * 24); + System.out.println(days + 1); + + } } -- Gitblit v1.8.0