feat(mes/wms/终端): 工位终端状态感知 + 全厂统一账号 + 单号短号规则 + 退料SN逐颗核对闭环(2026-11-26~28 现场整改)

【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 全量更新
This commit is contained in:
SunYF
2026-11-28 13:44:51 +08:00
parent 79a9d7846d
commit 88875c1f13
163 changed files with 11754 additions and 3021 deletions
@@ -0,0 +1,114 @@
// Code generated by ent, DO NOT EDIT.
package stationterminalstate
import (
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the stationterminalstate type in the database.
Label = "station_terminal_state"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldStationNo holds the string denoting the stationno field in the database.
FieldStationNo = "station_no"
// FieldPowered holds the string denoting the powered field in the database.
FieldPowered = "powered"
// FieldLoggedIn holds the string denoting the loggedin field in the database.
FieldLoggedIn = "logged_in"
// FieldOperator holds the string denoting the operator field in the database.
FieldOperator = "operator"
// FieldPaused holds the string denoting the paused field in the database.
FieldPaused = "paused"
// FieldLastHeartbeatAt holds the string denoting the lastheartbeatat field in the database.
FieldLastHeartbeatAt = "last_heartbeat_at"
// FieldUpdatedAt holds the string denoting the updatedat field in the database.
FieldUpdatedAt = "updated_at"
// Table holds the table name of the stationterminalstate in the database.
Table = "station_terminal_state"
)
// Columns holds all SQL columns for stationterminalstate fields.
var Columns = []string{
FieldID,
FieldStationNo,
FieldPowered,
FieldLoggedIn,
FieldOperator,
FieldPaused,
FieldLastHeartbeatAt,
FieldUpdatedAt,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// DefaultPowered holds the default value on creation for the "powered" field.
DefaultPowered bool
// DefaultLoggedIn holds the default value on creation for the "loggedIn" field.
DefaultLoggedIn bool
// DefaultOperator holds the default value on creation for the "operator" field.
DefaultOperator string
// OperatorValidator is a validator for the "operator" field. It is called by the builders before save.
OperatorValidator func(string) error
// DefaultPaused holds the default value on creation for the "paused" field.
DefaultPaused bool
// DefaultLastHeartbeatAt holds the default value on creation for the "lastHeartbeatAt" field.
DefaultLastHeartbeatAt int64
// DefaultUpdatedAt holds the default value on creation for the "updatedAt" field.
DefaultUpdatedAt int64
// IDValidator is a validator for the "id" field. It is called by the builders before save.
IDValidator func(int) error
)
// OrderOption defines the ordering options for the StationTerminalState queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByStationNo orders the results by the stationNo field.
func ByStationNo(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStationNo, opts...).ToFunc()
}
// ByPowered orders the results by the powered field.
func ByPowered(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPowered, opts...).ToFunc()
}
// ByLoggedIn orders the results by the loggedIn field.
func ByLoggedIn(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLoggedIn, opts...).ToFunc()
}
// ByOperator orders the results by the operator field.
func ByOperator(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldOperator, opts...).ToFunc()
}
// ByPaused orders the results by the paused field.
func ByPaused(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPaused, opts...).ToFunc()
}
// ByLastHeartbeatAt orders the results by the lastHeartbeatAt field.
func ByLastHeartbeatAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLastHeartbeatAt, opts...).ToFunc()
}
// ByUpdatedAt orders the results by the updatedAt field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
@@ -0,0 +1,319 @@
// Code generated by ent, DO NOT EDIT.
package stationterminalstate
import (
"bj_power_mes/ent/predicate"
"entgo.io/ent/dialect/sql"
)
// ID filters vertices based on their ID field.
func ID(id int) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldLTE(FieldID, id))
}
// StationNo applies equality check predicate on the "stationNo" field. It's identical to StationNoEQ.
func StationNo(v int) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldEQ(FieldStationNo, v))
}
// Powered applies equality check predicate on the "powered" field. It's identical to PoweredEQ.
func Powered(v bool) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldEQ(FieldPowered, v))
}
// LoggedIn applies equality check predicate on the "loggedIn" field. It's identical to LoggedInEQ.
func LoggedIn(v bool) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldEQ(FieldLoggedIn, v))
}
// Operator applies equality check predicate on the "operator" field. It's identical to OperatorEQ.
func Operator(v string) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldEQ(FieldOperator, v))
}
// Paused applies equality check predicate on the "paused" field. It's identical to PausedEQ.
func Paused(v bool) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldEQ(FieldPaused, v))
}
// LastHeartbeatAt applies equality check predicate on the "lastHeartbeatAt" field. It's identical to LastHeartbeatAtEQ.
func LastHeartbeatAt(v int64) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldEQ(FieldLastHeartbeatAt, v))
}
// UpdatedAt applies equality check predicate on the "updatedAt" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v int64) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldEQ(FieldUpdatedAt, v))
}
// StationNoEQ applies the EQ predicate on the "stationNo" field.
func StationNoEQ(v int) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldEQ(FieldStationNo, v))
}
// StationNoNEQ applies the NEQ predicate on the "stationNo" field.
func StationNoNEQ(v int) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldNEQ(FieldStationNo, v))
}
// StationNoIn applies the In predicate on the "stationNo" field.
func StationNoIn(vs ...int) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldIn(FieldStationNo, vs...))
}
// StationNoNotIn applies the NotIn predicate on the "stationNo" field.
func StationNoNotIn(vs ...int) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldNotIn(FieldStationNo, vs...))
}
// StationNoGT applies the GT predicate on the "stationNo" field.
func StationNoGT(v int) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldGT(FieldStationNo, v))
}
// StationNoGTE applies the GTE predicate on the "stationNo" field.
func StationNoGTE(v int) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldGTE(FieldStationNo, v))
}
// StationNoLT applies the LT predicate on the "stationNo" field.
func StationNoLT(v int) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldLT(FieldStationNo, v))
}
// StationNoLTE applies the LTE predicate on the "stationNo" field.
func StationNoLTE(v int) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldLTE(FieldStationNo, v))
}
// PoweredEQ applies the EQ predicate on the "powered" field.
func PoweredEQ(v bool) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldEQ(FieldPowered, v))
}
// PoweredNEQ applies the NEQ predicate on the "powered" field.
func PoweredNEQ(v bool) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldNEQ(FieldPowered, v))
}
// LoggedInEQ applies the EQ predicate on the "loggedIn" field.
func LoggedInEQ(v bool) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldEQ(FieldLoggedIn, v))
}
// LoggedInNEQ applies the NEQ predicate on the "loggedIn" field.
func LoggedInNEQ(v bool) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldNEQ(FieldLoggedIn, v))
}
// OperatorEQ applies the EQ predicate on the "operator" field.
func OperatorEQ(v string) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldEQ(FieldOperator, v))
}
// OperatorNEQ applies the NEQ predicate on the "operator" field.
func OperatorNEQ(v string) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldNEQ(FieldOperator, v))
}
// OperatorIn applies the In predicate on the "operator" field.
func OperatorIn(vs ...string) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldIn(FieldOperator, vs...))
}
// OperatorNotIn applies the NotIn predicate on the "operator" field.
func OperatorNotIn(vs ...string) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldNotIn(FieldOperator, vs...))
}
// OperatorGT applies the GT predicate on the "operator" field.
func OperatorGT(v string) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldGT(FieldOperator, v))
}
// OperatorGTE applies the GTE predicate on the "operator" field.
func OperatorGTE(v string) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldGTE(FieldOperator, v))
}
// OperatorLT applies the LT predicate on the "operator" field.
func OperatorLT(v string) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldLT(FieldOperator, v))
}
// OperatorLTE applies the LTE predicate on the "operator" field.
func OperatorLTE(v string) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldLTE(FieldOperator, v))
}
// OperatorContains applies the Contains predicate on the "operator" field.
func OperatorContains(v string) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldContains(FieldOperator, v))
}
// OperatorHasPrefix applies the HasPrefix predicate on the "operator" field.
func OperatorHasPrefix(v string) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldHasPrefix(FieldOperator, v))
}
// OperatorHasSuffix applies the HasSuffix predicate on the "operator" field.
func OperatorHasSuffix(v string) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldHasSuffix(FieldOperator, v))
}
// OperatorEqualFold applies the EqualFold predicate on the "operator" field.
func OperatorEqualFold(v string) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldEqualFold(FieldOperator, v))
}
// OperatorContainsFold applies the ContainsFold predicate on the "operator" field.
func OperatorContainsFold(v string) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldContainsFold(FieldOperator, v))
}
// PausedEQ applies the EQ predicate on the "paused" field.
func PausedEQ(v bool) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldEQ(FieldPaused, v))
}
// PausedNEQ applies the NEQ predicate on the "paused" field.
func PausedNEQ(v bool) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldNEQ(FieldPaused, v))
}
// LastHeartbeatAtEQ applies the EQ predicate on the "lastHeartbeatAt" field.
func LastHeartbeatAtEQ(v int64) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldEQ(FieldLastHeartbeatAt, v))
}
// LastHeartbeatAtNEQ applies the NEQ predicate on the "lastHeartbeatAt" field.
func LastHeartbeatAtNEQ(v int64) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldNEQ(FieldLastHeartbeatAt, v))
}
// LastHeartbeatAtIn applies the In predicate on the "lastHeartbeatAt" field.
func LastHeartbeatAtIn(vs ...int64) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldIn(FieldLastHeartbeatAt, vs...))
}
// LastHeartbeatAtNotIn applies the NotIn predicate on the "lastHeartbeatAt" field.
func LastHeartbeatAtNotIn(vs ...int64) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldNotIn(FieldLastHeartbeatAt, vs...))
}
// LastHeartbeatAtGT applies the GT predicate on the "lastHeartbeatAt" field.
func LastHeartbeatAtGT(v int64) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldGT(FieldLastHeartbeatAt, v))
}
// LastHeartbeatAtGTE applies the GTE predicate on the "lastHeartbeatAt" field.
func LastHeartbeatAtGTE(v int64) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldGTE(FieldLastHeartbeatAt, v))
}
// LastHeartbeatAtLT applies the LT predicate on the "lastHeartbeatAt" field.
func LastHeartbeatAtLT(v int64) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldLT(FieldLastHeartbeatAt, v))
}
// LastHeartbeatAtLTE applies the LTE predicate on the "lastHeartbeatAt" field.
func LastHeartbeatAtLTE(v int64) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldLTE(FieldLastHeartbeatAt, v))
}
// UpdatedAtEQ applies the EQ predicate on the "updatedAt" field.
func UpdatedAtEQ(v int64) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldEQ(FieldUpdatedAt, v))
}
// UpdatedAtNEQ applies the NEQ predicate on the "updatedAt" field.
func UpdatedAtNEQ(v int64) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldNEQ(FieldUpdatedAt, v))
}
// UpdatedAtIn applies the In predicate on the "updatedAt" field.
func UpdatedAtIn(vs ...int64) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldIn(FieldUpdatedAt, vs...))
}
// UpdatedAtNotIn applies the NotIn predicate on the "updatedAt" field.
func UpdatedAtNotIn(vs ...int64) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldNotIn(FieldUpdatedAt, vs...))
}
// UpdatedAtGT applies the GT predicate on the "updatedAt" field.
func UpdatedAtGT(v int64) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldGT(FieldUpdatedAt, v))
}
// UpdatedAtGTE applies the GTE predicate on the "updatedAt" field.
func UpdatedAtGTE(v int64) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldGTE(FieldUpdatedAt, v))
}
// UpdatedAtLT applies the LT predicate on the "updatedAt" field.
func UpdatedAtLT(v int64) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldLT(FieldUpdatedAt, v))
}
// UpdatedAtLTE applies the LTE predicate on the "updatedAt" field.
func UpdatedAtLTE(v int64) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.FieldLTE(FieldUpdatedAt, v))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.StationTerminalState) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.StationTerminalState) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.StationTerminalState) predicate.StationTerminalState {
return predicate.StationTerminalState(sql.NotPredicates(p))
}