feat: 来料检处置项实体与复检、日排产达成对比、PLC/WMS 传输日志
- WMS 新增「检验处置项」实体(schema + ent 生成码),配套检验记录实体调整与复检接口,完善来料检/不良退货/入库检验前端 - MES 日排产:新增达成率统计与计划对比逻辑,调整日排产前端与流程卡/工序流 - 日志与传输:MES 新增 PLC 日志与 WMS 客户端传输日志,WMS 新增 MES 客户端传输日志 - MES 其他:扫码、工单/工件、AGV 客户端与告警、产品导入等逻辑完善及前端调整 - 工位终端:上线面板/作业面板、工件 handler 与 MES 客户端调整 - 配置与文档:更新 mes-api.yaml、三端构建产物与问题记录文档
This commit is contained in:
@@ -82,13 +82,26 @@ func (s *Service) flowStationPoint(ctx context.Context, stationNo int) (*ent.Lin
|
||||
return pts[0], true
|
||||
}
|
||||
|
||||
// flowStationBusy 该工位/末端是否被其他在制工件占用(按工件台账 atStationNo 判定,
|
||||
// 口径与 plc_monitor 位置核对一致;DONE/SCRAPPED 不算占用)。
|
||||
func (s *Service) flowStationBusy(ctx context.Context, stationNo int) bool {
|
||||
exist, err := s.ctx.EntClient.Workpiece.Query().
|
||||
// flowStationBusyBy 工位台面占用判定(2026-11-16 工位物理互斥):
|
||||
// 滚筒线单件流,工位台面同一时间只能放一个工件。按工件台账 atStationNo 判定,
|
||||
// 口径与 plc_monitor 位置核对一致;DONE/SCRAPPED 不算占用。
|
||||
// 返回:台面是否被占、占用件所属工单号。占用件属于其他工单 → 本件不准流入,在缓存位排队。
|
||||
func (s *Service) flowStationBusyBy(ctx context.Context, stationNo int, orderNo string) (bool, string, error) {
|
||||
wps, err := s.ctx.EntClient.Workpiece.Query().
|
||||
Where(workpiece.AtStationNoEQ(stationNo), workpiece.StatusNotIn("DONE", "SCRAPPED")).
|
||||
Exist(ctx)
|
||||
return err == nil && exist
|
||||
All(ctx)
|
||||
if err != nil {
|
||||
return false, "", err
|
||||
}
|
||||
for _, w := range wps {
|
||||
if w.OrderNo != orderNo {
|
||||
return true, w.OrderNo, nil
|
||||
}
|
||||
}
|
||||
if len(wps) > 0 {
|
||||
return true, "", nil // 台面被本工单在制件占用,同样放不进第二件
|
||||
}
|
||||
return false, "", nil
|
||||
}
|
||||
|
||||
// flowSend 按 §4.4 路由表下发流转指令,返回执行方式:
|
||||
@@ -191,8 +204,11 @@ func (s *Service) flowMoveOnce(ctx context.Context, sn, operator string) (*FlowM
|
||||
}
|
||||
// 目标选择:真实候选工位优先(升序,首个「台账空闲 + 无其他在制工件」者);
|
||||
// 无台账行=虚拟工位(负数前段工位)仅作兜底。
|
||||
// 2026-11-16 工位物理互斥:滚筒线单件流,工位台面被其他工单在制件占用 → 不准流入,
|
||||
// 件留在缓存位/原地排队(下游 flowToCacheOrStay / stay)。末端下料位(END)豁免互斥。
|
||||
var virtualCand *int
|
||||
occupiedHit := false
|
||||
occupiedHint := ""
|
||||
for _, cand := range cands {
|
||||
pt, has := s.flowStationPoint(ctx, cand)
|
||||
if !has {
|
||||
@@ -200,10 +216,21 @@ func (s *Service) flowMoveOnce(ctx context.Context, sn, operator string) (*FlowM
|
||||
virtualCand = &c
|
||||
continue
|
||||
}
|
||||
if pt.Occupied || s.flowStationBusy(ctx, cand) {
|
||||
if pt.Occupied {
|
||||
occupiedHit = true
|
||||
continue
|
||||
}
|
||||
if pt.PointType != "END" {
|
||||
busy, otherOrder, err := s.flowStationBusyBy(ctx, cand, wp.OrderNo)
|
||||
if err == nil && busy {
|
||||
occupiedHit = true
|
||||
if otherOrder != "" {
|
||||
occupiedHint = "工位" + strconv.Itoa(cand) + "正在加工工单" + otherOrder +
|
||||
"的工件,须等其流转走后本件才能进入,已在缓存位排队等待"
|
||||
}
|
||||
continue
|
||||
}
|
||||
}
|
||||
return s.flowExecMove(ctx, src, wp, sn, srcType, srcNo, pt, operator, doneAll)
|
||||
}
|
||||
if virtualCand != nil {
|
||||
@@ -213,6 +240,9 @@ func (s *Service) flowMoveOnce(ctx context.Context, sn, operator string) (*FlowM
|
||||
if occupiedHit && srcType == plc.SrcStation && !doneAll {
|
||||
return s.flowToCacheOrStay(ctx, src, wp, sn, operator, srcNo)
|
||||
}
|
||||
if occupiedHint != "" {
|
||||
return stay(occupiedHint)
|
||||
}
|
||||
return stay("下一道工序候选工位均不可达/不可用,滞留原地")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user