Browse Source

Merge remote-tracking branch 'origin/develop' into develop

develop
wangsixiang 10 months ago
parent
commit
5dfe6e1536
  1. 27
      zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java
  2. 17
      zc-business/src/main/resources/mapper/business/DcEventMapper.xml

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

@ -104,8 +104,7 @@ public class WeatherForecastController extends BaseController {
JSONObject jsonResult = JSONObject.parseObject(response.body().string()); JSONObject jsonResult = JSONObject.parseObject(response.body().string());
if (jsonResult.getInteger("code") == 200) { if (jsonResult.getInteger("code") == 200) {
jsonObject.put("name",dcRegion.getRegionName()); jsonObject.put(weather.getString("METEOROLOGICALEARLYWARNING") + dcRegion.getId(), extracted(jsonResult, "warning", dcRegion));
jsonObject.put(weather.getString("METEOROLOGICALEARLYWARNING") + dcRegion.getId(), extracted(jsonResult,"warning"));
} else { } else {
return AjaxResult.error(jsonResult.getInteger("code"), "请求失败"); return AjaxResult.error(jsonResult.getInteger("code"), "请求失败");
@ -178,18 +177,17 @@ public class WeatherForecastController extends BaseController {
JSONObject jsonResult = JSONObject.parseObject(response.body().string()); JSONObject jsonResult = JSONObject.parseObject(response.body().string());
if (jsonResult.getInteger("code") == 200) { if (jsonResult.getInteger("code") == 200) {
jsonObject.put("name",dcRegion.getRegionName());
if (Objects.equals(redisKey, weather.getString("WEATHERFACTS"))) { if (Objects.equals(redisKey, weather.getString("WEATHERFACTS"))) {
jsonObject.put(redisKey + dcRegion.getId(), extracted(jsonResult, "now")); jsonObject.put(redisKey + dcRegion.getId(), extracted(jsonResult, "now", dcRegion));
} else if (Objects.equals(redisKey, weather.getString("METEOROLOGICALEARLYWARNING"))) { } else if (Objects.equals(redisKey, weather.getString("METEOROLOGICALEARLYWARNING"))) {
jsonObject.put(redisKey + dcRegion.getId(), extracted(jsonResult, "warning")); jsonObject.put(redisKey + dcRegion.getId(), extracted(jsonResult, "warning", dcRegion));
} else if (Objects.equals(redisKey, weather.getString("HOURLYWEATHER"))) { } else if (Objects.equals(redisKey, weather.getString("HOURLYWEATHER"))) {
jsonObject.put(redisKey + dcRegion.getId(), extracted(jsonResult,"hourly")); jsonObject.put(redisKey + dcRegion.getId(), extracted(jsonResult, "hourly", dcRegion));
} }
} else { } else {
return AjaxResult.error(jsonResult.getInteger("code"), "请求失败"); return AjaxResult.error(jsonResult.getInteger("code"), "请求失败");
@ -203,7 +201,7 @@ public class WeatherForecastController extends BaseController {
} }
if (Objects.equals(redisKey, weather.getString("WEATHERFACTS"))) { if (Objects.equals(redisKey, weather.getString("WEATHERFACTS"))) {
redisCache.setCacheObject(redisKey, jsonObject, 13, TimeUnit.MINUTES); redisCache.setCacheObject(redisKey, jsonObject, 13, TimeUnit.MINUTES);
@ -220,14 +218,21 @@ public class WeatherForecastController extends BaseController {
} }
} }
private static Object extracted(JSONObject jsonResult, String type) { private static Object extracted(JSONObject jsonResult, String type, DcRegion dcRegion) {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("code", jsonResult.getString("code")); jsonObject.put("code", jsonResult.getString("code"));
if (Objects.equals(jsonResult.getString("code"), "200")) { if (Objects.equals(jsonResult.getString("code"), "200")) {
if (Objects.equals(type, "now")) { if (Objects.equals(type, "now")) {
return jsonResult.getJSONObject(type);
JSONObject object = jsonResult.getJSONObject(type);
object.put("name", dcRegion.getRegionName());
return object;
} else { } else {
return jsonResult.getJSONArray(type); JSONArray jsonArray = jsonResult.getJSONArray(type);
jsonArray.forEach(item -> {
((JSONObject) item).put("name", dcRegion.getRegionName());
});
return jsonArray;
} }
} else if (Objects.equals(jsonResult.getString("code"), "500")) { } else if (Objects.equals(jsonResult.getString("code"), "500")) {
jsonObject.put("msg", "请求失败:无响应或超时"); jsonObject.put("msg", "请求失败:无响应或超时");
@ -271,7 +276,7 @@ public class WeatherForecastController extends BaseController {
JSONObject jsonResult = JSONObject.parseObject(response.body().string()); JSONObject jsonResult = JSONObject.parseObject(response.body().string());
if (jsonResult.getInteger("code") == 200) { if (jsonResult.getInteger("code") == 200) {
jsonObject.put("weatherInTheAreaWhereTheIncidentOccurred",jsonResult); jsonObject.put("weatherInTheAreaWhereTheIncidentOccurred", jsonResult);
} else { } else {
return AjaxResult.error(jsonResult.getInteger("code"), "请求失败"); return AjaxResult.error(jsonResult.getInteger("code"), "请求失败");
} }

17
zc-business/src/main/resources/mapper/business/DcEventMapper.xml

@ -145,7 +145,7 @@
--> -->
<sql id="selectDcEventMainVo"> <sql id="selectDcEventMainVo">
select id, dept_id, stake_mark, direction, user_id, start_time, end_time, estimated_end_time, event_level, event_type, event_subclass, event_cause, description, event_state, event_source, event_nature, remark, create_time, update_time, event_source_tips, in_tunnel from dc_event select id, dept_id, stake_mark, direction, user_id, start_time, end_time, estimated_end_time, event_level, event_type, event_subclass, event_cause, description, event_state, event_source, event_nature, remark, create_time, update_time, event_source_tips, in_tunnel,occurrence_time from dc_event
</sql> </sql>
<sql id="selectDcEventVo"> <sql id="selectDcEventVo">
SELECT id, SELECT id,
@ -350,7 +350,20 @@
<if test="inTunnel != null ">and in_tunnel = #{inTunnel}</if> <if test="inTunnel != null ">and in_tunnel = #{inTunnel}</if>
<if test="isPerceived != null ">and is_perceived = #{isPerceived}</if> <if test="isPerceived != null ">and is_perceived = #{isPerceived}</if>
</where> </where>
ORDER BY create_time desc <choose>
<when test="eventState == 0">
ORDER BY occurrence_time DESC
</when>
<when test="eventState == 1">
ORDER BY start_time DESC
</when>
<when test="eventState == 2">
ORDER BY end_time DESC
</when>
<otherwise>
ORDER BY create_time DESC
</otherwise>
</choose>
</select> </select>
<!-- 关联调度信息记录表 查询详情 --> <!-- 关联调度信息记录表 查询详情 -->

Loading…
Cancel
Save