From dc73bb0a098f9c176ea4b6e920a5e70d9a618833 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期一, 27 十一月 2023 16:52:39 +0800
Subject: [PATCH] aps插入出库操作

---
 proto/inventory_order/server.go                  |   74 +++++++++
 proto/inventory_order.proto                      |   24 ++
 proto/inventory_order/inventory_order.pb.go      |  324 ++++++++++++++++++++++++++++++++++++++--
 proto/inventory_order/inventory_order_grpc.pb.go |   36 ++++
 main.go                                          |    2 
 proto/product_inventory/server.go                |    3 
 6 files changed, 442 insertions(+), 21 deletions(-)

diff --git a/main.go b/main.go
index 91c2eeb..68e32ad 100644
--- a/main.go
+++ b/main.go
@@ -15,6 +15,7 @@
 	"wms/models"
 	"wms/pkg/logx"
 	"wms/proto/client"
+	"wms/proto/inventory_order"
 	"wms/proto/product_inventory"
 	"wms/proto/purchase_wms"
 	"wms/proto/supplier"
@@ -65,6 +66,7 @@
 		//todo 娣诲姞鍏蜂綋鏈嶅姟
 		product_inventory.RegisterProductInventoryServiceServer(s, &product_inventory.Server{})
 		purchase_wms.RegisterPurchaseServiceServer(s, &purchase_wms.Server{})
+		inventory_order.RegisterInventoryOrderServiceServer(s, &inventory_order.Server{})
 		err = s.Serve(ln)
 		if err != nil {
 			logx.Errorf("grpc server init error: %v", err.Error())
diff --git a/proto/inventory_order.proto b/proto/inventory_order.proto
index 113c6de..b624137 100644
--- a/proto/inventory_order.proto
+++ b/proto/inventory_order.proto
@@ -4,6 +4,7 @@
 
 service inventoryOrderService {
   rpc CreateNewOrder(CreateNewOrderRequest) returns(CreateNewOrderResponse) {}
+  rpc CreateOperationList(CreateOperationListRequest) returns(CreateOperationListResponse) {}
 }
 
 message CreateNewOrderRequest{
@@ -17,4 +18,25 @@
   int32   Code = 1;
   string  Msg = 2;
   string OrderId = 3;
-}
\ No newline at end of file
+}
+
+//-------------------------------------------------------CreateOperationList------------------------------------
+
+message OperationProduct {
+  string ProductNumber = 1;
+  int64 Amount = 2;
+}
+
+message OperationList {
+  string SourceNumber = 1;
+  repeated OperationProduct Products = 2;
+}
+
+message CreateOperationListRequest{
+  int64 OperationType = 1;
+  repeated OperationList List = 2;
+}
+
+message CreateOperationListResponse{
+}
+
diff --git a/proto/inventory_order/inventory_order.pb.go b/proto/inventory_order/inventory_order.pb.go
index 6fe5871..d65e27b 100644
--- a/proto/inventory_order/inventory_order.pb.go
+++ b/proto/inventory_order/inventory_order.pb.go
@@ -154,6 +154,209 @@
 	return ""
 }
 
