| | |
| | | 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" |
| | |
| | | "wms/opa" |
| | | "wms/pkg/logx" |
| | | "wms/pkg/structx" |
| | | "wms/proto/product_inventory" |
| | | "wms/request" |
| | | ) |
| | | |
| | |
| | | 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 库存调拨列表 |