From b90a5f64d8da785b2d6a0f3d4ded721f84f2ed8e Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期一, 18 三月 2024 15:59:42 +0800 Subject: [PATCH] crm查询采购信息2 --- /dev/null | 45 --------------------------------------------- main.go | 2 -- proto/purchase_wms/server.go | 1 - 3 files changed, 0 insertions(+), 48 deletions(-) diff --git a/main.go b/main.go index 2c657ed..2b4c8d8 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,6 @@ "google.golang.org/grpc" "net" "srm/api/v1/test" - "srm/proto/crm_srm" "srm/proto/purchase_wms" "srm/proto/qualityinspect" "srm/proto/supplier" @@ -51,7 +50,6 @@ //todo 娣诲姞鍏蜂綋鏈嶅姟 purchase_wms.RegisterPurchaseServiceServer(s, &purchase_wms.Server{}) supplier.RegisterSupplierServiceServer(s, &supplier.Server{}) - crm_srm.RegisterCrmAndSrmServiceServer(s, &crm_srm.Server{}) err = s.Serve(ln) if err != nil { global.GVA_LOG.Error("grpc server init error: %v", zap.Error(err)) diff --git a/proto/crm_srm.proto b/proto/crm_srm.proto deleted file mode 100644 index be954c9..0000000 --- a/proto/crm_srm.proto +++ /dev/null @@ -1,21 +0,0 @@ -syntax = "proto3"; - -option go_package = "./crm_srm"; - -service CrmAndSrmService { - rpc CrmGetPurchaseInfo(CrmGetPurchaseInfoRequest) returns(CrmGetPurchaseInfoResponse) {} -} - -message CrmGetPurchaseInfoRequest{ - string SalesDetailsNumber = 1; -} - -message CrmGetPurchaseInfo { - int64 Amount = 1; - int64 FinishAmount = 2; - string ProductId = 3; -} - -message CrmGetPurchaseInfoResponse{ - repeated CrmGetPurchaseInfo Info = 1; -} \ No newline at end of file diff --git a/proto/crm_srm/crm_srm.pb.go b/proto/crm_srm/crm_srm.pb.go deleted file mode 100644 index ec0f7e6..0000000 --- a/proto/crm_srm/crm_srm.pb.go +++ /dev/null @@ -1,300 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.26.0 -// protoc v4.24.0 -// source: crm_srm.proto - -package crm_srm - -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 CrmGetPurchaseInfoRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - SalesDetailsNumber string `protobuf:"bytes,1,opt,name=SalesDetailsNumber,proto3" json:"SalesDetailsNumber,omitempty"` -} - -func (x *CrmGetPurchaseInfoRequest) Reset() { - *x = CrmGetPurchaseInfoRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_crm_srm_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CrmGetPurchaseInfoRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CrmGetPurchaseInfoRequest) ProtoMessage() {} - -func (x *CrmGetPurchaseInfoRequest) ProtoReflect() protoreflect.Message { - mi := &file_crm_srm_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 CrmGetPurchaseInfoRequest.ProtoReflect.Descriptor instead. -func (*CrmGetPurchaseInfoRequest) Descriptor() ([]byte, []int) { - return file_crm_srm_proto_rawDescGZIP(), []int{0} -} - -func (x *CrmGetPurchaseInfoRequest) GetSalesDetailsNumber() string { - if x != nil { - return x.SalesDetailsNumber - } - return "" -} - -type CrmGetPurchaseInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Amount int64 `protobuf:"varint,1,opt,name=Amount,proto3" json:"Amount,omitempty"` - FinishAmount int64 `protobuf:"varint,2,opt,name=FinishAmount,proto3" json:"FinishAmount,omitempty"` - ProductId string `protobuf:"bytes,3,opt,name=ProductId,proto3" json:"ProductId,omitempty"` -} - -func (x *CrmGetPurchaseInfo) Reset() { - *x = CrmGetPurchaseInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_crm_srm_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CrmGetPurchaseInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CrmGetPurchaseInfo) ProtoMessage() {} - -func (x *CrmGetPurchaseInfo) ProtoReflect() protoreflect.Message { - mi := &file_crm_srm_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 CrmGetPurchaseInfo.ProtoReflect.Descriptor instead. -func (*CrmGetPurchaseInfo) Descriptor() ([]byte, []int) { - return file_crm_srm_proto_rawDescGZIP(), []int{1} -} - -func (x *CrmGetPurchaseInfo) GetAmount() int64 { - if x != nil { - return x.Amount - } - return 0 -} - -func (x *CrmGetPurchaseInfo) GetFinishAmount() int64 { - if x != nil { - return x.FinishAmount - } - return 0 -} - -func (x *CrmGetPurchaseInfo) GetProductId() string { - if x != nil { - return x.ProductId - } - return "" -} - -type CrmGetPurchaseInfoResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Info []*CrmGetPurchaseInfo `protobuf:"bytes,1,rep,name=Info,proto3" json:"Info,omitempty"` -} - -func (x *CrmGetPurchaseInfoResponse) Reset() { - *x = CrmGetPurchaseInfoResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_crm_srm_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CrmGetPurchaseInfoResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CrmGetPurchaseInfoResponse) ProtoMessage() {} - -func (x *CrmGetPurchaseInfoResponse) ProtoReflect() protoreflect.Message { - mi := &file_crm_srm_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 CrmGetPurchaseInfoResponse.ProtoReflect.Descriptor instead. -func (*CrmGetPurchaseInfoResponse) Descriptor() ([]byte, []int) { - return file_crm_srm_proto_rawDescGZIP(), []int{2} -} - -func (x *CrmGetPurchaseInfoResponse) GetInfo() []*CrmGetPurchaseInfo { - if x != nil { - return x.Info - } - return nil -} - -var File_crm_srm_proto protoreflect.FileDescriptor - -var file_crm_srm_proto_rawDesc = []byte{ - 0x0a, 0x0d, 0x63, 0x72, 0x6d, 0x5f, 0x73, 0x72, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0x4b, 0x0a, 0x19, 0x43, 0x72, 0x6d, 0x47, 0x65, 0x74, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, - 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2e, 0x0a, 0x12, - 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x4e, 0x75, 0x6d, 0x62, - 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, - 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x6e, 0x0a, 0x12, - 0x43, 0x72, 0x6d, 0x47, 0x65, 0x74, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e, - 0x66, 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x46, 0x69, - 0x6e, 0x69, 0x73, 0x68, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x0c, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1c, - 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x22, 0x45, 0x0a, 0x1a, - 0x43, 0x72, 0x6d, 0x47, 0x65, 0x74, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e, - 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x04, 0x49, 0x6e, - 0x66, 0x6f, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x43, 0x72, 0x6d, 0x47, 0x65, - 0x74, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x49, - 0x6e, 0x66, 0x6f, 0x32, 0x63, 0x0a, 0x10, 0x43, 0x72, 0x6d, 0x41, 0x6e, 0x64, 0x53, 0x72, 0x6d, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4f, 0x0a, 0x12, 0x43, 0x72, 0x6d, 0x47, 0x65, - 0x74, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1a, 0x2e, - 0x43, 0x72, 0x6d, 0x47, 0x65, 0x74, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e, - 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x43, 0x72, 0x6d, 0x47, - 0x65, 0x74, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0b, 0x5a, 0x09, 0x2e, 0x2f, 0x63, 0x72, - 0x6d, 0x5f, 0x73, 0x72, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_crm_srm_proto_rawDescOnce sync.Once - file_crm_srm_proto_rawDescData = file_crm_srm_proto_rawDesc -) - -func file_crm_srm_proto_rawDescGZIP() []byte { - file_crm_srm_proto_rawDescOnce.Do(func() { - file_crm_srm_proto_rawDescData = protoimpl.X.CompressGZIP(file_crm_srm_proto_rawDescData) - }) - return file_crm_srm_proto_rawDescData -} - -var file_crm_srm_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_crm_srm_proto_goTypes = []interface{}{ - (*CrmGetPurchaseInfoRequest)(nil), // 0: CrmGetPurchaseInfoRequest - (*CrmGetPurchaseInfo)(nil), // 1: CrmGetPurchaseInfo - (*CrmGetPurchaseInfoResponse)(nil), // 2: CrmGetPurchaseInfoResponse -} -var file_crm_srm_proto_depIdxs = []int32{ - 1, // 0: CrmGetPurchaseInfoResponse.Info:type_name -> CrmGetPurchaseInfo - 0, // 1: CrmAndSrmService.CrmGetPurchaseInfo:input_type -> CrmGetPurchaseInfoRequest - 2, // 2: CrmAndSrmService.CrmGetPurchaseInfo:output_type -> CrmGetPurchaseInfoResponse - 2, // [2:3] is the sub-list for method output_type - 1, // [1:2] 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_crm_srm_proto_init() } -func file_crm_srm_proto_init() { - if File_crm_srm_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_crm_srm_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CrmGetPurchaseInfoRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_crm_srm_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CrmGetPurchaseInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_crm_srm_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CrmGetPurchaseInfoResponse); 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_crm_srm_proto_rawDesc, - NumEnums: 0, - NumMessages: 3, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_crm_srm_proto_goTypes, - DependencyIndexes: file_crm_srm_proto_depIdxs, - MessageInfos: file_crm_srm_proto_msgTypes, - }.Build() - File_crm_srm_proto = out.File - file_crm_srm_proto_rawDesc = nil - file_crm_srm_proto_goTypes = nil - file_crm_srm_proto_depIdxs = nil -} diff --git a/proto/crm_srm/crm_srm_grpc.pb.go b/proto/crm_srm/crm_srm_grpc.pb.go deleted file mode 100644 index 6ed2547..0000000 --- a/proto/crm_srm/crm_srm_grpc.pb.go +++ /dev/null @@ -1,101 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. - -package crm_srm - -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 - -// CrmAndSrmServiceClient is the client API for CrmAndSrmService 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 CrmAndSrmServiceClient interface { - CrmGetPurchaseInfo(ctx context.Context, in *CrmGetPurchaseInfoRequest, opts ...grpc.CallOption) (*CrmGetPurchaseInfoResponse, error) -} - -type crmAndSrmServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewCrmAndSrmServiceClient(cc grpc.ClientConnInterface) CrmAndSrmServiceClient { - return &crmAndSrmServiceClient{cc} -} - -func (c *crmAndSrmServiceClient) CrmGetPurchaseInfo(ctx context.Context, in *CrmGetPurchaseInfoRequest, opts ...grpc.CallOption) (*CrmGetPurchaseInfoResponse, error) { - out := new(CrmGetPurchaseInfoResponse) - err := c.cc.Invoke(ctx, "/CrmAndSrmService/CrmGetPurchaseInfo", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// CrmAndSrmServiceServer is the server API for CrmAndSrmService service. -// All implementations must embed UnimplementedCrmAndSrmServiceServer -// for forward compatibility -type CrmAndSrmServiceServer interface { - CrmGetPurchaseInfo(context.Context, *CrmGetPurchaseInfoRequest) (*CrmGetPurchaseInfoResponse, error) - mustEmbedUnimplementedCrmAndSrmServiceServer() -} - -// UnimplementedCrmAndSrmServiceServer must be embedded to have forward compatible implementations. -type UnimplementedCrmAndSrmServiceServer struct { -} - -func (UnimplementedCrmAndSrmServiceServer) CrmGetPurchaseInfo(context.Context, *CrmGetPurchaseInfoRequest) (*CrmGetPurchaseInfoResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CrmGetPurchaseInfo not implemented") -} -func (UnimplementedCrmAndSrmServiceServer) mustEmbedUnimplementedCrmAndSrmServiceServer() {} - -// UnsafeCrmAndSrmServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to CrmAndSrmServiceServer will -// result in compilation errors. -type UnsafeCrmAndSrmServiceServer interface { - mustEmbedUnimplementedCrmAndSrmServiceServer() -} - -func RegisterCrmAndSrmServiceServer(s grpc.ServiceRegistrar, srv CrmAndSrmServiceServer) { - s.RegisterService(&CrmAndSrmService_ServiceDesc, srv) -} - -func _CrmAndSrmService_CrmGetPurchaseInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CrmGetPurchaseInfoRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CrmAndSrmServiceServer).CrmGetPurchaseInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/CrmAndSrmService/CrmGetPurchaseInfo", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CrmAndSrmServiceServer).CrmGetPurchaseInfo(ctx, req.(*CrmGetPurchaseInfoRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// CrmAndSrmService_ServiceDesc is the grpc.ServiceDesc for CrmAndSrmService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var CrmAndSrmService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "CrmAndSrmService", - HandlerType: (*CrmAndSrmServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "CrmGetPurchaseInfo", - Handler: _CrmAndSrmService_CrmGetPurchaseInfo_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "crm_srm.proto", -} diff --git a/proto/crm_srm/server.go b/proto/crm_srm/server.go deleted file mode 100644 index 8909db1..0000000 --- a/proto/crm_srm/server.go +++ /dev/null @@ -1,45 +0,0 @@ -package crm_srm - -import ( - "context" - "errors" - "srm/global" - "srm/model/purchase" -) - -type Server struct { - UnimplementedCrmAndSrmServiceServer -} - -func (s *Server) CrmGetPurchaseInfo(ctx context.Context, req *CrmGetPurchaseInfoRequest) (*CrmGetPurchaseInfoResponse, error) { - if req.SalesDetailsNumber == "" { - return nil, errors.New("閲囪喘鍗曠紪鐮佷笉鑳戒负绌�") - } - var ps purchase.Purchase - err := global.GVA_DB.Model(&purchase.Purchase{}).Where("source_order = ?", req.SalesDetailsNumber).Preload("Supplier").First(&ps).Error - if err != nil { - return nil, err - } - pps := make([]*purchase.PurchaseProducts, 0) - err = global.GVA_DB.Model(&purchase.PurchaseProducts{}).Where("purchase_id = ?", ps.ID).Preload("Product").Find(&pps).Error - if err != nil { - return nil, err - } - info := make([]*CrmGetPurchaseInfo, 0) - flag := false - if ps.Status == purchase.OrderStatusStored || ps.Status == purchase.OrderStatusCompleted { - flag = true - } - for _, pp := range pps { - var cgpi CrmGetPurchaseInfo - cgpi.ProductId = pp.Product.Number - cgpi.Amount = pp.Amount.IntPart() - if flag { - cgpi.FinishAmount = cgpi.Amount - } - info = append(info, &cgpi) - } - resp := new(CrmGetPurchaseInfoResponse) - resp.Info = info - return resp, nil -} diff --git a/proto/purchase_wms/server.go b/proto/purchase_wms/server.go index f7339e7..434dedd 100644 --- a/proto/purchase_wms/server.go +++ b/proto/purchase_wms/server.go @@ -168,7 +168,6 @@ info.ProductName = pp.Product.Name info.Specs = pp.Product.Specifications info.Unit = pp.Product.Unit - break } } infos = append(infos, &info) -- Gitblit v1.8.0