Browse Source

首页模块开发

tags/v1.1.0^2
chenjiandong 1 year ago
parent
commit
934115bbcb
3 changed files with 88 additions and 2 deletions
  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 View File

} }


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

+ 54
- 0
tuoheng-admin/src/main/java/com/tuoheng/admin/entity/dto/index/AirportDetailDto.java View File

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 View File

package com.tuoheng.admin.service.impl; package com.tuoheng.admin.service.impl;


import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.admin.entity.domain.Question; import com.tuoheng.admin.entity.domain.Question;
import com.tuoheng.admin.entity.domain.ThMission; 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.dto.index.QuestionListDto;
import com.tuoheng.admin.entity.request.index.GetAirportDetailDto; import com.tuoheng.admin.entity.request.index.GetAirportDetailDto;
import com.tuoheng.admin.entity.request.index.GetQuestionListDto; import com.tuoheng.admin.entity.request.index.GetQuestionListDto;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;


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


/** /**
* @author chenjiandong * @author chenjiandong
String param = "airportId=" + getAirportDetailDto.getAirportId(); String param = "airportId=" + getAirportDetailDto.getAirportId();
String result = HttpUtils.sendGet(url, param); String result = HttpUtils.sendGet(url, param);
JsonResult jsonResult = JacksonUtil.json2pojo(result, JsonResult.class); 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 @Override

Loading…
Cancel
Save