feat: 重构入库流程,支持序列号与类型解耦,新增通用入库组件
- 重构物料档案字段:将"序列号件"改为"序列号",描述是否有序列号,与类型独立 - 调整入库页逻辑:按物料"序列号"决定记账方式,类型仅用于页签归属 - 新增通用入库组件 InboundEntry,复用三个类型页签的表单逻辑 - 优化成品入库页面,提交后自动切换到入库列表页签 - 修正物料校验提示文案,统一表述为"是否有序列号"
This commit is contained in:
@@ -189,6 +189,10 @@ var schemaPatchSQL = []string{
|
||||
// 工位↔接驳台 1:1:部分唯一索引只约束已绑定工位(station_no>0)的行,库房/其他接驳台不参与。
|
||||
`CREATE UNIQUE INDEX IF NOT EXISTS ux_dock_station_no ON dock (station_no) WHERE station_no > 0`,
|
||||
|
||||
// ---- 接驳台布局修正(2026-10-06):按产线布局,工位1~10 各配 R1/R2 两个接驳台(对应1号/2号AGV),----
|
||||
// ---- 一个工位可绑多个接驳台,撤销 1:1 唯一索引;对应关系以 dock 表内置数据为准 ----
|
||||
`DROP INDEX IF EXISTS ux_dock_station_no`,
|
||||
|
||||
// ---- 生产模型重构(2026-09-22 定稿):删除「工序编号/工位派工」旧模型遗留 ----
|
||||
// 路线唯一源头 = 工单工艺组合 flow_combination([{flowId,stationNo}],工位号即顺序号);
|
||||
// 装配绑定/备料/齐套全部改走工艺物料清单 flow_material,bom_item/material_request/process_code 退役。
|
||||
|
||||
@@ -89,7 +89,7 @@ func ListDocksMaintHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
size = 20
|
||||
}
|
||||
list, err := query.
|
||||
Order(ent.Desc("createdAt"), ent.Desc("id")).
|
||||
Order(ent.Desc(dock.FieldCreatedAt), ent.Desc(dock.FieldID)).
|
||||
Offset((page - 1) * size).Limit(size).All(r.Context())
|
||||
if err != nil {
|
||||
httpx.Fail(w, 3113, "查询接驳台失败:"+err.Error())
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"bj_power_mes/ent"
|
||||
"bj_power_mes/ent/dailyplan"
|
||||
"bj_power_mes/ent/station"
|
||||
"bj_power_mes/ent/dock"
|
||||
"bj_power_mes/ent/workorder"
|
||||
"bj_power_mes/ent/workpiece"
|
||||
)
|
||||
@@ -206,8 +206,9 @@ func (s *Service) saveDailyPlanBatch(ctx context.Context, req DailyPlanReq, oper
|
||||
return nil
|
||||
}
|
||||
|
||||
// SuggestedDockCodes 查工单工艺组合覆盖工位的接驳台编码(DOCKxx),供排产/备料默认推荐。
|
||||
// 路线唯一源头 = 工单 flow_combination(按工位号升序),接驳台取 station.dock_code。
|
||||
// SuggestedDockCodes 查工单工艺组合覆盖工位的接驳台编码,供排产/备料默认推荐。
|
||||
// 路线唯一源头 = 工单 flow_combination(按工位号升序);接驳台真源 = dock 表(按 station_no 聚合,
|
||||
// 一个工位可配 R1/R2 多个接驳台),station.dock_code 仅默认兜底,故统一从 dock 表取全集。
|
||||
func (s *Service) SuggestedDockCodes(ctx context.Context, orderNo string) []string {
|
||||
wo, err := s.ctx.EntClient.WorkOrder.Query().Where(workorder.WorkOrderNo(orderNo)).First(ctx)
|
||||
if err != nil {
|
||||
@@ -217,16 +218,19 @@ func (s *Service) SuggestedDockCodes(ctx context.Context, orderNo string) []stri
|
||||
if len(items) == 0 {
|
||||
return nil
|
||||
}
|
||||
sts, err := s.ctx.EntClient.Station.Query().Where(station.StationNoIn(RouteStationsOfWO(items)...)).All(ctx)
|
||||
docks, err := s.ctx.EntClient.Dock.Query().
|
||||
Where(dock.StationNoIn(RouteStationsOfWO(items)...), dock.DockTypeEQ("line")).
|
||||
Order(ent.Asc(dock.FieldStationNo), ent.Asc(dock.FieldDockCode)).
|
||||
All(ctx)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
out := []string{}
|
||||
for _, st := range sts {
|
||||
if st.DockCode != "" && !seen[st.DockCode] {
|
||||
seen[st.DockCode] = true
|
||||
out = append(out, st.DockCode)
|
||||
for _, d := range docks {
|
||||
if d.DockCode != "" && !seen[d.DockCode] {
|
||||
seen[d.DockCode] = true
|
||||
out = append(out, d.DockCode)
|
||||
}
|
||||
}
|
||||
return out
|
||||
@@ -357,8 +361,8 @@ func (s *Service) ListDailyPlansPaged(ctx context.Context, planDateStart, planDa
|
||||
|
||||
// UnplannedWorkOrder 未排产工单(供日排产页「未排产」入口展示)
|
||||
type UnplannedWorkOrder struct {
|
||||
OrderNo string `json:"orderNo"`
|
||||
ProductTypeId int `json:"productTypeId"`
|
||||
OrderNo string `json:"orderNo"`
|
||||
ProductTypeId int `json:"productTypeId"`
|
||||
Quantity int `json:"quantity"`
|
||||
DueDate string `json:"dueDate"`
|
||||
Status string `json:"status"`
|
||||
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
"time"
|
||||
|
||||
"bj_power_mes/ent"
|
||||
"bj_power_mes/ent/dock"
|
||||
"bj_power_mes/ent/flowmaterial"
|
||||
"bj_power_mes/ent/materialrequest"
|
||||
"bj_power_mes/ent/station"
|
||||
"bj_power_mes/ent/workorder"
|
||||
"bj_power_mes/internal/wmsclient"
|
||||
)
|
||||
@@ -114,12 +114,16 @@ func (s *Service) GenerateMaterialRequest(ctx context.Context, planDate string,
|
||||
for _, it := range g.items {
|
||||
stationsByFlow[it.FlowId] = append(stationsByFlow[it.FlowId], it.StationNo)
|
||||
}
|
||||
// 工位号 → 接驳台编码
|
||||
// 工位号 → 默认接驳台编码:真源 = dock 表(一工位可绑 R1/R2 多个接驳台,按编码升序取第一个为默认)
|
||||
dockByStation := map[int]string{}
|
||||
if sts, e := s.ctx.EntClient.Station.Query().
|
||||
Where(station.StationNoIn(RouteStationsOfWO(g.items)...)).All(ctx); e == nil {
|
||||
for _, st := range sts {
|
||||
dockByStation[st.StationNo] = st.DockCode
|
||||
if dks, e := s.ctx.EntClient.Dock.Query().
|
||||
Where(dock.StationNoIn(RouteStationsOfWO(g.items)...), dock.DockTypeEQ("line")).
|
||||
Order(ent.Asc(dock.FieldStationNo), ent.Asc(dock.FieldDockCode)).
|
||||
All(ctx); e == nil {
|
||||
for _, d := range dks {
|
||||
if _, ok := dockByStation[d.StationNo]; !ok && d.DockCode != "" {
|
||||
dockByStation[d.StationNo] = d.DockCode
|
||||
}
|
||||
}
|
||||
}
|
||||
for flowId, stations := range stationsByFlow {
|
||||
|
||||
@@ -30,17 +30,17 @@ func (s *Service) Seed(ctx context.Context) error {
|
||||
"produce.processflow", "produce.station", "produce.performance", "produce.processcard",
|
||||
// 按钮级权限(块2)
|
||||
"produce.workorder:add", "produce.workorder:edit", "produce.workorder:delete",
|
||||
"produce.workorder:dailyplan", "produce.material:generate", "produce.material:outbound",
|
||||
"produce.plc:send", "produce.product:add", "produce.product:edit", "produce.product:delete",
|
||||
"produce.workorder:dailyplan", "produce.material:generate", "produce.material:outbound",
|
||||
"produce.plc:send", "produce.product:add", "produce.product:edit", "produce.product:delete",
|
||||
"produce.processflow:add", "produce.processflow:edit", "produce.processflow:delete",
|
||||
"produce.processflow:upload", "produce.station:edit", "produce.station:add", "produce.station:delete",
|
||||
// 预警中心 / 附件中心(含归档清理按钮)
|
||||
"sys.alert", "sys.attachment", "sys.attachment:manage",
|
||||
// 数量不符处理(上报在工位终端,处理在本页)
|
||||
"produce.qty", "produce.qty:handle",
|
||||
// 质量检验:过程检操作工自检(process);完工检(final)由质检员专属(见下方 dropCodes,补1 权限粒度拆分)
|
||||
"produce.quality", "produce.quality:process",
|
||||
}
|
||||
// 数量不符处理(上报在工位终端,处理在本页)
|
||||
"produce.qty", "produce.qty:handle",
|
||||
// 质量检验:过程检操作工自检(process);完工检(final)由质检员专属(见下方 dropCodes,补1 权限粒度拆分)
|
||||
"produce.quality", "produce.quality:process",
|
||||
}
|
||||
} else if r.code == "INSPECTOR" {
|
||||
codes = []string{"produce.trace", "produce.wip", "produce.performance", "sys.eventlog",
|
||||
"sys.inspect", "sys.inspect:checkin", "sys.inspect:point", "sys.inspect:process",
|
||||
@@ -203,7 +203,7 @@ func (s *Service) Seed(ctx context.Context) error {
|
||||
seedStations(ctx, s)
|
||||
// 5. 接驳台主数据(真源在 MES,2026-09-21 自 WMS 迁入);系统预置只读
|
||||
seedDocks(ctx, s)
|
||||
// 6. 接驳台↔工位 1:1 绑定(系统预置只读主数据,页面不可更改,由种子初始化)
|
||||
// 6. 接驳台↔工位默认绑定(系统预置只读主数据;一工位可绑多接驳台,station.dock_code 仅存默认接驳台兜底)
|
||||
bindStationDocks(ctx, s)
|
||||
return nil
|
||||
}
|
||||
@@ -266,9 +266,10 @@ func seedStations(ctx context.Context, s *Service) {
|
||||
}
|
||||
}
|
||||
|
||||
// bindStationDocks 接驳台↔工位 1:1 绑定:接驳台为系统预置只读主数据,绑定关系由种子初始化、页面不可更改。
|
||||
// 内置且带接驳台的工位(station_no 1~10)各绑定一个产线接驳台(DOCK01~DOCK10);以 dock.station_no 为对照真源,
|
||||
// 若当前绑定不一致则回填,幂等可重复执行。库房/虚拟接驳台(station_no=0)及无接驳台工位不参与绑定。
|
||||
// bindStationDocks 接驳台↔工位默认绑定:按产线布局(2026-10-06),工位1~10 各配 R1/R2 两个接驳台,
|
||||
// 一个工位可对应多个接驳台,对应关系以 dock 表内置数据(用户内置/种子数据)为准,页面展示也按 dock 表聚合。
|
||||
// station.dock_code 仅作为「默认接驳台」兜底字段:仅在该工位尚未绑定时按 dock.station_no 回填一次,
|
||||
// 不覆盖既有值(避免一工位多接驳台时来回翻转);库房/虚拟接驳台(station_no=0)及无接驳台工位不参与。
|
||||
func bindStationDocks(ctx context.Context, s *Service) {
|
||||
docks, err := s.ctx.EntClient.Dock.Query().
|
||||
Where(dock.StationNoGT(0), dock.DockTypeEQ("line")).
|
||||
@@ -282,7 +283,7 @@ func bindStationDocks(ctx context.Context, s *Service) {
|
||||
if err != nil || st == nil {
|
||||
continue
|
||||
}
|
||||
if !st.HasDock || !st.IsBuiltin || st.DockCode == d.DockCode {
|
||||
if st.DockCode != "" || !st.HasDock || !st.IsBuiltin {
|
||||
continue
|
||||
}
|
||||
_, _ = s.ctx.EntClient.Station.UpdateOneID(st.ID).SetDockCode(d.DockCode).Save(ctx)
|
||||
|
||||
Reference in New Issue
Block a user