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:
@@ -5,7 +5,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"bj_power_mes/ent"
|
||||
@@ -206,10 +205,10 @@ func (s *Service) PlcMonitorClearInTransit(ctx context.Context, req ClearInTrans
|
||||
s.ctx.EventLog.Write(ctx, "plc_in_transit_clear", "", operator, "plc", obj,
|
||||
desc,
|
||||
map[string]any{
|
||||
"object": obj,
|
||||
"before": before,
|
||||
"after": 0,
|
||||
"operator": operator,
|
||||
"object": obj,
|
||||
"before": before,
|
||||
"after": 0,
|
||||
"operator": operator,
|
||||
"clearedAt": time.Now().Format(time.RFC3339),
|
||||
})
|
||||
return &ClearInTransitResult{Addr: req.Addr, Before: before}, nil
|
||||
@@ -219,12 +218,12 @@ func (s *Service) PlcMonitorClearInTransit(ctx context.Context, req ClearInTrans
|
||||
|
||||
// PositionMismatch 一处「MES 记录有、PLC 实际无」的位置不一致。
|
||||
type PositionMismatch struct {
|
||||
WorkpieceID int64 `json:"workpieceId"`
|
||||
Sn string `json:"sn"`
|
||||
OrderNo string `json:"orderNo"`
|
||||
Status string `json:"status"`
|
||||
AtStationNo int `json:"atStationNo"` // MES 记录的物理位置
|
||||
CurStationNo int `json:"curStationNo"` // MES 记录的业务位置(最后报工工位)
|
||||
WorkpieceID int64 `json:"workpieceId"`
|
||||
Sn string `json:"sn"`
|
||||
OrderNo string `json:"orderNo"`
|
||||
Status string `json:"status"`
|
||||
AtStationNo int `json:"atStationNo"` // MES 记录的物理位置
|
||||
CurStationNo int `json:"curStationNo"` // MES 记录的业务位置(最后报工工位)
|
||||
}
|
||||
|
||||
// PositionCheck 工件位置核对结果:PLC 实际点位态 + MES 记录与实际不符的工件列表。
|
||||
@@ -278,7 +277,7 @@ func (s *Service) PlcPositionCheck(ctx context.Context) (*PositionCheck, error)
|
||||
// CorrectPositionReq 工件位置纠正请求体。
|
||||
type CorrectPositionReq struct {
|
||||
WorkpieceID int64 `json:"workpieceId"`
|
||||
}// PlcPositionCorrect 纠正工件位置:把"记录在工位、实际 PLC 无托盘"的工件清为不在工位(atStationNo=0)。
|
||||
} // PlcPositionCorrect 纠正工件位置:把"记录在工位、实际 PLC 无托盘"的工件清为不在工位(atStationNo=0)。
|
||||
// 记操作日志(event_log,type=plc_position_correct),含工件 SN、纠正前/后位置、操作人。
|
||||
func (s *Service) PlcPositionCorrect(ctx context.Context, req CorrectPositionReq, operator string) error {
|
||||
if req.WorkpieceID <= 0 {
|
||||
@@ -308,81 +307,3 @@ func (s *Service) PlcPositionCorrect(ctx context.Context, req CorrectPositionReq
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
// ---------- 末端取件释放(块 H 收尾:末端下料检测位有工位在位信号,但无工位终端/接驳台、不下发 PLC 装配工序码,取件无完成信号,占用台账须人工确认释放) ----------
|
||||
|
||||
// EndPointOccupied 末端下料检测位(END-U=G11 上排 / END-D=G12 下排)的一条占用记录。
|
||||
type EndPointOccupied struct {
|
||||
PointNo string `json:"pointNo"` // 点位编号 END-U / END-D
|
||||
Label string `json:"label"` // 点位名称
|
||||
StationNo int `json:"stationNo"` // 对应工位 11/12
|
||||
Sn string `json:"sn"` // 占用工件的 SN
|
||||
OrderNo string `json:"orderNo"` // 来源:所属工单(占用记账时写入)
|
||||
UpdatedAt int64 `json:"updatedAt"` // 占用时间(点位台账最后更新时间)
|
||||
}
|
||||
|
||||
// ListEndPointOccupied 列出末端下料检测位(G11/G12)当前被占用的记录。
|
||||
// 末端下料检测位有工位在位信号,但无工位终端/接驳台、不下发 PLC 装配工序码(人工确认工位);取件动作没有「已取走」完成信号,工件被物理取走后点位台账不会自动清,必须人工确认释放。
|
||||
func (s *Service) ListEndPointOccupied(ctx context.Context) ([]EndPointOccupied, error) {
|
||||
pts, err := s.ctx.EntClient.LinePoint.Query().
|
||||
Where(linepoint.PointType("END"), linepoint.Occupied(true)).
|
||||
Order(ent.Asc(linepoint.FieldSeq)).All(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out := make([]EndPointOccupied, 0, len(pts))
|
||||
for _, p := range pts {
|
||||
out = append(out, EndPointOccupied{
|
||||
PointNo: p.PointNo,
|
||||
Label: p.Label,
|
||||
StationNo: p.StationNo,
|
||||
Sn: p.CurrentSn,
|
||||
OrderNo: p.OrderNo,
|
||||
UpdatedAt: p.UpdatedAt.Unix(),
|
||||
})
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// ReleaseEndPointReq 末端取件释放请求体。
|
||||
type ReleaseEndPointReq struct {
|
||||
PointNo string `json:"pointNo"`
|
||||
}
|
||||
|
||||
// ReleaseEndPoint 人工确认末端取件:释放 G11/G12 点位占用(OccupyPoint OUT)并写操作日志。
|
||||
// 记 event_log(type=point_release_manual),含 SN、点位、操作人、释放时间、说明「人工确认末端取件」。
|
||||
func (s *Service) ReleaseEndPoint(ctx context.Context, req ReleaseEndPointReq, operator string) error {
|
||||
pointNo := strings.TrimSpace(req.PointNo)
|
||||
if pointNo == "" {
|
||||
return errors.New("缺少点位编号")
|
||||
}
|
||||
pt, err := s.ctx.EntClient.LinePoint.Query().Where(linepoint.PointNo(pointNo)).First(ctx)
|
||||
if err != nil {
|
||||
return errors.New("点位不存在:" + pointNo)
|
||||
}
|
||||
if pt.PointType != "END" {
|
||||
return errors.New("仅支持释放末端下料检测位(G11/G12)")
|
||||
}
|
||||
if !pt.Occupied {
|
||||
return errors.New("该点位当前未被占用,无需释放")
|
||||
}
|
||||
sn, orderNo := pt.CurrentSn, pt.OrderNo
|
||||
// 释放点位(唯一事实源维护入口,内部写 line.point.out 流水)
|
||||
if err := s.OccupyPoint(ctx, pointNo, sn, orderNo, operator, "OUT"); err != nil {
|
||||
return err
|
||||
}
|
||||
now := time.Now().Unix()
|
||||
s.ctx.EventLog.Write(ctx, "point_release_manual", orderNo, operator, "line_point", pointNo,
|
||||
"人工确认末端取件:"+pointNo+"("+pt.Label+")",
|
||||
map[string]any{
|
||||
"object": "点位 " + pointNo,
|
||||
"pointNo": pointNo,
|
||||
"pointLabel": pt.Label,
|
||||
"sn": sn,
|
||||
"orderNo": orderNo,
|
||||
"operator": operator,
|
||||
"releasedAt": now,
|
||||
"note": "人工确认末端取件",
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user