Browse Source

Merge branch 'develop' of gitadmin/tuoheng_telecomumale into release

tags/v1.3.1
wanjing 1 year ago
parent
commit
18eb64e010
6 changed files with 31 additions and 16 deletions
  1. +2
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/execute/ExecuteTaskService.java
  2. +4
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/CallTianYiPlatformService.java
  3. +12
    -7
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/task/ShelterTaskService.java
  4. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionMapper.xml
  5. +7
    -0
      tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/service/InspectionServiceTest.java
  6. +5
    -0
      tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/tzhl/TZHLGetAirportLineListServiceTest.java

+ 2
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/execute/ExecuteTaskService.java View File

return JsonResult.success("泰州海陵区城管,航线不存在"); 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("泰州海陵区城管,执行任务,下发任务失败"); log.info("泰州海陵区城管,执行任务,下发任务失败");
return JsonResult.success("泰州海陵区城管,执行任务,下发任务失败"); return JsonResult.success("泰州海陵区城管,执行任务,下发任务失败");
} }


Long recordId = shelterTaskResponse.getRecord();

inspection.setStatus(InspectionStatusEnum.PREPARING.getCode()); inspection.setStatus(InspectionStatusEnum.PREPARING.getCode());


TZHLOnlineUavResponse tzhlOnlineUavResponse = onlineUavService.getOnlineUav(); TZHLOnlineUavResponse tzhlOnlineUavResponse = onlineUavService.getOnlineUav();

+ 4
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/CallTianYiPlatformService.java View File

response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, JsonResult.class); response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, JsonResult.class);
} catch (RestClientException e) { } catch (RestClientException e) {
log.info("泰州海陵区城管,接口异常, url:{}", url); log.info("泰州海陵区城管,接口异常, url:{}", url);
log.info("泰州海陵区城管,接口异常, httpEntity:{}", httpEntity);
log.info("泰州海陵区城管,接口异常, request:{}", request);
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "泰州海陵区城管,接口异常"); throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "泰州海陵区城管,接口异常");
} }


if (null == response || !response.hasBody()) { if (null == response || !response.hasBody()) {
log.info("泰州海陵区城管,接口返回为空,response为空"); log.info("泰州海陵区城管,接口返回为空,response为空");
log.info("泰州海陵区城管,接口返回为空, url:{}", url); log.info("泰州海陵区城管,接口返回为空, url:{}", url);
log.info("泰州海陵区城管,接口返回为空, httpEntity:{}", httpEntity);
log.info("泰州海陵区城管,接口返回为空, request:{}", request);
throw new ServiceException("泰州海陵区城管,接口返回为空"); throw new ServiceException("泰州海陵区城管,接口返回为空");
} }
if (response.getBody().getCode() != 200) { if (response.getBody().getCode() != 200) {
log.info("泰州海陵区城管,接口返回失败,response:{}", response.getBody()); log.info("泰州海陵区城管,接口返回失败,response:{}", response.getBody());
log.info("泰州海陵区城管,接口返回失败, url:{}", url); log.info("泰州海陵区城管,接口返回失败, url:{}", url);
log.info("泰州海陵区城管,接口返回失败, httpEntity:{}", httpEntity);
log.info("泰州海陵区城管,接口返回失败, request:{}", request);
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "泰州海陵区城管,接口返回失败"); throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "泰州海陵区城管,接口返回失败");
} }
return JSONObject.toJSONString(response.getBody().getData()); return JSONObject.toJSONString(response.getBody().getData());
if (response.getBody().getCode() != 200) { if (response.getBody().getCode() != 200) {
log.info("泰州海陵区城管,接口返回失败,response:{}", response.getBody()); log.info("泰州海陵区城管,接口返回失败,response:{}", response.getBody());
log.info("泰州海陵区城管,接口返回失败, url:{}", url); log.info("泰州海陵区城管,接口返回失败, url:{}", url);
log.info("泰州海陵区城管,接口返回失败, httpEntity:{}", httpEntity);
log.info("泰州海陵区城管,接口返回失败, request:{}", request);
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "泰州海陵区城管,接口返回失败"); throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "泰州海陵区城管,接口返回失败");
} }
return JSONObject.toJSONString(response.getBody().getData()); return JSONObject.toJSONString(response.getBody().getData());

