Browse Source

Merge branch 'develop' of http://192.168.11.14:51037/gitadmin/tuoheng_telecomumale into develop

tags/v1.3.1
chengwang 1 year ago
parent
commit
cb25b4dcfb
21 changed files with 293 additions and 97 deletions
  1. +3
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/execute/ExecuteInspectionService.java
  2. +30
    -24
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/execute/ExecuteTaskService.java
  3. +5
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/constant/TZHLConstant.java
  4. +16
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/response/TZHLFlyLogResponse.java
  5. +5
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/response/TZHLOnlineUavResponse.java
  6. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/response/TZHLTokenResponse.java
  7. +8
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/CallTianYiPlatformService.java
  8. +15
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/airport/TZHLGetAirportListService.java
  9. +14
    -8
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/data/FlyDataService.java
  10. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogByErrorService.java
  11. +16
    -12
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogByNormalService.java
  12. +34
    -5
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogBySuccessService.java
  13. +32
    -17
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogService.java
  14. +12
    -7
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/task/ShelterTaskService.java
  15. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/token/TZHLGetTokenService.java
  16. +7
    -13
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/task/FlyLogTask.java
  17. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/InspectionMapper.xml
  18. +21
    -0
      tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/service/InspectionServiceTest.java
  19. +32
    -0
      tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/tzhl/TZHLFlyDataServiceTest.java
  20. +33
    -0
      tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/tzhl/TZHLFlyLogServiceTest.java
  21. +5
    -0
      tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/tzhl/TZHLGetAirportLineListServiceTest.java

+ 3
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/execute/ExecuteInspectionService.java View File

