Browse Source

优化天气服务 天气情况判断逻辑

develop
zhaoxianglong 9 months ago
parent
commit
69925e8cec
  1. 21
      zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java

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

@ -267,15 +267,22 @@ public class WeatherForecastController extends BaseController {
String visLevel = jsonObject.getString("visLevel");
if (Objects.equals(visLevel, UniversalEnum.ONE.getValue())) {
jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue());
jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber());
} else if (Objects.equals(visLevel, UniversalEnum.TWO.getValue()) || Objects.equals(visLevel, UniversalEnum.THREE.getValue())) {
jsonObject.put("weatherCondition", UniversalEnum.CLOUDY.getValue());
jsonObject.put("weatherConditionCode", UniversalEnum.CLOUDY.getNumber());
} else if (Objects.equals(visLevel, UniversalEnum.FOUR.getValue()) || Objects.equals(visLevel, UniversalEnum.FIVE.getValue()) || Objects.equals(visLevel, UniversalEnum.SIX.getValue())) {
Double rhu = jsonObject.getDouble("rhu");
if (rhu > UniversalEnum.SIXTY.getNumber()) {
jsonObject.put("weatherCondition", UniversalEnum.OVERCAST_SKY.getValue());
jsonObject.put("weatherConditionCode", UniversalEnum.OVERCAST_SKY.getNumber());
} else {
if (Objects.equals(visLevel, UniversalEnum.ONE.getValue())) {
jsonObject.put("weatherCondition", UniversalEnum.CLEAR_WEATHER.getValue());
jsonObject.put("weatherConditionCode", UniversalEnum.CLEAR_WEATHER.getNumber());
} else if (Objects.equals(visLevel, UniversalEnum.TWO.getValue()) || Objects.equals(visLevel, UniversalEnum.THREE.getValue())) {
jsonObject.put("weatherCondition", UniversalEnum.CLOUDY.getValue());
jsonObject.put("weatherConditionCode", UniversalEnum.CLOUDY.getNumber());
} 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("weatherConditionCode", UniversalEnum.OVERCAST_SKY.getNumber());
}
}
} else {

Loading…
Cancel
Save