Kaynağa Gözat

重构获取航线 机场 气象数据接口代码

tags/v1.3.1
chengwang 1 yıl önce
ebeveyn
işleme
1c9dbfe78c
9 değiştirilmiş dosya ile 69 ekleme ve 71 silme
  1. +8
    -8
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AirPortController.java
  2. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportService.java
  3. +4
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportServiceImpl.java
  4. +7
    -7
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/GetAirLineListService.java
  5. +15
    -30
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/GetAirportVideoService.java
  6. +16
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/request/TZHLAirportLineListRequest.java
  7. +16
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/airport/TZHLGetAirportListService.java
  8. +0
    -15
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/airportline/TZHLGetAirportLineListService.java
  9. +1
    -1
      tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/tzhl/TZHLGetAirportListServiceTest.java

+ 8
- 8
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/AirPortController.java Dosyayı Görüntüle

@@ -38,8 +38,8 @@ public class AirPortController {
* @return
*/
@GetMapping("/line/list")
public JsonResult getAirLineList(String sn) {
return airportService.getAirLineList(sn);
public JsonResult getAirLineList(String sn,Long id) {
return airportService.getAirLineList(sn,id);
}
/**
* 获取机场详细信息
@@ -52,14 +52,14 @@ public class AirPortController {
}

/**
* 根据无人机id获取机场内外监控视频
* @param droneId
* 根据巡检机场id获取机场内外监控视频
* @param airportId
* @return
*/
@GetMapping("/getAirportVideo/{droneId}")
public JsonResult getAirportVideo(@PathVariable("droneId") Integer droneId){
log.info("进入获取无人机内外视频画面:airportId={}",droneId);
return airportService.getAirportVideo(droneId);
@GetMapping("/getAirportVideo/{airportId}")
public JsonResult getAirportVideo(@PathVariable("airportId") Integer airportId){
log.info("进入获取无人机内外视频画面:airportId={}",airportId);
return airportService.getAirportVideo(airportId);
}



+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportService.java Dosyayı Görüntüle

@@ -10,7 +10,7 @@ public interface AirportService {

JsonResult getAirportList(List<Long> ids);

JsonResult getAirLineList(String sn);
JsonResult getAirLineList(String sn,Long id);

JsonResult executeTask(String userId, Inspection inspection);

@@ -18,6 +18,6 @@ public interface AirportService {

JsonResult reversalFlight(ReversalFlightDto dto);

JsonResult getAirportVideo(Integer droneId);
JsonResult getAirportVideo(Integer airportId);

}

+ 4
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportServiceImpl.java Dosyayı Görüntüle

@@ -35,8 +35,8 @@ public class AirportServiceImpl implements AirportService {
}

@Override
public JsonResult getAirLineList(String sn) {
return getAirLineListService.getAirLineList(sn);
public JsonResult getAirLineList(String sn,Long id) {
return getAirLineListService.getAirLineList(sn,id);
}

@Override
@@ -55,7 +55,7 @@ public class AirportServiceImpl implements AirportService {
}

@Override
public JsonResult getAirportVideo(Integer droneId) {
return getAirportVideoService.getAirportVideo(droneId);
public JsonResult getAirportVideo(Integer airportId) {
return getAirportVideoService.getAirportVideo(airportId);
}
}

+ 7
- 7
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/GetAirLineListService.java Dosyayı Görüntüle

@@ -17,15 +17,15 @@ public class GetAirLineListService {
@Autowired
private TZHLGetAirportLineListService tzhlGetAirportLineListService;

public JsonResult getAirLineList(String sn) {
public JsonResult getAirLineList(String sn,Long id) {
//根据机场序列号获取航线列表
// JsonResult result = tzhlGetAirportLineListService.getAirportLine(null,sn,null);
//
// if(result.getCode() != 0){
// return JsonResult.error(result.getMsg());
// }
JsonResult result = tzhlGetAirportLineListService.getAirportLine(null,sn,id,null);

return null;
if(result.getCode() != 0){
return JsonResult.error(result.getMsg());
}

return result;

}


+ 15
- 30
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/GetAirportVideoService.java Dosyayı Görüntüle

@@ -1,19 +1,14 @@
package com.tuoheng.admin.service.third.airport;

import cn.hutool.core.util.ObjectUtil;
import com.tuoheng.admin.constant.SystemConstant;
import com.tuoheng.admin.entity.Tenant;
import com.tuoheng.admin.enums.code.AriportCodeEnum;
import com.tuoheng.admin.mapper.TenantMapper;
import com.tuoheng.admin.utils.CurrentUserUtil;
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.admin.tzhl.service.airport.TZHLGetAirportListService;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* @Author ChengWang
* @Date 2023/4/26
@@ -23,31 +18,21 @@ import org.springframework.stereotype.Service;
public class GetAirportVideoService {

@Autowired
private TenantMapper tenantMapper;
private TZHLGetAirportListService tzhlGetAirportListService;


public JsonResult getAirportVideo(Integer droneId) {
//读取不同租户的机场平台url
Tenant tenant = tenantMapper.selectById(CurrentUserUtil.getTenantId());
if (ObjectUtil.isEmpty(tenant)) {
return JsonResult.error(AriportCodeEnum.GET_NO_TENANT.getCode(), AriportCodeEnum.GET_NO_TENANT.getMsg());
}
//校验
if(null == droneId){
return JsonResult.error(AriportCodeEnum.DRONE_ID_IS_NULL.getCode(),AriportCodeEnum.DRONE_ID_IS_NULL.getMsg());
}
String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_LIST;
String tempParam = "&tenantCode=" + tenant.getCode() + "&droneId=" + droneId;
String param = "page=1&limit=100" + tempParam;
String airPortStr = HttpUtils.sendGet(url, param);
//String---->JsonResult
JsonResult jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class);

if(ObjectUtil.isEmpty(jsonResult) || ObjectUtil.isEmpty(jsonResult.getData()) && jsonResult.getCode() != 0){
return JsonResult.error(AriportCodeEnum.BAD_REQUEST.getCode(),AriportCodeEnum.BAD_REQUEST.getMsg());

public JsonResult getAirportVideo(Integer airportId) {

List<Long> ids = new ArrayList<>();
ids.add((long)airportId);

JsonResult result = tzhlGetAirportListService.getAirportList(ids);
if(result.getCode() != 0){
return JsonResult.error(result.getCode());
}

return jsonResult;
return result;

}
}

+ 16
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/request/TZHLAirportLineListRequest.java Dosyayı Görüntüle

@@ -0,0 +1,16 @@
package com.tuoheng.admin.tzhl.request;

import lombok.Data;

/**
* @Author ChengWang
* @Date 2023/8/11
*/
@Data
public class TZHLAirportLineListRequest {

/**
* 机场id
*/
private String ids;
}

+ 16
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/airport/TZHLGetAirportListService.java Dosyayı Görüntüle

@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.tuoheng.admin.dto.GetAirportListDto;
import com.tuoheng.admin.tzhl.constant.TZHLConstant;
import com.tuoheng.admin.tzhl.request.TZHLAirportLineListRequest;
import com.tuoheng.admin.tzhl.service.CallTianYiPlatformService;
import com.tuoheng.common.core.config.common.CommonConfig;
import com.tuoheng.common.core.utils.JsonResult;
@@ -14,6 +15,7 @@ import org.springframework.http.HttpEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

@@ -34,13 +36,23 @@ public class TZHLGetAirportListService {
private CallTianYiPlatformService callTianYiPlatformService;

public JsonResult getAirportList(List<Long> idList){
String param = "?ids=" + idList;
Long[] longs = idList.stream().toArray(Long[]::new);
String username = Arrays.toString(longs);

System.out.println(username);


//Long[] ids = idList.toArray(new Long[idList.size()]);

//String param = "?ids=" + idList;
TZHLAirportLineListRequest request = new TZHLAirportLineListRequest();
request.setIds(username);


//读取全量机场平台列表
String url = TZHLConstant.TIAN_YI_API_AIRPORT_LIST + param;
String url = TZHLConstant.TIAN_YI_API_AIRPORT_LIST ;

String data = callTianYiPlatformService.callGet(url, null);
//List<GetAirportListDto> getAirportListDtoLists = JSON.parseArray(JSON.parse(body).toString(), GetAirportListDto.class);
String data = callTianYiPlatformService.callGet(url, request);
List<GetAirportListDto> getAirportListDtoList = JSON.parseArray(data, GetAirportListDto.class);
if(ObjectUtil.isNull(getAirportListDtoList)){
return JsonResult.error("查询机场列表数据为空");

+ 0
- 15
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/airportline/TZHLGetAirportLineListService.java Dosyayı Görüntüle

@@ -29,15 +29,9 @@ import java.util.List;
@Slf4j
public class TZHLGetAirportLineListService {

@Autowired
private TZHLGetTokenService tzhlGetTokenService;

@Autowired
private CallTianYiPlatformService callTianYiPlatformService;

@Autowired
private RestTemplate restTemplate;

public JsonResult getAirportLine(String name, String sn, Long id, String lineType){
TZHLGetAirportLineListRequest request = new TZHLGetAirportLineListRequest();
request.setName(name);
@@ -56,13 +50,4 @@ public class TZHLGetAirportLineListService {
return JsonResult.success(tzhlAirportLineResponses);
}

private JsonResult check(String token) {
if(StringUtils.isEmpty(token)){
return JsonResult.error("token不存在或已过期");
}

return JsonResult.success();
}


}

+ 1
- 1
tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/tzhl/TZHLGetAirportListServiceTest.java Dosyayı Görüntüle

@@ -27,7 +27,7 @@ public class TZHLGetAirportListServiceTest {
@Test
public void testGetAirportListTest() {
List<Long> ids = new ArrayList<>();
ids.add(7l);
ids.add(null);
JsonResult result = tzhlGetAirportListService.getAirportList(ids);
System.out.println("data" + result.getData());
}

Yükleniyor…
İptal
Kaydet