Browse Source

1、机场id、航线id类型改为Long;2、任务新增recordId字段;3、修改任务执行代码;

tags/v1.3.1
wanjing 1 year ago
parent
commit
ddd74a0af0
24 changed files with 264 additions and 195 deletions
  1. +9
    -0
      tuoheng-service/tuoheng-admin/sql/sql_change_20230812.sql
  2. +7
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Inspection.java
  3. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/AccidentForwardRequest.java
  4. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/AddAccidentRequest.java
  5. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/add/AddAccidentService.java
  6. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/forward/CreateEmergencyInspection.java
  7. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryEmergencyListService.java
  8. +3
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/airportline/query/inspection/QueryAirportLineByAirportService.java
  9. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/update/status/UpdateWaittStatusService.java
  10. +1
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportServiceImpl.java
  11. +0
    -79
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/ExecuteTaskService.java
  12. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/drone/DroneContinueService.java
  13. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/drone/DroneService.java
  14. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/drone/DroneServiceImpl.java
  15. +90
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/execute/ExecuteTaskService.java
  16. +20
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/response/TZHLShelterTaskResponse.java
  17. +21
    -17
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/CallTianYiPlatformService.java
  18. +17
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/airportline/TZHLGetAirportLineListService.java
  19. +2
    -10
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/onlineuav/OnlineUavService.java
  20. +53
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/task/ShelterTaskService.java
  21. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/task/FlyLogTask.java
  22. +0
    -65
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/task/OnlineUavTask.java
  23. +4
    -7
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionMapper.xml
  24. +27
    -0
      tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/tzhl/TZHLOnlineUavServiceTest.java

+ 9
- 0
tuoheng-service/tuoheng-admin/sql/sql_change_20230812.sql View File

@@ -0,0 +1,9 @@
-- 20230812 10:37
-- v1.3.0

use tuoheng_telecomumale;

-- 任务表
-- 新增飞行记录id字段
alter table tuoheng_telecomumale.th_inspection add recor_id bigint default 0 not null comment '飞行记录id' after type;


+ 7
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/Inspection.java View File

