* @return | * @return | ||||
*/ | */ | ||||
@GetMapping("/line/list") | @GetMapping("/line/list") | ||||
public JsonResult getAirLineList(String sn) { | |||||
return airportService.getAirLineList(sn); | |||||
public JsonResult getAirLineList(String sn,Long id) { | |||||
return airportService.getAirLineList(sn,id); | |||||
} | } | ||||
/** | /** | ||||
* 获取机场详细信息 | * 获取机场详细信息 | ||||
} | } | ||||
/** | /** | ||||
* 根据无人机id获取机场内外监控视频 | |||||
* @param droneId | |||||
* 根据巡检机场id获取机场内外监控视频 | |||||
* @param airportId | |||||
* @return | * @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); | |||||
} | } | ||||
JsonResult getAirportList(List<Long> ids); | JsonResult getAirportList(List<Long> ids); | ||||
JsonResult getAirLineList(String sn); | |||||
JsonResult getAirLineList(String sn,Long id); | |||||
JsonResult executeTask(String userId, Inspection inspection); | JsonResult executeTask(String userId, Inspection inspection); | ||||
JsonResult reversalFlight(ReversalFlightDto dto); | JsonResult reversalFlight(ReversalFlightDto dto); | ||||
JsonResult getAirportVideo(Integer droneId); | |||||
JsonResult getAirportVideo(Integer airportId); | |||||
} | } |
} | } | ||||
@Override | @Override | ||||
public JsonResult getAirLineList(String sn) { | |||||
return getAirLineListService.getAirLineList(sn); | |||||
public JsonResult getAirLineList(String sn,Long id) { | |||||
return getAirLineListService.getAirLineList(sn,id); | |||||
} | } | ||||
@Override | @Override | ||||
} | } | ||||
@Override | @Override | ||||
public JsonResult getAirportVideo(Integer droneId) { | |||||
return getAirportVideoService.getAirportVideo(droneId); | |||||
public JsonResult getAirportVideo(Integer airportId) { | |||||
return getAirportVideoService.getAirportVideo(airportId); | |||||
} | } | ||||
} | } |
@Autowired | @Autowired | ||||
private TZHLGetAirportLineListService tzhlGetAirportLineListService; | 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; | |||||
} | } | ||||
package com.tuoheng.admin.service.third.airport; | 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 com.tuoheng.common.core.utils.JsonResult; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
/** | /** | ||||
* @Author ChengWang | * @Author ChengWang | ||||
* @Date 2023/4/26 | * @Date 2023/4/26 | ||||
public class GetAirportVideoService { | public class GetAirportVideoService { | ||||
@Autowired | @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; | |||||
} | } | ||||
} | } |
package com.tuoheng.admin.tzhl.request; | |||||
import lombok.Data; | |||||
/** | |||||
* @Author ChengWang | |||||
* @Date 2023/8/11 | |||||
*/ | |||||
@Data | |||||
public class TZHLAirportLineListRequest { | |||||
/** | |||||
* 机场id | |||||
*/ | |||||
private String ids; | |||||
} |
import com.alibaba.fastjson.JSON; | import com.alibaba.fastjson.JSON; | ||||
import com.tuoheng.admin.dto.GetAirportListDto; | import com.tuoheng.admin.dto.GetAirportListDto; | ||||
import com.tuoheng.admin.tzhl.constant.TZHLConstant; | import com.tuoheng.admin.tzhl.constant.TZHLConstant; | ||||
import com.tuoheng.admin.tzhl.request.TZHLAirportLineListRequest; | |||||
import com.tuoheng.admin.tzhl.service.CallTianYiPlatformService; | import com.tuoheng.admin.tzhl.service.CallTianYiPlatformService; | ||||
import com.tuoheng.common.core.config.common.CommonConfig; | import com.tuoheng.common.core.config.common.CommonConfig; | ||||
import com.tuoheng.common.core.utils.JsonResult; | import com.tuoheng.common.core.utils.JsonResult; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import org.springframework.web.client.RestTemplate; | import org.springframework.web.client.RestTemplate; | ||||
import java.util.Arrays; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
private CallTianYiPlatformService callTianYiPlatformService; | private CallTianYiPlatformService callTianYiPlatformService; | ||||
public JsonResult getAirportList(List<Long> idList){ | 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); | List<GetAirportListDto> getAirportListDtoList = JSON.parseArray(data, GetAirportListDto.class); | ||||
if(ObjectUtil.isNull(getAirportListDtoList)){ | if(ObjectUtil.isNull(getAirportListDtoList)){ | ||||
return JsonResult.error("查询机场列表数据为空"); | return JsonResult.error("查询机场列表数据为空"); |
@Slf4j | @Slf4j | ||||
public class TZHLGetAirportLineListService { | public class TZHLGetAirportLineListService { | ||||
@Autowired | |||||
private TZHLGetTokenService tzhlGetTokenService; | |||||
@Autowired | @Autowired | ||||
private CallTianYiPlatformService callTianYiPlatformService; | private CallTianYiPlatformService callTianYiPlatformService; | ||||
@Autowired | |||||
private RestTemplate restTemplate; | |||||
public JsonResult getAirportLine(String name, String sn, Long id, String lineType){ | public JsonResult getAirportLine(String name, String sn, Long id, String lineType){ | ||||
TZHLGetAirportLineListRequest request = new TZHLGetAirportLineListRequest(); | TZHLGetAirportLineListRequest request = new TZHLGetAirportLineListRequest(); | ||||
request.setName(name); | request.setName(name); | ||||
return JsonResult.success(tzhlAirportLineResponses); | return JsonResult.success(tzhlAirportLineResponses); | ||||
} | } | ||||
private JsonResult check(String token) { | |||||
if(StringUtils.isEmpty(token)){ | |||||
return JsonResult.error("token不存在或已过期"); | |||||
} | |||||
return JsonResult.success(); | |||||
} | |||||
} | } |
@Test | @Test | ||||
public void testGetAirportListTest() { | public void testGetAirportListTest() { | ||||
List<Long> ids = new ArrayList<>(); | List<Long> ids = new ArrayList<>(); | ||||
ids.add(7l); | |||||
ids.add(null); | |||||
JsonResult result = tzhlGetAirportListService.getAirportList(ids); | JsonResult result = tzhlGetAirportListService.getAirportList(ids); | ||||
System.out.println("data" + result.getData()); | System.out.println("data" + result.getData()); | ||||
} | } |