feat(shipping-notice): 增强发货通知与订单抽取功能,支持多进程处理与紧急停止
- 移除不再使用的 SHIPPING_NOTICE_LAYOUT_PARSER_REVISION 配置 - 在环境配置中新增 SHIPPING_NOTICE_WORKER_CONCURRENCY 和 SHIPPING_NOTICE_JOB_RUNNING_TIMEOUT_SECONDS - 实现发货通知 worker 进程,支持并发处理订单抽取任务 - 引入紧急停止功能,允许管理员在运行中控制订单解析状态 - 更新相关 API,支持读取与设置紧急停止状态 - 增强文档与代码注释,反映新的业务逻辑与功能要求
This commit is contained in:
1 parent
d0fe084999
commit
b352c281d5
149 files changed
+12550
-1874
No files matched your search
@@ -2,7 +2,8 @@
|
||||
* features/chat/shipping/useShippingNoticeIntakes.ts
|
||||
* 用途:发货通知选择即上传、创建 intake 与批量状态轮询编排。
|
||||
* 依赖:file-assets.api、shipping.api、shipping.types、shippingNoticeAttachmentIntegrity、后端布局状态汇总。
|
||||
* 逻辑:useChatShipping / useChatAttachments 在货代 Agent 下委托本 composable 管理预解析附件;
|
||||
* 逻辑:useChatShipping / useChatAttachments 在货代 Agent 下委托本 composable 原子加入附件并并发预解析;
|
||||
* 点击发送时汇集输入框内全部合格附件,不以某次文件选择生成的 uploadBatchId 截断;
|
||||
* 完整性判定委托 shippingNoticeAttachmentIntegrity(与后端契约对齐);会话刷新仅恢复未提交的处理中或解析失败附件。
|
||||
*/
|
||||
import { computed, onBeforeUnmount, ref, type Ref } from 'vue';
|
||||
@@ -247,8 +248,6 @@ export interface UseShippingNoticeIntakesOptions {
|
||||
export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOptions) {
|
||||
const pollTimer = ref<ReturnType<typeof setTimeout> | null>(null);
|
||||
const pollRound = ref(0);
|
||||
// 新文件选择显式推进当前批次;恢复历史卡片不能覆盖它。
|
||||
const currentUploadBatchId = ref<string | null>(null);
|
||||
|
||||
const noticeAttachments = computed(() =>
|
||||
options.attachments.value.filter(
|
||||
@@ -256,12 +255,8 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
),
|
||||
);
|
||||
|
||||
const currentBatchAttachments = computed(() => {
|
||||
const batchId = currentUploadBatchId.value;
|
||||
return batchId
|
||||
? noticeAttachments.value.filter((item) => item.uploadBatchId === batchId)
|
||||
: noticeAttachments.value;
|
||||
});
|
||||
// 输入框就是本次提交边界;多次选择加入的附件必须一起校验和发送。
|
||||
const currentBatchAttachments = noticeAttachments;
|
||||
|
||||
const hasBlockingUploadOrParse = computed(() =>
|
||||
currentBatchAttachments.value.some((item) =>
|
||||
@@ -422,16 +417,19 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 将同一次选择的发货通知作为一个批次加入输入区,并并发完成资产上传与 Intake 创建。
|
||||
* 核心逻辑:先原子追加全部附件,确保 UI 立即展示完整批次;再并发预处理,单文件失败由 processSingleFile 独立记录。
|
||||
* @param files - 用户同一次选择的本地附件;所有文件共享同一个 uploadBatchId
|
||||
* @returns 全部附件的预处理任务结束后完成;单文件失败不会拒绝整个批次
|
||||
*/
|
||||
const enqueueNoticeFiles = async (files: File[]) => {
|
||||
// 同一次选择共享一个持久化批次;后续发送只会自动取这个最新批次。
|
||||
// 同一次选择共享批次 ID,用于上传幂等和状态关联;发送范围由当前输入框决定。
|
||||
const uploadBatchId = globalThis.crypto?.randomUUID?.()
|
||||
|| `${Date.now()}-${Math.random().toString(36).slice(2, 12)}`;
|
||||
currentUploadBatchId.value = uploadBatchId;
|
||||
for (const file of files) {
|
||||
const attachment = createPendingAttachment(file, uploadBatchId);
|
||||
options.attachments.value = [...options.attachments.value, attachment];
|
||||
await processSingleFile(attachment);
|
||||
}
|
||||
const batchAttachments = files.map((file) => createPendingAttachment(file, uploadBatchId));
|
||||
options.attachments.value = [...options.attachments.value, ...batchAttachments];
|
||||
await Promise.all(batchAttachments.map((attachment) => processSingleFile(attachment)));
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -468,12 +466,15 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
};
|
||||
|
||||
const getParsedIntakeNos = () => {
|
||||
const eligible = noticeAttachments.value.filter(isOrderExtractionEligibleIntake);
|
||||
const currentBatchId = currentUploadBatchId.value
|
||||
|| [...noticeAttachments.value].reverse().find((item) => item.uploadBatchId)?.uploadBatchId;
|
||||
return eligible
|
||||
.filter((item) => item.uploadBatchId === currentBatchId)
|
||||
.map((item) => String(item.intakeNo));
|
||||
const seen = new Set<string>();
|
||||
return noticeAttachments.value
|
||||
.filter(isOrderExtractionEligibleIntake)
|
||||
.map((item) => String(item.intakeNo || '').trim().toUpperCase())
|
||||
.filter((intakeNo) => {
|
||||
if (!intakeNo || seen.has(intakeNo)) return false;
|
||||
seen.add(intakeNo);
|
||||
return true;
|
||||
});
|
||||
};
|
||||
|
||||
/** 点击发送后立即展示订单识别阶段,并启动 Intake 状态轮询。 */
|
||||
|
||||
Reference in new issue
Block a user