|
|
@ -19,6 +19,7 @@ import com.zc.common.core.websocket.WebSocketService; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import okhttp3.Response; |
|
|
|
import org.aspectj.weaver.ast.Var; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
@ -257,13 +258,273 @@ public class WeatherForecastController extends BaseController { |
|
|
|
JSONObject jsonResult = JSONObject.parseObject(response.body().string()); |
|
|
|
if (jsonResult.getInteger("code") == UniversalEnum.TWO_HUNDRED.getNumber()) { |
|
|
|
JSONArray data = jsonResult.getJSONArray("data"); |
|
|
|
//data.forEach(item->{
|
|
|
|
JSONArray jsonArray = new JSONArray(); |
|
|
|
for (int i = 0; i < data.size(); i++) { |
|
|
|
|
|
|
|
JSONObject jsonObject = (JSONObject) JSON.toJSON(data.get(i)); |
|
|
|
String pre = jsonObject.getString("pre"); |
|
|
|
if (Objects.equals(pre, UniversalEnum.ZERO.getValue())) { |
|
|
|
|
|
|
|
String visLevel = jsonObject.getString("visLevel"); |
|
|
|
|
|
|
|
if (Objects.equals(visLevel, UniversalEnum.ONE.getValue()) || Objects.equals(visLevel, UniversalEnum.TWO.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "晴天"); |
|
|
|
jsonObject.put("weatherConditionCode", "0"); |
|
|
|
} else if (Objects.equals(visLevel, UniversalEnum.THREE.getValue()) || Objects.equals(visLevel, UniversalEnum.FOUR.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "多云"); |
|
|
|
jsonObject.put("weatherConditionCode", "1"); |
|
|
|
} else if (Objects.equals(visLevel, UniversalEnum.FIVE.getValue()) || Objects.equals(visLevel, UniversalEnum.SIX.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "阴天"); |
|
|
|
jsonObject.put("weatherConditionCode", "2"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
String preLevel = jsonObject.getString("preLevel"); |
|
|
|
String pph = jsonObject.getString("pph"); |
|
|
|
|
|
|
|
switch (preLevel) { |
|
|
|
case "0": |
|
|
|
//if (Objects.equals(pph, UniversalEnum.ONE.getValue())) {
|
|
|
|
jsonObject.put("weatherCondition", "晴天"); |
|
|
|
jsonObject.put("weatherConditionCode", "0"); |
|
|
|
//} else if (Objects.equals(pph, UniversalEnum.TWO.getValue())) {
|
|
|
|
// jsonObject.put("weatherCondition", "");
|
|
|
|
// jsonObject.put("weatherConditionCode", "");
|
|
|
|
//} else if (Objects.equals(pph, UniversalEnum.THREE.getValue())) {
|
|
|
|
// jsonObject.put("weatherCondition", "");
|
|
|
|
// jsonObject.put("weatherConditionCode", "");
|
|
|
|
//} else if (Objects.equals(pph, UniversalEnum.FOUR.getValue())) {
|
|
|
|
// jsonObject.put("weatherCondition", "");
|
|
|
|
// jsonObject.put("weatherConditionCode", "");
|
|
|
|
//} else if (Objects.equals(pph, UniversalEnum.ZERO.getValue())) {
|
|
|
|
// jsonObject.put("weatherCondition", "");
|
|
|
|
// jsonObject.put("weatherConditionCode", "");
|
|
|
|
//
|
|
|
|
//}
|
|
|
|
break; |
|
|
|
case "1": |
|
|
|
case "2": |
|
|
|
if (Objects.equals(pph, UniversalEnum.ONE.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "小雨"); |
|
|
|
jsonObject.put("weatherConditionCode", "3"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.TWO.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "雨夹雪"); |
|
|
|
jsonObject.put("weatherConditionCode", "4"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.THREE.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "小雪"); |
|
|
|
jsonObject.put("weatherConditionCode", "5"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.FOUR.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "冻雨"); |
|
|
|
jsonObject.put("weatherConditionCode", "6"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.ZERO.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "晴天"); |
|
|
|
jsonObject.put("weatherConditionCode", "0"); |
|
|
|
} |
|
|
|
break; |
|
|
|
case "3": |
|
|
|
if (Objects.equals(pph, UniversalEnum.ONE.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "中雨"); |
|
|
|
jsonObject.put("weatherConditionCode", "7"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.TWO.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "雨夹雪"); |
|
|
|
jsonObject.put("weatherConditionCode", "4"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.THREE.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "中雪"); |
|
|
|
jsonObject.put("weatherConditionCode", "8"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.FOUR.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "冻雨"); |
|
|
|
jsonObject.put("weatherConditionCode", "6"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.ZERO.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "晴天"); |
|
|
|
jsonObject.put("weatherConditionCode", "0"); |
|
|
|
} |
|
|
|
break; |
|
|
|
case "4": |
|
|
|
if (Objects.equals(pph, UniversalEnum.ONE.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "大雨"); |
|
|
|
jsonObject.put("weatherConditionCode", "9"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.TWO.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "雨夹雪"); |
|
|
|
jsonObject.put("weatherConditionCode", "4"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.THREE.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "大雪"); |
|
|
|
jsonObject.put("weatherConditionCode", "10"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.FOUR.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "冻雨"); |
|
|
|
jsonObject.put("weatherConditionCode", "6"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.ZERO.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "晴天"); |
|
|
|
jsonObject.put("weatherConditionCode", "0"); |
|
|
|
} |
|
|
|
break; |
|
|
|
case "5": |
|
|
|
if (Objects.equals(pph, UniversalEnum.ONE.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "暴雨"); |
|
|
|
jsonObject.put("weatherConditionCode", "11"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.TWO.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "雨夹雪"); |
|
|
|
jsonObject.put("weatherConditionCode", "4"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.THREE.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "暴雪"); |
|
|
|
jsonObject.put("weatherConditionCode", "12"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.FOUR.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "冻雨"); |
|
|
|
jsonObject.put("weatherConditionCode", "6"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.ZERO.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "晴天"); |
|
|
|
jsonObject.put("weatherConditionCode", "0"); |
|
|
|
} |
|
|
|
break; |
|
|
|
case "6": |
|
|
|
if (Objects.equals(pph, UniversalEnum.ONE.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "大暴雨"); |
|
|
|
jsonObject.put("weatherConditionCode", "13"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.TWO.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "雨夹雪"); |
|
|
|
jsonObject.put("weatherConditionCode", "4"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.THREE.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "大暴雪"); |
|
|
|
jsonObject.put("weatherConditionCode", "14"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.FOUR.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "冻雨"); |
|
|
|
jsonObject.put("weatherConditionCode", "6"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.ZERO.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "晴天"); |
|
|
|
jsonObject.put("weatherConditionCode", "0"); |
|
|
|
} |
|
|
|
break; |
|
|
|
case "7": |
|
|
|
if (Objects.equals(pph, UniversalEnum.ONE.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "特大暴雨"); |
|
|
|
jsonObject.put("weatherConditionCode", "15"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.TWO.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "雨夹雪"); |
|
|
|
jsonObject.put("weatherConditionCode", "4"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.THREE.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "特大暴雪"); |
|
|
|
jsonObject.put("weatherConditionCode", "16"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.FOUR.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "冻雨"); |
|
|
|
jsonObject.put("weatherConditionCode", "6"); |
|
|
|
} else if (Objects.equals(pph, UniversalEnum.ZERO.getValue())) { |
|
|
|
jsonObject.put("weatherCondition", "晴天"); |
|
|
|
jsonObject.put("weatherConditionCode", "0"); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
//if (Objects.equals(preLevel, "0")) {
|
|
|
|
// if (Objects.equals(pph, "1")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "2")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "3")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "4")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "0")) {
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
//} else if (Objects.equals(preLevel, "1")) {
|
|
|
|
//
|
|
|
|
// if (Objects.equals(pph, "1")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "2")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "3")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "4")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "0")) {
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
//} else if (Objects.equals(preLevel, "2")) {
|
|
|
|
//
|
|
|
|
//});
|
|
|
|
if (data.size() != UniversalEnum.ZERO.getNumber()) { |
|
|
|
// if (Objects.equals(pph, "1")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "2")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "3")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "4")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "0")) {
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
//} else if (Objects.equals(preLevel, "3")) {
|
|
|
|
//
|
|
|
|
// if (Objects.equals(pph, "1")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "2")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "3")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "4")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "0")) {
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
//} else if (Objects.equals(preLevel, "4")) {
|
|
|
|
//
|
|
|
|
// if (Objects.equals(pph, "1")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "2")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "3")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "4")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "0")) {
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
//} else if (Objects.equals(preLevel, "5")) {
|
|
|
|
//
|
|
|
|
// if (Objects.equals(pph, "1")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "2")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "3")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "4")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "0")) {
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
//} else if (Objects.equals(preLevel, "6")) {
|
|
|
|
//
|
|
|
|
// if (Objects.equals(pph, "1")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "2")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "3")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "4")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "0")) {
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
//} else if (Objects.equals(preLevel, "7")) {
|
|
|
|
//
|
|
|
|
// if (Objects.equals(pph, "1")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "2")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "3")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "4")) {
|
|
|
|
//
|
|
|
|
// }else if (Objects.equals(pph, "0")) {
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
} |
|
|
|
jsonArray.add(i,jsonObject); |
|
|
|
}; |
|
|
|
if (jsonArray.size() != UniversalEnum.ZERO.getNumber()) { |
|
|
|
redisCache.deleteObject("currentWeatherAndForecastInformation" + numStake); |
|
|
|
redisCache.setCacheObject("currentWeatherAndForecastInformation" + numStake, data); |
|
|
|
return AjaxResult.success(data); |
|
|
|
redisCache.setCacheObject("currentWeatherAndForecastInformation" + numStake, jsonArray); |
|
|
|
return AjaxResult.success(jsonArray); |
|
|
|
} else { |
|
|
|
JSONArray cacheObject = redisCache.getCacheObject("currentWeatherAndForecastInformation" + numStake); |
|
|
|
return AjaxResult.success(cacheObject); |
|
|
|