From 8dfb8feb32bb5e4e460e23dcde42612a26fa2bcb Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期日, 27 八月 2023 01:11:28 +0800
Subject: [PATCH] fix

---
 model/work_order.go |   37 +++++++++++++++++++++++++++++++++----
 1 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/model/work_order.go b/model/work_order.go
index 6848342..b453d81 100644
--- a/model/work_order.go
+++ b/model/work_order.go
@@ -22,7 +22,7 @@
 		Unit        string          `gorm:"type:varchar(100);comment:鍗曚綅" json:"unit"`
 		StartTime   int64           `gorm:"comment:璁″垝寮�濮嬫椂闂�" json:"startTime"`
 		EndTime     int64           `gorm:"comment:璁″垝缁撴潫鏃堕棿" json:"endTime"`
-		Status      OrderStatus     `json:"-"`
+		Status      OrderStatus
 	}
 
 	OrderSearch struct {
@@ -33,14 +33,17 @@
 		Orm          *gorm.DB
 		Preload      bool
 		StartTimeMax int64
+		StartTimeMin int64
+		StatusList   []OrderStatus
 	}
 )
 
 type OrderStatus int
 
 const (
-	OrderStatusUnFinished OrderStatus = 1
-	OrderStatusFinished   OrderStatus = 2
+	OrderStatusWaitProcess OrderStatus = 1
+	OrderStatusProcessing  OrderStatus = 2
+	OrderStatusFinished    OrderStatus = 3
 )
 
 func (slf *Order) TableName() string {
@@ -73,9 +76,18 @@
 	slf.StartTimeMax = ts
 	return slf
 }
+func (slf *OrderSearch) SetStartTimeMin(ts int64) *OrderSearch {
+	slf.StartTimeMin = ts
+	return slf
+}
 
 func (slf *OrderSearch) SetStatus(status OrderStatus) *OrderSearch {
 	slf.Status = status
+	return slf
+}
+
+func (slf *OrderSearch) SetStatusList(statusList []OrderStatus) *OrderSearch {
+	slf.StatusList = statusList
 	return slf
 }
 
@@ -89,6 +101,11 @@
 	return slf
 }
 
+func (slf *OrderSearch) SetId(id uint) *OrderSearch {
+	slf.ID = id
+	return slf
+}
+
 func (slf *OrderSearch) build() *gorm.DB {
 	var db = slf.Orm.Model(&Order{})
 
@@ -96,18 +113,30 @@
 		db = db.Order(slf.OrderBy)
 	}
 
+	if slf.ID != 0 {
+		db = db.Where("id = ?", slf.ID)
+	}
+
 	if slf.WorkOrderID != "" {
-		db = db.Where("work_order_id = ?", slf.OrderID)
+		db = db.Where("work_order_id = ?", slf.WorkOrderID)
 	}
 
 	if slf.Status != 0 {
 		db = db.Where("status = ?", slf.Status)
 	}
 
+	if len(slf.StatusList) != 0 {
+		db = db.Where("status in ?", slf.StatusList)
+	}
+
 	if slf.StartTimeMax != 0 {
 		db = db.Where("start_time <= ?", slf.StartTimeMax)
 	}
 
+	if slf.StartTimeMin != 0 {
+		db = db.Where("start_time >= ?", slf.StartTimeMin)
+	}
+
 	if slf.Preload {
 		db = db.Preload("InputMaterials").Preload("OutputMaterials")
 	}

--
Gitblit v1.8.0