refactor(device): 重构设备配置获取逻辑

- 在 ViidController 中添加获取 DeviceConfigEntity 的逻辑
- 在 VideoPieceGetter 中使用 DeviceConfigManager 替代 DeviceConfigEntity
- 优化设备配置参数的获取方式,使用 getBigDecimal 和 getString 方法
- 移除未使用的代码片段,提高代码可读性
This commit is contained in:
2025-09-03 17:32:14 +08:00
parent 982e9180f1
commit 9a086fc86d
2 changed files with 44 additions and 51 deletions

View File

@@ -257,23 +257,15 @@ public class VideoPieceGetter {
private boolean doCut(Long deviceId, Long faceSampleId, Date baseTime, Task task) {
DeviceEntity device = deviceRepository.getDevice(deviceId);
DeviceConfigEntity config = deviceRepository.getDeviceConfig(deviceId);
DeviceConfigManager config = deviceRepository.getDeviceConfigManager(deviceId);
DeviceConfigEntity dConfig = deviceRepository.getDeviceConfig(deviceId);
SourceEntity source = sourceMapper.querySameVideo(faceSampleId, device.getId());
if (source == null || task.force) {
BigDecimal cutPre = BigDecimal.valueOf(5L);
BigDecimal cutPost = BigDecimal.valueOf(4L);
if (config != null) {
// 有配置
if (config.getCutPre() != null) {
cutPre = config.getCutPre();
}
if (config.getCutPost() != null) {
cutPost = config.getCutPost();
}
}
IDeviceStorageOperator pieceGetter = DeviceFactory.getDeviceStorageOperator(device, config);
BigDecimal cutPre = config.getBigDecimal("cut_pre", BigDecimal.valueOf(5L));
BigDecimal cutPost = config.getBigDecimal("cut_post", BigDecimal.valueOf(5L));
IDeviceStorageOperator pieceGetter = DeviceFactory.getDeviceStorageOperator(device, dConfig);
if (pieceGetter == null) {
return false;
}
@@ -319,8 +311,8 @@ public class VideoPieceGetter {
sourceEntity.setUrl(imgSource.getUrl());
sourceEntity.setPosJson(imgSource.getPosJson());
}
if (StringUtils.isNotBlank(config.getVideoCrop())) {
sourceEntity.setPosJson(config.getVideoCrop());
if (StringUtils.isNotBlank(config.getString("video_crop"))) {
sourceEntity.setPosJson(config.getString("video_crop"));
}
sourceEntity.setVideoUrl(url);
sourceEntity.setFaceSampleId(faceSampleId);
@@ -348,8 +340,8 @@ public class VideoPieceGetter {
videoReUploader.addTask(sourceEntity.getId());
} else {
source.setVideoUrl(url);
if (StringUtils.isNotBlank(config.getVideoCrop())) {
source.setPosJson(config.getVideoCrop());
if (StringUtils.isNotBlank(config.getString("video_crop"))) {
source.setPosJson(config.getString("video_crop"));
}
sourceMapper.update(source);
videoReUploader.addTask(source.getId());