@@ -1,5 +1,7 @@ | |||
package com.tuoheng.admin.service.third.airport; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.tuoheng.admin.tzhl.response.TZHLAirportMsgResponse; | |||
import com.tuoheng.admin.tzhl.service.airport.TZHLGetAirportMsgService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
@@ -19,12 +21,12 @@ public class GetAirportDetailService { | |||
public JsonResult getAirportDetail(String sn) { | |||
JsonResult airportMsg = tzhlGetAirportMsgService.getAirportMsg(sn); | |||
if(airportMsg.getCode() != 0){ | |||
return JsonResult.error(airportMsg.getMsg()); | |||
TZHLAirportMsgResponse airportMsgResponse = tzhlGetAirportMsgService.getAirportMsg(sn); | |||
if(ObjectUtil.isNull(airportMsgResponse)){ | |||
return JsonResult.error("获取机场信息失败"); | |||
} | |||
return airportMsg; | |||
return JsonResult.success(airportMsgResponse); | |||
} | |||
} |
@@ -0,0 +1,42 @@ | |||
package com.tuoheng.admin.tzhl.response; | |||
import lombok.Data; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2023/8/12 | |||
*/ | |||
@Data | |||
public class TZHLAirportMsgResponse { | |||
/** | |||
* 环境温度 单位":"°C" | |||
*/ | |||
private Float environmentTemperature; | |||
/** | |||
* 降雨量("0":"无雨","1":"小雨","2":"中雨","3":"大雨") | |||
*/ | |||
private Integer rainfall; | |||
/** | |||
* 电量百分比 | |||
*/ | |||
private Integer capacityPercent; | |||
/** | |||
* 舱内温度 单位":"°C" | |||
*/ | |||
private Float temperature; | |||
/** | |||
* 舱内湿度 单位":"%RH" | |||
*/ | |||
private Integer humidity; | |||
/** | |||
* 风速 单位:"m/s" | |||
*/ | |||
private Float windSpeed; | |||
} |
@@ -1,6 +1,8 @@ | |||
package com.tuoheng.admin.tzhl.service.airport; | |||
import com.alibaba.fastjson.JSON; | |||
import com.tuoheng.admin.tzhl.constant.TZHLConstant; | |||
import com.tuoheng.admin.tzhl.response.TZHLAirportMsgResponse; | |||
import com.tuoheng.admin.tzhl.service.CallTianYiPlatformService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.common.core.utils.StringUtils; | |||
@@ -20,19 +22,20 @@ public class TZHLGetAirportMsgService { | |||
@Autowired | |||
private CallTianYiPlatformService callTianYiPlatformService; | |||
public JsonResult getAirportMsg(String sn){ | |||
public TZHLAirportMsgResponse getAirportMsg(String sn){ | |||
JsonResult jsonResult = this.check(sn); | |||
if(jsonResult.getCode() != 0){ | |||
return JsonResult.error(jsonResult.getMsg()); | |||
return null; | |||
} | |||
//读取全量机场平台列表 | |||
String param = "?sn=" +sn; | |||
String url = TZHLConstant.TIAN_YI_API_AIRPORT_MSG + param; | |||
String data = callTianYiPlatformService.callGet(url, null); | |||
TZHLAirportMsgResponse tzhlAirportMsgResponse = JSON.parseObject(data, TZHLAirportMsgResponse.class); | |||
return JsonResult.success(data); | |||
return tzhlAirportMsgResponse; | |||
} | |||
private JsonResult check(String sn) { |