|
@@ -5,7 +5,6 @@ import cn.reghao.jutil.jdk.converter.DateTimeConverter;
|
|
|
import cn.reghao.jutil.jdk.db.Page;
|
|
import cn.reghao.jutil.jdk.db.Page;
|
|
|
import cn.reghao.jutil.jdk.result.Result;
|
|
import cn.reghao.jutil.jdk.result.Result;
|
|
|
import cn.reghao.jutil.tool.id.SnowFlake;
|
|
import cn.reghao.jutil.tool.id.SnowFlake;
|
|
|
-import cn.reghao.oss.sdk.model.dto.ObjectInfo;
|
|
|
|
|
import cn.reghao.oss.sdk.model.dto.media.ImageInfo;
|
|
import cn.reghao.oss.sdk.model.dto.media.ImageInfo;
|
|
|
import cn.reghao.oss.sdk.model.dto.media.VideoInfo;
|
|
import cn.reghao.oss.sdk.model.dto.media.VideoInfo;
|
|
|
import cn.reghao.tnb.common.auth.UserContext;
|
|
import cn.reghao.tnb.common.auth.UserContext;
|
|
@@ -20,7 +19,6 @@ import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
@@ -32,6 +30,7 @@ import java.util.stream.Collectors;
|
|
|
public class CamRecordService {
|
|
public class CamRecordService {
|
|
|
@DubboReference(check = false, timeout = 60_000)
|
|
@DubboReference(check = false, timeout = 60_000)
|
|
|
private OssService ossService;
|
|
private OssService ossService;
|
|
|
|
|
+ private int channelCode = 107;
|
|
|
|
|
|
|
|
private final SnowFlake idGenerator;
|
|
private final SnowFlake idGenerator;
|
|
|
private final CamDeviceMapper camDeviceMapper;
|
|
private final CamDeviceMapper camDeviceMapper;
|
|
@@ -95,7 +94,7 @@ public class CamRecordService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 一个天中的监控记录
|
|
|
|
|
|
|
+ * 获取某天的监控录像
|
|
|
*
|
|
*
|
|
|
* @param dayStr 2024-08-31 格式的字符串
|
|
* @param dayStr 2024-08-31 格式的字符串
|
|
|
* @return
|
|
* @return
|
|
@@ -106,32 +105,13 @@ public class CamRecordService {
|
|
|
return list.stream().map(CamRecordInfo::new).collect(Collectors.toList());
|
|
return list.stream().map(CamRecordInfo::new).collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public CamRecordVo getCamRecord(long recordId) {
|
|
|
|
|
- try {
|
|
|
|
|
- CamRecord camRecord = camRecordMapper.findByRecordId(recordId);
|
|
|
|
|
- if (camRecord != null) {
|
|
|
|
|
- String recordTime = DateTimeConverter.format(camRecord.getStartAt());
|
|
|
|
|
- String coverUrl = camRecord.getCoverUrl();
|
|
|
|
|
- String videoFileId = camRecord.getVideoFileId();
|
|
|
|
|
- ObjectInfo diskFile = ossService.getObjectInfo(111, videoFileId);
|
|
|
|
|
- if (diskFile != null) {
|
|
|
|
|
- long loginUser = UserContext.getUserId();
|
|
|
|
|
- /*long owner = diskFile.getOwner();
|
|
|
|
|
- if (loginUser == owner) {
|
|
|
|
|
- String videoUrl = String.format("/%s", diskFile.getObjectName());
|
|
|
|
|
- return new CamRecordVo(camRecord.getCamId(), recordId, recordTime, coverUrl, videoUrl);
|
|
|
|
|
- }*/
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return null;
|
|
|
|
|
|
|
+ public CamRecordDetail getCamRecord(long recordId) {
|
|
|
|
|
+ CamRecord camRecord = camRecordMapper.findByRecordId(recordId);
|
|
|
|
|
+ return camRecord == null ? null : getCamRecordDetail(camRecord);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 一个月中的哪些天有监控记录
|
|
|
|
|
|
|
+ * 某月中的哪些天有监控录像
|
|
|
*
|
|
*
|
|
|
* @param yearMonth 2024-08 格式的字符串
|
|
* @param yearMonth 2024-08 格式的字符串
|
|
|
* @return
|
|
* @return
|
|
@@ -146,51 +126,35 @@ public class CamRecordService {
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private List<String> findByYearMonth(long camId, String yearMonth) {
|
|
|
|
|
- /*Specification<CamRecord> specification = (root, query, cb) -> {
|
|
|
|
|
- Predicate fp = cb.conjunction();
|
|
|
|
|
- Predicate p1 = cb.equal(root.get("camId").as(Long.class), camId);
|
|
|
|
|
- fp = cb.and(fp, p1);
|
|
|
|
|
- return query.where(fp).groupBy(root.get("startAt")).getRestriction();
|
|
|
|
|
- };
|
|
|
|
|
- camRecordMapper.findAll(specification);*/
|
|
|
|
|
- return Collections.emptyList();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Deprecated
|
|
|
|
|
- public CamRecordVo getLatestRecord(long camId) {
|
|
|
|
|
|
|
+ public CamRecordDetail getLatestRecord(long camId) {
|
|
|
|
|
+ long loginUser = UserContext.getUserId();
|
|
|
CamDeviceQuery camDeviceQuery = new CamDeviceQuery.Builder()
|
|
CamDeviceQuery camDeviceQuery = new CamDeviceQuery.Builder()
|
|
|
.camId(camId)
|
|
.camId(camId)
|
|
|
|
|
+ .owner(loginUser)
|
|
|
.build();
|
|
.build();
|
|
|
- Page page = new Page(1, 10);
|
|
|
|
|
|
|
+ Page page = new Page(1, 1);
|
|
|
List<CamDevice> camDeviceList = camDeviceMapper.findCamDeviceQueryByPage(page, camDeviceQuery);
|
|
List<CamDevice> camDeviceList = camDeviceMapper.findCamDeviceQueryByPage(page, camDeviceQuery);
|
|
|
CamDevice camDevice = camDeviceList.get(0);
|
|
CamDevice camDevice = camDeviceList.get(0);
|
|
|
if (camDevice.getState()) {
|
|
if (camDevice.getState()) {
|
|
|
- String videoUrl = camDevice.getPullUrl();
|
|
|
|
|
- CamUrl camUrl = new CamUrl(videoUrl, true);
|
|
|
|
|
|
|
+ String liveUrl = camDevice.getPullUrl();
|
|
|
|
|
+ CamUrl camUrl = new CamUrl(liveUrl, true);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //PageRequest pageRequest = PageRequest.of(0, 1, Sort.by(Sort.Direction.DESC, "createTime"));
|
|
|
|
|
- List<CamRecord> camRecordList = camRecordMapper.findByCamId(camId, page);
|
|
|
|
|
- if (camRecordList.isEmpty()) {
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ CamRecord camRecord = camRecordMapper.findLatestRecord(camId);
|
|
|
|
|
+ return camRecord == null ? null : getCamRecordDetail(camRecord);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- CamRecord camRecord = camRecordList.get(0);
|
|
|
|
|
|
|
+ private CamRecordDetail getCamRecordDetail(CamRecord camRecord) {
|
|
|
String recordTime = DateTimeConverter.format(camRecord.getStartAt());
|
|
String recordTime = DateTimeConverter.format(camRecord.getStartAt());
|
|
|
long recordId = camRecord.getRecordId();
|
|
long recordId = camRecord.getRecordId();
|
|
|
- String coverUrl = camRecord.getCoverUrl();
|
|
|
|
|
String videoFileId = camRecord.getVideoFileId();
|
|
String videoFileId = camRecord.getVideoFileId();
|
|
|
-
|
|
|
|
|
- /*ObjectInfo diskFile = ossService.getObjectInfo(111, videoFileId);
|
|
|
|
|
- if (diskFile != null) {
|
|
|
|
|
- long loginUser = UserContext.getUserId();
|
|
|
|
|
- long owner = diskFile.getOwner();
|
|
|
|
|
- if (loginUser == owner) {
|
|
|
|
|
- String videoUrl = String.format("/%s", diskFile.getObjectName());
|
|
|
|
|
- return new CamRecordVo(camRecord.getCamId(), recordId, recordTime, coverUrl, videoUrl);
|
|
|
|
|
- }
|
|
|
|
|
- }*/
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ String signedUrl = ossService.getSignedUrlByUrl(channelCode, videoFileId);
|
|
|
|
|
+ CamUrl camUrl = new CamUrl(signedUrl);
|
|
|
|
|
+ return new CamRecordDetail(camRecord.getCamId(), recordId, recordTime, camUrl);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|