From 329095b4c501351cda9316f26d1e617b1b0bc3ec Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期二, 09 四月 2024 15:11:27 +0800
Subject: [PATCH] 纤度检验表返回设备登记表详情
---
models/fineness.go | 43 ++++++++++++++++++++++++++++++++++---------
1 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/models/fineness.go b/models/fineness.go
index 72dab54..c82e5a5 100644
--- a/models/fineness.go
+++ b/models/fineness.go
@@ -2,6 +2,7 @@
import (
"fmt"
+ "github.com/shopspring/decimal"
"gorm.io/gorm"
"silkserver/pkg/mysqlx"
)
@@ -10,22 +11,28 @@
// FinenessRegister 绾ゅ害鐧昏
FinenessRegister struct {
gorm.Model
- Number string `gorm:"type:varchar(255);not null;comment:缂栧彿" json:"number"` //缂栧彿
- FinishDate string `gorm:"type:varchar(255);not null;comment:钀戒笣鏃堕棿" json:"finishDate"` //钀戒笣鏃堕棿
- Workshop string `gorm:"type:varchar(255);not null;comment:杞﹂棿" json:"name"` //杞﹂棿
- WorkshopGroup string `gorm:"type:varchar(255);not null;comment:杞︾粍" json:"workshopGroup"` //杞︾粍
- Market string `gorm:"type:varchar(255);not null;comment:搴勫彛" json:"market"` //搴勫彛
- Spec string `gorm:"type:varchar(255);not null;comment:瑙勬牸" json:"spec"` //瑙勬牸
- StartCircle uint8 `gorm:"type:varchar(255);not null;comment:寮�濮嬪洖鏁�" json:"startCircle"` //寮�濮嬪洖鏁�
- EndCircle uint8 `gorm:"type:varchar(255);not null;comment:缁撴潫鍥炴暟" json:"endCircle"` //缁撴潫鍥炴暟
+ Number string `gorm:"type:varchar(255);not null;comment:缂栧彿" json:"number"` //缂栧彿
+ FinenessCheckID uint `gorm:"not null;comment:绾ゅ害妫�楠岃〃ID" json:"finenessCheckID"` //绾ゅ害妫�楠岃〃ID
+ FinishDate string `gorm:"type:varchar(255);not null;comment:钀戒笣鏃堕棿" json:"finishDate"` //钀戒笣鏃堕棿
+ Workshop string `gorm:"type:varchar(255);not null;comment:杞﹂棿" json:"name"` //杞﹂棿
+ WorkshopGroup int `gorm:"type:int(11);not null;default:0;comment:杞︾粍" json:"workshopGroup"` //杞︾粍
+ Market string `gorm:"type:varchar(255);not null;comment:搴勫彛" json:"market"` //搴勫彛
+ Spec string `gorm:"type:varchar(255);not null;comment:瑙勬牸" json:"spec"` //瑙勬牸
+ Circle uint8 `gorm:"not null;default:0;comment:鍥炴暟" json:"circle"` //鍥炴暟
+ TotalCircle uint8 `gorm:"not null;default:0;comment:鎬诲洖鏁�" json:"totalCircle"` //鎬诲洖鏁�
+ FinenessList []FinenessItem `gorm:"foreignkey:FinenessRegisterID;references:ID" json:"finenessList"`
+ SumFineness decimal.Decimal `gorm:"type:decimal(12,2);not null;comment:鍚堣绾ゅ害" json:"sumFineness"`
+ SumQuantity decimal.Decimal `gorm:"type:decimal(12,2);not null;comment:鍚堣鏁伴噺" json:"sumQuantity"`
+ Position int `gorm:"not null;default:0;comment:杞﹀彿" json:"position"` //鏈�鍚庝竴涓溅鍙�
}
-
FinenessRegisterSearch struct {
FinenessRegister
Order string
PageNum int
PageSize int
Orm *gorm.DB
+ Preload bool
+ Keyword string
}
)
@@ -52,6 +59,11 @@
return slf
}
+func (slf *FinenessRegisterSearch) SetPreload() *FinenessRegisterSearch {
+ slf.Preload = true
+ return slf
+}
+
func (slf *FinenessRegisterSearch) SetID(id uint) *FinenessRegisterSearch {
slf.ID = id
return slf
@@ -59,6 +71,11 @@
func (slf *FinenessRegisterSearch) SetNumber(number string) *FinenessRegisterSearch {
slf.Number = number
+ return slf
+}
+
+func (slf *FinenessRegisterSearch) SetKeyword(keyword string) *FinenessRegisterSearch {
+ slf.Keyword = keyword
return slf
}
@@ -77,6 +94,14 @@
db = db.Where("number = ?", slf.Number)
}
+ if slf.Preload {
+ db = db.Model(&FinenessRegister{}).Preload("FinenessList")
+ }
+
+ if slf.Keyword != "" {
+ db = db.Where("number like ?", fmt.Sprintf("%%%s%%", slf.Keyword))
+ }
+
return db
}
--
Gitblit v1.8.0