4 天以前 91c82965b2d987452ca276e3a03b48c8dcda2ae9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import type { PageParam, PageResult } from '@vben/request';
 
import { requestClient } from '#/api/request';
import type { MesProBagCodeApi } from '#/api/mes/pro/bagCode';
import type { MesProPalletApi } from '#/api/mes/pro/pallet';
 
export namespace MesProBatchApi {
  /** 生产批次人员配置 */
  export interface BatchWorker {
    id?: number; // 编号
    batchId?: number; // 批次编号
    userId?: number; // 生产人员用户编号
    userName?: string; // 生产人员昵称
    workerType?: number; // 岗位类型(字典 mes_pro_batch_worker_type)
    remark?: string; // 备注
  }
 
  /** 生产批次 */
  export interface Batch {
    id?: number; // 编号
    code?: string; // 批次号(自动生成)
    itemId?: number; // 品种(产品物料)编号
    itemCode?: string; // 品种编码(后端拼接)
    itemName?: string; // 品种名称(后端拼接)
    itemSpecification?: string; // 品种规格(后端拼接)
    lineId?: number; // 产线编号
    lineCode?: string; // 产线编码(后端回填)
    lineName?: string; // 产线名称(后端回填)
    produceDate?: string; // 生产日期
    planQuantity?: number; // 计划数量
    ownerUserId?: number; // 责任人用户编号
    ownerUserName?: string; // 责任人昵称
    bagQuantity?: number; // 已生成袋码数量
    palletQuantity?: number; // 已生成托盘码数量
    status?: number; // 批次状态(字典 mes_pro_batch_status)
    remark?: string; // 备注
    createTime?: string; // 创建时间
    workers?: BatchWorker[]; // 生产人员配置列表
  }
 
  /** 生产批次扫码追溯 */
  export interface BatchTrace {
    id?: number; // 生产批次编号
    code?: string; // 批次号(二维码内容)
    status?: number; // 批次状态(字典 mes_pro_batch_status)
    produceDate?: string; // 生产日期
    lineCode?: string; // 产线编码
    lineName?: string; // 产线名称
    ownerUserId?: number; // 责任人用户编号
    ownerUserName?: string; // 责任人昵称
    planQuantity?: number; // 计划数量
    bagQuantity?: number; // 已生成袋码数量
    palletQuantity?: number; // 已生成托盘码数量
    remark?: string; // 备注
    itemId?: number; // 品种(物料)编号
    itemCode?: string; // 品种编码
    itemName?: string; // 品种名称
    itemSpecification?: string; // 品种规格
    workers?: BatchWorker[]; // 生产人员配置列表
    pallets?: MesProPalletApi.Pallet[]; // 托盘码列表
    bags?: MesProBagCodeApi.BagCode[]; // 袋码列表(最多前 2000 条,按袋序号升序)
    bagTotal?: number; // 袋码总数
  }
 
  /** 生产批次分页查询参数 */
  export interface PageParams extends PageParam {
    code?: string;
    itemId?: number;
    lineId?: number;
    lineCode?: string;
    lineName?: string;
    ownerUserId?: number;
    status?: number;
    produceDate?: string[];
    createTime?: string[];
  }
}
 
/** 查询生产批次分页 */
export function getBatchPage(params: MesProBatchApi.PageParams) {
  return requestClient.get<PageResult<MesProBatchApi.Batch>>(
    '/mes/pro/batch/page',
    { params },
  );
}
 
/** 查询生产批次详情(含人员配置) */
export function getBatch(id: number) {
  return requestClient.get<MesProBatchApi.Batch>(
    `/mes/pro/batch/get?id=${id}`,
  );
}
 
/** 新增生产批次(自动生成批次号) */
export function createBatch(data: MesProBatchApi.Batch) {
  return requestClient.post<number>('/mes/pro/batch/create', data);
}
 
/** 修改生产批次 */
export function updateBatch(data: MesProBatchApi.Batch) {
  return requestClient.put('/mes/pro/batch/update', data);
}
 
/** 删除生产批次 */
export function deleteBatch(id: number) {
  return requestClient.delete(`/mes/pro/batch/delete?id=${id}`);
}
 
/** 更新生产批次状态 */
export function updateBatchStatus(id: number, status: number) {
  return requestClient.put(
    `/mes/pro/batch/update-status?id=${id}&status=${status}`,
  );
}
 
/** 查询生产批次精简列表(供下拉选择) */
export function getBatchSimpleList() {
  return requestClient.get<MesProBatchApi.Batch[]>('/mes/pro/batch/simple-list');
}
 
/** 导出生产批次 Excel */
export function exportBatchExcel(params: MesProBatchApi.PageParams) {
  return requestClient.download('/mes/pro/batch/export-excel', { params });
}
 
/** 扫码追溯:根据批次号(二维码内容)反查批次、人员、托盘、袋码信息 */
export function getBatchByCode(code: string) {
  return requestClient.get<MesProBatchApi.BatchTrace>(
    `/mes/pro/batch/get-by-code?code=${encodeURIComponent(code)}`,
  );
}
 
/** 批量导出批次二维码图片 ZIP(批次图 + 该批次全部托盘图) */
export function exportBatchQr(batchId: number) {
  return requestClient.download(`/mes/pro/batch/export-qr?batchId=${batchId}`);
}