From 7a3a9a739392d048655efac6a28592410a8809c2 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期五, 17 十一月 2023 09:57:29 +0800
Subject: [PATCH] 在库产品类型修改
---
controllers/reorder_rule_controller.go | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 50 insertions(+), 9 deletions(-)
diff --git a/controllers/reorder_rule_controller.go b/controllers/reorder_rule_controller.go
index 69d8590..4eeaa18 100644
--- a/controllers/reorder_rule_controller.go
+++ b/controllers/reorder_rule_controller.go
@@ -17,6 +17,7 @@
"wms/pkg/logx"
"wms/pkg/timex"
"wms/proto/inventory_order"
+ "wms/proto/purchase_wms"
"wms/request"
)
@@ -119,7 +120,7 @@
rule.Prediction = rule.Amount.Add(rule.Prediction)
}
//鍑哄簱灏辩华
- operationType = []constvar.BaseOperationType{constvar.BaseOperationTypeOutgoing, constvar.BaseOperationTypeInternal}
+ operationType = []constvar.BaseOperationType{constvar.BaseOperationTypeOutgoing, constvar.BaseOperationTypeInternal, constvar.BaseOperationTypeDisuse}
amount, err = GetProductAmount(productIds, nil, locationIds, status, operationType)
if err != nil {
util.ResponseFormat(c, code.RequestParamError, "鏌ヨ閲嶈璐ц鍒欏垪琛ㄥけ璐�")
@@ -221,7 +222,7 @@
}
prediction = amount.Add(prediction)
//鍑哄簱灏辩华
- operationType = []constvar.BaseOperationType{constvar.BaseOperationTypeOutgoing, constvar.BaseOperationTypeInternal}
+ operationType = []constvar.BaseOperationType{constvar.BaseOperationTypeOutgoing, constvar.BaseOperationTypeInternal, constvar.BaseOperationTypeDisuse}
list, err = GetProductAmount(productIds, nil, locationIds, status, operationType)
if err != nil {
util.ResponseFormat(c, code.RequestParamError, "鏌ヨ閲嶈璐ц鍒欏垪琛ㄥけ璐�")
@@ -289,6 +290,16 @@
util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�")
return
}
+ if params.Route == "閲囪喘" {
+ client := purchase_wms.NewPurchaseServiceClient(PurchaseServiceConn)
+ resp, err := client.GetSupplierListByProductId(c, &purchase_wms.GetSupplierListByProductIdRequest{ProductId: params.ProductId})
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "grpc璋冪敤澶辫触")
+ return
+ }
+ util.ResponseFormat(c, code.Success, resp.List)
+ return
+ }
client := inventory_order.NewInventoryOrderServiceClient(InventoryOrderServiceConn)
order, err := client.CreateNewOrder(c, &inventory_order.CreateNewOrderRequest{
OrderNumber: params.OrderNumber.IntPart(),
@@ -300,18 +311,25 @@
util.ResponseFormat(c, code.RequestParamError, "grpc璋冪敤澶辫触")
return
}
+ err = orderAgain(params, order.OrderId)
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "閲嶈澶辫触")
+ return
+ }
+ util.ResponseFormat(c, code.Success, "閲嶈鎴愬姛")
+}
+
+func orderAgain(params models.ReorderRule, SourceNumber string) error {
location, err := models.NewLocationSearch().SetID(params.LocationId).First()
if err != nil {
- util.ResponseFormat(c, code.RequestParamError, "鏌ヨ浣嶇疆淇℃伅澶辫触")
- return
+ return err
}
houseCode := strings.Split(location.JointName, "/")[0]
var operationType models.OperationType
err = models.NewOperationTypeSearch().Orm.Model(&models.OperationType{}).Joins("left join wms_warehouse on wms_job_type.warehouse_id = wms_warehouse.id").
Where("wms_job_type.base_operation_type = 1 and wms_warehouse.code = ?", houseCode).First(&operationType).Error
if err != nil {
- util.ResponseFormat(c, code.RequestParamError, "鏌ヨ浣嶇疆淇℃伅澶辫触")
- return
+ return err
}
var operation models.Operation
var details models.OperationDetails
@@ -327,19 +345,42 @@
operation.FromLocationID = 1
operation.Number = strconv.FormatInt(time.Now().Unix(), 10)
operation.ToLocationID = params.LocationId
- operation.SourceNumber = order.OrderId
+ operation.SourceNumber = SourceNumber
err = models.WithTransaction(func(db *gorm.DB) error {
if err = models.NewOperationSearch().SetOrm(db).Create(&operation); err != nil {
return err
}
params.OrderNumber = decimal.NewFromInt(0)
- err = models.NewReorderRuleSearch().SetID(params.Id).Update(¶ms)
+ err = models.NewReorderRuleSearch().SetOrm(db).SetID(params.Id).Update(¶ms)
return err
})
+
+ return err
+}
+
+// SubmitOrder
+// @Tags 閲嶈璐ц鍒�
+// @Summary 鍐嶈涓�娆�
+// @Produce application/json
+// @Param object body models.ReorderRule true "鍙傛暟"
+// @Success 200 {object} util.Response "鎴愬姛"
+// @Router /api-wms/v1/reorderRule/submitOrder [post]
+func (slf ReorderRuleController) SubmitOrder(c *gin.Context) {
+ var params models.ReorderRule
+ client := purchase_wms.NewPurchaseServiceClient(PurchaseServiceConn)
+ resp, err := client.CreatePurchaseByWms(c, &purchase_wms.CreatePurchaseByWmsRequest{
+ SupplierId: params.SupplierId,
+ ProductId: params.ProductId,
+ Amount: params.OrderNumber.IntPart(),
+ })
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "grpc璋冪敤澶辫触")
+ return
+ }
+ err = orderAgain(params, resp.PurchaseNumber)
if err != nil {
util.ResponseFormat(c, code.RequestParamError, "閲嶈澶辫触")
return
}
- util.ResponseFormat(c, code.Success, "閲嶈鎴愬姛")
}
--
Gitblit v1.8.0