|
@ -1,11 +1,18 @@ |
|
|
package org.dromara.sample.manage.service.impl; |
|
|
package org.dromara.sample.manage.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
|
import cn.hutool.core.io.FileUtil; |
|
|
import cn.hutool.core.map.MapUtil; |
|
|
import cn.hutool.core.map.MapUtil; |
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
|
|
import com.alibaba.nacos.common.utils.CollectionUtils; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
import io.seata.common.util.StringUtils; |
|
|
import io.seata.common.util.StringUtils; |
|
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.dubbo.config.annotation.DubboReference; |
|
|
import org.apache.dubbo.config.annotation.DubboReference; |
|
|
import org.apache.http.client.methods.CloseableHttpResponse; |
|
|
import org.apache.http.client.methods.CloseableHttpResponse; |
|
@ -16,17 +23,32 @@ import org.apache.http.entity.StringEntity; |
|
|
import org.apache.http.impl.client.CloseableHttpClient; |
|
|
import org.apache.http.impl.client.CloseableHttpClient; |
|
|
import org.apache.http.impl.client.HttpClients; |
|
|
import org.apache.http.impl.client.HttpClients; |
|
|
import org.apache.http.util.EntityUtils; |
|
|
import org.apache.http.util.EntityUtils; |
|
|
|
|
|
import org.dromara.business.api.RemoteBusinessAlertService; |
|
|
|
|
|
import org.dromara.business.api.domain.vo.RemoteBusinessAlertVo; |
|
|
|
|
|
import org.dromara.common.core.utils.file.MimeTypeUtils; |
|
|
|
|
|
import org.dromara.common.oss.core.OssClient; |
|
|
|
|
|
import org.dromara.common.oss.entity.UploadResult; |
|
|
|
|
|
import org.dromara.common.oss.factory.OssFactory; |
|
|
|
|
|
import org.dromara.common.sdk.mqtt.CommonTopicRequest; |
|
|
import org.dromara.sample.common.util.Md5Utils; |
|
|
import org.dromara.sample.common.util.Md5Utils; |
|
|
import org.dromara.sample.manage.config.XingluoApiConfig; |
|
|
import org.dromara.sample.manage.config.XingluoApiConfig; |
|
|
|
|
|
import org.dromara.sample.manage.config.XingluoApiEnum; |
|
|
import org.dromara.sample.manage.mapper.IDeviceMapper; |
|
|
import org.dromara.sample.manage.mapper.IDeviceMapper; |
|
|
import org.dromara.sample.manage.mapper.ISampleEngineRecordMapper; |
|
|
import org.dromara.sample.manage.mapper.ISampleEngineRecordMapper; |
|
|
import org.dromara.sample.manage.mapper.ITaskJobMapper; |
|
|
import org.dromara.sample.manage.mapper.ITaskJobMapper; |
|
|
|
|
|
import org.dromara.sample.manage.mapper.SampleWarningRecordMapper; |
|
|
import org.dromara.sample.manage.model.dto.*; |
|
|
import org.dromara.sample.manage.model.dto.*; |
|
|
import org.dromara.sample.manage.model.entity.EngineRecordEntity; |
|
|
import org.dromara.sample.manage.model.entity.EngineRecordEntity; |
|
|
import org.dromara.sample.manage.model.entity.TaskJobEntity; |
|
|
import org.dromara.sample.manage.model.entity.TaskJobEntity; |
|
|
|
|
|
import org.dromara.sample.manage.model.entity.WarningRecordEntity; |
|
|
import org.dromara.sample.manage.service.IDeviceService; |
|
|
import org.dromara.sample.manage.service.IDeviceService; |
|
|
import org.dromara.sample.manage.service.ISampleEngineRecordService; |
|
|
import org.dromara.sample.manage.service.ISampleEngineRecordService; |
|
|
|
|
|
import org.dromara.sample.manage.service.ISampleWarningRecordService; |
|
|
|
|
|
import org.dromara.sample.media.constant.MinIOConstants; |
|
|
|
|
|
import org.dromara.sample.wayline.mapper.IWaylineJobMapper; |
|
|
|
|
|
import org.dromara.sample.wayline.model.entity.WaylineJobEntity; |
|
|
import org.dromara.system.api.RemoteConfigService; |
|
|
import org.dromara.system.api.RemoteConfigService; |
|
|
|
|
|
import org.dromara.system.api.RemoteDictService; |
|
|
import org.json.JSONArray; |
|
|
import org.json.JSONArray; |
|
|
import org.json.JSONObject; |
|
|
import org.json.JSONObject; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
@ -34,12 +56,18 @@ import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
import java.io.InputStream; |
|
|
import java.net.URI; |
|
|
import java.net.URI; |
|
|
import java.net.URISyntaxException; |
|
|
import java.net.URISyntaxException; |
|
|
|
|
|
import java.net.URL; |
|
|
|
|
|
import java.net.URLConnection; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
import static org.apache.commons.compress.utils.ArchiveUtils.sanitize; |
|
|
import static org.apache.commons.compress.utils.ArchiveUtils.sanitize; |
|
|
|
|
|
|
|
|
|
|
|
@RequiredArgsConstructor |
|
|
@Service |
|
|
@Service |
|
|
@Slf4j |
|
|
@Slf4j |
|
|
@Transactional |
|
|
@Transactional |
|
@ -50,15 +78,30 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService |
|
|
@Resource |
|
|
@Resource |
|
|
ITaskJobMapper taskJobMapper; |
|
|
ITaskJobMapper taskJobMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
SampleWarningRecordMapper sampleWarningRecordMapper; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private XingluoApiConfig xingluoApiConfig; |
|
|
private XingluoApiConfig xingluoApiConfig; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private IDeviceService deviceService; |
|
|
private IDeviceService deviceService; |
|
|
|
|
|
|
|
|
|
|
|
// @Autowired
|
|
|
|
|
|
// private ISampleWarningRecordService sampleWarningRecordService;
|
|
|
|
|
|
|
|
|
|
|
|
// @Autowired
|
|
|
|
|
|
private final IWaylineJobMapper waylineJobMapper; |
|
|
|
|
|
|
|
|
@DubboReference |
|
|
@DubboReference |
|
|
private RemoteConfigService remoteConfigService; |
|
|
private RemoteConfigService remoteConfigService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@DubboReference |
|
|
|
|
|
private final RemoteBusinessAlertService businessAlertService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Map<String, Object> extractType(Map<String, Object> objectMap) { |
|
|
public Map<String, Object> extractType(Map<String, Object> objectMap) { |
|
|
EngineRecordEntity record = new EngineRecordEntity(); |
|
|
EngineRecordEntity record = new EngineRecordEntity(); |
|
@ -103,7 +146,8 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService |
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
//ExtraTypeResponse(code=200, message=操作成功, data=[ExtraType(id=2022, sence=可见光, type=秸秆焚烧(烟、火、焚后痕迹), extra_type=2010_12, model=01, user=xuzhou_ai, difficult=0, if_open=1, sence_id=2022, conf=0.7, aiConfig=0), ExtraType(id=2023, sence=可见光, type=烟火识别, extra_type=2010_13, model=01, user=xuzhou_ai, difficult=0, if_open=1, sence_id=2023, conf=0.7, aiConfig=0), ExtraType(id=2003, sence=可见光, type=是否佩戴安全绳, extra_type=2003_ext, model=01, user=xuzhou_ai, difficult=0, if_open=1, sence_id=2003, conf=0.7, aiConfig=0), ExtraType(id=2004, sence=可见光, type=是否佩戴安全帽, extra_type=2004_ext, model=01, user=xuzhou_ai, difficult=0, if_open=1, sence_id=2004, conf=0.7, aiConfig=1), ExtraType(id=2034, sence=可见光, type=路面车辆计数, extra_type=2010_24, model=01, user=xuzhou_ai, difficult=0, if_open=1, sence_id=2034, conf=0.7, aiConfig=0), ExtraType(id=2015, sence=可见光, type=多类型车辆计数, extra_type=2010_5, model=01, user=xuzhou_ai, difficult=0, if_open=1, sence_id=2015, conf=0.7, aiConfig=0), ExtraType(id=2016, sence=可见光, type=多类型车辆拥堵聚集, extra_type=2010_6, model=01, user=xuzhou_ai, difficult=0, if_open=1, sence_id=2016, conf=0.7, aiConfig=0)])
|
|
|
//ExtraTypeResponse(code=200, message=操作成功, data=[ExtraType(id=2022, sence=可见光, type=秸秆焚烧(烟、火、焚后痕迹), extra_type=2010_12, model=01, user=xuzhou_ai, difficult=0, if_open=1, sence_id=2022, conf=0.7, aiConfig=0), ExtraType(id=2023, sence=可见光, type=烟火识别, extra_type=2010_13, model=01, user=xuzhou_ai, difficult=0, if_open=1, sence_id=2023, conf=0.7, aiConfig=0), ExtraType(id=2003, sence=可见光, type=是否佩戴安全绳, extra_type=2003_ext, model=01, user=xuzhou_ai, difficult=0, if_open=1, sence_id=2003, conf=0.7, aiConfig=0), ExtraType(id=2004, sence=可见光, type=是否佩戴安全帽, extra_type=2004_ext, model=01, user=xuzhou_ai, difficult=0, if_open=1, sence_id=2004, conf=0.7, aiConfig=1), ExtraType(id=2034, sence=可见光, type=路面车辆计数, extra_type=2010_24, model=01, user=xuzhou_ai, difficult=0, if_open=1, sence_id=2034, conf=0.7, aiConfig=0), ExtraType(id=2015, sence=可见光, type=多类型车辆计数, extra_type=2010_5, model=01, user=xuzhou_ai, difficult=0, if_open=1, sence_id=2015, conf=0.7, aiConfig=0), ExtraType(id=2016, sence=可见光, type=多类型车辆拥堵聚集, extra_type=2010_6, model=01, user=xuzhou_ai, difficult=0, if_open=1, sence_id=2016, conf=0.7, aiConfig=0)])
|
|
|
ExtraTypeResponse response = mapper.readValue(algorithmResponseBody,ExtraTypeResponse.class); |
|
|
ExtraTypeResponse response = mapper.readValue(algorithmResponseBody,ExtraTypeResponse.class); |
|
|
System.out.println(response); |
|
|
|
|
|
|
|
|
System.out.println(JSONUtil.toJsonStr(response)); |
|
|
List<ExtraType> list = response.getData(); |
|
|
List<ExtraType> list = response.getData(); |
|
|
for (ExtraType extraType : list) { |
|
|
for (ExtraType extraType : list) { |
|
|
extra_type_list.add(extraType.getExtra_type()); |
|
|
extra_type_list.add(extraType.getExtra_type()); |
|
@ -146,6 +190,7 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService |
|
|
|
|
|
|
|
|
//查询用户开通的场景
|
|
|
//查询用户开通的场景
|
|
|
Object rtmpUrlParam = objectMap.get("rtmpUrl"); |
|
|
Object rtmpUrlParam = objectMap.get("rtmpUrl"); |
|
|
|
|
|
String pushUrl = "rtmp://" + ip + "/live/livesteam/" + rtmpUrl + "ai1"; |
|
|
if (StringUtils.isNotEmpty(token)){ |
|
|
if (StringUtils.isNotEmpty(token)){ |
|
|
JSONObject jsonObj2 = new JSONObject(); |
|
|
JSONObject jsonObj2 = new JSONObject(); |
|
|
String type = objectMap.get("type").toString(); |
|
|
String type = objectMap.get("type").toString(); |
|
@ -156,8 +201,8 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService |
|
|
jsonObj2.put("extra_type_list",new JSONArray(list)); |
|
|
jsonObj2.put("extra_type_list",new JSONArray(list)); |
|
|
// jsonObj2.put("input_url","http://"+ip+":19008/live/livesteam/"+objectMap.get("rtmpUrl")+".flv");
|
|
|
// jsonObj2.put("input_url","http://"+ip+":19008/live/livesteam/"+objectMap.get("rtmpUrl")+".flv");
|
|
|
jsonObj2.put("input_url", "rtmp://"+ip+"/live/livesteam/"+ rtmpUrl);//预览接口必须要传rtmp,不能是flv
|
|
|
jsonObj2.put("input_url", "rtmp://"+ip+"/live/livesteam/"+ rtmpUrl);//预览接口必须要传rtmp,不能是flv
|
|
|
String pushUrl = "rtmp://" + ip + "/live/livesteam/" + rtmpUrl + "ai1"; |
|
|
|
|
|
jsonObj2.put("push_url", pushUrl); //推流接口有时候不稳定,需要检查SRS服务
|
|
|
jsonObj2.put("push_url", pushUrl); //推流接口有时候不稳定,需要检查SRS服务
|
|
|
|
|
|
// live.setUrl(url.toString().replace("rtmp", "webrtc"));
|
|
|
// jsonObj2.put("play_url", objectMap.get("play_url")); //play_url不必传, play和push是一对, play 其实是冗余的, 方便记录更详细的日志
|
|
|
// jsonObj2.put("play_url", objectMap.get("play_url")); //play_url不必传, play和push是一对, play 其实是冗余的, 方便记录更详细的日志
|
|
|
/** |
|
|
/** |
|
|
* {"code":500,"message":"任务启动错误:can not open input stream http://114.235.183.163:19008/live/livesteam/7CTXN2T00B07C5-165-0-7.flv","data":null} |
|
|
* {"code":500,"message":"任务启动错误:can not open input stream http://114.235.183.163:19008/live/livesteam/7CTXN2T00B07C5-165-0-7.flv","data":null} |
|
@ -165,6 +210,12 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService |
|
|
* {"code":500,"message":"任务启动错误:can not open output rtmp://114.235.183.163/live/livesteam/7CTXN2T00B07C5-165-0-7ai1","data":null} |
|
|
* {"code":500,"message":"任务启动错误:can not open output rtmp://114.235.183.163/live/livesteam/7CTXN2T00B07C5-165-0-7ai1","data":null} |
|
|
* {"code":200,"message":"操作成功","data":{"task_id":"NOZGoIIubQ","mission_batch":"WX1748254304635"}} |
|
|
* {"code":200,"message":"操作成功","data":{"task_id":"NOZGoIIubQ","mission_batch":"WX1748254304635"}} |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
//测试环境,直接接收url,跳过无人机
|
|
|
|
|
|
// Object rtmpUrlParam = objectMap.get("inputUrl");
|
|
|
|
|
|
jsonObj2.put("input_url", "rtmp://114.235.183.163/live/livesteam/1581F6Q8X24CE00G02S4-81-0-0");//预览接口必须要传rtmp,不能是flv
|
|
|
|
|
|
jsonObj2.put("push_url", "rtmp://114.235.183.163/live/livesteam/1581F6Q8X24CE00G02S4-81-0-0ai1");//预览接口必须要传rtmp,不能是flv
|
|
|
|
|
|
|
|
|
String responseBody2 = PostRequest(jsonObj2, xingluoApiConfig.getEngineStart(),token); //"http://60.204.247.65:8100/Third/Engine/Start"
|
|
|
String responseBody2 = PostRequest(jsonObj2, xingluoApiConfig.getEngineStart(),token); //"http://60.204.247.65:8100/Third/Engine/Start"
|
|
|
ObjectMapper mapper1 = new ObjectMapper(); |
|
|
ObjectMapper mapper1 = new ObjectMapper(); |
|
|
EngineResponse response = null; |
|
|
EngineResponse response = null; |
|
@ -194,12 +245,17 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService |
|
|
engineRecordMapper.insert(record); |
|
|
engineRecordMapper.insert(record); |
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap(); |
|
|
Map<String, Object> map = new HashMap(); |
|
|
map.put("push_url", "http://"+ip+":1985/rtc/v1/whep/?app=live/livesteam&stream="+ rtmpUrl +"ai1"); |
|
|
// map.put("push_url", "http://"+ip+":1985/rtc/v1/whep/?app=live/livesteam&stream="+ rtmpUrl +"ai1");
|
|
|
|
|
|
// live.setUrl(url.toString().replace("rtmp", "webrtc"));
|
|
|
|
|
|
map.put("push_url", pushUrl.replaceFirst("rtmp", "webrtc")); |
|
|
map.put("task_id", taskId);//objectMap.get("task_id")
|
|
|
map.put("task_id", taskId);//objectMap.get("task_id")
|
|
|
|
|
|
|
|
|
//添加任务id和jobid关联关系
|
|
|
//添加任务id和jobid关联关系
|
|
|
TaskJobEntity taskJobEntity = new TaskJobEntity(); |
|
|
TaskJobEntity taskJobEntity = new TaskJobEntity(); |
|
|
taskJobEntity.setJobId(objectMap.get("jobId").toString()); |
|
|
|
|
|
|
|
|
String jobIdStr = MapUtil.getStr(objectMap, "jobId"); |
|
|
|
|
|
jobIdStr = StrUtil.isEmpty(jobIdStr) ? "-1" : jobIdStr; //没有航线,默认-1
|
|
|
|
|
|
taskJobEntity.setJobId(jobIdStr); |
|
|
taskJobEntity.setTaskId(objectMap.get("task_id").toString()); |
|
|
taskJobEntity.setTaskId(objectMap.get("task_id").toString()); |
|
|
taskJobEntity.setDeviceSn(deviceSn); |
|
|
taskJobEntity.setDeviceSn(deviceSn); |
|
|
taskJobMapper.insert(taskJobEntity); |
|
|
taskJobMapper.insert(taskJobEntity); |
|
@ -274,9 +330,189 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Integer dealAlertData(cn.hutool.json.JSONObject resObject) { |
|
|
|
|
|
cn.hutool.json.JSONObject entries = new cn.hutool.json.JSONObject(resObject); |
|
|
|
|
|
CallBackDTO callBackVo = JSONUtil.toBean(resObject, CallBackDTO.class); |
|
|
|
|
|
String taskIdStr = entries.getStr("taskId"); |
|
|
|
|
|
if(StrUtil.isBlank(taskIdStr)){return 0;} //无任务ID拦截
|
|
|
|
|
|
|
|
|
|
|
|
//基于历史记录,找相同设备- trackId是否相同,不同才保存, (每次记录中eventId都不同,所以不做参考)
|
|
|
|
|
|
//同一图片上传可能包含多个物体,传值可能是 h1v93,或者fdi32,或者h1v93,fdi32, 只要trackIds不同,就保存记录
|
|
|
|
|
|
List<WarningRecordEntity> warningRecordList = new ArrayList<>(); |
|
|
|
|
|
// String fileUrlStr = "mediafile/e5b8ce3a-3562-40e0-b244-91554d9c17ad/DJI_202505211323_001_e5b8ce3a-3562-40e0-b244-91554d9c17ad/DJI_20250521132610_0001_V.jpeg";
|
|
|
|
|
|
// String fileUrl = fileService.getObjectUrlOne(MinIOConstants.BUCKET_DKCY, fileUrlStr, 360000).toString();
|
|
|
|
|
|
if (CollectionUtils.isEmpty(callBackVo.getEvents())){return 0;} //空事件拦截
|
|
|
|
|
|
|
|
|
|
|
|
/** 传值转WarningRecord记录 **/ |
|
|
|
|
|
for (EventsDTO eventsVo : callBackVo.getEvents()){ //一个事件一个图片
|
|
|
|
|
|
String extraTypeStr = eventsVo.getExtraType(); |
|
|
|
|
|
String trackIds = eventsVo.getObjects().stream().map(ObjectsDTO::getTrackId).collect(Collectors.joining(",")); |
|
|
|
|
|
// Long count = sampleWarningRecordService.lambdaQuery()
|
|
|
|
|
|
// .eq(WarningRecordEntity::getTaskId, taskIdStr)
|
|
|
|
|
|
// .eq(WarningRecordEntity::getExtraType, extraTypeStr)
|
|
|
|
|
|
// .eq(WarningRecordEntity::getTrackIds, trackIds)
|
|
|
|
|
|
// .count();
|
|
|
|
|
|
LambdaQueryWrapper<WarningRecordEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
queryWrapper.eq(WarningRecordEntity::getTaskId, taskIdStr) |
|
|
|
|
|
.eq(WarningRecordEntity::getExtraType, extraTypeStr) |
|
|
|
|
|
.eq(WarningRecordEntity::getTrackIds, trackIds); |
|
|
|
|
|
Long count = sampleWarningRecordMapper.selectCount(queryWrapper); |
|
|
|
|
|
if(count > 0){continue;} |
|
|
|
|
|
|
|
|
|
|
|
WarningRecordEntity warningRecord = new WarningRecordEntity(); |
|
|
|
|
|
warningRecord.setTaskId(callBackVo.getTaskId()); |
|
|
|
|
|
warningRecord.setAlgoId(eventsVo.getAlgoId()); |
|
|
|
|
|
warningRecord.setEventId(eventsVo.getEventId()); |
|
|
|
|
|
warningRecord.setExtraType(eventsVo.getExtraType()); |
|
|
|
|
|
warningRecord.setPicUrl(eventsVo.getPicUrl()); |
|
|
|
|
|
// warningRecord.setPicUrl("http://114.235.183.147:9090/api/v1/download-shared-object/aHR0cDovLzEyNy4wLjAuMTo5MDAwL2RrY3kvbWVkaWFmaWxlL2U1YjhjZTNhLTM1NjItNDBlMC1iMjQ0LTkxNTU0ZDljMTdhZC9ESklfMjAyNTA1MjExMzIzXzAwMV9lNWI4Y2UzYS0zNTYyLTQwZTAtYjI0NC05MTU1NGQ5YzE3YWQvREpJXzIwMjUwNTIxMTMyNjEwXzAwMDFfVi5qcGVnP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QVI5MEk5QkxXWVZBWkRLOUowVjElMkYyMDI1MDUyMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTA1MjJUMTUxNzAxWiZYLUFtei1FeHBpcmVzPTQzMjAwJlgtQW16LVNlY3VyaXR5LVRva2VuPWV5SmhiR2NpT2lKSVV6VXhNaUlzSW5SNWNDSTZJa3BYVkNKOS5leUpoWTJObGMzTkxaWGtpT2lKQlVqa3dTVGxDVEZkWlZrRmFSRXM1U2pCV01TSXNJbVY0Y0NJNk1UYzBOemsyT0RneE9Dd2ljR0Z5Wlc1MElqb2lZV1J0YVc0aWZRLkh1N1VaVkhuS19EUWhfR1lnLVB0cVhBNFpJTHpPTk1vTkZ3by1YalI0N0R3U3VnZ2NyRC1EdXkxeEdfM3FmWXdRQmdPd29Ca2xGVTRYLWpvNncxY0lRJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZ2ZXJzaW9uSWQ9bnVsbCZYLUFtei1TaWduYXR1cmU9MjNmZjdhZWViNTJlZjk4ZWFmMTg5OTg4MjQzNDk5ZTRiYzgwNzI5ZWU1MzJkM2M2MTdlMDFmM2U3ODZlZDA1OQ");
|
|
|
|
|
|
warningRecord.setTimestamp(eventsVo.getTimestamp()); |
|
|
|
|
|
String objJsonStr = JSONUtil.toJsonStr(eventsVo.getObjects()); |
|
|
|
|
|
warningRecord.setRemark(objJsonStr); |
|
|
|
|
|
warningRecord.setTrackIds(trackIds); |
|
|
|
|
|
// System.out.println(JSONUtil.toJsonStr(eventsVo.getObjects()));
|
|
|
|
|
|
warningRecordList.add(warningRecord); |
|
|
|
|
|
} |
|
|
|
|
|
// sampleWarningRecordService.saveBatch(warningRecordList);
|
|
|
|
|
|
sampleWarningRecordMapper.insert(warningRecordList); |
|
|
|
|
|
|
|
|
|
|
|
/** WarningRecord转 businessAlert记录 **/ |
|
|
|
|
|
//保存数据到BusinessAlert
|
|
|
|
|
|
String activeProfile = "w_nantong"; |
|
|
|
|
|
ArrayList<RemoteBusinessAlertVo> alertVoList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
for (WarningRecordEntity warningRecordEntity : warningRecordList) { |
|
|
|
|
|
RemoteBusinessAlertVo remoteBusinessAlertVo = new RemoteBusinessAlertVo(); |
|
|
|
|
|
if(ObjectUtil.isEmpty(warningRecordEntity.getTaskId())){ continue;} //空数据跳过
|
|
|
|
|
|
|
|
|
|
|
|
setupLabelInfo(warningRecordEntity, remoteBusinessAlertVo);//设置标签信息
|
|
|
|
|
|
|
|
|
|
|
|
//查找最新任务TaskJob
|
|
|
|
|
|
LambdaQueryWrapper<TaskJobEntity> taskJobquery = new LambdaQueryWrapper<>(TaskJobEntity.class) |
|
|
|
|
|
.eq(TaskJobEntity::getTaskId, warningRecordEntity.getTaskId()) |
|
|
|
|
|
.orderByDesc(TaskJobEntity::getCreateTime) |
|
|
|
|
|
.last("limit 1"); |
|
|
|
|
|
TaskJobEntity taskJobEntity = taskJobMapper.selectOne(taskJobquery); |
|
|
|
|
|
|
|
|
|
|
|
String deviceSn = ""; |
|
|
|
|
|
if(BeanUtil.isNotEmpty(taskJobEntity)){ |
|
|
|
|
|
String jobId = taskJobEntity.getJobId(); |
|
|
|
|
|
deviceSn = taskJobEntity.getDeviceSn(); |
|
|
|
|
|
if(StrUtil.equals("-1",jobId)){ //没有jobId,给个默认名称
|
|
|
|
|
|
remoteBusinessAlertVo.setJobId("-1"); |
|
|
|
|
|
remoteBusinessAlertVo.setJobName("手动飞行" + "-" +remoteBusinessAlertVo.getLabelCn()+ DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss")); |
|
|
|
|
|
} else if(StrUtil.isNotEmpty(jobId)){ |
|
|
|
|
|
LambdaQueryWrapper<WaylineJobEntity> waylineJobQuery = new LambdaQueryWrapper<>(); |
|
|
|
|
|
waylineJobQuery.eq(WaylineJobEntity::getJobId,jobId); //jobId是unique唯一
|
|
|
|
|
|
WaylineJobEntity waylineJobEntity = waylineJobMapper.selectOne(waylineJobQuery); |
|
|
|
|
|
if(BeanUtil.isEmpty(waylineJobEntity)){continue;} //找不到航线-不处理预警
|
|
|
|
|
|
remoteBusinessAlertVo.setJobId(waylineJobEntity.getJobId()); |
|
|
|
|
|
remoteBusinessAlertVo.setJobName(waylineJobEntity.getName()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
remoteBusinessAlertVo.setLat(""); |
|
|
|
|
|
remoteBusinessAlertVo.setLng(""); |
|
|
|
|
|
if(StrUtil.isNotEmpty(deviceSn)){ |
|
|
|
|
|
Optional<DeviceDTO> deviceBySn = deviceService.getDeviceBySn(deviceSn); |
|
|
|
|
|
DeviceDTO deviceDTO = deviceBySn.isPresent() ? deviceBySn.get() : null; |
|
|
|
|
|
remoteBusinessAlertVo.setLat(deviceDTO.getLatitude()+ ""); //34.20912175973148
|
|
|
|
|
|
remoteBusinessAlertVo.setLng(deviceDTO.getLongitude()+ "");//117.2260332850499
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//预警基础信息扩展
|
|
|
|
|
|
// remoteBusinessAlertVo.setAlertType("1"); //1:图片比对预警 2:AI实时预警
|
|
|
|
|
|
remoteBusinessAlertVo.setAssign(false); |
|
|
|
|
|
String minioUrl = saveAliyunPreviewToMinio(warningRecordEntity.getPicUrl(),deviceSn, MinIOConstants.BUCKET_DKCY); |
|
|
|
|
|
remoteBusinessAlertVo.setImages(minioUrl); |
|
|
|
|
|
// remoteBusinessAlertVo.setMaxImages("");//mateFileUrl
|
|
|
|
|
|
// remoteBusinessAlertVo.setMateSourceImgUrl("");//mateFileUrl
|
|
|
|
|
|
remoteBusinessAlertVo.setTaskContent(""); |
|
|
|
|
|
remoteBusinessAlertVo.setHandleType("waiting"); |
|
|
|
|
|
// remoteBusinessAlertVo.setDeptId(aiCompareEntity.getCreateDept()+"");//暂时没有
|
|
|
|
|
|
// remoteBusinessAlertVo.setDeptName(aiCompareEntity.getDeptName());
|
|
|
|
|
|
remoteBusinessAlertVo.setHandleNum(0); |
|
|
|
|
|
//businessAlertConstructInfo数据
|
|
|
|
|
|
alertVoList.add(remoteBusinessAlertVo); |
|
|
|
|
|
} |
|
|
|
|
|
businessAlertService.saveBusinessAlert(alertVoList,activeProfile); //触发预警消息
|
|
|
|
|
|
|
|
|
|
|
|
return callBackVo.getEvents().size(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//基于算法名称赋值
|
|
|
|
|
|
private static void setupLabelInfo(WarningRecordEntity warningRecordEntity, RemoteBusinessAlertVo remoteBusinessAlertVo) { |
|
|
|
|
|
// String extraType = XingluoApiEnum.SAFETY_HARNESS.getExtraType();
|
|
|
|
|
|
switch (warningRecordEntity.getExtraType()){ |
|
|
|
|
|
case "2010_12": //秸秆焚烧 ------
|
|
|
|
|
|
remoteBusinessAlertVo.setLabelCn(XingluoApiEnum.FIRE.getTypeStr()); |
|
|
|
|
|
remoteBusinessAlertVo.setLabelEn(XingluoApiEnum.FIRE.getAiType()); |
|
|
|
|
|
break; |
|
|
|
|
|
case "2010_13": //烟火识别
|
|
|
|
|
|
remoteBusinessAlertVo.setLabelCn(XingluoApiEnum.FIREWORKS.getTypeStr()); |
|
|
|
|
|
remoteBusinessAlertVo.setLabelEn(XingluoApiEnum.FIREWORKS.getAiType()); |
|
|
|
|
|
break; |
|
|
|
|
|
case "2003_ext": //安全带预警 ------
|
|
|
|
|
|
remoteBusinessAlertVo.setLabelCn(XingluoApiEnum.SAFETY_HARNESS.getTypeStr()); |
|
|
|
|
|
remoteBusinessAlertVo.setLabelEn(XingluoApiEnum.SAFETY_HARNESS.getAiType()); |
|
|
|
|
|
break; |
|
|
|
|
|
case "2004_ext"://安全帽预警 -----
|
|
|
|
|
|
remoteBusinessAlertVo.setLabelCn(XingluoApiEnum.SAFETY_HELMET.getTypeStr()); |
|
|
|
|
|
remoteBusinessAlertVo.setLabelEn(XingluoApiEnum.SAFETY_HELMET.getAiType()); |
|
|
|
|
|
break; |
|
|
|
|
|
case "2010_24"://路面车辆计数
|
|
|
|
|
|
remoteBusinessAlertVo.setLabelCn(XingluoApiEnum.CARCOUNT.getTypeStr()); |
|
|
|
|
|
remoteBusinessAlertVo.setLabelEn(XingluoApiEnum.CARCOUNT.getAiType()); |
|
|
|
|
|
break; |
|
|
|
|
|
case "2010_5"://多类型车辆计数
|
|
|
|
|
|
remoteBusinessAlertVo.setLabelCn(XingluoApiEnum.CARCOUNTMULTITYPE.getTypeStr()); |
|
|
|
|
|
remoteBusinessAlertVo.setLabelEn(XingluoApiEnum.CARCOUNTMULTITYPE.getAiType()); |
|
|
|
|
|
break; |
|
|
|
|
|
case "2010_6"://多类型车辆拥堵聚集
|
|
|
|
|
|
remoteBusinessAlertVo.setLabelCn(XingluoApiEnum.CARMULTITYPEJAM.getTypeStr()); |
|
|
|
|
|
remoteBusinessAlertVo.setLabelEn(XingluoApiEnum.CARMULTITYPEJAM.getAiType()); |
|
|
|
|
|
break; |
|
|
|
|
|
case "2010_29": //无人机安全帽检测 ------
|
|
|
|
|
|
remoteBusinessAlertVo.setLabelCn(XingluoApiEnum.SAFETY_HELMET_NEW.getTypeStr());//安全帽预警-新
|
|
|
|
|
|
remoteBusinessAlertVo.setLabelEn(XingluoApiEnum.SAFETY_HELMET_NEW.getAiType()); //SafetyHelmet
|
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String saveAliyunPreviewToMinio(String aliyunUrl,String deviceSn, String minioBucket) { |
|
|
|
|
|
try { |
|
|
|
|
|
URL url = new URL(aliyunUrl); |
|
|
|
|
|
URLConnection conn = url.openConnection(); |
|
|
|
|
|
conn.setConnectTimeout(3_500); |
|
|
|
|
|
conn.setReadTimeout(3_500); |
|
|
|
|
|
InputStream inputStream = conn.getInputStream(); |
|
|
|
|
|
long fileSize = conn.getContentLengthLong(); |
|
|
|
|
|
|
|
|
|
|
|
String fileName = FileUtil.getName(url.getPath()); |
|
|
|
|
|
String path = url.getPath().replace(fileName, deviceSn+ fileName); // eg: /ai/report/29847/{deviceSn+xxx.jpg}
|
|
|
|
|
|
String originalFileName = path.substring(path.lastIndexOf("/") + 1); // qwfbGaBixI.jpg
|
|
|
|
|
|
String suffix = originalFileName.contains(".") ? originalFileName.substring(originalFileName.lastIndexOf(".")) : ".jpg"; // fallback
|
|
|
|
|
|
|
|
|
|
|
|
// String newFileName = IdUtils.fastUUID() + suffix;
|
|
|
|
|
|
OssClient minioClient = OssFactory.instance(minioBucket); |
|
|
|
|
|
UploadResult result = minioClient.upload(inputStream, path, fileSize, MimeTypeUtils.IMAGE_JPG); |
|
|
|
|
|
// MinioUtil.uploadFile(path,inputStream,);
|
|
|
|
|
|
|
|
|
|
|
|
inputStream.close(); |
|
|
|
|
|
return path; // 返回 MinIO 的访问地址
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
throw new RuntimeException("上传图片失败", e); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String PostRequest( JSONObject jsonObj, String url, String token |
|
|
//通用提交
|
|
|
) { |
|
|
public String PostRequest( JSONObject jsonObj, String url, String token) { |
|
|
try (CloseableHttpClient httpClient = HttpClients.createDefault()) { |
|
|
try (CloseableHttpClient httpClient = HttpClients.createDefault()) { |
|
|
// 1. 创建POST请求对象
|
|
|
// 1. 创建POST请求对象
|
|
|
HttpPost post = new HttpPost(url); |
|
|
HttpPost post = new HttpPost(url); |
|
@ -301,8 +537,7 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public String GetRequest(URI uri, String token |
|
|
public String GetRequest(URI uri, String token) { |
|
|
) { |
|
|
|
|
|
try (CloseableHttpClient httpClient = HttpClients.createDefault()) { |
|
|
try (CloseableHttpClient httpClient = HttpClients.createDefault()) { |
|
|
// URI uri = new URIBuilder("https://api.example.com/data")
|
|
|
// URI uri = new URIBuilder("https://api.example.com/data")
|
|
|
// .addParameter("param1", "value1")
|
|
|
// .addParameter("param1", "value1")
|
|
|