Files
bj_power/bj_power_mes/ent/lossledger/lossledger.go
T
SunYF 88875c1f13 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 全量更新
2026-11-28 13:44:51 +08:00

155 lines
5.7 KiB
Go

// Code generated by ent, DO NOT EDIT.
package lossledger
import (
"time"
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the lossledger type in the database.
Label = "loss_ledger"
// 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"
// FieldMaterialCode holds the string denoting the materialcode field in the database.
FieldMaterialCode = "material_code"
// FieldMaterialName holds the string denoting the materialname field in the database.
FieldMaterialName = "material_name"
// FieldTheoryQty holds the string denoting the theoryqty field in the database.
FieldTheoryQty = "theory_qty"
// FieldActualQty holds the string denoting the actualqty field in the database.
FieldActualQty = "actual_qty"
// FieldLossQty holds the string denoting the lossqty field in the database.
FieldLossQty = "loss_qty"
// FieldReason holds the string denoting the reason field in the database.
FieldReason = "reason"
// FieldReturnNo holds the string denoting the returnno field in the database.
FieldReturnNo = "return_no"
// FieldWorkOrderNo holds the string denoting the workorderno field in the database.
FieldWorkOrderNo = "work_order_no"
// FieldOperator holds the string denoting the operator field in the database.
FieldOperator = "operator"
// FieldCreatedAt holds the string denoting the createdat field in the database.
FieldCreatedAt = "created_at"
// Table holds the table name of the lossledger in the database.
Table = "loss_ledgers"
)
// Columns holds all SQL columns for lossledger fields.
var Columns = []string{
FieldID,
FieldStationNo,
FieldMaterialCode,
FieldMaterialName,
FieldTheoryQty,
FieldActualQty,
FieldLossQty,
FieldReason,
FieldReturnNo,
FieldWorkOrderNo,
FieldOperator,
FieldCreatedAt,
}
// 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 (
// MaterialCodeValidator is a validator for the "materialCode" field. It is called by the builders before save.
MaterialCodeValidator func(string) error
// DefaultMaterialName holds the default value on creation for the "materialName" field.
DefaultMaterialName string
// MaterialNameValidator is a validator for the "materialName" field. It is called by the builders before save.
MaterialNameValidator func(string) error
// ReasonValidator is a validator for the "reason" field. It is called by the builders before save.
ReasonValidator func(string) error
// DefaultReturnNo holds the default value on creation for the "returnNo" field.
DefaultReturnNo string
// ReturnNoValidator is a validator for the "returnNo" field. It is called by the builders before save.
ReturnNoValidator func(string) error
// DefaultWorkOrderNo holds the default value on creation for the "workOrderNo" field.
DefaultWorkOrderNo string
// WorkOrderNoValidator is a validator for the "workOrderNo" field. It is called by the builders before save.
WorkOrderNoValidator func(string) error
// 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
// DefaultCreatedAt holds the default value on creation for the "createdAt" field.
DefaultCreatedAt func() time.Time
)
// OrderOption defines the ordering options for the LossLedger 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()
}
// ByMaterialCode orders the results by the materialCode field.
func ByMaterialCode(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMaterialCode, opts...).ToFunc()
}
// ByMaterialName orders the results by the materialName field.
func ByMaterialName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMaterialName, opts...).ToFunc()
}
// ByTheoryQty orders the results by the theoryQty field.
func ByTheoryQty(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTheoryQty, opts...).ToFunc()
}
// ByActualQty orders the results by the actualQty field.
func ByActualQty(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldActualQty, opts...).ToFunc()
}
// ByLossQty orders the results by the lossQty field.
func ByLossQty(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLossQty, opts...).ToFunc()
}
// ByReason orders the results by the reason field.
func ByReason(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldReason, opts...).ToFunc()
}
// ByReturnNo orders the results by the returnNo field.
func ByReturnNo(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldReturnNo, opts...).ToFunc()
}
// ByWorkOrderNo orders the results by the workOrderNo field.
func ByWorkOrderNo(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldWorkOrderNo, opts...).ToFunc()
}
// ByOperator orders the results by the operator field.
func ByOperator(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldOperator, opts...).ToFunc()
}
// ByCreatedAt orders the results by the createdAt field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}