Please enter the commit message for your changes. Lines starting

with '#' will be ignored, and an empty message aborts the commit.

On branch develop
Your branch is up to date with 'goflyapp/develop'.

Changes to be committed:
	modified:   zlt-business/order-center/src/main/java/com/central/order/config/AliyunImsConfig.java
	modified:   zlt-business/order-center/src/main/java/com/central/order/controller/AutoCutVideoController.java
	modified:   zlt-business/order-center/src/main/java/com/central/order/feign/DeviceCenterService.java
	new file:   zlt-business/order-center/src/main/java/com/central/order/model/params/EditTaskQueryParams.java
	modified:   zlt-business/order-center/src/main/java/com/central/order/service/IEditTaskService.java
	modified:   zlt-business/order-center/src/main/java/com/central/order/service/impl/EditTaskServiceImpl.java
	modified:   zlt-business/order-center/src/main/java/com/central/order/service/impl/MediaServiceImpl.java
	modified:   zlt-business/order-center/src/main/resources/application.yml
	modified:   zlt-business/order-center/src/main/resources/bootstrap.yml
	modified:   zlt-config/src/main/resources/bootstrap.properties
	modified:   zlt-web/react-web/src/main/frontend/config/proxy.ts
	modified:   zlt-web/react-web/src/main/frontend/config/routes.ts
	new file:   zlt-web/react-web/src/main/frontend/src/pages/orders/EditTask/components/CreateForm.tsx
	new file:   zlt-web/react-web/src/main/frontend/src/pages/orders/EditTask/components/UpdateForm.tsx
	new file:   zlt-web/react-web/src/main/frontend/src/pages/orders/EditTask/index.tsx
	modified:   zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/index.tsx
	modified:   zlt-web/react-web/src/main/frontend/src/pages/orders/Tourism/components/UpdateForm.tsx
	modified:   zlt-web/react-web/src/main/frontend/src/pages/orders/Tourism/index.tsx
	modified:   zlt-web/react-web/src/main/frontend/src/services/orders/api.ts
	modified:   zlt-web/react-web/src/main/frontend/src/services/orders/typings.d.ts
