feat(mes): 添加定时同步可生产数量到WMS及BOM项相关标准字段
- 在main.go中添加定时任务每10分钟同步可生产数量到WMS系统 - 为BomItem实体添加relatedStandard字段及相关CRUD方法 - 为InspectionRecord实体添加reportNo、materialCode、materialName等字段 - 更新ent schema确保新字段的验证和默认值设置 - 添加必要的数据库迁移和字段映射逻辑
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"bj_power_wms/ent/materialdemand"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// MaterialDemand is the model entity for the MaterialDemand schema.
|
||||
type MaterialDemand struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// 物料编码(图号)
|
||||
MaterialCode string `json:"materialCode,omitempty"`
|
||||
// 未来5天需求量(近5天日排产×单台用量)
|
||||
Future5Qty int `json:"future5Qty,omitempty"`
|
||||
// 更新时间(unix 秒)
|
||||
UpdatedAt int64 `json:"updatedAt,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*MaterialDemand) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case materialdemand.FieldID, materialdemand.FieldFuture5Qty, materialdemand.FieldUpdatedAt:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case materialdemand.FieldMaterialCode:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the MaterialDemand fields.
|
||||
func (_m *MaterialDemand) 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 materialdemand.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 materialdemand.FieldMaterialCode:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field material_code", values[i])
|
||||
} else if value.Valid {
|
||||
_m.MaterialCode = value.String
|
||||
}
|
||||
case materialdemand.FieldFuture5Qty:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field future5_qty", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Future5Qty = int(value.Int64)
|
||||
}
|
||||
case materialdemand.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.UpdatedAt = value.Int64
|
||||
}
|
||||
default:
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the MaterialDemand.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (_m *MaterialDemand) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this MaterialDemand.
|
||||
// Note that you need to call MaterialDemand.Unwrap() before calling this method if this MaterialDemand
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (_m *MaterialDemand) Update() *MaterialDemandUpdateOne {
|
||||
return NewMaterialDemandClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the MaterialDemand 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 *MaterialDemand) Unwrap() *MaterialDemand {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: MaterialDemand is not a transactional entity")
|
||||
}
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (_m *MaterialDemand) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("MaterialDemand(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("material_code=")
|
||||
builder.WriteString(_m.MaterialCode)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("future5_qty=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Future5Qty))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.UpdatedAt))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// MaterialDemands is a parsable slice of MaterialDemand.
|
||||
type MaterialDemands []*MaterialDemand
|
||||
Reference in New Issue
Block a user