@@ -53,8 +53,9 @@ public class ExecuteInspectionService {
*/
public JsonResult execute(String id) {
log.info("进入立即执行任务业务");
String userId = CurrentUserUtil.getUserId();
String tenantId = CurrentUserUtil.getTenantId();
User user = CurrentUserUtil.getUserInfo();
String userId = user.getId();
String tenantId = user.getTenantId();

JsonResult result = this.check(userId, tenantId, id);
if (0 != result.getCode()) {

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

@@ -3,8 +3,10 @@ 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.entity.InspectionHistory;
import com.tuoheng.admin.enums.InspectionStatusEnum;
import com.tuoheng.admin.enums.code.inspection.ExecuteInspectionCodeEnum;
import com.tuoheng.admin.mapper.InspectionHistoryMapper;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.mapper.TenantMapper;
import com.tuoheng.admin.service.third.dsp.IDspService;
@@ -37,16 +39,13 @@ public class ExecuteTaskService {
private InspectionMapper inspectionMapper;

@Autowired
private TZHLGetAirportLineListService tzhlGetAirportLineListService;
private InspectionHistoryMapper inspectionHistoryMapper;

@Autowired
private ShelterTaskService shelterTaskService;

@Autowired
private OnlineUavService onlineUavService;
private TZHLGetAirportLineListService tzhlGetAirportLineListService;

@Autowired
private IDspService dspService;
private ShelterTaskService shelterTaskService;

public JsonResult executeTask(String userId, Inspection inspection) {
log.info("进入泰州海陵区城管,执行任务,inspectionId={}", inspection.getId());
@@ -57,31 +56,23 @@ public class ExecuteTaskService {
return JsonResult.success("泰州海陵区城管,航线不存在");
}

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

Long recordId = shelterTaskResponse.getRecord();
inspection.setStatus(InspectionStatusEnum.FLIGHT_FAILED.getCode());
this.updateInspection(userId, inspection, recordId);

inspection.setStatus(InspectionStatusEnum.PREPARING.getCode());
this.insertInspectionHistory(inspection, "下发任务失败");

TZHLOnlineUavResponse tzhlOnlineUavResponse = onlineUavService.getOnlineUav();
if (ObjectUtil.isEmpty(tzhlOnlineUavResponse)) {
log.info("泰州海陵区城管,执行任务,获取推流地址失败");
} else {
// 通知DSP
JsonResult result = dspService.startAI(inspection, tzhlOnlineUavResponse.getPlayUrl(), tzhlOnlineUavResponse.getPlayUrl());
if (0 != result.getCode()) {
log.info("泰州海陵区城管,执行任务,通知DSP失败");
inspection.setStatus(InspectionStatusEnum.FLIGHT_FAILED.getCode());
}
return JsonResult.success("泰州海陵区城管,执行任务,下发任务失败");
}

inspection.setStatus(InspectionStatusEnum.PREPARING.getCode());
this.updateInspection(userId, inspection, recordId);

log.info("进入调用机场平台方法: 等待机场平台回调,修改执行任务状态");
log.info("任务下发成功,修改任务状态,status={}", inspection.getStatus());

return JsonResult.success();
}

@@ -99,4 +90,19 @@ public class ExecuteTaskService {
inspection.setRecordId(recordId);
inspectionMapper.update(inspection);
}

/**
* 更新任务失败记录
*
* @param inspection
*/
private void insertInspectionHistory(Inspection inspection, String msg) {
InspectionHistory inspectionHistory = new InspectionHistory();
inspectionHistory.setTenantId(inspection.getTenantId());
inspectionHistory.setInspectionId(inspection.getId());
inspectionHistory.setHistoryName(msg);
inspectionHistory.setCreateUser("");
inspectionHistory.setCreateTime(DateUtils.now());
inspectionHistoryMapper.insert(inspectionHistory);
}
}

+ 5
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/constant/TZHLConstant.java View File

@@ -20,6 +20,11 @@ public interface TZHLConstant {
*/
String HL_TOKEN_KEY = "HL_TOKEN";

/**
* reids:fly log key
*/
String HL_FLY_LOG = "HL_FLY_LOG_";

/**
* 天翼星云机场平台:票据登录
*/

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

@@ -37,4 +37,20 @@ public class TZHLFlyLogResponse {
*/
private String content;

private String searchValue;

private String createBy;

private String createTime;

private String createTimeFrom;

private String createTimeTo;

private String updateBy;

private String updateTime;

private String remark;

}

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

@@ -42,4 +42,9 @@ public class TZHLOnlineUavResponse {
*/
private String playUrl;

/**
* 推流地址
*/
private String pushUrl;

}

+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/response/TZHLTokenResponse.java View File

@@ -25,12 +25,12 @@ public class TZHLTokenResponse {
/**
* 部门ID
*/
private String deptId;
private Long deptId;

/**
* 无人机id
*/
private String uavId;
private Long uavId;

/**
* 访问token

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

@@ -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());
@@ -81,6 +81,10 @@ public class CallTianYiPlatformService {

String url = TZHLConfig.tzhlURL + apiPath;
ResponseEntity<JsonResult> response;

log.info("泰州海陵区城管,url:{}", url);
log.info("泰州海陵区城管,request:{}", request);

try {
response = restTemplate.exchange(url, HttpMethod.POST, httpEntity, JsonResult.class);
} catch (Exception e) {
@@ -97,7 +101,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());

+ 15
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/airport/TZHLGetAirportListService.java View File

@@ -45,5 +45,20 @@ public class TZHLGetAirportListService {
return JsonResult.success(getAirportListDtoList);
}

public GetAirportListDto getAirport(Long id){
Long[] idArr = new Long[ ]{id};
TZHLAirportLineListRequest request = new TZHLAirportLineListRequest();
request.setIds(Arrays.toString(idArr));

//读取全量机场平台列表
String url = TZHLConstant.TIAN_YI_API_AIRPORT_LIST ;

String data = callTianYiPlatformService.callGet(url, request);
List<GetAirportListDto> getAirportListDtoList = JSON.parseArray(data, GetAirportListDto.class);
if(ObjectUtil.isNull(getAirportListDtoList)){
log.info("查询机场列表数据为空");
return null;
}
return getAirportListDtoList.get(0);
}
}

+ 14
- 8
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/data/FlyDataService.java View File

@@ -5,13 +5,17 @@ import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tuoheng.admin.dto.GetAirportListDto;
import com.tuoheng.admin.entity.FlightDataHl;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.mapper.FlightDataHlMapper;
import com.tuoheng.admin.tzhl.constant.TZHLConstant;
import com.tuoheng.admin.tzhl.response.TZHLAirportFlightDataResponse;
import com.tuoheng.admin.tzhl.response.TZHLTokenResponse;
import com.tuoheng.admin.tzhl.service.CallTianYiPlatformService;
import com.tuoheng.admin.tzhl.service.airport.TZHLGetAirportListService;
import com.tuoheng.admin.tzhl.service.token.TZHLGetTokenService;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.JsonResult;
@@ -42,21 +46,18 @@ public class FlyDataService {
@Autowired
private CallTianYiPlatformService callTianYiPlatformService;

public void getFlyData(Inspection inspection) {
@Autowired
private TZHLGetAirportListService getAirportListService;

public void getFlyData(Inspection inspection) {
String apiPath = TZHLConstant.TIAN_YI_API_FLIGHT_DATA;
log.info("请求机场平台获取飞行数据url,apiPath={}",apiPath);

JSONObject jsonObject = this.jsonObjectRequest(inspection);
log.info("封装的请求参数信息,jsonObject:{}", jsonObject.toString());
String dataJson = callTianYiPlatformService.callPost(apiPath, jsonObject);

List<TZHLAirportFlightDataResponse> flightDataHlList = JSON.parseArray(dataJson, TZHLAirportFlightDataResponse.class);

//查询到的数据 入库
// 查询到的数据入库
this.addFlightDataHl(inspection,flightDataHlList);


}

/**
@@ -102,9 +103,14 @@ public class FlyDataService {
return null;
}
//根据任务获取对应的部门
String deptId = inspection.getDeptId();
Long recordId = inspection.getRecordId();

GetAirportListDto airportListDto = getAirportListService.getAirport(inspection.getAirportId());
Long deptId = 0L;
if (ObjectUtil.isNotEmpty(airportListDto)) {
deptId = airportListDto.getDeptId();
}

JSONObject jsonObject = new JSONObject();
jsonObject.put("recordId",recordId);
jsonObject.put("deptId",deptId);

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogByErrorService.java View File

@@ -50,7 +50,7 @@ public class FlyLogByErrorService {
}

/**
* 更新任务
* 更新任务失败记录
*
* @param inspection
*/

+ 16
- 12
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogByNormalService.java View File

@@ -8,6 +8,7 @@ import com.tuoheng.admin.mapper.InspectionHistoryMapper;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.service.third.dsp.IDspService;
import com.tuoheng.admin.tzhl.response.TZHLFlyLogResponse;
import com.tuoheng.admin.tzhl.service.fly.data.FlyDataService;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
@@ -43,8 +44,11 @@ public class FlyLogByNormalService {
@Autowired
private IDspService dspService;

@Autowired
private FlyDataService flyDataService;

public void getFlyLog(Inspection inspection, TZHLFlyLogResponse flyLogResponse) {
log.info("获取飞行日志,status=error,title={}", flyLogResponse.getTitle());
log.info("获取飞行日志,status=normal,title={}", flyLogResponse.getTitle());

if (ObjectUtil.isEmpty(flyLogResponse)) {
log.info("flyLogResponse:{}", flyLogResponse);
@@ -75,12 +79,11 @@ public class FlyLogByNormalService {
*/
private void prepareTask(Inspection inspection, TZHLFlyLogResponse flyLogResponse) {
String title = flyLogResponse.getTitle().replace(PREPARE_TASK, "");
if (ObjectUtil.isEmpty(title) && title.length() < 2) {
return;
}
String status = title.substring(0, 2);
if (SUCCESS.equals(status)) {
inspection.setStatus(InspectionStatusEnum.IN_FLIGHT.getCode());

this.updateInspection(inspection);
} else if (FAILED.equals(status)) {
if (FAILED.equals(status)) {
inspection.setStatus(InspectionStatusEnum.FLIGHT_FAILED.getCode());

this.updateInspection(inspection);
@@ -99,13 +102,11 @@ public class FlyLogByNormalService {
*/
private void executeTask(Inspection inspection, TZHLFlyLogResponse flyLogResponse) {
String title = flyLogResponse.getTitle().replace(PREPARE_TASK, "");
if (ObjectUtil.isEmpty(title) && title.length() < 2) {
return;
}
String status = title.substring(0, 2);
if (SUCCESS.equals(status)) {
inspection.setStatus(InspectionStatusEnum.IN_FLIGHT.getCode());

this.updateInspection(inspection);

} else if (FAILED.equals(status)) {
if (FAILED.equals(status)) {
inspection.setStatus(InspectionStatusEnum.FLIGHT_FAILED.getCode());

this.updateInspection(inspection);
@@ -128,6 +129,9 @@ public class FlyLogByNormalService {

this.updateInspection(inspection);

// 拉取飞行数据
flyDataService.getFlyData(inspection);

dspService.stopAI(inspection.getId());
}


+ 34
- 5
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogBySuccessService.java View File

@@ -1,10 +1,15 @@
package com.tuoheng.admin.tzhl.service.fly.log;

import cn.hutool.core.util.ObjectUtil;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.enums.InspectionStatusEnum;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.service.third.dsp.IDspService;
import com.tuoheng.admin.tzhl.response.TZHLFlyLogResponse;
import com.tuoheng.admin.tzhl.response.TZHLOnlineUavResponse;
import com.tuoheng.admin.tzhl.service.fly.onlineuav.OnlineUavService;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -16,13 +21,37 @@ public class FlyLogBySuccessService {
@Autowired
private InspectionMapper inspectionMapper;

@Autowired
private OnlineUavService onlineUavService;

@Autowired
private IDspService dspService;

public void getFlyLog(Inspection inspection, TZHLFlyLogResponse flyLogResponse) {
log.info("获取飞行日志,status=success,title={}", flyLogResponse.getTitle());
if ("已起飞".equals(flyLogResponse.getTitle())) {
inspection.setStatus(InspectionStatusEnum.IN_FLIGHT.getCode());
inspection.setUpdateUser("");
inspection.setUpdateTime(DateUtils.now());
inspectionMapper.updateStatus(inspection);
if (InspectionStatusEnum.IN_FLIGHT.getCode() == inspection.getStatus()) {
log.info("获取飞行日志,该任务状态已经改是飞行中,inspectionid={}", inspection.getId());
return;
}
log.info("获取飞行日志,status=success,title={}", flyLogResponse.getTitle());
inspection.setStatus(InspectionStatusEnum.IN_FLIGHT.getCode());
inspection.setUpdateUser("");
inspection.setUpdateTime(DateUtils.now());
inspectionMapper.updateStatus(inspection);

log.info("获取飞行日志,status=success,修改任务状态,status={}", inspection.getStatus());

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

// 通知DSP
JsonResult result = dspService.startAI(inspection, tzhlOnlineUavResponse.getPushUrl(), tzhlOnlineUavResponse.getPushUrl());
if (0 != result.getCode()) {
log.info("泰州海陵区城管,执行任务,通知DSP失败");
inspection.setStatus(InspectionStatusEnum.FLIGHT_FAILED.getCode());
}
}


+ 32
- 17
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogService.java View File

@@ -1,5 +1,6 @@
package com.tuoheng.admin.tzhl.service.fly.log;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.tzhl.constant.TZHLConstant;
@@ -7,6 +8,7 @@ import com.tuoheng.admin.tzhl.request.TZHLFlyDataRequest;
import com.tuoheng.admin.tzhl.request.TZHLFlyLogRequest;
import com.tuoheng.admin.tzhl.response.TZHLFlyDataResponse;
import com.tuoheng.admin.tzhl.response.TZHLFlyLogResponse;
import com.tuoheng.admin.tzhl.response.TZHLTokenResponse;
import com.tuoheng.admin.tzhl.service.CallTianYiPlatformService;
import com.tuoheng.common.core.utils.RedisUtils;
import lombok.extern.slf4j.Slf4j;
@@ -18,10 +20,15 @@ import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@Slf4j
@Service
public class FlyLogService {

@Autowired
private RedisUtils redisUtils;

@Autowired
private CallTianYiPlatformService callTianYiPlatformService;

@@ -38,24 +45,32 @@ public class FlyLogService {
String apiPath = TZHLConstant.TIAN_YI_API_FLIGHT_LOG;
TZHLFlyLogRequest request = new TZHLFlyLogRequest();
request.setRecordId(inspection.getRecordId());
request.setCreateTime(null);

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
String dataJson = callTianYiPlatformService.callGet(apiPath, null);

TZHLFlyLogResponse flyLogResponse = JSON.parseObject(dataJson, TZHLFlyLogResponse.class);
log.info("获取飞行日志,flyLogResponse={}", flyLogResponse);
if ("success".equals(flyLogResponse.getStatus())) {
flyLogBySuccessService.getFlyLog(inspection, flyLogResponse);
} else if ("success".equals(flyLogResponse.getStatus())) {
flyLogByErrorService.getFlyLog(inspection, flyLogResponse);
} else if ("success".equals(flyLogResponse.getStatus())) {
flyLogByNormalService.getFlyLog(inspection, flyLogResponse);
} else {
log.info("status类型不匹配");
TZHLFlyLogResponse flyLogResponseOld = (TZHLFlyLogResponse) redisUtils.get(TZHLConstant.HL_FLY_LOG + inspection.getId());
if (ObjectUtil.isNotEmpty(flyLogResponseOld)) {
String createTime = flyLogResponseOld.getCreateTime();
request.setCreateTime(createTime);
}
}
String dataJson = callTianYiPlatformService.callPost(apiPath, request);
List<TZHLFlyLogResponse> flyLogResponseList = JSON.parseArray(dataJson, TZHLFlyLogResponse.class);

if (ObjectUtil.isEmpty(flyLogResponseList)) {
log.info("获取飞行日志,flyLogResponseList为空");
return;
}

for (TZHLFlyLogResponse flyLogResponse : flyLogResponseList) {
log.info("获取飞行日志,flyLogResponse={}", flyLogResponse);
// redisUtils.set(TZHLConstant.HL_FLY_LOG + inspection.getId(), flyLogResponse);
if ("success".equals(flyLogResponse.getStatus())) {
flyLogBySuccessService.getFlyLog(inspection, flyLogResponse);
} else if ("normal".equals(flyLogResponse.getStatus())) {
flyLogByNormalService.getFlyLog(inspection, flyLogResponse);
} else if ("error".equals(flyLogResponse.getStatus())) {
// flyLogByErrorService.getFlyLog(inspection, flyLogResponse);
} else {
log.info("status类型不匹配");
}
}
}

}

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

@@ -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;
}


+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/token/TZHLGetTokenService.java View File

@@ -39,7 +39,7 @@ public class TZHLGetTokenService {
return tokenResponse.getToken();
}

private TZHLTokenResponse getTokenResponse() {
public TZHLTokenResponse getTokenResponse() {
TZHLGetTokenRequest request = new TZHLGetTokenRequest();
request.setTicket(TZHLConfig.tzhlTicket);
HttpHeaders headers = new HttpHeaders();

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

@@ -2,6 +2,7 @@ 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.InspectionFileStatusEnum;
import com.tuoheng.admin.enums.InspectionStatusEnum;
import com.tuoheng.admin.enums.InspectionTypeEnum;
import com.tuoheng.admin.enums.MarkEnum;
@@ -16,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

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

@@ -34,22 +36,14 @@ public class FlyLogTask {

@XxlJob("telecomumaleFlyLogTaskHandler")
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());
log.info("执行定时,获取飞行日志:" + LocalDateTime.now());
List<Integer> statusList = new ArrayList<>();
statusList.add(InspectionStatusEnum.PREPARING.getCode());
statusList.add(InspectionStatusEnum.IN_FLIGHT.getCode());
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.PREPARING.getCode()));
.in(Inspection::getStatus,statusList));
log.info("执行定时执行飞行任务:机场任务数" + inspectionList.size());
if (StringUtils.isEmpty(inspectionList)) {
return;

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

@@ -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>

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

@@ -11,6 +11,7 @@ import com.tuoheng.admin.request.inspection.MissionStatusRequest;
import com.tuoheng.admin.request.inspection.QueryInspectionPageListRequest;
import com.tuoheng.admin.service.inspection.IInspectionService;
import com.tuoheng.admin.service.inspection.update.status.UpdateFlightStatusService;
import com.tuoheng.admin.tzhl.service.fly.log.FlyLogService;
import com.tuoheng.common.core.utils.DateUtils;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
@@ -34,6 +35,26 @@ public class InspectionServiceTest {
@Autowired
private UpdateFlightStatusService updateFlightStatusService;

@Autowired
private FlyLogService flyLogService;

@Test
public void testExecute() {
String id = "da5da2c67dc152de5e43c7e7a104bfcf";
// iInspectionService.execute(id);
//
// try {
// Thread.sleep(1000 * 5);
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }

Inspection inspection = inspectionMapper.selectById(id);

flyLogService.getFlyLog(inspection);

}

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

+ 32
- 0
tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/tzhl/TZHLFlyDataServiceTest.java View File

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

import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.tzhl.service.fly.data.FlyDataService;
import com.tuoheng.admin.tzhl.service.fly.log.FlyLogService;
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 TZHLFlyDataServiceTest {

@Autowired
private InspectionMapper inspectionMapper;

@Autowired
private FlyDataService flyDataService;

@Test
public void testFlyLog() {
String id = "da5da2c67dc152de5e43c7e7a104bfcf";
Inspection inspection = inspectionMapper.selectById(id);
flyDataService.getFlyData(inspection);
}

}

+ 33
- 0
tuoheng-service/tuoheng-admin/src/test/java/com/tuoheng/admin/tzhl/TZHLFlyLogServiceTest.java View File

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

import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.tzhl.response.TZHLOnlineUavResponse;
import com.tuoheng.admin.tzhl.service.fly.log.FlyLogService;
import com.tuoheng.admin.tzhl.service.fly.onlineuav.OnlineUavService;
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 TZHLFlyLogServiceTest {

@Autowired
private InspectionMapper inspectionMapper;

@Autowired
private FlyLogService flyLogService;

@Test
public void testFlyLog() {
String id = "da5da2c67dc152de5e43c7e7a104bfcf";
Inspection inspection = inspectionMapper.selectById(id);
flyLogService.getFlyLog(inspection);
}

}

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

@@ -32,4 +32,9 @@ public class TZHLGetAirportLineListServiceTest {
System.out.println("data值为" + result.getData());
}

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

}

Loading…
Cancel
Save