This commit is contained in:
2025-04-15 23:43:17 +08:00
parent 08af710d22
commit ec04ebe97a
20 changed files with 933 additions and 101 deletions
@@ -11,7 +11,7 @@ import org.springframework.context.annotation.Configuration;
@Configuration
@ConfigurationProperties(prefix = "aliyun.ims")
public class AliyunImsConfig {
private String endpoint;
private String endpoint = "ice.cn-beijing.aliyuncs.com";
private String accessKeyId;
private String accessKeySecret;
private String region;
@@ -29,4 +29,4 @@ public class AliyunImsConfig {
.setEndpoint(endpoint);
return new Client(config);
}
}
}
@@ -1,11 +1,13 @@
package com.central.order.controller;
import com.central.common.model.PageResult;
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.model.dto.CallbackDTO;
import com.central.order.model.params.EditTaskQueryParams;
import com.central.order.service.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -246,4 +248,58 @@ public class AutoCutVideoController {
private void notifyUser(String userId, String message) {
// Implementation of notifyUser method
}
@Operation(summary = "获取剪辑任务列表")
@GetMapping("/list")
public Result<PageResult<EditTask>> getTaskList(
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@RequestParam(required = false) String orderSn,
@RequestParam(required = false) String jobId,
@RequestParam(required = false) Integer status) {
try {
EditTaskQueryParams params = EditTaskQueryParams.builder()
.page(page)
.limit(limit)
.orderSn(orderSn)
.jobId(jobId)
.status(status)
.build();
PageResult<EditTask> result = editTaskService.getTaskList(params);
return Result.succeed(result);
} catch (Exception e) {
log.error("查询剪辑任务列表失败", e);
return Result.failed("查询任务列表失败");
}
}
@Operation(summary = "保存或更新剪辑任务")
@PostMapping("/save")
public Result<Boolean> saveOrUpdateTask(@RequestBody EditTask task) {
try {
boolean success = editTaskService.saveOrUpdateTask(task);
return Result.succeed(success);
} catch (Exception e) {
log.error("保存剪辑任务失败: task={}", task, e);
return Result.failed("保存任务失败: " + e.getMessage());
}
}
@Operation(summary = "删除剪辑任务")
@DeleteMapping("/delete/{id}")
public Result<Boolean> deleteTask(@PathVariable Integer id) {
try {
boolean success = editTaskService.deleteTask(id);
return Result.succeed(success);
} catch (Exception e) {
log.error("删除剪辑任务失败: id={}", id, e);
return Result.failed("删除任务失败: " + e.getMessage());
}
}
}
@@ -25,5 +25,5 @@ public interface DeviceCenterService {
*/
@GetMapping("/wayline/sign/{id}")
String getLineFileSign(@PathVariable("id") String id);
}
@@ -0,0 +1,18 @@
package com.central.order.model.params;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class EditTaskQueryParams {
private Integer page = 1;
private Integer limit = 10;
private String orderSn;
private String jobId;
private Integer status;
}
@@ -1,7 +1,9 @@
package com.central.order.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.central.common.model.PageResult;
import com.central.order.model.EditTask;
import com.central.order.model.params.EditTaskQueryParams;
/**
* 视频编辑任务服务接口
@@ -41,4 +43,19 @@ public interface IEditTaskService extends IService<EditTask> {
* @return 任务实体
*/
EditTask getTaskByOrderSn(String orderSn);
/**
* 分页查询剪辑任务
*/
PageResult<EditTask> getTaskList(EditTaskQueryParams params);
/**
* 保存或更新剪辑任务
*/
boolean saveOrUpdateTask(EditTask task);
/**
* 删除剪辑任务
*/
boolean deleteTask(Integer id);
}
@@ -2,14 +2,20 @@ 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.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.central.common.exception.BusinessException;
import com.central.common.model.PageResult;
import com.central.order.constants.EditTaskStatus;
import com.central.order.mapper.EditTaskMapper;
import com.central.order.model.EditTask;
import com.central.order.model.params.EditTaskQueryParams;
import com.central.order.service.IEditTaskService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.Date;
@@ -18,6 +24,7 @@ import java.util.Date;
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class EditTaskServiceImpl extends ServiceImpl<EditTaskMapper, EditTask> implements IEditTaskService {
@Override
@@ -81,4 +88,92 @@ public class EditTaskServiceImpl extends ServiceImpl<EditTaskMapper, EditTask> i
throw new BusinessException("查询订单任务失败: " + e.getMessage());
}
}
@Override
public PageResult<EditTask> getTaskList(EditTaskQueryParams params) {
try {
// 构建查询条件
LambdaQueryWrapper<EditTask> wrapper = new LambdaQueryWrapper<EditTask>()
.eq(StringUtils.hasText(params.getOrderSn()), EditTask::getOrderSn, params.getOrderSn())
.eq(StringUtils.hasText(params.getJobId()), EditTask::getJobId, params.getJobId())
.eq(params.getStatus() != null, EditTask::getStatus, params.getStatus())
.orderByDesc(EditTask::getId);
// 执行分页查询
Page<EditTask> page = new Page<>(params.getPage(), params.getLimit());
Page<EditTask> resultPage = page(page, wrapper);
// 转换为PageResult
return PageResult.<EditTask>builder()
.data(resultPage.getRecords())
.resp_code(0)
.count(resultPage.getTotal())
.build();
} catch (Exception e) {
log.error("查询剪辑任务列表失败", e);
throw new BusinessException("查询任务列表失败: " + e.getMessage());
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean saveOrUpdateTask(EditTask task) {
try {
// 参数验证
validateTask(task);
// 如果是新增任务
if (task.getId() == null) {
task.setCreateTime(new Date());
task.setStatus(EditTaskStatus.PENDING);
}
// 更新任务
task.setUpdateTime(new Date());
return saveOrUpdate(task);
} catch (Exception e) {
log.error("保存剪辑任务失败: task={}", task, e);
throw new BusinessException("保存任务失败: " + e.getMessage());
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean deleteTask(Integer id) {
try {
// 查询任务
EditTask task = getById(id);
if (task == null) {
throw new BusinessException("任务不存在");
}
// 检查任务状态
if (EditTaskStatus.isProcessing(task.getStatus())) {
throw new BusinessException("任务处理中,不能删除");
}
return removeById(id);
} catch (Exception e) {
log.error("删除剪辑任务失败: id={}", id, e);
throw new BusinessException("删除任务失败: " + e.getMessage());
}
}
/**
* 验证任务参数
*/
private void validateTask(EditTask task) {
if (task == null) {
throw new BusinessException("任务参数不能为空");
}
if (!StringUtils.hasText(task.getOrderSn())) {
throw new BusinessException("订单编号不能为空");
}
if (task.getUserId() == null) {
throw new BusinessException("用户ID不能为空");
}
}
}
@@ -1,7 +1,11 @@
package com.central.order.service.impl;
import com.alibaba.fastjson.JSON;
import com.aliyun.ice20201109.Client;
import com.aliyun.ice20201109.models.*;
import com.aliyun.ice20201109.models.GetMediaProducingJobRequest;
import com.aliyun.ice20201109.models.GetMediaProducingJobResponse;
import com.aliyun.ice20201109.models.SubmitMediaProducingJobRequest;
import com.aliyun.ice20201109.models.SubmitMediaProducingJobResponse;
import com.central.common.exception.BusinessException;
import com.central.order.config.AliyunImsConfig;
import com.central.order.model.OrderFile;
@@ -12,7 +16,9 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Service
@@ -25,30 +31,39 @@ public class MediaServiceImpl implements IMediaService {
@Override
public String submitEditTask(String orderNo, List<OrderFile> orderFiles, List<TourismFile> tourismFiles) {
try {
// 1. 构建媒体资源列表
List<String> mediaAssets = buildMediaAssets(orderFiles, tourismFiles);
// 1. 构建时间线配置
String timeline = buildTimeline(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());
// 3. 构建项目元数据
String projectMetadata = buildProjectMetadata(orderNo);
// 4. 构建userData
String userData = buildUserData(orderNo);
// 打印请求参数,方便调试
log.info("提交任务参数: timeline={}, outputConfig={}, projectMetadata={}, userData={}",
timeline, outputConfig, projectMetadata, userData);
// 5. 构建请求
SubmitMediaProducingJobRequest request = new SubmitMediaProducingJobRequest()
.setTimeline(timeline)
.setOutputMediaConfig(outputConfig)
.setProjectMetadata(projectMetadata)
.setUserData(userData);
// 6. 提交任务
SubmitMediaProducingJobResponse response = imsClient.submitMediaProducingJob(request);
// 4. 提交任务
SubmitBatchMediaProducingJobResponse response = imsClient.submitBatchMediaProducingJob(request);
if (response != null && response.getStatusCode() == 200) {
String jobId = response.getBody().getJobId();
log.info("提交智能一键成片任务成功: orderNo={}, jobId={}", orderNo, jobId);
log.info("提交智能一键成片任务成功: orderNo={}, jobId={}, projectId={}",
orderNo, jobId, response.getBody().getProjectId());
return jobId;
} else {
throw new BusinessException("提交任务失败: " + (response != null ? response.getBody().getMessage() : "未知错误"));
throw new BusinessException("提交任务失败: " + (response != null ? response.getBody().getRequestId() : "未知错误"));
}
} catch (Exception e) {
@@ -60,14 +75,14 @@ public class MediaServiceImpl implements IMediaService {
@Override
public String getTaskStatus(String jobId) {
try {
GetBatchMediaProducingJobRequest request = new GetBatchMediaProducingJobRequest()
.setJobId(jobId)
.setProject(imsConfig.getProjectName());
GetMediaProducingJobRequest request = new GetMediaProducingJobRequest()
.setJobId(jobId);
GetBatchMediaProducingJobResponse response = imsClient.getBatchMediaProducingJob(request);
if (response != null && response.getBody() != null) {
return response.getBody().getStatus();
GetMediaProducingJobResponse response = imsClient.getMediaProducingJob(request);
if (response != null && response.getBody() != null
&& response.getBody().getMediaProducingJob() != null) {
return response.getBody().getMediaProducingJob().getStatus();
}
return "UNKNOWN";
@@ -80,14 +95,14 @@ public class MediaServiceImpl implements IMediaService {
@Override
public String getTaskResult(String jobId) {
try {
GetBatchMediaProducingJobRequest request = new GetBatchMediaProducingJobRequest()
.setJobId(jobId)
.setProject(imsConfig.getProjectName());
GetMediaProducingJobRequest request = new GetMediaProducingJobRequest()
.setJobId(jobId);
GetBatchMediaProducingJobResponse response = imsClient.getBatchMediaProducingJob(request);
if (response != null && response.getBody() != null) {
return response.getBody().getOutputUrl();
GetMediaProducingJobResponse response = imsClient.getMediaProducingJob(request);
if (response != null && response.getBody() != null
&& response.getBody().getMediaProducingJob() != null) {
return response.getBody().getMediaProducingJob().getMediaURL();
}
return null;
@@ -98,54 +113,102 @@ public class MediaServiceImpl implements IMediaService {
}
/**
* 构建媒体资源列表
* 构建输出配置
* 按照阿里云文档格式:
* {
* "MediaURL": "oss://bucket-name/output/example.mp4"
* }
*/
private List<String> buildMediaAssets(List<OrderFile> orderFiles, List<TourismFile> tourismFiles) {
List<String> assets = new ArrayList<>();
private String buildOutputConfig(String orderNo) {
Map<String, String> config = new HashMap<>();
// 注意:这里只需要设置MediaURL
config.put("MediaURL", String.format("oss://%s/output/%s_%s.mp4",
imsConfig.getBucket(),
orderNo,
System.currentTimeMillis()
));
String configJson = JSON.toJSONString(config);
log.debug("输出配置: {}", configJson);
return configJson;
}
/**
* 构建时间线配置
* 按照阿里云文档格式:
* {
* "VideoTracks": [{
* "VideoTrackClips": [{
* "MediaId": "xxxxx"
* }]
* }]
* }
*/
private String buildTimeline(List<OrderFile> orderFiles, List<TourismFile> tourismFiles) {
Map<String, Object> timeline = new HashMap<>();
List<Map<String, Object>> videoTracks = new ArrayList<>();
Map<String, Object> videoTrack = new HashMap<>();
List<Map<String, Object>> videoTrackClips = 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()
));
Map<String, Object> clip = new HashMap<>();
clip.put("MediaId", getMediaId(file.getFilePath()));
videoTrackClips.add(clip);
}
}
// 处理景区文件
if (tourismFiles != null) {
for (TourismFile file : tourismFiles) {
assets.add(String.format("{\"type\":\"image\",\"url\":\"oss://%s/%s\"}",
imsConfig.getBucket(),
file.getImageUrl()
));
Map<String, Object> clip = new HashMap<>();
clip.put("MediaId", getMediaId(file.getImageUrl()));
videoTrackClips.add(clip);
}
}
return assets;
videoTrack.put("VideoTrackClips", videoTrackClips);
videoTracks.add(videoTrack);
timeline.put("VideoTracks", videoTracks);
String timelineJson = JSON.toJSONString(timeline);
log.debug("时间线配置: {}", timelineJson);
return timelineJson;
}
/**
* 构建输出配置
* 构建项目元数据
*/
private String buildOutputConfig(String orderNo) {
return String.format(
"{\"resolution\":\"1080p\",\"bitrate\":\"5000kbps\",\"fileName\":\"%s_%s\"}",
orderNo,
System.currentTimeMillis()
);
private String buildProjectMetadata(String orderNo) {
Map<String, String> metadata = new HashMap<>();
metadata.put("title", "订单视频_" + orderNo);
metadata.put("description", "智能一键成片生成的视频");
metadata.put("tags", "订单视频,自动生成");
String metadataJson = JSON.toJSONString(metadata);
log.debug("项目元数据: {}", metadataJson);
return metadataJson;
}
/**
* 获取媒体类型
* 构建用户数据
*/
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";
private String buildUserData(String orderNo) {
Map<String, String> userData = new HashMap<>();
userData.put("orderNo", orderNo);
String userDataJson = JSON.toJSONString(userData);
log.debug("用户数据: {}", userDataJson);
return userDataJson;
}
}
/**
* 获取媒体ID
*/
private String getMediaId(String filePath) {
// TODO: 这里需要实现获取MediaId的逻辑
// 可能需要先将文件上传到阿里云,然后获取MediaId
return filePath;
}
}
@@ -81,12 +81,12 @@ videos:
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
endpoint: ice.cn-beijing.aliyuncs.com
access-key-id: ${zlt.oss.secretId}
access-key-secret: ${zlt.oss.secretKey}
region: cn-beijing
project-name: ${IMS_PROJECT_NAME}
pipeline-name: ${IMS_PIPELINE_NAME}
template-id: ${IMS_TEMPLATE_ID}
callback-url: ${IMS_CALLBACK_URL}
bucket: ${OSS_BUCKET_NAME}
template-id: ${IMS_TEMPLATE_ID:e26a222d7cfb4a1dae85077efaeb05cd}
callback-url: ${IMS_CALLBACK_URL:http://img.goflytec.com/api-order/auto/cut/callback}
bucket: ${zlt.oss.bucketName}
@@ -4,10 +4,10 @@ server:
spring:
application:
name: order-center
# cloud:
# nacos:
# discovery:
# ip: 81.70.164.178
cloud:
nacos:
discovery:
ip: 81.70.164.178
# cloud:
# nacos:
# discovery:
@@ -1,13 +1,13 @@
########################## bootstrap级别通用配置 ##########################
# 默认开发环境
spring.profiles.active=dev
spring.profiles.active=prod
##### nacos(注册中心和配置中心)地址
#spring.cloud.nacos.server-addr=81.70.164.178:8848
spring.cloud.nacos.server-addr=127.0.0.1:8848
spring.cloud.nacos.server-addr=81.70.164.178:8848
#spring.cloud.nacos.server-addr=127.0.0.1:8848
spring.cloud.nacos.username=nacos
spring.cloud.nacos.password=nacos
#spring.cloud.nacos.password=nacosGFLY
#spring.cloud.nacos.password=nacos
spring.cloud.nacos.password=nacosGFLY
spring.cloud.nacos.config.file-extension=yml
spring.cloud.nacos.config.shared-configs[0].data-id=common.yml
spring.cloud.nacos.config.shared-configs[0].refresh=true
@@ -9,43 +9,43 @@
export default {
dev: {
'/api-uaa/': {
// target: 'http://119.45.169.13:9900',
target: 'http://127.0.0.1:9900',
target: 'http://119.45.169.13:9900',
// target: 'http://127.0.0.1:9900',
changeOrigin: true,
},
'/api-user/': {
// target: 'http://119.45.169.13:9900',
target: 'http://127.0.0.1:9900',
target: 'http://119.45.169.13:9900',
// target: 'http://127.0.0.1:9900',
changeOrigin: true,
},
'/api-log/': {
// target: 'http://119.45.169.13:9900',
target: 'http://127.0.0.1:9900',
target: 'http://119.45.169.13:9900',
// target: 'http://127.0.0.1:9900',
changeOrigin: true,
},
'/api-search/': {
// target: 'http://119.45.169.13:9900',
target: 'http://127.0.0.1:9900',
target: 'http://119.45.169.13:9900',
// target: 'http://127.0.0.1:9900',
changeOrigin: true,
},
'/api-generator/': {
// target: 'http://119.45.169.13:9900',
target: 'http://127.0.0.1:9900',
target: 'http://119.45.169.13:9900',
// target: 'http://127.0.0.1:9900',
changeOrigin: true,
},
'/api-file/': {
// target: 'http://119.45.169.13:9900',
target: 'http://127.0.0.1:9900',
target: 'http://119.45.169.13:9900',
// target: 'http://127.0.0.1:9900',
changeOrigin: true,
},
'/api-order/': {
// target: 'http://119.45.169.13:9900',
target: 'http://127.0.0.1:9900',
target: 'http://119.45.169.13:9900',
// target: 'http://127.0.0.1:9900',
changeOrigin: true,
},
'/api-device/': {
// target: 'http://119.45.169.13:9900',
target: 'http://127.0.0.1:9900',
target: 'http://119.45.169.13:9900',
// target: 'http://127.0.0.1:9900',
changeOrigin: true,
},
},
@@ -116,6 +116,10 @@
path: '/orders/videoTemplate.html',
component: './orders/VideoTemplate',
},
{
path: '/orders/editTask.html',
component: './orders/EditTask',
},
],
},
{
@@ -166,6 +170,12 @@
path: '/',
redirect: '/welcome',
},
{
path: '/orders/edit-task',
name: '剪辑任务管理',
icon: 'VideoCameraOutlined',
component: './orders/EditTask',
},
{
component: './404',
},
@@ -0,0 +1,88 @@
import React from 'react';
import {
ModalForm,
ProForm,
ProFormText,
ProFormSelect,
ProFormTextArea,
} from '@ant-design/pro-components';
interface CreateFormProps {
visible: boolean;
onVisibleChange: (visible: boolean) => void;
onSubmit: (values: ORDERS.EditTask) => Promise<boolean>;
}
const CreateForm: React.FC<CreateFormProps> = ({
visible,
onVisibleChange,
onSubmit,
}) => {
return (
<ModalForm
title="新增剪辑任务"
visible={visible}
onVisibleChange={onVisibleChange}
modalProps={{ destroyOnClose: true }}
onFinish={onSubmit}
>
<ProForm.Group>
<ProFormText
width="md"
name="userId"
label="用户ID"
rules={[{ required: true, message: '请输入用户ID' }]}
placeholder="请输入用户ID"
/>
<ProFormText
width="md"
name="orderSn"
label="订单编号"
rules={[{ required: true, message: '请输入订单编号' }]}
placeholder="请输入订单编号"
/>
</ProForm.Group>
<ProForm.Group>
<ProFormText
width="md"
name="jobId"
label="任务ID"
rules={[{ required: true, message: '请输入任务ID' }]}
placeholder="请输入任务ID"
/>
<ProFormSelect
width="md"
name="status"
label="状态"
options={[
{ label: '待处理', value: 0 },
{ label: '处理中', value: 1 },
{ label: '处理完成', value: 2 },
{ label: '处理失败', value: 3 },
]}
rules={[{ required: true, message: '请选择状态' }]}
placeholder="请选择状态"
initialValue={0}
/>
</ProForm.Group>
<ProForm.Group>
<ProFormTextArea
width="md"
name="result"
label="处理结果"
placeholder="请输入处理结果"
/>
<ProFormTextArea
width="md"
name="remark"
label="备注"
placeholder="请输入备注"
/>
</ProForm.Group>
</ModalForm>
);
};
export default CreateForm;
@@ -0,0 +1,90 @@
import React from 'react';
import {
ModalForm,
ProForm,
ProFormText,
ProFormSelect,
ProFormTextArea,
} from '@ant-design/pro-components';
interface UpdateFormProps {
updateModalVisible: boolean;
onVisibleChange: (visible: boolean) => void;
onSubmit: (values: Partial<ORDERS.EditTask>) => Promise<boolean>;
values?: ORDERS.EditTask;
}
const UpdateForm: React.FC<UpdateFormProps> = ({
updateModalVisible,
onVisibleChange,
onSubmit,
values,
}) => {
return (
<ModalForm
title="修改剪辑任务"
visible={updateModalVisible}
onVisibleChange={onVisibleChange}
modalProps={{ destroyOnClose: true }}
onFinish={onSubmit}
initialValues={values}
>
<ProForm.Group>
<ProFormText
width="md"
name="userId"
label="用户ID"
rules={[{ required: true, message: '请输入用户ID' }]}
placeholder="请输入用户ID"
/>
<ProFormText
width="md"
name="orderSn"
label="订单编号"
rules={[{ required: true, message: '请输入订单编号' }]}
placeholder="请输入订单编号"
/>
</ProForm.Group>
<ProForm.Group>
<ProFormText
width="md"
name="jobId"
label="任务ID"
rules={[{ required: true, message: '请输入任务ID' }]}
placeholder="请输入任务ID"
/>
<ProFormSelect
width="md"
name="status"
label="状态"
options={[
{ label: '待处理', value: 0 },
{ label: '处理中', value: 1 },
{ label: '处理完成', value: 2 },
{ label: '处理失败', value: 3 },
]}
rules={[{ required: true, message: '请选择状态' }]}
placeholder="请选择状态"
/>
</ProForm.Group>
<ProForm.Group>
<ProFormTextArea
width="md"
name="result"
label="处理结果"
placeholder="请输入处理结果"
/>
<ProFormTextArea
width="md"
name="remark"
label="备注"
placeholder="请输入备注"
/>
</ProForm.Group>
</ModalForm>
);
};
export default UpdateForm;
@@ -0,0 +1,310 @@
import React, { useRef, useState, useCallback } from 'react';
import { PlusOutlined } from '@ant-design/icons';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import {
PageContainer,
ProTable,
QueryFilter,
ProFormSelect,
ProFormText,
} from '@ant-design/pro-components';
import { Button, Space, Typography, Popconfirm, message, Tag, Tooltip } from 'antd';
import { getEditTaskList, deleteEditTask } from '@/services/orders/api';
import CreateForm from './components/CreateForm';
import UpdateForm from './components/UpdateForm';
const { Link } = Typography;
// 状态选项
const STATUS_OPTIONS = [
{ label: '待处理', value: 0 },
{ label: '处理中', value: 1 },
{ label: '处理完成', value: 2 },
{ label: '处理失败', value: 3 },
];
// 状态颜色映射
const statusColorMap = {
0: { color: 'default', text: '待处理' },
1: { color: 'processing', text: '处理中' },
2: { color: 'success', text: '处理完成' },
3: { color: 'error', text: '处理失败' },
};
// 渲染状态标签
const renderStatus = (status: number) => {
const statusInfo = statusColorMap[status] || { color: 'gray', text: '未知状态' };
return <Tag color={statusInfo.color}>{statusInfo.text}</Tag>;
};
const TableList: React.FC = () => {
const actionRef = useRef<ActionType>();
const [params, setParams] = useState<Record<string, string | number>>({});
const [createModalVisible, handleModalVisible] = useState<boolean>(false);
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
const [currentRow, setCurrentRow] = useState<ORDERS.EditTask>();
// 处理API请求
const handleApiRequest = async (
apiCall: () => Promise<any>,
loadingMessage: string,
successMessage: string,
) => {
const hide = message.loading(loadingMessage);
try {
const result = await apiCall();
hide();
if (result.resp_code === 0) {
message.success(successMessage);
return true;
}
message.error(result.resp_msg);
return false;
} catch (error) {
hide();
message.error(`${successMessage}失败`);
return false;
}
};
// 处理删除
const handleDelete = async (record: ORDERS.EditTask) => {
return handleApiRequest(
() => deleteEditTask(record.id),
'正在删除',
'删除成功'
);
};
// 表格操作处理
const handleTableAction = useCallback(async (
action: 'add' | 'edit' | 'delete',
record?: ORDERS.EditTask,
values?: Partial<ORDERS.EditTask>
) => {
let success = false;
switch (action) {
case 'add':
success = await handleAdd(values as ORDERS.EditTask);
success && handleModalVisible(false);
break;
case 'edit':
if (record) {
success = await handleEdit(record, values || {});
if (success) {
handleUpdateModalVisible(false);
setCurrentRow(undefined);
}
}
break;
case 'delete':
success = await handleDelete(record!);
break;
}
if (success && actionRef.current) {
actionRef.current.reload();
}
}, []);
// 修改 request 处理方式
const handleRequest = async (
params: {
pageSize?: number;
current?: number;
keyword?: string;
} & Record<string, any>,
) => {
const msg = message.loading('正在加载数据...', 0);
try {
const response = await getEditTaskList({
page: params.current || 1,
limit: params.pageSize || 10,
orderSn: params.orderSn,
jobId: params.jobId,
status: params.status,
});
msg();
if (response.resp_code === 0) {
return {
data: response.data.records || [],
success: true,
total: response.data.total || 0,
};
}
message.error(response.resp_msg);
return {
data: [],
success: false,
total: 0,
};
} catch (error) {
msg();
message.error('获取数据失败');
return {
data: [],
success: false,
total: 0,
};
}
};
// 表格列定义
const columns: ProColumns<ORDERS.EditTask>[] = [
{
dataIndex: 'index',
valueType: 'indexBorder',
width: 48,
fixed: 'left',
},
{
title: 'ID',
dataIndex: 'id',
width: 80,
},
{
title: '用户ID',
dataIndex: 'userId',
width: 100,
},
{
title: '订单编号',
dataIndex: 'orderSn',
width: 180,
ellipsis: true,
},
{
title: '任务ID',
dataIndex: 'jobId',
width: 180,
ellipsis: true,
},
{
title: '处理结果',
dataIndex: 'result',
width: 200,
ellipsis: true,
},
{
title: '状态',
dataIndex: 'status',
width: 100,
render: (status) => renderStatus(status as number),
},
{
title: '备注',
dataIndex: 'remark',
width: 200,
ellipsis: true,
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateTime',
width: 160,
ellipsis: true,
},
{
title: '更新时间',
dataIndex: 'updateTime',
valueType: 'dateTime',
width: 160,
ellipsis: true,
},
{
title: '操作',
key: 'action',
width: 120,
fixed: 'right',
render: (_, record) => (
<Space>
<Link
onClick={() => {
setCurrentRow(record);
handleUpdateModalVisible(true);
}}
>
修改
</Link>
<Popconfirm
title={`确认删除该剪辑任务?`}
description="删除后将无法恢复,请谨慎操作"
onConfirm={() => handleTableAction('delete', record)}
>
<Link>删除</Link>
</Popconfirm>
</Space>
),
},
];
return (
<PageContainer header={{ title: '剪辑任务管理' }}>
<QueryFilter
defaultCollapsed={false}
split
span={6}
className="query-filter"
onFinish={setParams}
>
<ProFormText
name="orderSn"
label="订单编号"
placeholder="请输入订单编号"
/>
<ProFormText
name="jobId"
label="任务ID"
placeholder="请输入任务ID"
/>
<ProFormSelect
name="status"
label="状态"
placeholder="请选择状态"
options={STATUS_OPTIONS}
/>
</QueryFilter>
<ProTable<ORDERS.EditTask>
rowKey="id"
headerTitle="剪辑任务列表"
actionRef={actionRef}
columns={columns}
request={handleRequest}
search={false}
params={params}
scroll={{ x: 1500 }}
pagination={{
showSizeChanger: true,
showQuickJumper: true,
defaultPageSize: 10,
}}
toolBarRender={() => [
<Button
key="add"
type="primary"
onClick={() => handleModalVisible(true)}
>
<PlusOutlined /> 新增剪辑任务
</Button>,
]}
style={{
width: '100%',
overflow: 'auto',
}}
/>
<CreateForm
visible={createModalVisible}
onVisibleChange={handleModalVisible}
onSubmit={async (values) => handleTableAction('add', undefined, values)}
/>
<UpdateForm
updateModalVisible={updateModalVisible}
onVisibleChange={handleUpdateModalVisible}
onSubmit={async (values) => handleTableAction('edit', currentRow, values)}
values={currentRow}
/>
</PageContainer>
);
};
export default TableList;
@@ -10,9 +10,8 @@ import {
ProFormDigit,
ProTable,
QueryFilter,
Tooltip,
} from '@ant-design/pro-components';
import { Typography, Popconfirm, Space, message, Image, Button, Tag } from 'antd';
import { Typography, Popconfirm, Space, message, Image, Button, Tag, Tooltip } from 'antd';
import React, { useRef, useState, useCallback, useEffect } from 'react';
import UpdateForm from './components/UpdateForm';
import { wayline, device } from '@/services/device/api';
@@ -3,6 +3,7 @@ import {
ProForm,
ProFormText,
ProFormSelect,
ProFormTextArea,
} from '@ant-design/pro-components';
import React from 'react';
@@ -45,21 +46,27 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
name="tourismName"
label="名称"
width="md"
rules={[formRules.required]}
rules={[{ required: true, message: '此项为必填项' }]}
placeholder="请输入景区名称"
/>
<ProFormText
name="tourismAddress"
label="地址"
width="md"
rules={[formRules.required]}
rules={[{ required: true, message: '此项为必填项' }]}
placeholder="请输入景区地址"
/>
</ProForm.Group>
<ProForm.Group>
<ProFormText
name="tourismPhone"
label="联系电话"
width="md"
rules={[formRules.required, formRules.phone]}
rules={[
{ required: true, message: '此项为必填项' },
{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号' }
]}
placeholder="请输入联系电话"
/>
<ProFormSelect
@@ -67,10 +74,24 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
label="状态"
width="md"
options={STATUS_OPTIONS}
rules={[formRules.required]}
rules={[{ required: true, message: '此项为必填项' }]}
placeholder="请选择状态"
/>
</ProForm.Group>
<ProForm.Group>
<ProFormTextArea
name="tourismDesc"
label="景点描述"
width="xl"
placeholder="请输入景点描述"
fieldProps={{
rows: 4,
maxLength: 500,
showCount: true,
}}
/>
</ProForm.Group>
</ModalForm>
);
};
@@ -7,8 +7,9 @@ import {
PageContainer,
ProForm,
ProFormText,
ProTable,
ProFormSelect,
ProFormTextArea,
ProTable,
} from '@ant-design/pro-components';
import { Typography, message, Popconfirm, Button, Space } from 'antd';
import React, { useRef, useState, useCallback } from 'react';
@@ -127,10 +128,15 @@ const TableList: React.FC = () => {
ellipsis: true,
},
{
title: '地址',
title: '景点',
dataIndex: 'tourismAddress',
ellipsis: true,
},
{
title: '景点描述',
dataIndex: 'tourismDesc',
ellipsis: true,
},
{
title: '联系电话',
dataIndex: 'tourismPhone',
@@ -233,6 +239,9 @@ const TableList: React.FC = () => {
rules={[formRules.required]}
placeholder="请输入景区地址"
/>
</ProForm.Group>
<ProForm.Group>
<ProFormText
name="tourismPhone"
label="联系电话"
@@ -249,6 +258,20 @@ const TableList: React.FC = () => {
initialValue="1"
/>
</ProForm.Group>
<ProForm.Group>
<ProFormTextArea
name="tourismDesc"
label="景点描述"
width="xl"
placeholder="请输入景点描述"
fieldProps={{
rows: 4,
maxLength: 500,
showCount: true,
}}
/>
</ProForm.Group>
</ModalForm>
{/* 修改表单 */}
@@ -259,3 +259,32 @@ export async function updateVideoTemplateStatus(id: number, status: number) {
});
}
// 获取剪辑任务列表
export async function getEditTaskList(params: {
page: number;
limit: number;
orderSn?: string;
jobId?: string;
status?: number;
}) {
return request('/api-order/auto/cut/list', {
method: 'GET',
params,
});
}
// 新增剪辑任务
export async function saveOrUpdateEditTask(data: ORDERS.EditTask) {
return request('/api-order/auto/cut/save', {
method: 'POST',
data,
});
}
// 删除剪辑任务
export async function deleteEditTask(id: number) {
return request(`/api-order/auto/cut/delete/${id}`, {
method: 'DELETE',
});
}
@@ -182,6 +182,19 @@ declare namespace ORDERS {
company?: string;
isDel?: number;
}
interface EditTask {
id: number;
userId: number;
orderSn: string;
jobId: string;
result: string;
status: number;
createTime: string;
updateTime: string;
tenantId: number;
remark: string;
}
}
declare namespace API {