+ 12
- 7
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/task/ShelterTaskService.java View File

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.ArrayList;
import java.util.List;

@Slf4j @Slf4j
@Service @Service
public class ShelterTaskService { public class ShelterTaskService {
@Autowired @Autowired
private CallTianYiPlatformService callTianYiPlatformService; 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; String apiPath = TZHLConstant.TIAN_YI_API_SHELTER_TASKS;
JSONObject jsonObject = this.buildJSONObject(inspection, tzhlAirportLineResponse); JSONObject jsonObject = this.buildJSONObject(inspection, tzhlAirportLineResponse);
String dataJson = callTianYiPlatformService.callPost(apiPath, jsonObject); 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) { private JSONObject buildJSONObject(Inspection inspection, TZHLAirportLineResponse tzhlAirportLineResponse) {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("dockSn", inspection.getSn());
jsonObject.put("taskName", inspection.getName()); jsonObject.put("taskName", inspection.getName());
jsonObject.put("taskType", 0); // 任务类型(0:立即执行,1:定时任务,2:条件任务) jsonObject.put("taskType", 0); // 任务类型(0:立即执行,1:定时任务,2:条件任务)
jsonObject.put("isIntervene", 1); // 人为干预(0:false,1:true) jsonObject.put("isIntervene", 1); // 人为干预(0:false,1:true)
jsonObject.put("outOfControlAction", 0); // 遥控器失控动作("0":"返航","1":"悬停","2":"降落") jsonObject.put("outOfControlAction", 0); // 遥控器失控动作("0":"返航","1":"悬停","2":"降落")
jsonObject.put("rthAltitude", 100); // 返航高度(单位:米) jsonObject.put("rthAltitude", 100); // 返航高度(单位:米)
Integer flyLineVersion = tzhlAirportLineResponse.getFlyLineVersion(); Integer flyLineVersion = tzhlAirportLineResponse.getFlyLineVersion();
String lineCodes = "";
String lineCodesTmp = "";
if (3 == flyLineVersion) { if (3 == flyLineVersion) {
lineCodes = "v2_";
lineCodesTmp = "v2_";
} else if (4 == flyLineVersion) { } 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; return jsonObject;
} }



+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionMapper.xml View File

<if test="channelName != null">channel_name = #{channelName},</if> <if test="channelName != null">channel_name = #{channelName},</if>
<if test="legId != null and legId != ''">leg_id = #{legId},</if> <if test="legId != null and legId != ''">leg_id = #{legId},</if>
<if test="legName != null">leg_name = #{legName},</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="airportId != null">airport_id = #{airportId},</if>
<if test="sn != null">sn = #{sn},</if> <if test="sn != null">sn = #{sn},</if>
<if test="airportName != null">airport_name = #{airportName},</if> <if test="airportName != null">airport_name = #{airportName},</if>

+ 7
- 0
tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/service/InspectionServiceTest.java View File

@Autowired @Autowired
private UpdateFlightStatusService updateFlightStatusService; private UpdateFlightStatusService updateFlightStatusService;



@Test
public void testExecute() {
String id = "2f0ab151d48edac218a579bf6cab274a";
iInspectionService.execute(id);
}

@Test @Test
public void testPageList() { public void testPageList() {
QueryInspectionPageListRequest request = new QueryInspectionPageListRequest(); QueryInspectionPageListRequest request = new QueryInspectionPageListRequest();

+ 5
- 0
tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/tzhl/TZHLGetAirportLineListServiceTest.java View File

System.out.println("data值为" + result.getData()); System.out.println("data值为" + result.getData());
} }


@Test
public void testGetAirportLineTest() {
tzhlGetAirportLineListService.getAirportLineById(19L);
}

} }

Loading…
Cancel
Save