feat: 新增产品工艺管理与工序审核功能
- 新增产品工艺(product_process)及明细(product_process_item)数据模型 - 新增工序审核开关(need_audit)与审核角色(audit_role)字段 - 新增待审核签字页面与路由 - 优化 WMS/MES 接口交互,增加业务错误处理与友好提示 - 补充库存过滤逻辑,避免返回已出库 SN 数据 - 调整默认查询时间范围为近一个月,优化用户体验
This commit is contained in:
@@ -231,11 +231,19 @@ type importErr struct {
|
||||
}
|
||||
|
||||
// excelInboundHandler Excel 批量导入入库
|
||||
// mode=batch(批次件):列头(首行忽略) 图号 | 批次号(可空自动生成) | 数量 | 生产日期 | 供应商 | 区域 | 备注
|
||||
// mode=sn(序列号件): 列头(首行忽略) 图号 | SN | 区域 | 生产日期 | 供应商
|
||||
// mode=batch(批次件) 列头(首行忽略):
|
||||
//
|
||||
// 图号 | 批次号(可空自动生成) | 数量 | 生产日期 | 供应商 | 区域 | 架 | 层 | 位 | 备注 | 检测单号 | 产品工号 | 归属类型 | 归属编号
|
||||
//
|
||||
// mode=sn(序列号件) 列头(首行忽略):
|
||||
//
|
||||
// 图号 | SN | 区域 | 生产日期 | 供应商 | 架 | 层 | 位 | 备注 | 检测单号 | 产品工号 | 归属类型 | 归属编号
|
||||
//
|
||||
// 新增列(架/层/位/备注/检测单号/产品工号/归属) 均为【可选、追加在末尾】,老模板文件缺这些列仍可导入(对应字段留空)。
|
||||
// 归属类型填 workorder/project/other(其他值按 other 处理);workorder/project 必须同时填归属编号,other 可不填。
|
||||
//
|
||||
// 强约束:全成功或全失败(一次性全导入 or 全失败,禁止部分成功)。
|
||||
// 流程:阶段1 逐行解析+校验(物料存在/数量>0/SN不重复/区域必填) → 任一错则整体拒绝并列出错误行(一行不写);
|
||||
// 流程:阶段1 逐行解析+校验(物料存在/数量>0/SN不重复/区域必填/归属编号规则) → 任一错则整体拒绝并列出错误行(一行不写);
|
||||
// 阶段2 全部通过 → 开启单事务,整体提交,任一步失败整体回滚。
|
||||
func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -272,15 +280,22 @@ func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
|
||||
type planRow struct {
|
||||
row int
|
||||
code string
|
||||
batchNo string
|
||||
sn string
|
||||
qty int
|
||||
prodDate string
|
||||
supplier string
|
||||
zone string
|
||||
remark string
|
||||
row int
|
||||
code string
|
||||
batchNo string
|
||||
sn string
|
||||
qty int
|
||||
prodDate string
|
||||
supplier string
|
||||
zone string
|
||||
remark string
|
||||
shelfNo string
|
||||
layerNo string
|
||||
positionNo string
|
||||
inspectionNo string
|
||||
productWorkNo string
|
||||
ownershipType string
|
||||
ownershipNo string
|
||||
}
|
||||
plans := make([]planRow, 0, len(rows)-1)
|
||||
errs := make([]importErr, 0)
|
||||
@@ -300,18 +315,34 @@ func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
pr := planRow{row: i + 1}
|
||||
pr.code = cell(0)
|
||||
if mode == "sn" {
|
||||
// 图号|SN|区域|生产日期|供应商|架|层|位|备注|检测单号|产品工号|归属类型|归属编号
|
||||
pr.sn = cell(1)
|
||||
pr.zone = cell(2) // 序列号件模板: 图号|SN|区域|生产日期|供应商
|
||||
pr.zone = cell(2)
|
||||
pr.prodDate = cell(3)
|
||||
pr.supplier = cell(4)
|
||||
pr.remark = cell(4)
|
||||
pr.shelfNo = cell(5)
|
||||
pr.layerNo = cell(6)
|
||||
pr.positionNo = cell(7)
|
||||
pr.remark = cell(8)
|
||||
pr.inspectionNo = cell(9)
|
||||
pr.productWorkNo = cell(10)
|
||||
pr.ownershipType = cell(11)
|
||||
pr.ownershipNo = cell(12)
|
||||
} else {
|
||||
// 图号|批次号|数量|生产日期|供应商|区域|架|层|位|备注|检测单号|产品工号|归属类型|归属编号
|
||||
pr.batchNo = cell(1)
|
||||
pr.qty = atoi(cell(2), 0)
|
||||
pr.prodDate = cell(3)
|
||||
pr.supplier = cell(4)
|
||||
pr.zone = cell(5) // 批次件模板: 图号|批次号|数量|生产日期|供应商|区域|备注
|
||||
pr.remark = cell(6)
|
||||
pr.zone = cell(5)
|
||||
pr.shelfNo = cell(6)
|
||||
pr.layerNo = cell(7)
|
||||
pr.positionNo = cell(8)
|
||||
pr.remark = cell(9)
|
||||
pr.inspectionNo = cell(10)
|
||||
pr.productWorkNo = cell(11)
|
||||
pr.ownershipType = cell(12)
|
||||
pr.ownershipNo = cell(13)
|
||||
}
|
||||
|
||||
if pr.code == "" {
|
||||
@@ -357,6 +388,14 @@ func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
errs = append(errs, importErr{pr.row, pr.code, "区域为空(必填)"})
|
||||
continue
|
||||
}
|
||||
// 归属校验(与手动录入口径一致:workorder/project 必填编号;other/空 不需要)
|
||||
pr.ownershipType = ownershipTypeOrNone(pr.ownershipType)
|
||||
if pr.ownershipType == "workorder" || pr.ownershipType == "project" {
|
||||
if pr.ownershipNo == "" {
|
||||
errs = append(errs, importErr{pr.row, pr.code, "归属类型为" + pr.ownershipType + "时归属编号必填"})
|
||||
continue
|
||||
}
|
||||
}
|
||||
plans = append(plans, pr)
|
||||
}
|
||||
|
||||
@@ -396,6 +435,12 @@ func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
SetNillableProductionDate(strPtr(pr.prodDate)).
|
||||
SetNillableSupplier(strPtr(pr.supplier)).
|
||||
SetNillableZoneCode(strPtr(pr.zone)).
|
||||
SetNillableShelfNo(strPtr(pr.shelfNo)).
|
||||
SetNillableLayerNo(strPtr(pr.layerNo)).
|
||||
SetNillablePositionNo(strPtr(pr.positionNo)).
|
||||
SetNillableProductWorkNo(strPtr(pr.productWorkNo)).
|
||||
SetNillableOwnershipType(strPtr(pr.ownershipType)).
|
||||
SetNillableOwnershipNo(strPtr(pr.ownershipNo)).
|
||||
SetStatus("在库").
|
||||
SetInboundNo(inboundNo).
|
||||
Save(ctx0()); e != nil {
|
||||
@@ -420,6 +465,10 @@ func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
if _, e = tx.Inventory.UpdateOneID(existing.ID).
|
||||
AddQuantity(pr.qty).
|
||||
SetNillableSupplier(strPtr(pr.supplier)).
|
||||
SetNillableProductWorkNo(strPtr(pr.productWorkNo)).
|
||||
SetNillableShelfNo(strPtr(pr.shelfNo)).
|
||||
SetNillableLayerNo(strPtr(pr.layerNo)).
|
||||
SetNillablePositionNo(strPtr(pr.positionNo)).
|
||||
Save(ctx0()); e != nil {
|
||||
fail(w, http.StatusInternalServerError, "追加批次失败: "+e.Error())
|
||||
return
|
||||
@@ -436,6 +485,12 @@ func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
SetNillableSupplier(strPtr(pr.supplier)).
|
||||
SetQualityStatus("未检").
|
||||
SetNillableZoneCode(strPtr(pr.zone)).
|
||||
SetNillableShelfNo(strPtr(pr.shelfNo)).
|
||||
SetNillableLayerNo(strPtr(pr.layerNo)).
|
||||
SetNillablePositionNo(strPtr(pr.positionNo)).
|
||||
SetNillableProductWorkNo(strPtr(pr.productWorkNo)).
|
||||
SetNillableOwnershipType(strPtr(pr.ownershipType)).
|
||||
SetNillableOwnershipNo(strPtr(pr.ownershipNo)).
|
||||
SetStatus("在库").
|
||||
SetInboundNo(inboundNo).
|
||||
Save(ctx0()); e != nil {
|
||||
@@ -458,8 +513,16 @@ func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
SetManageMode(m.ManageMode).
|
||||
SetSnMode(m.SnMode).
|
||||
SetNillableZoneCode(strPtr(pr.zone)).
|
||||
SetNillableShelfNo(strPtr(pr.shelfNo)).
|
||||
SetNillableLayerNo(strPtr(pr.layerNo)).
|
||||
SetNillablePositionNo(strPtr(pr.positionNo)).
|
||||
SetQuantity(ternary(mode == "sn", 1, pr.qty)).
|
||||
SetNillableRemark(strPtr(pr.remark)).
|
||||
SetInspectionNo(pr.inspectionNo).
|
||||
SetOwnershipType(ownershipTypeOrNone(pr.ownershipType)).
|
||||
SetNillableOwnershipNo(strPtr(pr.ownershipNo)).
|
||||
SetNillableProductWorkNo(strPtr(pr.productWorkNo)).
|
||||
SetNillableQualityStatus(strPtr("未检")).
|
||||
SetOperator("excel-import").
|
||||
Save(ctx0()); e != nil {
|
||||
fail(w, http.StatusInternalServerError, "创建入库单失败: "+e.Error())
|
||||
|
||||
Reference in New Issue
Block a user