瀏覽代碼

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

tags/v1.3.1
chengwang 1 年之前
父節點
當前提交
e773459613
共有 5 個文件被更改,包括 286 次插入16 次删除
  1. +11
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/execute/ExecuteTaskService.java
  2. +66
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogByErrorService.java
  3. +161
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogByNormalService.java
  4. +29
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogBySuccessService.java
  5. +19
    -13
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogService.java

+ 11
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/airport/execute/ExecuteTaskService.java 查看文件

@@ -7,6 +7,7 @@ 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.service.third.dsp.IDspService;
import com.tuoheng.admin.tzhl.config.TZHLConfig;
import com.tuoheng.admin.tzhl.constant.TZHLConstant;
import com.tuoheng.admin.tzhl.response.TZHLAirportLineResponse;
@@ -44,6 +45,9 @@ public class ExecuteTaskService {
@Autowired
private OnlineUavService onlineUavService;

@Autowired
private IDspService dspService;

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

@@ -61,13 +65,18 @@ public class ExecuteTaskService {

Long recordId = shelterTaskResponse.getRecord();

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

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());
}
}

this.updateInspection(userId, inspection, recordId);
@@ -83,7 +92,6 @@ public class ExecuteTaskService {
* @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);

+ 66
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogByErrorService.java 查看文件

@@ -0,0 +1,66 @@
package com.tuoheng.admin.tzhl.service.fly.log;

import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.InspectionHistory;
import com.tuoheng.admin.enums.InspectionStatusEnum;
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.common.core.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class FlyLogByErrorService {

@Autowired
private InspectionMapper inspectionMapper;

@Autowired
private InspectionHistoryMapper inspectionHistoryMapper;

@Autowired
private IDspService dspService;

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

this.updateInspection(inspection);

this.insertInspectionHistory(inspection, flyLogResponse.getTitle());

// 停止dsp分支
dspService.stopAI(inspection.getId());
}

/**
* 修改任务执行时数据
*
* @param inspection
*/
private void updateInspection(Inspection inspection) {
inspection.setStatus(inspection.getStatus());
inspection.setUpdateUser("");
inspection.setUpdateTime(DateUtils.now());
inspectionMapper.updateStatus(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);
}
}

+ 161
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogByNormalService.java 查看文件

@@ -0,0 +1,161 @@
package com.tuoheng.admin.tzhl.service.fly.log;

import cn.hutool.core.util.ObjectUtil;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.InspectionHistory;
import com.tuoheng.admin.enums.InspectionStatusEnum;
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.common.core.utils.DateUtils;
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 FlyLogByNormalService {

private final static String SUCCESS = "成功";
private final static String FAILED = "失败";

private final static String PREPARE_TASK = "下发航线任务"; // 1、下发航线任务+成功/失败(任务失败会给出错误码,需自行跟据大疆的上云api进行转译。下同)
private final static String EXECUTE_TASK = "执行航线任务"; // 2、执行航线任务+成功/失败
private final static String CANCEL_TASK = "取消航线任务"; // 3、取消航线任务+成功/失败
private final static String PAUSE_TASK = "暂停航线任务"; // 4、暂停航线任务+成功/失败
private final static String RECOVERY_TASK = "恢复航线任务"; // 5、恢复航线任务+成功/失败
private final static String FLY_COMPLETED = "超5分钟未收到飞行数据,平台主动汇总"; // 6、超5分钟未收到飞行数据,平台主动汇总(此时飞机已完成飞行并关机)
private final static String CLOUD_STORAGE_INSUFFICIENT = "云存储不足,飞行视频未保存"; // 7、云存储不足,飞行视频未保存
private final static String ONE_CLICK_TAKEOFF = "一键起飞"; // 8、一键起飞
private final static String POINT_FLY = "指点飞行"; // 9、指点飞行
private final static String POINT_FLY_CANCEL = "取消指点飞行"; // 10、取消指点飞行
private final static String RETURN_HOME = "一键返航"; // 11、一键返航
private final static String RETURN_HOME_CANCEL = "取消返航"; // 12、取消返航

@Autowired
private InspectionMapper inspectionMapper;

@Autowired
private InspectionHistoryMapper inspectionHistoryMapper;

@Autowired
private IDspService dspService;

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

if (ObjectUtil.isEmpty(flyLogResponse)) {
log.info("flyLogResponse:{}", flyLogResponse);
}
String title = flyLogResponse.getTitle();
if (StringUtils.isEmpty(title)) {
log.info("title为空");
}

if (title.contains(PREPARE_TASK)) {
// 下发任务
this.prepareTask(inspection, flyLogResponse);
} else if (title.contains(EXECUTE_TASK)) {
// 执行任务
this.executeTask(inspection, flyLogResponse);
} else if (title.contains(FLY_COMPLETED)) {
// 飞行完成
this.completedTask(inspection, flyLogResponse);
} else if (title.contains(CLOUD_STORAGE_INSUFFICIENT)) {
// TODO,产品确认该场景不做处理
}
}

