|
|
@@ -1,11 +1,13 @@ |
|
|
|
package com.tuoheng.admin.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.tuoheng.admin.entity.domain.Question; |
|
|
|
import com.tuoheng.admin.entity.domain.ThMission; |
|
|
|
import com.tuoheng.admin.entity.dto.index.AirportDetailDto; |
|
|
|
import com.tuoheng.admin.entity.dto.index.QuestionListDto; |
|
|
|
import com.tuoheng.admin.entity.request.index.GetAirportDetailDto; |
|
|
|
import com.tuoheng.admin.entity.request.index.GetQuestionListDto; |
|
|
@@ -26,8 +28,10 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author chenjiandong |
|
|
@@ -78,7 +82,35 @@ public class IndexServiceImpl implements IndexService { |
|
|
|
String param = "airportId=" + getAirportDetailDto.getAirportId(); |
|
|
|
String result = HttpUtils.sendGet(url, param); |
|
|
|
JsonResult jsonResult = JacksonUtil.json2pojo(result, JsonResult.class); |
|
|
|
return jsonResult; |
|
|
|
AirportDetailDto airportDetailDto = new AirportDetailDto(); |
|
|
|
JSONObject dataObject = (JSONObject) JSONObject.toJSON(jsonResult.getData()); |
|
|
|
JSONObject wthJson = dataObject.getJSONObject("WTH"); |
|
|
|
if(Objects.nonNull(wthJson)){ |
|
|
|
JSONObject parmJson = wthJson.getJSONObject("parm"); |
|
|
|
airportDetailDto.setWspd(parmJson.getString("WSPD") + "m/s") |
|
|
|
.setWdir(parmJson.getString("WDIR") + "度"); |
|
|
|
//用角度表示风向,是把圆周分成360度,北风(N)是0度(即360度),东风(E)是90度,南风(S)是180度,西风(W)是270度 |
|
|
|
BigDecimal hpa = parmJson.getBigDecimal("Hpa"); |
|
|
|
BigDecimal mpa = hpa.divide(new BigDecimal(100000), 1, BigDecimal.ROUND_HALF_UP); |
|
|
|
airportDetailDto.setHpa(mpa + "Mpa"); |
|
|
|
} |
|
|
|
JSONObject tahJson = dataObject.getJSONObject("TAH"); |
|
|
|
if(Objects.nonNull(tahJson)){ |
|
|
|
JSONObject parmJson = wthJson.getJSONObject("parm"); |
|
|
|
BigDecimal hum = parmJson.getBigDecimal("Hum").divide(new BigDecimal(10), 1, BigDecimal.ROUND_HALF_UP); |
|
|
|
airportDetailDto.setHum(hum + "rh"); |
|
|
|
BigDecimal tmp = parmJson.getBigDecimal("Tmp").divide(new BigDecimal(10), 1, BigDecimal.ROUND_HALF_UP); |
|
|
|
airportDetailDto.setTmp(tmp + "℃"); |
|
|
|
} |
|
|
|
JSONObject mountJson = dataObject.getJSONObject("mount"); |
|
|
|
if(Objects.nonNull(mountJson)){ |
|
|
|
airportDetailDto.setMountName(mountJson.getString("cameraName") + "、" + |
|
|
|
mountJson.getString("megaphoneName") + "、" + |
|
|
|
mountJson.getString("searchlightName") |
|
|
|
); |
|
|
|
} |
|
|
|
airportDetailDto.setStatus(dataObject.getString("status")); |
|
|
|
return JsonResult.success(airportDetailDto); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |