feat: 新增检测单关联、基础数据优化与入库单升级
1. 新增出库单检测单号字段并添加索引支持溯源 2. 优化基础数据页面物料类型展示与选择逻辑 3. 升级入库单导入功能,支持自动生成单号并返回导入结果 4. 优化接驳台查询排序方式 5. 修复字符串拼接空格问题
This commit is contained in:
@@ -0,0 +1,438 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package hook
|
||||
|
||||
import (
|
||||
"bj_power_wms"
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// The AgvTaskFunc type is an adapter to allow the use of ordinary
|
||||
// function as AgvTask mutator.
|
||||
type AgvTaskFunc func(context.Context, *bj_power_wms.AgvTaskMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f AgvTaskFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.AgvTaskMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.AgvTaskMutation", m)
|
||||
}
|
||||
|
||||
// The AttachmentFunc type is an adapter to allow the use of ordinary
|
||||
// function as Attachment mutator.
|
||||
type AttachmentFunc func(context.Context, *bj_power_wms.AttachmentMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f AttachmentFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.AttachmentMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.AttachmentMutation", m)
|
||||
}
|
||||
|
||||
// The EventLogFunc type is an adapter to allow the use of ordinary
|
||||
// function as EventLog mutator.
|
||||
type EventLogFunc func(context.Context, *bj_power_wms.EventLogMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f EventLogFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.EventLogMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.EventLogMutation", m)
|
||||
}
|
||||
|
||||
// The InboundDetailFunc type is an adapter to allow the use of ordinary
|
||||
// function as InboundDetail mutator.
|
||||
type InboundDetailFunc func(context.Context, *bj_power_wms.InboundDetailMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f InboundDetailFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.InboundDetailMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.InboundDetailMutation", m)
|
||||
}
|
||||
|
||||
// The InboundOrderFunc type is an adapter to allow the use of ordinary
|
||||
// function as InboundOrder mutator.
|
||||
type InboundOrderFunc func(context.Context, *bj_power_wms.InboundOrderMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f InboundOrderFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.InboundOrderMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.InboundOrderMutation", m)
|
||||
}
|
||||
|
||||
// The InspectionRecordFunc type is an adapter to allow the use of ordinary
|
||||
// function as InspectionRecord mutator.
|
||||
type InspectionRecordFunc func(context.Context, *bj_power_wms.InspectionRecordMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f InspectionRecordFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.InspectionRecordMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.InspectionRecordMutation", m)
|
||||
}
|
||||
|
||||
// The InventoryFunc type is an adapter to allow the use of ordinary
|
||||
// function as Inventory mutator.
|
||||
type InventoryFunc func(context.Context, *bj_power_wms.InventoryMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f InventoryFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.InventoryMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.InventoryMutation", m)
|
||||
}
|
||||
|
||||
// The InventoryLockFunc type is an adapter to allow the use of ordinary
|
||||
// function as InventoryLock mutator.
|
||||
type InventoryLockFunc func(context.Context, *bj_power_wms.InventoryLockMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f InventoryLockFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.InventoryLockMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.InventoryLockMutation", m)
|
||||
}
|
||||
|
||||
// The MaterialFunc type is an adapter to allow the use of ordinary
|
||||
// function as Material mutator.
|
||||
type MaterialFunc func(context.Context, *bj_power_wms.MaterialMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f MaterialFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.MaterialMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.MaterialMutation", m)
|
||||
}
|
||||
|
||||
// The MaterialDemandFunc type is an adapter to allow the use of ordinary
|
||||
// function as MaterialDemand mutator.
|
||||
type MaterialDemandFunc func(context.Context, *bj_power_wms.MaterialDemandMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f MaterialDemandFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.MaterialDemandMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.MaterialDemandMutation", m)
|
||||
}
|
||||
|
||||
// The OrderMaterialLedgerFunc type is an adapter to allow the use of ordinary
|
||||
// function as OrderMaterialLedger mutator.
|
||||
type OrderMaterialLedgerFunc func(context.Context, *bj_power_wms.OrderMaterialLedgerMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f OrderMaterialLedgerFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.OrderMaterialLedgerMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.OrderMaterialLedgerMutation", m)
|
||||
}
|
||||
|
||||
// The OutboundDetailFunc type is an adapter to allow the use of ordinary
|
||||
// function as OutboundDetail mutator.
|
||||
type OutboundDetailFunc func(context.Context, *bj_power_wms.OutboundDetailMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f OutboundDetailFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.OutboundDetailMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.OutboundDetailMutation", m)
|
||||
}
|
||||
|
||||
// The OutboundOrderFunc type is an adapter to allow the use of ordinary
|
||||
// function as OutboundOrder mutator.
|
||||
type OutboundOrderFunc func(context.Context, *bj_power_wms.OutboundOrderMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f OutboundOrderFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.OutboundOrderMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.OutboundOrderMutation", m)
|
||||
}
|
||||
|
||||
// The PermissionFunc type is an adapter to allow the use of ordinary
|
||||
// function as Permission mutator.
|
||||
type PermissionFunc func(context.Context, *bj_power_wms.PermissionMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f PermissionFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.PermissionMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.PermissionMutation", m)
|
||||
}
|
||||
|
||||
// The ReturnOrderFunc type is an adapter to allow the use of ordinary
|
||||
// function as ReturnOrder mutator.
|
||||
type ReturnOrderFunc func(context.Context, *bj_power_wms.ReturnOrderMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f ReturnOrderFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.ReturnOrderMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.ReturnOrderMutation", m)
|
||||
}
|
||||
|
||||
// The RoleFunc type is an adapter to allow the use of ordinary
|
||||
// function as Role mutator.
|
||||
type RoleFunc func(context.Context, *bj_power_wms.RoleMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f RoleFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.RoleMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.RoleMutation", m)
|
||||
}
|
||||
|
||||
// The SemiFinishedFunc type is an adapter to allow the use of ordinary
|
||||
// function as SemiFinished mutator.
|
||||
type SemiFinishedFunc func(context.Context, *bj_power_wms.SemiFinishedMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f SemiFinishedFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.SemiFinishedMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.SemiFinishedMutation", m)
|
||||
}
|
||||
|
||||
// The StocktakeItemFunc type is an adapter to allow the use of ordinary
|
||||
// function as StocktakeItem mutator.
|
||||
type StocktakeItemFunc func(context.Context, *bj_power_wms.StocktakeItemMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f StocktakeItemFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.StocktakeItemMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.StocktakeItemMutation", m)
|
||||
}
|
||||
|
||||
// The StocktakeOrderFunc type is an adapter to allow the use of ordinary
|
||||
// function as StocktakeOrder mutator.
|
||||
type StocktakeOrderFunc func(context.Context, *bj_power_wms.StocktakeOrderMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f StocktakeOrderFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.StocktakeOrderMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.StocktakeOrderMutation", m)
|
||||
}
|
||||
|
||||
// The UserFunc type is an adapter to allow the use of ordinary
|
||||
// function as User mutator.
|
||||
type UserFunc func(context.Context, *bj_power_wms.UserMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f UserFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.UserMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.UserMutation", m)
|
||||
}
|
||||
|
||||
// The ZoneFunc type is an adapter to allow the use of ordinary
|
||||
// function as Zone mutator.
|
||||
type ZoneFunc func(context.Context, *bj_power_wms.ZoneMutation) (bj_power_wms.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f ZoneFunc) Mutate(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if mv, ok := m.(*bj_power_wms.ZoneMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *bj_power_wms.ZoneMutation", m)
|
||||
}
|
||||
|
||||
// Condition is a hook condition function.
|
||||
type Condition func(context.Context, bj_power_wms.Mutation) bool
|
||||
|
||||
// And groups conditions with the AND operator.
|
||||
func And(first, second Condition, rest ...Condition) Condition {
|
||||
return func(ctx context.Context, m bj_power_wms.Mutation) bool {
|
||||
if !first(ctx, m) || !second(ctx, m) {
|
||||
return false
|
||||
}
|
||||
for _, cond := range rest {
|
||||
if !cond(ctx, m) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// Or groups conditions with the OR operator.
|
||||
func Or(first, second Condition, rest ...Condition) Condition {
|
||||
return func(ctx context.Context, m bj_power_wms.Mutation) bool {
|
||||
if first(ctx, m) || second(ctx, m) {
|
||||
return true
|
||||
}
|
||||
for _, cond := range rest {
|
||||
if cond(ctx, m) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Not negates a given condition.
|
||||
func Not(cond Condition) Condition {
|
||||
return func(ctx context.Context, m bj_power_wms.Mutation) bool {
|
||||
return !cond(ctx, m)
|
||||
}
|
||||
}
|
||||
|
||||
// HasOp is a condition testing mutation operation.
|
||||
func HasOp(op bj_power_wms.Op) Condition {
|
||||
return func(_ context.Context, m bj_power_wms.Mutation) bool {
|
||||
return m.Op().Is(op)
|
||||
}
|
||||
}
|
||||
|
||||
// HasAddedFields is a condition validating `.AddedField` on fields.
|
||||
func HasAddedFields(field string, fields ...string) Condition {
|
||||
return func(_ context.Context, m bj_power_wms.Mutation) bool {
|
||||
if _, exists := m.AddedField(field); !exists {
|
||||
return false
|
||||
}
|
||||
for _, field := range fields {
|
||||
if _, exists := m.AddedField(field); !exists {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// HasClearedFields is a condition validating `.FieldCleared` on fields.
|
||||
func HasClearedFields(field string, fields ...string) Condition {
|
||||
return func(_ context.Context, m bj_power_wms.Mutation) bool {
|
||||
if exists := m.FieldCleared(field); !exists {
|
||||
return false
|
||||
}
|
||||
for _, field := range fields {
|
||||
if exists := m.FieldCleared(field); !exists {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// HasFields is a condition validating `.Field` on fields.
|
||||
func HasFields(field string, fields ...string) Condition {
|
||||
return func(_ context.Context, m bj_power_wms.Mutation) bool {
|
||||
if _, exists := m.Field(field); !exists {
|
||||
return false
|
||||
}
|
||||
for _, field := range fields {
|
||||
if _, exists := m.Field(field); !exists {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// If executes the given hook under condition.
|
||||
//
|
||||
// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))
|
||||
func If(hk bj_power_wms.Hook, cond Condition) bj_power_wms.Hook {
|
||||
return func(next bj_power_wms.Mutator) bj_power_wms.Mutator {
|
||||
return bj_power_wms.MutateFunc(func(ctx context.Context, m bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
if cond(ctx, m) {
|
||||
return hk(next).Mutate(ctx, m)
|
||||
}
|
||||
return next.Mutate(ctx, m)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// On executes the given hook only for the given operation.
|
||||
//
|
||||
// hook.On(Log, bj_power_wms.Delete|bj_power_wms.Create)
|
||||
func On(hk bj_power_wms.Hook, op bj_power_wms.Op) bj_power_wms.Hook {
|
||||
return If(hk, HasOp(op))
|
||||
}
|
||||
|
||||
// Unless skips the given hook only for the given operation.
|
||||
//
|
||||
// hook.Unless(Log, bj_power_wms.Update|bj_power_wms.UpdateOne)
|
||||
func Unless(hk bj_power_wms.Hook, op bj_power_wms.Op) bj_power_wms.Hook {
|
||||
return If(hk, Not(HasOp(op)))
|
||||
}
|
||||
|
||||
// FixedError is a hook returning a fixed error.
|
||||
func FixedError(err error) bj_power_wms.Hook {
|
||||
return func(bj_power_wms.Mutator) bj_power_wms.Mutator {
|
||||
return bj_power_wms.MutateFunc(func(context.Context, bj_power_wms.Mutation) (bj_power_wms.Value, error) {
|
||||
return nil, err
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Reject returns a hook that rejects all operations that match op.
|
||||
//
|
||||
// func (T) Hooks() []bj_power_wms.Hook {
|
||||
// return []bj_power_wms.Hook{
|
||||
// Reject(bj_power_wms.Delete|bj_power_wms.Update),
|
||||
// }
|
||||
// }
|
||||
func Reject(op bj_power_wms.Op) bj_power_wms.Hook {
|
||||
hk := FixedError(fmt.Errorf("%s operation is not allowed", op))
|
||||
return On(hk, op)
|
||||
}
|
||||
|
||||
// Chain acts as a list of hooks and is effectively immutable.
|
||||
// Once created, it will always hold the same set of hooks in the same order.
|
||||
type Chain struct {
|
||||
hooks []bj_power_wms.Hook
|
||||
}
|
||||
|
||||
// NewChain creates a new chain of hooks.
|
||||
func NewChain(hooks ...bj_power_wms.Hook) Chain {
|
||||
return Chain{append([]bj_power_wms.Hook(nil), hooks...)}
|
||||
}
|
||||
|
||||
// Hook chains the list of hooks and returns the final hook.
|
||||
func (c Chain) Hook() bj_power_wms.Hook {
|
||||
return func(mutator bj_power_wms.Mutator) bj_power_wms.Mutator {
|
||||
for i := len(c.hooks) - 1; i >= 0; i-- {
|
||||
mutator = c.hooks[i](mutator)
|
||||
}
|
||||
return mutator
|
||||
}
|
||||
}
|
||||
|
||||
// Append extends a chain, adding the specified hook
|
||||
// as the last ones in the mutation flow.
|
||||
func (c Chain) Append(hooks ...bj_power_wms.Hook) Chain {
|
||||
newHooks := make([]bj_power_wms.Hook, 0, len(c.hooks)+len(hooks))
|
||||
newHooks = append(newHooks, c.hooks...)
|
||||
newHooks = append(newHooks, hooks...)
|
||||
return Chain{newHooks}
|
||||
}
|
||||
|
||||
// Extend extends a chain, adding the specified chain
|
||||
// as the last ones in the mutation flow.
|
||||
func (c Chain) Extend(chain Chain) Chain {
|
||||
return c.Append(chain.hooks...)
|
||||
}
|
||||
Reference in New Issue
Block a user