From 3f4f2d033f63296ad7e80415cfe2af41f136bfc0 Mon Sep 17 00:00:00 2001
From: jiangshuai <291802688@qq.com>
Date: 星期一, 13 十一月 2023 11:18:53 +0800
Subject: [PATCH] 修改文件服务器端口号
---
controllers/reorder_rule_controller.go | 40 +++++++++++++++++++++++++++++++++++++---
1 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/controllers/reorder_rule_controller.go b/controllers/reorder_rule_controller.go
index 0c04e43..a2b1dbe 100644
--- a/controllers/reorder_rule_controller.go
+++ b/controllers/reorder_rule_controller.go
@@ -3,15 +3,20 @@
import (
"github.com/gin-gonic/gin"
"github.com/shopspring/decimal"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/credentials/insecure"
"gorm.io/gorm"
"strconv"
"strings"
"time"
+ "wms/conf"
"wms/constvar"
"wms/extend/code"
"wms/extend/util"
"wms/models"
+ "wms/pkg/logx"
"wms/pkg/timex"
+ "wms/proto/inventory_order"
"wms/request"
)
@@ -114,7 +119,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, "鏌ヨ閲嶈璐ц鍒欏垪琛ㄥけ璐�")
@@ -216,7 +221,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, "鏌ヨ閲嶈璐ц鍒欏垪琛ㄥけ璐�")
@@ -254,6 +259,23 @@
util.ResponseFormat(c, code.Success, "鏇存柊鎴愬姛")
}
+var InventoryOrderServiceConn *grpc.ClientConn
+
+func InitInventoryOrderServiceConn() {
+ var err error
+ InventoryOrderServiceConn, err = grpc.Dial(conf.GrpcServerConf.ApsAddr, grpc.WithTransportCredentials(insecure.NewCredentials()))
+ if err != nil {
+ logx.Errorf("grpc dial product service error: %v", err.Error())
+ return
+ }
+}
+
+func CloseInventoryOrderServiceConn() {
+ if InventoryOrderServiceConn != nil {
+ InventoryOrderServiceConn.Close()
+ }
+}
+
// OrderAgain
// @Tags 閲嶈璐ц鍒�
// @Summary 鍐嶈涓�娆�
@@ -265,6 +287,17 @@
var params models.ReorderRule
if err := c.BindJSON(¶ms); err != nil {
util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�")
+ return
+ }
+ client := inventory_order.NewInventoryOrderServiceClient(InventoryOrderServiceConn)
+ order, err := client.CreateNewOrder(c, &inventory_order.CreateNewOrderRequest{
+ OrderNumber: params.OrderNumber.IntPart(),
+ Unit: params.Unit,
+ ProductId: params.ProductId,
+ Customer: "WMS鎺ㄩ��",
+ })
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "grpc璋冪敤澶辫触")
return
}
location, err := models.NewLocationSearch().SetID(params.LocationId).First()
@@ -294,13 +327,14 @@
operation.FromLocationID = 1
operation.Number = strconv.FormatInt(time.Now().Unix(), 10)
operation.ToLocationID = params.LocationId
+ operation.SourceNumber = order.OrderId
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
})
if err != nil {
--
Gitblit v1.8.0