@@ -32,12 +32,12 @@ public class AirPortController { | |||
/** | |||
* 获取巡检线路 | |||
* | |||
* @param droneId 机场列表里面的droneId | |||
* @param | |||
* @return | |||
*/ | |||
@GetMapping("/line/list/{droneId}") | |||
public JsonResult getAirLineList(@PathVariable("droneId") Integer droneId) { | |||
return airportService.getAirLineList(droneId); | |||
@GetMapping("/line/list") | |||
public JsonResult getAirLineList(String sn) { | |||
return airportService.getAirLineList(sn); | |||
} | |||
/** | |||
* 获取机场详细信息 |
@@ -8,7 +8,7 @@ public interface AirportService { | |||
JsonResult getAirportList(); | |||
JsonResult getAirLineList(Integer droneId); | |||
JsonResult getAirLineList(String sn); | |||
JsonResult executeTask(String userId, Inspection inspection); | |||
@@ -33,8 +33,8 @@ public class AirportServiceImpl implements AirportService { | |||
} | |||
@Override | |||
public JsonResult getAirLineList(Integer droneId) { | |||
return getAirLineListService.getAirLineList(droneId); | |||
public JsonResult getAirLineList(String sn) { | |||
return getAirLineListService.getAirLineList(sn); | |||
} | |||
@Override |
@@ -1,23 +1,12 @@ | |||
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.admin.vo.AirLineVO; | |||
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.airportline.TZHLGetAirportLineListService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.common.core.utils.StringUtils; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.Objects; | |||
@Slf4j | |||
@Service | |||
public class GetAirLineListService { | |||
@@ -25,21 +14,19 @@ public class GetAirLineListService { | |||
@Autowired | |||
private TenantMapper tenantMapper; | |||
public JsonResult getAirLineList(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()); | |||
} | |||
String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_LINE_LIST; | |||
String param = "page=1&limit=100&droneId=" + droneId; | |||
String airPortStr = HttpUtils.sendGet(url, param); | |||
JsonResult<AirLineVO> jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class); | |||
@Autowired | |||
private TZHLGetAirportLineListService tzhlGetAirportLineListService; | |||
if (ObjectUtil.isEmpty(jsonResult) || (!ObjectUtil.isEmpty(Objects.requireNonNull(jsonResult).getData()) && jsonResult.getCode() != 0)) { | |||
return JsonResult.error(AriportCodeEnum.BAD_REQUEST.getCode(), AriportCodeEnum.BAD_REQUEST.getMsg()); | |||
public JsonResult getAirLineList(String sn) { | |||
//根据机场序列号获取航线列表 | |||
JsonResult result = tzhlGetAirportLineListService.getAirportLine(null,sn,null); | |||
if(result.getCode() != 0){ | |||
return JsonResult.error(result.getMsg()); | |||
} | |||
return jsonResult; | |||
return result; | |||
} | |||
} |
@@ -1,24 +1,12 @@ | |||
package com.tuoheng.admin.service.third.airport; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.alibaba.fastjson.JSONObject; | |||
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.admin.vo.AirPortVO; | |||
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 com.tuoheng.common.core.utils.StringUtils; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.List; | |||
@Slf4j | |||
@Service | |||
public class GetAirportListService { | |||
@@ -26,22 +14,19 @@ public class GetAirportListService { | |||
@Autowired | |||
private TenantMapper tenantMapper; | |||
@Autowired | |||
private TZHLGetAirportListService tzhlGetAirportListService; | |||
public JsonResult getAirportList() { | |||
//读取不同租户的机场平台url | |||
Tenant tenant = tenantMapper.selectById(CurrentUserUtil.getTenantId()); | |||
if (ObjectUtil.isEmpty(tenant)) { | |||
return JsonResult.error(AriportCodeEnum.GET_NO_TENANT.getCode(), AriportCodeEnum.GET_NO_TENANT.getMsg()); | |||
//读取全量机场列表数据 | |||
JsonResult result = tzhlGetAirportListService.getAirportList(); | |||
if(result.getCode() != 0){ | |||
return JsonResult.error(result.getMsg()); | |||
} | |||
String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_LIST; | |||
String param = "page=1&limit=100&tenantCode=" + tenant.getCode(); | |||
String airPortStr = HttpUtils.sendGet(url, param); | |||
JsonResult jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class); | |||
return result; | |||
if (ObjectUtil.isEmpty(jsonResult) || (!ObjectUtil.isEmpty(jsonResult.getData()) && jsonResult.getCode() != 0)) { | |||
return JsonResult.error(AriportCodeEnum.BAD_REQUEST.getCode(), AriportCodeEnum.BAD_REQUEST.getMsg()); | |||
} | |||
return jsonResult; | |||
} | |||
} |
@@ -25,7 +25,7 @@ public class TZHLGetAirportLineListServiceTest { | |||
@Test | |||
public void testGetAirportLineListTest() { | |||
String name = null; | |||
String sn = "7"; | |||
String sn = "4TADKCC0010018"; | |||
String lineType = null; | |||
JsonResult result = tzhlGetAirportLineListService.getAirportLine(name,sn,lineType); | |||
System.out.println("data" + result.getData()); |