From d3ad03c1597dcdbdeae9805d15f1036bbaf95a02 Mon Sep 17 00:00:00 2001 From: Iamasoldier <1272745473@qq.com> Date: Mon, 14 Jul 2025 00:53:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=AE=A2=E5=8D=95=E7=B4=A0=E6=9D=90?= =?UTF-8?q?=E7=AE=A1=E7=90=86):=20=E7=B4=A0=E6=9D=90=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E5=90=8E=EF=BC=8C=E8=BE=BE=E5=88=B0=E4=BA=8C?= =?UTF-8?q?=E7=BB=B4=E7=A0=81=E7=B4=A0=E6=9D=90=E8=A6=81=E6=B1=82=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E5=90=8E=EF=BC=8C=E9=80=9A=E7=9F=A5=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E4=B8=8A=E4=BC=A0=E5=AE=8C=E6=88=90=E3=80=82?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B9=8B=E5=89=8D=E9=80=9A=E8=BF=87=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E6=89=A7=E8=A1=8C=E7=8A=B6=E6=80=81=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E6=9D=A5=E8=A7=A6=E5=8F=91=E9=80=9A=E7=9F=A5=E5=92=8C=E4=B8=80?= =?UTF-8?q?=E9=94=AE=E6=88=90=E7=89=87=E9=80=BB=E8=BE=91=E7=9A=84bug?= =?UTF-8?q?=E3=80=82=E6=96=B0=E5=A2=9E=E5=88=A4=E6=96=AD=E4=BA=8C=E7=BB=B4?= =?UTF-8?q?=E7=A0=81=E6=98=AF=E5=90=A6=E5=BC=80=E5=90=AF=E4=B8=80=E9=94=AE?= =?UTF-8?q?=E6=88=90=E7=89=87=E7=9A=84=E5=8A=9F=E8=83=BD=E7=9A=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E4=B9=8B=E5=89=8D=E6=98=AF=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E4=BC=9A=E5=85=A8=E9=83=A8=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E4=B8=80=E9=94=AE=E6=88=90=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/controller/OrderFileController.java | 72 ++++++++++++------- 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/zlt-business/order-center/src/main/java/com/central/order/controller/OrderFileController.java b/zlt-business/order-center/src/main/java/com/central/order/controller/OrderFileController.java index 07cd5d20..e25ac6da 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/controller/OrderFileController.java +++ b/zlt-business/order-center/src/main/java/com/central/order/controller/OrderFileController.java @@ -7,6 +7,7 @@ import com.central.order.enums.OrderStatus; import com.central.order.feign.FileCenterService; import com.central.order.feign.UserCenterService; import com.central.order.model.*; +import com.central.order.model.EditTask; import com.central.order.service.*; import com.central.order.util.DateUtils; import io.swagger.v3.oas.annotations.Operation; @@ -167,44 +168,44 @@ public class OrderFileController { log.warn("参数为空,orderFile: {}", orderFile); return Result.failed(orderFile,"参数为空"); } - + // 校验订单是否存在 Order order = orderService.getOrderByNumber(orderFile.getOrderNo()); if (order == null) { log.warn("订单不存在,订单号: {}", orderFile.getOrderNo()); return Result.failed(orderFile,"订单不存在"); } - + // 校验文件路径是否为空 if (orderFile.getFilePath() == null || orderFile.getFilePath().trim().isEmpty()) { log.warn("素材路径为空,订单号: {}", orderFile.getOrderNo()); return Result.failed(orderFile,"素材路径为空"); } - + // 先校验记录是否已经存在 OrderFile existingOrderFile = orderFileService.getOrderFileByFilePath(orderFile.getFilePath()); if (existingOrderFile != null) { log.info("记录已存在,不再重复创建,订单号: {}, 文件路径: {}", orderFile.getOrderNo(), orderFile.getFilePath()); return Result.succeed(existingOrderFile, "记录已存在,无需重复创建"); } - + // 设置订单相关信息 orderFile.setOrderNo(order.getOrderNo()); orderFile.setUserId(order.getUserId()); - + // 创建文件信息 FileInfo fileInfo = fileCenterService.creatFileInfo(orderFile.getFilePath()); if (fileInfo == null) { log.warn("文件信息创建失败,filePath: {}", orderFile.getFilePath()); return Result.failed(orderFile,"文件信息创建失败"); } - + // 设置文件相关信息 orderFile.setFileId(fileInfo.getId()); orderFile.setFilePath(fileInfo.getPath()); orderFile.setFileType(fileInfo.getContentType()); orderFile.setTourismId(order.getTourismId()); - + // 保存记录 boolean saved = orderFileService.save(orderFile); if (saved) { @@ -257,27 +258,46 @@ public class OrderFileController { //发送用户素材上传成功通知 sendMessageForResouresUploaded(order,tourism); - //触发一键成片 - // 1. 创建新任务 - EditTask task = editTaskService.createTask(order.getOrderNo(), order.getUserId()); + // 检查是否开启一键成片功能 + if (isVideoEditEnabled(qrCode)) { + log.info("二维码已开启一键成片功能,开始触发一键成片: orderNo={}, codeId={}", + order.getOrderNo(), order.getCodeId()); - // 2. 获取素材文件 - List orderFiles = orderFileService.getOrderFileByOrderNo(order.getOrderNo()); + //触发一键成片 + // 1. 创建新任务 + EditTask task = editTaskService.createTask(order.getOrderNo(), order.getUserId()); - // 3. 提交编辑任务 - String jobId = videoEditService.submitEditTask(order.getOrderNo(), orderFiles); - log.info("提交一键成片任务成功: orderNo={}, jobId={}, totalMediaFiles={}", - order.getOrderNo(), jobId, orderFiles.size()); - // 4. 更新任务信息 - task.setJobId(jobId); - task.setStatus(EditTaskStatus.PROCESSING); - editTaskService.saveOrUpdateTask(task); + // 2. 获取素材文件 + List orderFiles = orderFileService.getOrderFileByOrderNo(order.getOrderNo()); + + // 3. 提交编辑任务 + String jobId = videoEditService.submitEditTask(order.getOrderNo(), orderFiles); + log.info("提交一键成片任务成功: orderNo={}, jobId={}, totalMediaFiles={}", + order.getOrderNo(), jobId, orderFiles.size()); + // 4. 更新任务信息 + task.setJobId(jobId); + task.setStatus(EditTaskStatus.PROCESSING); + editTaskService.saveOrUpdateTask(task); + } else { + log.info("二维码未开启一键成片功能,跳过一键成片: orderNo={}, codeId={}, enableVideoEdit={}", + order.getOrderNo(), order.getCodeId(), qrCode.getEnableVideoEdit()); + } } } catch (Exception e) { log.error("检查素材数量异常,订单号: {}", order.getOrderNo(), e); } } + /** + * 检查是否开启一键成片功能 + */ + private boolean isVideoEditEnabled(QrCode qrCode) { + return qrCode != null + && qrCode.getEnableVideoEdit() != null + && qrCode.getEnableVideoEdit() == 1 + && qrCode.getTemplateId() != null; // 确保有模板ID + } + /** * 素材上传完成小程序通知 * @param order @@ -324,21 +344,21 @@ public class OrderFileController { if (filePath == null || filePath.trim().isEmpty()) { return Result.failed("文件路径不能为空"); } - + OrderFile orderFile = orderFileService.getOrderFileByFilePath(filePath); if (orderFile == null) { return Result.failed("未找到对应的订单文件记录"); } - + // 设置文件查看URL orderFile.setViewUrl(fileCenterService.getViewUrlByPath(orderFile.getFilePath())); - + // 设置压缩文件查看URL Map fileMap = new HashMap<>(); fileMap.put("style", fileStyle); fileMap.put("path", orderFile.getFilePath()); orderFile.setZipViewUrl(fileCenterService.getViewUrlByPathStyle(fileMap)); - + return Result.succeed(orderFile, "记录已存在"); } catch (Exception e) { log.error("根据文件路径查询订单文件记录失败: filePath={}", filePath, e); @@ -353,10 +373,10 @@ public class OrderFileController { if (filePath == null || filePath.trim().isEmpty()) { return Result.failed("文件路径不能为空"); } - + OrderFile orderFile = orderFileService.getOrderFileByFilePath(filePath); boolean exists = orderFile != null; - + if (exists) { return Result.succeed(true, "记录已存在"); } else {