From 19c81eccddd39e4d4d6769093c7210809e7b752e Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期二, 14 十一月 2023 18:39:38 +0800
Subject: [PATCH] srm添加进货单
---
proto/purchase_wms/purchase_wms_grpc.pb.go | 137 +++++++++++
proto/purchase_wms/purchase_wms.pb.go | 459 ++++++++++++++++++++++++++++++++++++++
main.go | 2
docs/swagger.yaml | 6
proto/purchase_wms.proto | 37 +++
docs/docs.go | 9
proto/purchase_wms/server.go | 53 ++++
docs/swagger.json | 9
proto/product_inventory/server.go | 2
9 files changed, 713 insertions(+), 1 deletions(-)
diff --git a/docs/docs.go b/docs/docs.go
index 76ee786..017f8d3 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -3002,6 +3002,9 @@
"description": "HSCode string ` + "`" + `gorm:\"type:varchar(255);comment:HS缂栫爜\" json:\"HSCode\"` + "`" + ` //HS缂栫爜\nOriginCountryId int ` + "`" + `gorm:\"type:int(11);comment:鍘熶骇鍦癷d\" json:\"originCountryId\"` + "`" + ` //鍘熶骇鍦癷d\nOriginCountryName string ` + "`" + `gorm:\"type:varchar(255);comment:鍘熶骇鍦板悕绉癨" json:\"originCountryName\"` + "`" + ` //鍘熶骇鍦板悕绉�",
"type": "string"
},
+ "inputAmount": {
+ "type": "number"
+ },
"internalNotes": {
"description": "鍐呴儴璇存槑",
"type": "string"
@@ -3073,6 +3076,12 @@
"description": "鍑哄簱璇存槑",
"type": "string"
},
+ "outputAmount": {
+ "type": "number"
+ },
+ "predictionAmount": {
+ "type": "number"
+ },
"principal": {
"description": "璐熻矗浜�",
"type": "string"
diff --git a/docs/swagger.json b/docs/swagger.json
index fb080eb..00e8854 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -2990,6 +2990,9 @@
"description": "HSCode string `gorm:\"type:varchar(255);comment:HS缂栫爜\" json:\"HSCode\"` //HS缂栫爜\nOriginCountryId int `gorm:\"type:int(11);comment:鍘熶骇鍦癷d\" json:\"originCountryId\"` //鍘熶骇鍦癷d\nOriginCountryName string `gorm:\"type:varchar(255);comment:鍘熶骇鍦板悕绉癨" json:\"originCountryName\"` //鍘熶骇鍦板悕绉�",
"type": "string"
},
+ "inputAmount": {
+ "type": "number"
+ },
"internalNotes": {
"description": "鍐呴儴璇存槑",
"type": "string"
@@ -3061,6 +3064,12 @@
"description": "鍑哄簱璇存槑",
"type": "string"
},
+ "outputAmount": {
+ "type": "number"
+ },
+ "predictionAmount": {
+ "type": "number"
+ },
"principal": {
"description": "璐熻矗浜�",
"type": "string"
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 37b8823..41799e9 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -465,6 +465,8 @@
OriginCountryId int `gorm:"type:int(11);comment:鍘熶骇鍦癷d" json:"originCountryId"` //鍘熶骇鍦癷d
OriginCountryName string `gorm:"type:varchar(255);comment:鍘熶骇鍦板悕绉�" json:"originCountryName"` //鍘熶骇鍦板悕绉�
type: string
+ inputAmount:
+ type: number
internalNotes:
description: 鍐呴儴璇存槑
type: string
@@ -515,6 +517,10 @@
outStorageExplain:
description: 鍑哄簱璇存槑
type: string
+ outputAmount:
+ type: number
+ predictionAmount:
+ type: number
principal:
description: 璐熻矗浜�
type: string
diff --git a/main.go b/main.go
index 0fb90de..9069f9a 100644
--- a/main.go
+++ b/main.go
@@ -15,6 +15,7 @@
"wms/models"
"wms/pkg/logx"
"wms/proto/product_inventory"
+ "wms/proto/purchase_wms"
"wms/router"
)
@@ -58,6 +59,7 @@
s := grpc.NewServer()
//todo 娣诲姞鍏蜂綋鏈嶅姟
product_inventory.RegisterProductInventoryServiceServer(s, &product_inventory.Server{})
+ purchase_wms.RegisterPurchaseServiceServer(s, &purchase_wms.Server{})
err = s.Serve(ln)
if err != nil {
logx.Errorf("grpc server init error: %v", err.Error())
diff --git a/proto/product_inventory/server.go b/proto/product_inventory/server.go
index 5abf83f..bb375e1 100644
--- a/proto/product_inventory/server.go
+++ b/proto/product_inventory/server.go
@@ -156,7 +156,7 @@
}
operation.OperationTypeName = operationType.Name
operation.OperationTypeId = operationType.Id
- location, err := models.NewLocationSearch().SetJointNames([]string{warehouse.Code}).First()
+ location, err := models.NewLocationSearch().SetID(warehouse.LocationId).First()
if err != nil {
return nil, err
}
diff --git a/proto/purchase_wms.proto b/proto/purchase_wms.proto
new file mode 100644
index 0000000..d3c7d3e
--- /dev/null
+++ b/proto/purchase_wms.proto
@@ -0,0 +1,37 @@
+syntax = "proto3";
+
+option go_package = "./purchase_wms";
+
+service PurchaseService {
+ rpc PurchaseToWms(PurchaseToWmsRequest) returns (PurchaseToWmsResponse);
+ rpc UpdatePurchaseStatus(UpdatePurchaseStatusRequest) returns (UpdatePurchaseStatusResponse) {}
+}
+
+
+message PurchaseProduct{
+ string Id = 1;
+ int64 Amount = 2;
+}
+
+message PurchaseToWmsRequest {
+ string Number = 1; //閲囪喘缂栧彿
+ string SupplierName = 2; //渚涘簲鍟�
+ repeated PurchaseProduct Product = 3;
+}
+
+message PurchaseToWmsResponse {
+ int32 code = 1;
+ string message = 2;
+}
+
+//-------------------------------------------------------------------
+
+message UpdatePurchaseStatusRequest {
+ string Number = 1;//閲囪喘缂栧彿
+}
+
+message UpdatePurchaseStatusResponse {
+ int32 Code = 1;
+ string Msg = 2;
+}
+
diff --git a/proto/purchase_wms/purchase_wms.pb.go b/proto/purchase_wms/purchase_wms.pb.go
new file mode 100644
index 0000000..5189495
--- /dev/null
+++ b/proto/purchase_wms/purchase_wms.pb.go
@@ -0,0 +1,459 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// protoc-gen-go v1.26.0
+// protoc v4.24.0
+// source: purchase_wms.proto
+
+package purchase_wms
+
+import (
+ protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+ protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+ reflect "reflect"
+ sync "sync"
+)
+
+const (
+ // Verify that this generated code is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+ // Verify that runtime/protoimpl is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
+
+type PurchaseProduct struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Id string `protobuf:"bytes,1,opt,name=Id,proto3" json:"Id,omitempty"`
+ Amount int64 `protobuf:"varint,2,opt,name=Amount,proto3" json:"Amount,omitempty"`
+}
+
+func (x *PurchaseProduct) Reset() {
+ *x = PurchaseProduct{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_purchase_wms_proto_msgTypes[0]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *PurchaseProduct) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*PurchaseProduct) ProtoMessage() {}
+
+func (x *PurchaseProduct) ProtoReflect() protoreflect.Message {
+ mi := &file_purchase_wms_proto_msgTypes[0]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use PurchaseProduct.ProtoReflect.Descriptor instead.
+func (*PurchaseProduct) Descriptor() ([]byte, []int) {
+ return file_purchase_wms_proto_rawDescGZIP(), []int{0}
+}
+
+func (x *PurchaseProduct) GetId() string {
+ if x != nil {
+ return x.Id
+ }
+ return ""
+}
+
+func (x *PurchaseProduct) GetAmount() int64 {
+ if x != nil {
+ return x.Amount
+ }
+ return 0
+}
+
+type PurchaseToWmsRequest struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Number string `protobuf:"bytes,1,opt,name=Number,proto3" json:"Number,omitempty"` //閲囪喘缂栧彿
+ SupplierName string `protobuf:"bytes,2,opt,name=SupplierName,proto3" json:"SupplierName,omitempty"` //渚涘簲鍟�
+ Product []*PurchaseProduct `protobuf:"bytes,3,rep,name=Product,proto3" json:"Product,omitempty"`
+}
+
+func (x *PurchaseToWmsRequest) Reset() {
+ *x = PurchaseToWmsRequest{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_purchase_wms_proto_msgTypes[1]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *PurchaseToWmsRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*PurchaseToWmsRequest) ProtoMessage() {}
+
+func (x *PurchaseToWmsRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_purchase_wms_proto_msgTypes[1]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use PurchaseToWmsRequest.ProtoReflect.Descriptor instead.
+func (*PurchaseToWmsRequest) Descriptor() ([]byte, []int) {
+ return file_purchase_wms_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *PurchaseToWmsRequest) GetNumber() string {
+ if x != nil {
+ return x.Number
+ }
+ return ""
+}
+
+func (x *PurchaseToWmsRequest) GetSupplierName() string {
+ if x != nil {
+ return x.SupplierName
+ }
+ return ""
+}
+
+func (x *PurchaseToWmsRequest) GetProduct() []*PurchaseProduct {
+ if x != nil {
+ return x.Product
+ }
+ return nil
+}
+
+type PurchaseToWmsResponse struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
+ Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
+}
+
+func (x *PurchaseToWmsResponse) Reset() {
+ *x = PurchaseToWmsResponse{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_purchase_wms_proto_msgTypes[2]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *PurchaseToWmsResponse) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*PurchaseToWmsResponse) ProtoMessage() {}
+
+func (x *PurchaseToWmsResponse) ProtoReflect() protoreflect.Message {
+ mi := &file_purchase_wms_proto_msgTypes[2]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use PurchaseToWmsResponse.ProtoReflect.Descriptor instead.
+func (*PurchaseToWmsResponse) Descriptor() ([]byte, []int) {
+ return file_purchase_wms_proto_rawDescGZIP(), []int{2}
+}
+
+func (x *PurchaseToWmsResponse) GetCode() int32 {
+ if x != nil {
+ return x.Code
+ }
+ return 0
+}
+
+func (x *PurchaseToWmsResponse) GetMessage() string {
+ if x != nil {
+ return x.Message
+ }
+ return ""
+}
+
+type UpdatePurchaseStatusRequest struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Number string `protobuf:"bytes,1,opt,name=Number,proto3" json:"Number,omitempty"` //閲囪喘缂栧彿
+}
+
+func (x *UpdatePurchaseStatusRequest) Reset() {
+ *x = UpdatePurchaseStatusRequest{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_purchase_wms_proto_msgTypes[3]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *UpdatePurchaseStatusRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*UpdatePurchaseStatusRequest) ProtoMessage() {}
+
+func (x *UpdatePurchaseStatusRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_purchase_wms_proto_msgTypes[3]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use UpdatePurchaseStatusRequest.ProtoReflect.Descriptor instead.
+func (*UpdatePurchaseStatusRequest) Descriptor() ([]byte, []int) {
+ return file_purchase_wms_proto_rawDescGZIP(), []int{3}
+}
+
+func (x *UpdatePurchaseStatusRequest) GetNumber() string {
+ if x != nil {
+ return x.Number
+ }
+ return ""
+}
+
+type UpdatePurchaseStatusResponse struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Code int32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"`
+ Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
+}
+
+func (x *UpdatePurchaseStatusResponse) Reset() {
+ *x = UpdatePurchaseStatusResponse{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_purchase_wms_proto_msgTypes[4]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *UpdatePurchaseStatusResponse) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*UpdatePurchaseStatusResponse) ProtoMessage() {}
+
+func (x *UpdatePurchaseStatusResponse) ProtoReflect() protoreflect.Message {
+ mi := &file_purchase_wms_proto_msgTypes[4]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use UpdatePurchaseStatusResponse.ProtoReflect.Descriptor instead.
+func (*UpdatePurchaseStatusResponse) Descriptor() ([]byte, []int) {
+ return file_purchase_wms_proto_rawDescGZIP(), []int{4}
+}
+
+func (x *UpdatePurchaseStatusResponse) GetCode() int32 {
+ if x != nil {
+ return x.Code
+ }
+ return 0
+}
+
+func (x *UpdatePurchaseStatusResponse) GetMsg() string {
+ if x != nil {
+ return x.Msg
+ }
+ return ""
+}
+
+var File_purchase_wms_proto protoreflect.FileDescriptor
+
+var file_purchase_wms_proto_rawDesc = []byte{
+ 0x0a, 0x12, 0x70, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x5f, 0x77, 0x6d, 0x73, 0x2e, 0x70,
+ 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x39, 0x0a, 0x0f, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65,
+ 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20,
+ 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e,
+ 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22,
+ 0x7e, 0x0a, 0x14, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x54, 0x6f, 0x57, 0x6d, 0x73,
+ 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65,
+ 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12,
+ 0x22, 0x0a, 0x0c, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x18,
+ 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x4e,
+ 0x61, 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x18, 0x03,
+ 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x50,
+ 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x07, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x22,
+ 0x45, 0x0a, 0x15, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x54, 0x6f, 0x57, 0x6d, 0x73,
+ 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65,
+ 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07,
+ 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d,
+ 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x35, 0x0a, 0x1b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
+ 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65,
+ 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18,
+ 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x44, 0x0a,
+ 0x1c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x53,
+ 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a,
+ 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64,
+ 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03,
+ 0x4d, 0x73, 0x67, 0x32, 0xa8, 0x01, 0x0a, 0x0f, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65,
+ 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3e, 0x0a, 0x0d, 0x50, 0x75, 0x72, 0x63, 0x68,
+ 0x61, 0x73, 0x65, 0x54, 0x6f, 0x57, 0x6d, 0x73, 0x12, 0x15, 0x2e, 0x50, 0x75, 0x72, 0x63, 0x68,
+ 0x61, 0x73, 0x65, 0x54, 0x6f, 0x57, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
+ 0x16, 0x2e, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x54, 0x6f, 0x57, 0x6d, 0x73, 0x52,
+ 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x55, 0x0a, 0x14, 0x55, 0x70, 0x64, 0x61, 0x74,
+ 0x65, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12,
+ 0x1c, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65,
+ 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e,
+ 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x53, 0x74,
+ 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x10,
+ 0x5a, 0x0e, 0x2e, 0x2f, 0x70, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x5f, 0x77, 0x6d, 0x73,
+ 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+}
+
+var (
+ file_purchase_wms_proto_rawDescOnce sync.Once
+ file_purchase_wms_proto_rawDescData = file_purchase_wms_proto_rawDesc
+)
+
+func file_purchase_wms_proto_rawDescGZIP() []byte {
+ file_purchase_wms_proto_rawDescOnce.Do(func() {
+ file_purchase_wms_proto_rawDescData = protoimpl.X.CompressGZIP(file_purchase_wms_proto_rawDescData)
+ })
+ return file_purchase_wms_proto_rawDescData
+}
+
+var file_purchase_wms_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
+var file_purchase_wms_proto_goTypes = []interface{}{
+ (*PurchaseProduct)(nil), // 0: PurchaseProduct
+ (*PurchaseToWmsRequest)(nil), // 1: PurchaseToWmsRequest
+ (*PurchaseToWmsResponse)(nil), // 2: PurchaseToWmsResponse
+ (*UpdatePurchaseStatusRequest)(nil), // 3: UpdatePurchaseStatusRequest
+ (*UpdatePurchaseStatusResponse)(nil), // 4: UpdatePurchaseStatusResponse
+}
+var file_purchase_wms_proto_depIdxs = []int32{
+ 0, // 0: PurchaseToWmsRequest.Product:type_name -> PurchaseProduct
+ 1, // 1: PurchaseService.PurchaseToWms:input_type -> PurchaseToWmsRequest
+ 3, // 2: PurchaseService.UpdatePurchaseStatus:input_type -> UpdatePurchaseStatusRequest
+ 2, // 3: PurchaseService.PurchaseToWms:output_type -> PurchaseToWmsResponse
+ 4, // 4: PurchaseService.UpdatePurchaseStatus:output_type -> UpdatePurchaseStatusResponse
+ 3, // [3:5] is the sub-list for method output_type
+ 1, // [1:3] is the sub-list for method input_type
+ 1, // [1:1] is the sub-list for extension type_name
+ 1, // [1:1] is the sub-list for extension extendee
+ 0, // [0:1] is the sub-list for field type_name
+}
+
+func init() { file_purchase_wms_proto_init() }
+func file_purchase_wms_proto_init() {
+ if File_purchase_wms_proto != nil {
+ return
+ }
+ if !protoimpl.UnsafeEnabled {
+ file_purchase_wms_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*PurchaseProduct); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_purchase_wms_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*PurchaseToWmsRequest); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_purchase_wms_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*PurchaseToWmsResponse); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_purchase_wms_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*UpdatePurchaseStatusRequest); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_purchase_wms_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*UpdatePurchaseStatusResponse); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ }
+ type x struct{}
+ out := protoimpl.TypeBuilder{
+ File: protoimpl.DescBuilder{
+ GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+ RawDescriptor: file_purchase_wms_proto_rawDesc,
+ NumEnums: 0,
+ NumMessages: 5,
+ NumExtensions: 0,
+ NumServices: 1,
+ },
+ GoTypes: file_purchase_wms_proto_goTypes,
+ DependencyIndexes: file_purchase_wms_proto_depIdxs,
+ MessageInfos: file_purchase_wms_proto_msgTypes,
+ }.Build()
+ File_purchase_wms_proto = out.File
+ file_purchase_wms_proto_rawDesc = nil
+ file_purchase_wms_proto_goTypes = nil
+ file_purchase_wms_proto_depIdxs = nil
+}
diff --git a/proto/purchase_wms/purchase_wms_grpc.pb.go b/proto/purchase_wms/purchase_wms_grpc.pb.go
new file mode 100644
index 0000000..4edcf55
--- /dev/null
+++ b/proto/purchase_wms/purchase_wms_grpc.pb.go
@@ -0,0 +1,137 @@
+// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
+
+package purchase_wms
+
+import (
+ context "context"
+ grpc "google.golang.org/grpc"
+ codes "google.golang.org/grpc/codes"
+ status "google.golang.org/grpc/status"
+)
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the grpc package it is being compiled against.
+// Requires gRPC-Go v1.32.0 or later.
+const _ = grpc.SupportPackageIsVersion7
+
+// PurchaseServiceClient is the client API for PurchaseService service.
+//
+// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
+type PurchaseServiceClient interface {
+ PurchaseToWms(ctx context.Context, in *PurchaseToWmsRequest, opts ...grpc.CallOption) (*PurchaseToWmsResponse, error)
+ UpdatePurchaseStatus(ctx context.Context, in *UpdatePurchaseStatusRequest, opts ...grpc.CallOption) (*UpdatePurchaseStatusResponse, error)
+}
+
+type purchaseServiceClient struct {
+ cc grpc.ClientConnInterface
+}
+
+func NewPurchaseServiceClient(cc grpc.ClientConnInterface) PurchaseServiceClient {
+ return &purchaseServiceClient{cc}
+}
+
+func (c *purchaseServiceClient) PurchaseToWms(ctx context.Context, in *PurchaseToWmsRequest, opts ...grpc.CallOption) (*PurchaseToWmsResponse, error) {
+ out := new(PurchaseToWmsResponse)
+ err := c.cc.Invoke(ctx, "/PurchaseService/PurchaseToWms", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *purchaseServiceClient) UpdatePurchaseStatus(ctx context.Context, in *UpdatePurchaseStatusRequest, opts ...grpc.CallOption) (*UpdatePurchaseStatusResponse, error) {
+ out := new(UpdatePurchaseStatusResponse)
+ err := c.cc.Invoke(ctx, "/PurchaseService/UpdatePurchaseStatus", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+// PurchaseServiceServer is the server API for PurchaseService service.
+// All implementations must embed UnimplementedPurchaseServiceServer
+// for forward compatibility
+type PurchaseServiceServer interface {
+ PurchaseToWms(context.Context, *PurchaseToWmsRequest) (*PurchaseToWmsResponse, error)
+ UpdatePurchaseStatus(context.Context, *UpdatePurchaseStatusRequest) (*UpdatePurchaseStatusResponse, error)
+ mustEmbedUnimplementedPurchaseServiceServer()
+}
+
+// UnimplementedPurchaseServiceServer must be embedded to have forward compatible implementations.
+type UnimplementedPurchaseServiceServer struct {
+}
+
+func (UnimplementedPurchaseServiceServer) PurchaseToWms(context.Context, *PurchaseToWmsRequest) (*PurchaseToWmsResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method PurchaseToWms not implemented")
+}
+func (UnimplementedPurchaseServiceServer) UpdatePurchaseStatus(context.Context, *UpdatePurchaseStatusRequest) (*UpdatePurchaseStatusResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method UpdatePurchaseStatus not implemented")
+}
+func (UnimplementedPurchaseServiceServer) mustEmbedUnimplementedPurchaseServiceServer() {}
+
+// UnsafePurchaseServiceServer may be embedded to opt out of forward compatibility for this service.
+// Use of this interface is not recommended, as added methods to PurchaseServiceServer will
+// result in compilation errors.
+type UnsafePurchaseServiceServer interface {
+ mustEmbedUnimplementedPurchaseServiceServer()
+}
+
+func RegisterPurchaseServiceServer(s grpc.ServiceRegistrar, srv PurchaseServiceServer) {
+ s.RegisterService(&PurchaseService_ServiceDesc, srv)
+}
+
+func _PurchaseService_PurchaseToWms_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(PurchaseToWmsRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(PurchaseServiceServer).PurchaseToWms(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/PurchaseService/PurchaseToWms",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(PurchaseServiceServer).PurchaseToWms(ctx, req.(*PurchaseToWmsRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _PurchaseService_UpdatePurchaseStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(UpdatePurchaseStatusRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(PurchaseServiceServer).UpdatePurchaseStatus(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/PurchaseService/UpdatePurchaseStatus",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(PurchaseServiceServer).UpdatePurchaseStatus(ctx, req.(*UpdatePurchaseStatusRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+// PurchaseService_ServiceDesc is the grpc.ServiceDesc for PurchaseService service.
+// It's only intended for direct use with grpc.RegisterService,
+// and not to be introspected or modified (even as a copy)
+var PurchaseService_ServiceDesc = grpc.ServiceDesc{
+ ServiceName: "PurchaseService",
+ HandlerType: (*PurchaseServiceServer)(nil),
+ Methods: []grpc.MethodDesc{
+ {
+ MethodName: "PurchaseToWms",
+ Handler: _PurchaseService_PurchaseToWms_Handler,
+ },
+ {
+ MethodName: "UpdatePurchaseStatus",
+ Handler: _PurchaseService_UpdatePurchaseStatus_Handler,
+ },
+ },
+ Streams: []grpc.StreamDesc{},
+ Metadata: "purchase_wms.proto",
+}
diff --git a/proto/purchase_wms/server.go b/proto/purchase_wms/server.go
new file mode 100644
index 0000000..e97ce12
--- /dev/null
+++ b/proto/purchase_wms/server.go
@@ -0,0 +1,53 @@
+package purchase_wms
+
+import (
+ "context"
+ "github.com/shopspring/decimal"
+ "strconv"
+ "time"
+ "wms/constvar"
+ "wms/models"
+ "wms/pkg/timex"
+)
+
+type Server struct {
+ UnimplementedPurchaseServiceServer
+}
+
+func (s *Server) PurchaseToWms(c context.Context, req *PurchaseToWmsRequest) (*PurchaseToWmsResponse, error) {
+ var operation models.Operation
+ var details []*models.OperationDetails
+ operation.SourceNumber = req.Number
+ operation.OperationDate = timex.TimeToString2(time.Now())
+ operation.Number = strconv.FormatInt(time.Now().Unix(), 10)
+ operation.Status = constvar.OperationStatus_Ready
+ warehouse, err := models.NewWarehouseSearch().First()
+ if err != nil {
+ return nil, err
+ }
+ operationType, err := models.NewOperationTypeSearch().SetWarehouseId(warehouse.Id).SetBaseOperationType(constvar.BaseOperationTypeIncoming).First()
+ if err != nil {
+ return nil, err
+ }
+ operation.OperationTypeName = operationType.Name
+ operation.OperationTypeId = operationType.Id
+ location, err := models.NewLocationSearch().SetID(warehouse.LocationId).First()
+ if err != nil {
+ return nil, err
+ }
+ operation.ToLocationID = location.Id
+ first, err := models.NewLocationSearch().SetType(int(constvar.LocationTypeVendor)).First()
+ if err != nil {
+ return nil, err
+ }
+ operation.FromLocationID = first.Id
+ operation.BaseOperationType = constvar.BaseOperationTypeIncoming
+ for _, product := range req.Product {
+ var detail models.OperationDetails
+ detail.ProductId = product.Id
+ detail.Amount = decimal.NewFromInt(product.Amount)
+ details = append(details, &detail)
+ }
+ err = models.NewOperationSearch().Create(&operation)
+ return new(PurchaseToWmsResponse), err
+}
--
Gitblit v1.8.0