diff --git a/src/modules/container-loading/api/platformContainerLoading.test.ts b/src/modules/container-loading/api/platformContainerLoading.test.ts index 812ad0ff..eca4898c 100644 --- a/src/modules/container-loading/api/platformContainerLoading.test.ts +++ b/src/modules/container-loading/api/platformContainerLoading.test.ts @@ -5,6 +5,7 @@ import { http } from '@/shared/api/http' import { adjustSmartLoadingItem, assignPendingReviewSmartLoadingOrder, assignSmartLoadingGroup, assignSmartLoadingItem, assignSmartLoadingPallet, getContainer, listContainers, listSmartLoadingCandidates, listSmartLoadingWorkbenchContainers, removeAllUnpickedSmartLoadingItems, removeSmartLoadingGroup, removeSmartLoadingItem, removeSmartLoadingPallet, + recommendSmartLoading, getContainerClearance, downloadContainerClearance, uploadContainerClearance, completeContainerClearance, getContainerOverview, updateContainerPickupCode, markContainerException, cancelContainerException, uploadContainerDocument, downloadContainerDocument, downloadContainerPdaPhoto, getCustomerContainerTransitSummary, @@ -131,6 +132,25 @@ describe('platform container loading API', () => { ) }) + it('limits smart recommendation to the current customer and inbound filters', async () => { + vi.mocked(http.post).mockResolvedValue({ code: '200', data: plan }) + + await recommendSmartLoading('10', 5, { + customerId: '9007199254740998', + inboundCode: ' EXXHWK2609140162 ', + }) + + expect(http.post).toHaveBeenCalledWith( + '/platform/v1/first-leg/smart-loading/plans/10/recommend', + expect.objectContaining({ + expectedVersion: 5, + customerId: '9007199254740998', + inboundCode: 'EXXHWK2609140162', + operationId: expect.stringContaining('recommend-'), + }), + ) + }) + it('removes a sealed pallet through the whole-pallet command', async () => { vi.mocked(http.delete).mockResolvedValue({ code: '200', data: plan }) diff --git a/src/modules/container-loading/api/platformContainerLoading.ts b/src/modules/container-loading/api/platformContainerLoading.ts index c5c163ca..0cde8afb 100644 --- a/src/modules/container-loading/api/platformContainerLoading.ts +++ b/src/modules/container-loading/api/platformContainerLoading.ts @@ -380,8 +380,20 @@ export async function assignSmartLoadingGroup(planId: string, inboundId: string, ) return plan(unwrapApiResponse(response)) } -export async function recommendSmartLoading(planId: string, expectedVersion: number) { - const response = await http.post, ApiEnvelope>(`${smartLoadingPath}/plans/${encodeURIComponent(planId)}/recommend`, { expectedVersion, operationId: operationId('recommend') }) +export async function recommendSmartLoading( + planId: string, + expectedVersion: number, + scope: { customerId?: string; inboundCode?: string } = {}, +) { + const response = await http.post, ApiEnvelope>( + `${smartLoadingPath}/plans/${encodeURIComponent(planId)}/recommend`, + { + expectedVersion, + operationId: operationId('recommend'), + ...(scope.customerId ? { customerId: scope.customerId } : {}), + ...(scope.inboundCode?.trim() ? { inboundCode: scope.inboundCode.trim() } : {}), + }, + ) return plan(unwrapApiResponse(response)) } diff --git a/src/modules/container-loading/pages/GlobalSmartLoadingView.test.ts b/src/modules/container-loading/pages/GlobalSmartLoadingView.test.ts index ac393792..8750bc6b 100644 --- a/src/modules/container-loading/pages/GlobalSmartLoadingView.test.ts +++ b/src/modules/container-loading/pages/GlobalSmartLoadingView.test.ts @@ -760,8 +760,8 @@ describe('GlobalSmartLoadingView', () => { await button!.trigger('click') await flushPromises() - expect(recommendSmartLoading).toHaveBeenCalledWith(plan.id, 2) - expect(recommendSmartLoading).toHaveBeenCalledWith(plan.id, 3) + expect(recommendSmartLoading).toHaveBeenCalledWith(plan.id, 2, { customerId: '', inboundCode: '' }) + expect(recommendSmartLoading).toHaveBeenCalledWith(plan.id, 3, { customerId: '', inboundCode: '' }) expect(getSmartLoadingPlanByBooking).toHaveBeenCalledTimes(2) expect(warningMessage).not.toHaveBeenCalled() expect(wrapper.text()).not.toContain('装柜操作失败') diff --git a/src/modules/container-loading/pages/GlobalSmartLoadingView.vue b/src/modules/container-loading/pages/GlobalSmartLoadingView.vue index 3e05c6a7..400332ed 100644 --- a/src/modules/container-loading/pages/GlobalSmartLoadingView.vue +++ b/src/modules/container-loading/pages/GlobalSmartLoadingView.vue @@ -549,15 +549,19 @@ function candidateBlocked(candidate: SmartLoadingCandidateRow) { } async function recommend() { if (!plan.value) return + const scope = { + customerId: String(appliedQuery.value.customerId || ''), + inboundCode: String(appliedQuery.value.inboundCode || '').trim(), + } await mutate(async () => { try { - acceptPlan(await recommendSmartLoading(plan.value!.id, plan.value!.version)) + acceptPlan(await recommendSmartLoading(plan.value!.id, plan.value!.version, scope)) } catch (error) { const details = getApiErrorDetails(error, '智能推荐失败') if (details.code !== 'A0409' || !/(版本|并发|已被修改|已变化)/.test(details.message)) throw error await loadSelectedPlan() if (!plan.value) throw error - acceptPlan(await recommendSmartLoading(plan.value.id, plan.value.version)) + acceptPlan(await recommendSmartLoading(plan.value.id, plan.value.version, scope)) } await loadCandidateData() ElMessage.success('智能推荐已生成')