重构排产/叫料配送/时钟/终端事件驱动,清理 SHIPPED 废弃状态

时钟与 JWT:验签按「谁签发谁的时间为准」,向签发方取 /api/server-time,
对端地址由既有 BaseURL 自动推导;不再要求现场人工 w32tm 对时。

排产 C 方案:工单状态不再回写排产,排产只表示启用开关;启用排产是唯一
开工开关,未启用不允许建档上件;完工/取消后工单进度从工单派生、叫料池
按工单状态重算;逐日手改后合计为准;日期筛选默认空=全部日期。

叫料配送 B 方案:新增 DELIVERED 待签收态,货真到工位才从 PREPARED 转
DELIVERED、工人签收再转 DONE;PREPARED 在途不可签收/退库;叫料队列一屏
显示 PENDING+PREPARED、支持批量完成备料;配送链改按工位凑车,一张配送单
=一个托盘=一个工位,只在配送单页新建,未派车可删可改;新建弹窗直列有货
工位;派车硬门禁要求接驳台传感器检测到托盘;删除改为事务内复核状态、
带 PENDING 条件删单头,防止并发派车时误删。

装配记账:新增已装量 installedQty 与追溯绑定 traceBind,落实「总账=分账
之和」;追溯件绑定/撤销回补、非序列号件报工按单台用量自动扣已装;报工前
按工位×物料核对累计已签收 ≥ 已消耗,不够拦下。

工件与工位终端:建档/重上线增加上料位可达性校验与 PLC 送件、半截补齐防
重复扣库;终端去轮询改事件驱动(报警/工件到位/点位/停单即时推送),铃铛
只挂消息类预警、与待办角标分家;刷新保留拧紧录入;跨服务连线失败不再
误报成数据库故障;新增 BJ_POWER_DEV=1 单进程调试模式(不起守护/托盘)。

告警:新增处置字段 resolved_at/resolved_by,红点=待处置数,确认关闭才消。

