Przeglądaj źródła

修改获取飞行日志代码

tags/v1.3.1
wanjing 1 rok temu
rodzic
commit
e8212db626
5 zmienionych plików z 49 dodań i 22 usunięć
  1. +5
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/constant/TZHLConstant.java
  2. +16
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/response/TZHLFlyLogResponse.java
  3. +7
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogByNormalService.java
  4. +14
    -9
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogService.java
  5. +7
    -13
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/task/FlyLogTask.java

+ 5
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/constant/TZHLConstant.java Wyświetl plik

@@ -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 Wyświetl plik

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

}

+ 7
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogByNormalService.java Wyświetl plik

@@ -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,6 +44,9 @@ 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());

@@ -128,6 +132,9 @@ public class FlyLogByNormalService {

this.updateInspection(inspection);

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

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


+ 14
- 9
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogService.java Wyświetl plik

@@ -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;
@@ -22,6 +24,9 @@ import org.springframework.web.client.RestTemplate;
@Service
public class FlyLogService {

@Autowired
private RedisUtils redisUtils;

@Autowired
private CallTianYiPlatformService callTianYiPlatformService;

@@ -38,24 +43,24 @@ 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 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);
TZHLFlyLogResponse flyLogResponse = JSON.parseObject(dataJson, TZHLFlyLogResponse.class);
redisUtils.set(TZHLConstant.HL_FLY_LOG + inspection.getId(), flyLogResponse);
log.info("获取飞行日志,flyLogResponse={}", flyLogResponse);
if ("success".equals(flyLogResponse.getStatus())) {
flyLogBySuccessService.getFlyLog(inspection, flyLogResponse);
} else if ("success".equals(flyLogResponse.getStatus())) {
} else if ("error".equals(flyLogResponse.getStatus())) {
flyLogByErrorService.getFlyLog(inspection, flyLogResponse);
} else if ("success".equals(flyLogResponse.getStatus())) {
} else if ("normal".equals(flyLogResponse.getStatus())) {
flyLogByNormalService.getFlyLog(inspection, flyLogResponse);
} else {
log.info("status类型不匹配");
}
}


}

+ 7
- 13
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/task/FlyLogTask.java Wyświetl plik

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

Ładowanie…
Anuluj
Zapisz