Переглянути джерело

优化获取飞行日志代码

tags/v1.3.1
wanjing 1 рік тому
джерело
коміт
c29b133e8c
1 змінених файлів з 8 додано та 2 видалено
  1. +8
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogService.java

+ 8
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/tzhl/service/fly/log/FlyLogService.java Переглянути файл

@@ -20,7 +20,9 @@ import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

@Slf4j
@Service
@@ -54,13 +56,17 @@ public class FlyLogService {
List<TZHLFlyLogResponse> flyLogResponseList = JSON.parseArray(dataJson, TZHLFlyLogResponse.class);

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

//根据日期进行降序排序
List<TZHLFlyLogResponse> flyLogResponseListSortDesc = flyLogResponseList.stream().sorted(Comparator.comparing(TZHLFlyLogResponse::getCreateTime).reversed()).collect(Collectors.toList());
TZHLFlyLogResponse flyLogResponseLast = flyLogResponseListSortDesc.get(0);
redisUtils.set(TZHLConstant.HL_FLY_LOG + inspection.getId(), flyLogResponseLast);

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())) {

Завантаження…
Відмінити
Зберегти