| | |
| | | "wms/models" |
| | | "wms/pkg/logx" |
| | | "wms/proto/client" |
| | | "wms/proto/inventory_order" |
| | | "wms/proto/product_inventory" |
| | | "wms/proto/purchase_wms" |
| | | "wms/proto/supplier" |
| | |
| | | //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()) |
| | |
| | | |
| | | service inventoryOrderService { |
| | | rpc CreateNewOrder(CreateNewOrderRequest) returns(CreateNewOrderResponse) {} |
| | | rpc CreateOperationList(CreateOperationListRequest) returns(CreateOperationListResponse) {} |
| | | } |
| | | |
| | | message CreateNewOrderRequest{ |
| | |
| | | int32 Code = 1; |
| | | string Msg = 2; |
| | | string OrderId = 3; |
| | | } |
| | | } |
| | | |
| | | //-------------------------------------------------------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{ |
| | | } |
| | | |
| | |
| | | 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{ |
| | |
| | | 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 ( |
| | |
| | | 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() } |
| | |
| | | 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{ |
| | |
| | | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), |
| | | RawDescriptor: file_inventory_order_proto_rawDesc, |
| | | NumEnums: 0, |
| | | NumMessages: 2, |
| | | NumMessages: 6, |
| | | NumExtensions: 0, |
| | | NumServices: 1, |
| | | }, |
| | |
| | | // 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 { |
| | |
| | | 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() |
| | | } |
| | | |
| | |
| | | |
| | | 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() {} |
| | | |
| | |
| | | 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) |
| | |
| | | MethodName: "CreateNewOrder", |
| | | Handler: _InventoryOrderService_CreateNewOrder_Handler, |
| | | }, |
| | | { |
| | | MethodName: "CreateOperationList", |
| | | Handler: _InventoryOrderService_CreateOperationList_Handler, |
| | | }, |
| | | }, |
| | | Streams: []grpc.StreamDesc{}, |
| | | Metadata: "inventory_order.proto", |
New file |
| | |
| | | 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 |
| | | } |
| | |
| | | } |
| | | 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 |