|
|
|
|
|
|
|
|
package com.tuoheng.admin.service.third.airport; |
|
|
package com.tuoheng.admin.service.third.airport; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.tuoheng.admin.dto.AirportDetailDto; |
|
|
import com.tuoheng.admin.dto.AirportDetailDto; |
|
|
import com.tuoheng.common.core.config.common.CommonConfig; |
|
|
import com.tuoheng.common.core.config.common.CommonConfig; |
|
|
import com.tuoheng.common.core.utils.HttpUtils; |
|
|
import com.tuoheng.common.core.utils.HttpUtils; |
|
|
import com.tuoheng.common.core.utils.JacksonUtil; |
|
|
import com.tuoheng.common.core.utils.JacksonUtil; |
|
|
import com.tuoheng.common.core.utils.JsonResult; |
|
|
import com.tuoheng.common.core.utils.JsonResult; |
|
|
|
|
|
import com.tuoheng.common.core.utils.StringUtils; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String url = CommonConfig.airportURL + "/api/airportInterface/getAirportStatus"; |
|
|
String url = CommonConfig.airportURL + "/api/airportInterface/getAirportStatus"; |
|
|
String param = "airportId=" + airportId; |
|
|
String param = "airportId=" + airportId; |
|
|
String result = HttpUtils.sendGet(url, param); |
|
|
String result = HttpUtils.sendGet(url, param); |
|
|
|
|
|
if (StringUtils.isEmpty(result)) { |
|
|
|
|
|
log.info("获取机场状态,机场平台返回为空, airportId={}", airportId); |
|
|
|
|
|
return JsonResult.error("获取机场状态,机场平台返回为空"); |
|
|
|
|
|
} |
|
|
JsonResult jsonResult = JacksonUtil.json2pojo(result, JsonResult.class); |
|
|
JsonResult jsonResult = JacksonUtil.json2pojo(result, JsonResult.class); |
|
|
|
|
|
if (0 != jsonResult.getCode()) { |
|
|
|
|
|
log.info("获取机场状态,机场平台返回失败,jsonResult={}", jsonResult); |
|
|
|
|
|
return JsonResult.error("获取机场状态,机场平台返回失败"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
AirportDetailDto vo = new AirportDetailDto(); |
|
|
AirportDetailDto vo = new AirportDetailDto(); |
|
|
JSONObject dataObject = (JSONObject) JSONObject.toJSON(jsonResult.getData()); |
|
|
JSONObject dataObject = (JSONObject) JSONObject.toJSON(jsonResult.getData()); |
|
|
log.info("响应信息:{}", dataObject.toJSONString()); |
|
|
log.info("响应信息:{}", dataObject.toJSONString()); |
|
|
|
|
|
|
|
|
log.info("参数信息:{}", wthJson.toJSONString()); |
|
|
log.info("参数信息:{}", wthJson.toJSONString()); |
|
|
JSONObject parmJson = wthJson.getJSONObject("parmNew"); |
|
|
JSONObject parmJson = wthJson.getJSONObject("parmNew"); |
|
|
log.info("参数信息parmJson:{}", parmJson.toJSONString()); |
|
|
log.info("参数信息parmJson:{}", parmJson.toJSONString()); |
|
|
vo.setWspd(parmJson.getString("WSPD") + "m/s") |
|
|
|
|
|
.setWdir(parmJson.getString("WDIRNAME")) |
|
|
|
|
|
.setHpa(parmJson.getString("Hpa") + "Mpa") |
|
|
|
|
|
.setHum(parmJson.getString("Hum") + "rh") |
|
|
|
|
|
.setRainfull(parmJson.getString("Rainfull")) |
|
|
|
|
|
.setTmp(parmJson.getString("Tmp") + "℃"); |
|
|
|
|
|
|
|
|
String wspd = ""; |
|
|
|
|
|
String wdir = ""; |
|
|
|
|
|
String hpa = ""; |
|
|
|
|
|
String hum = ""; |
|
|
|
|
|
String rainfull = ""; |
|
|
|
|
|
String tmp = ""; |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(parmJson.getString("WSPD"))) { |
|
|
|
|
|
wspd = parmJson.getString("WSPD") + "m/s"; |
|
|
|
|
|
} |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(parmJson.getString("WDIRNAME"))) { |
|
|
|
|
|
wdir = parmJson.getString("WDIRNAME"); |
|
|
|
|
|
} |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(parmJson.getString("Hpa"))) { |
|
|
|
|
|
hpa = parmJson.getString("Hpa") + "Mpa"; |
|
|
|
|
|
} |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(parmJson.getString("Hum"))) { |
|
|
|
|
|
hum = parmJson.getString("Hum") + "rh"; |
|
|
|
|
|
} |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(parmJson.getString("Rainfull"))) { |
|
|
|
|
|
rainfull = parmJson.getString("Rainfull"); |
|
|
|
|
|
} |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(parmJson.getString("Tmp"))) { |
|
|
|
|
|
tmp = parmJson.getString("Tmp") + "℃"; |
|
|
|
|
|
} |
|
|
|
|
|
vo.setWspd(wspd) |
|
|
|
|
|
.setWdir(wdir) |
|
|
|
|
|
.setHpa(hpa) |
|
|
|
|
|
.setHum(hum) |
|
|
|
|
|
.setRainfull(rainfull) |
|
|
|
|
|
.setTmp(tmp); |
|
|
} |
|
|
} |
|
|
JSONObject tahJson = dataObject.getJSONObject("TAH"); |
|
|
JSONObject tahJson = dataObject.getJSONObject("TAH"); |
|
|
if (Objects.nonNull(tahJson)) { |
|
|
if (Objects.nonNull(tahJson)) { |
|
|
JSONObject parmJson = tahJson.getJSONObject("parmNew"); |
|
|
JSONObject parmJson = tahJson.getJSONObject("parmNew"); |
|
|
vo.setHum(parmJson.getString("Hum") + "rh") |
|
|
|
|
|
.setTmp(parmJson.getString("Tmp") + "℃"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String hum = ""; |
|
|
|
|
|
String tmp = ""; |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(parmJson.getString("Hum"))) { |
|
|
|
|
|
hum = parmJson.getString("Hum") + "rh"; |
|
|
|
|
|
} |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(parmJson.getString("Tmp"))) { |
|
|
|
|
|
tmp = parmJson.getString("Tmp") + "℃"; |
|
|
|
|
|
} |
|
|
|
|
|
vo.setHum(hum).setTmp(tmp); |
|
|
} |
|
|
} |
|
|
JSONObject mountJson = dataObject.getJSONObject("mount"); |
|
|
JSONObject mountJson = dataObject.getJSONObject("mount"); |
|
|
if (Objects.nonNull(mountJson)) { |
|
|
if (Objects.nonNull(mountJson)) { |
|
|
vo.setMountName(mountJson.getString("cameraName") + "、" + |
|
|
|
|
|
mountJson.getString("megaphoneName") + "、" + |
|
|
|
|
|
mountJson.getString("searchlightName") |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
String cameraName = ""; |
|
|
|
|
|
String megaphoneName = ""; |
|
|
|
|
|
String searchlightName = ""; |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(mountJson.getString("cameraName"))) { |
|
|
|
|
|
cameraName = mountJson.getString("cameraName") + "、"; |
|
|
|
|
|
} |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(mountJson.getString("megaphoneName"))) { |
|
|
|
|
|
megaphoneName = mountJson.getString("megaphoneName") + "、"; |
|
|
|
|
|
} |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(mountJson.getString("searchlightName"))) { |
|
|
|
|
|
searchlightName = mountJson.getString("searchlightName"); |
|
|
|
|
|
} |
|
|
|
|
|
vo.setMountName(cameraName + megaphoneName + searchlightName); |
|
|
|
|
|
} |
|
|
|
|
|
String status = ""; |
|
|
|
|
|
if (ObjectUtil.isNotEmpty(dataObject.getString("status"))) { |
|
|
|
|
|
status = dataObject.getString("status"); |
|
|
} |
|
|
} |
|
|
vo.setStatus(dataObject.getString("status")); |
|
|
|
|
|
|
|
|
vo.setStatus(status); |
|
|
return JsonResult.success(vo); |
|
|
return JsonResult.success(vo); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |