|
@@ -6,7 +6,6 @@ import com.hikvision.artemis.sdk.ArtemisHttpUtil;
|
|
|
import com.hikvision.artemis.sdk.config.ArtemisConfig;
|
|
|
import com.zfjg.common.core.constant.GlobalConstant;
|
|
|
import com.zfjg.common.core.utils.DateUtils;
|
|
|
-import com.zfjg.common.core.utils.IdGenerator;
|
|
|
import com.zfjg.common.core.utils.SpringUtils;
|
|
|
import com.zfjg.common.core.utils.StringUtils;
|
|
|
import com.zfjg.common.redis.service.RedisService;
|
|
@@ -20,13 +19,12 @@ import com.zfjg.manage.mapper.sys.SysPullLogMapper;
|
|
|
import com.zfjg.manage.service.device.IDeviceService;
|
|
|
import com.zfjg.manage.service.enforce.video.IEnforceVideoHkResService;
|
|
|
import com.zfjg.manage.service.enforce.video.IEnforceVideoService;
|
|
|
-import com.zfjg.manage.utils.LoggerUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.slf4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
@@ -34,7 +32,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.*;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -45,9 +44,6 @@ import java.util.stream.Collectors;
|
|
|
* 海康平台,同步视频列表
|
|
|
*/
|
|
|
public class DataShareVeidoListClient {
|
|
|
-
|
|
|
- private static final Logger LOGGER = LoggerUtils.getLogger(LoggerUtils.PatrolLoggerType.HIK_DATA_SYNC_LOG);
|
|
|
-
|
|
|
@Value("${hikvision.host}")
|
|
|
private String host;
|
|
|
|
|
@@ -89,7 +85,7 @@ public class DataShareVeidoListClient {
|
|
|
// @Scheduled(cron = "* 0/1 * * * ?")
|
|
|
public void rsyncVediosData() {
|
|
|
if (isopen) {
|
|
|
- LOGGER.info("同步视频数据开始");
|
|
|
+ log.info("同步视频数据开始");
|
|
|
List<Device> devices = deviceRepository.getBaseMapper().selectList(new QueryWrapper<Device>().lambda()
|
|
|
.eq(Device::getIsDeleted, 0));
|
|
|
if (StringUtils.isEmpty(devices)) {
|
|
@@ -114,7 +110,7 @@ public class DataShareVeidoListClient {
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
- LOGGER.info("同步视频数据已关闭");
|
|
|
+ log.info("同步视频数据已关闭");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -122,7 +118,7 @@ public class DataShareVeidoListClient {
|
|
|
@Scheduled(cron = "${fire.corn.datashare-vedio-rsync.time}")
|
|
|
public void pageRsyncVideoData_v2() {
|
|
|
if (!isopen) {
|
|
|
- LOGGER.info("同步视频数据已关闭");
|
|
|
+ log.info("同步视频数据已关闭");
|
|
|
return;
|
|
|
}
|
|
|
/**
|
|
@@ -161,7 +157,7 @@ public class DataShareVeidoListClient {
|
|
|
|
|
|
|
|
|
String body = json.toJSONString();
|
|
|
- LOGGER.info("requset={}", body);
|
|
|
+ log.info("requset={}", body);
|
|
|
|
|
|
/**
|
|
|
* STEP6:调用接口
|
|
@@ -210,8 +206,9 @@ public class DataShareVeidoListClient {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public void run() {
|
|
|
- System.out.println("线程:" + Thread.currentThread().getName() + " , 开始读取数据------");
|
|
|
+ log.info("线程:" + Thread.currentThread().getName() + " , 开始读取数据------");
|
|
|
SysPullLog sysPullLog = new SysPullLog();
|
|
|
sysPullLog.setType("video");
|
|
|
sysPullLog.setRunTime(DateUtils.getNowDate());
|
|
@@ -219,18 +216,18 @@ public class DataShareVeidoListClient {
|
|
|
long start = System.currentTimeMillis();
|
|
|
JSONObject result = JSONObject.parseObject(ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType, null));// post请求application/json类型参数
|
|
|
if (!"0".equals(result.getString("code"))) {
|
|
|
- LOGGER.error("根据监控点列表查询录像完整性结果出错");
|
|
|
+ log.error("根据监控点列表查询录像完整性结果出错");
|
|
|
sysPullLog.setState(1L);
|
|
|
sysPullLog.setExceptJson(result.getString("msg"));
|
|
|
sysPullLogMapper.insert(sysPullLog);
|
|
|
return;
|
|
|
}
|
|
|
sysPullLogMapper.insert(sysPullLog);
|
|
|
- System.out.println("线程:" + Thread.currentThread().getName() + " , 读取数据耗时 :" + (System.currentTimeMillis() - start) + "ms");
|
|
|
+ log.info("线程:" + Thread.currentThread().getName() + " , 读取数据耗时 :" + (System.currentTimeMillis() - start) + "ms");
|
|
|
List<EnforceVideoHkRes> enforceVideoHkRes = result.getJSONObject("data").getJSONArray("list").toJavaList(EnforceVideoHkRes.class);
|
|
|
enforceVideoHkRes.stream().forEach(t -> {
|
|
|
t.setSysPullId(sysPullLog.getId());
|
|
|
- String serialNo =t.getRecorderCode();
|
|
|
+ String serialNo = t.getRecorderCode();
|
|
|
Device deviceOptional = deviceRepository.getBaseMapper()
|
|
|
.selectOne(new QueryWrapper<Device>()
|
|
|
.lambda()
|
|
@@ -241,46 +238,49 @@ public class DataShareVeidoListClient {
|
|
|
/**
|
|
|
* 视频时间取takeTimeString,时长取duration
|
|
|
*/
|
|
|
- Date takeTime = t.getTakeTimeString();
|
|
|
- Integer duration = t.getDuration();
|
|
|
- if (takeTime != null) {
|
|
|
- EnforceVideo video = enforceVideoRepository.getBaseMapper()
|
|
|
- .selectOne(new QueryWrapper<EnforceVideo>().lambda()
|
|
|
- .eq(EnforceVideo::getMediaId, t.getMediaId())
|
|
|
- //放开筛选条件,前端删除视频会有视频重复出现的情况
|
|
|
- //.eq(EnforceVideo::getIsDeleted, 0)
|
|
|
- .last("LIMIT 1"));
|
|
|
- if (Objects.isNull(video)) {
|
|
|
- String yyMMdd = DateUtils.getDay(takeTime, DateUtils.DATETIME_FORMAT_DAY3);
|
|
|
- EnforceVideo enforceVideo = new EnforceVideo();
|
|
|
- enforceVideo.setMediaId(t.getMediaId());
|
|
|
- enforceVideo.setCameraIndexCode(deviceOptional.getCameraIndexCode());
|
|
|
- enforceVideo.setDeviceId(deviceOptional.getId());
|
|
|
- enforceVideo.setDeviceName(deviceOptional.getDeviceName());
|
|
|
- enforceVideo.setSerialNo(serialNo);
|
|
|
- enforceVideo.setVideoName(yyMMdd);
|
|
|
- enforceVideo.setDeviceIndexCode(deviceOptional.getDeviceIndexCode());
|
|
|
- enforceVideo.setVideoBeginTime(takeTime);
|
|
|
- enforceVideo.setVideoEndTime(new Date((takeTime.getTime() / 1000 + duration) * 1000));
|
|
|
- enforceVideo.setThumbnailUrl(t.getThumbnailUrl());
|
|
|
- enforceVideo.setEnforceOrgId(deviceOptional.getEnforceOrgId());
|
|
|
- enforceVideo.setEnforceOrgName(deviceOptional.getEnforceOrgName());
|
|
|
- enforceVideo.setUsePersonName(deviceOptional.getUsePersonName());
|
|
|
- enforceVideo.setUsePersonId(deviceOptional.getUsePersonId());
|
|
|
-
|
|
|
- enforceVideoRepository.save(enforceVideo);
|
|
|
- //将视频绑定到任务上
|
|
|
- videoBindJobService.bindVideo2JobById(enforceVideo.getId());
|
|
|
- } else {
|
|
|
- LOGGER.info("该视频片段已存在,hikDeviceId={},takeTime={},duration={},MediaId = {}", serialNo, takeTime, duration, t.getMediaId());
|
|
|
- t.setState(1);
|
|
|
- }
|
|
|
+ Date takeTime = t.getTakeTimeString();
|
|
|
+ Integer duration = t.getDuration();
|
|
|
+ if (takeTime != null) {
|
|
|
+ EnforceVideo video = enforceVideoRepository.getBaseMapper()
|
|
|
+ .selectOne(new QueryWrapper<EnforceVideo>().lambda()
|
|
|
+ .eq(EnforceVideo::getMediaId, t.getMediaId())
|
|
|
+ //放开筛选条件,前端删除视频会有视频重复出现的情况
|
|
|
+ //.eq(EnforceVideo::getIsDeleted, 0)
|
|
|
+ .last("LIMIT 1"));
|
|
|
+ if (Objects.isNull(video)) {
|
|
|
+ String yyMMdd = DateUtils.getDay(takeTime, DateUtils.DATETIME_FORMAT_DAY3);
|
|
|
+ EnforceVideo enforceVideo = new EnforceVideo();
|
|
|
+ enforceVideo.setMediaId(t.getMediaId());
|
|
|
+ enforceVideo.setCameraIndexCode(deviceOptional.getCameraIndexCode());
|
|
|
+ enforceVideo.setDeviceId(deviceOptional.getId());
|
|
|
+ enforceVideo.setDeviceName(deviceOptional.getDeviceName());
|
|
|
+ enforceVideo.setSerialNo(serialNo);
|
|
|
+ enforceVideo.setVideoName(yyMMdd);
|
|
|
+ enforceVideo.setDeviceIndexCode(deviceOptional.getDeviceIndexCode());
|
|
|
+ enforceVideo.setVideoBeginTime(takeTime);
|
|
|
+ enforceVideo.setVideoEndTime(new Date((takeTime.getTime() / 1000 + duration) * 1000));
|
|
|
+ enforceVideo.setThumbnailUrl(t.getThumbnailUrl());
|
|
|
+ enforceVideo.setEnforceOrgId(deviceOptional.getEnforceOrgId());
|
|
|
+ enforceVideo.setEnforceOrgName(deviceOptional.getEnforceOrgName());
|
|
|
+ enforceVideo.setUsePersonName(deviceOptional.getUsePersonName());
|
|
|
+ enforceVideo.setVideoType("master");
|
|
|
+ enforceVideo.setFileId(1L);
|
|
|
+ enforceVideo.setDuration(1L);
|
|
|
+ enforceVideo.setUsePersonId(deviceOptional.getUsePersonId());
|
|
|
+ enforceVideo.setTimeOut(0);
|
|
|
+ enforceVideoRepository.save(enforceVideo);
|
|
|
+ //将视频绑定到任务上
|
|
|
+ videoBindJobService.bindVideo2JobById(enforceVideo.getId());
|
|
|
} else {
|
|
|
- LOGGER.info("任务时间为空!,hikDeviceId={},格式为={},MediaId = {}", serialNo, t.getFileType(), t.getMediaId());
|
|
|
- t.setState(2);
|
|
|
+ log.info("该视频片段已存在,hikDeviceId={},takeTime={},duration={},MediaId = {}", serialNo, takeTime, duration, t.getMediaId());
|
|
|
+ t.setState(1);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ log.info("任务时间为空!,hikDeviceId={},格式为={},MediaId = {}", serialNo, t.getFileType(), t.getMediaId());
|
|
|
+ t.setState(2);
|
|
|
+ }
|
|
|
} else {
|
|
|
- LOGGER.warn("设备:serialNo:[{}]不存在!", serialNo);
|
|
|
+ log.warn("设备:serialNo:[{}]不存在!", serialNo);
|
|
|
t.setState(3);
|
|
|
}
|
|
|
});
|
|
@@ -322,7 +322,7 @@ public class DataShareVeidoListClient {
|
|
|
* STEP5:组装请求参数
|
|
|
*/
|
|
|
String body = JSONObject.toJSONString(shareVideoListRequest);
|
|
|
- LOGGER.info("同步视频数据请求参数,request={}", shareVideoListRequest);
|
|
|
+ log.info("同步视频数据请求参数,request={}", shareVideoListRequest);
|
|
|
|
|
|
/**
|
|
|
* STEP6:调用接口
|
|
@@ -330,13 +330,13 @@ public class DataShareVeidoListClient {
|
|
|
JSONObject result = JSONObject.parseObject(ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType, null));// post请求application/json类型参数
|
|
|
DataShareVideoListResponse response = JSONObject.toJavaObject(result, DataShareVideoListResponse.class);
|
|
|
if (!"0".equals(response.getCode())) {
|
|
|
- LOGGER.error("根据监控点列表查询录像完整性结果出错,[{}]", shareVideoListRequest.getRecorderCode());
|
|
|
+ log.error("根据监控点列表查询录像完整性结果出错,[{}]", shareVideoListRequest.getRecorderCode());
|
|
|
return;
|
|
|
}
|
|
|
-// LOGGER.info("同步视频数据,接口返回数据,result={}", result);
|
|
|
+// log.info("同步视频数据,接口返回数据,result={}", result);
|
|
|
shareVideoListRequest.setTotal(response.getData().getTotal());
|
|
|
long mp4Total = response.getData().getList().stream().filter(s -> "mp4".equals(s.getFileType())).count();
|
|
|
- LOGGER.info("同步视频数据响应数据,serial_no={},total={}", shareVideoListRequest.getRecorderCode(), mp4Total);
|
|
|
+ log.info("同步视频数据响应数据,serial_no={},total={}", shareVideoListRequest.getRecorderCode(), mp4Total);
|
|
|
response.getData().getList().forEach(t -> {
|
|
|
String serialNo = t.getRecorderCode();
|
|
|
List<Device> deviceList = deviceRepository.getBaseMapper().selectList(new QueryWrapper<Device>().lambda().eq(Device::getSerialNo, serialNo).orderByDesc(Device::getIsDeleted));
|
|
@@ -377,15 +377,15 @@ public class DataShareVeidoListClient {
|
|
|
//将视频绑定到任务上
|
|
|
videoBindJobService.bindVideo2JobById(enforceVideo.getId());
|
|
|
} else {
|
|
|
- LOGGER.info("该视频片段已存在,hikDeviceId={},takeTime={},duration={},MediaId = {}", serialNo, takeTime, duration, t.getMediaId());
|
|
|
+ log.info("该视频片段已存在,hikDeviceId={},takeTime={},duration={},MediaId = {}", serialNo, takeTime, duration, t.getMediaId());
|
|
|
}
|
|
|
} else {
|
|
|
- LOGGER.info("该视频片段格式不是MP4,hikDeviceId={},格式为={},MediaId = {}", serialNo, t.getFileType(), t.getMediaId());
|
|
|
+ log.info("该视频片段格式不是MP4,hikDeviceId={},格式为={},MediaId = {}", serialNo, t.getFileType(), t.getMediaId());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
} else {
|
|
|
- LOGGER.warn("设备:serialNo:[{}]不存在!", serialNo);
|
|
|
+ log.warn("设备:serialNo:[{}]不存在!", serialNo);
|
|
|
}
|
|
|
});
|
|
|
//判断是否最后一页,否则进行再次查询下一页
|
|
@@ -430,7 +430,7 @@ public class DataShareVeidoListClient {
|
|
|
* STEP5:组装请求参数
|
|
|
*/
|
|
|
String body = JSONObject.toJSONString(shareVideoListRequest);
|
|
|
- LOGGER.info("同步视频数据请求参数,request={}", shareVideoListRequest);
|
|
|
+ log.info("同步视频数据请求参数,request={}", shareVideoListRequest);
|
|
|
|
|
|
/**
|
|
|
* STEP6:调用接口
|
|
@@ -440,7 +440,7 @@ public class DataShareVeidoListClient {
|
|
|
if (!"0".equals(response.getCode())) {
|
|
|
log.error("根据监控点列表查询录像完整性结果出错,[{}]", shareVideoListRequest.toString());
|
|
|
}
|
|
|
-// LOGGER.info("同步视频数据,接口返回数据,result={}", result);
|
|
|
+// log.info("同步视频数据,接口返回数据,result={}", result);
|
|
|
shareVideoListRequest.setTotal(response.getData().getTotal());
|
|
|
List<DataShareVideoListResponse.Result.DataNode> list = response.getData().getList();
|
|
|
for (DataShareVideoListResponse.Result.DataNode t : list) {
|
|
@@ -455,7 +455,7 @@ public class DataShareVeidoListClient {
|
|
|
device = one;
|
|
|
redisService.setCacheObject(GlobalConstant.ENFORCE_DEVICE + serialNo, JSONObject.toJSONString(device), 1l, TimeUnit.DAYS);
|
|
|
} else {
|
|
|
- LOGGER.warn("设备:serialNo:[{}]不存在!", serialNo);
|
|
|
+ log.warn("设备:serialNo:[{}]不存在!", serialNo);
|
|
|
continue;
|
|
|
}
|
|
|
} else {
|
|
@@ -495,19 +495,19 @@ public class DataShareVeidoListClient {
|
|
|
//将视频绑定到任务上
|
|
|
videoBindJobService.bindVideo2JobById(enforceVideo.getId());
|
|
|
} else {
|
|
|
- LOGGER.info("该视频片段已存在,hikDeviceId={},takeTime={},duration={},MediaId = {}", serialNo, takeTime, duration, t.getMediaId());
|
|
|
+ log.info("该视频片段已存在,hikDeviceId={},takeTime={},duration={},MediaId = {}", serialNo, takeTime, duration, t.getMediaId());
|
|
|
}
|
|
|
} else {
|
|
|
- LOGGER.info("该视频片段格式不是MP4,hikDeviceId={},格式为={},MediaId = {}", serialNo, t.getFileType(), t.getMediaId());
|
|
|
+ log.info("该视频片段格式不是MP4,hikDeviceId={},格式为={},MediaId = {}", serialNo, t.getFileType(), t.getMediaId());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
// long mp4Total = response.getData().getList().stream().filter(s -> "mp4".equals(s.getFileType())).count();
|
|
|
-// LOGGER.info("同步视频数据响应数据,page={},total={}", shareVideoListRequest.getPageNo(), mp4Total);
|
|
|
+// log.info("同步视频数据响应数据,page={},total={}", shareVideoListRequest.getPageNo(), mp4Total);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
- LOGGER.error("根据监控点列表查询录像完整性结果出错,[{}]", shareVideoListRequest.toString());
|
|
|
+ log.error("根据监控点列表查询录像完整性结果出错,[{}]", shareVideoListRequest.toString());
|
|
|
}
|
|
|
|
|
|
}
|