You've already forked FrameTour-BE
feat(device): 集成 zt-device 服务
- 移除 DeviceController、DeviceService 相关代码 - 更新 ViidController、WvpController 使用 DeviceIntegrationService - 修改 DeviceFactory 创建 DeviceEntity 的方式 - 更新 DeviceRepository 使用 DeviceV2DTO -调整 CustomUploadTaskService、AppScenicServiceImpl 中的设备相关逻辑 - 移除 DeviceServiceImpl 类 - 更新 VideoPieceCleaner、VideoPieceGetter 任务类,使用 DeviceIntegrationService 获取设备信息
This commit is contained in:
@@ -16,6 +16,8 @@ import com.ycwl.basic.mapper.FaceSampleMapper;
|
||||
import com.ycwl.basic.mapper.SourceMapper;
|
||||
import com.ycwl.basic.model.mobile.order.IsBuyRespVO;
|
||||
import com.ycwl.basic.model.pc.device.entity.DeviceConfigEntity;
|
||||
import com.ycwl.basic.integration.device.service.DeviceIntegrationService;
|
||||
import com.ycwl.basic.integration.device.dto.device.DeviceV2DTO;
|
||||
import com.ycwl.basic.model.pc.device.entity.DeviceEntity;
|
||||
import com.ycwl.basic.model.pc.source.entity.MemberSourceEntity;
|
||||
import com.ycwl.basic.model.pc.source.entity.SourceEntity;
|
||||
@@ -77,6 +79,8 @@ public class VideoPieceGetter {
|
||||
private VideoReUploader videoReUploader;
|
||||
@Autowired
|
||||
private ScenicRepository scenicRepository;
|
||||
@Autowired
|
||||
private DeviceIntegrationService deviceIntegrationService;
|
||||
|
||||
@Data
|
||||
public static class Task {
|
||||
@@ -145,7 +149,7 @@ public class VideoPieceGetter {
|
||||
Map<Long, Long> pairDeviceMap = new ConcurrentHashMap<>();
|
||||
if (!list.isEmpty()) {
|
||||
Long scenicId = list.getFirst().getScenicId();
|
||||
List<DeviceEntity> allDeviceByScenicId = deviceRepository.getAllDeviceByScenicId(scenicId);
|
||||
List<DeviceV2DTO> allDeviceByScenicId = deviceRepository.getAllDeviceByScenicId(scenicId);
|
||||
allDeviceByScenicId.forEach(device -> {
|
||||
Long deviceId = device.getId();
|
||||
DeviceConfigManager deviceConfig = deviceRepository.getDeviceConfigManager(deviceId);
|
||||
@@ -256,16 +260,21 @@ public class VideoPieceGetter {
|
||||
}
|
||||
|
||||
private boolean doCut(Long deviceId, Long faceSampleId, Date baseTime, Task task) {
|
||||
DeviceEntity device = deviceRepository.getDevice(deviceId);
|
||||
// 通过zt-device服务获取设备信息
|
||||
DeviceV2DTO deviceV2 = deviceIntegrationService.getDevice(deviceId);
|
||||
if (deviceV2 == null) {
|
||||
log.warn("设备不存在,设备ID: {}", deviceId);
|
||||
return false;
|
||||
}
|
||||
DeviceConfigManager config = deviceRepository.getDeviceConfigManager(deviceId);
|
||||
DeviceConfigEntity dConfig = deviceRepository.getDeviceConfig(deviceId);
|
||||
|
||||
SourceEntity source = sourceMapper.querySameVideo(faceSampleId, device.getId());
|
||||
SourceEntity source = sourceMapper.querySameVideo(faceSampleId, deviceV2.getId());
|
||||
|
||||
if (source == null || task.force) {
|
||||
BigDecimal cutPre = config.getBigDecimal("cut_pre", BigDecimal.valueOf(5L));
|
||||
BigDecimal cutPost = config.getBigDecimal("cut_post", BigDecimal.valueOf(5L));
|
||||
IDeviceStorageOperator pieceGetter = DeviceFactory.getDeviceStorageOperator(device, dConfig);
|
||||
IDeviceStorageOperator pieceGetter = DeviceFactory.getDeviceStorageOperator(deviceV2, dConfig);
|
||||
if (pieceGetter == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -316,7 +325,7 @@ public class VideoPieceGetter {
|
||||
}
|
||||
sourceEntity.setVideoUrl(url);
|
||||
sourceEntity.setFaceSampleId(faceSampleId);
|
||||
sourceEntity.setScenicId(device.getScenicId());
|
||||
sourceEntity.setScenicId(deviceV2.getScenicId());
|
||||
sourceEntity.setDeviceId(deviceId);
|
||||
sourceEntity.setType(1);
|
||||
if (task.memberId != null && task.faceId != null) {
|
||||
@@ -324,9 +333,9 @@ public class VideoPieceGetter {
|
||||
videoSource.setMemberId(task.getMemberId());
|
||||
videoSource.setType(1);
|
||||
videoSource.setFaceId(task.getFaceId());
|
||||
videoSource.setScenicId(device.getScenicId());
|
||||
videoSource.setScenicId(deviceV2.getScenicId());
|
||||
videoSource.setSourceId(sourceEntity.getId());
|
||||
IsBuyRespVO isBuy = orderBiz.isBuy(task.getMemberId(), device.getScenicId(), 1, task.getFaceId());
|
||||
IsBuyRespVO isBuy = orderBiz.isBuy(task.getMemberId(), deviceV2.getScenicId(), 1, task.getFaceId());
|
||||
if (isBuy.isBuy()) { // 如果用户买过
|
||||
videoSource.setIsBuy(1);
|
||||
} else if (isBuy.isFree()) { // 全免费逻辑
|
||||
@@ -352,10 +361,10 @@ public class VideoPieceGetter {
|
||||
int count = sourceMapper.hasRelationTo(task.getMemberId(), source.getId(), 1);
|
||||
if (count <= 0) {
|
||||
// 没有关联
|
||||
IsBuyRespVO isBuy = orderBiz.isBuy(task.getMemberId(), device.getScenicId(), 1, task.getFaceId());
|
||||
IsBuyRespVO isBuy = orderBiz.isBuy(task.getMemberId(), deviceV2.getScenicId(), 1, task.getFaceId());
|
||||
MemberSourceEntity videoSource = new MemberSourceEntity();
|
||||
videoSource.setId(SnowFlakeUtil.getLongId());
|
||||
videoSource.setScenicId(device.getScenicId());
|
||||
videoSource.setScenicId(deviceV2.getScenicId());
|
||||
videoSource.setFaceId(task.getFaceId());
|
||||
videoSource.setMemberId(task.getMemberId());
|
||||
videoSource.setType(1);
|
||||
|
Reference in New Issue
Block a user