清理:删除 migrate 中 SHIPPED→DELIVERED 兼容补丁;场景1测试断言改为
现行 PREPARED / DELIVERED;同步更新案例.md、现场对时操作卡.md 与 ent 生成代码。
This commit is contained in:
SunYF
2026-11-26 17:18:58 +08:00
parent 20e061c969
commit 6b98b21dd4
141 changed files with 16312 additions and 1964 deletions
+12 -1
View File
@@ -35,6 +35,8 @@ type CallPool struct {
SentQty int `json:"sentQty,omitempty"`
// 占用中(待备料叫料单请求量合计)
ReservedQty int `json:"reservedQty,omitempty"`
// 已装量(装配消耗:追溯件绑定扣/撤销回补,非序列号件报工自动扣)
InstalledQty int `json:"installedQty,omitempty"`
// 是否含非今日排产(跨日叫料预警/仓库驳回异常标记)
CrossDay bool `json:"crossDay,omitempty"`
// 派生快照:贡献需求的排产日期(逗号分隔,可空)
@@ -53,7 +55,7 @@ func (*CallPool) scanValues(columns []string) ([]any, error) {
switch columns[i] {
case callpool.FieldCrossDay:
values[i] = new(sql.NullBool)
case callpool.FieldID, callpool.FieldStationNo, callpool.FieldSnMode, callpool.FieldReqQty, callpool.FieldAdjQty, callpool.FieldSentQty, callpool.FieldReservedQty:
case callpool.FieldID, callpool.FieldStationNo, callpool.FieldSnMode, callpool.FieldReqQty, callpool.FieldAdjQty, callpool.FieldSentQty, callpool.FieldReservedQty, callpool.FieldInstalledQty:
values[i] = new(sql.NullInt64)
case callpool.FieldMaterialCode, callpool.FieldMaterialName, callpool.FieldUnit, callpool.FieldPlanDates:
values[i] = new(sql.NullString)
@@ -134,6 +136,12 @@ func (_m *CallPool) assignValues(columns []string, values []any) error {
} else if value.Valid {
_m.ReservedQty = int(value.Int64)
}
case callpool.FieldInstalledQty:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field installedQty", values[i])
} else if value.Valid {
_m.InstalledQty = int(value.Int64)
}
case callpool.FieldCrossDay:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field crossDay", values[i])
@@ -221,6 +229,9 @@ func (_m *CallPool) String() string {
builder.WriteString("reservedQty=")
builder.WriteString(fmt.Sprintf("%v", _m.ReservedQty))
builder.WriteString(", ")
builder.WriteString("installedQty=")
builder.WriteString(fmt.Sprintf("%v", _m.InstalledQty))
builder.WriteString(", ")
builder.WriteString("crossDay=")
builder.WriteString(fmt.Sprintf("%v", _m.CrossDay))
builder.WriteString(", ")
+10
View File
@@ -31,6 +31,8 @@ const (
FieldSentQty = "sent_qty"
// FieldReservedQty holds the string denoting the reservedqty field in the database.
FieldReservedQty = "reserved_qty"
// FieldInstalledQty holds the string denoting the installedqty field in the database.
FieldInstalledQty = "installed_qty"
// FieldCrossDay holds the string denoting the crossday field in the database.
FieldCrossDay = "cross_day"
// FieldPlanDates holds the string denoting the plandates field in the database.
@@ -55,6 +57,7 @@ var Columns = []string{
FieldAdjQty,
FieldSentQty,
FieldReservedQty,
FieldInstalledQty,
FieldCrossDay,
FieldPlanDates,
FieldCreatedAt,
@@ -92,6 +95,8 @@ var (
DefaultSentQty int
// DefaultReservedQty holds the default value on creation for the "reservedQty" field.
DefaultReservedQty int
// DefaultInstalledQty holds the default value on creation for the "installedQty" field.
DefaultInstalledQty int
// DefaultCrossDay holds the default value on creation for the "crossDay" field.
DefaultCrossDay bool
// DefaultPlanDates holds the default value on creation for the "planDates" field.
@@ -161,6 +166,11 @@ func ByReservedQty(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldReservedQty, opts...).ToFunc()
}
// ByInstalledQty orders the results by the installedQty field.
func ByInstalledQty(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldInstalledQty, opts...).ToFunc()
}
// ByCrossDay orders the results by the crossDay field.
func ByCrossDay(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCrossDay, opts...).ToFunc()
+45
View File
@@ -99,6 +99,11 @@ func ReservedQty(v int) predicate.CallPool {
return predicate.CallPool(sql.FieldEQ(FieldReservedQty, v))
}
// InstalledQty applies equality check predicate on the "installedQty" field. It's identical to InstalledQtyEQ.
func InstalledQty(v int) predicate.CallPool {
return predicate.CallPool(sql.FieldEQ(FieldInstalledQty, v))
}
// CrossDay applies equality check predicate on the "crossDay" field. It's identical to CrossDayEQ.
func CrossDay(v bool) predicate.CallPool {
return predicate.CallPool(sql.FieldEQ(FieldCrossDay, v))
@@ -554,6 +559,46 @@ func ReservedQtyLTE(v int) predicate.CallPool {
return predicate.CallPool(sql.FieldLTE(FieldReservedQty, v))
}
// InstalledQtyEQ applies the EQ predicate on the "installedQty" field.
func InstalledQtyEQ(v int) predicate.CallPool {
return predicate.CallPool(sql.FieldEQ(FieldInstalledQty, v))
}
// InstalledQtyNEQ applies the NEQ predicate on the "installedQty" field.
func InstalledQtyNEQ(v int) predicate.CallPool {
return predicate.CallPool(sql.FieldNEQ(FieldInstalledQty, v))
}
// InstalledQtyIn applies the In predicate on the "installedQty" field.
func InstalledQtyIn(vs ...int) predicate.CallPool {
return predicate.CallPool(sql.FieldIn(FieldInstalledQty, vs...))
}
// InstalledQtyNotIn applies the NotIn predicate on the "installedQty" field.
func InstalledQtyNotIn(vs ...int) predicate.CallPool {
return predicate.CallPool(sql.FieldNotIn(FieldInstalledQty, vs...))
}
// InstalledQtyGT applies the GT predicate on the "installedQty" field.
func InstalledQtyGT(v int) predicate.CallPool {
return predicate.CallPool(sql.FieldGT(FieldInstalledQty, v))
}
// InstalledQtyGTE applies the GTE predicate on the "installedQty" field.
func InstalledQtyGTE(v int) predicate.CallPool {
return predicate.CallPool(sql.FieldGTE(FieldInstalledQty, v))
}
// InstalledQtyLT applies the LT predicate on the "installedQty" field.
func InstalledQtyLT(v int) predicate.CallPool {
return predicate.CallPool(sql.FieldLT(FieldInstalledQty, v))
}
// InstalledQtyLTE applies the LTE predicate on the "installedQty" field.
func InstalledQtyLTE(v int) predicate.CallPool {
return predicate.CallPool(sql.FieldLTE(FieldInstalledQty, v))
}
// CrossDayEQ applies the EQ predicate on the "crossDay" field.
func CrossDayEQ(v bool) predicate.CallPool {
return predicate.CallPool(sql.FieldEQ(FieldCrossDay, v))
+25
View File
@@ -130,6 +130,20 @@ func (_c *CallPoolCreate) SetNillableReservedQty(v *int) *CallPoolCreate {
return _c
}
// SetInstalledQty sets the "installedQty" field.
func (_c *CallPoolCreate) SetInstalledQty(v int) *CallPoolCreate {
_c.mutation.SetInstalledQty(v)
return _c
}
// SetNillableInstalledQty sets the "installedQty" field if the given value is not nil.
func (_c *CallPoolCreate) SetNillableInstalledQty(v *int) *CallPoolCreate {
if v != nil {
_c.SetInstalledQty(*v)
}
return _c
}
// SetCrossDay sets the "crossDay" field.
func (_c *CallPoolCreate) SetCrossDay(v bool) *CallPoolCreate {
_c.mutation.SetCrossDay(v)
@@ -255,6 +269,10 @@ func (_c *CallPoolCreate) defaults() {
v := callpool.DefaultReservedQty
_c.mutation.SetReservedQty(v)
}
if _, ok := _c.mutation.InstalledQty(); !ok {
v := callpool.DefaultInstalledQty
_c.mutation.SetInstalledQty(v)
}
if _, ok := _c.mutation.CrossDay(); !ok {
v := callpool.DefaultCrossDay
_c.mutation.SetCrossDay(v)
@@ -317,6 +335,9 @@ func (_c *CallPoolCreate) check() error {
if _, ok := _c.mutation.ReservedQty(); !ok {
return &ValidationError{Name: "reservedQty", err: errors.New(`ent: missing required field "CallPool.reservedQty"`)}
}
if _, ok := _c.mutation.InstalledQty(); !ok {
return &ValidationError{Name: "installedQty", err: errors.New(`ent: missing required field "CallPool.installedQty"`)}
}
if _, ok := _c.mutation.CrossDay(); !ok {
return &ValidationError{Name: "crossDay", err: errors.New(`ent: missing required field "CallPool.crossDay"`)}
}
@@ -407,6 +428,10 @@ func (_c *CallPoolCreate) createSpec() (*CallPool, *sqlgraph.CreateSpec) {
_spec.SetField(callpool.FieldReservedQty, field.TypeInt, value)
_node.ReservedQty = value
}
if value, ok := _c.mutation.InstalledQty(); ok {
_spec.SetField(callpool.FieldInstalledQty, field.TypeInt, value)
_node.InstalledQty = value
}
if value, ok := _c.mutation.CrossDay(); ok {
_spec.SetField(callpool.FieldCrossDay, field.TypeBool, value)
_node.CrossDay = value
+54
View File
@@ -197,6 +197,27 @@ func (_u *CallPoolUpdate) AddReservedQty(v int) *CallPoolUpdate {
return _u
}
// SetInstalledQty sets the "installedQty" field.
func (_u *CallPoolUpdate) SetInstalledQty(v int) *CallPoolUpdate {
_u.mutation.ResetInstalledQty()
_u.mutation.SetInstalledQty(v)
return _u
}
// SetNillableInstalledQty sets the "installedQty" field if the given value is not nil.
func (_u *CallPoolUpdate) SetNillableInstalledQty(v *int) *CallPoolUpdate {
if v != nil {
_u.SetInstalledQty(*v)
}
return _u
}
// AddInstalledQty adds value to the "installedQty" field.
func (_u *CallPoolUpdate) AddInstalledQty(v int) *CallPoolUpdate {
_u.mutation.AddInstalledQty(v)
return _u
}
// SetCrossDay sets the "crossDay" field.
func (_u *CallPoolUpdate) SetCrossDay(v bool) *CallPoolUpdate {
_u.mutation.SetCrossDay(v)
@@ -360,6 +381,12 @@ func (_u *CallPoolUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if value, ok := _u.mutation.AddedReservedQty(); ok {
_spec.AddField(callpool.FieldReservedQty, field.TypeInt, value)
}
if value, ok := _u.mutation.InstalledQty(); ok {
_spec.SetField(callpool.FieldInstalledQty, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedInstalledQty(); ok {
_spec.AddField(callpool.FieldInstalledQty, field.TypeInt, value)
}
if value, ok := _u.mutation.CrossDay(); ok {
_spec.SetField(callpool.FieldCrossDay, field.TypeBool, value)
}
@@ -559,6 +586,27 @@ func (_u *CallPoolUpdateOne) AddReservedQty(v int) *CallPoolUpdateOne {
return _u
}
// SetInstalledQty sets the "installedQty" field.
func (_u *CallPoolUpdateOne) SetInstalledQty(v int) *CallPoolUpdateOne {
_u.mutation.ResetInstalledQty()
_u.mutation.SetInstalledQty(v)
return _u
}
// SetNillableInstalledQty sets the "installedQty" field if the given value is not nil.
func (_u *CallPoolUpdateOne) SetNillableInstalledQty(v *int) *CallPoolUpdateOne {
if v != nil {
_u.SetInstalledQty(*v)
}
return _u
}
// AddInstalledQty adds value to the "installedQty" field.
func (_u *CallPoolUpdateOne) AddInstalledQty(v int) *CallPoolUpdateOne {
_u.mutation.AddInstalledQty(v)
return _u
}
// SetCrossDay sets the "crossDay" field.
func (_u *CallPoolUpdateOne) SetCrossDay(v bool) *CallPoolUpdateOne {
_u.mutation.SetCrossDay(v)
@@ -752,6 +800,12 @@ func (_u *CallPoolUpdateOne) sqlSave(ctx context.Context) (_node *CallPool, err
if value, ok := _u.mutation.AddedReservedQty(); ok {
_spec.AddField(callpool.FieldReservedQty, field.TypeInt, value)
}
if value, ok := _u.mutation.InstalledQty(); ok {
_spec.SetField(callpool.FieldInstalledQty, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedInstalledQty(); ok {
_spec.AddField(callpool.FieldInstalledQty, field.TypeInt, value)
}
if value, ok := _u.mutation.CrossDay(); ok {
_spec.SetField(callpool.FieldCrossDay, field.TypeBool, value)
}
+3 -1
View File
@@ -319,6 +319,7 @@ var (
{Name: "adj_qty", Type: field.TypeInt, Comment: "人工调整量(可正可负;改动留痕 event_log)", Default: 0},
{Name: "sent_qty", Type: field.TypeInt, Comment: "已发净额(完成备料实发累加;退库收回扣减回补)", Default: 0},
{Name: "reserved_qty", Type: field.TypeInt, Comment: "占用中(待备料叫料单请求量合计)", Default: 0},
{Name: "installed_qty", Type: field.TypeInt, Comment: "已装量(装配消耗:追溯件绑定扣/撤销回补,非序列号件报工自动扣)", Default: 0},
{Name: "cross_day", Type: field.TypeBool, Comment: "是否含非今日排产(跨日叫料预警/仓库驳回异常标记)", Default: false},
{Name: "plan_dates", Type: field.TypeString, Size: 255, Comment: "派生快照:贡献需求的排产日期(逗号分隔,可空)", Default: ""},
{Name: "created_at", Type: field.TypeTime},
@@ -874,6 +875,7 @@ var (
{Name: "unit", Type: field.TypeString, Size: 16, Default: ""},
{Name: "unit_qty", Type: field.TypeFloat64, Comment: "单台用量(总账量,必须等于各工序分账量之和)", Default: 0},
{Name: "loss_rate", Type: field.TypeFloat64, Comment: "损耗率%(展示口径,不参与备料计算)", Default: 0},
{Name: "trace_bind", Type: field.TypeBool, Comment: "追溯绑定:true=装配时需绑定到工件(可追溯,新建默认)/false=不绑定不校验", Default: true},
{Name: "remark", Type: field.TypeString, Size: 255, Default: ""},
{Name: "created_at", Type: field.TypeTime},
}
@@ -899,7 +901,7 @@ var (
// ProductProcessColumns holds the columns for the "product_process" table.
ProductProcessColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "product_code", Type: field.TypeString, Size: 64, Comment: "产品编码(WMS 物料档案 item_type=3 产品编号)"},
{Name: "product_code", Type: field.TypeString, Size: 64, Comment: "产品编码(WMS 物料档案 item_type=3 图号)"},
{Name: "product_name", Type: field.TypeString, Size: 128, Comment: "产品名称(快照,WMS 改名不回写)", Default: ""},
{Name: "name", Type: field.TypeString, Size: 128, Comment: "产品工艺名称,如 DX100常规"},
{Name: "status", Type: field.TypeString, Size: 20, Default: "INACTIVE"},
+169 -28
View File
@@ -8273,32 +8273,34 @@ func (m *BackupRecordMutation) ResetEdge(name string) error {
// CallPoolMutation represents an operation that mutates the CallPool nodes in the graph.
type CallPoolMutation struct {
config
op Op
typ string
id *int
stationNo *int
addstationNo *int
materialCode *string
materialName *string
unit *string
snMode *int
addsnMode *int
reqQty *int
addreqQty *int
adjQty *int
addadjQty *int
sentQty *int
addsentQty *int
reservedQty *int
addreservedQty *int
crossDay *bool
planDates *string
createdAt *time.Time
updatedAt *time.Time
clearedFields map[string]struct{}
done bool
oldValue func(context.Context) (*CallPool, error)
predicates []predicate.CallPool
op Op
typ string
id *int
stationNo *int
addstationNo *int
materialCode *string
materialName *string
unit *string
snMode *int
addsnMode *int
reqQty *int
addreqQty *int
adjQty *int
addadjQty *int
sentQty *int
addsentQty *int
reservedQty *int
addreservedQty *int
installedQty *int
addinstalledQty *int
crossDay *bool
planDates *string
createdAt *time.Time
updatedAt *time.Time
clearedFields map[string]struct{}
done bool
oldValue func(context.Context) (*CallPool, error)
predicates []predicate.CallPool
}
var _ ent.Mutation = (*CallPoolMutation)(nil)
@@ -8849,6 +8851,62 @@ func (m *CallPoolMutation) ResetReservedQty() {
m.addreservedQty = nil
}
// SetInstalledQty sets the "installedQty" field.
func (m *CallPoolMutation) SetInstalledQty(i int) {
m.installedQty = &i
m.addinstalledQty = nil
}
// InstalledQty returns the value of the "installedQty" field in the mutation.
func (m *CallPoolMutation) InstalledQty() (r int, exists bool) {
v := m.installedQty
if v == nil {
return
}
return *v, true
}
// OldInstalledQty returns the old "installedQty" field's value of the CallPool entity.
// If the CallPool object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CallPoolMutation) OldInstalledQty(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldInstalledQty is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldInstalledQty requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldInstalledQty: %w", err)
}
return oldValue.InstalledQty, nil
}
// AddInstalledQty adds i to the "installedQty" field.
func (m *CallPoolMutation) AddInstalledQty(i int) {
if m.addinstalledQty != nil {
*m.addinstalledQty += i
} else {
m.addinstalledQty = &i
}
}
// AddedInstalledQty returns the value that was added to the "installedQty" field in this mutation.
func (m *CallPoolMutation) AddedInstalledQty() (r int, exists bool) {
v := m.addinstalledQty
if v == nil {
return
}
return *v, true
}
// ResetInstalledQty resets all changes to the "installedQty" field.
func (m *CallPoolMutation) ResetInstalledQty() {
m.installedQty = nil
m.addinstalledQty = nil
}
// SetCrossDay sets the "crossDay" field.
func (m *CallPoolMutation) SetCrossDay(b bool) {
m.crossDay = &b
@@ -9027,7 +9085,7 @@ func (m *CallPoolMutation) Type() string {
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *CallPoolMutation) Fields() []string {
fields := make([]string, 0, 13)
fields := make([]string, 0, 14)
if m.stationNo != nil {
fields = append(fields, callpool.FieldStationNo)
}
@@ -9055,6 +9113,9 @@ func (m *CallPoolMutation) Fields() []string {
if m.reservedQty != nil {
fields = append(fields, callpool.FieldReservedQty)
}
if m.installedQty != nil {
fields = append(fields, callpool.FieldInstalledQty)
}
if m.crossDay != nil {
fields = append(fields, callpool.FieldCrossDay)
}
@@ -9093,6 +9154,8 @@ func (m *CallPoolMutation) Field(name string) (ent.Value, bool) {
return m.SentQty()
case callpool.FieldReservedQty:
return m.ReservedQty()
case callpool.FieldInstalledQty:
return m.InstalledQty()
case callpool.FieldCrossDay:
return m.CrossDay()
case callpool.FieldPlanDates:
@@ -9128,6 +9191,8 @@ func (m *CallPoolMutation) OldField(ctx context.Context, name string) (ent.Value
return m.OldSentQty(ctx)
case callpool.FieldReservedQty:
return m.OldReservedQty(ctx)
case callpool.FieldInstalledQty:
return m.OldInstalledQty(ctx)
case callpool.FieldCrossDay:
return m.OldCrossDay(ctx)
case callpool.FieldPlanDates:
@@ -9208,6 +9273,13 @@ func (m *CallPoolMutation) SetField(name string, value ent.Value) error {
}
m.SetReservedQty(v)
return nil
case callpool.FieldInstalledQty:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetInstalledQty(v)
return nil
case callpool.FieldCrossDay:
v, ok := value.(bool)
if !ok {
@@ -9262,6 +9334,9 @@ func (m *CallPoolMutation) AddedFields() []string {
if m.addreservedQty != nil {
fields = append(fields, callpool.FieldReservedQty)
}
if m.addinstalledQty != nil {
fields = append(fields, callpool.FieldInstalledQty)
}
return fields
}
@@ -9282,6 +9357,8 @@ func (m *CallPoolMutation) AddedField(name string) (ent.Value, bool) {
return m.AddedSentQty()
case callpool.FieldReservedQty:
return m.AddedReservedQty()
case callpool.FieldInstalledQty:
return m.AddedInstalledQty()
}
return nil, false
}
@@ -9333,6 +9410,13 @@ func (m *CallPoolMutation) AddField(name string, value ent.Value) error {
}
m.AddReservedQty(v)
return nil
case callpool.FieldInstalledQty:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddInstalledQty(v)
return nil
}
return fmt.Errorf("unknown CallPool numeric field %s", name)
}
@@ -9387,6 +9471,9 @@ func (m *CallPoolMutation) ResetField(name string) error {
case callpool.FieldReservedQty:
m.ResetReservedQty()
return nil
case callpool.FieldInstalledQty:
m.ResetInstalledQty()
return nil
case callpool.FieldCrossDay:
m.ResetCrossDay()
return nil
@@ -24647,6 +24734,7 @@ type ProductBOMMutation struct {
addunitQty *float64
lossRate *float64
addlossRate *float64
traceBind *bool
remark *string
createdAt *time.Time
clearedFields map[string]struct{}
@@ -25051,6 +25139,42 @@ func (m *ProductBOMMutation) ResetLossRate() {
m.addlossRate = nil
}
// SetTraceBind sets the "traceBind" field.
func (m *ProductBOMMutation) SetTraceBind(b bool) {
m.traceBind = &b
}
// TraceBind returns the value of the "traceBind" field in the mutation.
func (m *ProductBOMMutation) TraceBind() (r bool, exists bool) {
v := m.traceBind
if v == nil {
return
}
return *v, true
}
// OldTraceBind returns the old "traceBind" field's value of the ProductBOM entity.
// If the ProductBOM object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *ProductBOMMutation) OldTraceBind(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTraceBind is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTraceBind requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTraceBind: %w", err)
}
return oldValue.TraceBind, nil
}
// ResetTraceBind resets all changes to the "traceBind" field.
func (m *ProductBOMMutation) ResetTraceBind() {
m.traceBind = nil
}
// SetRemark sets the "remark" field.
func (m *ProductBOMMutation) SetRemark(s string) {
m.remark = &s
@@ -25157,7 +25281,7 @@ func (m *ProductBOMMutation) Type() string {
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *ProductBOMMutation) Fields() []string {
fields := make([]string, 0, 9)
fields := make([]string, 0, 10)
if m.productCode != nil {
fields = append(fields, productbom.FieldProductCode)
}
@@ -25179,6 +25303,9 @@ func (m *ProductBOMMutation) Fields() []string {
if m.lossRate != nil {
fields = append(fields, productbom.FieldLossRate)
}
if m.traceBind != nil {
fields = append(fields, productbom.FieldTraceBind)
}
if m.remark != nil {
fields = append(fields, productbom.FieldRemark)
}
@@ -25207,6 +25334,8 @@ func (m *ProductBOMMutation) Field(name string) (ent.Value, bool) {
return m.UnitQty()
case productbom.FieldLossRate:
return m.LossRate()
case productbom.FieldTraceBind:
return m.TraceBind()
case productbom.FieldRemark:
return m.Remark()
case productbom.FieldCreatedAt:
@@ -25234,6 +25363,8 @@ func (m *ProductBOMMutation) OldField(ctx context.Context, name string) (ent.Val
return m.OldUnitQty(ctx)
case productbom.FieldLossRate:
return m.OldLossRate(ctx)
case productbom.FieldTraceBind:
return m.OldTraceBind(ctx)
case productbom.FieldRemark:
return m.OldRemark(ctx)
case productbom.FieldCreatedAt:
@@ -25296,6 +25427,13 @@ func (m *ProductBOMMutation) SetField(name string, value ent.Value) error {
}
m.SetLossRate(v)
return nil
case productbom.FieldTraceBind:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTraceBind(v)
return nil
case productbom.FieldRemark:
v, ok := value.(string)
if !ok {
@@ -25407,6 +25545,9 @@ func (m *ProductBOMMutation) ResetField(name string) error {
case productbom.FieldLossRate:
m.ResetLossRate()
return nil
case productbom.FieldTraceBind:
m.ResetTraceBind()
return nil
case productbom.FieldRemark:
m.ResetRemark()
return nil
+13
View File
@@ -31,6 +31,8 @@ type ProductBOM struct {
UnitQty float64 `json:"unitQty,omitempty"`
// 损耗率%(展示口径,不参与备料计算)
LossRate float64 `json:"lossRate,omitempty"`
// 追溯绑定:true=装配时需绑定到工件(可追溯,新建默认)/false=不绑定不校验
TraceBind bool `json:"traceBind,omitempty"`
// Remark holds the value of the "remark" field.
Remark string `json:"remark,omitempty"`
// CreatedAt holds the value of the "createdAt" field.
@@ -43,6 +45,8 @@ func (*ProductBOM) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case productbom.FieldTraceBind:
values[i] = new(sql.NullBool)
case productbom.FieldUnitQty, productbom.FieldLossRate:
values[i] = new(sql.NullFloat64)
case productbom.FieldID:
@@ -114,6 +118,12 @@ func (_m *ProductBOM) assignValues(columns []string, values []any) error {
} else if value.Valid {
_m.LossRate = value.Float64
}
case productbom.FieldTraceBind:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field traceBind", values[i])
} else if value.Valid {
_m.TraceBind = value.Bool
}
case productbom.FieldRemark:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field remark", values[i])
@@ -183,6 +193,9 @@ func (_m *ProductBOM) String() string {
builder.WriteString("lossRate=")
builder.WriteString(fmt.Sprintf("%v", _m.LossRate))
builder.WriteString(", ")
builder.WriteString("traceBind=")
builder.WriteString(fmt.Sprintf("%v", _m.TraceBind))
builder.WriteString(", ")
builder.WriteString("remark=")
builder.WriteString(_m.Remark)
builder.WriteString(", ")
+10
View File
@@ -27,6 +27,8 @@ const (
FieldUnitQty = "unit_qty"
// FieldLossRate holds the string denoting the lossrate field in the database.
FieldLossRate = "loss_rate"
// FieldTraceBind holds the string denoting the tracebind field in the database.
FieldTraceBind = "trace_bind"
// FieldRemark holds the string denoting the remark field in the database.
FieldRemark = "remark"
// FieldCreatedAt holds the string denoting the createdat field in the database.
@@ -45,6 +47,7 @@ var Columns = []string{
FieldUnit,
FieldUnitQty,
FieldLossRate,
FieldTraceBind,
FieldRemark,
FieldCreatedAt,
}
@@ -80,6 +83,8 @@ var (
DefaultUnitQty float64
// DefaultLossRate holds the default value on creation for the "lossRate" field.
DefaultLossRate float64
// DefaultTraceBind holds the default value on creation for the "traceBind" field.
DefaultTraceBind bool
// DefaultRemark holds the default value on creation for the "remark" field.
DefaultRemark string
// RemarkValidator is a validator for the "remark" field. It is called by the builders before save.
@@ -133,6 +138,11 @@ func ByLossRate(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLossRate, opts...).ToFunc()
}
// ByTraceBind orders the results by the traceBind field.
func ByTraceBind(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTraceBind, opts...).ToFunc()
}
// ByRemark orders the results by the remark field.
func ByRemark(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRemark, opts...).ToFunc()
+15
View File
@@ -89,6 +89,11 @@ func LossRate(v float64) predicate.ProductBOM {
return predicate.ProductBOM(sql.FieldEQ(FieldLossRate, v))
}
// TraceBind applies equality check predicate on the "traceBind" field. It's identical to TraceBindEQ.
func TraceBind(v bool) predicate.ProductBOM {
return predicate.ProductBOM(sql.FieldEQ(FieldTraceBind, v))
}
// Remark applies equality check predicate on the "remark" field. It's identical to RemarkEQ.
func Remark(v string) predicate.ProductBOM {
return predicate.ProductBOM(sql.FieldEQ(FieldRemark, v))
@@ -504,6 +509,16 @@ func LossRateLTE(v float64) predicate.ProductBOM {
return predicate.ProductBOM(sql.FieldLTE(FieldLossRate, v))
}
// TraceBindEQ applies the EQ predicate on the "traceBind" field.
func TraceBindEQ(v bool) predicate.ProductBOM {
return predicate.ProductBOM(sql.FieldEQ(FieldTraceBind, v))
}
// TraceBindNEQ applies the NEQ predicate on the "traceBind" field.
func TraceBindNEQ(v bool) predicate.ProductBOM {
return predicate.ProductBOM(sql.FieldNEQ(FieldTraceBind, v))
}
// RemarkEQ applies the EQ predicate on the "remark" field.
func RemarkEQ(v string) predicate.ProductBOM {
return predicate.ProductBOM(sql.FieldEQ(FieldRemark, v))
+25
View File
@@ -102,6 +102,20 @@ func (_c *ProductBOMCreate) SetNillableLossRate(v *float64) *ProductBOMCreate {
return _c
}
// SetTraceBind sets the "traceBind" field.
func (_c *ProductBOMCreate) SetTraceBind(v bool) *ProductBOMCreate {
_c.mutation.SetTraceBind(v)
return _c
}
// SetNillableTraceBind sets the "traceBind" field if the given value is not nil.
func (_c *ProductBOMCreate) SetNillableTraceBind(v *bool) *ProductBOMCreate {
if v != nil {
_c.SetTraceBind(*v)
}
return _c
}
// SetRemark sets the "remark" field.
func (_c *ProductBOMCreate) SetRemark(v string) *ProductBOMCreate {
_c.mutation.SetRemark(v)
@@ -191,6 +205,10 @@ func (_c *ProductBOMCreate) defaults() {
v := productbom.DefaultLossRate
_c.mutation.SetLossRate(v)
}
if _, ok := _c.mutation.TraceBind(); !ok {
v := productbom.DefaultTraceBind
_c.mutation.SetTraceBind(v)
}
if _, ok := _c.mutation.Remark(); !ok {
v := productbom.DefaultRemark
_c.mutation.SetRemark(v)
@@ -249,6 +267,9 @@ func (_c *ProductBOMCreate) check() error {
if _, ok := _c.mutation.LossRate(); !ok {
return &ValidationError{Name: "lossRate", err: errors.New(`ent: missing required field "ProductBOM.lossRate"`)}
}
if _, ok := _c.mutation.TraceBind(); !ok {
return &ValidationError{Name: "traceBind", err: errors.New(`ent: missing required field "ProductBOM.traceBind"`)}
}
if _, ok := _c.mutation.Remark(); !ok {
return &ValidationError{Name: "remark", err: errors.New(`ent: missing required field "ProductBOM.remark"`)}
}
@@ -325,6 +346,10 @@ func (_c *ProductBOMCreate) createSpec() (*ProductBOM, *sqlgraph.CreateSpec) {
_spec.SetField(productbom.FieldLossRate, field.TypeFloat64, value)
_node.LossRate = value
}
if value, ok := _c.mutation.TraceBind(); ok {
_spec.SetField(productbom.FieldTraceBind, field.TypeBool, value)
_node.TraceBind = value
}
if value, ok := _c.mutation.Remark(); ok {
_spec.SetField(productbom.FieldRemark, field.TypeString, value)
_node.Remark = value
+34
View File
@@ -140,6 +140,20 @@ func (_u *ProductBOMUpdate) AddLossRate(v float64) *ProductBOMUpdate {
return _u
}
// SetTraceBind sets the "traceBind" field.
func (_u *ProductBOMUpdate) SetTraceBind(v bool) *ProductBOMUpdate {
_u.mutation.SetTraceBind(v)
return _u
}
// SetNillableTraceBind sets the "traceBind" field if the given value is not nil.
func (_u *ProductBOMUpdate) SetNillableTraceBind(v *bool) *ProductBOMUpdate {
if v != nil {
_u.SetTraceBind(*v)
}
return _u
}
// SetRemark sets the "remark" field.
func (_u *ProductBOMUpdate) SetRemark(v string) *ProductBOMUpdate {
_u.mutation.SetRemark(v)
@@ -266,6 +280,9 @@ func (_u *ProductBOMUpdate) sqlSave(ctx context.Context) (_node int, err error)
if value, ok := _u.mutation.AddedLossRate(); ok {
_spec.AddField(productbom.FieldLossRate, field.TypeFloat64, value)
}
if value, ok := _u.mutation.TraceBind(); ok {
_spec.SetField(productbom.FieldTraceBind, field.TypeBool, value)
}
if value, ok := _u.mutation.Remark(); ok {
_spec.SetField(productbom.FieldRemark, field.TypeString, value)
}
@@ -403,6 +420,20 @@ func (_u *ProductBOMUpdateOne) AddLossRate(v float64) *ProductBOMUpdateOne {
return _u
}
// SetTraceBind sets the "traceBind" field.
func (_u *ProductBOMUpdateOne) SetTraceBind(v bool) *ProductBOMUpdateOne {
_u.mutation.SetTraceBind(v)
return _u
}
// SetNillableTraceBind sets the "traceBind" field if the given value is not nil.
func (_u *ProductBOMUpdateOne) SetNillableTraceBind(v *bool) *ProductBOMUpdateOne {
if v != nil {
_u.SetTraceBind(*v)
}
return _u
}
// SetRemark sets the "remark" field.
func (_u *ProductBOMUpdateOne) SetRemark(v string) *ProductBOMUpdateOne {
_u.mutation.SetRemark(v)
@@ -559,6 +590,9 @@ func (_u *ProductBOMUpdateOne) sqlSave(ctx context.Context) (_node *ProductBOM,
if value, ok := _u.mutation.AddedLossRate(); ok {
_spec.AddField(productbom.FieldLossRate, field.TypeFloat64, value)
}
if value, ok := _u.mutation.TraceBind(); ok {
_spec.SetField(productbom.FieldTraceBind, field.TypeBool, value)
}
if value, ok := _u.mutation.Remark(); ok {
_spec.SetField(productbom.FieldRemark, field.TypeString, value)
}
+14 -6
View File
@@ -581,22 +581,26 @@ func init() {
callpoolDescReservedQty := callpoolFields[9].Descriptor()
// callpool.DefaultReservedQty holds the default value on creation for the reservedQty field.
callpool.DefaultReservedQty = callpoolDescReservedQty.Default.(int)
// callpoolDescInstalledQty is the schema descriptor for installedQty field.
callpoolDescInstalledQty := callpoolFields[10].Descriptor()
// callpool.DefaultInstalledQty holds the default value on creation for the installedQty field.
callpool.DefaultInstalledQty = callpoolDescInstalledQty.Default.(int)
// callpoolDescCrossDay is the schema descriptor for crossDay field.
callpoolDescCrossDay := callpoolFields[10].Descriptor()
callpoolDescCrossDay := callpoolFields[11].Descriptor()
// callpool.DefaultCrossDay holds the default value on creation for the crossDay field.
callpool.DefaultCrossDay = callpoolDescCrossDay.Default.(bool)
// callpoolDescPlanDates is the schema descriptor for planDates field.
callpoolDescPlanDates := callpoolFields[11].Descriptor()
callpoolDescPlanDates := callpoolFields[12].Descriptor()
// callpool.DefaultPlanDates holds the default value on creation for the planDates field.
callpool.DefaultPlanDates = callpoolDescPlanDates.Default.(string)
// callpool.PlanDatesValidator is a validator for the "planDates" field. It is called by the builders before save.
callpool.PlanDatesValidator = callpoolDescPlanDates.Validators[0].(func(string) error)
// callpoolDescCreatedAt is the schema descriptor for createdAt field.
callpoolDescCreatedAt := callpoolFields[12].Descriptor()
callpoolDescCreatedAt := callpoolFields[13].Descriptor()
// callpool.DefaultCreatedAt holds the default value on creation for the createdAt field.
callpool.DefaultCreatedAt = callpoolDescCreatedAt.Default.(func() time.Time)
// callpoolDescUpdatedAt is the schema descriptor for updatedAt field.
callpoolDescUpdatedAt := callpoolFields[13].Descriptor()
callpoolDescUpdatedAt := callpoolFields[14].Descriptor()
// callpool.DefaultUpdatedAt holds the default value on creation for the updatedAt field.
callpool.DefaultUpdatedAt = callpoolDescUpdatedAt.Default.(func() time.Time)
// callpool.UpdateDefaultUpdatedAt holds the default value on update for the updatedAt field.
@@ -1539,14 +1543,18 @@ func init() {
productbomDescLossRate := productbomFields[7].Descriptor()
// productbom.DefaultLossRate holds the default value on creation for the lossRate field.
productbom.DefaultLossRate = productbomDescLossRate.Default.(float64)
// productbomDescTraceBind is the schema descriptor for traceBind field.
productbomDescTraceBind := productbomFields[8].Descriptor()
// productbom.DefaultTraceBind holds the default value on creation for the traceBind field.
productbom.DefaultTraceBind = productbomDescTraceBind.Default.(bool)
// productbomDescRemark is the schema descriptor for remark field.
productbomDescRemark := productbomFields[8].Descriptor()
productbomDescRemark := productbomFields[9].Descriptor()
// productbom.DefaultRemark holds the default value on creation for the remark field.
productbom.DefaultRemark = productbomDescRemark.Default.(string)
// productbom.RemarkValidator is a validator for the "remark" field. It is called by the builders before save.
productbom.RemarkValidator = productbomDescRemark.Validators[0].(func(string) error)
// productbomDescCreatedAt is the schema descriptor for createdAt field.
productbomDescCreatedAt := productbomFields[9].Descriptor()
productbomDescCreatedAt := productbomFields[10].Descriptor()
// productbom.DefaultCreatedAt holds the default value on creation for the createdAt field.
productbom.DefaultCreatedAt = productbomDescCreatedAt.Default.(func() time.Time)
// productbomDescID is the schema descriptor for id field.