fix(一键成片):功能逻辑优化,模板管理等前后端功能实现
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package com.central.order.config;
|
||||
|
||||
import com.aliyun.ice20201109.Client;
|
||||
import com.aliyun.teaopenapi.models.Config;
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Data
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "aliyun.ims")
|
||||
public class AliyunImsConfig {
|
||||
private String endpoint;
|
||||
private String accessKeyId;
|
||||
private String accessKeySecret;
|
||||
private String region;
|
||||
private String projectName;
|
||||
private String pipelineName;
|
||||
private String templateId;
|
||||
private String callbackUrl;
|
||||
private String bucket;
|
||||
|
||||
@Bean
|
||||
public Client imsClient() throws Exception {
|
||||
Config config = new Config()
|
||||
.setAccessKeyId(accessKeyId)
|
||||
.setAccessKeySecret(accessKeySecret)
|
||||
.setEndpoint(endpoint);
|
||||
return new Client(config);
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package com.central.order.constants;
|
||||
|
||||
/**
|
||||
* 编辑任务状态常量
|
||||
*/
|
||||
public interface EditTaskStatus {
|
||||
/**
|
||||
* 待处理
|
||||
*/
|
||||
int PENDING = 0;
|
||||
|
||||
/**
|
||||
* 处理中
|
||||
*/
|
||||
int PROCESSING = 1;
|
||||
|
||||
/**
|
||||
* 处理完成
|
||||
*/
|
||||
int COMPLETED = 2;
|
||||
|
||||
/**
|
||||
* 处理失败
|
||||
*/
|
||||
int FAILED = 3;
|
||||
|
||||
/**
|
||||
* 判断是否为处理中状态
|
||||
*/
|
||||
static boolean isProcessing(Integer status) {
|
||||
return PROCESSING == status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为完成状态
|
||||
*/
|
||||
static boolean isCompleted(Integer status) {
|
||||
return COMPLETED == status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态描述
|
||||
*/
|
||||
static String getStatusDesc(Integer status) {
|
||||
switch (status) {
|
||||
case PENDING: return "待处理";
|
||||
case PROCESSING: return "处理中";
|
||||
case COMPLETED: return "已完成";
|
||||
case FAILED: return "失败";
|
||||
default: return "未知状态";
|
||||
}
|
||||
}
|
||||
}
|
||||
+119
-30
@@ -1,11 +1,12 @@
|
||||
package com.central.order.controller;
|
||||
|
||||
import com.central.common.model.Result;
|
||||
import com.central.order.constants.EditTaskStatus;
|
||||
import com.central.order.enums.OrderStatus;
|
||||
import com.central.order.feign.FileCenterService;
|
||||
import com.central.order.model.*;
|
||||
import com.central.order.service.IOrderFileService;
|
||||
import com.central.order.service.IOrderService;
|
||||
import com.central.order.service.ITourismFileService;
|
||||
import com.central.order.model.dto.CallbackDTO;
|
||||
import com.central.order.service.*;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -13,10 +14,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -36,47 +34,124 @@ public class AutoCutVideoController {
|
||||
@Value("${videos.edit-config.url}")
|
||||
private String url;
|
||||
|
||||
private final RestTemplate restTemplate;
|
||||
@Value("${videos.edit-config.app-id}")
|
||||
private String appId;
|
||||
|
||||
@Value("${videos.edit-config.callback-url}")
|
||||
private String callbackUrl;
|
||||
|
||||
private RestTemplate restTemplate;
|
||||
@Autowired
|
||||
private IOrderService orderService;
|
||||
@Autowired
|
||||
private IEditTaskService editTaskService;
|
||||
@Autowired
|
||||
private IOrderFileService orderFileService;
|
||||
@Autowired
|
||||
private ITourismFileService tourismFileService;
|
||||
@Autowired
|
||||
private FileCenterService fileCenterService;
|
||||
@Autowired
|
||||
private IVideoEditService videoEditService;
|
||||
|
||||
@Operation(summary = "根据订单号生成视频")
|
||||
@GetMapping("/generate/{orderNo}")
|
||||
public Result generateVideo(@PathVariable String orderNo) {
|
||||
@PostMapping("/generate")
|
||||
public Result generateVideo(@RequestParam String orderNo) {
|
||||
try {
|
||||
// 1. 获取订单信息
|
||||
// 1. 验证订单状态
|
||||
Order order = orderService.getOrderByNumber(orderNo);
|
||||
if (order == null) {
|
||||
return Result.failed("订单不存在");
|
||||
if (order == null || !OrderStatus.isValidForEdit(order.getOrderStatus())) {
|
||||
return Result.failed("订单状态不允许生成视频");
|
||||
}
|
||||
|
||||
// 2. 获取订单相关文件
|
||||
List<OrderFile> orderFiles = orderFileService.getOrderFileByOrderNo(orderNo);
|
||||
// 2. 检查是否存在进行中的任务
|
||||
EditTask existingTask = editTaskService.getTaskByOrderSn(orderNo);
|
||||
if (existingTask != null && EditTaskStatus.isProcessing(existingTask.getStatus())) {
|
||||
return Result.failed("已存在进行中的编辑任务");
|
||||
}
|
||||
|
||||
// 3. 获取景区素材
|
||||
// 3. 创建新任务
|
||||
EditTask task = editTaskService.createTask(orderNo, order.getUserId());
|
||||
|
||||
// 4. 获取素材文件
|
||||
List<OrderFile> orderFiles = orderFileService.getOrderFileByOrderNo(orderNo);
|
||||
List<TourismFile> tourismFiles = tourismFileService.getByTourismId(order.getTourismId());
|
||||
|
||||
// 4. 构建素材列表
|
||||
SourceDTO sourceDTO = buildSourceDTO(orderFiles, tourismFiles);
|
||||
// 5. 提交编辑任务
|
||||
String jobId = videoEditService.submitEditTask(orderNo, orderFiles, tourismFiles);
|
||||
|
||||
// 5. 构建请求参数
|
||||
RequestParamsEntity requestParams = buildRequestParams(order, sourceDTO);
|
||||
// 6. 更新任务信息
|
||||
editTaskService.updateTaskStatus(jobId, EditTaskStatus.PROCESSING, null);
|
||||
|
||||
// 6. 调用一键成片接口
|
||||
Object response = restTemplate.postForObject(url, requestParams, Object.class);
|
||||
|
||||
log.info("一键成片请求成功: orderNo={}, response={}", orderNo, response);
|
||||
return Result.succeed(response);
|
||||
return Result.succeed(jobId);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("一键成片请求失败: orderNo={}", orderNo, e);
|
||||
return Result.failed("生成视频失败:" + e.getMessage());
|
||||
log.error("提交视频编辑任务失败: orderNo={}", orderNo, e);
|
||||
return Result.failed("提交任务失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "智能剪辑回调接口")
|
||||
@PostMapping("/callback")
|
||||
public Result handleCallback(@RequestBody CallbackDTO callback) {
|
||||
log.info("收到视频编辑回调: {}", callback);
|
||||
try {
|
||||
// 1. 验证回调信息
|
||||
if (!isValidCallback(callback)) {
|
||||
return Result.failed("无效的回调信息");
|
||||
}
|
||||
|
||||
// 2. 获取任务信息
|
||||
EditTask task = editTaskService.getTaskByJobId(callback.getJobId());
|
||||
if (task == null) {
|
||||
return Result.failed("未找到对应的任务");
|
||||
}
|
||||
|
||||
// 3. 处理成功回调
|
||||
if ("Success".equals(callback.getStatus())) {
|
||||
// 更新任务状态
|
||||
editTaskService.updateTaskStatus(
|
||||
callback.getJobId(),
|
||||
EditTaskStatus.COMPLETED,
|
||||
callback.getResult()
|
||||
);
|
||||
|
||||
// 发送通知
|
||||
notifyUser(task.getUserId().toString(), "视频制作完成");
|
||||
}
|
||||
// 4. 处理失败回调
|
||||
else {
|
||||
editTaskService.updateTaskStatus(
|
||||
callback.getJobId(),
|
||||
EditTaskStatus.FAILED,
|
||||
callback.getErrorMessage()
|
||||
);
|
||||
|
||||
// 记录错误日志
|
||||
log.error("视频编辑失败: jobId={}, error={}",
|
||||
callback.getJobId(), callback.getErrorMessage());
|
||||
}
|
||||
|
||||
return Result.succeed("回调处理成功");
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("处理视频编辑回调失败", e);
|
||||
return Result.failed("处理回调失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "获取任务状态")
|
||||
@GetMapping("/task/status/{orderNo}")
|
||||
public Result getTaskStatus(@PathVariable String orderNo) {
|
||||
try {
|
||||
EditTask task = editTaskService.getTaskByOrderSn(orderNo);
|
||||
if (task == null) {
|
||||
return Result.failed("未找到任务记录");
|
||||
}
|
||||
return Result.succeed(task);
|
||||
} catch (Exception e) {
|
||||
log.error("获取任务状态失败", e);
|
||||
return Result.failed("获取任务状态失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,9 +207,9 @@ public class AutoCutVideoController {
|
||||
*/
|
||||
private RequestParamsEntity buildRequestParams(Order order, SourceDTO sourceDTO) {
|
||||
return RequestParamsEntity.builder()
|
||||
.appId("68c9ba9a92934623acdb6e84b4174f43") // 从配置文件获取
|
||||
.taskId(order.getOrderNo()) // 使用订单号作为任务ID
|
||||
.callbackUrl("your-callback-url") // 从配置文件获取
|
||||
.appId(appId) // 使用配置文件中的appId
|
||||
.taskId(order.getOrderNo())
|
||||
.callbackUrl(callbackUrl) // 使用配置文件中的callbackUrl
|
||||
.source(sourceDTO)
|
||||
.build();
|
||||
}
|
||||
@@ -157,4 +232,18 @@ public class AutoCutVideoController {
|
||||
|
||||
return "other";
|
||||
}
|
||||
|
||||
private String extractJobId(Object response) {
|
||||
// Implementation of extractJobId method
|
||||
return null; // Placeholder return, actual implementation needed
|
||||
}
|
||||
|
||||
private boolean isValidCallback(CallbackDTO callback) {
|
||||
// Implementation of isValidCallback method
|
||||
return false; // Placeholder return, actual implementation needed
|
||||
}
|
||||
|
||||
private void notifyUser(String userId, String message) {
|
||||
// Implementation of notifyUser method
|
||||
}
|
||||
}
|
||||
|
||||
-3
@@ -97,9 +97,6 @@ public class OrderController {
|
||||
@Autowired
|
||||
private IProfitSharingService profitSharingService;
|
||||
|
||||
@Autowired
|
||||
private SettleInfo defaultSettleInfo; // 注入配置的SettleInfo
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
package com.central.order.controller;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.order.model.VideoTemplate;
|
||||
import com.central.order.service.IVideoTemplateService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/video/template")
|
||||
@Tag(name = "视频模板管理")
|
||||
public class VideoTemplateController {
|
||||
|
||||
private final IVideoTemplateService videoTemplateService;
|
||||
|
||||
@Operation(summary = "分页查询模板")
|
||||
@GetMapping("/list")
|
||||
public Result<PageResult<VideoTemplate>> list(@RequestParam Map<String, Object> params) {
|
||||
try {
|
||||
PageResult<VideoTemplate> result = videoTemplateService.findList(params);
|
||||
return Result.succeed(result);
|
||||
} catch (Exception e) {
|
||||
log.error("查询模板列表失败", e);
|
||||
return Result.failed("查询失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "添加模板")
|
||||
@PostMapping
|
||||
public Result<Boolean> save(@RequestBody VideoTemplate template) {
|
||||
try {
|
||||
boolean result = videoTemplateService.saveTemplate(template);
|
||||
return Result.succeed(result);
|
||||
} catch (Exception e) {
|
||||
log.error("添加模板失败", e);
|
||||
return Result.failed("添加失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "更新模板")
|
||||
@PutMapping
|
||||
public Result<Boolean> update(@RequestBody VideoTemplate template) {
|
||||
try {
|
||||
boolean result = videoTemplateService.updateTemplate(template);
|
||||
return Result.succeed(result);
|
||||
} catch (Exception e) {
|
||||
log.error("更新模板失败", e);
|
||||
return Result.failed("更新失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "删除模板")
|
||||
@DeleteMapping("/{id}")
|
||||
public Result<Boolean> delete(@PathVariable Long id) {
|
||||
try {
|
||||
boolean result = videoTemplateService.deleteTemplate(id);
|
||||
return Result.succeed(result);
|
||||
} catch (Exception e) {
|
||||
log.error("删除模板失败", e);
|
||||
return Result.failed("删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "更新模板状态")
|
||||
@PutMapping("/{id}/status/{status}")
|
||||
public Result<Boolean> updateStatus(@PathVariable Long id, @PathVariable Integer status) {
|
||||
try {
|
||||
boolean result = videoTemplateService.updateStatus(id, status);
|
||||
return Result.succeed(result);
|
||||
} catch (Exception e) {
|
||||
log.error("更新模板状态失败", e);
|
||||
return Result.failed("更新状态失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "获取可用模板")
|
||||
@GetMapping("/active")
|
||||
public Result<VideoTemplate> getActiveTemplate() {
|
||||
try {
|
||||
VideoTemplate template = videoTemplateService.getActiveTemplate();
|
||||
return Result.succeed(template);
|
||||
} catch (Exception e) {
|
||||
log.error("获取可用模板失败", e);
|
||||
return Result.failed("获取失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,4 +28,59 @@ public enum OrderStatus implements ZltEnum {
|
||||
private Integer id;
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 判断订单状态是否允许编辑视频
|
||||
* 只有设备执行完成的订单才能进行视频编辑
|
||||
*/
|
||||
public static boolean isValidForEdit(Integer status) {
|
||||
return status != null && status.equals(COMPLETE.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID获取状态枚举
|
||||
*/
|
||||
public static OrderStatus fromId(Integer id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
for (OrderStatus status : values()) {
|
||||
if (status.getId().equals(id)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态描述
|
||||
*/
|
||||
public static String getDesc(Integer id) {
|
||||
OrderStatus status = fromId(id);
|
||||
return status != null ? status.getContent() : "未知状态";
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为最终状态
|
||||
*/
|
||||
public static boolean isFinalStatus(Integer status) {
|
||||
return status != null && (
|
||||
status.equals(CANCELED.getId()) ||
|
||||
status.equals(UPLOADED.getId()) ||
|
||||
status.equals(REFUNDED.getId()) ||
|
||||
status.equals(REFUND_FAILED.getId())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否可以退款
|
||||
*/
|
||||
public static boolean canRefund(Integer status) {
|
||||
return status != null && (
|
||||
status.equals(PAID.getId()) ||
|
||||
status.equals(DOING.getId()) ||
|
||||
status.equals(COMPLETE.getId()) ||
|
||||
status.equals(UPLOADING.getId()) ||
|
||||
status.equals(UPLOADED.getId())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.central.order.mapper;
|
||||
|
||||
import com.central.order.model.vo.DistributionDataVO;
|
||||
import com.central.order.model.vo.IncomeDataVO;
|
||||
import com.central.order.model.vo.TourismRankingVO;
|
||||
import com.central.order.model.vo.TrendDataVO;
|
||||
@@ -45,17 +44,7 @@ public interface DashboardMapper {
|
||||
})
|
||||
Long getTodayIncome();
|
||||
|
||||
@Select("SELECT COUNT(*) FROM device-center.wayline_file WHERE is_del = 0")
|
||||
Long getTotalWaylines();
|
||||
|
||||
@Select("SELECT COUNT(*) FROM device-center.wayline_file WHERE is_del = 0 AND last_use_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)")
|
||||
Long getActiveWaylines();
|
||||
|
||||
@Select("SELECT COUNT(*) FROM device-center.manage_device WHERE is_del = 0")
|
||||
Long getTotalDevices();
|
||||
|
||||
@Select("SELECT COUNT(*) FROM device-center.manage_device WHERE is_del = 0 AND status = 1")
|
||||
Long getOnlineDevices();
|
||||
|
||||
@Select({
|
||||
"SELECT",
|
||||
@@ -69,16 +58,6 @@ public interface DashboardMapper {
|
||||
})
|
||||
List<TrendDataVO> getOrderTrend();
|
||||
|
||||
@Select({
|
||||
"SELECT",
|
||||
" device_type as type,",
|
||||
" COUNT(*) as value",
|
||||
"FROM devices",
|
||||
"WHERE is_del = 0",
|
||||
"GROUP BY device_type"
|
||||
})
|
||||
List<DistributionDataVO> getDeviceDistribution();
|
||||
|
||||
@Select({
|
||||
"SELECT",
|
||||
" 'platform' as type,",
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.central.order.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.central.order.model.EditTask;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 视频编辑任务Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface EditTaskMapper extends BaseMapper<EditTask> {
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.central.order.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.central.order.model.VideoTemplate;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface VideoTemplateMapper extends BaseMapper<VideoTemplate> {
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.central.order.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("edit_task")
|
||||
public class EditTask {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private Long userId;
|
||||
private String orderSn;
|
||||
private String jobId;
|
||||
private String result;
|
||||
|
||||
@Schema(description = "状态:0-待处理 1-处理中 2-处理完成 3-处理失败")
|
||||
private Integer status;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateTime;
|
||||
//租户ID
|
||||
private Long tenantId;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
+6
-7
@@ -1,14 +1,13 @@
|
||||
package com.central.order.model;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.Getter;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
/**
|
||||
* 一键成片请求参数实体类
|
||||
@@ -24,15 +23,15 @@ public class RequestParamsEntity {
|
||||
@Schema(description = "应用ID")
|
||||
@NotBlank(message = "应用ID不能为空")
|
||||
private String appId;
|
||||
|
||||
|
||||
@Schema(description = "任务ID")
|
||||
@NotBlank(message = "任务ID不能为空")
|
||||
private String taskId;
|
||||
|
||||
|
||||
@Schema(description = "回调地址")
|
||||
@NotBlank(message = "回调地址不能为空")
|
||||
private String callbackUrl;
|
||||
|
||||
|
||||
@Schema(description = "素材来源")
|
||||
@NotNull(message = "素材来源不能为空")
|
||||
private SourceDTO source;
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.central.order.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.central.common.model.SuperEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("video_template")
|
||||
@Schema(description = "视频模板")
|
||||
public class VideoTemplate extends SuperEntity {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@Schema(description = "主键ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "模板ID")
|
||||
private String templateId;
|
||||
|
||||
@Schema(description = "模板名称")
|
||||
private String templateName;
|
||||
|
||||
@Schema(description = "模板描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "状态:0-禁用 1-启用")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "模板配置JSON")
|
||||
private String config;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
@Schema(description = "租户ID")
|
||||
private Long tenantId;
|
||||
|
||||
@Schema(description = "所属公司")
|
||||
private String company;
|
||||
|
||||
@Schema(description = "是否删除:0-否 1-是")
|
||||
private Integer isDel;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.central.order.model.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CallbackDTO {
|
||||
private String jobId;
|
||||
private String status; // SUCCESS, FAILED
|
||||
private String result; // 处理结果,可能包含视频URL或错误信息
|
||||
private String errorCode;
|
||||
private String errorMessage;
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.central.order.model.dto;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class VideoEditRequest {
|
||||
private List<MediaInfo> sources;
|
||||
private OutputInfo output;
|
||||
private String templateId;
|
||||
private String projectName;
|
||||
private String pipelineName;
|
||||
private String callbackUrl;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public static class MediaInfo {
|
||||
private String mediaUrl;
|
||||
private String mediaType; // VIDEO, IMAGE, AUDIO
|
||||
private Integer duration; // 持续时间(毫秒)
|
||||
private String text; // 文本内容
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public static class OutputInfo {
|
||||
private String outputName;
|
||||
private String outputType; // MP4, MOV等
|
||||
private Integer width;
|
||||
private Integer height;
|
||||
private String quality; // HD, SD等
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.central.order.model.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 视频编辑状态枚举
|
||||
*/
|
||||
@Getter
|
||||
public enum VideoEditStatus {
|
||||
QUEUED("Queued", "排队中"),
|
||||
RUNNING("Running", "处理中"),
|
||||
SUCCESS("Success", "处理成功"),
|
||||
FAIL("Fail", "处理失败"),
|
||||
UNKNOWN("Unknown", "未知状态");
|
||||
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
||||
VideoEditStatus(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public static VideoEditStatus fromCode(String code) {
|
||||
for (VideoEditStatus status : values()) {
|
||||
if (status.getCode().equals(code)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.central.order.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.central.order.model.EditTask;
|
||||
|
||||
/**
|
||||
* 视频编辑任务服务接口
|
||||
*/
|
||||
public interface IEditTaskService extends IService<EditTask> {
|
||||
/**
|
||||
* 创建编辑任务
|
||||
*
|
||||
* @param orderSn 订单编号
|
||||
* @param userId 用户ID
|
||||
* @return 任务实体
|
||||
*/
|
||||
EditTask createTask(String orderSn, Long userId);
|
||||
|
||||
/**
|
||||
* 更新任务状态
|
||||
*
|
||||
* @param jobId 任务ID
|
||||
* @param status 状态
|
||||
* @param result 结果信息
|
||||
* @return 是否更新成功
|
||||
*/
|
||||
boolean updateTaskStatus(String jobId, Integer status, String result);
|
||||
|
||||
/**
|
||||
* 根据任务ID获取任务
|
||||
*
|
||||
* @param jobId 任务ID
|
||||
* @return 任务实体
|
||||
*/
|
||||
EditTask getTaskByJobId(String jobId);
|
||||
|
||||
/**
|
||||
* 根据订单号获取最新任务
|
||||
*
|
||||
* @param orderSn 订单编号
|
||||
* @return 任务实体
|
||||
*/
|
||||
EditTask getTaskByOrderSn(String orderSn);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.central.order.service;
|
||||
|
||||
import com.central.order.model.OrderFile;
|
||||
import com.central.order.model.TourismFile;
|
||||
import java.util.List;
|
||||
|
||||
public interface IMediaService {
|
||||
/**
|
||||
* 提交智能一键成片任务
|
||||
*/
|
||||
String submitEditTask(String orderNo, List<OrderFile> orderFiles, List<TourismFile> tourismFiles);
|
||||
|
||||
/**
|
||||
* 查询任务状态
|
||||
*/
|
||||
String getTaskStatus(String jobId);
|
||||
|
||||
/**
|
||||
* 获取任务结果
|
||||
*/
|
||||
String getTaskResult(String jobId);
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.central.order.service;
|
||||
|
||||
import com.central.order.model.OrderFile;
|
||||
import com.central.order.model.TourismFile;
|
||||
import com.central.order.model.dto.VideoEditStatus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 视频编辑服务接口
|
||||
*/
|
||||
public interface IVideoEditService {
|
||||
/**
|
||||
* 提交编辑任务
|
||||
*
|
||||
* @param orderNo 订单号
|
||||
* @param orderFiles 订单相关文件
|
||||
* @param tourismFiles 景区相关文件
|
||||
* @return 任务ID
|
||||
*/
|
||||
String submitEditTask(String orderNo, List<OrderFile> orderFiles, List<TourismFile> tourismFiles);
|
||||
|
||||
/**
|
||||
* 查询编辑任务状态
|
||||
*
|
||||
* @param jobId 任务ID
|
||||
* @return 任务状态
|
||||
*/
|
||||
VideoEditStatus queryEditStatus(String jobId);
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.central.order.service;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.service.ISuperService;
|
||||
import com.central.order.model.VideoTemplate;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface IVideoTemplateService extends ISuperService<VideoTemplate> {
|
||||
|
||||
/**
|
||||
* 分页查询模板
|
||||
*/
|
||||
PageResult<VideoTemplate> findList(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 添加模板
|
||||
*/
|
||||
boolean saveTemplate(VideoTemplate template);
|
||||
|
||||
/**
|
||||
* 更新模板
|
||||
*/
|
||||
boolean updateTemplate(VideoTemplate template);
|
||||
|
||||
/**
|
||||
* 删除模板
|
||||
*/
|
||||
boolean deleteTemplate(Long id);
|
||||
|
||||
/**
|
||||
* 更新模板状态
|
||||
*/
|
||||
boolean updateStatus(Long id, Integer status);
|
||||
|
||||
/**
|
||||
* 获取可用模板
|
||||
*/
|
||||
VideoTemplate getActiveTemplate();
|
||||
}
|
||||
+12
-62
@@ -22,23 +22,22 @@ public class DashboardServiceImpl implements IDashboardService {
|
||||
public DashboardStatisticsVO getDashboardStatistics() {
|
||||
DashboardStatisticsVO statistics = new DashboardStatisticsVO();
|
||||
|
||||
// 1. 获取订单统计
|
||||
statistics.setOrderStats(getOrderStatistics());
|
||||
try {
|
||||
// 1. 获取订单统计
|
||||
statistics.setOrderStats(getOrderStatistics());
|
||||
|
||||
// 2. 获取收入统计
|
||||
statistics.setIncomeStats(getIncomeStatistics());
|
||||
// 2. 获取收入统计
|
||||
statistics.setIncomeStats(getIncomeStatistics());
|
||||
|
||||
// 3. 获取航线统计
|
||||
// statistics.setWaylineStats(getWaylineStatistics());
|
||||
// 5. 获取图表统计
|
||||
statistics.setChartStats(getChartStatistics());
|
||||
|
||||
// 4. 获取设备统计
|
||||
// statistics.setDeviceStats(getDeviceStatistics());
|
||||
// 6. 获取景区排行
|
||||
statistics.setTourismRanking(getTourismRanking());
|
||||
|
||||
// 5. 获取图表统计
|
||||
statistics.setChartStats(getChartStatistics());
|
||||
|
||||
// 6. 获取景区排行
|
||||
statistics.setTourismRanking(getTourismRanking());
|
||||
} catch (Exception e) {
|
||||
log.error("获取仪表盘统计数据失败", e);
|
||||
}
|
||||
|
||||
return statistics;
|
||||
}
|
||||
@@ -100,52 +99,6 @@ public class DashboardServiceImpl implements IDashboardService {
|
||||
return stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取航线统计
|
||||
*/
|
||||
private WaylineStatistics getWaylineStatistics() {
|
||||
WaylineStatistics stats = new WaylineStatistics();
|
||||
|
||||
// 获取航线总数
|
||||
stats.setTotalWaylines(dashboardMapper.getTotalWaylines());
|
||||
|
||||
// 获取活跃航线数
|
||||
stats.setActiveWaylines(dashboardMapper.getActiveWaylines());
|
||||
|
||||
// 计算使用率
|
||||
if (stats.getTotalWaylines() > 0) {
|
||||
BigDecimal usage = new BigDecimal(stats.getActiveWaylines())
|
||||
.divide(new BigDecimal(stats.getTotalWaylines()), 4, RoundingMode.HALF_UP)
|
||||
.multiply(new BigDecimal(100));
|
||||
stats.setWaylineUsage(usage);
|
||||
}
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备统计
|
||||
*/
|
||||
private DeviceStatistics getDeviceStatistics() {
|
||||
DeviceStatistics stats = new DeviceStatistics();
|
||||
|
||||
// 获取设备总数
|
||||
stats.setTotalDevices(dashboardMapper.getTotalDevices());
|
||||
|
||||
// 获取在线设备数
|
||||
stats.setOnlineDevices(dashboardMapper.getOnlineDevices());
|
||||
|
||||
// 计算在线率
|
||||
if (stats.getTotalDevices() > 0) {
|
||||
BigDecimal onlineRate = new BigDecimal(stats.getOnlineDevices())
|
||||
.divide(new BigDecimal(stats.getTotalDevices()), 4, RoundingMode.HALF_UP)
|
||||
.multiply(new BigDecimal(100));
|
||||
stats.setDeviceOnlineRate(onlineRate);
|
||||
}
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图表统计
|
||||
*/
|
||||
@@ -155,9 +108,6 @@ public class DashboardServiceImpl implements IDashboardService {
|
||||
// 获取订单趋势(最近7天)
|
||||
stats.setOrderTrend(dashboardMapper.getOrderTrend());
|
||||
|
||||
// 获取设备分布
|
||||
// stats.setDeviceDistribution(dashboardMapper.getDeviceDistribution());
|
||||
|
||||
// 获取收入构成
|
||||
stats.setIncomeData(dashboardMapper.getIncomeData());
|
||||
|
||||
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
package com.central.order.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.central.common.exception.BusinessException;
|
||||
import com.central.order.mapper.EditTaskMapper;
|
||||
import com.central.order.model.EditTask;
|
||||
import com.central.order.service.IEditTaskService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 视频编辑任务服务实现类
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class EditTaskServiceImpl extends ServiceImpl<EditTaskMapper, EditTask> implements IEditTaskService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public EditTask createTask(String orderSn, Long userId) {
|
||||
try {
|
||||
EditTask task = EditTask.builder()
|
||||
.orderSn(orderSn)
|
||||
.userId(userId)
|
||||
.status(0) // 初始状态:待处理
|
||||
.createTime(new Date())
|
||||
.build();
|
||||
|
||||
// 保存任务
|
||||
if (!save(task)) {
|
||||
throw new BusinessException("创建任务失败");
|
||||
}
|
||||
|
||||
return task;
|
||||
} catch (Exception e) {
|
||||
log.error("创建编辑任务失败: orderSn={}, userId={}", orderSn, userId, e);
|
||||
throw new BusinessException("创建任务失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updateTaskStatus(String jobId, Integer status, String result) {
|
||||
try {
|
||||
return update(new LambdaUpdateWrapper<EditTask>()
|
||||
.eq(EditTask::getJobId, jobId)
|
||||
.set(EditTask::getStatus, status)
|
||||
.set(EditTask::getResult, result)
|
||||
.set(EditTask::getRemark, "状态更新时间:" + new Date()));
|
||||
} catch (Exception e) {
|
||||
log.error("更新任务状态失败: jobId={}, status={}", jobId, status, e);
|
||||
throw new BusinessException("更新任务状态失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EditTask getTaskByJobId(String jobId) {
|
||||
try {
|
||||
return getOne(new LambdaQueryWrapper<EditTask>()
|
||||
.eq(EditTask::getJobId, jobId));
|
||||
} catch (Exception e) {
|
||||
log.error("查询任务失败: jobId={}", jobId, e);
|
||||
throw new BusinessException("查询任务失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EditTask getTaskByOrderSn(String orderSn) {
|
||||
try {
|
||||
return getOne(new LambdaQueryWrapper<EditTask>()
|
||||
.eq(EditTask::getOrderSn, orderSn)
|
||||
.orderByDesc(EditTask::getId)
|
||||
.last("LIMIT 1"));
|
||||
} catch (Exception e) {
|
||||
log.error("查询订单任务失败: orderSn={}", orderSn, e);
|
||||
throw new BusinessException("查询订单任务失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
package com.central.order.service.impl;
|
||||
|
||||
import com.aliyun.ice20201109.Client;
|
||||
import com.aliyun.ice20201109.models.*;
|
||||
import com.central.common.exception.BusinessException;
|
||||
import com.central.order.config.AliyunImsConfig;
|
||||
import com.central.order.model.OrderFile;
|
||||
import com.central.order.model.TourismFile;
|
||||
import com.central.order.service.IMediaService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MediaServiceImpl implements IMediaService {
|
||||
|
||||
private final Client imsClient;
|
||||
private final AliyunImsConfig imsConfig;
|
||||
|
||||
@Override
|
||||
public String submitEditTask(String orderNo, List<OrderFile> orderFiles, List<TourismFile> tourismFiles) {
|
||||
try {
|
||||
// 1. 构建媒体资源列表
|
||||
List<String> mediaAssets = buildMediaAssets(orderFiles, tourismFiles);
|
||||
|
||||
// 2. 构建输出配置
|
||||
String outputConfig = buildOutputConfig(orderNo);
|
||||
|
||||
// 3. 构建请求
|
||||
SubmitBatchMediaProducingJobRequest request = new SubmitBatchMediaProducingJobRequest()
|
||||
.setProject(imsConfig.getProjectName())
|
||||
.setPipelineName(imsConfig.getPipelineName())
|
||||
.setTemplateId(imsConfig.getTemplateId())
|
||||
.setInputMediaAssets(mediaAssets)
|
||||
.setOutputConfig(outputConfig)
|
||||
.setCallbackUrl(imsConfig.getCallbackUrl());
|
||||
|
||||
// 4. 提交任务
|
||||
SubmitBatchMediaProducingJobResponse response = imsClient.submitBatchMediaProducingJob(request);
|
||||
|
||||
if (response != null && response.getStatusCode() == 200) {
|
||||
String jobId = response.getBody().getJobId();
|
||||
log.info("提交智能一键成片任务成功: orderNo={}, jobId={}", orderNo, jobId);
|
||||
return jobId;
|
||||
} else {
|
||||
throw new BusinessException("提交任务失败: " + (response != null ? response.getBody().getMessage() : "未知错误"));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("提交智能一键成片任务失败: orderNo={}", orderNo, e);
|
||||
throw new BusinessException("提交任务失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTaskStatus(String jobId) {
|
||||
try {
|
||||
GetBatchMediaProducingJobRequest request = new GetBatchMediaProducingJobRequest()
|
||||
.setJobId(jobId)
|
||||
.setProject(imsConfig.getProjectName());
|
||||
|
||||
GetBatchMediaProducingJobResponse response = imsClient.getBatchMediaProducingJob(request);
|
||||
|
||||
if (response != null && response.getBody() != null) {
|
||||
return response.getBody().getStatus();
|
||||
}
|
||||
return "UNKNOWN";
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("查询任务状态失败: jobId={}", jobId, e);
|
||||
throw new BusinessException("查询任务状态失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTaskResult(String jobId) {
|
||||
try {
|
||||
GetBatchMediaProducingJobRequest request = new GetBatchMediaProducingJobRequest()
|
||||
.setJobId(jobId)
|
||||
.setProject(imsConfig.getProjectName());
|
||||
|
||||
GetBatchMediaProducingJobResponse response = imsClient.getBatchMediaProducingJob(request);
|
||||
|
||||
if (response != null && response.getBody() != null) {
|
||||
return response.getBody().getOutputUrl();
|
||||
}
|
||||
return null;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("获取任务结果失败: jobId={}", jobId, e);
|
||||
throw new BusinessException("获取任务结果失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建媒体资源列表
|
||||
*/
|
||||
private List<String> buildMediaAssets(List<OrderFile> orderFiles, List<TourismFile> tourismFiles) {
|
||||
List<String> assets = new ArrayList<>();
|
||||
|
||||
// 处理订单文件
|
||||
if (orderFiles != null) {
|
||||
for (OrderFile file : orderFiles) {
|
||||
assets.add(String.format("{\"type\":\"%s\",\"url\":\"oss://%s/%s\"}",
|
||||
getMediaType(file.getFileType()),
|
||||
imsConfig.getBucket(),
|
||||
file.getFilePath()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// 处理景区文件
|
||||
if (tourismFiles != null) {
|
||||
for (TourismFile file : tourismFiles) {
|
||||
assets.add(String.format("{\"type\":\"image\",\"url\":\"oss://%s/%s\"}",
|
||||
imsConfig.getBucket(),
|
||||
file.getImageUrl()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
return assets;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建输出配置
|
||||
*/
|
||||
private String buildOutputConfig(String orderNo) {
|
||||
return String.format(
|
||||
"{\"resolution\":\"1080p\",\"bitrate\":\"5000kbps\",\"fileName\":\"%s_%s\"}",
|
||||
orderNo,
|
||||
System.currentTimeMillis()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取媒体类型
|
||||
*/
|
||||
private String getMediaType(String fileType) {
|
||||
if (fileType == null) return "other";
|
||||
if (fileType.startsWith("video/")) return "video";
|
||||
if (fileType.startsWith("audio/")) return "audio";
|
||||
if (fileType.startsWith("image/")) return "image";
|
||||
return "other";
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.central.order.service.impl;
|
||||
|
||||
import com.central.common.exception.BusinessException;
|
||||
import com.central.order.constants.EditTaskStatus;
|
||||
import com.central.order.model.OrderFile;
|
||||
import com.central.order.model.TourismFile;
|
||||
import com.central.order.model.dto.VideoEditStatus;
|
||||
import com.central.order.service.IEditTaskService;
|
||||
import com.central.order.service.IMediaService;
|
||||
import com.central.order.service.IVideoEditService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 视频编辑服务实现类
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class VideoEditServiceImpl implements IVideoEditService {
|
||||
|
||||
private final IMediaService mediaService;
|
||||
private final IEditTaskService editTaskService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String submitEditTask(String orderNo, List<OrderFile> orderFiles, List<TourismFile> tourismFiles) {
|
||||
try {
|
||||
// 提交智能一键成片任务
|
||||
String jobId = mediaService.submitEditTask(orderNo, orderFiles, tourismFiles);
|
||||
|
||||
// 更新任务状态
|
||||
editTaskService.updateTaskStatus(jobId, EditTaskStatus.PROCESSING, null);
|
||||
|
||||
return jobId;
|
||||
} catch (Exception e) {
|
||||
log.error("提交视频编辑任务失败: orderNo={}", orderNo, e);
|
||||
throw new BusinessException("提交编辑任务失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VideoEditStatus queryEditStatus(String jobId) {
|
||||
try {
|
||||
String status = mediaService.getTaskStatus(jobId);
|
||||
return VideoEditStatus.fromCode(status);
|
||||
} catch (Exception e) {
|
||||
log.error("查询任务状态失败: jobId={}", jobId, e);
|
||||
throw new BusinessException("查询任务状态失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package com.central.order.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.service.impl.SuperServiceImpl;
|
||||
import com.central.order.mapper.VideoTemplateMapper;
|
||||
import com.central.order.model.VideoTemplate;
|
||||
import com.central.order.service.IVideoTemplateService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class VideoTemplateServiceImpl extends SuperServiceImpl<VideoTemplateMapper, VideoTemplate> implements IVideoTemplateService {
|
||||
|
||||
@Override
|
||||
public PageResult<VideoTemplate> findList(Map<String, Object> params) {
|
||||
Page<VideoTemplate> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit"));
|
||||
|
||||
LambdaQueryWrapper<VideoTemplate> wrapper = new LambdaQueryWrapper<VideoTemplate>()
|
||||
.eq(VideoTemplate::getIsDel, 0)
|
||||
.orderByDesc(VideoTemplate::getCreateTime);
|
||||
|
||||
Page<VideoTemplate> result = baseMapper.selectPage(page, wrapper);
|
||||
return PageResult.<VideoTemplate>builder().data(result.getRecords()).count(result.getTotal()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean saveTemplate(VideoTemplate template) {
|
||||
template.setCreateTime(new Date());
|
||||
template.setUpdateTime(new Date());
|
||||
template.setIsDel(0);
|
||||
return save(template);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updateTemplate(VideoTemplate template) {
|
||||
template.setUpdateTime(new Date());
|
||||
return updateById(template);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean deleteTemplate(Long id) {
|
||||
VideoTemplate template = getById(id);
|
||||
if (template != null) {
|
||||
template.setIsDel(1);
|
||||
template.setUpdateTime(new Date());
|
||||
return updateById(template);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updateStatus(Long id, Integer status) {
|
||||
VideoTemplate template = getById(id);
|
||||
if (template != null) {
|
||||
template.setStatus(status);
|
||||
template.setUpdateTime(new Date());
|
||||
return updateById(template);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VideoTemplate getActiveTemplate() {
|
||||
return getOne(new LambdaQueryWrapper<VideoTemplate>()
|
||||
.eq(VideoTemplate::getStatus, 1)
|
||||
.eq(VideoTemplate::getIsDel, 0)
|
||||
.orderByDesc(VideoTemplate::getCreateTime)
|
||||
.last("LIMIT 1"));
|
||||
}
|
||||
}
|
||||
@@ -75,6 +75,18 @@ file:
|
||||
# password: ${zlt.datasource.password}
|
||||
videos:
|
||||
edit-config:
|
||||
url: ${EDIT_SERVICE_URL:http://example.com/api/edit}
|
||||
app-id: ${EDIT_APP_ID:your-app-id}
|
||||
callback-url: ${EDIT_CALLBACK_URL:http://your-domain/api/callback}
|
||||
url: ${VIDEOS_EDIT_URL:http://example.com/api/edit}
|
||||
app-id: ${VIDEOS_APP_ID:gcb4432dcc7e4e3a92063807f3e75d58}
|
||||
callback-url: ${VIDEOS_CALLBACK_URL:http://img.goflytec.com/api-order/auto/cut/callback}
|
||||
|
||||
aliyun:
|
||||
ims:
|
||||
endpoint: ice.cn-shanghai.aliyuncs.com
|
||||
access-key-id: ${ALIYUN_ACCESS_KEY_ID}
|
||||
access-key-secret: ${ALIYUN_ACCESS_KEY_SECRET}
|
||||
region: cn-shanghai
|
||||
project-name: ${IMS_PROJECT_NAME}
|
||||
pipeline-name: ${IMS_PIPELINE_NAME}
|
||||
template-id: ${IMS_TEMPLATE_ID}
|
||||
callback-url: ${IMS_CALLBACK_URL}
|
||||
bucket: ${OSS_BUCKET_NAME}
|
||||
|
||||
Reference in New Issue
Block a user