+type OperationProduct struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	ProductNumber string `protobuf:"bytes,1,opt,name=ProductNumber,proto3" json:"ProductNumber,omitempty"`
+	Amount        int64  `protobuf:"varint,2,opt,name=Amount,proto3" json:"Amount,omitempty"`
+}
+
+func (x *OperationProduct) Reset() {
+	*x = OperationProduct{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_inventory_order_proto_msgTypes[2]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *OperationProduct) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*OperationProduct) ProtoMessage() {}
+
+func (x *OperationProduct) ProtoReflect() protoreflect.Message {
+	mi := &file_inventory_order_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 OperationProduct.ProtoReflect.Descriptor instead.
+func (*OperationProduct) Descriptor() ([]byte, []int) {
+	return file_inventory_order_proto_rawDescGZIP(), []int{2}
+}
+
+func (x *OperationProduct) GetProductNumber() string {
+	if x != nil {
+		return x.ProductNumber
+	}
+	return ""
+}
+
+func (x *OperationProduct) GetAmount() int64 {
+	if x != nil {
+		return x.Amount
+	}
+	return 0
+}
+
+type OperationList struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	SourceNumber string              `protobuf:"bytes,1,opt,name=SourceNumber,proto3" json:"SourceNumber,omitempty"`
+	Products     []*OperationProduct `protobuf:"bytes,2,rep,name=Products,proto3" json:"Products,omitempty"`
+}
+
+func (x *OperationList) Reset() {
+	*x = OperationList{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_inventory_order_proto_msgTypes[3]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *OperationList) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*OperationList) ProtoMessage() {}
+
+func (x *OperationList) ProtoReflect() protoreflect.Message {
+	mi := &file_inventory_order_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 OperationList.ProtoReflect.Descriptor instead.
+func (*OperationList) Descriptor() ([]byte, []int) {
+	return file_inventory_order_proto_rawDescGZIP(), []int{3}
+}
+
+func (x *OperationList) GetSourceNumber() string {
+	if x != nil {
+		return x.SourceNumber
+	}
+	return ""
+}
+
+func (x *OperationList) GetProducts() []*OperationProduct {
+	if x != nil {
+		return x.Products
+	}
+	return nil
+}
+
+type CreateOperationListRequest struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	OperationType int64            `protobuf:"varint,1,opt,name=OperationType,proto3" json:"OperationType,omitempty"`
+	List          []*OperationList `protobuf:"bytes,2,rep,name=List,proto3" json:"List,omitempty"`
+}
+
+func (x *CreateOperationListRequest) Reset() {
+	*x = CreateOperationListRequest{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_inventory_order_proto_msgTypes[4]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *CreateOperationListRequest) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*CreateOperationListRequest) ProtoMessage() {}
+
+func (x *CreateOperationListRequest) ProtoReflect() protoreflect.Message {
+	mi := &file_inventory_order_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 CreateOperationListRequest.ProtoReflect.Descriptor instead.
+func (*CreateOperationListRequest) Descriptor() ([]byte, []int) {
+	return file_inventory_order_proto_rawDescGZIP(), []int{4}
+}
+
+func (x *CreateOperationListRequest) GetOperationType() int64 {
+	if x != nil {
+		return x.OperationType
+	}
+	return 0
+}
+
+func (x *CreateOperationListRequest) GetList() []*OperationList {
+	if x != nil {
+		return x.List
+	}
+	return nil
+}
+
+type CreateOperationListResponse struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+}
+
+func (x *CreateOperationListResponse) Reset() {
+	*x = CreateOperationListResponse{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_inventory_order_proto_msgTypes[5]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *CreateOperationListResponse) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*CreateOperationListResponse) ProtoMessage() {}
+
+func (x *CreateOperationListResponse) ProtoReflect() protoreflect.Message {
+	mi := &file_inventory_order_proto_msgTypes[5]
+	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 CreateOperationListResponse.ProtoReflect.Descriptor instead.
+func (*CreateOperationListResponse) Descriptor() ([]byte, []int) {
+	return file_inventory_order_proto_rawDescGZIP(), []int{5}
+}
+
 var File_inventory_order_proto protoreflect.FileDescriptor
 
 var file_inventory_order_proto_rawDesc = []byte{
@@ -172,15 +375,40 @@
 	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, 0x12, 0x18, 0x0a, 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01,
-	0x28, 0x09, 0x52, 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x32, 0x5c, 0x0a, 0x15, 0x69,
-	0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x53, 0x65, 0x72,
-	0x76, 0x69, 0x63, 0x65, 0x12, 0x43, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x65,
-	0x77, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e,
-	0x65, 0x77, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17,
-	0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x65, 0x77, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52,
-	0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x13, 0x5a, 0x11, 0x2e, 0x2f, 0x69,
-	0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x62, 0x06,
-	0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x28, 0x09, 0x52, 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x22, 0x50, 0x0a, 0x10, 0x4f,
+	0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x12,
+	0x24, 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72,
+	0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4e,
+	0x75, 0x6d, 0x62, 0x65, 0x72, 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, 0x62, 0x0a,
+	0x0d, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x22,
+	0x0a, 0x0c, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01,
+	0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, 0x75, 0x6d, 0x62,
+	0x65, 0x72, 0x12, 0x2d, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x18, 0x02,
+	0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
+	0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x08, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74,
+	0x73, 0x22, 0x66, 0x0a, 0x1a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x70, 0x65, 0x72, 0x61,
+	0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
+	0x24, 0x0a, 0x0d, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65,
+	0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f,
+	0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x22, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x02, 0x20,
+	0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c,
+	0x69, 0x73, 0x74, 0x52, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x1d, 0x0a, 0x1b, 0x43, 0x72, 0x65,
+	0x61, 0x74, 0x65, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x73, 0x74,
+	0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xb0, 0x01, 0x0a, 0x15, 0x69, 0x6e, 0x76,
+	0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69,
+	0x63, 0x65, 0x12, 0x43, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x65, 0x77, 0x4f,
+	0x72, 0x64, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x65, 0x77,
+	0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x43,
+	0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x65, 0x77, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73,
+	0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x52, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74,
+	0x65, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1b,
+	0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
+	0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x43, 0x72,
+	0x65, 0x61, 0x74, 0x65, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x69, 0x73,
+	0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x13, 0x5a, 0x11, 0x2e,
+	0x2f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x6f, 0x72, 0x64, 0x65, 0x72,
+	0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -195,19 +423,27 @@
 	return file_inventory_order_proto_rawDescData
 }
 
-var file_inventory_order_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
+var file_inventory_order_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
 var file_inventory_order_proto_goTypes = []interface{}{
-	(*CreateNewOrderRequest)(nil),  // 0: CreateNewOrderRequest
-	(*CreateNewOrderResponse)(nil), // 1: CreateNewOrderResponse
+	(*CreateNewOrderRequest)(nil),       // 0: CreateNewOrderRequest
+	(*CreateNewOrderResponse)(nil),      // 1: CreateNewOrderResponse
+	(*OperationProduct)(nil),            // 2: OperationProduct
+	(*OperationList)(nil),               // 3: OperationList
+	(*CreateOperationListRequest)(nil),  // 4: CreateOperationListRequest
+	(*CreateOperationListResponse)(nil), // 5: CreateOperationListResponse
 }
 var file_inventory_order_proto_depIdxs = []int32{
-	0, // 0: inventoryOrderService.CreateNewOrder:input_type -> CreateNewOrderRequest
-	1, // 1: inventoryOrderService.CreateNewOrder:output_type -> CreateNewOrderResponse
-	1, // [1:2] is the sub-list for method output_type
-	0, // [0:1] is the sub-list for method input_type
-	0, // [0:0] is the sub-list for extension type_name
-	0, // [0:0] is the sub-list for extension extendee
-	0, // [0:0] is the sub-list for field type_name
+	2, // 0: OperationList.Products:type_name -> OperationProduct
+	3, // 1: CreateOperationListRequest.List:type_name -> OperationList
+	0, // 2: inventoryOrderService.CreateNewOrder:input_type -> CreateNewOrderRequest
+	4, // 3: inventoryOrderService.CreateOperationList:input_type -> CreateOperationListRequest
+	1, // 4: inventoryOrderService.CreateNewOrder:output_type -> CreateNewOrderResponse
+	5, // 5: inventoryOrderService.CreateOperationList:output_type -> CreateOperationListResponse
+	4, // [4:6] is the sub-list for method output_type
+	2, // [2:4] is the sub-list for method input_type
+	2, // [2:2] is the sub-list for extension type_name
+	2, // [2:2] is the sub-list for extension extendee
+	0, // [0:2] is the sub-list for field type_name
 }
 
 func init() { file_inventory_order_proto_init() }
@@ -240,6 +476,54 @@
 				return nil
 			}
 		}
