From 8324f872ef3a4d0c978a9b1d062800c6a1701c12 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期五, 01 十二月 2023 09:58:17 +0800
Subject: [PATCH] fix

---
 model/common/common.go |  149 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 138 insertions(+), 11 deletions(-)

diff --git a/model/common/common.go b/model/common/common.go
index c953878..b0a9b22 100644
--- a/model/common/common.go
+++ b/model/common/common.go
@@ -1,6 +1,9 @@
 package common
 
-import "github.com/shopspring/decimal"
+import (
+	"apsClient/constvar"
+	"github.com/shopspring/decimal"
+)
 
 // 鎺掔▼浠诲姟涓嬪彂
 type (
@@ -35,16 +38,21 @@
 	}
 
 	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"`
-		DeviceID        string               `gorm:"type:varchar(191);not null;comment:璁惧ID" json:"deviceId"`
-		DeviceName      string               `gorm:"type:varchar(191);not null;comment:璁惧鍚嶇О" 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"`         // 浜哄憳鍒楄〃
+		ProductProcedureID string               `gorm:"index;type:varchar(191);not null;comment:浜у搧宸ュ簭ID" json:"productProcedureID"`
+		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 {
@@ -52,3 +60,122 @@
 		Procedures []*ProductProcedure `json:"procedures"` // 宸ュ簭鍒楄〃
 	}
 )
+
+// PLC鍐欏叆鍦板潃
+type (
+	RequestPlcAddress struct {
+		DeviceId string
+	}
+	ResponsePlcAddress struct {
+		KeyData        []byte
+		AddressData    []byte
+		DeviceId       string
+		PlcAddressList []*PlcAddress //plc 瀹屾垚閲忥紝鎬婚噺锛� 璇诲啓鍦板潃
+		PlcConfig      PlcConfig     //鐢ㄧ綉鍙h繕鏄鍙d互鍙婄綉鍙p 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鎴杕odbusRTU 鏃剁敤
+		SerialName string             `gorm:"type:int(11)"  json:"serialName"`  //涓插彛鍚嶇О锛宮ethod = serial鎴杕odbusRTU 鏃剁敤
+		DataBit    int                `gorm:"type:int(11)"  json:"dataBit"`     //鏁版嵁浣嶏紝method = modbusRTU 鐢�
+		StopBit    int                `gorm:"type:int(11)"  json:"stopBit"`     //鍋滄浣嶏紝method = modbusRTU 鐢�
+		Parity     constvar.Parity    `gorm:"type:int(11)"  json:"parity"`      //鏍¢獙鏂瑰紡锛宮ethod = modbusRTU 鐢�
+		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锛屼竴涓満鍣ㄥ彲鑳芥湁澶氫釜鏈轰綅锛岄渶瑕佸垎鍒厤缃畃lc鍦板潃
+		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"`    //宸ヨ壓妯″瀷缂栧彿
+		Product   string                 `json:"product"`   //浜у搧鍚嶇О
+		Procedure string                 `json:"procedure"` //宸ュ簭
+		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   //鏄惁瀹屾垚
+	FinishAmount       int    `json:"finishAmount"`       //isFinish = true鏃跺彇宸ュ簭鏈�缁堝姞宸ユ暟浼犱笂鍘�
+	ProductProcedureID string `json:"productProcedureID"` //浜у搧宸ュ簭id
+	StartTs            int64  `json:"start_ts"`           //寮�濮嬫椂闂�
+	FinishTs           int64  `json:"finish_ts"`          //缁撴潫鏃堕棿
+}
+
+// DeviceMsg 涓嬪彂鍒扮粓绔殑璁惧淇℃伅
+type DeviceMsg 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"`
+	DeviceName          string                 `json:"deviceName"`
+	DeviceMac           string                 `json:"deviceMac"`
+	PlcAddressList      []*PlcAddress
+	PlcConfig           *PlcConfig
+}
+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"`
+}
+
+type PullDataType string
+
+const (
+	PullDataTypeProcessModel           = "process_model"
+	PullDataTypeDevice                 = "device"
+	PullDataTypeProcessModelPlcAddress = "process_model_plc_address"
+)
+
+// MsgPullDataRequest 鎷夊彇浜戠鏁版嵁
+type MsgPullDataRequest struct {
+	DataType PullDataType `json:"dataType"` //瑕佹媺鍙栫殑鏁版嵁绫诲瀷
+}
+
+type MsgPullDataResponse struct {
+	DataType PullDataType `json:"dataType"` //瑕佹媺鍙栫殑鏁版嵁绫诲瀷
+	Data     interface{}  //杩斿洖鐨勬暟鎹�
+}
+
+type RTUConfig struct {
+	BaudRate   int             `json:"baudRate"`                     //涓插彛娉㈢壒鐜囷紝 method = serial鏃� 鐢�
+	SerialName string          `json:"serialName"`                   //涓插彛鍚嶇О锛宮ethod = serial鏃� 鐢�
+	DataBit    int             `gorm:"type:int(11)"  json:"dataBit"` //鏁版嵁浣嶏紝method = modbusRTU 鐢�
+	StopBit    int             `gorm:"type:int(11)"  json:"stopBit"` //鍋滄浣嶏紝method = modbusRTU 鐢�
+	Parity     constvar.Parity `gorm:"type:int(11)"  json:"parity"`  //鏍¢獙鏂瑰紡锛宮ethod = modbusRTU 鐢�
+}
+
+// MsgReportData 鏁版嵁涓婃姤
+type MsgReportData struct {
+	ReportType constvar.ReportType `json:"reportType"` //涓婃姤绫诲瀷
+	Content    string              `json:"Content"`
+}

--
Gitblit v1.8.0