Browse Source

修复视频巡检图片路径问题

zhongwei
Jone 2 months ago
parent
commit
382c13bd59
  1. 44
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java

44
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/schedule/VideoTaskSchedule.java

@ -30,6 +30,7 @@ import com.hnac.hzinfo.inspect.task.service.IEventRecordService;
import com.hnac.hzinfo.inspect.task.service.IEventService;
import com.hnac.hzinfo.inspect.task.service.ITaskService;
import com.hnac.hzinfo.inspect.task.service.ITaskUserService;
import com.hnac.hzinfo.inspect.task.service.impl.FileUploaderService;
import com.hnac.hzinfo.sdk.core.response.HzPage;
import com.hnac.hzinfo.sdk.core.response.Result;
import com.xxl.job.core.biz.model.ReturnT;
@ -57,6 +58,7 @@ import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import static com.hnac.hzinfo.inspect.task.schedule.XxlJobConstants.EXECUTE_VIDEO_TASK;
@ -77,13 +79,12 @@ public class VideoTaskSchedule {
private final IRobotTaskService robotTaskService;
private final ICameraInfoService cameraInfoService;
private final ISoeClient soeClient;
private final DataSourceTransactionManager dataSourceTransactionManager;
private final TransactionDefinition transactionDefinition;
private final IOssClient ossClient;
private final ContentService contentService;
private final IBigModelAnalysisClient bigModelClient;
private final IMessageClient messageClient;
private final ISysClient sysClient;
private final FileUploaderService fileUploaderService;
/**
* 视频巡检任务执行
@ -251,22 +252,31 @@ public class VideoTaskSchedule {
private void pictureHandle(String url, Long contentId, EventRecordEntity record, TaskEntity task) {
FileUtil.ByteArrayMultipartFile multipartFile = null;
try {
multipartFile = FileUtil.getMultipartFileFromPureUrl(url);
if (ObjectUtil.isEmpty(multipartFile.getContentType())) {
multipartFile.setContentType(FileUtil.IMG);
}
} catch (IOException e) {
log.error("获取截图文件失败", e);
// FileUtil.ByteArrayMultipartFile multipartFile = null;
// try {
// multipartFile = FileUtil.getMultipartFileFromPureUrl(url);
// if (ObjectUtil.isEmpty(multipartFile.getContentType())) {
// multipartFile.setContentType(FileUtil.IMG);
// }
// } catch (IOException e) {
// log.error("获取截图文件失败", e);
// record.setCurrentValue("获取截图文件失败");
// return;
// }
// R<BladeFile> fileResponse = ossClient.putFileByNameAndTenantId("file", multipartFile, task.getTenantId());
// log.info("【taskId:{}}】视频巡检任务执行,上传minio结果,{}", task.getId(), Optional.ofNullable(fileResponse).map(JsonUtil::toJson).orElse("null"));
// if (fileResponse.isSuccess()) {
// record.setFileUrl(Optional.ofNullable(fileResponse.getData().getLink()).orElse(record.getFileUrl()));
// }
try {
BladeFile bladeFile = fileUploaderService.upload(url, UUID.randomUUID().toString()+".jpg");
record.setFileUrl(Optional.ofNullable(bladeFile.getLink()).orElse(record.getFileUrl()));
} catch (Exception e) {
log.error("获取截图文件失败", e);
record.setCurrentValue("获取截图文件失败");
return;
}
R<BladeFile> fileResponse = ossClient.putFileByNameAndTenantId("file", multipartFile, task.getTenantId());
log.info("【taskId:{}}】视频巡检任务执行,上传minio结果,{}", task.getId(), Optional.ofNullable(fileResponse).map(JsonUtil::toJson).orElse("null"));
if (fileResponse.isSuccess()) {
record.setFileUrl(Optional.ofNullable(fileResponse.getData().getLink()).orElse(record.getFileUrl()));
}
}
ContentEntity content = contentService.getById(contentId);
if (StringUtil.isBlank(content.getMultiCheckTypeSon())) {

Loading…
Cancel
Save