| | |
| | | import com.moral.api.service.CityWeatherService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.RedisConstants; |
| | | import com.moral.util.DateUtils; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | |
| | | @Autowired |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | @Override |
| | | public void insertCityWeather() { |
| | | //获取城市配置 |
| | |
| | | cityWeather.setValue(JSONObject.toJSONString(now)); |
| | | Date time = DateUtils.dataToTimeStampTime(new Date(), DateUtils.yyyy_MM_dd_HH_EN); |
| | | cityWeather.setTime(time); |
| | | //存入数据库 |
| | | cityWeatherMapper.insert(cityWeather); |
| | | //存入redis |
| | | redisTemplate.opsForHash().put(RedisConstants.CITY_WEATHER, cityCode, now); |
| | | } |
| | | } |
| | | |