feat: 完成产线与仓储系统多模块迭代升级
本次迭代覆盖MES与WMS核心业务: 1. 新增接驳台托盘传感器读取与AGV对接能力 2. 完善工单排产、备料流程与权限体系拆分 3. 优化看板接口与前端路由、样式 4. 新增操作日志、库存盘点与角色保护逻辑 5. 修复代理地址、BOM保存等已知问题
This commit is contained in:
@@ -4,6 +4,7 @@ package ent
|
||||
|
||||
import (
|
||||
"bj_power_mes/ent/dailyplan"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -25,6 +26,8 @@ type DailyPlan struct {
|
||||
PlanQty int `json:"planQty,omitempty"`
|
||||
// 已完成数量
|
||||
CompletedQty int `json:"completedQty,omitempty"`
|
||||
// 送达接驳台列表 DOCK01..20
|
||||
DockCodes []string `json:"dockCodes,omitempty"`
|
||||
// Status holds the value of the "status" field.
|
||||
Status string `json:"status,omitempty"`
|
||||
// Operator holds the value of the "operator" field.
|
||||
@@ -41,6 +44,8 @@ func (*DailyPlan) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case dailyplan.FieldDockCodes:
|
||||
values[i] = new([]byte)
|
||||
case dailyplan.FieldID, dailyplan.FieldPlanQty, dailyplan.FieldCompletedQty:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case dailyplan.FieldOrderNo, dailyplan.FieldPlanDate, dailyplan.FieldStatus, dailyplan.FieldOperator:
|
||||
@@ -92,6 +97,14 @@ func (_m *DailyPlan) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
_m.CompletedQty = int(value.Int64)
|
||||
}
|
||||
case dailyplan.FieldDockCodes:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field dockCodes", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
if err := json.Unmarshal(*value, &_m.DockCodes); err != nil {
|
||||
return fmt.Errorf("unmarshal field dockCodes: %w", err)
|
||||
}
|
||||
}
|
||||
case dailyplan.FieldStatus:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field status", values[i])
|
||||
@@ -165,6 +178,9 @@ func (_m *DailyPlan) String() string {
|
||||
builder.WriteString("completedQty=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.CompletedQty))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("dockCodes=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.DockCodes))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("status=")
|
||||
builder.WriteString(_m.Status)
|
||||
builder.WriteString(", ")
|
||||
|
||||
@@ -21,6 +21,8 @@ const (
|
||||
FieldPlanQty = "plan_qty"
|
||||
// FieldCompletedQty holds the string denoting the completedqty field in the database.
|
||||
FieldCompletedQty = "completed_qty"
|
||||
// FieldDockCodes holds the string denoting the dockcodes field in the database.
|
||||
FieldDockCodes = "dock_codes"
|
||||
// FieldStatus holds the string denoting the status field in the database.
|
||||
FieldStatus = "status"
|
||||
// FieldOperator holds the string denoting the operator field in the database.
|
||||
@@ -40,6 +42,7 @@ var Columns = []string{
|
||||
FieldPlanDate,
|
||||
FieldPlanQty,
|
||||
FieldCompletedQty,
|
||||
FieldDockCodes,
|
||||
FieldStatus,
|
||||
FieldOperator,
|
||||
FieldCreatedAt,
|
||||
|
||||
@@ -304,6 +304,16 @@ func CompletedQtyLTE(v int) predicate.DailyPlan {
|
||||
return predicate.DailyPlan(sql.FieldLTE(FieldCompletedQty, v))
|
||||
}
|
||||
|
||||
// DockCodesIsNil applies the IsNil predicate on the "dockCodes" field.
|
||||
func DockCodesIsNil() predicate.DailyPlan {
|
||||
return predicate.DailyPlan(sql.FieldIsNull(FieldDockCodes))
|
||||
}
|
||||
|
||||
// DockCodesNotNil applies the NotNil predicate on the "dockCodes" field.
|
||||
func DockCodesNotNil() predicate.DailyPlan {
|
||||
return predicate.DailyPlan(sql.FieldNotNull(FieldDockCodes))
|
||||
}
|
||||
|
||||
// StatusEQ applies the EQ predicate on the "status" field.
|
||||
func StatusEQ(v string) predicate.DailyPlan {
|
||||
return predicate.DailyPlan(sql.FieldEQ(FieldStatus, v))
|
||||
|
||||
@@ -60,6 +60,12 @@ func (_c *DailyPlanCreate) SetNillableCompletedQty(v *int) *DailyPlanCreate {
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDockCodes sets the "dockCodes" field.
|
||||
func (_c *DailyPlanCreate) SetDockCodes(v []string) *DailyPlanCreate {
|
||||
_c.mutation.SetDockCodes(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (_c *DailyPlanCreate) SetStatus(v string) *DailyPlanCreate {
|
||||
_c.mutation.SetStatus(v)
|
||||
@@ -279,6 +285,10 @@ func (_c *DailyPlanCreate) createSpec() (*DailyPlan, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(dailyplan.FieldCompletedQty, field.TypeInt, value)
|
||||
_node.CompletedQty = value
|
||||
}
|
||||
if value, ok := _c.mutation.DockCodes(); ok {
|
||||
_spec.SetField(dailyplan.FieldDockCodes, field.TypeJSON, value)
|
||||
_node.DockCodes = value
|
||||
}
|
||||
if value, ok := _c.mutation.Status(); ok {
|
||||
_spec.SetField(dailyplan.FieldStatus, field.TypeString, value)
|
||||
_node.Status = value
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/dialect/sql/sqljson"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
@@ -99,6 +100,24 @@ func (_u *DailyPlanUpdate) AddCompletedQty(v int) *DailyPlanUpdate {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDockCodes sets the "dockCodes" field.
|
||||
func (_u *DailyPlanUpdate) SetDockCodes(v []string) *DailyPlanUpdate {
|
||||
_u.mutation.SetDockCodes(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AppendDockCodes appends value to the "dockCodes" field.
|
||||
func (_u *DailyPlanUpdate) AppendDockCodes(v []string) *DailyPlanUpdate {
|
||||
_u.mutation.AppendDockCodes(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearDockCodes clears the value of the "dockCodes" field.
|
||||
func (_u *DailyPlanUpdate) ClearDockCodes() *DailyPlanUpdate {
|
||||
_u.mutation.ClearDockCodes()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (_u *DailyPlanUpdate) SetStatus(v string) *DailyPlanUpdate {
|
||||
_u.mutation.SetStatus(v)
|
||||
@@ -241,6 +260,17 @@ func (_u *DailyPlanUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if value, ok := _u.mutation.AddedCompletedQty(); ok {
|
||||
_spec.AddField(dailyplan.FieldCompletedQty, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.DockCodes(); ok {
|
||||
_spec.SetField(dailyplan.FieldDockCodes, field.TypeJSON, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AppendedDockCodes(); ok {
|
||||
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
||||
sqljson.Append(u, dailyplan.FieldDockCodes, value)
|
||||
})
|
||||
}
|
||||
if _u.mutation.DockCodesCleared() {
|
||||
_spec.ClearField(dailyplan.FieldDockCodes, field.TypeJSON)
|
||||
}
|
||||
if value, ok := _u.mutation.Status(); ok {
|
||||
_spec.SetField(dailyplan.FieldStatus, field.TypeString, value)
|
||||
}
|
||||
@@ -345,6 +375,24 @@ func (_u *DailyPlanUpdateOne) AddCompletedQty(v int) *DailyPlanUpdateOne {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDockCodes sets the "dockCodes" field.
|
||||
func (_u *DailyPlanUpdateOne) SetDockCodes(v []string) *DailyPlanUpdateOne {
|
||||
_u.mutation.SetDockCodes(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AppendDockCodes appends value to the "dockCodes" field.
|
||||
func (_u *DailyPlanUpdateOne) AppendDockCodes(v []string) *DailyPlanUpdateOne {
|
||||
_u.mutation.AppendDockCodes(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearDockCodes clears the value of the "dockCodes" field.
|
||||
func (_u *DailyPlanUpdateOne) ClearDockCodes() *DailyPlanUpdateOne {
|
||||
_u.mutation.ClearDockCodes()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (_u *DailyPlanUpdateOne) SetStatus(v string) *DailyPlanUpdateOne {
|
||||
_u.mutation.SetStatus(v)
|
||||
@@ -517,6 +565,17 @@ func (_u *DailyPlanUpdateOne) sqlSave(ctx context.Context) (_node *DailyPlan, er
|
||||
if value, ok := _u.mutation.AddedCompletedQty(); ok {
|
||||
_spec.AddField(dailyplan.FieldCompletedQty, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := _u.mutation.DockCodes(); ok {
|
||||
_spec.SetField(dailyplan.FieldDockCodes, field.TypeJSON, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AppendedDockCodes(); ok {
|
||||
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
||||
sqljson.Append(u, dailyplan.FieldDockCodes, value)
|
||||
})
|
||||
}
|
||||
if _u.mutation.DockCodesCleared() {
|
||||
_spec.ClearField(dailyplan.FieldDockCodes, field.TypeJSON)
|
||||
}
|
||||
if value, ok := _u.mutation.Status(); ok {
|
||||
_spec.SetField(dailyplan.FieldStatus, field.TypeString, value)
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ var (
|
||||
{Name: "plan_date", Type: field.TypeString, Size: 10},
|
||||
{Name: "plan_qty", Type: field.TypeInt, Default: 0},
|
||||
{Name: "completed_qty", Type: field.TypeInt, Default: 0},
|
||||
{Name: "dock_codes", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}},
|
||||
{Name: "status", Type: field.TypeString, Size: 20, Default: "PENDING"},
|
||||
{Name: "operator", Type: field.TypeString, Size: 64, Default: ""},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
|
||||
@@ -1829,6 +1829,8 @@ type DailyPlanMutation struct {
|
||||
addplanQty *int
|
||||
completedQty *int
|
||||
addcompletedQty *int
|
||||
dockCodes *[]string
|
||||
appenddockCodes []string
|
||||
status *string
|
||||
operator *string
|
||||
createdAt *time.Time
|
||||
@@ -2127,6 +2129,71 @@ func (m *DailyPlanMutation) ResetCompletedQty() {
|
||||
m.addcompletedQty = nil
|
||||
}
|
||||
|
||||
// SetDockCodes sets the "dockCodes" field.
|
||||
func (m *DailyPlanMutation) SetDockCodes(s []string) {
|
||||
m.dockCodes = &s
|
||||
m.appenddockCodes = nil
|
||||
}
|
||||
|
||||
// DockCodes returns the value of the "dockCodes" field in the mutation.
|
||||
func (m *DailyPlanMutation) DockCodes() (r []string, exists bool) {
|
||||
v := m.dockCodes
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldDockCodes returns the old "dockCodes" field's value of the DailyPlan entity.
|
||||
// If the DailyPlan 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 *DailyPlanMutation) OldDockCodes(ctx context.Context) (v []string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldDockCodes is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldDockCodes requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldDockCodes: %w", err)
|
||||
}
|
||||
return oldValue.DockCodes, nil
|
||||
}
|
||||
|
||||
// AppendDockCodes adds s to the "dockCodes" field.
|
||||
func (m *DailyPlanMutation) AppendDockCodes(s []string) {
|
||||
m.appenddockCodes = append(m.appenddockCodes, s...)
|
||||
}
|
||||
|
||||
// AppendedDockCodes returns the list of values that were appended to the "dockCodes" field in this mutation.
|
||||
func (m *DailyPlanMutation) AppendedDockCodes() ([]string, bool) {
|
||||
if len(m.appenddockCodes) == 0 {
|
||||
return nil, false
|
||||
}
|
||||
return m.appenddockCodes, true
|
||||
}
|
||||
|
||||
// ClearDockCodes clears the value of the "dockCodes" field.
|
||||
func (m *DailyPlanMutation) ClearDockCodes() {
|
||||
m.dockCodes = nil
|
||||
m.appenddockCodes = nil
|
||||
m.clearedFields[dailyplan.FieldDockCodes] = struct{}{}
|
||||
}
|
||||
|
||||
// DockCodesCleared returns if the "dockCodes" field was cleared in this mutation.
|
||||
func (m *DailyPlanMutation) DockCodesCleared() bool {
|
||||
_, ok := m.clearedFields[dailyplan.FieldDockCodes]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetDockCodes resets all changes to the "dockCodes" field.
|
||||
func (m *DailyPlanMutation) ResetDockCodes() {
|
||||
m.dockCodes = nil
|
||||
m.appenddockCodes = nil
|
||||
delete(m.clearedFields, dailyplan.FieldDockCodes)
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (m *DailyPlanMutation) SetStatus(s string) {
|
||||
m.status = &s
|
||||
@@ -2318,7 +2385,7 @@ func (m *DailyPlanMutation) Type() string {
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *DailyPlanMutation) Fields() []string {
|
||||
fields := make([]string, 0, 8)
|
||||
fields := make([]string, 0, 9)
|
||||
if m.orderNo != nil {
|
||||
fields = append(fields, dailyplan.FieldOrderNo)
|
||||
}
|
||||
@@ -2331,6 +2398,9 @@ func (m *DailyPlanMutation) Fields() []string {
|
||||
if m.completedQty != nil {
|
||||
fields = append(fields, dailyplan.FieldCompletedQty)
|
||||
}
|
||||
if m.dockCodes != nil {
|
||||
fields = append(fields, dailyplan.FieldDockCodes)
|
||||
}
|
||||
if m.status != nil {
|
||||
fields = append(fields, dailyplan.FieldStatus)
|
||||
}
|
||||
@@ -2359,6 +2429,8 @@ func (m *DailyPlanMutation) Field(name string) (ent.Value, bool) {
|
||||
return m.PlanQty()
|
||||
case dailyplan.FieldCompletedQty:
|
||||
return m.CompletedQty()
|
||||
case dailyplan.FieldDockCodes:
|
||||
return m.DockCodes()
|
||||
case dailyplan.FieldStatus:
|
||||
return m.Status()
|
||||
case dailyplan.FieldOperator:
|
||||
@@ -2384,6 +2456,8 @@ func (m *DailyPlanMutation) OldField(ctx context.Context, name string) (ent.Valu
|
||||
return m.OldPlanQty(ctx)
|
||||
case dailyplan.FieldCompletedQty:
|
||||
return m.OldCompletedQty(ctx)
|
||||
case dailyplan.FieldDockCodes:
|
||||
return m.OldDockCodes(ctx)
|
||||
case dailyplan.FieldStatus:
|
||||
return m.OldStatus(ctx)
|
||||
case dailyplan.FieldOperator:
|
||||
@@ -2429,6 +2503,13 @@ func (m *DailyPlanMutation) SetField(name string, value ent.Value) error {
|
||||
}
|
||||
m.SetCompletedQty(v)
|
||||
return nil
|
||||
case dailyplan.FieldDockCodes:
|
||||
v, ok := value.([]string)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetDockCodes(v)
|
||||
return nil
|
||||
case dailyplan.FieldStatus:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
@@ -2514,6 +2595,9 @@ func (m *DailyPlanMutation) AddField(name string, value ent.Value) error {
|
||||
// mutation.
|
||||
func (m *DailyPlanMutation) ClearedFields() []string {
|
||||
var fields []string
|
||||
if m.FieldCleared(dailyplan.FieldDockCodes) {
|
||||
fields = append(fields, dailyplan.FieldDockCodes)
|
||||
}
|
||||
if m.FieldCleared(dailyplan.FieldUpdatedAt) {
|
||||
fields = append(fields, dailyplan.FieldUpdatedAt)
|
||||
}
|
||||
@@ -2531,6 +2615,9 @@ func (m *DailyPlanMutation) FieldCleared(name string) bool {
|
||||
// error if the field is not defined in the schema.
|
||||
func (m *DailyPlanMutation) ClearField(name string) error {
|
||||
switch name {
|
||||
case dailyplan.FieldDockCodes:
|
||||
m.ClearDockCodes()
|
||||
return nil
|
||||
case dailyplan.FieldUpdatedAt:
|
||||
m.ClearUpdatedAt()
|
||||
return nil
|
||||
@@ -2554,6 +2641,9 @@ func (m *DailyPlanMutation) ResetField(name string) error {
|
||||
case dailyplan.FieldCompletedQty:
|
||||
m.ResetCompletedQty()
|
||||
return nil
|
||||
case dailyplan.FieldDockCodes:
|
||||
m.ResetDockCodes()
|
||||
return nil
|
||||
case dailyplan.FieldStatus:
|
||||
m.ResetStatus()
|
||||
return nil
|
||||
|
||||
@@ -142,23 +142,23 @@ func init() {
|
||||
// dailyplan.DefaultCompletedQty holds the default value on creation for the completedQty field.
|
||||
dailyplan.DefaultCompletedQty = dailyplanDescCompletedQty.Default.(int)
|
||||
// dailyplanDescStatus is the schema descriptor for status field.
|
||||
dailyplanDescStatus := dailyplanFields[5].Descriptor()
|
||||
dailyplanDescStatus := dailyplanFields[6].Descriptor()
|
||||
// dailyplan.DefaultStatus holds the default value on creation for the status field.
|
||||
dailyplan.DefaultStatus = dailyplanDescStatus.Default.(string)
|
||||
// dailyplan.StatusValidator is a validator for the "status" field. It is called by the builders before save.
|
||||
dailyplan.StatusValidator = dailyplanDescStatus.Validators[0].(func(string) error)
|
||||
// dailyplanDescOperator is the schema descriptor for operator field.
|
||||
dailyplanDescOperator := dailyplanFields[6].Descriptor()
|
||||
dailyplanDescOperator := dailyplanFields[7].Descriptor()
|
||||
// dailyplan.DefaultOperator holds the default value on creation for the operator field.
|
||||
dailyplan.DefaultOperator = dailyplanDescOperator.Default.(string)
|
||||
// dailyplan.OperatorValidator is a validator for the "operator" field. It is called by the builders before save.
|
||||
dailyplan.OperatorValidator = dailyplanDescOperator.Validators[0].(func(string) error)
|
||||
// dailyplanDescCreatedAt is the schema descriptor for createdAt field.
|
||||
dailyplanDescCreatedAt := dailyplanFields[7].Descriptor()
|
||||
dailyplanDescCreatedAt := dailyplanFields[8].Descriptor()
|
||||
// dailyplan.DefaultCreatedAt holds the default value on creation for the createdAt field.
|
||||
dailyplan.DefaultCreatedAt = dailyplanDescCreatedAt.Default.(func() time.Time)
|
||||
// dailyplanDescUpdatedAt is the schema descriptor for updatedAt field.
|
||||
dailyplanDescUpdatedAt := dailyplanFields[8].Descriptor()
|
||||
dailyplanDescUpdatedAt := dailyplanFields[9].Descriptor()
|
||||
// dailyplan.DefaultUpdatedAt holds the default value on creation for the updatedAt field.
|
||||
dailyplan.DefaultUpdatedAt = dailyplanDescUpdatedAt.Default.(func() time.Time)
|
||||
// dailyplan.UpdateDefaultUpdatedAt holds the default value on update for the updatedAt field.
|
||||
|
||||
Reference in New Issue
Block a user