+		file_inventory_order_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*OperationProduct); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_inventory_order_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*OperationList); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_inventory_order_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*CreateOperationListRequest); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_inventory_order_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*CreateOperationListResponse); 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{
@@ -247,7 +531,7 @@
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_inventory_order_proto_rawDesc,
 			NumEnums:      0,
-			NumMessages:   2,
+			NumMessages:   6,
 			NumExtensions: 0,
 			NumServices:   1,
 		},
diff --git a/proto/inventory_order/inventory_order_grpc.pb.go b/proto/inventory_order/inventory_order_grpc.pb.go
index eaeb0a2..fd1952a 100644
--- a/proto/inventory_order/inventory_order_grpc.pb.go
+++ b/proto/inventory_order/inventory_order_grpc.pb.go
@@ -19,6 +19,7 @@
 // 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 InventoryOrderServiceClient interface {
 	CreateNewOrder(ctx context.Context, in *CreateNewOrderRequest, opts ...grpc.CallOption) (*CreateNewOrderResponse, error)
+	CreateOperationList(ctx context.Context, in *CreateOperationListRequest, opts ...grpc.CallOption) (*CreateOperationListResponse, error)
 }
 
 type inventoryOrderServiceClient struct {
@@ -38,11 +39,21 @@
 	return out, nil
 }
 
