feat:多项功能优化

This commit is contained in:
zhoujianjin
2026-09-18 18:54:54 +08:00
parent 672cd23329
commit 543655d441
48 changed files with 1289 additions and 447 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ type BomItem struct {
ID int `json:"id,omitempty"`
// 产品编码
ProductCode string `json:"productCode,omitempty"`
// BOM名称:同一型号多份并存(如 厂家A/厂家B/含半成品),工单按名选用
// 物料清单名称:同一型号多份并存(如 厂家A/厂家B/含半成品),工单按名选用
BomName string `json:"bomName,omitempty"`
// 物料编码
MaterialCode string `json:"materialCode,omitempty"`
+1 -1
View File
@@ -18,7 +18,7 @@ type InspectionRecord struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// 记录类型 CHECKIN/POINT/PROCESS/DONE/ALARM/INCOMING/FINAL
// 记录类型 CHECKIN/POINT/PROCESS/DONE/ALARM/INCOMING/FINAL/QC_PROCESS
Category string `json:"category,omitempty"`
// 工位号
StationNo string `json:"stationNo,omitempty"`
+2
View File
@@ -689,6 +689,8 @@ var (
{Name: "flow_id", Type: field.TypeInt, Nullable: true},
{Name: "station_type", Type: field.TypeString, Size: 20, Default: "LINE"},
{Name: "status", Type: field.TypeString, Size: 20, Default: "ENABLED"},
{Name: "is_builtin", Type: field.TypeBool, Default: false},
{Name: "has_dock", Type: field.TypeBool, Default: false},
{Name: "created_at", Type: field.TypeTime},
}
// StationTable holds the schema information for the "station" table.
+109 -1
View File
@@ -17429,6 +17429,8 @@ type StationMutation struct {
addflowId *int
stationType *string
status *string
isBuiltin *bool
hasDock *bool
createdAt *time.Time
clearedFields map[string]struct{}
done bool
@@ -17774,6 +17776,78 @@ func (m *StationMutation) ResetStatus() {
m.status = nil
}
// SetIsBuiltin sets the "isBuiltin" field.
func (m *StationMutation) SetIsBuiltin(b bool) {
m.isBuiltin = &b
}
// IsBuiltin returns the value of the "isBuiltin" field in the mutation.
func (m *StationMutation) IsBuiltin() (r bool, exists bool) {
v := m.isBuiltin
if v == nil {
return
}
return *v, true
}
// OldIsBuiltin returns the old "isBuiltin" field's value of the Station entity.
// If the Station 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 *StationMutation) OldIsBuiltin(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldIsBuiltin is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldIsBuiltin requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldIsBuiltin: %w", err)
}
return oldValue.IsBuiltin, nil
}
// ResetIsBuiltin resets all changes to the "isBuiltin" field.
func (m *StationMutation) ResetIsBuiltin() {
m.isBuiltin = nil
}
// SetHasDock sets the "hasDock" field.
func (m *StationMutation) SetHasDock(b bool) {
m.hasDock = &b
}
// HasDock returns the value of the "hasDock" field in the mutation.
func (m *StationMutation) HasDock() (r bool, exists bool) {
v := m.hasDock
if v == nil {
return
}
return *v, true
}
// OldHasDock returns the old "hasDock" field's value of the Station entity.
// If the Station 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 *StationMutation) OldHasDock(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldHasDock is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldHasDock requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldHasDock: %w", err)
}
return oldValue.HasDock, nil
}
// ResetHasDock resets all changes to the "hasDock" field.
func (m *StationMutation) ResetHasDock() {
m.hasDock = nil
}
// SetCreatedAt sets the "createdAt" field.
func (m *StationMutation) SetCreatedAt(t time.Time) {
m.createdAt = &t
@@ -17844,7 +17918,7 @@ func (m *StationMutation) Type() string {
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *StationMutation) Fields() []string {
fields := make([]string, 0, 6)
fields := make([]string, 0, 8)
if m.stationNo != nil {
fields = append(fields, station.FieldStationNo)
}
@@ -17860,6 +17934,12 @@ func (m *StationMutation) Fields() []string {
if m.status != nil {
fields = append(fields, station.FieldStatus)
}
if m.isBuiltin != nil {
fields = append(fields, station.FieldIsBuiltin)
}
if m.hasDock != nil {
fields = append(fields, station.FieldHasDock)
}
if m.createdAt != nil {
fields = append(fields, station.FieldCreatedAt)
}
@@ -17881,6 +17961,10 @@ func (m *StationMutation) Field(name string) (ent.Value, bool) {
return m.StationType()
case station.FieldStatus:
return m.Status()
case station.FieldIsBuiltin:
return m.IsBuiltin()
case station.FieldHasDock:
return m.HasDock()
case station.FieldCreatedAt:
return m.CreatedAt()
}
@@ -17902,6 +17986,10 @@ func (m *StationMutation) OldField(ctx context.Context, name string) (ent.Value,
return m.OldStationType(ctx)
case station.FieldStatus:
return m.OldStatus(ctx)
case station.FieldIsBuiltin:
return m.OldIsBuiltin(ctx)
case station.FieldHasDock:
return m.OldHasDock(ctx)
case station.FieldCreatedAt:
return m.OldCreatedAt(ctx)
}
@@ -17948,6 +18036,20 @@ func (m *StationMutation) SetField(name string, value ent.Value) error {
}
m.SetStatus(v)
return nil
case station.FieldIsBuiltin:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetIsBuiltin(v)
return nil
case station.FieldHasDock:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetHasDock(v)
return nil
case station.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
@@ -18055,6 +18157,12 @@ func (m *StationMutation) ResetField(name string) error {
case station.FieldStatus:
m.ResetStatus()
return nil
case station.FieldIsBuiltin:
m.ResetIsBuiltin()
return nil
case station.FieldHasDock:
m.ResetHasDock()
return nil
case station.FieldCreatedAt:
m.ResetCreatedAt()
return nil
+9 -1
View File
@@ -1077,8 +1077,16 @@ func init() {
station.DefaultStatus = stationDescStatus.Default.(string)
// station.StatusValidator is a validator for the "status" field. It is called by the builders before save.
station.StatusValidator = stationDescStatus.Validators[0].(func(string) error)
// stationDescIsBuiltin is the schema descriptor for isBuiltin field.
stationDescIsBuiltin := stationFields[6].Descriptor()
// station.DefaultIsBuiltin holds the default value on creation for the isBuiltin field.
station.DefaultIsBuiltin = stationDescIsBuiltin.Default.(bool)
// stationDescHasDock is the schema descriptor for hasDock field.
stationDescHasDock := stationFields[7].Descriptor()
// station.DefaultHasDock holds the default value on creation for the hasDock field.
station.DefaultHasDock = stationDescHasDock.Default.(bool)
// stationDescCreatedAt is the schema descriptor for createdAt field.
stationDescCreatedAt := stationFields[6].Descriptor()
stationDescCreatedAt := stationFields[8].Descriptor()
// station.DefaultCreatedAt holds the default value on creation for the createdAt field.
station.DefaultCreatedAt = stationDescCreatedAt.Default.(func() time.Time)
// stationDescID is the schema descriptor for id field.
+24
View File
@@ -27,6 +27,10 @@ type Station struct {
StationType string `json:"stationType,omitempty"`
// Status holds the value of the "status" field.
Status string `json:"status,omitempty"`
// 内置工位:不可改类型/不可删除
IsBuiltin bool `json:"isBuiltin,omitempty"`
// 是否有接驳台(实体位置,内置不可改)
HasDock bool `json:"hasDock,omitempty"`
// CreatedAt holds the value of the "createdAt" field.
CreatedAt time.Time `json:"createdAt,omitempty"`
selectValues sql.SelectValues
@@ -37,6 +41,8 @@ func (*Station) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case station.FieldIsBuiltin, station.FieldHasDock:
values[i] = new(sql.NullBool)
case station.FieldID, station.FieldStationNo, station.FieldFlowId:
values[i] = new(sql.NullInt64)
case station.FieldName, station.FieldStationType, station.FieldStatus:
@@ -94,6 +100,18 @@ func (_m *Station) assignValues(columns []string, values []any) error {
} else if value.Valid {
_m.Status = value.String
}
case station.FieldIsBuiltin:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field isBuiltin", values[i])
} else if value.Valid {
_m.IsBuiltin = value.Bool
}
case station.FieldHasDock:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field hasDock", values[i])
} else if value.Valid {
_m.HasDock = value.Bool
}
case station.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field createdAt", values[i])
@@ -151,6 +169,12 @@ func (_m *Station) String() string {
builder.WriteString("status=")
builder.WriteString(_m.Status)
builder.WriteString(", ")
builder.WriteString("isBuiltin=")
builder.WriteString(fmt.Sprintf("%v", _m.IsBuiltin))
builder.WriteString(", ")
builder.WriteString("hasDock=")
builder.WriteString(fmt.Sprintf("%v", _m.HasDock))
builder.WriteString(", ")
builder.WriteString("createdAt=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
builder.WriteByte(')')
+20
View File
@@ -23,6 +23,10 @@ const (
FieldStationType = "station_type"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
// FieldIsBuiltin holds the string denoting the isbuiltin field in the database.
FieldIsBuiltin = "is_builtin"
// FieldHasDock holds the string denoting the hasdock field in the database.
FieldHasDock = "has_dock"
// FieldCreatedAt holds the string denoting the createdat field in the database.
FieldCreatedAt = "created_at"
// Table holds the table name of the station in the database.
@@ -37,6 +41,8 @@ var Columns = []string{
FieldFlowId,
FieldStationType,
FieldStatus,
FieldIsBuiltin,
FieldHasDock,
FieldCreatedAt,
}
@@ -63,6 +69,10 @@ var (
DefaultStatus string
// StatusValidator is a validator for the "status" field. It is called by the builders before save.
StatusValidator func(string) error
// DefaultIsBuiltin holds the default value on creation for the "isBuiltin" field.
DefaultIsBuiltin bool
// DefaultHasDock holds the default value on creation for the "hasDock" field.
DefaultHasDock bool
// DefaultCreatedAt holds the default value on creation for the "createdAt" field.
DefaultCreatedAt func() time.Time
// IDValidator is a validator for the "id" field. It is called by the builders before save.
@@ -102,6 +112,16 @@ func ByStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStatus, opts...).ToFunc()
}
// ByIsBuiltin orders the results by the isBuiltin field.
func ByIsBuiltin(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldIsBuiltin, opts...).ToFunc()
}
// ByHasDock orders the results by the hasDock field.
func ByHasDock(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldHasDock, opts...).ToFunc()
}
// ByCreatedAt orders the results by the createdAt field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
+30
View File
@@ -79,6 +79,16 @@ func Status(v string) predicate.Station {
return predicate.Station(sql.FieldEQ(FieldStatus, v))
}
// IsBuiltin applies equality check predicate on the "isBuiltin" field. It's identical to IsBuiltinEQ.
func IsBuiltin(v bool) predicate.Station {
return predicate.Station(sql.FieldEQ(FieldIsBuiltin, v))
}
// HasDock applies equality check predicate on the "hasDock" field. It's identical to HasDockEQ.
func HasDock(v bool) predicate.Station {
return predicate.Station(sql.FieldEQ(FieldHasDock, v))
}
// CreatedAt applies equality check predicate on the "createdAt" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.Station {
return predicate.Station(sql.FieldEQ(FieldCreatedAt, v))
@@ -369,6 +379,26 @@ func StatusContainsFold(v string) predicate.Station {
return predicate.Station(sql.FieldContainsFold(FieldStatus, v))
}
// IsBuiltinEQ applies the EQ predicate on the "isBuiltin" field.
func IsBuiltinEQ(v bool) predicate.Station {
return predicate.Station(sql.FieldEQ(FieldIsBuiltin, v))
}
// IsBuiltinNEQ applies the NEQ predicate on the "isBuiltin" field.
func IsBuiltinNEQ(v bool) predicate.Station {
return predicate.Station(sql.FieldNEQ(FieldIsBuiltin, v))
}
// HasDockEQ applies the EQ predicate on the "hasDock" field.
func HasDockEQ(v bool) predicate.Station {
return predicate.Station(sql.FieldEQ(FieldHasDock, v))
}
// HasDockNEQ applies the NEQ predicate on the "hasDock" field.
func HasDockNEQ(v bool) predicate.Station {
return predicate.Station(sql.FieldNEQ(FieldHasDock, v))
}
// CreatedAtEQ applies the EQ predicate on the "createdAt" field.
func CreatedAtEQ(v time.Time) predicate.Station {
return predicate.Station(sql.FieldEQ(FieldCreatedAt, v))
+50
View File
@@ -82,6 +82,34 @@ func (_c *StationCreate) SetNillableStatus(v *string) *StationCreate {
return _c
}
// SetIsBuiltin sets the "isBuiltin" field.
func (_c *StationCreate) SetIsBuiltin(v bool) *StationCreate {
_c.mutation.SetIsBuiltin(v)
return _c
}
// SetNillableIsBuiltin sets the "isBuiltin" field if the given value is not nil.
func (_c *StationCreate) SetNillableIsBuiltin(v *bool) *StationCreate {
if v != nil {
_c.SetIsBuiltin(*v)
}
return _c
}
// SetHasDock sets the "hasDock" field.
func (_c *StationCreate) SetHasDock(v bool) *StationCreate {
_c.mutation.SetHasDock(v)
return _c
}
// SetNillableHasDock sets the "hasDock" field if the given value is not nil.
func (_c *StationCreate) SetNillableHasDock(v *bool) *StationCreate {
if v != nil {
_c.SetHasDock(*v)
}
return _c
}
// SetCreatedAt sets the "createdAt" field.
func (_c *StationCreate) SetCreatedAt(v time.Time) *StationCreate {
_c.mutation.SetCreatedAt(v)
@@ -149,6 +177,14 @@ func (_c *StationCreate) defaults() {
v := station.DefaultStatus
_c.mutation.SetStatus(v)
}
if _, ok := _c.mutation.IsBuiltin(); !ok {
v := station.DefaultIsBuiltin
_c.mutation.SetIsBuiltin(v)
}
if _, ok := _c.mutation.HasDock(); !ok {
v := station.DefaultHasDock
_c.mutation.SetHasDock(v)
}
if _, ok := _c.mutation.CreatedAt(); !ok {
v := station.DefaultCreatedAt()
_c.mutation.SetCreatedAt(v)
@@ -184,6 +220,12 @@ func (_c *StationCreate) check() error {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Station.status": %w`, err)}
}
}
if _, ok := _c.mutation.IsBuiltin(); !ok {
return &ValidationError{Name: "isBuiltin", err: errors.New(`ent: missing required field "Station.isBuiltin"`)}
}
if _, ok := _c.mutation.HasDock(); !ok {
return &ValidationError{Name: "hasDock", err: errors.New(`ent: missing required field "Station.hasDock"`)}
}
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "createdAt", err: errors.New(`ent: missing required field "Station.createdAt"`)}
}
@@ -244,6 +286,14 @@ func (_c *StationCreate) createSpec() (*Station, *sqlgraph.CreateSpec) {
_spec.SetField(station.FieldStatus, field.TypeString, value)
_node.Status = value
}
if value, ok := _c.mutation.IsBuiltin(); ok {
_spec.SetField(station.FieldIsBuiltin, field.TypeBool, value)
_node.IsBuiltin = value
}
if value, ok := _c.mutation.HasDock(); ok {
_spec.SetField(station.FieldHasDock, field.TypeBool, value)
_node.HasDock = value
}
if value, ok := _c.mutation.CreatedAt(); ok {
_spec.SetField(station.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
+68
View File
@@ -118,6 +118,34 @@ func (_u *StationUpdate) SetNillableStatus(v *string) *StationUpdate {
return _u
}
// SetIsBuiltin sets the "isBuiltin" field.
func (_u *StationUpdate) SetIsBuiltin(v bool) *StationUpdate {
_u.mutation.SetIsBuiltin(v)
return _u
}
// SetNillableIsBuiltin sets the "isBuiltin" field if the given value is not nil.
func (_u *StationUpdate) SetNillableIsBuiltin(v *bool) *StationUpdate {
if v != nil {
_u.SetIsBuiltin(*v)
}
return _u
}
// SetHasDock sets the "hasDock" field.
func (_u *StationUpdate) SetHasDock(v bool) *StationUpdate {
_u.mutation.SetHasDock(v)
return _u
}
// SetNillableHasDock sets the "hasDock" field if the given value is not nil.
func (_u *StationUpdate) SetNillableHasDock(v *bool) *StationUpdate {
if v != nil {
_u.SetHasDock(*v)
}
return _u
}
// Mutation returns the StationMutation object of the builder.
func (_u *StationUpdate) Mutation() *StationMutation {
return _u.mutation
@@ -212,6 +240,12 @@ func (_u *StationUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if value, ok := _u.mutation.Status(); ok {
_spec.SetField(station.FieldStatus, field.TypeString, value)
}
if value, ok := _u.mutation.IsBuiltin(); ok {
_spec.SetField(station.FieldIsBuiltin, field.TypeBool, value)
}
if value, ok := _u.mutation.HasDock(); ok {
_spec.SetField(station.FieldHasDock, field.TypeBool, value)
}
_spec.AddModifiers(_u.modifiers...)
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
@@ -324,6 +358,34 @@ func (_u *StationUpdateOne) SetNillableStatus(v *string) *StationUpdateOne {
return _u
}
// SetIsBuiltin sets the "isBuiltin" field.
func (_u *StationUpdateOne) SetIsBuiltin(v bool) *StationUpdateOne {
_u.mutation.SetIsBuiltin(v)
return _u
}
// SetNillableIsBuiltin sets the "isBuiltin" field if the given value is not nil.
func (_u *StationUpdateOne) SetNillableIsBuiltin(v *bool) *StationUpdateOne {
if v != nil {
_u.SetIsBuiltin(*v)
}
return _u
}
// SetHasDock sets the "hasDock" field.
func (_u *StationUpdateOne) SetHasDock(v bool) *StationUpdateOne {
_u.mutation.SetHasDock(v)
return _u
}
// SetNillableHasDock sets the "hasDock" field if the given value is not nil.
func (_u *StationUpdateOne) SetNillableHasDock(v *bool) *StationUpdateOne {
if v != nil {
_u.SetHasDock(*v)
}
return _u
}
// Mutation returns the StationMutation object of the builder.
func (_u *StationUpdateOne) Mutation() *StationMutation {
return _u.mutation
@@ -448,6 +510,12 @@ func (_u *StationUpdateOne) sqlSave(ctx context.Context) (_node *Station, err er
if value, ok := _u.mutation.Status(); ok {
_spec.SetField(station.FieldStatus, field.TypeString, value)
}
if value, ok := _u.mutation.IsBuiltin(); ok {
_spec.SetField(station.FieldIsBuiltin, field.TypeBool, value)
}
if value, ok := _u.mutation.HasDock(); ok {
_spec.SetField(station.FieldHasDock, field.TypeBool, value)
}
_spec.AddModifiers(_u.modifiers...)
_node = &Station{config: _u.config}
_spec.Assign = _node.assignValues