Browse Source

优化设备状态统计定时

优化天气服务判断规则
develop
zhaoxianglong 5 months ago
parent
commit
109d5e215f
  1. 3
      zc-business/src/main/java/com/zc/business/controller/DeviceStatus.java
  2. 9
      zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java

3
zc-business/src/main/java/com/zc/business/controller/DeviceStatus.java

@ -100,8 +100,7 @@ public class DeviceStatus {
executor.shutdown(); executor.shutdown();
} }
@Scheduled(cron = "0 30 23 * * ?") //@Scheduled(cron = "0 30 23 * * ?")
//@Scheduled(cron = "0 30 * * * ?")
public void periodicDataClearing() { public void periodicDataClearing() {
StatusService statusService = SpringUtils.getBean(StatusService.class); StatusService statusService = SpringUtils.getBean(StatusService.class);
LocalDateTime startTime = LocalDateTime.now().minusMonths(UniversalEnum.THREE.getNumber()); LocalDateTime startTime = LocalDateTime.now().minusMonths(UniversalEnum.THREE.getNumber());

9
zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java

@ -265,13 +265,13 @@ public class WeatherForecastController extends BaseController {
String visLevel = jsonObject.getString("visLevel"); String visLevel = jsonObject.getString("visLevel");
if (Objects.equals(visLevel, UniversalEnum.ONE.getValue()) || Objects.equals(visLevel, UniversalEnum.TWO.getValue())) { if (Objects.equals(visLevel, UniversalEnum.ONE.getValue())) {
jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue()); jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue());
jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber()); jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber());
} else if (Objects.equals(visLevel, UniversalEnum.THREE.getValue()) || Objects.equals(visLevel, UniversalEnum.FOUR.getValue())) { } else if (Objects.equals(visLevel, UniversalEnum.TWO.getValue()) || Objects.equals(visLevel, UniversalEnum.THREE.getValue())) {
jsonObject.put("weatherCondition", UniversalEnum.CLOUDY.getValue()); jsonObject.put("weatherCondition", UniversalEnum.CLOUDY.getValue());
jsonObject.put("weatherConditionCode", UniversalEnum.CLOUDY.getNumber()); jsonObject.put("weatherConditionCode", UniversalEnum.CLOUDY.getNumber());
} else if (Objects.equals(visLevel, UniversalEnum.FIVE.getValue()) || Objects.equals(visLevel, UniversalEnum.SIX.getValue())) { } else if (Objects.equals(visLevel, UniversalEnum.FOUR.getValue()) || Objects.equals(visLevel, UniversalEnum.FIVE.getValue()) || Objects.equals(visLevel, UniversalEnum.SIX.getValue())) {
jsonObject.put("weatherCondition", UniversalEnum.OVERCAST_SKY.getValue()); jsonObject.put("weatherCondition", UniversalEnum.OVERCAST_SKY.getValue());
jsonObject.put("weatherConditionCode", UniversalEnum.OVERCAST_SKY.getNumber()); jsonObject.put("weatherConditionCode", UniversalEnum.OVERCAST_SKY.getNumber());
} }
@ -398,7 +398,8 @@ public class WeatherForecastController extends BaseController {
} }
jsonArray.add(i, jsonObject); jsonArray.add(i, jsonObject);
}; }
;
if (jsonArray.size() != UniversalEnum.ZERO.getNumber()) { if (jsonArray.size() != UniversalEnum.ZERO.getNumber()) {
redisCache.deleteObject(UniversalEnum.CURRENT_WEATHER_AND_FORECAST_INFORMATION_SINGLE_WORD.getValue() + numStake); redisCache.deleteObject(UniversalEnum.CURRENT_WEATHER_AND_FORECAST_INFORMATION_SINGLE_WORD.getValue() + numStake);
redisCache.setCacheObject(UniversalEnum.CURRENT_WEATHER_AND_FORECAST_INFORMATION_SINGLE_WORD.getValue() + numStake, jsonArray); redisCache.setCacheObject(UniversalEnum.CURRENT_WEATHER_AND_FORECAST_INFORMATION_SINGLE_WORD.getValue() + numStake, jsonArray);

Loading…
Cancel
Save