@@ -69,6 +69,11 @@ public interface SystemConstant { | |||
*/ | |||
String ADD_PILOTTASK = "apiTask/add"; | |||
/** | |||
* 机场平台:获取机场路线列表接口 | |||
*/ | |||
String API_AIRPORT_LINE_FILE_LIST = "/airportInterface/getAirlineFileListForThird"; | |||
/** | |||
* 机场平台:获取机场状态 | |||
*/ |
@@ -1,11 +1,15 @@ | |||
package com.tuoheng.admin.controller; | |||
import com.tuoheng.admin.entity.request.inspection.AirportLineRequest; | |||
import com.tuoheng.admin.entity.vo.AirportLineVo; | |||
import com.tuoheng.admin.service.airportline.IAirportLineService; | |||
import com.tuoheng.admin.service.third.airport.AirportService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.*; | |||
import java.util.List; | |||
/** | |||
* 航线前端控制器 | |||
* | |||
@@ -29,6 +33,16 @@ public class AirportLineController { | |||
return airportLineService.getInfoByInspectionId(inspectionId); | |||
} | |||
/** | |||
* 根据机场ID获取航线列表 | |||
* @param airportId | |||
* @return | |||
*/ | |||
@GetMapping("/list/byAirportId/{airportId}") | |||
public JsonResult getListByAirportIdId(@PathVariable("airportId") String airportId) { | |||
return airportLineService.getListByAirportIdId(airportId); | |||
} | |||
/** | |||
*添加航线 | |||
* @param request |
@@ -0,0 +1,56 @@ | |||
package com.tuoheng.admin.entity.vo; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import java.io.Serializable; | |||
/** | |||
* 机场线路视图Vo | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2022-11-23 | |||
*/ | |||
@Data | |||
@NoArgsConstructor | |||
public class AirportLineVo implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 航线id | |||
*/ | |||
private Integer id; | |||
/** | |||
* 航线名称 | |||
*/ | |||
private String fileName; | |||
/** | |||
* 航线地址 | |||
*/ | |||
private String fileUrl; | |||
/** | |||
* 机场ID | |||
*/ | |||
private String airportId; | |||
/** | |||
* 机场名称 | |||
*/ | |||
private String airportName; | |||
/** | |||
* 航线类型:1,航点航线;2,指点航线;3,指面航线 | |||
*/ | |||
private String type; | |||
/** | |||
* 备注 | |||
*/ | |||
private String note; | |||
} |
@@ -2,14 +2,19 @@ package com.tuoheng.admin.service.airportline; | |||
import com.tuoheng.admin.entity.domain.AirportLine; | |||
import com.tuoheng.admin.entity.request.inspection.AirportLineRequest; | |||
import com.tuoheng.admin.entity.vo.AirportLineVo; | |||
import com.tuoheng.admin.mapper.AirportLineMapper; | |||
import com.tuoheng.admin.service.airportline.add.AddAirportLineService; | |||
import com.tuoheng.admin.service.airportline.query.inspection.QueryAirportLineByInspectionIdFactory; | |||
import com.tuoheng.admin.service.third.airport.AirportService; | |||
import com.tuoheng.common.core.common.BaseServiceImpl; | |||
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 org.springframework.web.bind.annotation.PathVariable; | |||
import java.util.List; | |||
/** | |||
* @Author ChengWang | |||
@@ -25,6 +30,9 @@ public class AirportLineServiceImpl extends BaseServiceImpl<AirportLineMapper, A | |||
@Autowired | |||
private AddAirportLineService addAirportLineService; | |||
@Autowired | |||
private AirportService airportService; | |||
/** | |||
* 查询航线信息 | |||
* | |||
@@ -36,6 +44,19 @@ public class AirportLineServiceImpl extends BaseServiceImpl<AirportLineMapper, A | |||
return queryAirportLineByInspectionIdFactory.getAirportLineList(inspectionId); | |||
} | |||
/** | |||
* 查询航线信息 | |||
* | |||
* @param airportId 任务Id | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult getListByAirportIdId(String airportId) { | |||
List<AirportLineVo> airportLineVoList = airportService.getAirportLineListByAirportIdAndLineIdList(airportId, null); | |||
return JsonResult.success(airportLineVoList); | |||
} | |||
/** | |||
*添加航线 | |||
* @param request |
@@ -4,6 +4,7 @@ import com.tuoheng.admin.entity.domain.AirportLine; | |||
import com.tuoheng.admin.entity.request.inspection.AirportLineRequest; | |||
import com.tuoheng.common.core.common.IBaseService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import org.springframework.web.bind.annotation.PathVariable; | |||
/** | |||
* @Author ChengWang | |||
@@ -19,6 +20,14 @@ public interface IAirportLineService extends IBaseService<AirportLine> { | |||
*/ | |||
JsonResult getInfoByInspectionId(String inspectionId); | |||
/** | |||
* 查询航线列表 | |||
* | |||
* @param airportId 机场Id | |||
* @return | |||
*/ | |||
JsonResult getListByAirportIdId(String airportId); | |||
/** | |||
*新增航线 | |||
* @param request |
@@ -3,10 +3,15 @@ package com.tuoheng.admin.service.third.airport; | |||
import com.tuoheng.admin.entity.domain.Inspection; | |||
import com.tuoheng.admin.entity.request.airport.DroneHoverRequest; | |||
import com.tuoheng.admin.entity.request.airport.ReversalFlightRequest; | |||
import com.tuoheng.admin.entity.vo.AirportLineVo; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import java.util.List; | |||
public interface AirportService { | |||
List<AirportLineVo> getAirportLineListByAirportIdAndLineIdList(String airportId, List<Integer> airportLineIdList); | |||
JsonResult getAirportList(); | |||
JsonResult getAirLineList(Integer droneId); |
@@ -3,12 +3,15 @@ package com.tuoheng.admin.service.third.airport; | |||
import com.tuoheng.admin.entity.domain.Inspection; | |||
import com.tuoheng.admin.entity.request.airport.DroneHoverRequest; | |||
import com.tuoheng.admin.entity.request.airport.ReversalFlightRequest; | |||
import com.tuoheng.admin.entity.vo.AirportLineVo; | |||
import com.tuoheng.admin.service.third.airport.drone.DroneService; | |||
import com.tuoheng.admin.service.third.airport.reversal.ReversalFlightService; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.List; | |||
@Service | |||
public class AirportServiceImpl implements AirportService { | |||
@@ -33,6 +36,11 @@ public class AirportServiceImpl implements AirportService { | |||
@Autowired | |||
private ReversalFlightService reversalFlightService; | |||
@Override | |||
public List<AirportLineVo> getAirportLineListByAirportIdAndLineIdList(String airportId, List<Integer> airportLineIdList) { | |||
return getAirLineListService.getList(airportId, airportLineIdList); | |||
} | |||
@Override | |||
public JsonResult getAirportList() { | |||
return getAirportListService.getAirportList(); |
@@ -1,20 +1,29 @@ | |||
package com.tuoheng.admin.service.third.airport; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.tuoheng.admin.constant.SystemConstant; | |||
import com.tuoheng.admin.entity.domain.Tenant; | |||
import com.tuoheng.admin.entity.vo.AirportLineVo; | |||
import com.tuoheng.admin.enums.code.AriportCodeEnum; | |||
import com.tuoheng.admin.mapper.TenantMapper; | |||
import com.tuoheng.admin.utils.CurrentUserUtil; | |||
import com.tuoheng.admin.entity.vo.AirLineVO; | |||
import com.tuoheng.common.core.config.common.CommonConfig; | |||
import com.tuoheng.common.core.exception.ServiceException; | |||
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.beans.factory.annotation.Autowired; | |||
import org.springframework.beans.factory.annotation.Qualifier; | |||
import org.springframework.http.*; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.web.client.RestTemplate; | |||
import org.springframework.web.util.UriComponentsBuilder; | |||
import java.util.List; | |||
import java.util.Objects; | |||
@Slf4j | |||
@@ -24,23 +33,78 @@ public class GetAirLineListService { | |||
@Autowired | |||
private TenantMapper tenantMapper; | |||
@Autowired | |||
@Qualifier("restTemplate") | |||
private RestTemplate restTemplate; | |||
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); | |||
log.info("调用机场平台,获取航线列表:airPortStr={}",airPortStr); | |||
//string----->JsonResult | |||
JsonResult<AirLineVO> jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class); | |||
String url = UriComponentsBuilder.fromHttpUrl(CommonConfig.airportURL + SystemConstant.API_AIRPORT_LINE_LIST) | |||
.queryParam("page", 1) | |||
.queryParam("limit", 100) | |||
.queryParam("droneId", droneId) | |||
.toUriString(); | |||
JsonResult jsonResult; | |||
try { | |||
jsonResult = restTemplate.getForObject(url, JsonResult.class); | |||
} catch (Exception e) { | |||
log.info("获机航线列表接口异常, url:{}", url); | |||
throw new ServiceException("获机航线列表接口异常"); | |||
} | |||
if (ObjectUtil.isEmpty(jsonResult) || (!ObjectUtil.isEmpty(Objects.requireNonNull(jsonResult).getData()) && jsonResult.getCode() != 0)) { | |||
return JsonResult.error(AriportCodeEnum.BAD_REQUEST.getCode(), AriportCodeEnum.BAD_REQUEST.getMsg()); | |||
} | |||
return jsonResult; | |||
} | |||
public List<AirportLineVo> getList(String airportId, List<Integer> airportLineIdList) { | |||
//读取不同租户的机场平台url | |||
Tenant tenant = tenantMapper.selectById(CurrentUserUtil.getTenantId()); | |||
if (ObjectUtil.isEmpty(tenant)) { | |||
return null; | |||
} | |||
String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_LINE_FILE_LIST; | |||
JSONObject jsonObject = new JSONObject(); | |||
jsonObject.put("tenantCode", tenant.getCode()); | |||
jsonObject.put("airportId", airportId); | |||
jsonObject.put("airlineFileIds", airportLineIdList); | |||
log.info("调用机场平台,获取航线列表,url:{}", url); | |||
log.info("调用机场平台,获取航线列表,jsonObject:{}", jsonObject); | |||
HttpHeaders headers = new HttpHeaders(); | |||
headers.setContentType(MediaType.APPLICATION_JSON); | |||
HttpEntity httpEntity = new HttpEntity(jsonObject, headers); | |||
ResponseEntity<JsonResult> response; | |||
try { | |||
response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, JsonResult.class); | |||
} catch (Exception e) { | |||
log.info("调用机场平台,获取航线列表接口异常,url:{}", url); | |||
log.info("调用机场平台,获取航线列表接口异常,jsonObject:{}", jsonObject); | |||
return null; | |||
} | |||
if (ObjectUtil.isEmpty(response)) { | |||
log.info("调用机场平台,获取航线列表接口返回为空,url:{}", url); | |||
log.info("调用机场平台,获取航线列表接口返回为空,jsonObject:{}", jsonObject); | |||
return null; | |||
} | |||
JsonResult jsonResult = response.getBody(); | |||
if (0 != jsonResult.getCode()) { | |||
log.info("调用机场平台,获取航线列表,失败,url:{}", url); | |||
log.info("调用机场平台,获取航线列表,失败,jsonObject:{}", jsonObject); | |||
log.info("调用机场平台,获取航线列表,失败,jsonResult:{}", jsonResult.getMsg()); | |||
return null; | |||
} | |||
List<AirportLineVo> airportLineVoList = JSONObject.parseArray(JSONObject.toJSONString(jsonResult.getData()), AirportLineVo.class); | |||
if (CollectionUtil.isEmpty(airportLineVoList)) { | |||
log.info("调用机场平台,获取航线列表,数据为空"); | |||
} | |||
return airportLineVoList; | |||
} | |||
} |