@@ -4,6 +4,7 @@ import com.tuoheng.admin.entity.FlightData; | |||
import com.tuoheng.admin.service.flightdata.IFlightDataService; | |||
import com.tuoheng.common.core.common.OperationEnum; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.PostMapping; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
@@ -29,6 +30,7 @@ public class CloudBoxCallbackoxController { | |||
* @param entity | |||
* @return | |||
*/ | |||
@PostMapping("/add") | |||
public OperationEnum addCallback(@RequestBody FlightData entity) { | |||
flightDataService.addCallback(entity); | |||
return OperationEnum.OPERATION_SUCCESS; |
@@ -1,5 +1,6 @@ | |||
package com.tuoheng.admin.service.flightdata; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
@@ -63,19 +64,25 @@ public class FlightDataServiceImpl extends BaseServiceImpl<FlightDataMapper, Fli | |||
@Override | |||
public void addCallback(FlightData entity) { | |||
if (entity != null && StringUtils.isNotEmpty(entity.getBoxSn())) { | |||
log.info("addCallback接口入参:" + entity); | |||
//查询正在执行的云盒所对应的任务 | |||
List<Inspection> inspectionList = inspectionMapper.getListByBox(entity.getBoxSn()); | |||
if (StringUtils.isNotEmpty(inspectionList)) { | |||
entity.setTenantId(inspectionList.get(0).getTenantId()); | |||
entity.setInspectionId(inspectionList.get(0).getId()); | |||
//将最新一条数据存放入缓存,并设置过期时间 | |||
redisUtils.set(inspectionList.get(0).getId(), entity, 10); | |||
} | |||
entity.setCreateTime(DateUtils.now()); | |||
flightDataMapper.insert(entity); | |||
log.info("addCallback接口入库成功:" + entity.getId()); | |||
log.info("addCallback接口入参:" + entity); | |||
if (ObjectUtil.isNull(entity)) { | |||
log.info("传入参数entity为空"); | |||
return; | |||
} | |||
if (StringUtils.isEmpty(entity.getBoxSn())) { | |||
log.info("云盒SN号为空"); | |||
return; | |||
} | |||
//查询正在执行的云盒所对应的任务 | |||
List<Inspection> inspectionList = inspectionMapper.getListByBox(entity.getBoxSn()); | |||
if (StringUtils.isNotEmpty(inspectionList)) { | |||
entity.setTenantId(inspectionList.get(0).getTenantId()); | |||
entity.setInspectionId(inspectionList.get(0).getId()); | |||
//将最新一条数据存放入缓存,并设置过期时间 | |||
redisUtils.set(inspectionList.get(0).getId(), entity, 10); | |||
} | |||
entity.setCreateTime(DateUtils.now()); | |||
flightDataMapper.insert(entity); | |||
log.info("addCallback接口入库成功:" + entity.getId()); | |||
} | |||
} |
@@ -68,6 +68,9 @@ public class OnlineIdentifService { | |||
@Value("${tuoheng.dsp-domain-url:}") | |||
private String dspDomainUrl; | |||
@Value("${tuoheng.dsp-service-inst-id:}") | |||
private String dspServiceInstId; | |||
@Value("${tuoheng.dsp-callback-url:}") | |||
private String dspCallbackUrl; | |||
@@ -102,7 +105,8 @@ public class OnlineIdentifService { | |||
log.info("开始调用DSP服务"); | |||
// 调用DSP服务 | |||
String url = String.format(Locale.ENGLISH, "%s/api/web/serviceInst/827938791cf98ec2dfceea59726e5085/application", dspDomainUrl, ""); | |||
String url = String.format(Locale.ENGLISH, "%s/api/web/serviceInst/%s/application", dspDomainUrl, dspServiceInstId); | |||
log.info("调用DSP服务, url:{}", url); | |||
try { | |||
Map<String, Object> paramMap = new HashMap<>(); | |||
@@ -208,7 +212,7 @@ public class OnlineIdentifService { | |||
response = restTemplate.exchange(url, HttpMethod.PUT, httpEntity, JsonResult.class); | |||
} catch (Exception e) { | |||
deliverStreamingService.deliver(liveChannelDto.getCode()); | |||
log.error("", e); | |||
log.error("设置通道状态异常!{}", e); | |||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "设置通道状态异常!"); | |||
} | |||
if (response == null || !response.hasBody() || response.getBody().getCode() != JsonResult.SUCCESS) { |
@@ -88,22 +88,29 @@ public class UploadFlightUrlService { | |||
Inspection inspection = (Inspection) result.getData(); | |||
log.info("上传离线视频业务接口, inspectionid:{}", inspection.getId()); | |||
log.info("上传离线视频业务接口, isLive:{}, analyseStatus:{}", inspection.getIsLive(), inspection.getAnalyseStatus()); | |||
//修改用户直播完也可以进行分析 | |||
if (1 == inspection.getIsLive() && inspection.getAnalyseStatus() != 1) { | |||
log.info("上传离线视频业务接口, 修改用户直播完进行分析"); | |||
inspection.setAnalyseStatus(1); | |||
inspectionMapper.updateById(inspection); | |||
} | |||
if (TaskStatusEnum.COMPLETE.getCode() != inspection.getStatus()) { | |||
log.info("上传离线视频业务接口, 只有飞行完成状态可以操作!"); | |||
throw new ServiceException(ServiceExceptionEnum.TASK_NOT_OPERATION); | |||
} | |||
// 如果任务处于待分析中,响应前端,任务待分析中,不能上传视频 | |||
if (AiAnalyseStatusEnum.WAITING.getCode() == inspection.getAnalyseStatus() | |||
|| AiAnalyseStatusEnum.RUNNING.getCode() == inspection.getAnalyseStatus()) { | |||
log.info("上传离线视频业务接口, 视频分析中,请稍后再试!"); | |||
throw new ServiceException(ServiceExceptionEnum.VIDEO_ANALYSIS_IN_PROGRESS); | |||
} | |||
if (AiAnalyseStatusEnum.SUCCESS.getCode() == inspection.getAnalyseStatus() | |||
|| AiAnalyseStatusEnum.SUCCESS_TIMEOUT.getCode() == inspection.getAnalyseStatus()) { | |||
log.info("上传离线视频业务接口, 视频分析已完成!"); | |||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "视频分析已完成"); | |||
} | |||
@@ -115,6 +122,7 @@ public class UploadFlightUrlService { | |||
.eq(InspectionFile::getInspectionId, inspection.getId()) | |||
.eq(InspectionFile::getMark, 1)); | |||
if (num > 0) { | |||
log.info("上传离线视频业务接口, 每次上传或重试,清除上次的数据"); | |||
inspectionFileMapper.deleteByInspectionId(inspection.getId()); | |||
} | |||
@@ -220,6 +228,8 @@ public class UploadFlightUrlService { | |||
* 调用DSP接口 | |||
*/ | |||
private void callDsp(String inspectionId, String videoUrl) { | |||
log.info("调用DSP接口, inspectionId:{}, videoUrl:{}", inspectionId, videoUrl); | |||
JSONObject requestDsp = new JSONObject(); | |||
JSONArray configList = new JSONArray(); | |||
JSONObject instConfigMode = new JSONObject(); |
@@ -12,6 +12,7 @@ import java.io.InputStreamReader; | |||
import java.io.PrintWriter; | |||
import java.net.HttpURLConnection; | |||
import java.net.URL; | |||
import java.util.Locale; | |||
import java.util.Map; | |||
@Slf4j | |||
@@ -24,10 +25,16 @@ public class DspServiceImpl implements IDspService { | |||
@Value("${tuoheng.dsp-domain-url:}") | |||
private String dspDomainUrl; | |||
@Value("${tuoheng.dsp-service-inst-id:}") | |||
private String dspServiceInstId; | |||
@Override | |||
public JSONObject serviceInstApplication(JSONObject jsonObject) { | |||
String url = dspDomainUrl + "api/web/serviceInst/827938791cf98ec2dfceea59726e5085/application"; | |||
String url = String.format(Locale.ENGLISH, "%s/api/web/serviceInst/%s/application", dspDomainUrl, dspServiceInstId); | |||
log.info("调用DSP服务, url:{}", url); | |||
log.info("调用DSP服务, jsonObject:{}", jsonObject); | |||
String result = doPost(url, jsonObject, null); | |||
log.info("调用DSP服务, result:{}", result); | |||
return JSONObject.parseObject(result); | |||
} | |||
@@ -136,7 +136,9 @@ tuoheng: | |||
# 通道地址 | |||
live-channel-domain-url: https://streaming.t-aaron.com/ | |||
# DSP服务域名 | |||
dsp-domain-url: https://dsp.t-aaron.com/ | |||
dsp-domain-url: https://dsp.t-aaron.com | |||
# DSP服务实例Id | |||
dsp-service-inst-id: ece32f4da856be0f4fc704930a52b9e7 | |||
# DSP回调地址 | |||
dsp-callback-url: https://192.168.11.11:9177/dsp/callback/{requestId} | |||
#飞手平台地址 |
@@ -142,7 +142,9 @@ tuoheng: | |||
# 通道地址 | |||
live-channel-domain-url: https://streaming.t-aaron.com/ | |||
# DSP服务域名 | |||
dsp-domain-url: http://192.168.11.241:7011/ | |||
dsp-domain-url: http://192.168.11.241:7011 | |||
# DSP服务实例Id | |||
dsp-service-inst-id: ece32f4da856be0f4fc704930a52b9e7 | |||
# DSP回调地址 | |||
dsp-callback-url: https://127.0.0.1:9117/dsp/callback/{requestId} | |||
#飞手平台地址 |
@@ -137,7 +137,9 @@ tuoheng: | |||
# 通道地址 | |||
live-channel-domain-url: https://streaming.t-aaron.com/ | |||
# DSP服务域名 | |||
dsp-domain-url: https://dsp-portal.t-aaron.com/ | |||
dsp-domain-url: https://dsp-portal.t-aaron.com | |||
# DSP服务实例Id | |||
dsp-service-inst-id: b7a505c204d5605235829ac0bb9b616a | |||
# DSP回调地址 | |||
dsp-callback-url: https://freeway.t-aaron.com/freeway/admin/dsp/callback/{requestId} | |||
#飞手平台地址 |
@@ -137,7 +137,9 @@ tuoheng: | |||
# 通道地址 | |||
live-channel-domain-url: https://streaming.t-aaron.com/ | |||
# DSP服务域名 | |||
dsp-domain-url: http://172.15.1.11:7011/ | |||
dsp-domain-url: http://172.15.1.11:7011 | |||
# DSP服务实例Id | |||
dsp-service-inst-id: 0d8166ba7a3081aa1179c37fa57d7d6b | |||
# DSP回调地址 | |||
dsp-callback-url: https://freeway-test.t-aaron.com/freeway/admin/dsp/callback/{requestId} | |||
#飞手平台地址 |