You've already forked FrameTour-BE
Merge branch 'fix'
This commit is contained in:
@@ -23,7 +23,7 @@ public class DeviceFactory {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (Integer.valueOf(DeviceStoreTypeEnum.ALI_OSS.getType()).equals(config.getStoreType())) {
|
if (Integer.valueOf(DeviceStoreTypeEnum.ALI_OSS.getType()).equals(config.getStoreType())) {
|
||||||
operator = new AliOssStorageOperator(config.getStoreConfigJson());
|
operator = new AliOssStorageOperator(config.getStoreConfigJson().replace("-internal.aliyuncs.com", ".aliyuncs.com"));
|
||||||
} else if (Integer.valueOf(DeviceStoreTypeEnum.WVP_ACTIVE.getType()).equals(config.getStoreType())) {
|
} else if (Integer.valueOf(DeviceStoreTypeEnum.WVP_ACTIVE.getType()).equals(config.getStoreType())) {
|
||||||
operator = new WvpActiveStorageOperator(config.getStoreConfigJson());
|
operator = new WvpActiveStorageOperator(config.getStoreConfigJson());
|
||||||
} else if (Integer.valueOf(DeviceStoreTypeEnum.WVP_PASSIVE.getType()).equals(config.getStoreType())) {
|
} else if (Integer.valueOf(DeviceStoreTypeEnum.WVP_PASSIVE.getType()).equals(config.getStoreType())) {
|
||||||
|
@@ -69,23 +69,15 @@ public class AliOssStorageOperator extends ADeviceStorageOperator {
|
|||||||
if (startDate == null || endDate == null) {
|
if (startDate == null || endDate == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<FileObject> fileList = new ArrayList<>();
|
|
||||||
if (startDate.after(endDate)) {
|
|
||||||
return fileList;
|
|
||||||
}
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.setTime(startDate);
|
calendar.setTime(startDate);
|
||||||
calendar.set(Calendar.SECOND, 0);
|
calendar.set(Calendar.SECOND, 0);
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
|
||||||
while (calendar.getTime().before(endDate)) {
|
|
||||||
String prefix = dateFormat.format(calendar.getTime());
|
String prefix = dateFormat.format(calendar.getTime());
|
||||||
List<FileObject> fileListByPrefix = getOssFileListByPrefix(prefix);
|
List<FileObject> fileList = getOssFileListByPrefix(prefix);
|
||||||
if (fileListByPrefix == null) {
|
if (fileList == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
fileList.addAll(fileListByPrefix);
|
|
||||||
calendar.add(Calendar.MINUTE, 1);
|
|
||||||
}
|
|
||||||
calendar.clear();
|
calendar.clear();
|
||||||
return fileList.stream()
|
return fileList.stream()
|
||||||
.sorted(Comparator.comparing(FileObject::getCreateTime))
|
.sorted(Comparator.comparing(FileObject::getCreateTime))
|
||||||
|
@@ -234,7 +234,7 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
|||||||
if (tourMinutes > 0) {
|
if (tourMinutes > 0) {
|
||||||
List<FaceSampleEntity> acceptFaceSampleList = faceSampleMapper.listByIds(acceptFaceSampleIds);
|
List<FaceSampleEntity> acceptFaceSampleList = faceSampleMapper.listByIds(acceptFaceSampleIds);
|
||||||
Date startDate = DateUtil.offsetMinute(firstFaceSample.get().getCreateAt(), -tourMinutes);
|
Date startDate = DateUtil.offsetMinute(firstFaceSample.get().getCreateAt(), -tourMinutes);
|
||||||
Date endDate = DateUtil.offsetMinute(firstFaceSample.get().getCreateAt(), 0);
|
Date endDate = DateUtil.offsetMinute(firstFaceSample.get().getCreateAt(), 1);
|
||||||
acceptFaceSampleIds = acceptFaceSampleList.stream()
|
acceptFaceSampleIds = acceptFaceSampleList.stream()
|
||||||
.filter(faceSample -> faceSample.getCreateAt().after(startDate) && faceSample.getCreateAt().before(endDate))
|
.filter(faceSample -> faceSample.getCreateAt().after(startDate) && faceSample.getCreateAt().before(endDate))
|
||||||
.map(FaceSampleEntity::getId)
|
.map(FaceSampleEntity::getId)
|
||||||
|
@@ -525,7 +525,6 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
String hash = MD5.create().digestHex(task.getTaskParams());
|
String hash = MD5.create().digestHex(task.getTaskParams());
|
||||||
String filename = StorageUtil.joinPath(StorageConstant.VLOG_PATH, hash + "_" + task.getScenicId() + ".mp4");
|
String filename = StorageUtil.joinPath(StorageConstant.VLOG_PATH, hash + "_" + task.getScenicId() + ".mp4");
|
||||||
adapter.setAcl(StorageAcl.PUBLIC_READ, filename);
|
adapter.setAcl(StorageAcl.PUBLIC_READ, filename);
|
||||||
videoReUploader.addVideoTask(video.getId());
|
|
||||||
int isBuy = 0;
|
int isBuy = 0;
|
||||||
FaceEntity face = faceRepository.getFace(task.getFaceId());
|
FaceEntity face = faceRepository.getFace(task.getFaceId());
|
||||||
if (face != null) {
|
if (face != null) {
|
||||||
|
@@ -7,15 +7,12 @@ import com.ycwl.basic.mapper.SourceMapper;
|
|||||||
import com.ycwl.basic.mapper.VideoMapper;
|
import com.ycwl.basic.mapper.VideoMapper;
|
||||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicConfigEntity;
|
import com.ycwl.basic.model.pc.scenic.entity.ScenicConfigEntity;
|
||||||
import com.ycwl.basic.model.pc.source.entity.SourceEntity;
|
import com.ycwl.basic.model.pc.source.entity.SourceEntity;
|
||||||
import com.ycwl.basic.model.pc.video.entity.VideoEntity;
|
|
||||||
import com.ycwl.basic.repository.ScenicRepository;
|
import com.ycwl.basic.repository.ScenicRepository;
|
||||||
import com.ycwl.basic.repository.VideoRepository;
|
import com.ycwl.basic.repository.VideoRepository;
|
||||||
import com.ycwl.basic.service.pc.ScenicService;
|
import com.ycwl.basic.service.pc.ScenicService;
|
||||||
import com.ycwl.basic.storage.adapters.IStorageAdapter;
|
import com.ycwl.basic.storage.adapters.IStorageAdapter;
|
||||||
import com.ycwl.basic.storage.enums.StorageAcl;
|
|
||||||
import com.ycwl.basic.storage.utils.StorageUtil;
|
import com.ycwl.basic.storage.utils.StorageUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.commons.lang3.Strings;
|
import org.apache.commons.lang3.Strings;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -94,44 +91,4 @@ public class VideoReUploader {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public void addVideoTask(Long videoId) {
|
|
||||||
VideoEntity entity = videoMapper.getEntity(videoId);
|
|
||||||
if (entity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (entity.getScenicId() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final String dstFilePath = StorageUtil.joinPath(StorageConstant.VLOG_PATH, entity.getTaskId() + "_" + entity.getScenicId() + ".mp4");
|
|
||||||
final IStorageAdapter adapter = scenicService.getScenicStorageAdapter(entity.getScenicId());
|
|
||||||
if (Strings.CS.equals(entity.getVideoUrl(), adapter.getUrl(dstFilePath))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String tmpFilePath = UUID.randomUUID().toString();
|
|
||||||
executor.execute(() -> {
|
|
||||||
// 先下载,后上传
|
|
||||||
File dstFile = new File(tmpFilePath);
|
|
||||||
log.info("下载视频:{};videoId:{}", entity.getVideoUrl(), videoId);
|
|
||||||
long size = HttpUtil.downloadFile(entity.getVideoUrl(), dstFile);
|
|
||||||
log.info("下载视频完成:{};大小:{};videoId:{}", entity.getVideoUrl(), size, videoId);
|
|
||||||
try {
|
|
||||||
log.info("开始上传:{};videoId:{}", dstFilePath, videoId);
|
|
||||||
String newUrl = adapter.uploadFile("video/mp4", dstFile, dstFilePath);
|
|
||||||
adapter.setAcl(StorageAcl.PUBLIC_READ, dstFilePath);
|
|
||||||
log.info("上传成功:{};videoId:{}", newUrl, videoId);
|
|
||||||
VideoEntity updateEntity = new VideoEntity();
|
|
||||||
updateEntity.setId(videoId);
|
|
||||||
updateEntity.setVideoUrl(newUrl);
|
|
||||||
videoMapper.update(updateEntity);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.info("上传失败:{};videoId:{}", dstFilePath, videoId, e);
|
|
||||||
} finally {
|
|
||||||
videoRepository.clearVideoCache(videoId);
|
|
||||||
try {
|
|
||||||
dstFile.delete();
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user