Browse Source

Merge branch 'develop' of gitadmin/tuoheng_telecomumale into release

tags/v1.3.1
wanjing 1 year ago
parent
commit
07d4538636
7 changed files with 56 additions and 25 deletions
  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. +5
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/data/FlyDataService.java
  4. +7
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogByNormalService.java
  5. +14
    -9
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogService.java
  6. +2
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/task/FlyDataTask.java
  7. +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 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/service/fly/data/FlyDataService.java View File

@@ -45,6 +45,7 @@ public class FlyDataService {
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());
@@ -128,6 +129,10 @@ public class FlyDataService {
.orderByDesc(FlightDataHl::getCreateTime)
.last("limit 1"));

if(CollectionUtil.isEmpty(flightDataHl) && flightDataHl.size() == 0){
//查出的数据为空,直接结束返回
return;
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

if(ObjectUtil.isNotNull(flightDataHl.get(0))){

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


}

+ 2
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/task/FlyDataTask.java View File

@@ -42,7 +42,8 @@ public class FlyDataTask {
log.info("执行定时执行飞行任务:" + LocalDateTime.now());
List<Inspection> inspectionList = inspectionMapper.selectList(new LambdaQueryWrapper<Inspection>()
.eq(Inspection::getMark, MarkEnum.VALID.getCode())
.between(Inspection::getInspectionTime, startTime, endTime)
//是查询任务表中所有正在执行中的任务(暂时注释掉,没问题删除)
//.between(Inspection::getInspectionTime, startTime, endTime)
//查询巡检方式为机场的任务
.eq(Inspection::getInspectionType, InspectionTypeEnum.AIRPORT.getCode())
//查询未执行任务
@@ -56,9 +57,7 @@ public class FlyDataTask {
//遍历任务列表中正在执行的任务进行飞行数据入库
for (Inspection inspection : inspectionList) {
log.info("执行定时,获取飞行数据: inspectionId:{}", inspection.getId());

flyDataService.getFlyData(inspection);

log.info("执行定时,获取飞行数据结束: inspectionId:{}");
}
}

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

Loading…
Cancel
Save