feat: 完成客户第12条需求+多系统改造
1. 新增预警表添加工单号字段,支持按工单号检索预警 2. 添加工单过滤在制品/绩效报表/预警中心查询 3. 补全WMS台账字段口径与权限配置 4. 修复备料单与数量不符处理流程 5. 新增配送进度/库位联动/自动出库功能 6. 修复AGV配送状态更新逻辑 7. 优化退料与库存管理细节
This commit is contained in:
@@ -1085,3 +1085,49 @@ func shortageHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
ok(w, map[string]any{"list": rows, "total": len(rows)})
|
||||
}
|
||||
}
|
||||
|
||||
// listStockBatchesInternalHandler GET /api/internal/stock/batches?materialCode=&zoneCode=
|
||||
// 供 MES「工单备料自动出库」分配批次用:返回该物料可出库的批次明细(结构件)与可用 SN 列表(电气件)。
|
||||
// 结构件按批次号升序(FIFO);统一质量门禁:仅「合格」库存可出库,未检/不合格/待退不返回。
|
||||
func listStockBatchesInternalHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
materialCode := strings.TrimSpace(r.URL.Query().Get("materialCode"))
|
||||
if materialCode == "" {
|
||||
fail(w, http.StatusBadRequest, "materialCode 必填")
|
||||
return
|
||||
}
|
||||
q := ctx.EntClient.Inventory.Query().
|
||||
Where(
|
||||
inventory.MaterialCodeEQ(materialCode),
|
||||
inventory.QuantityGT(0),
|
||||
inventory.QualityStatusEQ(QStatusPass),
|
||||
)
|
||||
if zc := strings.TrimSpace(r.URL.Query().Get("zoneCode")); zc != "" {
|
||||
q = q.Where(inventory.ZoneCodeEQ(zc))
|
||||
}
|
||||
rows, err := q.Order(ent.Asc("batch_no"), ent.Asc("created_at")).All(ctx0())
|
||||
if err != nil {
|
||||
fail(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
batches := make([]map[string]any, 0, len(rows))
|
||||
sns := make([]string, 0, len(rows))
|
||||
for _, inv := range rows {
|
||||
avail := inv.Quantity - inv.LockedQty
|
||||
if avail <= 0 {
|
||||
continue
|
||||
}
|
||||
if inv.ManageMode == 2 {
|
||||
if inv.SnCode != "" {
|
||||
sns = append(sns, inv.SnCode)
|
||||
}
|
||||
continue
|
||||
}
|
||||
batches = append(batches, map[string]any{
|
||||
"batchNo": inv.BatchNo, "quantity": inv.Quantity, "lockedQty": inv.LockedQty,
|
||||
"avail": avail, "zoneCode": inv.ZoneCode, "qualityStatus": inv.QualityStatus,
|
||||
})
|
||||
}
|
||||
ok(w, map[string]any{"batches": batches, "snList": sns})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user