一、AGV 挂起动作引擎(弃显式任务队列、弃并发硬拒) - 新增 internal/logic/agv_pending.go:待发动作直接挂任务(pending_action + pending_since), CONTINUE_LIFT(举升完成→continueTask#1)/ WAIT_DROP_CONFIRM(人工确认放下→continueTask#2) / FREE_ROBOT(末组完成→freeRobot);系统动作超 60s 未触发转预警人工重试,绝不自动重发 - Client 新增 ContinueTask(RCS 2.1.2) / FreeRobot(3.1.2),仅点名释放指定车,禁止释放全部 - agv_task 增 pending_action/pending_since 字段,ent 重生成 + db.go 幂等迁移补丁 + migrateonce - 回调按 B01/B02/C01 模板编排:业务流转到位即自动放行放下、回调自动放车; 仅人工派车(MANUAL)挂 WAIT_DROP_CONFIRM;新增 /agv/confirm-drop、/agv/pending/retry - 前端 AgvManual/Agv 确认放下、挂起重试按钮与等待提示联动 二、智能跟车 + 动态目标截断流转引擎 - 新增 internal/logic/flow_engine.go:事件驱动(报工/扫码),读 48 位物理快照,从下游往上游算, 前方占用则动态截断到最近空闲缓存位;IN_TRANSIT 在途闭锁防重复下发,MW=0 才确认到位落台账; 主线占用=台账 OR 传感器,工位 G 位只认台账;在途超 5s 落预警 - workpiece 增 flow_transit_mw/target/at 字段,ent 重生成 + 迁移补丁 三、PLC 读取优化与诊断 - 新增 internal/plc/snapshot_cache.go:2s TTL + singleflight + 写失效,合并 SSE/PLC监控/流转引擎 的重复点位读取;tcp.go 读块重构、localip.go 多网卡、plcdiag 诊断工具、plc_monitor/logging 配套 四、文档与前端 - help.js 重写「工位下发」帮助:明确报工自动驱动流转 vs 下发路线码的定位、缺料/握手/撤回边界 - 案例.md 补充定稿说明;public/index.html 构建指纹更新
292 lines
10 KiB
Go
292 lines
10 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"bj_power_mes/ent/workpiece"
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
)
|
|
|
|
// Workpiece 工件(SN):序列号管理的成品/主件
|
|
type Workpiece struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int `json:"id,omitempty"`
|
|
// 工件唯一SN
|
|
Sn string `json:"sn,omitempty"`
|
|
// 所属工单
|
|
OrderNo string `json:"orderNo,omitempty"`
|
|
// 工单ID
|
|
WorkOrderId int `json:"workOrderId,omitempty"`
|
|
// 业务位置:最后完成报工的工位号(0=未报任何工艺;下一道=工艺组合中工位号更大的下一条)
|
|
CurrentStationNo int `json:"currentStationNo,omitempty"`
|
|
// 物理位置:工件当前实际所在工位号(0=未在工位;建档/到达即写,完工/入库清空)
|
|
AtStationNo int `json:"atStationNo,omitempty"`
|
|
// Status holds the value of the "status" field.
|
|
Status string `json:"status,omitempty"`
|
|
// 进线时间
|
|
OnlineAt *time.Time `json:"onlineAt,omitempty"`
|
|
// 完工时间
|
|
DoneAt *time.Time `json:"doneAt,omitempty"`
|
|
// CreatedAt holds the value of the "createdAt" field.
|
|
CreatedAt time.Time `json:"createdAt,omitempty"`
|
|
// UpdatedAt holds the value of the "updatedAt" field.
|
|
UpdatedAt *time.Time `json:"updatedAt,omitempty"`
|
|
// 拧紧扭矩不合格待人工处置标记
|
|
TorqueNgPending bool `json:"torque_ng_pending,omitempty"`
|
|
// 拧紧不合格标记时间
|
|
TorqueNgAt *time.Time `json:"torque_ng_at,omitempty"`
|
|
// 拧紧不合格标记操作人
|
|
TorqueNgBy *string `json:"torque_ng_by,omitempty"`
|
|
// 流转在途MW地址(0=无在途;>0=已下发未确认到位)
|
|
FlowTransitMW int `json:"flowTransitMW,omitempty"`
|
|
// 流转在途目标点位编号(如 C3 / G9)
|
|
FlowTransitTarget string `json:"flowTransitTarget,omitempty"`
|
|
// 流转指令下发时刻(到位确认超时判定)
|
|
FlowTransitAt *time.Time `json:"flowTransitAt,omitempty"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*Workpiece) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case workpiece.FieldTorqueNgPending:
|
|
values[i] = new(sql.NullBool)
|
|
case workpiece.FieldID, workpiece.FieldWorkOrderId, workpiece.FieldCurrentStationNo, workpiece.FieldAtStationNo, workpiece.FieldFlowTransitMW:
|
|
values[i] = new(sql.NullInt64)
|
|
case workpiece.FieldSn, workpiece.FieldOrderNo, workpiece.FieldStatus, workpiece.FieldTorqueNgBy, workpiece.FieldFlowTransitTarget:
|
|
values[i] = new(sql.NullString)
|
|
case workpiece.FieldOnlineAt, workpiece.FieldDoneAt, workpiece.FieldCreatedAt, workpiece.FieldUpdatedAt, workpiece.FieldTorqueNgAt, workpiece.FieldFlowTransitAt:
|
|
values[i] = new(sql.NullTime)
|
|
default:
|
|
values[i] = new(sql.UnknownType)
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the Workpiece fields.
|
|
func (_m *Workpiece) 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 workpiece.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 workpiece.FieldSn:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field sn", values[i])
|
|
} else if value.Valid {
|
|
_m.Sn = value.String
|
|
}
|
|
case workpiece.FieldOrderNo:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field orderNo", values[i])
|
|
} else if value.Valid {
|
|
_m.OrderNo = value.String
|
|
}
|
|
case workpiece.FieldWorkOrderId:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field workOrderId", values[i])
|
|
} else if value.Valid {
|
|
_m.WorkOrderId = int(value.Int64)
|
|
}
|
|
case workpiece.FieldCurrentStationNo:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field currentStationNo", values[i])
|
|
} else if value.Valid {
|
|
_m.CurrentStationNo = int(value.Int64)
|
|
}
|
|
case workpiece.FieldAtStationNo:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field atStationNo", values[i])
|
|
} else if value.Valid {
|
|
_m.AtStationNo = int(value.Int64)
|
|
}
|
|
case workpiece.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 workpiece.FieldOnlineAt:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field onlineAt", values[i])
|
|
} else if value.Valid {
|
|
_m.OnlineAt = new(time.Time)
|
|
*_m.OnlineAt = value.Time
|
|
}
|
|
case workpiece.FieldDoneAt:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field doneAt", values[i])
|
|
} else if value.Valid {
|
|
_m.DoneAt = new(time.Time)
|
|
*_m.DoneAt = value.Time
|
|
}
|
|
case workpiece.FieldCreatedAt:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field createdAt", values[i])
|
|
} else if value.Valid {
|
|
_m.CreatedAt = value.Time
|
|
}
|
|
case workpiece.FieldUpdatedAt:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field updatedAt", values[i])
|
|
} else if value.Valid {
|
|
_m.UpdatedAt = new(time.Time)
|
|
*_m.UpdatedAt = value.Time
|
|
}
|
|
case workpiece.FieldTorqueNgPending:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field torque_ng_pending", values[i])
|
|
} else if value.Valid {
|
|
_m.TorqueNgPending = value.Bool
|
|
}
|
|
case workpiece.FieldTorqueNgAt:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field torque_ng_at", values[i])
|
|
} else if value.Valid {
|
|
_m.TorqueNgAt = new(time.Time)
|
|
*_m.TorqueNgAt = value.Time
|
|
}
|
|
case workpiece.FieldTorqueNgBy:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field torque_ng_by", values[i])
|
|
} else if value.Valid {
|
|
_m.TorqueNgBy = new(string)
|
|
*_m.TorqueNgBy = value.String
|
|
}
|
|
case workpiece.FieldFlowTransitMW:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field flowTransitMW", values[i])
|
|
} else if value.Valid {
|
|
_m.FlowTransitMW = int(value.Int64)
|
|
}
|
|
case workpiece.FieldFlowTransitTarget:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field flowTransitTarget", values[i])
|
|
} else if value.Valid {
|
|
_m.FlowTransitTarget = value.String
|
|
}
|
|
case workpiece.FieldFlowTransitAt:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field flowTransitAt", values[i])
|
|
} else if value.Valid {
|
|
_m.FlowTransitAt = new(time.Time)
|
|
*_m.FlowTransitAt = value.Time
|
|
}
|
|
default:
|
|
_m.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the Workpiece.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *Workpiece) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// Update returns a builder for updating this Workpiece.
|
|
// Note that you need to call Workpiece.Unwrap() before calling this method if this Workpiece
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *Workpiece) Update() *WorkpieceUpdateOne {
|
|
return NewWorkpieceClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the Workpiece 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 *Workpiece) Unwrap() *Workpiece {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: Workpiece is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *Workpiece) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("Workpiece(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
builder.WriteString("sn=")
|
|
builder.WriteString(_m.Sn)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("orderNo=")
|
|
builder.WriteString(_m.OrderNo)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("workOrderId=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.WorkOrderId))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("currentStationNo=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.CurrentStationNo))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("atStationNo=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.AtStationNo))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("status=")
|
|
builder.WriteString(_m.Status)
|
|
builder.WriteString(", ")
|
|
if v := _m.OnlineAt; v != nil {
|
|
builder.WriteString("onlineAt=")
|
|
builder.WriteString(v.Format(time.ANSIC))
|
|
}
|
|
builder.WriteString(", ")
|
|
if v := _m.DoneAt; v != nil {
|
|
builder.WriteString("doneAt=")
|
|
builder.WriteString(v.Format(time.ANSIC))
|
|
}
|
|
builder.WriteString(", ")
|
|
builder.WriteString("createdAt=")
|
|
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
if v := _m.UpdatedAt; v != nil {
|
|
builder.WriteString("updatedAt=")
|
|
builder.WriteString(v.Format(time.ANSIC))
|
|
}
|
|
builder.WriteString(", ")
|
|
builder.WriteString("torque_ng_pending=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.TorqueNgPending))
|
|
builder.WriteString(", ")
|
|
if v := _m.TorqueNgAt; v != nil {
|
|
builder.WriteString("torque_ng_at=")
|
|
builder.WriteString(v.Format(time.ANSIC))
|
|
}
|
|
builder.WriteString(", ")
|
|
if v := _m.TorqueNgBy; v != nil {
|
|
builder.WriteString("torque_ng_by=")
|
|
builder.WriteString(*v)
|
|
}
|
|
builder.WriteString(", ")
|
|
builder.WriteString("flowTransitMW=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.FlowTransitMW))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("flowTransitTarget=")
|
|
builder.WriteString(_m.FlowTransitTarget)
|
|
builder.WriteString(", ")
|
|
if v := _m.FlowTransitAt; v != nil {
|
|
builder.WriteString("flowTransitAt=")
|
|
builder.WriteString(v.Format(time.ANSIC))
|
|
}
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// Workpieces is a parsable slice of Workpiece.
|
|
type Workpieces []*Workpiece
|