You've already forked FrameTour-BE
乱七八糟的修改,其他外围流程逻辑完善
This commit is contained in:
@ -11,6 +11,7 @@ import com.ycwl.basic.model.pc.device.entity.DeviceEntity;
|
||||
import com.ycwl.basic.model.pc.faceSample.resp.FaceSampleRespVO;
|
||||
import com.ycwl.basic.model.pc.source.entity.SourceEntity;
|
||||
import com.ycwl.basic.utils.OssUtil;
|
||||
import com.ycwl.basic.utils.SnowFlakeUtil;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -49,9 +50,15 @@ public class VideoPieceGetter {
|
||||
|
||||
@Data
|
||||
public static class Task {
|
||||
public String type = "normal";
|
||||
public Long deviceId;
|
||||
public Long faceSampleId;
|
||||
public Date createTime;
|
||||
public Callback callback;
|
||||
|
||||
public static interface Callback {
|
||||
void onInvoke();
|
||||
}
|
||||
}
|
||||
@Data
|
||||
public static class FfmpegTask {
|
||||
@ -67,13 +74,17 @@ public class VideoPieceGetter {
|
||||
queue.add(task);
|
||||
}
|
||||
|
||||
@Scheduled(fixedDelay = 5000L)
|
||||
@Scheduled(fixedDelay = 1000L)
|
||||
public void doTask() {
|
||||
Task task = queue.poll();
|
||||
if (task == null) {
|
||||
return;
|
||||
}
|
||||
log.info("poll task: {}", task);
|
||||
if (!task.getType().equalsIgnoreCase("normal")) {
|
||||
task.getCallback().onInvoke();
|
||||
return;
|
||||
}
|
||||
FaceSampleRespVO faceSample = faceSampleMapper.getById(task.getFaceSampleId());
|
||||
DeviceEntity device = deviceMapper.getByDeviceId(task.getDeviceId());
|
||||
DeviceConfigEntity config = deviceMapper.getConfigByDeviceId(task.getDeviceId());
|
||||
@ -98,10 +109,6 @@ public class VideoPieceGetter {
|
||||
new Date(task.getCreateTime().getTime() - cutPre.multiply(BigDecimal.valueOf(1000)).longValue()),
|
||||
new Date(task.getCreateTime().getTime() + cutPost.multiply(BigDecimal.valueOf(1000)).longValue())
|
||||
);
|
||||
if (listByDtRange.isEmpty()) {
|
||||
queue.add(task);
|
||||
return;
|
||||
}
|
||||
long offset = task.getCreateTime().getTime() - listByDtRange.get(0).getCreateTime().getTime();
|
||||
FfmpegTask ffmpegTask = new FfmpegTask();
|
||||
ffmpegTask.setFileList(listByDtRange);
|
||||
@ -119,6 +126,7 @@ public class VideoPieceGetter {
|
||||
InputStream inputStream = new FileInputStream(outFile);
|
||||
String url = ossUtil.uploadFile(inputStream, "user-video-source", outFile.getName());
|
||||
SourceEntity sourceEntity = new SourceEntity();
|
||||
sourceEntity.setId(SnowFlakeUtil.getLongId());
|
||||
sourceEntity.setVideoUrl(url);
|
||||
sourceEntity.setFaceSampleId(faceSample.getId());
|
||||
sourceEntity.setScenicId(faceSample.getScenicId());
|
||||
|
Reference in New Issue
Block a user