From 02a2176f7c5733a4e4c4429c2028bbb86a967ce7 Mon Sep 17 00:00:00 2001 From: jiangshuai <291802688@qq.com> Date: 星期二, 06 二月 2024 10:13:38 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/SRM --- service/test/product.go | 2 model/test/material.go | 25 +++- proto/purchase_wms/purchase_wms_grpc.pb.go | 36 ++++++ proto/purchase_wms/purchase_wms.pb.go | 209 ++++++++++++++++++++++++++++------ model/purchase/request/purchase_type.go | 2 proto/purchase_wms.proto | 11 + proto/purchase_wms/server.go | 37 +++++- service/purchase/purchase.go | 22 -- global/model.go | 12 + 9 files changed, 285 insertions(+), 71 deletions(-) diff --git a/global/model.go b/global/model.go index 9a3d5b1..7bc5230 100644 --- a/global/model.go +++ b/global/model.go @@ -17,8 +17,16 @@ } func (m *GVA_MODEL) AfterFind(tx *gorm.DB) (err error) { - m.FormattedCreatedAt = m.CreatedAt.Format("2006-01-02 15:04:05") - m.FormattedUpdatedAt = m.UpdatedAt.Format("2006-01-02 15:04:05") + if m.CreatedAt != nil { + m.FormattedCreatedAt = m.CreatedAt.Format("2006-01-02 15:04:05") + } else { + m.FormattedCreatedAt = "--" + } + if m.UpdatedAt != nil { + m.FormattedUpdatedAt = m.UpdatedAt.Format("2006-01-02 15:04:05") + m.FormattedUpdatedAt = "--" + } + return } diff --git a/model/purchase/request/purchase_type.go b/model/purchase/request/purchase_type.go index 26956c6..5b2a05f 100644 --- a/model/purchase/request/purchase_type.go +++ b/model/purchase/request/purchase_type.go @@ -5,7 +5,7 @@ } type PurchaseType struct { - ID uint `gorm:"primarykey"` // 涓婚敭ID + ID uint `gorm:"primarykey" json:"id,string"` // 涓婚敭ID Name string `json:"name" form:"name" gorm:"type:varchar(255);not null;default '';comment:閲囪喘绫诲瀷"` // 閲囪喘绫诲瀷 Sort int `json:"sort" form:"sort" gorm:"type:int(11);not null;default 0;comment:鎺掑簭"` // 鎺掑簭 Pin bool `json:"pin" form:"pin" gorm:"type:tinyint(1);not null;default 0;comment:閲囪喘鍚嶇О"` // 鏄惁缃《 diff --git a/model/test/material.go b/model/test/material.go index 25053cb..257a277 100644 --- a/model/test/material.go +++ b/model/test/material.go @@ -26,7 +26,9 @@ MinPurchaseAmount decimal.Decimal `gorm:"type:decimal(35,18);comment:鏈�灏忛噰璐噺" json:"minPurchaseAmount"` PurchaseType PurchaseType `gorm:"type:int(11);comment:閲囪喘绫诲瀷" json:"purchaseType"` SalePrice decimal.Decimal `gorm:"type:decimal(35,18);comment:閿�鍞崟浠�" json:"salePrice"` - CategoryName string `gorm:"type:varchar(255);comment:浜у搧绫诲埆鍚嶇О" json:"categoryName"` //浜у搧绫诲埆鍚嶇О + CategoryName string `gorm:"type:varchar(255);comment:浜у搧绫诲埆鍚嶇О" json:"categoryName"` //浜у搧绫诲埆鍚嶇О + IsStorage int `gorm:"type:tinyint(1);default:1;comment:鏄惁瀛樺簱(1鏄�2鍚�)" json:"isStorage"` //鏃犲簱瀛樼殑鍦╳ms浠ュ強srm涓渶瑕佽繃婊ゆ帀 + IsVirtual int `json:"isVirtual" gorm:"type:tinyint(1);default:2;comment:鏄惁铏氭嫙鐗╂枡(1鏄�2鍚�)"` //铏氭嫙鐗╂枡鍦∕RP璁$畻鏃惰烦杩囪灞傜骇鐩存帴棰嗙敤涓嬬骇鐗╂枡锛岃櫄鎷熺墿鏂欎笉鐢熸垚宸ュ崟 } // PurchaseType 閲囪喘绫诲瀷 @@ -53,9 +55,10 @@ MaterialModeRaw MaterialMode = "鍘熸潗鏂�" MaterialModeSemi MaterialMode = "鍗婃垚鍝�" MaterialModeFinished MaterialMode = "鎴愬搧" - MaterialModeAuxiliary MaterialMode = "杈呮枡" //杈呮枡 - MaterialModeConsumables MaterialMode = "鑰楁潗" //鑰楁潗 - MaterialModeOther MaterialMode = "鍏朵粬" //鍏朵粬 + MaterialModeAuxiliary MaterialMode = "杈呮枡" //杈呮枡 + MaterialModeConsumables MaterialMode = "鑰楁潗" //鑰楁潗 + MaterialModeOther MaterialMode = "鍏朵粬" //鍏朵粬 + MaterialModeVirtual MaterialMode = "铏氭嫙浠�" //铏氭嫙浠�, 涓嶈兘閿�鍞紝涓嶈兘鍑哄叆搴擄紝涓嶈兘閲囪喘 ) func (t MaterialMode) Valid() bool { @@ -64,7 +67,8 @@ t != MaterialModeAuxiliary && t != MaterialModeConsumables && t != MaterialModeOther && - t != MaterialModeFinished { + t != MaterialModeFinished && + t != MaterialModeVirtual { return false } return true @@ -78,6 +82,14 @@ return MaterialTypeSemi case MaterialModeFinished: return MaterialTypeFinished + case MaterialModeAuxiliary: + return MaterialTypeAuxiliary + case MaterialModeConsumables: + return MaterialTypeConsumables + case MaterialModeOther: + return MaterialTypeOther + case MaterialModeVirtual: + return MaterialTypeVirtual } return MaterialType(0) } @@ -92,11 +104,12 @@ MaterialTypeAuxiliary //杈呮枡 MaterialTypeConsumables //鑰楁潗 MaterialTypeOther //鍏朵粬 + MaterialTypeVirtual //铏氭嫙浠� ) func (t MaterialType) Valid() bool { if t < MaterialTypeRaw || - t > MaterialTypeFinished { + t > MaterialTypeVirtual { return false } return true diff --git a/proto/purchase_wms.proto b/proto/purchase_wms.proto index c344dfd..8ae8034 100644 --- a/proto/purchase_wms.proto +++ b/proto/purchase_wms.proto @@ -8,6 +8,7 @@ rpc GetSupplierListByProductId(GetSupplierListByProductIdRequest) returns (GetSupplierListByProductIdResponse) {} rpc CreatePurchaseByWms(CreatePurchaseByWmsRequest) returns (CreatePurchaseByWmsResponse) {} rpc GetPurchaseInfo(GetPurchaseInfoRequest) returns (GetPurchaseInfoResponse) {} + rpc ExistSupplier(ExistSupplierRequest) returns (ExistSupplierResponse) {} } //------------------------------------------PurchaseToWms-------------------------------- @@ -92,5 +93,15 @@ repeated PurchaseInfo Infos = 1; } +//--------------------------------------------------ExistSupplier--------------------------------------- + +message ExistSupplierRequest { + repeated string ProductId = 1; +} + +message ExistSupplierResponse { + bool Exist = 1; +} + diff --git a/proto/purchase_wms/purchase_wms.pb.go b/proto/purchase_wms/purchase_wms.pb.go index 5af5073..054124e 100644 --- a/proto/purchase_wms/purchase_wms.pb.go +++ b/proto/purchase_wms/purchase_wms.pb.go @@ -791,6 +791,100 @@ return nil } +type ExistSupplierRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ProductId []string `protobuf:"bytes,1,rep,name=ProductId,proto3" json:"ProductId,omitempty"` +} + +func (x *ExistSupplierRequest) Reset() { + *x = ExistSupplierRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_purchase_wms_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ExistSupplierRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExistSupplierRequest) ProtoMessage() {} + +func (x *ExistSupplierRequest) ProtoReflect() protoreflect.Message { + mi := &file_purchase_wms_proto_msgTypes[13] + 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 ExistSupplierRequest.ProtoReflect.Descriptor instead. +func (*ExistSupplierRequest) Descriptor() ([]byte, []int) { + return file_purchase_wms_proto_rawDescGZIP(), []int{13} +} + +func (x *ExistSupplierRequest) GetProductId() []string { + if x != nil { + return x.ProductId + } + return nil +} + +type ExistSupplierResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Exist bool `protobuf:"varint,1,opt,name=Exist,proto3" json:"Exist,omitempty"` +} + +func (x *ExistSupplierResponse) Reset() { + *x = ExistSupplierResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_purchase_wms_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ExistSupplierResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExistSupplierResponse) ProtoMessage() {} + +func (x *ExistSupplierResponse) ProtoReflect() protoreflect.Message { + mi := &file_purchase_wms_proto_msgTypes[14] + 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 ExistSupplierResponse.ProtoReflect.Descriptor instead. +func (*ExistSupplierResponse) Descriptor() ([]byte, []int) { + return file_purchase_wms_proto_rawDescGZIP(), []int{14} +} + +func (x *ExistSupplierResponse) GetExist() bool { + if x != nil { + return x.Exist + } + return false +} + var File_purchase_wms_proto protoreflect.FileDescriptor var file_purchase_wms_proto_rawDesc = []byte{ @@ -876,35 +970,46 @@ 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, - 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x32, 0xad, 0x03, 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, - 0x12, 0x67, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x4c, - 0x69, 0x73, 0x74, 0x42, 0x79, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x12, 0x22, - 0x2e, 0x47, 0x65, 0x74, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, - 0x42, 0x79, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, - 0x4c, 0x69, 0x73, 0x74, 0x42, 0x79, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x52, 0x0a, 0x13, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x42, 0x79, 0x57, 0x6d, 0x73, - 0x12, 0x1b, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, - 0x65, 0x42, 0x79, 0x57, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x42, 0x79, - 0x57, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x46, 0x0a, - 0x0f, 0x47, 0x65, 0x74, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e, 0x66, 0x6f, - 0x12, 0x17, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x49, 0x6e, - 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 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, 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, + 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x22, 0x34, 0x0a, 0x14, 0x45, 0x78, 0x69, 0x73, 0x74, 0x53, 0x75, + 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, + 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x22, 0x2d, 0x0a, 0x15, 0x45, + 0x78, 0x69, 0x73, 0x74, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x45, 0x78, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x05, 0x45, 0x78, 0x69, 0x73, 0x74, 0x32, 0xef, 0x03, 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, 0x12, 0x67, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x53, 0x75, 0x70, 0x70, + 0x6c, 0x69, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x79, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, + 0x74, 0x49, 0x64, 0x12, 0x22, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, + 0x72, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x79, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x75, 0x70, + 0x70, 0x6c, 0x69, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x79, 0x50, 0x72, 0x6f, 0x64, 0x75, + 0x63, 0x74, 0x49, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x52, + 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, + 0x42, 0x79, 0x57, 0x6d, 0x73, 0x12, 0x1b, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x75, + 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x42, 0x79, 0x57, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x75, 0x72, 0x63, 0x68, + 0x61, 0x73, 0x65, 0x42, 0x79, 0x57, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x12, 0x46, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, + 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x17, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x75, 0x72, 0x63, 0x68, + 0x61, 0x73, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, + 0x2e, 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, 0x12, 0x40, 0x0a, 0x0d, 0x45, 0x78, + 0x69, 0x73, 0x74, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x45, 0x78, + 0x69, 0x73, 0x74, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x45, 0x78, 0x69, 0x73, 0x74, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x69, + 0x65, 0x72, 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 ( @@ -919,7 +1024,7 @@ return file_purchase_wms_proto_rawDescData } -var file_purchase_wms_proto_msgTypes = make([]protoimpl.MessageInfo, 13) +var file_purchase_wms_proto_msgTypes = make([]protoimpl.MessageInfo, 15) var file_purchase_wms_proto_goTypes = []interface{}{ (*PurchaseProduct)(nil), // 0: PurchaseProduct (*PurchaseToWmsRequest)(nil), // 1: PurchaseToWmsRequest @@ -934,6 +1039,8 @@ (*GetPurchaseInfoRequest)(nil), // 10: GetPurchaseInfoRequest (*PurchaseInfo)(nil), // 11: PurchaseInfo (*GetPurchaseInfoResponse)(nil), // 12: GetPurchaseInfoResponse + (*ExistSupplierRequest)(nil), // 13: ExistSupplierRequest + (*ExistSupplierResponse)(nil), // 14: ExistSupplierResponse } var file_purchase_wms_proto_depIdxs = []int32{ 0, // 0: PurchaseToWmsRequest.Product:type_name -> PurchaseProduct @@ -944,13 +1051,15 @@ 5, // 5: PurchaseService.GetSupplierListByProductId:input_type -> GetSupplierListByProductIdRequest 8, // 6: PurchaseService.CreatePurchaseByWms:input_type -> CreatePurchaseByWmsRequest 10, // 7: PurchaseService.GetPurchaseInfo:input_type -> GetPurchaseInfoRequest - 2, // 8: PurchaseService.PurchaseToWms:output_type -> PurchaseToWmsResponse - 4, // 9: PurchaseService.UpdatePurchaseStatus:output_type -> UpdatePurchaseStatusResponse - 7, // 10: PurchaseService.GetSupplierListByProductId:output_type -> GetSupplierListByProductIdResponse - 9, // 11: PurchaseService.CreatePurchaseByWms:output_type -> CreatePurchaseByWmsResponse - 12, // 12: PurchaseService.GetPurchaseInfo:output_type -> GetPurchaseInfoResponse - 8, // [8:13] is the sub-list for method output_type - 3, // [3:8] is the sub-list for method input_type + 13, // 8: PurchaseService.ExistSupplier:input_type -> ExistSupplierRequest + 2, // 9: PurchaseService.PurchaseToWms:output_type -> PurchaseToWmsResponse + 4, // 10: PurchaseService.UpdatePurchaseStatus:output_type -> UpdatePurchaseStatusResponse + 7, // 11: PurchaseService.GetSupplierListByProductId:output_type -> GetSupplierListByProductIdResponse + 9, // 12: PurchaseService.CreatePurchaseByWms:output_type -> CreatePurchaseByWmsResponse + 12, // 13: PurchaseService.GetPurchaseInfo:output_type -> GetPurchaseInfoResponse + 14, // 14: PurchaseService.ExistSupplier:output_type -> ExistSupplierResponse + 9, // [9:15] is the sub-list for method output_type + 3, // [3:9] is the sub-list for method input_type 3, // [3:3] is the sub-list for extension type_name 3, // [3:3] is the sub-list for extension extendee 0, // [0:3] is the sub-list for field type_name @@ -1118,6 +1227,30 @@ return nil } } + file_purchase_wms_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ExistSupplierRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_purchase_wms_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ExistSupplierResponse); 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{ @@ -1125,7 +1258,7 @@ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_purchase_wms_proto_rawDesc, NumEnums: 0, - NumMessages: 13, + NumMessages: 15, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/purchase_wms/purchase_wms_grpc.pb.go b/proto/purchase_wms/purchase_wms_grpc.pb.go index dcc5c68..cc71d37 100644 --- a/proto/purchase_wms/purchase_wms_grpc.pb.go +++ b/proto/purchase_wms/purchase_wms_grpc.pb.go @@ -23,6 +23,7 @@ GetSupplierListByProductId(ctx context.Context, in *GetSupplierListByProductIdRequest, opts ...grpc.CallOption) (*GetSupplierListByProductIdResponse, error) CreatePurchaseByWms(ctx context.Context, in *CreatePurchaseByWmsRequest, opts ...grpc.CallOption) (*CreatePurchaseByWmsResponse, error) GetPurchaseInfo(ctx context.Context, in *GetPurchaseInfoRequest, opts ...grpc.CallOption) (*GetPurchaseInfoResponse, error) + ExistSupplier(ctx context.Context, in *ExistSupplierRequest, opts ...grpc.CallOption) (*ExistSupplierResponse, error) } type purchaseServiceClient struct { @@ -78,6 +79,15 @@ return out, nil } +func (c *purchaseServiceClient) ExistSupplier(ctx context.Context, in *ExistSupplierRequest, opts ...grpc.CallOption) (*ExistSupplierResponse, error) { + out := new(ExistSupplierResponse) + err := c.cc.Invoke(ctx, "/PurchaseService/ExistSupplier", 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 @@ -87,6 +97,7 @@ GetSupplierListByProductId(context.Context, *GetSupplierListByProductIdRequest) (*GetSupplierListByProductIdResponse, error) CreatePurchaseByWms(context.Context, *CreatePurchaseByWmsRequest) (*CreatePurchaseByWmsResponse, error) GetPurchaseInfo(context.Context, *GetPurchaseInfoRequest) (*GetPurchaseInfoResponse, error) + ExistSupplier(context.Context, *ExistSupplierRequest) (*ExistSupplierResponse, error) mustEmbedUnimplementedPurchaseServiceServer() } @@ -108,6 +119,9 @@ } func (UnimplementedPurchaseServiceServer) GetPurchaseInfo(context.Context, *GetPurchaseInfoRequest) (*GetPurchaseInfoResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetPurchaseInfo not implemented") +} +func (UnimplementedPurchaseServiceServer) ExistSupplier(context.Context, *ExistSupplierRequest) (*ExistSupplierResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ExistSupplier not implemented") } func (UnimplementedPurchaseServiceServer) mustEmbedUnimplementedPurchaseServiceServer() {} @@ -212,6 +226,24 @@ return interceptor(ctx, in, info, handler) } +func _PurchaseService_ExistSupplier_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ExistSupplierRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PurchaseServiceServer).ExistSupplier(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/PurchaseService/ExistSupplier", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PurchaseServiceServer).ExistSupplier(ctx, req.(*ExistSupplierRequest)) + } + 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) @@ -239,6 +271,10 @@ MethodName: "GetPurchaseInfo", Handler: _PurchaseService_GetPurchaseInfo_Handler, }, + { + MethodName: "ExistSupplier", + Handler: _PurchaseService_ExistSupplier_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "purchase_wms.proto", diff --git a/proto/purchase_wms/server.go b/proto/purchase_wms/server.go index 24fa4d3..10bf8a1 100644 --- a/proto/purchase_wms/server.go +++ b/proto/purchase_wms/server.go @@ -54,13 +54,8 @@ if req.ProductId == "" { return nil, errors.New("浜у搧id涓虹┖") } - var pt purchase.PurchaseType - err := global.GVA_DB.Model(&purchase.PurchaseType{}).First(&pt).Error - if err != nil { - return nil, err - } var product test.SupplierMaterial - err = global.GVA_DB.Model(&test.SupplierMaterial{}).Where("number = ?", req.ProductId).First(&product).Error + err := global.GVA_DB.Model(&test.SupplierMaterial{}).Where("number = ?", req.ProductId).First(&product).Error if err != nil { if err == gorm.ErrRecordNotFound { var material test.Material @@ -87,7 +82,7 @@ //閲囪喘鍗� var purchaseRecord purchase.Purchase - purchaseRecord.PurchaseTypeId = int(pt.ID) + //purchaseRecord.SupplierId = int(req.SupplierId) if req.Source == "WMS" { purchaseRecord.OrderSource = "WMS鎺ㄩ��" @@ -160,3 +155,31 @@ resp.Infos = infos return resp, nil } + +func (s *Server) ExistSupplier(ctx context.Context, req *ExistSupplierRequest) (*ExistSupplierResponse, error) { + resp := new(ExistSupplierResponse) + if len(req.ProductId) == 0 { + resp.Exist = false + return resp, nil + } + var products []test.SupplierMaterial + err := global.GVA_DB.Model(&test.SupplierMaterial{}).Where("number in (?)", req.ProductId).Find(&products).Error + if err != nil { + return nil, err + } + for _, number := range req.ProductId { + exit := false + for _, product := range products { + if number == product.Number && product.SupplierId > 0 { + exit = true + break + } + } + if !exit { + resp.Exist = exit + return resp, nil + } + } + resp.Exist = true + return resp, nil +} diff --git a/service/purchase/purchase.go b/service/purchase/purchase.go index fb3db12..de89020 100644 --- a/service/purchase/purchase.go +++ b/service/purchase/purchase.go @@ -258,33 +258,21 @@ func (slf *PurchaseService) SavePurchaseType(list []*purchase.PurchaseType) (err error) { ids := make([]uint, 0) - newRecords := make([]*purchase.PurchaseType, 0) for _, item := range list { if item.ID != 0 { ids = append(ids, item.ID) - } else { - newRecords = append(newRecords, item) + item.ID = 0 } } err = global.GVA_DB.Transaction(func(tx *gorm.DB) error { - err = tx.Where("id not in ?", ids).Delete(&purchase.PurchaseType{}).Error + err = tx.Where("id in (?)", ids).Delete(&purchase.PurchaseType{}).Error if err != nil { return err } - if len(newRecords) > 0 { - err = tx.Create(newRecords).Error - if err != nil { - return err - } - } - for _, item := range list { - if item.ID != 0 { - err = tx.Where("id = ?", item.ID).Updates(item).Error - if err != nil { - return err - } - } + err = tx.Create(list).Error + if err != nil { + return err } return nil }) diff --git a/service/test/product.go b/service/test/product.go index bb19684..6375fca 100644 --- a/service/test/product.go +++ b/service/test/product.go @@ -120,6 +120,8 @@ db = db.Where("purchase_type = ?", test.PurchaseTypeOutSource) + db = db.Where("is_storage = ?", 1) + err = db.Count(&total).Error if err != nil { return -- Gitblit v1.8.0