From 578b74f9de4b96e88e2fddb726c7c6f78162b033 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期六, 21 十月 2023 14:34:23 +0800
Subject: [PATCH] 启停生产者
---
model/production_progress.go | 43 +++++++++++++++++++++----------------------
1 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/model/production_progress.go b/model/production_progress.go
index 3fdb02c..293a660 100644
--- a/model/production_progress.go
+++ b/model/production_progress.go
@@ -9,21 +9,22 @@
type (
ProductionProgress struct {
gorm.Model
- WorkOrderID string `gorm:"index;type:varchar(191);not null;comment:宸ュ崟ID" json:"workOrderID"`
- OrderID string `gorm:"index;type:varchar(191);not null;comment:璁㈠崟ID" json:"orderID"`
- ProcedureID string `gorm:"type:varchar(191);comment:宸ュ簭ID" json:"procedureId"`
- DeviceID string `gorm:"type:varchar(191);not null;comment:璁惧ID" json:"deviceId"`
- FinishedQuantity int64 `gorm:"type:int;not null;comment:瀹屾垚鏁伴噺" json:"finishedQuantity"`
- Channel int32 `gorm:"type:int;comment:宸ヤ綔閫氶亾" json:"channel"` //閫氶亾
- TotalQuantity int64 `gorm:"type:int;not null;comment:鎬婚噺" json:"totalQuantity"`
+ WorkOrderID string `gorm:"index;type:varchar(191);not null" json:"workOrderID"`
+ OrderID string `gorm:"index;type:varchar(191);not null" json:"orderID"`
+ ProcedureID string `gorm:"type:varchar(191)" json:"procedureId"`
+ DeviceID string `gorm:"type:varchar(191);not null" json:"deviceId"`
+ FinishedQuantity int64 `gorm:"type:int;not null" json:"finishedQuantity"`
+ Channel int32 `gorm:"type:int" json:"channel"` //閫氶亾
+ TotalQuantity int64 `gorm:"type:int;not null" json:"totalQuantity"`
}
ProductionProgressSearch struct {
ProductionProgress
- Order string
- PageNum int
- PageSize int
- Orm *gorm.DB
+ Order string
+ PageNum int
+ PageSize int
+ Orm *gorm.DB
+ UnFinished bool
}
)
@@ -78,6 +79,11 @@
return slf
}
+func (slf *ProductionProgressSearch) SetUnFinished() *ProductionProgressSearch {
+ slf.UnFinished = true
+ return slf
+}
+
func (slf *ProductionProgressSearch) build() *gorm.DB {
var db = slf.Orm.Model(&ProductionProgress{})
@@ -109,6 +115,10 @@
db = db.Where("channel = ?", slf.Channel)
}
+ if slf.UnFinished {
+ db = db.Where("finished_quantity < total_quantity")
+ }
+
return db
}
@@ -118,17 +128,6 @@
if err := db.Create(record).Error; err != nil {
return fmt.Errorf("create err: %v, record: %+v", err, record)
- }
-
- return nil
-}
-
-// CreateBatch 鎵归噺鎻掑叆
-func (slf *ProductionProgressSearch) CreateBatch(records []*ProductionProgress) error {
- var db = slf.build()
-
- if err := db.Create(&records).Error; err != nil {
- return fmt.Errorf("create batch err: %v, records: %+v", err, records)
}
return nil
--
Gitblit v1.8.0