feat: 移除工艺物料与混产模板实体、新增产线清线与 PLC 监控实时推送、看板双屏增强
- 移除实体:MES 删除 FlowMaterial(工艺物料)与 MixProductionTemplate(混产模板)全套(schema/ent 生成码/handler/logic),清理关联路由与种子 - 新增功能:产线清线(line_clearance handler + logic)、PLC 监控 WebSocket 实时推送(ws/plc_monitor_hub + handler) - 看板增强:新增管理屏与 KPI 组件(BoardManage/BoardKpi),调整演示屏 Mock 与各看板面板 - MES 完善:PLC 匹配/扭矩扫描/签收、工艺卡 PDF 与工单、AGV 链路、叫料/备料/在制品/短料预测等逻辑与前端调整 - 工位终端:删除离线面板 OfflinePanel,调整主界面/物料面板与 api/store/handler/路由 - WMS:AGV 托盘、物料与 MES 客户端调整及前端帮助/基础数据/叫料/托盘页 - 文档:更新产线API/客户问题/案例/部署手册/问题记录
This commit is contained in:
@@ -17,8 +17,8 @@ import (
|
||||
// ============ 报工后自动流转连锁(triggerFlowChain,2026-11-11 拍板) ============
|
||||
//
|
||||
// 报工完成后,工件物理位置自动推进:
|
||||
// 1. 有下一道工序:送该工序候选工位中首个「台账空闲 + 无其他在制工件 + §4.4 路由可达」的工位;
|
||||
// 2. 全部工序完成:送末端下料检测位(END-U=工位11 / END-D=工位12);
|
||||
// 1. 有下一道工艺:送该工艺候选工位中首个「台账空闲 + 无其他在制工件 + §4.4 路由可达」的工位;
|
||||
// 2. 全部工艺完成:送末端下料检测位(END-U=工位11 / END-D=工位12);
|
||||
// 3. 下游候选工位全部被占:按基础设置 cache.multi.order.policy(CfgMultiOrderCachePolicy)
|
||||
// —— strict=把工件送进源工位可达的第一个空闲缓存位(CACHE:C2/C3/C5/C6/C8/C9/C11/C12/C14)
|
||||
// 排队,无可达空位则落「缓存满载」报警并滞留原地;physical=直接堵在原地不动;
|
||||
@@ -173,12 +173,12 @@ func (s *Service) flowMoveOnce(ctx context.Context, sn, operator string) (*FlowM
|
||||
}
|
||||
route, err := FlowRouteOfWO(ctx, s.ctx.EntClient, wo)
|
||||
if err != nil || len(route) == 0 {
|
||||
return stay("工单未配置工艺组合,无法推导下一道工序")
|
||||
return stay("工单未配置工艺组合,无法推导下一道工艺")
|
||||
}
|
||||
nextSeq, doneAll := s.firstUndoneFlowSeq(ctx, s.ctx.EntClient, sn, route)
|
||||
var cands []int
|
||||
if doneAll {
|
||||
// 全部工序完成 → 末端下料检测位(G11/G12)
|
||||
// 全部工艺完成 → 末端下料检测位(G11/G12)
|
||||
cands = []int{11, 12}
|
||||
} else {
|
||||
for i := range route {
|
||||
@@ -188,7 +188,7 @@ func (s *Service) flowMoveOnce(ctx context.Context, sn, operator string) (*FlowM
|
||||
}
|
||||
}
|
||||
if len(cands) == 0 {
|
||||
return stay("未找到下一道工序的候选工位")
|
||||
return stay("未找到下一道工艺的候选工位")
|
||||
}
|
||||
}
|
||||
srcType, srcNo, sok := flowSrcInfo(src)
|
||||
@@ -198,9 +198,9 @@ func (s *Service) flowMoveOnce(ctx context.Context, sn, operator string) (*FlowM
|
||||
if src.PointType == "END" {
|
||||
return stay("工件已在末端下料检测位 " + src.PointNo + ",等待人工取件")
|
||||
}
|
||||
// 工件正停在下一道工序的候选工位上 → 等待加工,不推进
|
||||
// 工件正停在下一道工艺的候选工位上 → 等待加工,不推进
|
||||
if !doneAll && src.PointType == "STATION" && intsContains(cands, src.StationNo) {
|
||||
return stay("工件在工序候选工位" + strconv.Itoa(src.StationNo) + "等待加工")
|
||||
return stay("工件在工艺候选工位" + strconv.Itoa(src.StationNo) + "等待加工")
|
||||
}
|
||||
// 目标选择:真实候选工位优先(升序,首个「台账空闲 + 无其他在制工件」者);
|
||||
// 无台账行=虚拟工位(负数前段工位)仅作兜底。
|
||||
@@ -243,7 +243,7 @@ func (s *Service) flowMoveOnce(ctx context.Context, sn, operator string) (*FlowM
|
||||
if occupiedHint != "" {
|
||||
return stay(occupiedHint)
|
||||
}
|
||||
return stay("下一道工序候选工位均不可达/不可用,滞留原地")
|
||||
return stay("下一道工艺候选工位均不可达/不可用,滞留原地")
|
||||
}
|
||||
|
||||
// flowExecMove 流转到真实工位/末端:下发路由 + 台账 OUT/IN + 工件台账 + 流水。
|
||||
@@ -269,7 +269,7 @@ func (s *Service) flowExecMove(ctx context.Context, src *ent.LinePoint, wp *ent.
|
||||
}
|
||||
remark := "报工后自动流转 " + src.PointNo + " → " + tgtPt.PointNo
|
||||
if doneAll {
|
||||
remark = "全部工序完成,自动流转至末端下料位"
|
||||
remark = "全部工艺完成,自动流转至末端下料位"
|
||||
}
|
||||
s.flowLifecycle(ctx, wp, sn, operator, tgtNo, remark)
|
||||
s.ctx.EventLog.Write(ctx, "workpiece.flow.move", wp.OrderNo, operator, "workpiece", sn,
|
||||
@@ -286,18 +286,33 @@ func (s *Service) flowLedgerVirtualMove(ctx context.Context, src *ent.LinePoint,
|
||||
return &FlowMoveResult{Sn: sn, From: src.PointNo, Mode: flowModeStay,
|
||||
Msg: "虚拟工位流转失败(原点位释放出错):" + err.Error()}, false
|
||||
}
|
||||
// 物理下线(2026-11-18 用户拍板):虚拟工位无物理点位,件实体下线 → 下发 PLC 送末端下料位
|
||||
// (END-U 台账空闲走 G11,被占走 G12)。末端不落台账——件由虚拟工位台账(at_station_no)追踪,
|
||||
// 后续工艺报工在虚拟工位终端做,与件物理上停在 11 还是 12 无关。
|
||||
tgtNo := 11
|
||||
if pt, e := s.ctx.EntClient.LinePoint.Query().
|
||||
Where(linepoint.PointType("END"), linepoint.PointNoEQ("END-U"), linepoint.Occupied(true)).
|
||||
First(ctx); e == nil && pt != nil {
|
||||
tgtNo = 12
|
||||
}
|
||||
physMsg := ""
|
||||
if (src.PointType == "STATION" || src.PointType == "END") && src.StationNo >= 1 && src.StationNo <= 10 {
|
||||
if _, _, _, ok := s.flowSend(ctx, plc.SrcStation, src.StationNo, tgtNo, plc.SrcStation); ok {
|
||||
physMsg = ",实体已下发流转至末端下料位 G" + strconv.Itoa(tgtNo)
|
||||
}
|
||||
}
|
||||
if _, err := s.ctx.EntClient.Workpiece.UpdateOneID(wp.ID).SetAtStationNo(cand).Save(ctx); err != nil {
|
||||
return &FlowMoveResult{Sn: sn, From: src.PointNo, Mode: flowModeStay,
|
||||
Msg: "虚拟工位流转失败(工件台账更新出错):" + err.Error()}, false
|
||||
}
|
||||
label := "虚拟工位" + strconv.Itoa(cand)
|
||||
s.flowLifecycle(ctx, wp, sn, operator, cand, "流转至虚拟工位(无物理点位),纯台账流转")
|
||||
s.flowLifecycle(ctx, wp, sn, operator, cand, "流转至虚拟工位(无物理点位),纯台账流转"+physMsg)
|
||||
s.ctx.EventLog.Write(ctx, "workpiece.flow.move", wp.OrderNo, operator, "workpiece", sn,
|
||||
"自动流转至虚拟工位 "+strconv.Itoa(cand)+"(纯台账)",
|
||||
"自动流转至虚拟工位 "+strconv.Itoa(cand)+"(台账流转"+physMsg+")",
|
||||
map[string]any{"sn": sn, "orderNo": wp.OrderNo, "from": src.PointNo, "to": label, "mode": flowModeLedger})
|
||||
s.notifyDashboard()
|
||||
return &FlowMoveResult{Sn: sn, From: src.PointNo, To: label, Mode: flowModeLedger,
|
||||
Msg: "虚拟工位(无物理点位),纯台账流转"}, true
|
||||
Msg: "虚拟工位(无物理点位),台账流转" + physMsg}, true
|
||||
}
|
||||
|
||||
// flowToCacheOrStay 下游候选工位全部被占时的缓存策略分流(仅 strict 且源为工位时进缓存):
|
||||
@@ -349,7 +364,7 @@ func (s *Service) flowToCacheOrStay(ctx context.Context, src *ent.LinePoint, wp
|
||||
// alertLineCacheFull 缓存满载报警(type=line_cache_full,refType=flow_cache_full + refId=sn
|
||||
// 去重:同一工件存在未读报警时不再重复落)。
|
||||
func (s *Service) alertLineCacheFull(ctx context.Context, sn string, src *ent.LinePoint, srcNo int) {
|
||||
msg := fmt.Sprintf("产线缓存满载:工件 %s 流转时下游工序候选工位全部被占,且工位%d 可达的缓存位(C2/C3/C5/C6/C8/C9/C11/C12/C14)均无空位,工件滞留 %s,请人工干预或清理下游工位。",
|
||||
msg := fmt.Sprintf("产线缓存满载:工件 %s 流转时下游工艺候选工位全部被占,且工位%d 可达的缓存位(C2/C3/C5/C6/C8/C9/C11/C12/C14)均无空位,工件滞留 %s,请人工干预或清理下游工位。",
|
||||
sn, srcNo, src.PointNo)
|
||||
has, err := s.ctx.EntClient.Alert.Query().
|
||||
Where(alert.RefTypeEQ("flow_cache_full"), alert.RefIdEQ(sn), alert.StatusEQ("UNREAD")).
|
||||
|
||||
Reference in New Issue
Block a user