Merge branch 'master' of http://192.168.5.5:10010/r/aps/SRM
| | |
| | | } |
| | | |
| | | func (m *GVA_MODEL) AfterFind(tx *gorm.DB) (err error) { |
| | | 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 |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | 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:采购名称"` // 是否置顶 |
| | |
| | | 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"` //产品类别名称 |
| | | IsStorage int `gorm:"type:tinyint(1);default:1;comment:是否存库(1是2否)" json:"isStorage"` //无库存的在wms以及srm中需要过滤掉 |
| | | IsVirtual int `json:"isVirtual" gorm:"type:tinyint(1);default:2;comment:是否虚拟物料(1是2否)"` //虚拟物料在MRP计算时跳过该层级直接领用下级物料,虚拟物料不生成工单 |
| | | } |
| | | |
| | | // PurchaseType 采购类型 |
| | |
| | | MaterialModeAuxiliary MaterialMode = "辅料" //辅料 |
| | | MaterialModeConsumables MaterialMode = "耗材" //耗材 |
| | | MaterialModeOther MaterialMode = "其他" //其他 |
| | | MaterialModeVirtual MaterialMode = "虚拟件" //虚拟件, 不能销售,不能出入库,不能采购 |
| | | ) |
| | | |
| | | func (t MaterialMode) Valid() bool { |
| | |
| | | t != MaterialModeAuxiliary && |
| | | t != MaterialModeConsumables && |
| | | t != MaterialModeOther && |
| | | t != MaterialModeFinished { |
| | | t != MaterialModeFinished && |
| | | t != MaterialModeVirtual { |
| | | return false |
| | | } |
| | | return true |
| | |
| | | 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) |
| | | } |
| | |
| | | MaterialTypeAuxiliary //辅料 |
| | | MaterialTypeConsumables //耗材 |
| | | MaterialTypeOther //其他 |
| | | MaterialTypeVirtual //虚拟件 |
| | | ) |
| | | |
| | | func (t MaterialType) Valid() bool { |
| | | if t < MaterialTypeRaw || |
| | | t > MaterialTypeFinished { |
| | | t > MaterialTypeVirtual { |
| | | return false |
| | | } |
| | | return true |
| | |
| | | rpc GetSupplierListByProductId(GetSupplierListByProductIdRequest) returns (GetSupplierListByProductIdResponse) {} |
| | | rpc CreatePurchaseByWms(CreatePurchaseByWmsRequest) returns (CreatePurchaseByWmsResponse) {} |
| | | rpc GetPurchaseInfo(GetPurchaseInfoRequest) returns (GetPurchaseInfoResponse) {} |
| | | rpc ExistSupplier(ExistSupplierRequest) returns (ExistSupplierResponse) {} |
| | | } |
| | | |
| | | //------------------------------------------PurchaseToWms-------------------------------- |
| | |
| | | repeated PurchaseInfo Infos = 1; |
| | | } |
| | | |
| | | //--------------------------------------------------ExistSupplier--------------------------------------- |
| | | |
| | | message ExistSupplierRequest { |
| | | repeated string ProductId = 1; |
| | | } |
| | | |
| | | message ExistSupplierResponse { |
| | | bool Exist = 1; |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | 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{ |
| | |
| | | 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 ( |
| | |
| | | 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 |
| | |
| | | (*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 |
| | |
| | | 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 |
| | |
| | | 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{ |
| | |
| | | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), |
| | | RawDescriptor: file_purchase_wms_proto_rawDesc, |
| | | NumEnums: 0, |
| | | NumMessages: 13, |
| | | NumMessages: 15, |
| | | NumExtensions: 0, |
| | | NumServices: 1, |
| | | }, |
| | |
| | | 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 { |
| | |
| | | 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 |
| | |
| | | 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() |
| | | } |
| | | |
| | |
| | | } |
| | | 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() {} |
| | | |
| | |
| | | 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) |
| | |
| | | MethodName: "GetPurchaseInfo", |
| | | Handler: _PurchaseService_GetPurchaseInfo_Handler, |
| | | }, |
| | | { |
| | | MethodName: "ExistSupplier", |
| | | Handler: _PurchaseService_ExistSupplier_Handler, |
| | | }, |
| | | }, |
| | | Streams: []grpc.StreamDesc{}, |
| | | Metadata: "purchase_wms.proto", |
| | |
| | | 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 |
| | |
| | | |
| | | //采购单 |
| | | var purchaseRecord purchase.Purchase |
| | | purchaseRecord.PurchaseTypeId = int(pt.ID) |
| | | |
| | | //purchaseRecord.SupplierId = int(req.SupplierId) |
| | | if req.Source == "WMS" { |
| | | purchaseRecord.OrderSource = "WMS推送" |
| | |
| | | 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 |
| | | } |
| | |
| | | |
| | | 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 |
| | | err = tx.Create(list).Error |
| | | if err != nil { |
| | | return err |
| | | } |
| | | } |
| | | } |
| | | return nil |
| | | }) |
| | |
| | | |
| | | db = db.Where("purchase_type = ?", test.PurchaseTypeOutSource) |
| | | |
| | | db = db.Where("is_storage = ?", 1) |
| | | |
| | | err = db.Count(&total).Error |
| | | if err != nil { |
| | | return |