Browse Source

根据机场获取直播接口添加异常校验

tags/v1.2.0^2
chengwang 1 year ago
parent
commit
28ebd6f10e
1 changed files with 19 additions and 5 deletions
  1. +19
    -5
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryVideoService.java

+ 19
- 5
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryVideoService.java View File

@@ -2,6 +2,7 @@ package com.tuoheng.admin.service.inspection.query;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.entity.Inspection;
@@ -20,6 +21,9 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
* 根据任务id查询视频直播和回放
*
@@ -78,16 +82,26 @@ public class QueryVideoService {
return JsonResult.error(QueryVideoServiceEnum.AIRPORT_ID_IS_NULL.getCode(), QueryVideoServiceEnum.AIRPORT_ID_IS_NULL.getMsg());
}
//根据机场id查询对应正在巡检的任务
Inspection inspection = inspectionMapper.selectInspectionByAirport(id);
if(ObjectUtils.isEmpty(inspection)){
//Inspection inspection = inspectionMapper.selectInspectionByAirport(id);
List<Inspection> inspectionList = inspectionMapper.selectList(Wrappers.<Inspection>lambdaQuery()
.eq(Inspection::getStatus, InspectionStatusEnum.IN_FLIGHT.getCode())
.eq(Inspection::getMark, MarkEnum.VALID.getCode()).eq(Inspection::getAirportId, id));
if(CollectionUtils.isEmpty(inspectionList)){
return JsonResult.error(QueryVideoServiceEnum.INSPECTION_IS_NOT_EXIST.getCode(), QueryVideoServiceEnum.INSPECTION_IS_NOT_EXIST.getMsg());

}
if(inspectionList.size()>1){
return JsonResult.error("当前机场对应的正在飞行的任务存在多个,请检查!");
}
// if(ObjectUtils.isEmpty(inspection)){
// return JsonResult.error(QueryVideoServiceEnum.INSPECTION_IS_NOT_EXIST.getCode(), QueryVideoServiceEnum.INSPECTION_IS_NOT_EXIST.getMsg());
// }
InspectionVideoVo vo = new InspectionVideoVo();
if (10 == inspection.getStatus()) {
if (10 == inspectionList.get(0).getStatus()) {
//任务状态为任务飞行中10视频直播
LiveChannel liveChannel = liveChannelMapper.selectOne(new LambdaQueryWrapper<LiveChannel>()
.eq(LiveChannel::getMark, 1)
.eq(LiveChannel::getInspectionId, inspection.getId())
.eq(LiveChannel::getInspectionId, inspectionList.get(0).getId())
.eq(LiveChannel::getStatus, 1));
if (ObjectUtil.isNull(liveChannel)) {
return JsonResult.error(QueryVideoServiceEnum.LIVE_CHANNEL_IS_NOT_EXIST.getCode(), QueryVideoServiceEnum.LIVE_CHANNEL_IS_NOT_EXIST.getMsg());
@@ -96,7 +110,7 @@ public class QueryVideoService {
return JsonResult.error(QueryVideoServiceEnum.AIPULL_URL_IS_NOT_NULL.getCode(), QueryVideoServiceEnum.AIPULL_URL_IS_NOT_NULL.getMsg());
}
vo.setAipullUrl(liveChannel.getAipullUrl());
vo.setInspectionId(inspection.getId());
vo.setInspectionId(inspectionList.get(0).getId());
}

return JsonResult.success(vo);

Loading…
Cancel
Save