From f16252d8b4736a0212b14a2bfb0eeee411d0cc76 Mon Sep 17 00:00:00 2001 From: jiangshuai <291802688@qq.com> Date: 星期一, 13 十一月 2023 11:16:34 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS --- controllers/operation.go | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 54 insertions(+), 3 deletions(-) diff --git a/controllers/operation.go b/controllers/operation.go index 5bd16ef..08031a9 100644 --- a/controllers/operation.go +++ b/controllers/operation.go @@ -1,16 +1,20 @@ package controllers import ( + "context" "encoding/json" "errors" "fmt" "github.com/gin-gonic/gin" "github.com/shopspring/decimal" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" "gorm.io/gorm" "os" "sort" "strconv" "time" + "wms/conf" "wms/constvar" "wms/extend/code" "wms/extend/util" @@ -18,6 +22,7 @@ "wms/opa" "wms/pkg/logx" "wms/pkg/structx" + "wms/proto/product_inventory" "wms/request" ) @@ -257,7 +262,7 @@ util.ResponseFormat(c, code.Success, "淇敼鎴愬姛") } -// DeleteDevice +// Delete // // @Tags 鍏ュ簱/鍑哄簱 // @Summary 鍒犻櫎鍏ュ簱/鍑哄簱淇℃伅 @@ -299,7 +304,7 @@ util.ResponseFormat(c, code.Success, "鍒犻櫎鎴愬姛") } -// DeleteDevice +// Finish // // @Tags 鍏ュ簱/鍑哄簱 // @Summary 鏇存敼璁板綍鐘舵�� @@ -679,10 +684,41 @@ util.ResponseFormat(c, code.RequestError, err.Error()) return } + if operation.SourceNumber != "" { + go UpdateSalesDetailStatus(operation.SourceNumber) + } util.ResponseFormat(c, code.Success, "鎿嶄綔鎴愬姛") } -// listTransfer +var ProductInventoryServiceConn *grpc.ClientConn + +func InitProductInventoryServiceConn() { + var err error + ProductInventoryServiceConn, err = grpc.Dial(conf.GrpcServerConf.CrmAddr, grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + logx.Errorf("grpc dial product service error: %v", err.Error()) + return + } +} + +func CloseProductInventoryServiceConn() { + if ProductInventoryServiceConn != nil { + ProductInventoryServiceConn.Close() + } +} + +func UpdateSalesDetailStatus(number string) { + client := product_inventory.NewProductInventoryServiceClient(ProductInventoryServiceConn) + _, err := client.UpdateSalesDetailStatus(context.Background(), &product_inventory.UpdateSalesDetailStatusRequest{ + Number: number, + SalesDetailStatus: "宸插嚭搴�", + }) + if err != nil { + logx.Errorf("grpc dial UpdateSalesDetailStatus service error: %v", err) + } +} + +// ListTransfer // @Tags 鍏ュ簱/鍑哄簱 // @Summary 搴撳瓨璋冩嫧鍒楄〃 // @Produce application/json @@ -712,3 +748,18 @@ } util.ResponseFormatListWithPage(c, code.Success, list, int(total), params.Page, params.PageSize) } + +// GetLogisticCompanyList +// @Tags 鍏ュ簱/鍑哄簱 +// @Summary 鑾峰彇鐗╂祦鍏徃鍒楄〃 +// @Produce application/json +// @Success 200 {object} util.ResponseList{data=[]models.LogisticCompany} "鎴愬姛" +// @Router /api-wms/v1/operation/getLogisticCompanyList [get] +func (slf OperationController) GetLogisticCompanyList(c *gin.Context) { + companies, err := models.NewLogisticCompanySearch().FindNotTotal() + if err != nil { + util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触:"+err.Error()) + return + } + util.ResponseFormat(c, code.Success, companies) +} -- Gitblit v1.8.0