【MES · 工位终端状态感知(11-28 第十三节拍板)】 - 新增 station_terminal_state / station_terminal_event 两表:当前状态镜像 + 状态变化流水 - 在线判定走既有 SSE 长连接存活:建连/断连/30s ping 心跳,90s 无心跳判离线,零 HTTP 轮询 - 登录/退出/暂停/恢复由终端事件驱动上报;新增「终端状态」管理页(produce.terminalstate,仅超级管理员):看在线/登录/操作人/接单/下班判定/心跳,抽屉看状态流水 - 库管代退料前置条件②「工人已下班」据此判定:未登录或终端离线任一即下班 【工位终端 · 全厂统一账号(11-28 拍板)】 - 删除本地账号表与 seed,登录直连 MES 用户表;本地 SQLite 只剩操作日志+登录态,断网不能换人 - SSE 客户端携带本机固定工位号,MES 据连接存活映射该工位在线状态 【单号短号规则(11-27 拍板)】 - 叫料单 MR / 叫料包 PK / 转产退库 TR / 配送单 DL:改「前缀+YYMMDD+3位当天序号」,每天从 001 归零、超 999 进 4 位 - MR 与 TR 同列不同前缀独立计数不撞号;进程内互斥分配 + DB 唯一索引兜底;历史时间戳号一律不动 【退料闭环(11-28)】 - 退库单新增 sn_list:工位提交的待退 SN 清单落库,收货逐颗扫码核对(不按批次分组、允许跨批次混合,所属批次系统按 SN 带出,库管不必填) - 收货改大数量必须有实物依据:SN 件以精确扫描的最终清单为准(条数相等且不重复);批次件必须落到真实启用的四级库位,禁止凭空加库存 - 余量参考值口径定稿(N4):应剩余量 = 实际备料 − 已消耗 − 已退 − 已损耗 - 损耗台账取消「后审核批注」:删 status/comment/commenter/commented_at 字段,WMS 确认收货当场落账闭环,MES 台账只读 【日排产 · 两种 PENDING 区分(11-26 口径定稿)】 - daily_plan 新增 discarded 废弃标记:停用打标、新建不打标;额度只算 CONFIRMED + 未废弃 PENDING - 工单管「要干几台」、日排产管「按天从哪个工位领多少料」,两张账不合并不互倒推;排产合计可小于工单数(缺口靠借料/补料审批摆出,不自动兜底) 【其他】 - SN 查询大小写脱敏(11-27):存储原样不强制大小写,匹配 LOWER(sn)=LOWER(?),扫 ABC-0001 与 abc-0001 命中同一件 - 拧紧枪人工跳过链路:设备未连接时人工跳过上报,「拧紧跳过(设备未连接)」前缀单独列示,不写 torque_record 绝不冒充设备结果 - 单据流转提示规则表全量 35 条(MES 18 + WMS 17):常驻提示条、单号可复制;单号字段逐条对后端响应实测,取不到不显示复制按钮 - PLC 快照缓存/对账、产线清线、绩效与拧紧枪配置页同步修正 【文档】 - 新增《临时结束.md》2026-11-26 日排产/叫料/完工口径大讨论定稿(含状态专项结论与被推翻旧说法留档);问题临时.md 全量更新
172 lines
5.9 KiB
Go
172 lines
5.9 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_mes/ent/stationterminalevent"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
)
|
|
|
|
// StationTerminalEvent 工位终端状态变化流水(只增)。
|
|
type StationTerminalEvent struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int `json:"id,omitempty"`
|
|
// 工位号
|
|
StationNo int `json:"stationNo,omitempty"`
|
|
// 事件:stream_on/stream_off/login/logout/pause/resume/heartbeat
|
|
Event string `json:"event,omitempty"`
|
|
// 事件后登录态
|
|
LoggedIn bool `json:"loggedIn,omitempty"`
|
|
// 事件后开机态
|
|
Powered bool `json:"powered,omitempty"`
|
|
// 操作人
|
|
Operator string `json:"operator,omitempty"`
|
|
// 补充说明
|
|
Detail string `json:"detail,omitempty"`
|
|
// 事件时间 unix秒
|
|
CreatedAt int64 `json:"createdAt,omitempty"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*StationTerminalEvent) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case stationterminalevent.FieldLoggedIn, stationterminalevent.FieldPowered:
|
|
values[i] = new(sql.NullBool)
|
|
case stationterminalevent.FieldID, stationterminalevent.FieldStationNo, stationterminalevent.FieldCreatedAt:
|
|
values[i] = new(sql.NullInt64)
|
|
case stationterminalevent.FieldEvent, stationterminalevent.FieldOperator, stationterminalevent.FieldDetail:
|
|
values[i] = new(sql.NullString)
|
|
default:
|
|
values[i] = new(sql.UnknownType)
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the StationTerminalEvent fields.
|
|
func (_m *StationTerminalEvent) assignValues(columns []string, values []any) error {
|
|
if m, n := len(values), len(columns); m < n {
|
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
|
}
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case stationterminalevent.FieldID:
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
}
|
|
_m.ID = int(value.Int64)
|
|
case stationterminalevent.FieldStationNo:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field stationNo", values[i])
|
|
} else if value.Valid {
|
|
_m.StationNo = int(value.Int64)
|
|
}
|
|
case stationterminalevent.FieldEvent:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field event", values[i])
|
|
} else if value.Valid {
|
|
_m.Event = value.String
|
|
}
|
|
case stationterminalevent.FieldLoggedIn:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field loggedIn", values[i])
|
|
} else if value.Valid {
|
|
_m.LoggedIn = value.Bool
|
|
}
|
|
case stationterminalevent.FieldPowered:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field powered", values[i])
|
|
} else if value.Valid {
|
|
_m.Powered = value.Bool
|
|
}
|
|
case stationterminalevent.FieldOperator:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field operator", values[i])
|
|
} else if value.Valid {
|
|
_m.Operator = value.String
|
|
}
|
|
case stationterminalevent.FieldDetail:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field detail", values[i])
|
|
} else if value.Valid {
|
|
_m.Detail = value.String
|
|
}
|
|
case stationterminalevent.FieldCreatedAt:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field createdAt", values[i])
|
|
} else if value.Valid {
|
|
_m.CreatedAt = value.Int64
|
|
}
|
|
default:
|
|
_m.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the StationTerminalEvent.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *StationTerminalEvent) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// Update returns a builder for updating this StationTerminalEvent.
|
|
// Note that you need to call StationTerminalEvent.Unwrap() before calling this method if this StationTerminalEvent
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *StationTerminalEvent) Update() *StationTerminalEventUpdateOne {
|
|
return NewStationTerminalEventClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the StationTerminalEvent entity that was returned from a transaction after it was closed,
|
|
// so that all future queries will be executed through the driver which created the transaction.
|
|
func (_m *StationTerminalEvent) Unwrap() *StationTerminalEvent {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: StationTerminalEvent is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *StationTerminalEvent) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("StationTerminalEvent(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
builder.WriteString("stationNo=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.StationNo))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("event=")
|
|
builder.WriteString(_m.Event)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("loggedIn=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.LoggedIn))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("powered=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.Powered))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("operator=")
|
|
builder.WriteString(_m.Operator)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("detail=")
|
|
builder.WriteString(_m.Detail)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("createdAt=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.CreatedAt))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// StationTerminalEvents is a parsable slice of StationTerminalEvent.
|
|
type StationTerminalEvents []*StationTerminalEvent
|