jiangshuai
2023-11-13 f16252d8b4736a0212b14a2bfb0eeee411d0cc76
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"
)
@@ -679,9 +684,40 @@
      util.ResponseFormat(c, code.RequestError, err.Error())
      return
   }
   if operation.SourceNumber != "" {
      go UpdateSalesDetailStatus(operation.SourceNumber)
   }
   util.ResponseFormat(c, code.Success, "操作成功")
}
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   库存调拨列表