@@ -57,14 +57,12 @@ public class ExecuteTaskService { | |||
return JsonResult.success("泰州海陵区城管,航线不存在"); | |||
} | |||
TZHLShelterTaskResponse shelterTaskResponse = shelterTaskService.distributeTask(inspection, tzhlAirportLineResponse); | |||
if (ObjectUtil.isEmpty(shelterTaskResponse)) { | |||
Long recordId = shelterTaskService.distributeTask(inspection, tzhlAirportLineResponse); | |||
if (ObjectUtil.isEmpty(recordId)) { | |||
log.info("泰州海陵区城管,执行任务,下发任务失败"); | |||
return JsonResult.success("泰州海陵区城管,执行任务,下发任务失败"); | |||
} | |||
Long recordId = shelterTaskResponse.getRecord(); | |||
inspection.setStatus(InspectionStatusEnum.PREPARING.getCode()); | |||
TZHLOnlineUavResponse tzhlOnlineUavResponse = onlineUavService.getOnlineUav(); |
@@ -48,20 +48,20 @@ public class CallTianYiPlatformService { | |||
response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, JsonResult.class); | |||
} catch (RestClientException e) { | |||
log.info("泰州海陵区城管,接口异常, url:{}", url); | |||
log.info("泰州海陵区城管,接口异常, httpEntity:{}", httpEntity); | |||
log.info("泰州海陵区城管,接口异常, request:{}", request); | |||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "泰州海陵区城管,接口异常"); | |||
} | |||
if (null == response || !response.hasBody()) { | |||
log.info("泰州海陵区城管,接口返回为空,response为空"); | |||
log.info("泰州海陵区城管,接口返回为空, url:{}", url); | |||
log.info("泰州海陵区城管,接口返回为空, httpEntity:{}", httpEntity); | |||
log.info("泰州海陵区城管,接口返回为空, request:{}", request); | |||
throw new ServiceException("泰州海陵区城管,接口返回为空"); | |||
} | |||
if (response.getBody().getCode() != 200) { | |||
log.info("泰州海陵区城管,接口返回失败,response:{}", response.getBody()); | |||
log.info("泰州海陵区城管,接口返回失败, url:{}", url); | |||
log.info("泰州海陵区城管,接口返回失败, httpEntity:{}", httpEntity); | |||
log.info("泰州海陵区城管,接口返回失败, request:{}", request); | |||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "泰州海陵区城管,接口返回失败"); | |||
} | |||
return JSONObject.toJSONString(response.getBody().getData()); | |||
@@ -97,7 +97,7 @@ public class CallTianYiPlatformService { | |||
if (response.getBody().getCode() != 200) { | |||
log.info("泰州海陵区城管,接口返回失败,response:{}", response.getBody()); | |||
log.info("泰州海陵区城管,接口返回失败, url:{}", url); | |||
log.info("泰州海陵区城管,接口返回失败, httpEntity:{}", httpEntity); | |||
log.info("泰州海陵区城管,接口返回失败, request:{}", request); | |||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "泰州海陵区城管,接口返回失败"); | |||
} | |||
return JSONObject.toJSONString(response.getBody().getData()); |
@@ -13,6 +13,9 @@ import org.springframework.beans.factory.annotation.Qualifier; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.web.client.RestTemplate; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
@Slf4j | |||
@Service | |||
public class ShelterTaskService { | |||
@@ -24,29 +27,31 @@ public class ShelterTaskService { | |||
@Autowired | |||
private CallTianYiPlatformService callTianYiPlatformService; | |||
public TZHLShelterTaskResponse distributeTask(Inspection inspection, TZHLAirportLineResponse tzhlAirportLineResponse) { | |||
public Long distributeTask(Inspection inspection, TZHLAirportLineResponse tzhlAirportLineResponse) { | |||
String apiPath = TZHLConstant.TIAN_YI_API_SHELTER_TASKS; | |||
JSONObject jsonObject = this.buildJSONObject(inspection, tzhlAirportLineResponse); | |||
String dataJson = callTianYiPlatformService.callPost(apiPath, jsonObject); | |||
TZHLShelterTaskResponse shelterTaskResponse = JSON.parseObject(dataJson, TZHLShelterTaskResponse.class); | |||
return shelterTaskResponse; | |||
return Long.valueOf(dataJson); | |||
} | |||
private JSONObject buildJSONObject(Inspection inspection, TZHLAirportLineResponse tzhlAirportLineResponse) { | |||
JSONObject jsonObject = new JSONObject(); | |||
jsonObject.put("dockSn", inspection.getSn()); | |||
jsonObject.put("taskName", inspection.getName()); | |||
jsonObject.put("taskType", 0); // 任务类型(0:立即执行,1:定时任务,2:条件任务) | |||
jsonObject.put("isIntervene", 1); // 人为干预(0:false,1:true) | |||
jsonObject.put("outOfControlAction", 0); // 遥控器失控动作("0":"返航","1":"悬停","2":"降落") | |||
jsonObject.put("rthAltitude", 100); // 返航高度(单位:米) | |||
Integer flyLineVersion = tzhlAirportLineResponse.getFlyLineVersion(); | |||
String lineCodes = ""; | |||
String lineCodesTmp = ""; | |||
if (3 == flyLineVersion) { | |||
lineCodes = "v2_"; | |||
lineCodesTmp = "v2_"; | |||
} else if (4 == flyLineVersion) { | |||
lineCodes = "v3_"; | |||
lineCodesTmp = "v3_"; | |||
} | |||
jsonObject.put("lineCodes", lineCodes + inspection.getInspectionLine()); | |||
List<String> lineCodes = new ArrayList<>(); | |||
lineCodes.add(lineCodesTmp + inspection.getInspectionLine()); | |||
jsonObject.put("lineCodes", lineCodes); | |||
return jsonObject; | |||
} | |||
@@ -145,7 +145,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
<if test="channelName != null">channel_name = #{channelName},</if> | |||
<if test="legId != null and legId != ''">leg_id = #{legId},</if> | |||
<if test="legName != null">leg_name = #{legName},</if> | |||
<if test="recordId != null"> record_id = #{RecordId},</if> | |||
<if test="recordId != null"> record_id = #{recordId},</if> | |||
<if test="airportId != null">airport_id = #{airportId},</if> | |||
<if test="sn != null">sn = #{sn},</if> | |||
<if test="airportName != null">airport_name = #{airportName},</if> |
@@ -34,6 +34,13 @@ public class InspectionServiceTest { | |||
@Autowired | |||
private UpdateFlightStatusService updateFlightStatusService; | |||
@Test | |||
public void testExecute() { | |||
String id = "2f0ab151d48edac218a579bf6cab274a"; | |||
iInspectionService.execute(id); | |||
} | |||
@Test | |||
public void testPageList() { | |||
QueryInspectionPageListRequest request = new QueryInspectionPageListRequest(); |
@@ -32,4 +32,9 @@ public class TZHLGetAirportLineListServiceTest { | |||
System.out.println("data值为" + result.getData()); | |||
} | |||
@Test | |||
public void testGetAirportLineTest() { | |||
tzhlGetAirportLineListService.getAirportLineById(19L); | |||
} | |||
} |