Browse Source

Merge branch 'feature_v1.0' into develop

tags/V1.0.1^2
chengwang 1 year ago
parent
commit
574d98e89b
7 changed files with 233 additions and 5 deletions
  1. +12
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/InspectionController.java
  2. +34
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/VideoUrlVo.java
  3. +61
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/airport/AirportDataVo.java
  4. +4
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspection/QueryVideoServiceEnum.java
  5. +7
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/IInspectionService.java
  6. +11
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/InspectionServiceImpl.java
  7. +104
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/query/QueryVideoService.java

+ 12
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/InspectionController.java View File

@@ -186,5 +186,17 @@ public class InspectionController {
return iInspectionService.getList();
}

/**
* 根据任务id和无人机id获取直播和机场内外部视频
* @param inspectionId
* @param droneId
* @return
*/
@GetMapping("/videoUrl")
public JsonResult getVideoUrl(@RequestParam("inspectionId") String inspectionId,
@RequestParam("droneId") Integer droneId){
return iInspectionService.getVideoUrl(inspectionId,droneId);
}


}

+ 34
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/VideoUrlVo.java View File

@@ -0,0 +1,34 @@
package com.tuoheng.admin.entity.vo;

import lombok.Data;

/**
* @Author ChengWang
* @Date 2023/5/29
*/
@Data
public class VideoUrlVo {

/**
* 直播视频url
*/
private String aipullUrl;

/**
* 机场外部监控地址
*/
private String externalMonitorUrl;

/**
*机场外部监控地址flv
*/
private String flvExternalMonitorUrl;

/**
* 机场内部监控地址
*/
private String internalMonitorUrl;



}

+ 61
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/vo/airport/AirportDataVo.java View File

@@ -0,0 +1,61 @@
package com.tuoheng.admin.entity.vo.airport;

import lombok.Data;

/**
* @Author ChengWang
* @Date 2023/5/29
*/
@Data
public class AirportDataVo {

/**
* 机场id
*/
private Integer id;

/**
* 机场code
*/
private String code;

/**
* 机场名称
*/
private String name;

/**
* 图片
*/
private String image;

/**
* 机场外视频
*/
private String externalMonitorUrl;

/**
* 机场地址
*/
private String flvExternalMonitorUrl;

/**
* 机场外部视频
*/
private String internalMonitorUrl;

/**
* 覆盖范围
*/
private String coverage;

/**
*排序
*/
private Integer sort;

/**
* 备注
*/
private String note;
}

+ 4
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/inspection/QueryVideoServiceEnum.java View File

@@ -9,9 +9,10 @@ public enum QueryVideoServiceEnum {
QUERY_IS_FAILED(1230700, "获取数据失败"),
INSPECTION_ID_IS_NULL(1230701, "任务id为空"),
LIVE_CHANNEL_IS_NOT_EXIST(1230702, "直播通道为空"),
AIPULL_URL_IS_NOT_NULL(1230703, "直播地址为空"),
AIVIDEO_URL_IS_NOT_NULL(1230704, "回放地址为空"),
INSPECTION_IS_NOT_EXIST(1230705, "任务不存在");
AIPULL_URL_IS_NULL(1230703, "直播地址为空"),
AIVIDEO_URL_IS_NULL(1230704, "回放地址为空"),
DRONE_ID_IS_NULL(1230705, "无人机id为空"),
INSPECTION_IS_NOT_EXIST(1230706, "任务不存在");

/**
* 错误码

+ 7
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/IInspectionService.java View File

@@ -145,4 +145,11 @@ public interface IInspectionService {
*/
JsonResult getList();

/**
* 根据任务id和无人机id获取直播和机场内外部视频
* @param inspectionId
* @param droneId
* @return
*/
JsonResult getVideoUrl(String inspectionId, Integer droneId);
}

+ 11
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/inspection/InspectionServiceImpl.java View File

