- 新增 SyncFailure 实体:MES/WMS 两端 schema 源 + ent 生成码(create/delete/query/update 及子包) - ent 框架文件全量重生成:client/ent/hook/migrate/mutation/predicate/runtime/tx - 清理旧代码生成入口:删除 schema/gen.go 与 schema/tools/generate.go - 同步失败页面调整:MES/WMS SyncFailure.vue 接入新实体,MES 产品工艺页同步调整 - 主程序入口注册新实体:bj_power_mes.go / bj_power_wms.go,工作站 main.go 同步调整 - 更新文档:WMS README、案例、问题记录;刷新 MES/WMS 前端构建产物
225 lines
7.8 KiB
Go
225 lines
7.8 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_mes/ent/syncfailure"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
)
|
|
|
|
// SyncFailure 跨系统调用失败台账:本地已提交、对端通知失败,人工确认后重试
|
|
type SyncFailure struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int `json:"id,omitempty"`
|
|
// 调用方向,如 mes>wms / wms>mes
|
|
Direction string `json:"direction,omitempty"`
|
|
// 业务类型,如 material.sync
|
|
BizType string `json:"biz_type,omitempty"`
|
|
// 业务主键
|
|
BizKey string `json:"biz_key,omitempty"`
|
|
// 重试时原样重放的对端地址
|
|
Endpoint string `json:"endpoint,omitempty"`
|
|
// 通知载荷(JSON)
|
|
PayloadJSON string `json:"payload_json,omitempty"`
|
|
// 失败原因
|
|
ErrorMsg string `json:"error_msg,omitempty"`
|
|
// 幂等键 direction|biz_type|biz_key
|
|
IdempotencyKey string `json:"idempotency_key,omitempty"`
|
|
// PENDING/SUCCESS/DEAD
|
|
Status string `json:"status,omitempty"`
|
|
// 重试次数
|
|
RetryCount int32 `json:"retry_count,omitempty"`
|
|
// 首次失败时刻(unix秒)
|
|
CreatedAt int64 `json:"created_at,omitempty"`
|
|
// 最近失败时刻(unix秒)
|
|
LastErrorAt int64 `json:"last_error_at,omitempty"`
|
|
// 人工置 DEAD 的操作人
|
|
HandledBy string `json:"handled_by,omitempty"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*SyncFailure) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case syncfailure.FieldID, syncfailure.FieldRetryCount, syncfailure.FieldCreatedAt, syncfailure.FieldLastErrorAt:
|
|
values[i] = new(sql.NullInt64)
|
|
case syncfailure.FieldDirection, syncfailure.FieldBizType, syncfailure.FieldBizKey, syncfailure.FieldEndpoint, syncfailure.FieldPayloadJSON, syncfailure.FieldErrorMsg, syncfailure.FieldIdempotencyKey, syncfailure.FieldStatus, syncfailure.FieldHandledBy:
|
|
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 SyncFailure fields.
|
|
func (_m *SyncFailure) 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 syncfailure.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 syncfailure.FieldDirection:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field direction", values[i])
|
|
} else if value.Valid {
|
|
_m.Direction = value.String
|
|
}
|
|
case syncfailure.FieldBizType:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field biz_type", values[i])
|
|
} else if value.Valid {
|
|
_m.BizType = value.String
|
|
}
|
|
case syncfailure.FieldBizKey:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field biz_key", values[i])
|
|
} else if value.Valid {
|
|
_m.BizKey = value.String
|
|
}
|
|
case syncfailure.FieldEndpoint:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field endpoint", values[i])
|
|
} else if value.Valid {
|
|
_m.Endpoint = value.String
|
|
}
|
|
case syncfailure.FieldPayloadJSON:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field payload_json", values[i])
|
|
} else if value.Valid {
|
|
_m.PayloadJSON = value.String
|
|
}
|
|
case syncfailure.FieldErrorMsg:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field error_msg", values[i])
|
|
} else if value.Valid {
|
|
_m.ErrorMsg = value.String
|
|
}
|
|
case syncfailure.FieldIdempotencyKey:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field idempotency_key", values[i])
|
|
} else if value.Valid {
|
|
_m.IdempotencyKey = value.String
|
|
}
|
|
case syncfailure.FieldStatus:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field status", values[i])
|
|
} else if value.Valid {
|
|
_m.Status = value.String
|
|
}
|
|
case syncfailure.FieldRetryCount:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field retry_count", values[i])
|
|
} else if value.Valid {
|
|
_m.RetryCount = int32(value.Int64)
|
|
}
|
|
case syncfailure.FieldCreatedAt:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
|
} else if value.Valid {
|
|
_m.CreatedAt = value.Int64
|
|
}
|
|
case syncfailure.FieldLastErrorAt:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field last_error_at", values[i])
|
|
} else if value.Valid {
|
|
_m.LastErrorAt = value.Int64
|
|
}
|
|
case syncfailure.FieldHandledBy:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field handled_by", values[i])
|
|
} else if value.Valid {
|
|
_m.HandledBy = value.String
|
|
}
|
|
default:
|
|
_m.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the SyncFailure.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *SyncFailure) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// Update returns a builder for updating this SyncFailure.
|
|
// Note that you need to call SyncFailure.Unwrap() before calling this method if this SyncFailure
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *SyncFailure) Update() *SyncFailureUpdateOne {
|
|
return NewSyncFailureClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the SyncFailure 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 *SyncFailure) Unwrap() *SyncFailure {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: SyncFailure is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *SyncFailure) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("SyncFailure(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
builder.WriteString("direction=")
|
|
builder.WriteString(_m.Direction)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("biz_type=")
|
|
builder.WriteString(_m.BizType)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("biz_key=")
|
|
builder.WriteString(_m.BizKey)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("endpoint=")
|
|
builder.WriteString(_m.Endpoint)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("payload_json=")
|
|
builder.WriteString(_m.PayloadJSON)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("error_msg=")
|
|
builder.WriteString(_m.ErrorMsg)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("idempotency_key=")
|
|
builder.WriteString(_m.IdempotencyKey)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("status=")
|
|
builder.WriteString(_m.Status)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("retry_count=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.RetryCount))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.CreatedAt))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("last_error_at=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.LastErrorAt))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("handled_by=")
|
|
builder.WriteString(_m.HandledBy)
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// SyncFailures is a parsable slice of SyncFailure.
|
|
type SyncFailures []*SyncFailure
|