From fb4db4ae9b6a7f113ba049f6789e6916c0dcc276 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期一, 12 十月 2026 09:15:08 +0800
Subject: [PATCH] feat(mes): 新增业务码支持并优化追溯查询功能

---
 src/api/mes/pro/bagCode/index.ts |  122 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 118 insertions(+), 4 deletions(-)

diff --git a/src/api/mes/pro/bagCode/index.ts b/src/api/mes/pro/bagCode/index.ts
index 70d332c..57f2d3b 100644
--- a/src/api/mes/pro/bagCode/index.ts
+++ b/src/api/mes/pro/bagCode/index.ts
@@ -5,9 +5,11 @@
 export namespace MesProBagCodeApi {
   /** 琚嬬爜锛堜竴琚嬩竴鐮侊級 */
   export interface BagCode {
+    inboundTime?: string;
     id?: number; // 缂栧彿
     uuid?: string; // 鐢熸垚缁� UUID
     code?: string; // 琚嬬爜锛堜簩缁寸爜鍐呭锛�
+    businessCode?: string; // 鍐呴儴鍑哄叆搴撲笟鍔$爜锛堢函鐮佸�硷級
     bagNo?: number; // 鎵规鍐呰搴忓彿
     batchId?: number; // 鐢熶骇鎵规缂栧彿
     batchCode?: string; // 鎵规鍙�
@@ -15,8 +17,13 @@
     lineName?: string; // 浜х嚎鍚嶇О
     palletId?: number; // 缁戝畾鎵樼洏缂栧彿
     palletCode?: string; // 鎵樼洏鐮�
+    itemId?: number; // 鍝佺锛堢墿鏂欙級缂栧彿
+    itemCode?: string; // 鍝佺缂栫爜
+    itemName?: string; // 鍝佺鍚嶇О
     status?: number; // 鐘舵�侊紙瀛楀吀 mes_pro_bag_code_status锛�
     printTime?: string; // 瀵煎嚭锛堜氦浠樺嵃鍒凤級鏃堕棿
+    cancelTime?: string; // 浣滃簾鏃堕棿
+    cancelReason?: string; // 浣滃簾鍘熷洜
     remark?: string; // 澶囨敞
     createTime?: string; // 鍒涘缓鏃堕棿
   }
@@ -24,19 +31,42 @@
   /** 琚嬬爜鍒嗛〉鏌ヨ鍙傛暟 */
   export interface PageParams extends PageParam {
     code?: string;
+    businessCode?: string;
     batchId?: number;
     batchCode?: string;
     uuid?: string;
     palletId?: number;
+    itemId?: number;
     status?: number;
     createTime?: string[];
   }
 
-  /** 鐢熸垚鏁版嵁鍖呰姹� */
+  /** 鐢熸垚鏁版嵁鍖呰姹傦紙鍝佺涓昏閲忓崟浣嶇被鍨嬩负 N鍗冨厠 鏃舵寜鎵樼洏鏁版崲绠楄鏁帮紱涓� 鍚� 鏃舵棤鎵樼洏銆佺洿鎺ヨ緭鍏ヨ鐮佹暟锛� */
   export interface GenerateParams {
-    batchId: number; // 鐢熶骇鎵规缂栧彿
-    count: number; // 鐢熸垚琚嬫暟
+    itemId: number; // 鍝佺锛堢墿鏂欙級缂栧彿
+    palletCount?: number; // 鎵樼洏鏁帮紙48鍗冨厠/100鍗冨厠 鍝佺蹇呭~锛�
+    bagCount?: number; // 琚嬬爜鏁帮紙鍚ㄥ搧绉嶅繀濉級
     remark?: string; // 澶囨敞
+  }
+
+  export interface GenerateResult {
+    uuid?: string; // 鐢熸垚缁� UUID
+    type?: string; // 鍝佺涓昏閲忓崟浣嶇被鍨嬶紙48鍗冨厠/100鍗冨厠/鍚級
+    perPallet?: number; // 姣忔墭琚嬫暟锛堝惃鍝佺涓� 0锛�
+    totalCount?: number; // 鐢熸垚琚嬬爜鎬绘暟
+    palletIds?: number[]; // 鑷姩鐢熸垚鐨勬墭鐩樼紪鍙峰垪琛紙鍚ㄥ搧绉嶄负绌猴級
+  }
+
+  /** 鐢熸垚鍘熷琚嬬爜璇锋眰锛堜粎鍝佺+琚嬬爜鏁伴噺锛屼笉鍏宠仈璁¢噺鍗曚綅绫诲瀷銆佷笉鐢熸垚鎵樼洏锛� */
+  export interface RawGenerateParams {
+    itemId: number; // 鍝佺锛堢墿鏂欙級缂栧彿
+    count: number; // 琚嬬爜鏁伴噺
+    remark?: string; // 澶囨敞
+  }
+
+  export interface BindBatchParams {
+    batchId: number;
+    ids: number[];
   }
 
   /** 缁戝畾/瑙g粦鎵樼洏璇锋眰 */
@@ -45,13 +75,53 @@
     ids: number[]; // 琚嬬爜缂栧彿鍒楄〃
   }
 
