【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
6.2 KiB
Go
172 lines
6.2 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
||
|
||
package ent
|
||
|
||
import (
|
||
"bj_power_mes/ent/stationterminalstate"
|
||
"fmt"
|
||
"strings"
|
||
|
||
"entgo.io/ent"
|
||
"entgo.io/ent/dialect/sql"
|
||
)
|
||
|
||
// StationTerminalState 工位终端当前状态(上报镜像+心跳)。
|
||
type StationTerminalState struct {
|
||
config `json:"-"`
|
||
// ID of the ent.
|
||
ID int `json:"id,omitempty"`
|
||
// 工位号
|
||
StationNo int `json:"stationNo,omitempty"`
|
||
// 终端是否在线(SSE 建连 stream_on 置 true,断连 stream_off 置 false)
|
||
Powered bool `json:"powered,omitempty"`
|
||
// 该工位是否有登录会话(终端上报登录=是/退出=否)
|
||
LoggedIn bool `json:"loggedIn,omitempty"`
|
||
// 当前登录人(终端上报;无会话为空)
|
||
Operator string `json:"operator,omitempty"`
|
||
// 是否暂停接单(终端上报暂停/恢复)
|
||
Paused bool `json:"paused,omitempty"`
|
||
// 最近一次 SSE ping 心跳时间 unix秒(0=从未连接)
|
||
LastHeartbeatAt int64 `json:"lastHeartbeatAt,omitempty"`
|
||
// 状态更新时间 unix秒
|
||
UpdatedAt int64 `json:"updatedAt,omitempty"`
|
||
selectValues sql.SelectValues
|
||
}
|
||
|
||
// scanValues returns the types for scanning values from sql.Rows.
|
||
func (*StationTerminalState) scanValues(columns []string) ([]any, error) {
|
||
values := make([]any, len(columns))
|
||
for i := range columns {
|
||
switch columns[i] {
|
||
case stationterminalstate.FieldPowered, stationterminalstate.FieldLoggedIn, stationterminalstate.FieldPaused:
|
||
values[i] = new(sql.NullBool)
|
||
case stationterminalstate.FieldID, stationterminalstate.FieldStationNo, stationterminalstate.FieldLastHeartbeatAt, stationterminalstate.FieldUpdatedAt:
|
||
values[i] = new(sql.NullInt64)
|
||
case stationterminalstate.FieldOperator:
|
||
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 StationTerminalState fields.
|
||
func (_m *StationTerminalState) 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 stationterminalstate.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 stationterminalstate.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 stationterminalstate.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 stationterminalstate.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 stationterminalstate.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 stationterminalstate.FieldPaused:
|
||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||
return fmt.Errorf("unexpected type %T for field paused", values[i])
|
||
} else if value.Valid {
|
||
_m.Paused = value.Bool
|
||
}
|
||
case stationterminalstate.FieldLastHeartbeatAt:
|
||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||
return fmt.Errorf("unexpected type %T for field lastHeartbeatAt", values[i])
|
||
} else if value.Valid {
|
||
_m.LastHeartbeatAt = value.Int64
|
||
}
|
||
case stationterminalstate.FieldUpdatedAt:
|
||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||
return fmt.Errorf("unexpected type %T for field updatedAt", values[i])
|
||
} else if value.Valid {
|
||
_m.UpdatedAt = 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 StationTerminalState.
|
||
// This includes values selected through modifiers, order, etc.
|
||
func (_m *StationTerminalState) Value(name string) (ent.Value, error) {
|
||
return _m.selectValues.Get(name)
|
||
}
|
||
|
||
// Update returns a builder for updating this StationTerminalState.
|
||
// Note that you need to call StationTerminalState.Unwrap() before calling this method if this StationTerminalState
|
||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||
func (_m *StationTerminalState) Update() *StationTerminalStateUpdateOne {
|
||
return NewStationTerminalStateClient(_m.config).UpdateOne(_m)
|
||
}
|
||
|
||
// Unwrap unwraps the StationTerminalState 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 *StationTerminalState) Unwrap() *StationTerminalState {
|
||
_tx, ok := _m.config.driver.(*txDriver)
|
||
if !ok {
|
||
panic("ent: StationTerminalState is not a transactional entity")
|
||
}
|
||
_m.config.driver = _tx.drv
|
||
return _m
|
||
}
|
||
|
||
// String implements the fmt.Stringer.
|
||
func (_m *StationTerminalState) String() string {
|
||
var builder strings.Builder
|
||
builder.WriteString("StationTerminalState(")
|
||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||
builder.WriteString("stationNo=")
|
||
builder.WriteString(fmt.Sprintf("%v", _m.StationNo))
|
||
builder.WriteString(", ")
|
||
builder.WriteString("powered=")
|
||
builder.WriteString(fmt.Sprintf("%v", _m.Powered))
|
||
builder.WriteString(", ")
|
||
builder.WriteString("loggedIn=")
|
||
builder.WriteString(fmt.Sprintf("%v", _m.LoggedIn))
|
||
builder.WriteString(", ")
|
||
builder.WriteString("operator=")
|
||
builder.WriteString(_m.Operator)
|
||
builder.WriteString(", ")
|
||
builder.WriteString("paused=")
|
||
builder.WriteString(fmt.Sprintf("%v", _m.Paused))
|
||
builder.WriteString(", ")
|
||
builder.WriteString("lastHeartbeatAt=")
|
||
builder.WriteString(fmt.Sprintf("%v", _m.LastHeartbeatAt))
|
||
builder.WriteString(", ")
|
||
builder.WriteString("updatedAt=")
|
||
builder.WriteString(fmt.Sprintf("%v", _m.UpdatedAt))
|
||
builder.WriteByte(')')
|
||
return builder.String()
|
||
}
|
||
|
||
// StationTerminalStates is a parsable slice of StationTerminalState.
|
||
type StationTerminalStates []*StationTerminalState
|