@@ -297,4 +297,15 @@ public class InspectionServiceImpl implements IInspectionService {
return queryInspectionAndAirportStatusService.getList();
}

/**
* 根据任务id和无人机id获取直播和机场内外部视频
* @param inspectionId
* @param droneId
* @return
*/
@Override
public JsonResult getVideoUrl(String inspectionId, Integer droneId) {
return queryVideoService.getVideoUrl(inspectionId,droneId);
}

}

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

@@ -1,20 +1,39 @@
package com.tuoheng.admin.service.inspection.query;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.constant.SystemConstant;
import com.tuoheng.admin.entity.domain.Inspection;
import com.tuoheng.admin.entity.domain.LiveChannel;
import com.tuoheng.admin.entity.domain.Tenant;
import com.tuoheng.admin.entity.domain.User;
import com.tuoheng.admin.entity.vo.VideoUrlVo;
import com.tuoheng.admin.enums.InspectionStatusEnum;
import com.tuoheng.admin.enums.MarkEnum;
import com.tuoheng.admin.enums.code.AriportCodeEnum;
import com.tuoheng.admin.enums.code.inspection.QueryVideoServiceEnum;
import com.tuoheng.admin.mapper.InspectionMapper;
import com.tuoheng.admin.mapper.LiveChannelMapper;
import com.tuoheng.admin.entity.vo.LiveChannelVo;
import com.tuoheng.admin.mapper.TenantMapper;
import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.common.core.config.common.CommonConfig;
import com.tuoheng.common.core.utils.HttpUtils;
import com.tuoheng.common.core.utils.JacksonUtil;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.xmlbeans.impl.common.NameUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
* 根据任务id查询视频直播和回放
*
@@ -31,6 +50,9 @@ public class QueryVideoService {
@Autowired
private LiveChannelMapper liveChannelMapper;

@Autowired
private TenantMapper tenantMapper;


public JsonResult getVideoById(String id) {
if (StringUtils.isEmpty(id)) {
@@ -53,7 +75,7 @@ public class QueryVideoService {
return JsonResult.error(QueryVideoServiceEnum.LIVE_CHANNEL_IS_NOT_EXIST.getCode(), QueryVideoServiceEnum.LIVE_CHANNEL_IS_NOT_EXIST.getMsg());
}
if (StringUtils.isEmpty(liveChannel.getAipullUrl())) {
return JsonResult.error(QueryVideoServiceEnum.AIPULL_URL_IS_NOT_NULL.getCode(), QueryVideoServiceEnum.AIPULL_URL_IS_NOT_NULL.getMsg());
return JsonResult.error(QueryVideoServiceEnum.AIPULL_URL_IS_NULL.getCode(), QueryVideoServiceEnum.AIPULL_URL_IS_NULL.getMsg());
}
liveChannelVo.setAipullUrl(liveChannel.getAipullUrl());

@@ -61,10 +83,90 @@ public class QueryVideoService {
if (15 == inspection.getStatus()) {
//任务状态为任务飞行完成15视频回放
if (StringUtils.isEmpty(inspection.getAiVideoUrl())) {
return JsonResult.error(QueryVideoServiceEnum.AIVIDEO_URL_IS_NOT_NULL.getCode(), QueryVideoServiceEnum.AIVIDEO_URL_IS_NOT_NULL.getMsg());
return JsonResult.error(QueryVideoServiceEnum.AIVIDEO_URL_IS_NULL.getCode(), QueryVideoServiceEnum.AIVIDEO_URL_IS_NULL.getMsg());
}
liveChannelVo.setAiVideoUrl(CommonConfig.videoURL + inspection.getAiVideoUrl());
}
return JsonResult.success(liveChannelVo);
}

/**
* 根据任务id和无人机id获取直播和机场内外部视频
* @param inspectionId
* @param droneId
* @return
*/
public JsonResult getVideoUrl(String inspectionId, Integer droneId) {
User user = CurrentUserUtil.getUserInfo();
String userId = user.getId();
String tenantId = user.getTenantId();
//校验
JsonResult result = this.check(userId, tenantId, inspectionId, droneId);
if (0 != result.getCode()) {
log.info("进入获取直播和机场内外部视频接口,数据校验失败");
return JsonResult.error(result.getCode(), result.getMsg());
}
//获取机场内外部视频
Tenant tenant = tenantMapper.selectById(tenantId);
if (ObjectUtil.isNull(tenant)) {
return JsonResult.error(AriportCodeEnum.GET_NO_TENANT.getCode(), AriportCodeEnum.GET_NO_TENANT.getMsg());
}
String url = CommonConfig.airportURL + SystemConstant.API_AIRPORT_LIST;
String tempParam = "&tenantCode=" + tenant.getCode() + "&droneId=" + droneId;
String param = "page=1&limit=100" + tempParam;
String airPortStr = HttpUtils.sendGet(url, param);
if (StringUtils.isEmpty(airPortStr)) {
log.info("根据无人机id获取机场内外视频地址数据,返回为空:airPortStr={}", airPortStr);
throw new SecurityException("调用机场平台获取数据为空");
}
//String---->JsonResult
JsonResult jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class);
JSONObject dataObject = (JSONObject) JSONObject.toJSON(jsonResult.getData());
//url
VideoUrlVo vo = new VideoUrlVo();
if (Objects.nonNull(dataObject)) {
log.info("获取的数据,dataObject={}", dataObject.toJSONString());
//JSONObject recordsData = dataObject.get().getJSONObject("records");
Object records = dataObject.get("records");
String username = records.toString();
log.info("获取records中的数据为:username={}",username);

// if (Objects.isNull(recordsData)) {
// log.info("打印的数据为集合是的,recordsData:{}", recordsData.toString());
// System.out.println("转换为集合数为:"+recordsData.toString());
// }
// if(Objects.nonNull(recordsData)){
// vo.setExternalMonitorUrl(recordsData.getString("externalMonitorUrl"));
// vo.setFlvExternalMonitorUrl(recordsData.getString("flvExternalMonitorUrl"));
// vo.setInternalMonitorUrl(recordsData.getString("internalMonitorUrl"));
// }
}
//根据任务id获取aipullUrl
Inspection inspection = inspectionMapper.selectById(inspectionId);
if (ObjectUtil.isNull(inspection)) {
return JsonResult.error(QueryVideoServiceEnum.INSPECTION_IS_NOT_EXIST.getCode(), QueryVideoServiceEnum.INSPECTION_IS_NOT_EXIST.getMsg());
}
LiveChannel liveChannel = liveChannelMapper.selectOne(new LambdaQueryWrapper<LiveChannel>()
.eq(LiveChannel::getMark, MarkEnum.VALID.getCode())
.eq(LiveChannel::getInspectionId, inspection.getId())
.eq(LiveChannel::getStatus, 1));
if (ObjectUtil.isNotNull(liveChannel)) {
if (StringUtils.isNotEmpty(liveChannel.getAipullUrl())) {
vo.setAipullUrl(liveChannel.getAipullUrl());
}
}

return JsonResult.success(vo);
}


private JsonResult check(String userId, String tenantId, String inspectionId, Integer droneId) {
if(StringUtils.isEmpty(inspectionId)){
return JsonResult.error(QueryVideoServiceEnum.INSPECTION_ID_IS_NULL.getCode(),QueryVideoServiceEnum.INSPECTION_ID_IS_NULL.getMsg());
}
if(null == droneId){
return JsonResult.error(QueryVideoServiceEnum.DRONE_ID_IS_NULL.getCode(),QueryVideoServiceEnum.DRONE_ID_IS_NULL.getMsg());
}
return JsonResult.success();
}
}

Loading…
Cancel
Save