fix(一键成片):功能优化
This commit is contained in:
+1
-1
@@ -51,7 +51,7 @@ import java.util.Map;
|
|||||||
public class OrderController {
|
public class OrderController {
|
||||||
|
|
||||||
//设备执行任务默认时间长度3分钟
|
//设备执行任务默认时间长度3分钟
|
||||||
private static final long DEVICE_EXEC_TIME = 3;
|
private static final long DEVICE_EXEC_TIME = 4;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IOrderService orderService;
|
private IOrderService orderService;
|
||||||
|
|||||||
+34
-17
@@ -2,6 +2,7 @@ package com.central.order.listener;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.central.common.model.SysUser;
|
import com.central.common.model.SysUser;
|
||||||
|
import com.central.order.constants.EditTaskStatus;
|
||||||
import com.central.order.enums.MessageTemplateEnum;
|
import com.central.order.enums.MessageTemplateEnum;
|
||||||
import com.central.order.enums.OrderStatus;
|
import com.central.order.enums.OrderStatus;
|
||||||
import com.central.order.enums.OrderStatusChangeEnum;
|
import com.central.order.enums.OrderStatusChangeEnum;
|
||||||
@@ -11,6 +12,7 @@ import com.central.order.model.*;
|
|||||||
import com.central.order.service.*;
|
import com.central.order.service.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.event.EventListener;
|
import org.springframework.context.event.EventListener;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -26,14 +28,24 @@ import java.util.Map;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class OrderStatusChangeListener {
|
public class OrderStatusChangeListener {
|
||||||
|
|
||||||
private final IMessageService messageService;
|
@Autowired
|
||||||
private final ITourismService tourismService;
|
private IMessageService messageService;
|
||||||
private final IOrderService orderService;
|
@Autowired
|
||||||
private final IQrCodeService qrCodeService;
|
private ITourismService tourismService;
|
||||||
private final IVideoEditService videoEditService;
|
@Autowired
|
||||||
private final IOrderFileService orderFileService;
|
private IOrderService orderService;
|
||||||
private final IWxTemplateMessageService wxTemplateMessageService;
|
@Autowired
|
||||||
private final UserCenterService userCenterService;
|
private IQrCodeService qrCodeService;
|
||||||
|
@Autowired
|
||||||
|
private IVideoEditService videoEditService;
|
||||||
|
@Autowired
|
||||||
|
private IOrderFileService orderFileService;
|
||||||
|
@Autowired
|
||||||
|
private IWxTemplateMessageService wxTemplateMessageService;
|
||||||
|
@Autowired
|
||||||
|
private UserCenterService userCenterService;
|
||||||
|
@Autowired
|
||||||
|
private IEditTaskService editTaskService;
|
||||||
|
|
||||||
@EventListener
|
@EventListener
|
||||||
@Async
|
@Async
|
||||||
@@ -178,16 +190,21 @@ public class OrderStatusChangeListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 获取订单视频文件
|
// 3. 创建新任务
|
||||||
List<OrderFile> videoFiles = orderFileService.getOrderVideoFiles(order.getOrderNo());
|
EditTask task = editTaskService.createTask(order.getOrderNo(), order.getUserId());
|
||||||
if (videoFiles == null || videoFiles.isEmpty()) {
|
|
||||||
log.warn("未找到订单视频文件: orderNo={}", order.getOrderNo());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 提交视频编辑任务
|
// 4. 获取素材文件
|
||||||
String jobId = videoEditService.submitEditTask(order.getOrderNo(), videoFiles);
|
List<OrderFile> orderFiles = orderFileService.getOrderFileByOrderNo(order.getOrderNo());
|
||||||
log.info("提交一键成片任务成功: orderNo={}, jobId={}", order.getOrderNo(), jobId);
|
|
||||||
|
// 5. 提交编辑任务
|
||||||
|
String jobId = videoEditService.submitEditTask(order.getOrderNo(), orderFiles);
|
||||||
|
log.info("提交一键成片任务成功: orderNo={}, jobId={}, totalMediaFiles={}",
|
||||||
|
order.getOrderNo(), jobId, orderFiles.size());
|
||||||
|
|
||||||
|
// 6. 更新任务信息
|
||||||
|
task.setJobId(jobId);
|
||||||
|
task.setStatus(EditTaskStatus.PROCESSING);
|
||||||
|
editTaskService.saveOrUpdateTask(task);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// 这里只记录错误,不抛出异常,避免影响订单状态变更的主流程
|
// 这里只记录错误,不抛出异常,避免影响订单状态变更的主流程
|
||||||
|
|||||||
+5
@@ -79,5 +79,10 @@ public interface IOrderFileService extends ISuperService<OrderFile> {
|
|||||||
* @return 视频文件列表
|
* @return 视频文件列表
|
||||||
*/
|
*/
|
||||||
List<OrderFile> getOrderVideoFiles(String orderNo);
|
List<OrderFile> getOrderVideoFiles(String orderNo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取订单图片文件
|
||||||
|
*/
|
||||||
|
List<OrderFile> getOrderImageFiles(String orderNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-6
@@ -130,12 +130,12 @@ public class MediaServiceImpl implements IMediaService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3. 获取视频文件
|
// 3. 获取视频文件
|
||||||
List<OrderFile> videoFiles = orderFileService.getOrderVideoFiles(orderNo);
|
// List<OrderFile> videoFiles = orderFileService.getOrderVideoFiles(orderNo);
|
||||||
if (videoFiles == null || videoFiles.size() < 2) {
|
if (orderFiles == null || orderFiles.size() < 7) {
|
||||||
throw new BusinessException("订单视频文件数量不足,至少需要2个视频文件");
|
throw new BusinessException("订单视频文件数量不足,至少需要2个视频文件");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new TaskSubmitData(order, qrCode, videoFiles);
|
return new TaskSubmitData(order, qrCode, orderFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -186,9 +186,14 @@ public class MediaServiceImpl implements IMediaService {
|
|||||||
try {
|
try {
|
||||||
Map<String, String> clips = new HashMap<>();
|
Map<String, String> clips = new HashMap<>();
|
||||||
List<OrderFile> videoFiles = taskData.getVideoFiles();
|
List<OrderFile> videoFiles = taskData.getVideoFiles();
|
||||||
|
//@TODO 后期需要通过模板参数进行动态设置clips参数
|
||||||
clips.put("1", fileCenterService.getViewUrlByPath(videoFiles.get(0).getFilePath()));
|
clips.put("1", fileCenterService.getViewUrlByPath(videoFiles.get(4).getFilePath()));
|
||||||
clips.put("2", fileCenterService.getViewUrlByPath(videoFiles.get(1).getFilePath()));
|
clips.put("2", fileCenterService.getViewUrlByPath(videoFiles.get(5).getFilePath()));
|
||||||
|
clips.put("3", fileCenterService.getViewUrlByPath(videoFiles.get(6).getFilePath()));
|
||||||
|
clips.put("4", fileCenterService.getViewUrlByPath(videoFiles.get(0).getFilePath()));
|
||||||
|
clips.put("5", fileCenterService.getViewUrlByPath(videoFiles.get(1).getFilePath()));
|
||||||
|
clips.put("6", fileCenterService.getViewUrlByPath(videoFiles.get(2).getFilePath()));
|
||||||
|
clips.put("7", fileCenterService.getViewUrlByPath(videoFiles.get(3).getFilePath()));
|
||||||
|
|
||||||
return JSON.toJSONString(clips);
|
return JSON.toJSONString(clips);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
+10
@@ -1,5 +1,6 @@
|
|||||||
package com.central.order.service.impl;
|
package com.central.order.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.central.common.model.PageResult;
|
import com.central.common.model.PageResult;
|
||||||
import com.central.common.service.impl.SuperServiceImpl;
|
import com.central.common.service.impl.SuperServiceImpl;
|
||||||
@@ -93,4 +94,13 @@ public class OrderFileServiceImpl extends SuperServiceImpl<OrderFileMapper, Orde
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OrderFile> getOrderImageFiles(String orderNo) {
|
||||||
|
return baseMapper.selectList(
|
||||||
|
new QueryWrapper<OrderFile>()
|
||||||
|
.eq("order_no", orderNo)
|
||||||
|
.eq("file_type", "image/jpeg") // 假设图片类型为 "image"
|
||||||
|
.orderByAsc("create_time"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user