Browse Source

事故时间轴接口修改

tags/v1.2.0^2
chengwang 1 year ago
parent
commit
17e25951ab
5 changed files with 187 additions and 3 deletions
  1. +36
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/IndexGisController.java
  2. +0
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/TimeAxisService.java
  3. +12
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/index/IndexService.java
  4. +74
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/index/IndexServiceImpl.java
  5. +65
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/AirportMsgVo.java

+ 36
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/IndexGisController.java View File

@@ -0,0 +1,36 @@
package com.tuoheng.admin.controller;

import com.tuoheng.admin.service.index.IndexService;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* @Author ChengWang
* @Date 2023/3/16
*/
@RestController
@RequestMapping("/index")
@Slf4j
public class IndexGisController {

@Autowired
private IndexService indexService;

/**
* 获取机场详细信息
* @param airportId
* @return
*/
@GetMapping("/getAirportMsg/{airportId}")
public JsonResult getAirportMsg(@PathVariable("airportId") Integer airportId){
log.info("根据机场id获取机场详细信息,airportId={}",airportId.toString());
return indexService.getAirportMsg(airportId);
}


}

+ 0
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/TimeAxisService.java View File

@@ -61,9 +61,6 @@ public class TimeAxisService {
List<AccidentPromptlyLookVo> list = new ArrayList<>();;
List<AccidentRead> accidentReadList = accidentReadMapper.selectList(Wrappers.<AccidentRead>lambdaQuery()
.eq(AccidentRead::getAccidentId, accidentId));
if(CollectionUtils.isEmpty(accidentReadList) || accidentReadList.size() == 0){
list.add(null);
}
//遍历每个用户对应事故的时间
for (AccidentRead accidentRead : accidentReadList) {
AccidentPromptlyLookVo promptlyLookVo = new AccidentPromptlyLookVo();

+ 12
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/index/IndexService.java View File

@@ -0,0 +1,12 @@
package com.tuoheng.admin.service.index;

import com.tuoheng.common.core.utils.JsonResult;

/**
* @Author ChengWang
* @Date 2023/3/16
*/
public interface IndexService {

JsonResult getAirportMsg(Integer airportId);
}

+ 74
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/index/IndexServiceImpl.java View File

@@ -0,0 +1,74 @@
package com.tuoheng.admin.service.index;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.tuoheng.admin.vo.AirportMsgVo;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Objects;

/**
* @Author ChengWang
* @Date 2023/3/16
*/
@Service
@Slf4j
public class IndexServiceImpl implements IndexService{


@Override
public JsonResult getAirportMsg(Integer airportId) {
String url = CommonConfig.airportURL + "/api/airportInterface/getAirportStatus";
String param = "airportId" + airportId;
String result = HttpUtils.sendGet(url, param);
//JSONObject jsonObject = JSON.parseObject(result);
JsonResult jsonResult = JacksonUtil.json2pojo(result, JsonResult.class);
AirportMsgVo airportMsgVo = new AirportMsgVo();
JSONObject dataObject = (JSONObject) JSONObject.toJSON(jsonResult.getData());
JSONObject wthJson = dataObject.getJSONObject("WTH");
if(Objects.nonNull(wthJson)){
JSONObject parmJson = wthJson.getJSONObject("parmNew");
BigDecimal hum = parmJson.getBigDecimal("Hum").divide(new BigDecimal(10), 1, BigDecimal.ROUND_HALF_UP);
airportMsgVo.setHum(hum + "rh");
BigDecimal tmp = parmJson.getBigDecimal("Tmp").divide(new BigDecimal(10), 1, BigDecimal.ROUND_HALF_UP);
airportMsgVo.setTmp(tmp + "℃");

airportMsgVo.setWspd(parmJson.getString("WSPD") + "m/s")
.setWdir(parmJson.getString("WDIR") + "度")
.setRainfull(parmJson.getString("Rainfull") + "mm")
.setWidrName(parmJson.getString("WDIRNAME"));
//用角度表示风向,是把圆周分成360度,北风(N)是0度(即360度),东风(E)是90度,南风(S)是180度,西风(W)是270度
BigDecimal hpa = parmJson.getBigDecimal("Hpa");
if(hpa != null){
BigDecimal mpa = hpa.divide(new BigDecimal(100000), 1, BigDecimal.ROUND_HALF_UP);
airportMsgVo.setHpa(mpa + "Mpa");
airportMsgVo.setHpa(hpa + "Mpa");
}
}
JSONObject tahJson = dataObject.getJSONObject("TAH");
if(Objects.nonNull(tahJson)){
JSONObject parmJson = tahJson.getJSONObject("parmNew");
BigDecimal hum = parmJson.getBigDecimal("Hum").divide(new BigDecimal(10), 1, BigDecimal.ROUND_HALF_UP);
airportMsgVo.setHum(hum + "rh");
BigDecimal tmp = parmJson.getBigDecimal("Tmp").divide(new BigDecimal(10), 1, BigDecimal.ROUND_HALF_UP);
airportMsgVo.setTmp(tmp + "℃");
}
JSONObject mountJson = dataObject.getJSONObject("mount");
if(Objects.nonNull(mountJson)){
airportMsgVo.setMountName(mountJson.getString("cameraName") + "、" +
mountJson.getString("megaphoneName") + "、" +
mountJson.getString("searchlightName")
);
}
airportMsgVo.setStatus(dataObject.getString("status"));

return JsonResult.success(airportMsgVo);
}
}

+ 65
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/AirportMsgVo.java View File

@@ -0,0 +1,65 @@
package com.tuoheng.admin.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
* @Author ChengWang
* @Date 2023/3/16
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class AirportMsgVo {

/**
* 风速
*/
private String wspd;

/**
* 风向
*/
private String wdir;

/**
* 风向名称
*/
private String widrName;

/**
* 大气压力
*/
private String hpa;

/**
* 空气湿度
*/
private String hum;

/**
* 空气温度
*/
private String tmp;

/**
* 机场状态
*/
private String status;

/**
* 降雨量
*/
private String rainfull;

/**
* 可挂载设备
*/
private String mountName;



}

Loading…
Cancel
Save