package common
|
|
import (
|
"apsClient/constvar"
|
"github.com/shopspring/decimal"
|
)
|
|
// 排程任务下发
|
type (
|
WorkOrder struct {
|
WorkOrderID string `json:"workOrderId"`
|
OrderID string `gorm:"index;type:varchar(191);not null;comment:订单ID" json:"orderId"`
|
ProductID string `gorm:"type:varchar(191);comment:产品ID" json:"productId"`
|
ProductName string `gorm:"type:varchar(191);comment:产品名称" json:"productName"`
|
Parameter string `gorm:"type:varchar(1024);comment:参数需求" json:"parameter"`
|
Customer string `gorm:"type:varchar(191);comment:客户编码" json:"customer"`
|
DeliverDate string `gorm:"type:varchar(100);comment:交货日期" json:"deliverDate"`
|
OrderAttr string `json:"orderAttr"` // 订单属性拼接的字符串,即货物描述
|
Amount decimal.Decimal `gorm:"type:decimal(35,18);comment:数量" json:"amount"`
|
Unit string `gorm:"type:varchar(100);comment:单位" json:"unit"`
|
StartTime int64 `gorm:"comment:计划开始时间" json:"startTime"`
|
EndTime int64 `gorm:"comment:计划结束时间" json:"endTime"`
|
}
|
|
ProcedureMaterial struct {
|
MaterialID string `gorm:"type:varchar(191);comment:物料编号" json:"materialId"`
|
MaterialName string `gorm:"unique;type:varchar(191);not null;comment:物料名称" json:"materialName"`
|
Amount decimal.Decimal `gorm:"type:decimal(35,18);comment:数量" json:"amount"`
|
Unit string `gorm:"type:varchar(191);comment:单位" json:"unit"`
|
}
|
|
ProcedureWorker struct {
|
WorkerID string `gorm:"type:varchar(2048);comment:人员ID" json:"workerId"`
|
WorkerName string `gorm:"unique;type:varchar(191);not null;comment:人员姓名" json:"workerName"`
|
PhoneNum string `gorm:"type:varchar(191);comment:手机号" json:"phoneNum"`
|
StartTime int64 `gorm:"comment:开始时间" json:"startTime"`
|
EndTime int64 `gorm:"comment:结束时间" json:"endTime"`
|
}
|
|
ProductProcedure struct {
|
ProcedureID string `gorm:"uniqueIndex:idx_product_procedure;type:varchar(191);comment:工序ID" json:"procedureId"`
|
ProcedureName string `gorm:"type:varchar(191);comment:工序名称,仅查询用" json:"procedureName"`
|
NextProcedureID string `json:"nextProcedureId"`
|
NextProcedureName string `json:"nextProcedureName"`
|
DeviceID string `gorm:"type:varchar(191);not null;comment:设备ID" json:"deviceId"`
|
DeviceName string `json:"deviceName"`
|
StartTime int64 `gorm:"comment:计划开始时间" json:"startTime"`
|
EndTime int64 `gorm:"comment:计划结束时间" json:"endTime"`
|
WorkHours decimal.Decimal `gorm:"type:decimal(35,18);comment:工时" json:"workHours"`
|
InputMaterials []*ProcedureMaterial `json:"inputMaterials"` // 输入物料列表
|
OutputMaterials []*ProcedureMaterial `json:"outputMaterials"` // 输出物料列表
|
Workers []*ProcedureWorker `json:"workers"` // 人员列表
|
AllProcedureNames []string `json:"allProcedureNames"` // 所属工单工序列表
|
Channel int32 `json:"channel"` //通道序号
|
}
|
|
DeliverScheduleTask struct {
|
WorkOrder WorkOrder `json:"workOrder"`
|
Procedures []*ProductProcedure `json:"procedures"` // 工序列表
|
}
|
)
|
|
// PLC写入地址
|
type (
|
RequestPlcAddress struct {
|
DeviceId string
|
}
|
ResponsePlcAddress struct {
|
KeyData []byte
|
AddressData []byte
|
DeviceId string
|
PlcAddressList []*PlcAddress //plc 完成量,总量, 读写地址
|
PlcConfig PlcConfig //用网口还是端口以及网口ip port
|
}
|
|
PlcConfig struct {
|
Brand string `gorm:"type:varchar(191)" json:"brand"` //comment:PLC品牌
|
Method constvar.PlcMethod `gorm:"type:varchar(191)" json:"method"` //comment:接口方式
|
Address string `gorm:"type:varchar(191)" json:"address"` //plc ip地址, method = modbusTCP用
|
Port int `gorm:"type:int(11)" json:"port"` //plc 端口号, method = modbusTCP用
|
BaudRate int `gorm:"type:int(11)" json:"baudRate"` //串口波特率, method = serial时 用
|
SerialName string `gorm:"type:int(11)" json:"serialName"` //串口名称,method = serial时 用
|
IsOpen bool `gorm:"type:tinyint(1)" json:"isOpen"`
|
Detail string `gorm:"type:varchar(2048)" json:"-"`
|
Details []*PlcAddress `gorm:"-" json:"details"`
|
}
|
|
PlcAddress struct {
|
DeviceID string `json:"deviceID"` // 设备id
|
Channel int `json:"channel"` // 生产通道on,一个机器可能有多个机位,需要分别配置plc地址
|
StartAddress int `json:"startAddress"` // 数据起始地址
|
Length int `json:"length"` // 数据长度
|
Type string `json:"type"` // 数据类型
|
FieldName constvar.PlcStartAddressType `json:"fieldName"` // 对应系统字段,完成量或总量
|
}
|
)
|
|
// 工艺参数
|
type (
|
RequestProcessParams struct {
|
WorkOrder string `json:"workOrder,omitempty" form:"workOrder"` //工序编号
|
OrderId string `json:"orderId"` // 订单号
|
Product string `json:"password"` // 产品
|
Procedure string `json:"procedure"` // 工序
|
Device string `json:"device"` // 设备
|
DeviceId string `json:"deviceId" gorm:"-"` //用于过滤获取nsq消息
|
}
|
ResponseProcessParams struct {
|
Number string `json:"number"` //工艺模型编号
|
OrderId string `json:"orderId"` //订单id
|
Product string `json:"product"` //产品名称
|
Procedure string `json:"procedure"` //工序
|
WorkOrder string `json:"workOrder"` //工单
|
Device string `json:"device"` //设备
|
Params string `json:"params"`
|
ParamsMap map[string]interface{} `json:"paramsMap"`
|
DeviceId string `json:"deviceId" gorm:"-"` //用于过滤获取nsq消息
|
}
|
)
|
|
// MsgTaskStatusUpdate 任务状态改变
|
type MsgTaskStatusUpdate struct {
|
WorkOrderId string `json:"workOrderId"` //工单编号
|
ProcedureID string `json:"procedureId"` // 工序
|
DeviceId string `json:"deviceId"` //用于过滤获取nsq消息
|
IsProcessing bool //是否处理中
|
IsFinish bool //是否完成
|
}
|
|
type Device struct {
|
ID string `gorm:"comment:主键ID;primaryKey;type:varchar(191);" json:"id"`
|
DeviceProcedureAttr []*DeviceProcedureAttr `json:"deviceProcedureAttr"` // 设备工序属性列表
|
ExtChannelAmount int `gorm:"type:tinyint;comment:额外的通道数量;default:0;" json:"extChannelAmount"`
|
}
|
type DeviceProcedureAttr struct {
|
ProcedureID string `gorm:"index;type:varchar(191);comment:工序ID" json:"procedureId"`
|
ProcedureName string `gorm:"type:varchar(191);comment:工序名称" json:"procedureName"`
|
DeviceID string `gorm:"index;type:varchar(191);not null;comment:设备ID" json:"deviceId"`
|
}
|