From 76c74cf71fb82099e134cea6a34019655fed2f3f Mon Sep 17 00:00:00 2001
From: jiangshuai <291802688@qq.com>
Date: 星期二, 14 十一月 2023 14:52:37 +0800
Subject: [PATCH] 产品列表增加重订货规则统计
---
controllers/product_controller.go | 13 +++++++++++--
models/material.go | 3 +++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/controllers/product_controller.go b/controllers/product_controller.go
index fa65e70..053effc 100644
--- a/controllers/product_controller.go
+++ b/controllers/product_controller.go
@@ -125,8 +125,7 @@
product.PredictionAmount = product.Amount.Add(reorderAmount.TotalAmount)
var statisticsList []*request.ProductStatistics
- if err := models.NewOperationSearch().Orm.
- Table("wms_operation").
+ if err := models.NewOperationSearch().Orm.Table("wms_operation").
InnerJoins("INNER JOIN wms_operation_details on wms_operation_details.operation_id=wms_operation.id").
Select("SUM(wms_operation_details.amount) as total_amount,wms_operation.base_operation_type").
Where("wms_operation_details.product_id=? and wms_operation.`status`=? and wms_operation.base_operation_type in (?)", product.ID, constvar.OperationStatus_Finish, []constvar.BaseOperationType{constvar.BaseOperationTypeIncoming, constvar.BaseOperationTypeOutgoing, constvar.BaseOperationTypeDisuse}).
@@ -146,6 +145,16 @@
product.OutputAmount = product.OutputAmount.Add(v.TotalAmount)
}
}
+ reorderRules, rulesTotal, err := models.NewReorderRuleSearch().SetProductId(product.ID).Find()
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "閲嶈璐ц鍒欑粺璁″け璐�")
+ return
+ }
+ if rulesTotal == 1 {
+ product.MinInventoryRule = reorderRules[0].MinInventory
+ product.MaxInventoryRule = reorderRules[0].MaxInventory
+ }
+ product.ReorderRuleNum = rulesTotal
}
util.ResponseFormatList(c, code.Success, products, int(total))
}
diff --git a/models/material.go b/models/material.go
index d583e7b..91133b9 100644
--- a/models/material.go
+++ b/models/material.go
@@ -75,6 +75,9 @@
PredictionAmount decimal.Decimal `json:"predictionAmount" gorm:"-"`
InputAmount decimal.Decimal `json:"inputAmount" gorm:"-"`
OutputAmount decimal.Decimal `json:"outputAmount" gorm:"-"`
+ MinInventoryRule decimal.Decimal `json:"minInventoryRule" gorm:"-"` //鏈�灏忓簱瀛�
+ MaxInventoryRule decimal.Decimal `json:"maxInventoryRule" gorm:"-"` //鏈�澶у簱瀛�
+ ReorderRuleNum int64 `json:"reorderRuleNum"`
}
MaterialSearch struct {
--
Gitblit v1.8.0