+  /** 鐮存崯琚嬬爜鏇挎崲璇锋眰 */
+  export interface ReplaceParams {
+    batchId: number; // 鐢熶骇鎵规缂栧彿
+    oldIds: number[]; // 寰呮浛鎹㈡棫琚嬬爜缂栧彿鍒楄〃
+    reason: string; // 鏇挎崲鍘熷洜
+  }
+
+  /** 鐮存崯琚嬬爜鏇挎崲鏄庣粏 */
+  export interface ReplaceItem {
+    oldBagCodeId?: number;
+    oldCode?: string;
+    oldBagNo?: number;
+    oldStatus?: number;
+    oldPalletId?: number;
+    oldPalletCode?: string;
+    newBagCodeId?: number;
+    newCode?: string;
+    newBagNo?: number;
+    newPalletId?: number;
+    newPalletCode?: string;
+    reason?: string;
+    replaceTime?: string;
+  }
+
+  /** 鐮存崯琚嬬爜鏇挎崲缁撴灉 */
+  export interface ReplaceResult {
+    replaceUuid?: string;
+    batchId?: number;
+    batchCode?: string;
+    count?: number;
+    items?: ReplaceItem[];
+  }
+
   /** 鎵爜杩芥函淇℃伅 */
   export interface BagCodeTrace {
+    inboundTime?: string;
     id?: number; // 琚嬬爜缂栧彿
     code?: string; // 琚嬬爜锛堜簩缁寸爜鍐呭锛�
+    businessCode?: string; // 鍐呴儴鍑哄叆搴撲笟鍔$爜
     bagNo?: number; // 琚嬪簭鍙�
     status?: number; // 琚嬬爜鐘舵��
     printTime?: string; // 瀵煎嚭鍗板埛鏃堕棿
+    cancelTime?: string; // 浣滃簾鏃堕棿
+    cancelReason?: string; // 浣滃簾鍘熷洜
+    replacementUuid?: string; // 鏇挎崲缁� UUID
+    replacedByCode?: string; // 鏇挎崲鍚庣殑鏂拌鐮�
+    replacementOfCode?: string; // 琚浛鎹㈢殑鏃ц鐮�
     batchId?: number; // 鎵规缂栧彿
     batchCode?: string; // 鎵规鍙�
     batchStatus?: number; // 鎵规鐘舵��
@@ -71,7 +141,23 @@
 
 /** 鐢熸垚琚嬬爜鏁版嵁鍖咃紙杩斿洖鐢熸垚缁� UUID锛� */
 export function generateBagCodes(data: MesProBagCodeApi.GenerateParams) {
-  return requestClient.post<string>('/mes/pro/bag-code/generate', data);
+  return requestClient.post<MesProBagCodeApi.GenerateResult>(
+    '/mes/pro/bag-code/generate',
+    data,
+  );
+}
+
+/** 鐢熸垚鍘熷琚嬬爜锛堜粎閫夊搧绉嶄笌琚嬬爜鏁伴噺锛屼笉鐢熸垚鎵樼洏锛涜繑鍥炵敓鎴愮粍 UUID锛� */
+export function generateRawBagCodes(data: MesProBagCodeApi.RawGenerateParams) {
+  return requestClient.post<MesProBagCodeApi.GenerateResult>(
+    '/mes/pro/bag-code/raw-generate',
+    data,
+  );
+}
+
+/** 褰曞叆鐢熶骇鎵规 */
+export function bindBagCodeBatch(data: MesProBagCodeApi.BindBatchParams) {
+  return requestClient.put('/mes/pro/bag-code/bind-batch', data);
 }
 
 /** 鍒犻櫎琚嬬爜鐢熸垚缁� */
@@ -89,6 +175,14 @@
   return requestClient.put('/mes/pro/bag-code/unbind-pallet', data);
 }
 
+/** 浣滃簾鐮存崯琚嬬爜骞剁敓鎴愮瓑閲忔浛鎹㈣鐮� */
+export function replaceBagCodes(data: MesProBagCodeApi.ReplaceParams) {
+  return requestClient.post<MesProBagCodeApi.ReplaceResult>(
+    '/mes/pro/bag-code/replace',
+    data,
+  );
+}
+
 /** 鏌ヨ琚嬬爜璇︽儏 */
 export function getBagCode(id: number) {
   return requestClient.get<MesProBagCodeApi.BagCode>(
@@ -100,6 +194,16 @@
 export function getBagCodeByCode(code: string) {
   return requestClient.get<MesProBagCodeApi.BagCodeTrace>(
     `/mes/pro/bag-code/get-by-code?code=${encodeURIComponent(code)}`,
+  );
+}
+
+/**
+ * 鎵爜杩芥函锛氭牴鎹紪鐮佽В鏋愬叾绫诲瀷锛坆ag / pallet / batch锛夈��
+ * 缂栫爜缁熶竴涓恒��16 浣嶇函鏁板瓧銆嶅悗鏃犳硶鎸夊墠缂�鍒ゆ柇绫诲瀷锛屾敼鐢卞悗绔В鏋愶紱鍧囦笉鍖归厤杩斿洖 null銆�
+ */
+export function resolveTraceType(code: string) {
+  return requestClient.get<'bag' | 'batch' | 'pallet' | null>(
+    `/mes/pro/trace/resolve-type?code=${encodeURIComponent(code)}`,
   );
 }
 
@@ -127,3 +231,13 @@
 export function exportBagQr(params: { uuid?: string; batchId?: number }) {
   return requestClient.download('/mes/pro/bag-code/export-qr', { params });
 }
+
+/** 琛ョ敓鎴愬凡鏈夎鐮佺殑涓氬姟鐮侊紝閲嶅鎿嶄綔涓嶆洿鎹㈠凡鏈夌爜鍊笺�� */
+export function generateBagBusinessCodes(ids: number[]) {
+  return requestClient.post<number>('/mes/pro/bag-code/generate-business-code', { ids });
+}
+
+/** 涓氬姟浜岀淮鐮佷粎缂栫爜瀛樺偍鐨勪笟鍔$爜鍊硷紝涓嶆嫾鎺ヨ拷婧綉鍧�銆� */
+export function exportBagBusinessQr(params: { uuid?: string; batchId?: number }) {
+  return requestClient.download('/mes/pro/bag-code/export-business-qr', { params });
+}

--
Gitblit v1.9.3