mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:19:19 +08:00
feat: 优化店铺订单同步
This commit is contained in:
+10
@@ -115,6 +115,16 @@ public class PddOrderSyncController {
|
||||
return ApiResponse.success(fullSyncTaskService.latestTask(shopId));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询店铺全量同步任务列表", description = "按创建时间倒序,默认最近 20 条")
|
||||
@GetMapping("/full-task/list")
|
||||
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
|
||||
public ApiResponse<List<PddOrderFullSyncTaskVO>> listFullTasks(
|
||||
@Parameter(description = "内部店铺 ID") @RequestParam Long shopId,
|
||||
@Parameter(description = "条数上限,默认 20,最大 100")
|
||||
@RequestParam(required = false, defaultValue = "20") Integer limit) {
|
||||
return ApiResponse.success(fullSyncTaskService.listTasks(shopId, limit));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询全量同步任务")
|
||||
@GetMapping("/full-task/{taskId}")
|
||||
@RequirePermission(value = "biz:pdd:order:sync", description = "拼多多订单同步", allowSuper = true)
|
||||
|
||||
+12
@@ -121,6 +121,18 @@ public class PddOrderFullSyncTaskService {
|
||||
progress);
|
||||
}
|
||||
|
||||
/** 店铺全量任务列表(按 id 倒序) */
|
||||
public List<PddOrderFullSyncTaskVO> listTasks(Long shopId, Integer limit) {
|
||||
PddOrderSyncShopContext ctx = contextResolver.resolveForCurrentCompany(shopId);
|
||||
int lim = (limit == null || limit <= 0) ? 20 : Math.min(limit, 100);
|
||||
List<PddOrderFullSyncTaskPO> tasks = taskMapper.selectList(new LambdaQueryWrapper<PddOrderFullSyncTaskPO>()
|
||||
.eq(PddOrderFullSyncTaskPO::getCompanyId, ctx.getCompanyId())
|
||||
.eq(PddOrderFullSyncTaskPO::getShopId, ctx.getShopId())
|
||||
.orderByDesc(PddOrderFullSyncTaskPO::getId)
|
||||
.last("LIMIT " + lim));
|
||||
return tasks.stream().map(PddOrderFullSyncTaskService::toVo).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public PddOrderFullSyncTaskVO getTask(Long taskId) {
|
||||
PddOrderFullSyncTaskPO task = requireOwnedTask(taskId);
|
||||
return toVo(task);
|
||||
|
||||
@@ -56,6 +56,16 @@ export async function getPddLatestFullSyncTaskApi(shopId: number) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询店铺全量同步任务列表(按 id 倒序)
|
||||
*/
|
||||
export async function listPddFullSyncTasksApi(shopId: number, limit = 20) {
|
||||
return requestClient.get<PddOrderSyncVO.FullTask[]>(
|
||||
'/channel/pdd/order/sync/full-task/list',
|
||||
{ params: { shopId, limit } },
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消全量同步任务
|
||||
*/
|
||||
|
||||
+271
-170
@@ -9,13 +9,15 @@ import {
|
||||
Button,
|
||||
DatePicker,
|
||||
Drawer,
|
||||
Empty,
|
||||
Form,
|
||||
message,
|
||||
Modal,
|
||||
Progress,
|
||||
Radio,
|
||||
Space,
|
||||
Switch,
|
||||
Tag,
|
||||
message,
|
||||
} from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
@@ -24,7 +26,7 @@ import {
|
||||
createPddFullSyncTaskApi,
|
||||
getPddFullSyncTaskApi,
|
||||
getPddIncrementalSyncStatusApi,
|
||||
getPddLatestFullSyncTaskApi,
|
||||
listPddFullSyncTasksApi,
|
||||
resumePddFullSyncTaskApi,
|
||||
syncPddOrdersIncrementalApi,
|
||||
togglePddIncrementalSyncApi,
|
||||
@@ -43,38 +45,29 @@ const emit = defineEmits<Emits>();
|
||||
const openFlag = ref(false);
|
||||
const shop = ref<null | ShopVO.Info>(null);
|
||||
const loading = ref(false);
|
||||
const submitting = ref(false);
|
||||
const mode = ref<'day' | 'full' | 'incremental'>('full');
|
||||
const listLoading = ref(false);
|
||||
const incSubmitting = ref(false);
|
||||
const createSubmitting = ref(false);
|
||||
const createModalOpen = ref(false);
|
||||
const createMode = ref<'day' | 'range'>('range');
|
||||
const confirmDate = ref<Dayjs>(dayjs().subtract(1, 'day'));
|
||||
const range = ref<[Dayjs, Dayjs]>([
|
||||
dayjs().subtract(90, 'day'),
|
||||
dayjs().subtract(1, 'day'),
|
||||
]);
|
||||
const incremental = ref<null | PddOrderSyncVO.IncrementalStatus>(null);
|
||||
const fullTask = ref<null | PddOrderSyncVO.FullTask>(null);
|
||||
const fullTasks = ref<PddOrderSyncVO.FullTask[]>([]);
|
||||
let pollTimer: null | ReturnType<typeof setInterval> = null;
|
||||
let unsubProgress: (() => void) | null = null;
|
||||
let terminalNotifiedTaskId: null | number = null;
|
||||
const terminalNotifiedTaskIds = new Set<number>();
|
||||
|
||||
const drawerTitle = computed(() =>
|
||||
shop.value ? `同步拼多多订单 - ${shop.value.name}` : '同步拼多多订单',
|
||||
);
|
||||
|
||||
const taskProgressPercent = computed(() => {
|
||||
if (!fullTask.value || !fullTask.value.totalDays) return 0;
|
||||
return Math.min(
|
||||
100,
|
||||
Math.round((fullTask.value.doneDays / fullTask.value.totalDays) * 100),
|
||||
);
|
||||
});
|
||||
|
||||
const isFullActive = computed(() => {
|
||||
const s = fullTask.value?.status;
|
||||
return s === 'PENDING' || s === 'RUNNING';
|
||||
});
|
||||
|
||||
const canCancelFull = computed(() => isFullActive.value);
|
||||
const canResumeFull = computed(() => fullTask.value?.status === 'FAILED');
|
||||
const hasActiveFullTask = computed(() =>
|
||||
fullTasks.value.some((t) => t.status === 'PENDING' || t.status === 'RUNNING'),
|
||||
);
|
||||
|
||||
const incHealthLabel = computed(() => {
|
||||
const health = incremental.value?.health;
|
||||
@@ -101,6 +94,26 @@ function formatTime(time?: null | string) {
|
||||
return d.isValid() ? d.format('YYYY-MM-DD HH:mm:ss') : '-';
|
||||
}
|
||||
|
||||
function taskProgressPercent(task: PddOrderSyncVO.FullTask) {
|
||||
if (!task.totalDays) return 0;
|
||||
return Math.min(100, Math.round((task.doneDays / task.totalDays) * 100));
|
||||
}
|
||||
|
||||
function statusTag(status: string) {
|
||||
const map: Record<string, { color: string; text: string }> = {
|
||||
PENDING: { color: 'default', text: '等待中' },
|
||||
RUNNING: { color: 'processing', text: '执行中' },
|
||||
SUCCESS: { color: 'success', text: '成功' },
|
||||
FAILED: { color: 'error', text: '失败' },
|
||||
CANCELLED: { color: 'warning', text: '已取消' },
|
||||
};
|
||||
return map[status] || { color: 'default', text: status };
|
||||
}
|
||||
|
||||
function isTaskActive(task: PddOrderSyncVO.FullTask) {
|
||||
return task.status === 'PENDING' || task.status === 'RUNNING';
|
||||
}
|
||||
|
||||
function stopPoll() {
|
||||
if (pollTimer) {
|
||||
clearInterval(pollTimer);
|
||||
@@ -113,11 +126,20 @@ function unsubscribeProgress() {
|
||||
unsubProgress = null;
|
||||
}
|
||||
|
||||
function upsertTaskInList(task: PddOrderSyncVO.FullTask) {
|
||||
const idx = fullTasks.value.findIndex((t) => t.id === task.id);
|
||||
if (idx === -1) {
|
||||
fullTasks.value.unshift(task);
|
||||
} else {
|
||||
fullTasks.value[idx] = task;
|
||||
}
|
||||
}
|
||||
|
||||
function applyFullTaskUpdate(task: PddOrderSyncVO.FullTask) {
|
||||
if (!shop.value || task.shopId !== shop.value.id) {
|
||||
return;
|
||||
}
|
||||
fullTask.value = task;
|
||||
upsertTaskInList(task);
|
||||
const terminal =
|
||||
task.status === 'SUCCESS' ||
|
||||
task.status === 'FAILED' ||
|
||||
@@ -125,21 +147,22 @@ function applyFullTaskUpdate(task: PddOrderSyncVO.FullTask) {
|
||||
if (!terminal) {
|
||||
return;
|
||||
}
|
||||
stopPoll();
|
||||
submitting.value = false;
|
||||
if (!hasActiveFullTask.value) {
|
||||
stopPoll();
|
||||
}
|
||||
loading.value = false;
|
||||
if (terminalNotifiedTaskId === task.id) {
|
||||
if (terminalNotifiedTaskIds.has(task.id)) {
|
||||
return;
|
||||
}
|
||||
terminalNotifiedTaskId = task.id;
|
||||
terminalNotifiedTaskIds.add(task.id);
|
||||
if (task.status === 'SUCCESS') {
|
||||
message.success(`全量同步完成:${task.doneDays}/${task.totalDays} 天`);
|
||||
message.success(`全量任务 #${task.id} 完成:${task.doneDays}/${task.totalDays} 天`);
|
||||
emit('success');
|
||||
} else if (task.status === 'FAILED') {
|
||||
message.error(task.lastError || '全量同步失败');
|
||||
message.error(task.lastError || `全量任务 #${task.id} 失败`);
|
||||
emit('success');
|
||||
} else {
|
||||
message.info('全量同步已取消');
|
||||
message.info(`全量任务 #${task.id} 已取消`);
|
||||
emit('success');
|
||||
}
|
||||
}
|
||||
@@ -171,16 +194,21 @@ async function loadIncrementalStatus() {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadLatestFullTask() {
|
||||
async function loadFullTasks() {
|
||||
if (!shop.value) return;
|
||||
try {
|
||||
const task = await getPddLatestFullSyncTaskApi(shop.value.id);
|
||||
fullTask.value = task;
|
||||
if (task && (task.status === 'PENDING' || task.status === 'RUNNING')) {
|
||||
watchFullTask(task.id);
|
||||
listLoading.value = true;
|
||||
fullTasks.value = await listPddFullSyncTasksApi(shop.value.id, 30);
|
||||
const active = fullTasks.value.find((t) => isTaskActive(t));
|
||||
if (active) {
|
||||
watchActiveTasks();
|
||||
} else {
|
||||
stopPoll();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载全量任务失败:', error);
|
||||
console.error('加载全量任务列表失败:', error);
|
||||
} finally {
|
||||
listLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,27 +230,48 @@ async function handleToggleIncremental(checked: boolean | string | number) {
|
||||
}
|
||||
}
|
||||
|
||||
/** SSE 为主,低频轮询兜底(防止漏事件) */
|
||||
function watchFullTask(taskId: number) {
|
||||
async function handleManualIncremental() {
|
||||
if (!shop.value) return;
|
||||
try {
|
||||
incSubmitting.value = true;
|
||||
await syncPddOrdersIncrementalApi(shop.value.id);
|
||||
message.success('已入队,后台增量同步中');
|
||||
emit('success');
|
||||
await loadIncrementalStatus();
|
||||
} catch (error) {
|
||||
console.error('手动增量失败:', error);
|
||||
} finally {
|
||||
incSubmitting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** SSE 为主,低频轮询活跃任务兜底 */
|
||||
function watchActiveTasks() {
|
||||
stopPoll();
|
||||
subscribeProgress();
|
||||
pollTimer = setInterval(async () => {
|
||||
try {
|
||||
const task = await getPddFullSyncTaskApi(taskId);
|
||||
applyFullTaskUpdate(task);
|
||||
} catch (error) {
|
||||
console.error('轮询全量任务失败:', error);
|
||||
const actives = fullTasks.value.filter((t) => isTaskActive(t));
|
||||
if (actives.length === 0) {
|
||||
stopPoll();
|
||||
return;
|
||||
}
|
||||
await Promise.all(
|
||||
actives.map(async (t) => {
|
||||
try {
|
||||
applyFullTaskUpdate(await getPddFullSyncTaskApi(t.id));
|
||||
} catch (error) {
|
||||
console.error('轮询全量任务失败:', error);
|
||||
}
|
||||
}),
|
||||
);
|
||||
}, 10_000);
|
||||
}
|
||||
|
||||
async function handleCancelFull() {
|
||||
if (!fullTask.value) return;
|
||||
async function handleCancelFull(task: PddOrderSyncVO.FullTask) {
|
||||
try {
|
||||
loading.value = true;
|
||||
fullTask.value = await cancelPddFullSyncTaskApi(fullTask.value.id);
|
||||
stopPoll();
|
||||
message.success('已取消全量任务');
|
||||
applyFullTaskUpdate(await cancelPddFullSyncTaskApi(task.id));
|
||||
message.success(`已取消全量任务 #${task.id}`);
|
||||
emit('success');
|
||||
} catch (error) {
|
||||
console.error('取消全量任务失败:', error);
|
||||
@@ -232,104 +281,95 @@ async function handleCancelFull() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleResumeFull() {
|
||||
if (!fullTask.value) return;
|
||||
async function handleResumeFull(task: PddOrderSyncVO.FullTask) {
|
||||
try {
|
||||
loading.value = true;
|
||||
submitting.value = true;
|
||||
terminalNotifiedTaskId = null;
|
||||
const task = await resumePddFullSyncTaskApi(fullTask.value.id);
|
||||
fullTask.value = task;
|
||||
message.success('已续跑入队');
|
||||
watchFullTask(task.id);
|
||||
terminalNotifiedTaskIds.delete(task.id);
|
||||
const updated = await resumePddFullSyncTaskApi(task.id);
|
||||
upsertTaskInList(updated);
|
||||
message.success(`全量任务 #${task.id} 已续跑入队`);
|
||||
watchActiveTasks();
|
||||
} catch (error) {
|
||||
console.error('续跑全量任务失败:', error);
|
||||
message.error('续跑全量任务失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
function openCreateModal() {
|
||||
createMode.value = 'range';
|
||||
confirmDate.value = dayjs().subtract(1, 'day');
|
||||
range.value = [dayjs().subtract(90, 'day'), dayjs().subtract(1, 'day')];
|
||||
createModalOpen.value = true;
|
||||
}
|
||||
|
||||
async function handleCreateTask() {
|
||||
if (!shop.value) return;
|
||||
if (mode.value === 'day' && !confirmDate.value) {
|
||||
if (createMode.value === 'day' && !confirmDate.value) {
|
||||
message.warning('请选择成交日期');
|
||||
return;
|
||||
}
|
||||
if (mode.value === 'full' && (!range.value?.[0] || !range.value?.[1])) {
|
||||
if (createMode.value === 'range' && (!range.value?.[0] || !range.value?.[1])) {
|
||||
message.warning('请选择全量同步日期区间');
|
||||
return;
|
||||
}
|
||||
if ((mode.value === 'full' || mode.value === 'day') && isFullActive.value) {
|
||||
if (hasActiveFullTask.value) {
|
||||
message.warning('该店铺已有进行中的全量任务,请先等待或取消');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
loading.value = true;
|
||||
submitting.value = true;
|
||||
|
||||
if (mode.value === 'full' || mode.value === 'day') {
|
||||
const dateFrom =
|
||||
mode.value === 'day'
|
||||
? confirmDate.value.format('YYYY-MM-DD')
|
||||
: range.value[0].format('YYYY-MM-DD');
|
||||
const dateTo =
|
||||
mode.value === 'day'
|
||||
? confirmDate.value.format('YYYY-MM-DD')
|
||||
: range.value[1].format('YYYY-MM-DD');
|
||||
terminalNotifiedTaskId = null;
|
||||
const task = await createPddFullSyncTaskApi({
|
||||
shopId: shop.value.id,
|
||||
dateFrom,
|
||||
dateTo,
|
||||
});
|
||||
fullTask.value = task;
|
||||
message.success(
|
||||
mode.value === 'day'
|
||||
? '单日全量任务已创建,正在后台执行'
|
||||
: '全量同步任务已创建,正在后台执行',
|
||||
);
|
||||
watchFullTask(task.id);
|
||||
emit('success');
|
||||
return;
|
||||
}
|
||||
|
||||
await syncPddOrdersIncrementalApi(shop.value.id);
|
||||
message.success('已入队,后台同步中');
|
||||
createSubmitting.value = true;
|
||||
const dateFrom =
|
||||
createMode.value === 'day'
|
||||
? confirmDate.value.format('YYYY-MM-DD')
|
||||
: range.value[0].format('YYYY-MM-DD');
|
||||
const dateTo =
|
||||
createMode.value === 'day'
|
||||
? confirmDate.value.format('YYYY-MM-DD')
|
||||
: range.value[1].format('YYYY-MM-DD');
|
||||
const task = await createPddFullSyncTaskApi({
|
||||
shopId: shop.value.id,
|
||||
dateFrom,
|
||||
dateTo,
|
||||
});
|
||||
terminalNotifiedTaskIds.delete(task.id);
|
||||
upsertTaskInList(task);
|
||||
createModalOpen.value = false;
|
||||
message.success(
|
||||
createMode.value === 'day'
|
||||
? '单日全量任务已创建,正在后台执行'
|
||||
: '全量同步任务已创建,正在后台执行',
|
||||
);
|
||||
watchActiveTasks();
|
||||
emit('success');
|
||||
await loadIncrementalStatus();
|
||||
} catch (error) {
|
||||
console.error('同步拼多多订单失败:', error);
|
||||
loading.value = false;
|
||||
submitting.value = false;
|
||||
console.error('创建全量任务失败:', error);
|
||||
} finally {
|
||||
if (mode.value === 'incremental') {
|
||||
loading.value = false;
|
||||
submitting.value = false;
|
||||
}
|
||||
createSubmitting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
stopPoll();
|
||||
unsubscribeProgress();
|
||||
createModalOpen.value = false;
|
||||
openFlag.value = false;
|
||||
}
|
||||
|
||||
async function open(record: ShopVO.Info) {
|
||||
shop.value = record;
|
||||
mode.value = 'full';
|
||||
confirmDate.value = dayjs().subtract(1, 'day');
|
||||
range.value = [dayjs().subtract(90, 'day'), dayjs().subtract(1, 'day')];
|
||||
fullTask.value = null;
|
||||
fullTasks.value = [];
|
||||
incremental.value = null;
|
||||
submitting.value = false;
|
||||
loading.value = false;
|
||||
terminalNotifiedTaskId = null;
|
||||
createSubmitting.value = false;
|
||||
incSubmitting.value = false;
|
||||
createModalOpen.value = false;
|
||||
terminalNotifiedTaskIds.clear();
|
||||
stopPoll();
|
||||
subscribeProgress();
|
||||
openFlag.value = true;
|
||||
await Promise.all([loadIncrementalStatus(), loadLatestFullTask()]);
|
||||
await Promise.all([loadIncrementalStatus(), loadFullTasks()]);
|
||||
}
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
@@ -344,19 +384,21 @@ defineExpose({ open, close: handleClose });
|
||||
<Drawer
|
||||
v-model:open="openFlag"
|
||||
:title="drawerTitle"
|
||||
width="560"
|
||||
width="600"
|
||||
destroy-on-close
|
||||
:mask-closable="!isFullActive"
|
||||
:mask-closable="!hasActiveFullTask"
|
||||
@close="handleClose"
|
||||
>
|
||||
<!-- 状态面板 -->
|
||||
<div class="mb-4 space-y-3">
|
||||
<div class="rounded border border-slate-200 p-3 dark:border-[hsl(240deg_3.7%_22%)]">
|
||||
<div class="space-y-4">
|
||||
<!-- 增量 -->
|
||||
<div
|
||||
class="rounded border border-slate-200 p-3 dark:border-[hsl(240deg_3.7%_22%)]"
|
||||
>
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<span class="text-sm font-medium">增量同步</span>
|
||||
<Tag :color="incHealthColor">{{ incHealthLabel }}</Tag>
|
||||
</div>
|
||||
<div class="mb-2 flex items-center gap-3">
|
||||
<div class="mb-2 flex flex-wrap items-center gap-3">
|
||||
<Switch
|
||||
:checked="!!incremental?.enabled"
|
||||
checked-children="开"
|
||||
@@ -364,108 +406,167 @@ defineExpose({ open, close: handleClose });
|
||||
@change="handleToggleIncremental"
|
||||
/>
|
||||
<span class="text-xs text-slate-500">开启后定时 Job 拉取增量并转换</span>
|
||||
<Button
|
||||
size="small"
|
||||
type="primary"
|
||||
ghost
|
||||
:loading="incSubmitting"
|
||||
@click="handleManualIncremental"
|
||||
>
|
||||
手动增量一次
|
||||
</Button>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 gap-1 text-xs text-slate-600 sm:grid-cols-2 dark:text-slate-300">
|
||||
<div
|
||||
class="grid grid-cols-1 gap-1 text-xs text-slate-600 sm:grid-cols-2 dark:text-slate-300"
|
||||
>
|
||||
<div>游标:{{ formatTime(incremental?.lastCursorAt) }}</div>
|
||||
<div>上次成功:{{ formatTime(incremental?.lastSuccessTime) }}</div>
|
||||
</div>
|
||||
<p v-if="incremental?.lastError" class="mt-2 text-xs text-red-500">
|
||||
{{ incremental.lastError }}
|
||||
</p>
|
||||
<p class="mt-2 text-xs text-slate-500">
|
||||
手动增量按订单更新时间拉取自上次游标以来的变更,用于发货/售后等状态同步。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="rounded border border-slate-200 p-3 dark:border-[hsl(240deg_3.7%_22%)]">
|
||||
<div class="mb-2 flex items-center justify-between gap-2">
|
||||
<!-- 全量任务列表 -->
|
||||
<div
|
||||
class="rounded border border-slate-200 p-3 dark:border-[hsl(240deg_3.7%_22%)]"
|
||||
>
|
||||
<div class="mb-3 flex items-center justify-between gap-2">
|
||||
<span class="text-sm font-medium">全量同步任务</span>
|
||||
<Space size="small">
|
||||
<Button
|
||||
v-if="canCancelFull"
|
||||
size="small"
|
||||
danger
|
||||
:loading="loading"
|
||||
@click="handleCancelFull"
|
||||
>
|
||||
取消
|
||||
<Button size="small" :loading="listLoading" @click="loadFullTasks">
|
||||
刷新
|
||||
</Button>
|
||||
<Button
|
||||
v-if="canResumeFull"
|
||||
size="small"
|
||||
type="primary"
|
||||
:loading="loading"
|
||||
@click="handleResumeFull"
|
||||
:disabled="hasActiveFullTask"
|
||||
@click="openCreateModal"
|
||||
>
|
||||
续跑
|
||||
创建全量任务
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
<template v-if="fullTask">
|
||||
<div class="mb-2 text-sm">
|
||||
#{{ fullTask.id }} · {{ fullTask.status }} ·
|
||||
{{ fullTask.doneDays }}/{{ fullTask.totalDays }} 天
|
||||
<span v-if="fullTask.failedDays" class="text-red-500">
|
||||
· 失败日 {{ fullTask.failedDays }}
|
||||
</span>
|
||||
|
||||
<div v-if="fullTasks.length > 0" class="max-h-[52vh] space-y-3 overflow-y-auto pr-1">
|
||||
<div
|
||||
v-for="task in fullTasks"
|
||||
:key="task.id"
|
||||
class="rounded border border-slate-100 p-3 dark:border-[hsl(240deg_3.7%_18%)]"
|
||||
>
|
||||
<div class="mb-2 flex flex-wrap items-center justify-between gap-2">
|
||||
<div class="flex flex-wrap items-center gap-2 text-sm">
|
||||
<span class="font-medium">#{{ task.id }}</span>
|
||||
<Tag :color="statusTag(task.status).color">
|
||||
{{ statusTag(task.status).text }}
|
||||
</Tag>
|
||||
<span class="text-xs text-slate-500">
|
||||
{{ task.doneDays }}/{{ task.totalDays }} 天
|
||||
<template v-if="task.failedDays">
|
||||
· 失败日 {{ task.failedDays }}
|
||||
</template>
|
||||
</span>
|
||||
</div>
|
||||
<Space size="small">
|
||||
<Button
|
||||
v-if="isTaskActive(task)"
|
||||
size="small"
|
||||
danger
|
||||
:loading="loading"
|
||||
@click="handleCancelFull(task)"
|
||||
>
|
||||
取消
|
||||
</Button>
|
||||
<Button
|
||||
v-if="task.status === 'FAILED'"
|
||||
size="small"
|
||||
type="primary"
|
||||
:loading="loading"
|
||||
:disabled="hasActiveFullTask"
|
||||
@click="handleResumeFull(task)"
|
||||
>
|
||||
续跑
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
<div class="mb-2 text-xs text-slate-500">
|
||||
区间 {{ task.dateFrom }} ~ {{ task.dateTo }}
|
||||
<span v-if="task.currentDate"> · 当前 {{ task.currentDate }}</span>
|
||||
</div>
|
||||
<div class="mb-1 text-xs text-slate-400">
|
||||
创建 {{ formatTime(task.createTime) }}
|
||||
<template v-if="task.finishTime">
|
||||
· 结束 {{ formatTime(task.finishTime) }}
|
||||
</template>
|
||||
</div>
|
||||
<Progress
|
||||
v-if="isTaskActive(task) || task.status === 'SUCCESS'"
|
||||
:percent="taskProgressPercent(task)"
|
||||
size="small"
|
||||
:status="task.status === 'FAILED' ? 'exception' : undefined"
|
||||
/>
|
||||
<p v-if="task.lastError" class="mt-2 text-xs text-red-500">
|
||||
{{ task.lastError }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="mb-2 text-xs text-slate-500">
|
||||
区间 {{ fullTask.dateFrom }} ~ {{ fullTask.dateTo }}
|
||||
<span v-if="fullTask.currentDate"> · 当前 {{ fullTask.currentDate }}</span>
|
||||
</div>
|
||||
<Progress :percent="taskProgressPercent" size="small" />
|
||||
<p v-if="fullTask.lastError" class="mt-2 text-xs text-red-500">
|
||||
{{ fullTask.lastError }}
|
||||
</p>
|
||||
</template>
|
||||
<p v-else class="text-xs text-slate-500">暂无全量任务</p>
|
||||
</div>
|
||||
<Empty
|
||||
v-else
|
||||
:image="Empty.PRESENTED_IMAGE_SIMPLE"
|
||||
description="暂无全量任务"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 操作区 -->
|
||||
<Form layout="vertical">
|
||||
<Form.Item label="同步方式">
|
||||
<Radio.Group v-model:value="mode">
|
||||
<Radio value="full" :disabled="isFullActive">全量同步任务(按日区间)</Radio>
|
||||
<Radio value="day" :disabled="isFullActive">按成交日同步一天</Radio>
|
||||
<Radio value="incremental">手动增量一次</Radio>
|
||||
<template #footer>
|
||||
<div class="flex justify-end">
|
||||
<Button @click="handleClose">关闭</Button>
|
||||
</div>
|
||||
</template>
|
||||
</Drawer>
|
||||
|
||||
<Modal
|
||||
v-model:open="createModalOpen"
|
||||
title="创建全量同步任务"
|
||||
:confirm-loading="createSubmitting"
|
||||
ok-text="创建并开始"
|
||||
destroy-on-close
|
||||
@ok="handleCreateTask"
|
||||
>
|
||||
<Form layout="vertical" class="mt-2">
|
||||
<Form.Item label="任务类型">
|
||||
<Radio.Group v-model:value="createMode">
|
||||
<Radio value="range">按成交日区间</Radio>
|
||||
<Radio value="day">按成交日单日</Radio>
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
v-if="mode === 'full'"
|
||||
v-if="createMode === 'range'"
|
||||
label="成交日期区间"
|
||||
extra="按天串行拉取;每天成功后自动进入转换与 BI 日汇聚;会写入全量任务表"
|
||||
extra="按天串行拉取;每天成功后自动进入转换与 BI 日汇聚"
|
||||
>
|
||||
<DatePicker.RangePicker
|
||||
v-model:value="range"
|
||||
class="w-full"
|
||||
:allow-clear="false"
|
||||
:disabled="isFullActive"
|
||||
format="YYYY-MM-DD"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
v-else-if="mode === 'day'"
|
||||
v-else
|
||||
label="成交日期"
|
||||
extra="创建单日全量任务并持久化;若进行中任务已涵盖该日则不会重复创建"
|
||||
extra="创建单日全量任务;若进行中任务已涵盖该日则不会重复创建"
|
||||
>
|
||||
<DatePicker
|
||||
v-model:value="confirmDate"
|
||||
class="w-full"
|
||||
:allow-clear="false"
|
||||
:disabled="isFullActive"
|
||||
format="YYYY-MM-DD"
|
||||
/>
|
||||
</Form.Item>
|
||||
<p v-else class="mb-3 text-xs text-slate-500">
|
||||
按订单更新时间拉取自上次游标以来的变更,用于发货/售后等状态同步。
|
||||
</p>
|
||||
</Form>
|
||||
|
||||
<template #footer>
|
||||
<div class="flex justify-end gap-2">
|
||||
<Button @click="handleClose">关闭</Button>
|
||||
<Button type="primary" :loading="submitting" @click="handleSubmit">
|
||||
开始同步
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
</Drawer>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user