@@ -78,10 +78,15 @@ public class Inspection extends BaseEntity {
*/
private Integer inspectionType;

/**
* 飞行记录id
*/
private Long recordId;

/**
* 巡检机场id
*/
private Integer airportId;
private Long airportId;

/**
* 巡检无人机id
@@ -96,7 +101,7 @@ public class Inspection extends BaseEntity {
/**
* 巡检线路id
*/
private Integer inspectionLine;
private Long inspectionLine;

/**
* 巡检线路名称

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/AccidentForwardRequest.java View File

@@ -25,7 +25,7 @@ public class AccidentForwardRequest {
/**
* 机场Id
*/
private Integer airportId;
private Long airportId;

/**
* 机场名称

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/request/accident/AddAccidentRequest.java View File

@@ -17,7 +17,7 @@ public class AddAccidentRequest {
/**
* 巡检机场id
*/
private Integer airportId;
private Long airportId;

///**
// * 巡检机场名称

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/add/AddAccidentService.java View File

@@ -248,7 +248,7 @@ public class AddAccidentService {
inspection.setInspectionType(InspectionTypeEnum.AIRPORT.getCode());
inspection.setAirportId(request.getAirportId());
inspection.setDroneId(request.getDroneId());
inspection.setInspectionLine(0);
inspection.setInspectionLine(0L);
inspection.setInspectionLineName("");
inspection.setExecutionStartTime(DateUtils.now());
inspection.setCreateUser(user.getId());

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/forward/CreateEmergencyInspection.java View File

@@ -32,7 +32,7 @@ public final class CreateEmergencyInspection {
inspection.setEmergencyDataInspectionId(request.getEmergencyDataInspectionId());
inspection.setStatus(inspectionStatus);
inspection.setInspectionType(InspectionTypeEnum.AIRPORT.getCode());
inspection.setInspectionLine(0);
inspection.setInspectionLine(0L);
inspection.setInspectionLineName("");
inspection.setExecutionStartTime(DateUtils.now());
inspection.setChannelId("");

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/accident/query/QueryEmergencyListService.java View File

@@ -91,7 +91,7 @@ public class QueryEmergencyListService {

StringBuilder ids = new StringBuilder();
String airportIds;
Set<Integer> set = new HashSet<>();
Set<Long> set = new HashSet<>();
for (Inspection inspection : inspectionList) {
if (set.add(inspection.getAirportId())) {
ids.append(inspection.getAirportId()).append(",");

+ 3
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/airportline/query/inspection/QueryAirportLineByAirportService.java View File

@@ -38,7 +38,7 @@ public class QueryAirportLineByAirportService {
*/
public JsonResult getAirportLineList(Inspection inspection) {
log.info("进入根据任务ID获取航线,从机场平台获取");
Integer inspectionLine = inspection.getInspectionLine();
Long inspectionLine = inspection.getInspectionLine();
JsonResult result = this.checkParam(inspectionLine);
if (0 != result.getCode()) {
log.info("根据任务ID获取航线:校验参数失败:{}", result.getMsg());
@@ -48,7 +48,7 @@ public class QueryAirportLineByAirportService {
return JsonResult.success(airPortLineLocationVoList);
}

private JsonResult checkParam(Integer inspectionLine) {
private JsonResult checkParam(Long inspectionLine) {
if (ObjectUtil.isEmpty(inspectionLine)) {
log.info("进入根据任务ID获取航线,从机场平台获取业务,航线ID为空,inspectionLine={}", inspectionLine);
throw new ServiceException("航线ID为空");
@@ -56,7 +56,7 @@ public class QueryAirportLineByAirportService {
return JsonResult.success();
}

private List<AirPortLineLocationVo> getAirPortLocation(Integer inspectionLine) {
private List<AirPortLineLocationVo> getAirPortLocation(Long inspectionLine) {
String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_LOCATION;
String param = "id=" + inspectionLine;
String airPortLineLocationStr = HttpUtils.sendGet(url, param);

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/update/status/UpdateWaittStatusService.java View File

@@ -103,7 +103,7 @@ public class UpdateWaittStatusService {
this.updateReport(inspection);
}

public JsonResult getWeather(String airportUrl, Integer airportId) {
public JsonResult getWeather(String airportUrl, Long airportId) {
String url = airportUrl + SystemConstant.API_AIRPORT_GET_WEATHER;
String param = "airportId=" + airportId;
String weatherStr = HttpUtils.sendGet(url, param);

+ 1
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/AirportServiceImpl.java View File

@@ -2,6 +2,7 @@ package com.tuoheng.admin.service.third.airport;

import com.tuoheng.admin.dto.ReversalFlightDto;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.service.third.airport.execute.ExecuteTaskService;
import com.tuoheng.common.core.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

+ 0
- 79
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/ExecuteTaskService.java View File

@@ -1,79 +0,0 @@
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.Inspection;
import com.tuoheng.admin.entity.Tenant;
import com.tuoheng.admin.enums.InspectionStatusEnum;
import com.tuoheng.admin.enums.code.inspection.ExecuteInspectionCodeEnum;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.mapper.TenantMapper;
import com.tuoheng.common.core.config.common.CommonConfig;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.HttpUtils;
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;

@Slf4j
@Service
public class ExecuteTaskService {

@Autowired
private TenantMapper tenantMapper;

@Autowired
private InspectionMapper inspectionMapper;

public JsonResult executeTask(String userId, Inspection inspection) {
log.info("进入调用机场平台方法,执行任务");
// 读取不同租户的机场平台url
Tenant tenant = tenantMapper.selectById(inspection.getTenantId());
if (ObjectUtil.isEmpty(tenant)) {
log.info("进入调用机场平台方法: 租户不存在");
return JsonResult.error(ExecuteInspectionCodeEnum.TENANT_IS_NOT_EXIST.getCode(), ExecuteInspectionCodeEnum.TENANT_IS_NOT_EXIST.getMsg());
}

String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_EXECUTE_TASK;
JSONObject jsonObject = new JSONObject();
jsonObject.put("taskId", inspection.getInspectionLine());
jsonObject.put("requestId", inspection.getId());
jsonObject.put("requestName", inspection.getName());
jsonObject.put("code", SystemConstant.PLATFORM_CODE); // 与机场平台约定好的
jsonObject.put("tenantCode", tenant.getCode());

log.info("进入调用机场平台方法: url:{}", url);
log.info("进入调用机场平台方法: jsonObject:{}", jsonObject);

String airPortStr = HttpUtils.doSend(url, jsonObject, null, "POST");
if (StringUtils.isEmpty(airPortStr)) {
log.info("立即执行任务业务:机场接口返回数据为空,飞行失败,任务id:{},任务名称:{},机场id:{},机场名称:{}, 路线id:{},路线名称:{}",
inspection.getId(), inspection.getName(), inspection.getAirportId(), inspection.getAirportName(), inspection.getInspectionLine(), inspection.getInspectionLineName());
return JsonResult.error(ExecuteInspectionCodeEnum.AIRPORT_RETURN_DATA_IS_NULL.getCode(), ExecuteInspectionCodeEnum.AIRPORT_RETURN_DATA_IS_NULL.getMsg());
}

// 修改任务执行状态,防止手动执行和定时重复
this.updateInspectionExecutionStatus(userId, inspection);

log.info("进入调用机场平台方法: 等待机场平台回调,修改执行任务状态");
return JsonResult.success();
}

/**
* 修改任务执行状态
*
* @param userId
* @param inspection
*/
private void updateInspectionExecutionStatus(String userId, Inspection inspection) {
inspection.setStatus(InspectionStatusEnum.PREPARING.getCode());
inspection.setExecutionStatus(2);
inspection.setStatus(inspection.getStatus());
inspection.setUpdateUser(userId);
inspection.setUpdateTime(DateUtils.now());
inspectionMapper.update(inspection);
}
}

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/drone/DroneContinueService.java View File

@@ -21,7 +21,7 @@ public class DroneContinueService {
* @param airportId 机场Id
* @param inspectionId 巡检任务Id
*/
public JsonResult continuee(Integer airportId, String inspectionId) {
public JsonResult continuee(Long airportId, String inspectionId) {
String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_DRONE_CONTROL;
JSONObject jsonObject = new JSONObject();
jsonObject.put("zhilin", "04");

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/drone/DroneService.java View File

@@ -7,7 +7,7 @@ public interface DroneService {
/**
* 无人机继续飞行
*/
JsonResult continuee(Integer airportId, String inspectionId);
JsonResult continuee(Long airportId, String inspectionId);


}

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/drone/DroneServiceImpl.java View File

@@ -13,7 +13,7 @@ public class DroneServiceImpl implements DroneService {
private DroneContinueService droneContinueService;

@Override
public JsonResult continuee(Integer airportId, String inspectionId) {
public JsonResult continuee(Long airportId, String inspectionId) {
return droneContinueService.continuee(airportId, inspectionId);
}
}

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

@@ -0,0 +1,90 @@
package com.tuoheng.admin.service.third.airport.execute;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.enums.InspectionStatusEnum;
import com.tuoheng.admin.enums.code.inspection.ExecuteInspectionCodeEnum;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.mapper.TenantMapper;
import com.tuoheng.admin.tzhl.config.TZHLConfig;
import com.tuoheng.admin.tzhl.constant.TZHLConstant;
import com.tuoheng.admin.tzhl.response.TZHLAirportLineResponse;
import com.tuoheng.admin.tzhl.response.TZHLOnlineUavResponse;
import com.tuoheng.admin.tzhl.response.TZHLShelterTaskResponse;
import com.tuoheng.admin.tzhl.service.airportline.TZHLGetAirportLineListService;
import com.tuoheng.admin.tzhl.service.fly.onlineuav.OnlineUavService;
import com.tuoheng.admin.tzhl.service.task.ShelterTaskService;
import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.HttpUtils;
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.http.HttpStatus;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class ExecuteTaskService {

@Autowired
private TenantMapper tenantMapper;

@Autowired
private InspectionMapper inspectionMapper;

@Autowired
private TZHLGetAirportLineListService tzhlGetAirportLineListService;

@Autowired
private ShelterTaskService shelterTaskService;

@Autowired
private OnlineUavService onlineUavService;

public JsonResult executeTask(String userId, Inspection inspection) {
log.info("进入泰州海陵区城管,执行任务,inspectionId={}", inspection.getId());

TZHLAirportLineResponse tzhlAirportLineResponse = tzhlGetAirportLineListService.getAirportLineById(inspection.getInspectionLine());
if (ObjectUtil.isEmpty(tzhlAirportLineResponse)) {
log.info("泰州海陵区城管,执行任务,航线不存在,airportLineId:{}", tzhlAirportLineResponse.getId());
return JsonResult.success("泰州海陵区城管,航线不存在");
}

TZHLShelterTaskResponse shelterTaskResponse = shelterTaskService.distributeTask(inspection, tzhlAirportLineResponse);
if (ObjectUtil.isEmpty(shelterTaskResponse)) {
log.info("泰州海陵区城管,执行任务,下发任务失败");
return JsonResult.success("泰州海陵区城管,执行任务,下发任务失败");
}

Long recordId = shelterTaskResponse.getRecord();

TZHLOnlineUavResponse tzhlOnlineUavResponse = onlineUavService.getOnlineUav();
if (ObjectUtil.isEmpty(tzhlOnlineUavResponse)) {
log.info("泰州海陵区城管,执行任务,获取推流地址失败");
}

this.updateInspection(userId, inspection, recordId);

log.info("进入调用机场平台方法: 等待机场平台回调,修改执行任务状态");
return JsonResult.success();
}

/**
* 修改任务执行
*
* @param userId
* @param inspection
*/
private void updateInspection(String userId, Inspection inspection, Long recordId) {
inspection.setStatus(InspectionStatusEnum.PREPARING.getCode());
inspection.setExecutionStatus(2); // 修改任务执行状态,防止手动执行和定时重复
inspection.setStatus(inspection.getStatus());
inspection.setUpdateUser(userId);
inspection.setUpdateTime(DateUtils.now());
inspection.setRecordId(recordId);
inspectionMapper.update(inspection);
}
}

+ 20
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/response/TZHLShelterTaskResponse.java View File

@@ -0,0 +1,20 @@
package com.tuoheng.admin.tzhl.response;

import lombok.Data;

/**
* 下发任务返回参数
*
* @author wanjing
* @team tuoheng
* @date 2023-08-11
*/
@Data
public class TZHLShelterTaskResponse {

/**
* 飞行记录id
*/
private Long record;

}

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

@@ -6,7 +6,6 @@ import com.tuoheng.admin.tzhl.config.TZHLConfig;
import com.tuoheng.admin.tzhl.constant.TZHLConstant;
import com.tuoheng.admin.tzhl.request.TZHLGetTokenRequest;
import com.tuoheng.admin.tzhl.response.TZHLTokenResponse;
import com.tuoheng.admin.tzhl.service.token.TZHLGetTokenService;
import com.tuoheng.common.core.config.common.CommonConfig;
import com.tuoheng.common.core.exception.ServiceException;
import com.tuoheng.common.core.utils.JsonResult;
@@ -20,9 +19,6 @@ import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;

import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class CallTianYiPlatformService {
@@ -51,21 +47,23 @@ public class CallTianYiPlatformService {
try {
response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, JsonResult.class);
} catch (RestClientException e) {
log.info("请求获取机场url:{}", url);
log.info("请求获取机场列表, httpEntity:{}", httpEntity);
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "token不能为空");
log.info("泰州海陵区城管,接口异常, url:{}", url);
log.info("泰州海陵区城管,接口异常, httpEntity:{}", httpEntity);
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "泰州海陵区城管,接口异常");
}

if (null == response || !response.hasBody()) {
log.error("请求获取机场,response为空");
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "token不能为空");
log.info("泰州海陵区城管,接口返回为空,response为空");
log.info("泰州海陵区城管,接口返回为空, url:{}", url);
log.info("泰州海陵区城管,接口返回为空, httpEntity:{}", httpEntity);
throw new ServiceException("泰州海陵区城管,接口返回为空");
}
if (response.getBody().getCode() != 200) {
log.error("请求获取机场列表" + response.getBody());
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "token不能为空");
log.info("泰州海陵区城管,接口返回失败,response:{}", response.getBody());
log.info("泰州海陵区城管,接口返回失败, url:{}", url);
log.info("泰州海陵区城管,接口返回失败, httpEntity:{}", httpEntity);
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "泰州海陵区城管,接口返回失败");
}
log.info("查询机场列表数据成功,response={}", response);

return JSONObject.toJSONString(response.getBody().getData());
}

@@ -91,10 +89,16 @@ public class CallTianYiPlatformService {
throw new ServiceException("泰州海陵区城管,获取token接口异常");
}
if (null == response || !response.hasBody()) {
log.info("泰州海陵区城管,接口失败,response为空");
log.info("泰州海陵区城管,接口失败, url:{}", url);
log.info("泰州海陵区城管,接口失败, httpEntity:{}", httpEntity);
throw new ServiceException("南京海事局,接口失败");
log.info("泰州海陵区城管,接口返回为空,response为空");
log.info("泰州海陵区城管,接口返回为空, url:{}", url);
log.info("泰州海陵区城管,接口返回为空, httpEntity:{}", httpEntity);
throw new ServiceException("泰州海陵区城管,接口返回为空");
}
if (response.getBody().getCode() != 200) {
log.info("泰州海陵区城管,接口返回失败,response:{}", response.getBody());
log.info("泰州海陵区城管,接口返回失败, url:{}", url);
log.info("泰州海陵区城管,接口返回失败, httpEntity:{}", httpEntity);
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "泰州海陵区城管,接口返回失败");
}
return JSONObject.toJSONString(response.getBody().getData());
}

+ 17
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/airportline/TZHLGetAirportLineListService.java View File

@@ -24,7 +24,7 @@ public class TZHLGetAirportLineListService {
@Autowired
private CallTianYiPlatformService callTianYiPlatformService;

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();
request.setName(name);
request.setSn(sn);
@@ -36,10 +36,25 @@ public class TZHLGetAirportLineListService {

String data = callTianYiPlatformService.callPost(url, request);

List<TZHLAirportLineResponse> tzhlAirportLineResponses = JSON.parseArray(data,TZHLAirportLineResponse.class);
List<TZHLAirportLineResponse> tzhlAirportLineResponses = JSON.parseArray(data, TZHLAirportLineResponse.class);


return JsonResult.success(tzhlAirportLineResponses);
}

public TZHLAirportLineResponse getAirportLineById(Long id) {
TZHLGetAirportLineListRequest request = new TZHLGetAirportLineListRequest();
request.setId(id);
//获取航线列表
String url = TZHLConstant.TIAN_YI_API_FLY_LINE_LIST;
String data = callTianYiPlatformService.callPost(url, request);
List<TZHLAirportLineResponse> tzhlAirportLineResponseList = JSON.parseArray(data, TZHLAirportLineResponse.class);
for (TZHLAirportLineResponse tzhlAirportLineResponse : tzhlAirportLineResponseList) {
if (id.equals(tzhlAirportLineResponse.getId())) {
return tzhlAirportLineResponse;
}
}
return null;
}

}

+ 2
- 10
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/onlineuav/OnlineUavService.java View File

@@ -31,19 +31,11 @@ public class OnlineUavService {
@Autowired
private CallTianYiPlatformService callTianYiPlatformService;

public void getOnlineUav(Inspection inspection) {
public TZHLOnlineUavResponse getOnlineUav() {
String apiPath = TZHLConstant.TIAN_YI_API_FLIGHT_SCREEN;

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity httpEntity = new HttpEntity(null, headers);

String dataJson = callTianYiPlatformService.callGet(apiPath, null);

TZHLOnlineUavResponse onlineUavResponse = JSON.parseObject(dataJson, TZHLOnlineUavResponse.class);



return onlineUavResponse;
}



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

@@ -0,0 +1,53 @@
package com.tuoheng.admin.tzhl.service.task;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.tzhl.constant.TZHLConstant;
import com.tuoheng.admin.tzhl.response.TZHLAirportLineResponse;
import com.tuoheng.admin.tzhl.response.TZHLShelterTaskResponse;
import com.tuoheng.admin.tzhl.service.CallTianYiPlatformService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Slf4j
@Service
public class ShelterTaskService {

@Autowired
@Qualifier("restTemplate")
private RestTemplate restTemplate;

@Autowired
private CallTianYiPlatformService callTianYiPlatformService;

public TZHLShelterTaskResponse 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;
}

private JSONObject buildJSONObject(Inspection inspection, TZHLAirportLineResponse tzhlAirportLineResponse) {
JSONObject jsonObject = new JSONObject();
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 = "";
if (3 == flyLineVersion) {
lineCodes = "v2_";
} else if (4 == flyLineVersion) {
lineCodes = "v3_";
}
jsonObject.put("lineCodes", lineCodes + inspection.getInspectionLine());
return jsonObject;
}

}

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/task/FlyLogTask.java View File

@@ -49,7 +49,7 @@ public class FlyLogTask {
//查询未执行任务
.eq(Inspection::getExecutionStatus, 1)
//任务待飞行
.eq(Inspection::getStatus, InspectionStatusEnum.WAIT_FLIGHT.getCode()));
.eq(Inspection::getStatus, InspectionStatusEnum.PREPARING.getCode()));
log.info("执行定时执行飞行任务:机场任务数" + inspectionList.size());
if (StringUtils.isEmpty(inspectionList)) {
return;

+ 0
- 65
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/task/OnlineUavTask.java View File

@@ -1,65 +0,0 @@
package com.tuoheng.admin.tzhl.task;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.enums.InspectionStatusEnum;
import com.tuoheng.admin.enums.InspectionTypeEnum;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.service.third.airport.AirportService;
import com.tuoheng.admin.tzhl.service.fly.onlineuav.OnlineUavService;
import com.tuoheng.common.core.utils.StringUtils;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
* 定时扫描,然后飞行
*/
@Component
@Slf4j
public class OnlineUavTask {

@Autowired
private InspectionMapper inspectionMapper;

@Autowired
private OnlineUavService onlineUavService;

@XxlJob("telecomumaleOnlineUavTaskHandler")
public void airportTaskHandler() {
// 查询当前时间正负1分钟的时间跨度,xxljob执行频率为1分钟1次
long start = new Date().getTime() - 1 * 60000L;
long end = new Date().getTime() + 1 * 60000L;
Date startTime = new Date(start);
Date endTime = new Date(end);

log.info("执行定时执行飞行任务:" + LocalDateTime.now());
List<Inspection> inspectionList = inspectionMapper.selectList(new LambdaQueryWrapper<Inspection>()
.eq(Inspection::getMark, MarkEnum.VALID.getCode())
.between(Inspection::getInspectionTime, startTime, endTime)
//查询巡检方式为机场的任务
.eq(Inspection::getInspectionType, InspectionTypeEnum.AIRPORT.getCode())
//查询未执行任务
.eq(Inspection::getExecutionStatus, 1)
//任务待飞行
.eq(Inspection::getStatus, InspectionStatusEnum.WAIT_FLIGHT.getCode()));
log.info("执行定时执行飞行任务:机场任务数" + inspectionList.size());
if (StringUtils.isEmpty(inspectionList)) {
return;
}
for (Inspection inspection : inspectionList) {
log.info("执行定时,获取飞行画面: inspectionId:{}", inspection.getId());

onlineUavService.getOnlineUav(inspection);

log.info("执行定时,获取飞行画面: inspectionId:{}");
}
}

}

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

@@ -16,6 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="legId" column="leg_id" />
<result property="legName" column="leg_name" />
<result property="inspectionType" column="inspection_type" />
<result property="recordId" column="record_id" />
<result property="airportId" column="airport_id" />
<result property="airportName" column="airport_name" />
<result property="droneId" column="drone_id" />
@@ -66,7 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"

<sql id="Base_Column_list">
id, tenant_id, dept_id, code, name, type, channel_id, channel_name, leg_id, leg_name, inspection_type,
airport_id, airport_name, drone_id, inspection_line, inspection_line_name, equipment_id, equipment_name, equipment_mount_id,
record_id, airport_id, airport_name, drone_id, inspection_line, inspection_line_name, equipment_id, equipment_name, equipment_mount_id,
equipment_mount_name, cloud_box_id, cloud_box_name, box_sn, flight_hand, flight_hand_name, inspection_time,
execution_start_time, execution_end_time, is_live, is_taken, is_tilt, video_url, ai_video_url, report_url, srt_url,
status, analyse_status, progressbar, note, weather, fly_height, srt_name, heartbeat_time, execution_status,
@@ -76,7 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"

<sql id="selectInspectionVo">
select id, tenant_id, dept_id, code, name, type, channel_id, channel_name, leg_id, leg_name, inspection_type,
airport_id, airport_name, drone_id, inspection_line, inspection_line_name, equipment_id, equipment_name, equipment_mount_id,
record_id, airport_id, airport_name, drone_id, inspection_line, inspection_line_name, equipment_id, equipment_name, equipment_mount_id,
equipment_mount_name, cloud_box_id, cloud_box_name, box_sn, flight_hand, flight_hand_name, inspection_time,
execution_start_time, execution_end_time, is_live, is_taken, is_tilt, video_url, ai_video_url, report_url, srt_url,
status, analyse_status, progressbar, note, weather, fly_height, srt_name, heartbeat_time, execution_status,
@@ -136,8 +137,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="update" parameterType="com.tuoheng.admin.entity.Inspection">
update th_inspection
<trim prefix="SET" suffixOverrides=",">
<if test="tenantId != null and tenantId != ''">tenant_id = #{tenantId},</if>
<if test="deptId != null and deptId != ''">dept_id = #{deptId},</if>
<if test="code != null">code = #{code},</if>
<if test="name != null">name = #{name},</if>
<if test="type != null">type = #{type},</if>
@@ -145,7 +144,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="inspectionType != null">inspection_type = #{inspectionType},</if>
<if test="recordId != null"> record_id = #{RecordId},</if>
<if test="airportId != null">airport_id = #{airportId},</if>
<if test="airportName != null">airport_name = #{airportName},</if>
<if test="droneId != null"> drone_id = #{droneId},</if>
@@ -185,8 +184,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="endLatitude != null">end_latitude = #{endLatitude},</if>
<if test="mobile != null">mobile = #{mobile},</if>
<if test="patrolLocation != null">patrol_location = #{patrolLocation},</if>
<if test="createUser != null">create_user = #{createUser},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateUser != null">update_user = #{updateUser},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="mark != null">mark = #{mark},</if>

+ 27
- 0
tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/tzhl/TZHLOnlineUavServiceTest.java View File

@@ -0,0 +1,27 @@
package com.tuoheng.admin.tzhl;

import com.tuoheng.admin.tzhl.response.TZHLOnlineUavResponse;
import com.tuoheng.admin.tzhl.service.fly.onlineuav.OnlineUavService;
import com.tuoheng.admin.tzhl.service.token.TZHLGetTokenService;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class TZHLOnlineUavServiceTest {

@Autowired
private OnlineUavService onlineUavService;

@Test
public void testGetToken() {
TZHLOnlineUavResponse response = onlineUavService.getOnlineUav();
System.out.println("response = " + response);
}

}

Loading…
Cancel
Save