新增工件生命周期状态流水表,记录所有工件状态变更动作,替代原半成品质检计数源 调整工单状态流转,将「下发工单」与「开始执行」合并为「下发并开工」,自动启用关联排产 新增工件物理位置字段,区分业务位置与实际物理工位,解决工位对账滞后问题 统一物料类别处理,避免 WMS 同步时覆盖合法值或错误设置为 0 移除已废弃的返修状态,更新相关显示与逻辑
217 lines
7.7 KiB
Go
217 lines
7.7 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_mes/ent/workpiecelifecyclelog"
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
)
|
|
|
|
// 工件生命周期状态流水:NEW/ONLINE/REPORT/SEMI_IN/SEMI_OUT/DONE/SCRAPPED,所有状态变更点同事务写
|
|
type WorkpieceLifecycleLog struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int `json:"id,omitempty"`
|
|
// 工件SN
|
|
Sn string `json:"sn,omitempty"`
|
|
// 所属工单
|
|
WorkOrderNo string `json:"workOrderNo,omitempty"`
|
|
// 状态动作:NEW/ONLINE/REPORT/SEMI_IN/SEMI_OUT/DONE/SCRAPPED
|
|
Action string `json:"action,omitempty"`
|
|
// 变更前状态
|
|
FromStatus string `json:"fromStatus,omitempty"`
|
|
// 变更后状态
|
|
ToStatus string `json:"toStatus,omitempty"`
|
|
// 关联工位号
|
|
StationNo int `json:"stationNo,omitempty"`
|
|
// 工艺序号(工序顺序)
|
|
FlowSeq int `json:"flowSeq,omitempty"`
|
|
// 操作人
|
|
Operator string `json:"operator,omitempty"`
|
|
// 来源:workstation/mes/admin/reconcile
|
|
Source string `json:"source,omitempty"`
|
|
// 备注
|
|
Remark string `json:"remark,omitempty"`
|
|
// CreatedAt holds the value of the "createdAt" field.
|
|
CreatedAt time.Time `json:"createdAt,omitempty"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*WorkpieceLifecycleLog) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case workpiecelifecyclelog.FieldID, workpiecelifecyclelog.FieldStationNo, workpiecelifecyclelog.FieldFlowSeq:
|
|
values[i] = new(sql.NullInt64)
|
|
case workpiecelifecyclelog.FieldSn, workpiecelifecyclelog.FieldWorkOrderNo, workpiecelifecyclelog.FieldAction, workpiecelifecyclelog.FieldFromStatus, workpiecelifecyclelog.FieldToStatus, workpiecelifecyclelog.FieldOperator, workpiecelifecyclelog.FieldSource, workpiecelifecyclelog.FieldRemark:
|
|
values[i] = new(sql.NullString)
|
|
case workpiecelifecyclelog.FieldCreatedAt:
|
|
values[i] = new(sql.NullTime)
|
|
default:
|
|
values[i] = new(sql.UnknownType)
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the WorkpieceLifecycleLog fields.
|
|
func (_m *WorkpieceLifecycleLog) 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 workpiecelifecyclelog.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 workpiecelifecyclelog.FieldSn:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field sn", values[i])
|
|
} else if value.Valid {
|
|
_m.Sn = value.String
|
|
}
|
|
case workpiecelifecyclelog.FieldWorkOrderNo:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field workOrderNo", values[i])
|
|
} else if value.Valid {
|
|
_m.WorkOrderNo = value.String
|
|
}
|
|
case workpiecelifecyclelog.FieldAction:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field action", values[i])
|
|
} else if value.Valid {
|
|
_m.Action = value.String
|
|
}
|
|
case workpiecelifecyclelog.FieldFromStatus:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field fromStatus", values[i])
|
|
} else if value.Valid {
|
|
_m.FromStatus = value.String
|
|
}
|
|
case workpiecelifecyclelog.FieldToStatus:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field toStatus", values[i])
|
|
} else if value.Valid {
|
|
_m.ToStatus = value.String
|
|
}
|
|
case workpiecelifecyclelog.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 workpiecelifecyclelog.FieldFlowSeq:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field flowSeq", values[i])
|
|
} else if value.Valid {
|
|
_m.FlowSeq = int(value.Int64)
|
|
}
|
|
case workpiecelifecyclelog.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 workpiecelifecyclelog.FieldSource:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field source", values[i])
|
|
} else if value.Valid {
|
|
_m.Source = value.String
|
|
}
|
|
case workpiecelifecyclelog.FieldRemark:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field remark", values[i])
|
|
} else if value.Valid {
|
|
_m.Remark = value.String
|
|
}
|
|
case workpiecelifecyclelog.FieldCreatedAt:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field createdAt", values[i])
|
|
} else if value.Valid {
|
|
_m.CreatedAt = value.Time
|
|
}
|
|
default:
|
|
_m.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the WorkpieceLifecycleLog.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *WorkpieceLifecycleLog) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// Update returns a builder for updating this WorkpieceLifecycleLog.
|
|
// Note that you need to call WorkpieceLifecycleLog.Unwrap() before calling this method if this WorkpieceLifecycleLog
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *WorkpieceLifecycleLog) Update() *WorkpieceLifecycleLogUpdateOne {
|
|
return NewWorkpieceLifecycleLogClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the WorkpieceLifecycleLog 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 *WorkpieceLifecycleLog) Unwrap() *WorkpieceLifecycleLog {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: WorkpieceLifecycleLog is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *WorkpieceLifecycleLog) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("WorkpieceLifecycleLog(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
builder.WriteString("sn=")
|
|
builder.WriteString(_m.Sn)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("workOrderNo=")
|
|
builder.WriteString(_m.WorkOrderNo)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("action=")
|
|
builder.WriteString(_m.Action)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("fromStatus=")
|
|
builder.WriteString(_m.FromStatus)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("toStatus=")
|
|
builder.WriteString(_m.ToStatus)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("stationNo=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.StationNo))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("flowSeq=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.FlowSeq))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("operator=")
|
|
builder.WriteString(_m.Operator)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("source=")
|
|
builder.WriteString(_m.Source)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("remark=")
|
|
builder.WriteString(_m.Remark)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("createdAt=")
|
|
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// WorkpieceLifecycleLogs is a parsable slice of WorkpieceLifecycleLog.
|
|
type WorkpieceLifecycleLogs []*WorkpieceLifecycleLog
|