Parcourir la source

首页模块开发

tags/v1.1.0^2
chenjiandong il y a 1 an
Parent
révision
934115bbcb
3 fichiers modifiés avec 88 ajouts et 2 suppressions
  1. +1
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/controller/IndexGisController.java
  2. +54
    -0
      tuoheng-admin/src/main/java/com/tuoheng/admin/entity/dto/index/AirportDetailDto.java
  3. +33
    -1
      tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/IndexServiceImpl.java

+ 1
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/controller/IndexGisController.java Voir le fichier

@@ -37,7 +37,7 @@ public class IndexGisController {
}

/**
* 获取机场列表
* 获取机场详细信息
* @param getAirportDetailDto
* @return
*/

+ 54
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/dto/index/AirportDetailDto.java Voir le fichier

@@ -0,0 +1,54 @@
package com.tuoheng.admin.entity.dto.index;

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

/**
* @author chenjiandong
* @description: TODO
* @date 2022/12/28 14:53
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class AirportDetailDto {

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

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

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

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

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

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

/**
* 可选挂载
*/
private String mountName;

}

+ 33
- 1
tuoheng-admin/src/main/java/com/tuoheng/admin/service/impl/IndexServiceImpl.java Voir le fichier

@@ -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

Chargement…
Annuler
Enregistrer