瀏覽代碼

Merge branch 'develop' of gitadmin/tuoheng_telecomumale into release

tags/v1.3.1
wanjing 1 年之前
父節點
當前提交
0d60c3096c
共有 1 個文件被更改,包括 68 次插入14 次删除
  1. +68
    -14
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/GetAirportDetailService.java

+ 68
- 14
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/GetAirportDetailService.java 查看文件

@@ -1,11 +1,13 @@
package com.tuoheng.admin.service.third.airport;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.tuoheng.admin.dto.AirportDetailDto;
import com.tuoheng.common.core.config.common.CommonConfig;
import com.tuoheng.common.core.utils.HttpUtils;
import com.tuoheng.common.core.utils.JacksonUtil;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@@ -24,7 +26,16 @@ public class GetAirportDetailService {
String url = CommonConfig.airportURL + "/api/airportInterface/getAirportStatus";
String param = "airportId=" + airportId;
String result = HttpUtils.sendGet(url, param);
if (StringUtils.isEmpty(result)) {
log.info("获取机场状态,机场平台返回为空, airportId={}", airportId);
return JsonResult.error("获取机场状态,机场平台返回为空");
}
JsonResult jsonResult = JacksonUtil.json2pojo(result, JsonResult.class);
if (0 != jsonResult.getCode()) {
log.info("获取机场状态,机场平台返回失败,jsonResult={}", jsonResult);
return JsonResult.error("获取机场状态,机场平台返回失败");
}

AirportDetailDto vo = new AirportDetailDto();
JSONObject dataObject = (JSONObject) JSONObject.toJSON(jsonResult.getData());
log.info("响应信息:{}", dataObject.toJSONString());
@@ -33,28 +44,71 @@ public class GetAirportDetailService {
log.info("参数信息:{}", wthJson.toJSONString());
JSONObject parmJson = wthJson.getJSONObject("parmNew");
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");
if (Objects.nonNull(tahJson)) {
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");
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);
}
}

Loading…
取消
儲存