+func (c *inventoryOrderServiceClient) CreateOperationList(ctx context.Context, in *CreateOperationListRequest, opts ...grpc.CallOption) (*CreateOperationListResponse, error) {
+	out := new(CreateOperationListResponse)
+	err := c.cc.Invoke(ctx, "/inventoryOrderService/CreateOperationList", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // InventoryOrderServiceServer is the server API for InventoryOrderService service.
 // All implementations must embed UnimplementedInventoryOrderServiceServer
 // for forward compatibility
 type InventoryOrderServiceServer interface {
 	CreateNewOrder(context.Context, *CreateNewOrderRequest) (*CreateNewOrderResponse, error)
+	CreateOperationList(context.Context, *CreateOperationListRequest) (*CreateOperationListResponse, error)
 	mustEmbedUnimplementedInventoryOrderServiceServer()
 }
 
@@ -52,6 +63,9 @@
 
 func (UnimplementedInventoryOrderServiceServer) CreateNewOrder(context.Context, *CreateNewOrderRequest) (*CreateNewOrderResponse, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method CreateNewOrder not implemented")
+}
+func (UnimplementedInventoryOrderServiceServer) CreateOperationList(context.Context, *CreateOperationListRequest) (*CreateOperationListResponse, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method CreateOperationList not implemented")
 }
 func (UnimplementedInventoryOrderServiceServer) mustEmbedUnimplementedInventoryOrderServiceServer() {}
 
@@ -84,6 +98,24 @@
 	return interceptor(ctx, in, info, handler)
 }
 
+func _InventoryOrderService_CreateOperationList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(CreateOperationListRequest)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(InventoryOrderServiceServer).CreateOperationList(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/inventoryOrderService/CreateOperationList",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(InventoryOrderServiceServer).CreateOperationList(ctx, req.(*CreateOperationListRequest))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 // InventoryOrderService_ServiceDesc is the grpc.ServiceDesc for InventoryOrderService service.
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
@@ -95,6 +127,10 @@
 			MethodName: "CreateNewOrder",
 			Handler:    _InventoryOrderService_CreateNewOrder_Handler,
 		},
+		{
+			MethodName: "CreateOperationList",
+			Handler:    _InventoryOrderService_CreateOperationList_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "inventory_order.proto",
diff --git a/proto/inventory_order/server.go b/proto/inventory_order/server.go
new file mode 100644
index 0000000..884c8d9
--- /dev/null
+++ b/proto/inventory_order/server.go
@@ -0,0 +1,74 @@
+package inventory_order
+
+import (
+	"context"
+	"github.com/shopspring/decimal"
+	"strconv"
+	"time"
+	"wms/constvar"
+	"wms/models"
+	"wms/pkg/timex"
+)
+
+type Server struct {
+	UnimplementedInventoryOrderServiceServer
+}
+
+func (s *Server) CreateOperationList(ctx context.Context, req *CreateOperationListRequest) (*CreateOperationListResponse, error) {
+	var operations []*models.Operation
+	warehouse, err := models.NewWarehouseSearch().First()
+	if err != nil {
+		return nil, err
+	}
+	fromLocation, err := models.NewLocationSearch().SetID(warehouse.LocationId).First()
+	if err != nil {
+		return nil, err
+	}
+	toLocation, err := models.NewLocationSearch().SetType(int(constvar.LocationTypeCustomer)).First()
+	if err != nil {
+		return nil, err
+	}
+	tp := constvar.BaseOperationTypeOutgoing
+	if req.OperationType == 1 {
+		tp = constvar.BaseOperationTypeIncoming
+		fromLocation, err = models.NewLocationSearch().SetType(int(constvar.LocationTypeVendor)).First()
+		if err != nil {
+			return nil, err
+		}
+		toLocation, err = models.NewLocationSearch().SetID(warehouse.LocationId).First()
+		if err != nil {
+			return nil, err
+		}
+	}
+	operationType, err := models.NewOperationTypeSearch().SetWarehouseId(warehouse.Id).SetBaseOperationType(tp).First()
+	if err != nil {
+		return nil, err
+	}
+	for _, list := range req.List {
+		var operation models.Operation
+		var details []*models.OperationDetails
+		operation.SourceNumber = list.SourceNumber
+		operation.OperationDate = timex.TimeToString2(time.Now())
+		operation.Number = strconv.FormatInt(time.Now().Unix(), 10)
+		operation.Status = constvar.OperationStatus_Ready
+		operation.OperationTypeName = operationType.Name
+		operation.OperationTypeId = operationType.Id
+		operation.FromLocationID = fromLocation.Id
+		operation.ToLocationID = toLocation.Id
+		operation.BaseOperationType = constvar.BaseOperationTypeOutgoing
+		if req.OperationType == 1 {
+			operation.BaseOperationType = constvar.BaseOperationTypeIncoming
+		}
+		for _, product := range list.Products {
+			var detail models.OperationDetails
+			detail.ProductId = product.ProductNumber
+			detail.Amount = decimal.NewFromInt(product.Amount)
+			details = append(details, &detail)
+		}
+		operation.Details = details
+		operations = append(operations, &operation)
+	}
+	err = models.NewOperationSearch().CreateBatch(operations)
+	resp := new(CreateOperationListResponse)
+	return resp, err
+}
diff --git a/proto/product_inventory/server.go b/proto/product_inventory/server.go
index bb375e1..1b624b7 100644
--- a/proto/product_inventory/server.go
+++ b/proto/product_inventory/server.go
@@ -167,6 +167,9 @@
 	}
 	operation.ToLocationID = first.Id
 	operation.BaseOperationType = constvar.BaseOperationTypeOutgoing
+	operation.ReceiverName = req.Addressee
+	operation.ReceiverPhone = req.Phone
+	operation.ReceiverAddr = req.Address
 	if req.DeliverType == 1 {
 		for _, product := range req.ProductList {
 			var detail models.OperationDetails

--
Gitblit v1.8.0