【全系统 · 接驳台编码终版统一(12-01 用户拍板)】
- 新增 dockcode 包作为唯一真源:工位接驳台 = GW{工位号}{Z|Y}(Z=左/Y=右,工位1~10同一规则,废除左右互换),库房 = JBT21 不变
- 编码即海康 RCS 地图点位码:落库/界面/下发 RCS/读 PLC 传感器全用同一套;旧 DOCK01~20 全量废弃,系统内无第二套编号、无换算层
- dock 表去 side 字段;agv_task.target_dock、line_point、看板点位态与中文名、dockLabel 工具全部改 GW 规则
- 产线布局说明.md 同步终版(图纸名 GxZ/GxY 与 AGV 码 GWxZ/GWxY 一一对应;注明 RCS 图与主线流向图相差 180°,读图一律以 GW 码为准)
【MES · 签字模型二次重构(11-30 实测后定稿)】
- _OPERATOR 签字整体废除:工艺步骤删 needOperatorSign / needAudit / auditRole 字段,签字角色改 CALL(工人报检呼叫)+ INSPECTOR(检验员审核签)
- 呼叫时落步骤录入快照(stepValue/stepText/stepChecked/processId),供检验员查看与指纹比对;「待签任务」只认检验员签名步骤
- 「签字复核」(AuditPending 页面 + produce.audit 菜单 + 路由)整套删除
【MES · 台账续流根因修复(11-30 对账发现)】
- 流转目标「G6」与 line_point.point_no「6」对不上导致到位落账查不到、却先释放源位→工件从调度消失;新增 ledgerPointByTarget 归一
- settleDirect/settleInTransit 改为先占目标位、成功才释放源位;目标被占原样保留,工件进缓存位排队(实测 C2 排队不再丢件)
【WMS · 末级库位强校验与上架移库】
- 新增 LocationCascade 四级联动选择器(区/架/层/号,只从启用 level=4 节点派生);手工入库、半成品/成品入库、隔离库位一律四级必填且命中启用节点
- 新增上架/移库 relocate:只改四级库位与 updated_at,不动质量状态/数量/锁定量;不合格与锁定行同样允许移库;支持 ids 逐行指定或 scope 按物料+原库位整组搬
- MES 新增 WMS 自动回流库位配置(半成品/成品各一组末级库位,默认值 1区/1架/1层/1号,存 sys_config 可改)
【MES · 统一口径与工程整改】
- 新增 workpiece_location:工单详情工件列表/WIP/追溯三处共用位置判定(SCRAPPED→DONE→SEMI_STORED→在 StationNo→在途→待流转)
- 新增 workorder_close_warn:工单完工/取消时汇总各工位实物余料出一条预警,不阻断关单
- 分页下沉:新增 pagination 工具,同步失败台账(两端)改 Count+LIMIT/OFFSET 真分页,列表不再全量切片
- 全网对账/孤儿扫描(问题临时.md 第25/26节):10 类关系边断言实测,给出 8 条可重复巡检项
【文档】
- 产线布局说明.md 按 GW 编码终版重写;问题临时.md 新增 24.7 闭环实测、25 全网对账、26 补料→配送→报工人库闭环
401 lines
12 KiB
Go
401 lines
12 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_mes/ent/processstep"
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// ProcessStepCreate is the builder for creating a ProcessStep entity.
|
|
type ProcessStepCreate struct {
|
|
config
|
|
mutation *ProcessStepMutation
|
|
hooks []Hook
|
|
}
|
|
|
|
// SetFlowId sets the "flowId" field.
|
|
func (_c *ProcessStepCreate) SetFlowId(v int) *ProcessStepCreate {
|
|
_c.mutation.SetFlowId(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableFlowId sets the "flowId" field if the given value is not nil.
|
|
func (_c *ProcessStepCreate) SetNillableFlowId(v *int) *ProcessStepCreate {
|
|
if v != nil {
|
|
_c.SetFlowId(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetSeq sets the "seq" field.
|
|
func (_c *ProcessStepCreate) SetSeq(v int) *ProcessStepCreate {
|
|
_c.mutation.SetSeq(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableSeq sets the "seq" field if the given value is not nil.
|
|
func (_c *ProcessStepCreate) SetNillableSeq(v *int) *ProcessStepCreate {
|
|
if v != nil {
|
|
_c.SetSeq(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_c *ProcessStepCreate) SetName(v string) *ProcessStepCreate {
|
|
_c.mutation.SetName(v)
|
|
return _c
|
|
}
|
|
|
|
// SetCollectType sets the "collectType" field.
|
|
func (_c *ProcessStepCreate) SetCollectType(v string) *ProcessStepCreate {
|
|
_c.mutation.SetCollectType(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCollectType sets the "collectType" field if the given value is not nil.
|
|
func (_c *ProcessStepCreate) SetNillableCollectType(v *string) *ProcessStepCreate {
|
|
if v != nil {
|
|
_c.SetCollectType(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetNeedCheck sets the "needCheck" field.
|
|
func (_c *ProcessStepCreate) SetNeedCheck(v bool) *ProcessStepCreate {
|
|
_c.mutation.SetNeedCheck(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableNeedCheck sets the "needCheck" field if the given value is not nil.
|
|
func (_c *ProcessStepCreate) SetNillableNeedCheck(v *bool) *ProcessStepCreate {
|
|
if v != nil {
|
|
_c.SetNeedCheck(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetNeedInspectorSign sets the "needInspectorSign" field.
|
|
func (_c *ProcessStepCreate) SetNeedInspectorSign(v bool) *ProcessStepCreate {
|
|
_c.mutation.SetNeedInspectorSign(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableNeedInspectorSign sets the "needInspectorSign" field if the given value is not nil.
|
|
func (_c *ProcessStepCreate) SetNillableNeedInspectorSign(v *bool) *ProcessStepCreate {
|
|
if v != nil {
|
|
_c.SetNeedInspectorSign(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetAttachment sets the "attachment" field.
|
|
func (_c *ProcessStepCreate) SetAttachment(v []map[string]string) *ProcessStepCreate {
|
|
_c.mutation.SetAttachment(v)
|
|
return _c
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (_c *ProcessStepCreate) SetRemark(v string) *ProcessStepCreate {
|
|
_c.mutation.SetRemark(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
|
func (_c *ProcessStepCreate) SetNillableRemark(v *string) *ProcessStepCreate {
|
|
if v != nil {
|
|
_c.SetRemark(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCreatedAt sets the "createdAt" field.
|
|
func (_c *ProcessStepCreate) SetCreatedAt(v time.Time) *ProcessStepCreate {
|
|
_c.mutation.SetCreatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "createdAt" field if the given value is not nil.
|
|
func (_c *ProcessStepCreate) SetNillableCreatedAt(v *time.Time) *ProcessStepCreate {
|
|
if v != nil {
|
|
_c.SetCreatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetID sets the "id" field.
|
|
func (_c *ProcessStepCreate) SetID(v int) *ProcessStepCreate {
|
|
_c.mutation.SetID(v)
|
|
return _c
|
|
}
|
|
|
|
// Mutation returns the ProcessStepMutation object of the builder.
|
|
func (_c *ProcessStepCreate) Mutation() *ProcessStepMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the ProcessStep in the database.
|
|
func (_c *ProcessStepCreate) Save(ctx context.Context) (*ProcessStep, error) {
|
|
_c.defaults()
|
|
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (_c *ProcessStepCreate) SaveX(ctx context.Context) *ProcessStep {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *ProcessStepCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *ProcessStepCreate) ExecX(ctx context.Context) {
|
|
if err := _c.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_c *ProcessStepCreate) defaults() {
|
|
if _, ok := _c.mutation.Seq(); !ok {
|
|
v := processstep.DefaultSeq
|
|
_c.mutation.SetSeq(v)
|
|
}
|
|
if _, ok := _c.mutation.CollectType(); !ok {
|
|
v := processstep.DefaultCollectType
|
|
_c.mutation.SetCollectType(v)
|
|
}
|
|
if _, ok := _c.mutation.NeedCheck(); !ok {
|
|
v := processstep.DefaultNeedCheck
|
|
_c.mutation.SetNeedCheck(v)
|
|
}
|
|
if _, ok := _c.mutation.NeedInspectorSign(); !ok {
|
|
v := processstep.DefaultNeedInspectorSign
|
|
_c.mutation.SetNeedInspectorSign(v)
|
|
}
|
|
if _, ok := _c.mutation.Remark(); !ok {
|
|
v := processstep.DefaultRemark
|
|
_c.mutation.SetRemark(v)
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
v := processstep.DefaultCreatedAt()
|
|
_c.mutation.SetCreatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *ProcessStepCreate) check() error {
|
|
if _, ok := _c.mutation.Seq(); !ok {
|
|
return &ValidationError{Name: "seq", err: errors.New(`ent: missing required field "ProcessStep.seq"`)}
|
|
}
|
|
if _, ok := _c.mutation.Name(); !ok {
|
|
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "ProcessStep.name"`)}
|
|
}
|
|
if v, ok := _c.mutation.Name(); ok {
|
|
if err := processstep.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ProcessStep.name": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.CollectType(); !ok {
|
|
return &ValidationError{Name: "collectType", err: errors.New(`ent: missing required field "ProcessStep.collectType"`)}
|
|
}
|
|
if v, ok := _c.mutation.CollectType(); ok {
|
|
if err := processstep.CollectTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "collectType", err: fmt.Errorf(`ent: validator failed for field "ProcessStep.collectType": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.NeedCheck(); !ok {
|
|
return &ValidationError{Name: "needCheck", err: errors.New(`ent: missing required field "ProcessStep.needCheck"`)}
|
|
}
|
|
if _, ok := _c.mutation.NeedInspectorSign(); !ok {
|
|
return &ValidationError{Name: "needInspectorSign", err: errors.New(`ent: missing required field "ProcessStep.needInspectorSign"`)}
|
|
}
|
|
if _, ok := _c.mutation.Remark(); !ok {
|
|
return &ValidationError{Name: "remark", err: errors.New(`ent: missing required field "ProcessStep.remark"`)}
|
|
}
|
|
if v, ok := _c.mutation.Remark(); ok {
|
|
if err := processstep.RemarkValidator(v); err != nil {
|
|
return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "ProcessStep.remark": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "createdAt", err: errors.New(`ent: missing required field "ProcessStep.createdAt"`)}
|
|
}
|
|
if v, ok := _c.mutation.ID(); ok {
|
|
if err := processstep.IDValidator(v); err != nil {
|
|
return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "ProcessStep.id": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *ProcessStepCreate) sqlSave(ctx context.Context) (*ProcessStep, error) {
|
|
if err := _c.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
_node, _spec := _c.createSpec()
|
|
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
if _spec.ID.Value != _node.ID {
|
|
id := _spec.ID.Value.(int64)
|
|
_node.ID = int(id)
|
|
}
|
|
_c.mutation.id = &_node.ID
|
|
_c.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
func (_c *ProcessStepCreate) createSpec() (*ProcessStep, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &ProcessStep{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(processstep.Table, sqlgraph.NewFieldSpec(processstep.FieldID, field.TypeInt))
|
|
)
|
|
if id, ok := _c.mutation.ID(); ok {
|
|
_node.ID = id
|
|
_spec.ID.Value = id
|
|
}
|
|
if value, ok := _c.mutation.FlowId(); ok {
|
|
_spec.SetField(processstep.FieldFlowId, field.TypeInt, value)
|
|
_node.FlowId = value
|
|
}
|
|
if value, ok := _c.mutation.Seq(); ok {
|
|
_spec.SetField(processstep.FieldSeq, field.TypeInt, value)
|
|
_node.Seq = value
|
|
}
|
|
if value, ok := _c.mutation.Name(); ok {
|
|
_spec.SetField(processstep.FieldName, field.TypeString, value)
|
|
_node.Name = value
|
|
}
|
|
if value, ok := _c.mutation.CollectType(); ok {
|
|
_spec.SetField(processstep.FieldCollectType, field.TypeString, value)
|
|
_node.CollectType = value
|
|
}
|
|
if value, ok := _c.mutation.NeedCheck(); ok {
|
|
_spec.SetField(processstep.FieldNeedCheck, field.TypeBool, value)
|
|
_node.NeedCheck = value
|
|
}
|
|
if value, ok := _c.mutation.NeedInspectorSign(); ok {
|
|
_spec.SetField(processstep.FieldNeedInspectorSign, field.TypeBool, value)
|
|
_node.NeedInspectorSign = value
|
|
}
|
|
if value, ok := _c.mutation.Attachment(); ok {
|
|
_spec.SetField(processstep.FieldAttachment, field.TypeJSON, value)
|
|
_node.Attachment = value
|
|
}
|
|
if value, ok := _c.mutation.Remark(); ok {
|
|
_spec.SetField(processstep.FieldRemark, field.TypeString, value)
|
|
_node.Remark = value
|
|
}
|
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
|
_spec.SetField(processstep.FieldCreatedAt, field.TypeTime, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
return _node, _spec
|
|
}
|
|
|
|
// ProcessStepCreateBulk is the builder for creating many ProcessStep entities in bulk.
|
|
type ProcessStepCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*ProcessStepCreate
|
|
}
|
|
|
|
// Save creates the ProcessStep entities in the database.
|
|
func (_c *ProcessStepCreateBulk) Save(ctx context.Context) ([]*ProcessStep, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*ProcessStep, len(_c.builders))
|
|
mutators := make([]Mutator, len(_c.builders))
|
|
for i := range _c.builders {
|
|
func(i int, root context.Context) {
|
|
builder := _c.builders[i]
|
|
builder.defaults()
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*ProcessStepMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
if err := builder.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
builder.mutation = mutation
|
|
var err error
|
|
nodes[i], specs[i] = builder.createSpec()
|
|
if i < len(mutators)-1 {
|
|
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
|
} else {
|
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
|
// Invoke the actual operation on the latest mutation in the chain.
|
|
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
}
|
|
}
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
mutation.id = &nodes[i].ID
|
|
if specs[i].ID.Value != nil && nodes[i].ID == 0 {
|
|
id := specs[i].ID.Value.(int64)
|
|
nodes[i].ID = int(id)
|
|
}
|
|
mutation.done = true
|
|
return nodes[i], nil
|
|
})
|
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
|
mut = builder.hooks[i](mut)
|
|
}
|
|
mutators[i] = mut
|
|
}(i, ctx)
|
|
}
|
|
if len(mutators) > 0 {
|
|
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return nodes, nil
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_c *ProcessStepCreateBulk) SaveX(ctx context.Context) []*ProcessStep {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *ProcessStepCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *ProcessStepCreateBulk) ExecX(ctx context.Context) {
|
|
if err := _c.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|