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
+25 -21
View File
@@ -695,100 +695,104 @@ func init() {
returnorderDescSn := returnorderFields[6].Descriptor()
// returnorder.DefaultSn holds the default value on creation for the sn field.
returnorder.DefaultSn = returnorderDescSn.Default.(string)
// returnorderDescSnList is the schema descriptor for sn_list field.
returnorderDescSnList := returnorderFields[7].Descriptor()
// returnorder.DefaultSnList holds the default value on creation for the sn_list field.
returnorder.DefaultSnList = returnorderDescSnList.Default.(string)
// returnorderDescQty is the schema descriptor for qty field.
returnorderDescQty := returnorderFields[10].Descriptor()
returnorderDescQty := returnorderFields[11].Descriptor()
// returnorder.DefaultQty holds the default value on creation for the qty field.
returnorder.DefaultQty = returnorderDescQty.Default.(int)
// returnorderDescUnit is the schema descriptor for unit field.
returnorderDescUnit := returnorderFields[11].Descriptor()
returnorderDescUnit := returnorderFields[12].Descriptor()
// returnorder.DefaultUnit holds the default value on creation for the unit field.
returnorder.DefaultUnit = returnorderDescUnit.Default.(string)
// returnorderDescReason is the schema descriptor for reason field.
returnorderDescReason := returnorderFields[12].Descriptor()
returnorderDescReason := returnorderFields[13].Descriptor()
// returnorder.DefaultReason holds the default value on creation for the reason field.
returnorder.DefaultReason = returnorderDescReason.Default.(string)
// returnorderDescLossReason is the schema descriptor for loss_reason field.
returnorderDescLossReason := returnorderFields[13].Descriptor()
returnorderDescLossReason := returnorderFields[14].Descriptor()
// returnorder.DefaultLossReason holds the default value on creation for the loss_reason field.
returnorder.DefaultLossReason = returnorderDescLossReason.Default.(string)
// returnorder.LossReasonValidator is a validator for the "loss_reason" field. It is called by the builders before save.
returnorder.LossReasonValidator = returnorderDescLossReason.Validators[0].(func(string) error)
// returnorderDescStatus is the schema descriptor for status field.
returnorderDescStatus := returnorderFields[14].Descriptor()
returnorderDescStatus := returnorderFields[15].Descriptor()
// returnorder.DefaultStatus holds the default value on creation for the status field.
returnorder.DefaultStatus = returnorderDescStatus.Default.(string)
// returnorderDescTransportMode is the schema descriptor for transport_mode field.
returnorderDescTransportMode := returnorderFields[15].Descriptor()
returnorderDescTransportMode := returnorderFields[16].Descriptor()
// returnorder.DefaultTransportMode holds the default value on creation for the transport_mode field.
returnorder.DefaultTransportMode = returnorderDescTransportMode.Default.(string)
// returnorder.TransportModeValidator is a validator for the "transport_mode" field. It is called by the builders before save.
returnorder.TransportModeValidator = returnorderDescTransportMode.Validators[0].(func(string) error)
// returnorderDescDispatchedAt is the schema descriptor for dispatched_at field.
returnorderDescDispatchedAt := returnorderFields[16].Descriptor()
returnorderDescDispatchedAt := returnorderFields[17].Descriptor()
// returnorder.DefaultDispatchedAt holds the default value on creation for the dispatched_at field.
returnorder.DefaultDispatchedAt = returnorderDescDispatchedAt.Default.(int64)
// returnorderDescCancelledBy is the schema descriptor for cancelled_by field.
returnorderDescCancelledBy := returnorderFields[17].Descriptor()
returnorderDescCancelledBy := returnorderFields[18].Descriptor()
// returnorder.DefaultCancelledBy holds the default value on creation for the cancelled_by field.
returnorder.DefaultCancelledBy = returnorderDescCancelledBy.Default.(string)
// returnorder.CancelledByValidator is a validator for the "cancelled_by" field. It is called by the builders before save.
returnorder.CancelledByValidator = returnorderDescCancelledBy.Validators[0].(func(string) error)
// returnorderDescCancelReason is the schema descriptor for cancel_reason field.
returnorderDescCancelReason := returnorderFields[18].Descriptor()
returnorderDescCancelReason := returnorderFields[19].Descriptor()
// returnorder.DefaultCancelReason holds the default value on creation for the cancel_reason field.
returnorder.DefaultCancelReason = returnorderDescCancelReason.Default.(string)
// returnorder.CancelReasonValidator is a validator for the "cancel_reason" field. It is called by the builders before save.
returnorder.CancelReasonValidator = returnorderDescCancelReason.Validators[0].(func(string) error)
// returnorderDescOperator is the schema descriptor for operator field.
returnorderDescOperator := returnorderFields[19].Descriptor()
returnorderDescOperator := returnorderFields[20].Descriptor()
// returnorder.DefaultOperator holds the default value on creation for the operator field.
returnorder.DefaultOperator = returnorderDescOperator.Default.(string)
// returnorderDescReceiveBy is the schema descriptor for receive_by field.
returnorderDescReceiveBy := returnorderFields[20].Descriptor()
returnorderDescReceiveBy := returnorderFields[21].Descriptor()
// returnorder.DefaultReceiveBy holds the default value on creation for the receive_by field.
returnorder.DefaultReceiveBy = returnorderDescReceiveBy.Default.(string)
// returnorderDescReceiveQty is the schema descriptor for receive_qty field.
returnorderDescReceiveQty := returnorderFields[21].Descriptor()
returnorderDescReceiveQty := returnorderFields[22].Descriptor()
// returnorder.DefaultReceiveQty holds the default value on creation for the receive_qty field.
returnorder.DefaultReceiveQty = returnorderDescReceiveQty.Default.(int)
// returnorderDescReceiveDiff is the schema descriptor for receive_diff field.
returnorderDescReceiveDiff := returnorderFields[22].Descriptor()
returnorderDescReceiveDiff := returnorderFields[23].Descriptor()
// returnorder.DefaultReceiveDiff holds the default value on creation for the receive_diff field.
returnorder.DefaultReceiveDiff = returnorderDescReceiveDiff.Default.(int)
// returnorderDescReceiveNote is the schema descriptor for receive_note field.
returnorderDescReceiveNote := returnorderFields[23].Descriptor()
returnorderDescReceiveNote := returnorderFields[24].Descriptor()
// returnorder.DefaultReceiveNote holds the default value on creation for the receive_note field.
returnorder.DefaultReceiveNote = returnorderDescReceiveNote.Default.(string)
// returnorderDescAdjustQty is the schema descriptor for adjust_qty field.
returnorderDescAdjustQty := returnorderFields[24].Descriptor()
returnorderDescAdjustQty := returnorderFields[25].Descriptor()
// returnorder.DefaultAdjustQty holds the default value on creation for the adjust_qty field.
returnorder.DefaultAdjustQty = returnorderDescAdjustQty.Default.(int)
// returnorderDescAdjustBeforeQty is the schema descriptor for adjust_before_qty field.
returnorderDescAdjustBeforeQty := returnorderFields[25].Descriptor()
returnorderDescAdjustBeforeQty := returnorderFields[26].Descriptor()
// returnorder.DefaultAdjustBeforeQty holds the default value on creation for the adjust_before_qty field.
returnorder.DefaultAdjustBeforeQty = returnorderDescAdjustBeforeQty.Default.(int)
// returnorderDescAdjustedBy is the schema descriptor for adjusted_by field.
returnorderDescAdjustedBy := returnorderFields[26].Descriptor()
returnorderDescAdjustedBy := returnorderFields[27].Descriptor()
// returnorder.DefaultAdjustedBy holds the default value on creation for the adjusted_by field.
returnorder.DefaultAdjustedBy = returnorderDescAdjustedBy.Default.(string)
// returnorder.AdjustedByValidator is a validator for the "adjusted_by" field. It is called by the builders before save.
returnorder.AdjustedByValidator = returnorderDescAdjustedBy.Validators[0].(func(string) error)
// returnorderDescAdjustReason is the schema descriptor for adjust_reason field.
returnorderDescAdjustReason := returnorderFields[27].Descriptor()
returnorderDescAdjustReason := returnorderFields[28].Descriptor()
// returnorder.DefaultAdjustReason holds the default value on creation for the adjust_reason field.
returnorder.DefaultAdjustReason = returnorderDescAdjustReason.Default.(string)
// returnorder.AdjustReasonValidator is a validator for the "adjust_reason" field. It is called by the builders before save.
returnorder.AdjustReasonValidator = returnorderDescAdjustReason.Validators[0].(func(string) error)
// returnorderDescAdjustedAt is the schema descriptor for adjusted_at field.
returnorderDescAdjustedAt := returnorderFields[28].Descriptor()
returnorderDescAdjustedAt := returnorderFields[29].Descriptor()
// returnorder.DefaultAdjustedAt holds the default value on creation for the adjusted_at field.
returnorder.DefaultAdjustedAt = returnorderDescAdjustedAt.Default.(int64)
// returnorderDescCreatedAt is the schema descriptor for created_at field.
returnorderDescCreatedAt := returnorderFields[29].Descriptor()
returnorderDescCreatedAt := returnorderFields[30].Descriptor()
// returnorder.DefaultCreatedAt holds the default value on creation for the created_at field.
returnorder.DefaultCreatedAt = returnorderDescCreatedAt.Default.(func() int64)
// returnorderDescReceiveAt is the schema descriptor for receive_at field.
returnorderDescReceiveAt := returnorderFields[30].Descriptor()
returnorderDescReceiveAt := returnorderFields[31].Descriptor()
// returnorder.DefaultReceiveAt holds the default value on creation for the receive_at field.
returnorder.DefaultReceiveAt = returnorderDescReceiveAt.Default.(int64)
roleFields := schema.Role{}.Fields()