/**
* 下发任务
* @param inspection
* @param flyLogResponse
*/
private void prepareTask(Inspection inspection, TZHLFlyLogResponse flyLogResponse) {
String title = flyLogResponse.getTitle().replace(PREPARE_TASK, "");
String status = title.substring(0, 2);
if (SUCCESS.equals(status)) {
inspection.setStatus(InspectionStatusEnum.IN_FLIGHT.getCode());

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

this.updateInspection(inspection);

String error = title.replace(status, "");
this.insertInspectionHistory(inspection, error);

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

/**
* 执行任务
* @param inspection
* @param flyLogResponse
*/
private void executeTask(Inspection inspection, TZHLFlyLogResponse flyLogResponse) {
String title = flyLogResponse.getTitle().replace(PREPARE_TASK, "");
String status = title.substring(0, 2);
if (SUCCESS.equals(status)) {
inspection.setStatus(InspectionStatusEnum.IN_FLIGHT.getCode());

this.updateInspection(inspection);

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

this.updateInspection(inspection);

String error = title.replace(status, "");
this.insertInspectionHistory(inspection, error);

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

/**
* 完成任务
* @param inspection
* @param flyLogResponse
*/
private void completedTask(Inspection inspection, TZHLFlyLogResponse flyLogResponse) {
// 任务完成
inspection.setStatus(InspectionStatusEnum.FLIGHT_COMPLETED.getCode());

this.updateInspection(inspection);

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

/**
* 修改任务执行时数据
*
* @param inspection
*/
private void updateInspection(Inspection inspection) {
inspection.setStatus(inspection.getStatus());
inspection.setUpdateUser("");
inspection.setUpdateTime(DateUtils.now());
inspectionMapper.updateStatus(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);
}

}

+ 29
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogBySuccessService.java 查看文件

@@ -0,0 +1,29 @@
package com.tuoheng.admin.tzhl.service.fly.log;

import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.enums.InspectionStatusEnum;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.tzhl.response.TZHLFlyLogResponse;
import com.tuoheng.common.core.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class FlyLogBySuccessService {

@Autowired
private InspectionMapper inspectionMapper;

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

}

+ 19
- 13
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogService.java 查看文件

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.tzhl.constant.TZHLConstant;
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.service.CallTianYiPlatformService;
@@ -22,33 +23,38 @@ import org.springframework.web.client.RestTemplate;
public class FlyLogService {

@Autowired
private RedisUtils redisUtils;
private CallTianYiPlatformService callTianYiPlatformService;

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

@Autowired
private CallTianYiPlatformService callTianYiPlatformService;
private FlyLogByErrorService flyLogByErrorService;

@Autowired
private FlyLogByNormalService flyLogByNormalService;

public void getFlyLog(Inspection inspection) {
String apiPath = TZHLConstant.TIAN_YI_API_FLIGHT_LOG;

TZHLFlyDataRequest request = new TZHLFlyDataRequest();
request.setRecordId(null);
request.setDeptId("");
TZHLFlyLogRequest request = new TZHLFlyLogRequest();
request.setRecordId(inspection.getRecordId());
request.setCreateTime(null);

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

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类型不匹配");
}
}



Loading…
取消
儲存