zhangqian
2024-03-14 527bc709815b9ea0f2ed14450262c9a5832c141f
根据仓库返回产品剩余数量
2个文件已添加
5个文件已修改
474 ■■■■ 已修改文件
models/warehouse.go 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
proto/product_inventory.proto 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
proto/product_inventory/product_inventory.pb.go 292 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
proto/product_inventory/product_inventory_grpc.pb.go 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
proto/product_inventory/server.go 79 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/record_to_map.go 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/warehouse.go 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/warehouse.go
@@ -38,6 +38,7 @@
        Keyword  string
        Orm      *gorm.DB
        Preload  bool
        Codes    []string
    }
)
@@ -79,6 +80,11 @@
    return slf
}
func (slf *WarehouseSearch) SetCodes(codes []string) *WarehouseSearch {
    slf.Codes = codes
    return slf
}
func (slf *WarehouseSearch) SetName(name string) *WarehouseSearch {
    slf.Name = name
    return slf
@@ -116,10 +122,15 @@
    if slf.Preload {
        db = db.Preload("Company")
    }
    if slf.Code != "" {
        db = db.Where("code = ?", slf.Code)
    }
    if len(slf.Codes) > 0 {
        db = db.Where("code in ?", slf.Codes)
    }
    return db
}
proto/product_inventory.proto
@@ -34,6 +34,7 @@
message GetInventoryProductInfoRequest {
  string Number = 1;//明细单编码
  bool   GroupByWarehouse = 2; //是否按仓库分组
}
message ProductInfo{
@@ -55,8 +56,16 @@
  int32   Code = 1;
  string  Msg = 2;
  repeated ProductInfo ProductList = 3;
  repeated WarehouseProducts WarehouseProductsList = 4;
}
message WarehouseProducts {
  string WarehouseID = 1;
  string WarehouseName = 2;
  repeated ProductInfo ProductList = 3;
}
//------------------------------------------------------------
message UpdateSalesDetailStatusRequest {
proto/product_inventory/product_inventory.pb.go
@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
//     protoc-gen-go v1.26.0
//     protoc        v4.24.0
//     protoc-gen-go v1.31.0
//     protoc        v3.19.0
// source: product_inventory.proto
package product_inventory
@@ -246,7 +246,8 @@
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields
    Number string `protobuf:"bytes,1,opt,name=Number,proto3" json:"Number,omitempty"` //明细单编码
    Number           string `protobuf:"bytes,1,opt,name=Number,proto3" json:"Number,omitempty"`                      //明细单编码
    GroupByWarehouse bool   `protobuf:"varint,2,opt,name=GroupByWarehouse,proto3" json:"GroupByWarehouse,omitempty"` //是否按仓库分组
}
func (x *GetInventoryProductInfoRequest) Reset() {
@@ -286,6 +287,13 @@
        return x.Number
    }
    return ""
}
func (x *GetInventoryProductInfoRequest) GetGroupByWarehouse() bool {
    if x != nil {
        return x.GroupByWarehouse
    }
    return false
}
type ProductInfo struct {
@@ -428,9 +436,10 @@
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields
    Code        int32          `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"`
    Msg         string         `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
    ProductList []*ProductInfo `protobuf:"bytes,3,rep,name=ProductList,proto3" json:"ProductList,omitempty"`
    Code                  int32                `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"`
    Msg                   string               `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
    ProductList           []*ProductInfo       `protobuf:"bytes,3,rep,name=ProductList,proto3" json:"ProductList,omitempty"`
    WarehouseProductsList []*WarehouseProducts `protobuf:"bytes,4,rep,name=WarehouseProductsList,proto3" json:"WarehouseProductsList,omitempty"`
}
func (x *GetInventoryProductInfoResponse) Reset() {
@@ -486,6 +495,76 @@
    return nil
}
func (x *GetInventoryProductInfoResponse) GetWarehouseProductsList() []*WarehouseProducts {
    if x != nil {
        return x.WarehouseProductsList
    }
    return nil
}
type WarehouseProducts struct {
    state         protoimpl.MessageState
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields
    WarehouseID   string         `protobuf:"bytes,1,opt,name=WarehouseID,proto3" json:"WarehouseID,omitempty"`
    WarehouseName string         `protobuf:"bytes,2,opt,name=WarehouseName,proto3" json:"WarehouseName,omitempty"`
    ProductList   []*ProductInfo `protobuf:"bytes,3,rep,name=ProductList,proto3" json:"ProductList,omitempty"`
}
func (x *WarehouseProducts) Reset() {
    *x = WarehouseProducts{}
    if protoimpl.UnsafeEnabled {
        mi := &file_product_inventory_proto_msgTypes[6]
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        ms.StoreMessageInfo(mi)
    }
}
func (x *WarehouseProducts) String() string {
    return protoimpl.X.MessageStringOf(x)
}
func (*WarehouseProducts) ProtoMessage() {}
func (x *WarehouseProducts) ProtoReflect() protoreflect.Message {
    mi := &file_product_inventory_proto_msgTypes[6]
    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 WarehouseProducts.ProtoReflect.Descriptor instead.
func (*WarehouseProducts) Descriptor() ([]byte, []int) {
    return file_product_inventory_proto_rawDescGZIP(), []int{6}
}
func (x *WarehouseProducts) GetWarehouseID() string {
    if x != nil {
        return x.WarehouseID
    }
    return ""
}
func (x *WarehouseProducts) GetWarehouseName() string {
    if x != nil {
        return x.WarehouseName
    }
    return ""
}
func (x *WarehouseProducts) GetProductList() []*ProductInfo {
    if x != nil {
        return x.ProductList
    }
    return nil
}
type UpdateSalesDetailStatusRequest struct {
    state         protoimpl.MessageState
    sizeCache     protoimpl.SizeCache
@@ -498,7 +577,7 @@
func (x *UpdateSalesDetailStatusRequest) Reset() {
    *x = UpdateSalesDetailStatusRequest{}
    if protoimpl.UnsafeEnabled {
        mi := &file_product_inventory_proto_msgTypes[6]
        mi := &file_product_inventory_proto_msgTypes[7]
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        ms.StoreMessageInfo(mi)
    }
@@ -511,7 +590,7 @@
func (*UpdateSalesDetailStatusRequest) ProtoMessage() {}
func (x *UpdateSalesDetailStatusRequest) ProtoReflect() protoreflect.Message {
    mi := &file_product_inventory_proto_msgTypes[6]
    mi := &file_product_inventory_proto_msgTypes[7]
    if protoimpl.UnsafeEnabled && x != nil {
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        if ms.LoadMessageInfo() == nil {
@@ -524,7 +603,7 @@
// Deprecated: Use UpdateSalesDetailStatusRequest.ProtoReflect.Descriptor instead.
func (*UpdateSalesDetailStatusRequest) Descriptor() ([]byte, []int) {
    return file_product_inventory_proto_rawDescGZIP(), []int{6}
    return file_product_inventory_proto_rawDescGZIP(), []int{7}
}
func (x *UpdateSalesDetailStatusRequest) GetNumber() string {
@@ -553,7 +632,7 @@
func (x *UpdateSalesDetailStatusResponse) Reset() {
    *x = UpdateSalesDetailStatusResponse{}
    if protoimpl.UnsafeEnabled {
        mi := &file_product_inventory_proto_msgTypes[7]
        mi := &file_product_inventory_proto_msgTypes[8]
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        ms.StoreMessageInfo(mi)
    }
@@ -566,7 +645,7 @@
func (*UpdateSalesDetailStatusResponse) ProtoMessage() {}
func (x *UpdateSalesDetailStatusResponse) ProtoReflect() protoreflect.Message {
    mi := &file_product_inventory_proto_msgTypes[7]
    mi := &file_product_inventory_proto_msgTypes[8]
    if protoimpl.UnsafeEnabled && x != nil {
        ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
        if ms.LoadMessageInfo() == nil {
@@ -579,7 +658,7 @@
// Deprecated: Use UpdateSalesDetailStatusResponse.ProtoReflect.Descriptor instead.
func (*UpdateSalesDetailStatusResponse) Descriptor() ([]byte, []int) {
    return file_product_inventory_proto_rawDescGZIP(), []int{7}
    return file_product_inventory_proto_rawDescGZIP(), []int{8}
}
func (x *UpdateSalesDetailStatusResponse) GetCode() int32 {
@@ -627,71 +706,87 @@
    0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04,
    0x43, 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, 0x22, 0x38, 0x0a, 0x1e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f,
    0x73, 0x67, 0x22, 0x64, 0x0a, 0x1e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f,
    0x72, 0x79, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71,
    0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01,
    0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0xd5, 0x02, 0x0a,
    0x0b, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x0a, 0x06,
    0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x4e, 0x75,
    0x6d, 0x62, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01,
    0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x4f, 0x72, 0x64, 0x65,
    0x72, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x4f,
    0x72, 0x64, 0x65, 0x72, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x55, 0x6e,
    0x69, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x55, 0x6e, 0x69, 0x74, 0x12, 0x18,
    0x0a, 0x07, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52,
    0x07, 0x49, 0x6e, 0x76, 0x6f, 0x69, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x43, 0x61, 0x72, 0x72,
    0x69, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x43, 0x61, 0x72, 0x72, 0x69,
    0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x57, 0x61, 0x79, 0x62, 0x69, 0x6c, 0x6c, 0x18, 0x07, 0x20,
    0x01, 0x28, 0x09, 0x52, 0x07, 0x57, 0x61, 0x79, 0x62, 0x69, 0x6c, 0x6c, 0x12, 0x1c, 0x0a, 0x09,
    0x53, 0x61, 0x6c, 0x65, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52,
    0x09, 0x53, 0x61, 0x6c, 0x65, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x56, 0x61,
    0x6c, 0x6f, 0x72, 0x65, 0x6d, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x56, 0x61, 0x6c,
    0x6f, 0x72, 0x65, 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x57, 0x61, 0x72, 0x65, 0x68, 0x6f, 0x75, 0x73,
    0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x57, 0x61, 0x72, 0x65, 0x68, 0x6f, 0x75,
    0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0b, 0x20, 0x01,
    0x28, 0x09, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x28, 0x0a, 0x0f, 0x41, 0x76,
    0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x0c, 0x20,
    0x01, 0x28, 0x09, 0x52, 0x0f, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x75,
    0x6d, 0x62, 0x65, 0x72, 0x22, 0x77, 0x0a, 0x1f, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x76, 0x65, 0x6e,
    0x74, 0x6f, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52,
    0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x43, 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, 0x2e, 0x0a,
    0x0b, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03,
    0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f,
    0x52, 0x0b, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x66, 0x0a,
    0x1e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61,
    0x69, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
    0x16, 0x0a, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
    0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x2c, 0x0a, 0x11, 0x53, 0x61, 0x6c, 0x65, 0x73,
    0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01,
    0x28, 0x09, 0x52, 0x11, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53,
    0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x47, 0x0a, 0x1f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53,
    0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73,
    0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x43, 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, 0x32, 0xa1,
    0x02, 0x0a, 0x17, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74,
    0x6f, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x46, 0x0a, 0x0f, 0x43, 0x72,
    0x65, 0x61, 0x74, 0x65, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x17, 0x2e,
    0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52,
    0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f,
    0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
    0x22, 0x00, 0x12, 0x5e, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f,
    0x72, 0x79, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1f, 0x2e,
    0x47, 0x65, 0x74, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x64,
    0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20,
    0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x50, 0x72, 0x6f,
    0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
    0x22, 0x00, 0x12, 0x5e, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x61, 0x6c, 0x65,
    0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1f, 0x2e,
    0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69,
    0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20,
    0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61,
    0x69, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
    0x22, 0x00, 0x42, 0x15, 0x5a, 0x13, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x5f,
    0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
    0x33,
    0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x2a, 0x0a, 0x10,
    0x47, 0x72, 0x6f, 0x75, 0x70, 0x42, 0x79, 0x57, 0x61, 0x72, 0x65, 0x68, 0x6f, 0x75, 0x73, 0x65,
    0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x42, 0x79, 0x57,
    0x61, 0x72, 0x65, 0x68, 0x6f, 0x75, 0x73, 0x65, 0x22, 0xd5, 0x02, 0x0a, 0x0b, 0x50, 0x72, 0x6f,
    0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x4e, 0x75, 0x6d, 0x62,
    0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72,
    0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
    0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x41, 0x6d, 0x6f,
    0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x4f, 0x72, 0x64, 0x65, 0x72,
    0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x55, 0x6e, 0x69, 0x74, 0x18, 0x04,
    0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x55, 0x6e, 0x69, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x49, 0x6e,
    0x76, 0x6f, 0x69, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x49, 0x6e, 0x76,
    0x6f, 0x69, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x43, 0x61, 0x72, 0x72, 0x69, 0x65, 0x72, 0x18,
    0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x43, 0x61, 0x72, 0x72, 0x69, 0x65, 0x72, 0x12, 0x18,
    0x0a, 0x07, 0x57, 0x61, 0x79, 0x62, 0x69, 0x6c, 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52,
    0x07, 0x57, 0x61, 0x79, 0x62, 0x69, 0x6c, 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x61, 0x6c, 0x65,
    0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x53, 0x61, 0x6c,
    0x65, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x56, 0x61, 0x6c, 0x6f, 0x72, 0x65,
    0x6d, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x56, 0x61, 0x6c, 0x6f, 0x72, 0x65, 0x6d,
    0x12, 0x1c, 0x0a, 0x09, 0x57, 0x61, 0x72, 0x65, 0x68, 0x6f, 0x75, 0x73, 0x65, 0x18, 0x0a, 0x20,
    0x01, 0x28, 0x09, 0x52, 0x09, 0x57, 0x61, 0x72, 0x65, 0x68, 0x6f, 0x75, 0x73, 0x65, 0x12, 0x16,
    0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06,
    0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x28, 0x0a, 0x0f, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61,
    0x62, 0x6c, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52,
    0x0f, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72,
    0x22, 0xc1, 0x01, 0x0a, 0x1f, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72,
    0x79, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70,
    0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x43, 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, 0x2e, 0x0a, 0x0b, 0x50, 0x72,
    0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32,
    0x0c, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0b, 0x50,
    0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x48, 0x0a, 0x15, 0x57, 0x61,
    0x72, 0x65, 0x68, 0x6f, 0x75, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x4c,
    0x69, 0x73, 0x74, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x57, 0x61, 0x72, 0x65,
    0x68, 0x6f, 0x75, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x52, 0x15, 0x57,
    0x61, 0x72, 0x65, 0x68, 0x6f, 0x75, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73,
    0x4c, 0x69, 0x73, 0x74, 0x22, 0x8b, 0x01, 0x0a, 0x11, 0x57, 0x61, 0x72, 0x65, 0x68, 0x6f, 0x75,
    0x73, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x57, 0x61,
    0x72, 0x65, 0x68, 0x6f, 0x75, 0x73, 0x65, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
    0x0b, 0x57, 0x61, 0x72, 0x65, 0x68, 0x6f, 0x75, 0x73, 0x65, 0x49, 0x44, 0x12, 0x24, 0x0a, 0x0d,
    0x57, 0x61, 0x72, 0x65, 0x68, 0x6f, 0x75, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20,
    0x01, 0x28, 0x09, 0x52, 0x0d, 0x57, 0x61, 0x72, 0x65, 0x68, 0x6f, 0x75, 0x73, 0x65, 0x4e, 0x61,
    0x6d, 0x65, 0x12, 0x2e, 0x0a, 0x0b, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, 0x69, 0x73,
    0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63,
    0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0b, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, 0x69,
    0x73, 0x74, 0x22, 0x66, 0x0a, 0x1e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x61, 0x6c, 0x65,
    0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71,
    0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01,
    0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x2c, 0x0a, 0x11,
    0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75,
    0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65,
    0x74, 0x61, 0x69, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x47, 0x0a, 0x1f, 0x55, 0x70,
    0x64, 0x61, 0x74, 0x65, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53,
    0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a,
    0x04, 0x43, 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, 0x32, 0xa1, 0x02, 0x0a, 0x17, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49,
    0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12,
    0x46, 0x0a, 0x0f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69,
    0x6f, 0x6e, 0x12, 0x17, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x70, 0x65, 0x72, 0x61,
    0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x43, 0x72,
    0x65, 0x61, 0x74, 0x65, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73,
    0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5e, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x49, 0x6e,
    0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e,
    0x66, 0x6f, 0x12, 0x1f, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72,
    0x79, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75,
    0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f,
    0x72, 0x79, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73,
    0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5e, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, 0x74,
    0x65, 0x53, 0x61, 0x6c, 0x65, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x74, 0x61, 0x74,
    0x75, 0x73, 0x12, 0x1f, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x61, 0x6c, 0x65, 0x73,
    0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75,
    0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x61, 0x6c, 0x65,
    0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73,
    0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x15, 0x5a, 0x13, 0x2e, 0x2f, 0x70, 0x72, 0x6f,
    0x64, 0x75, 0x63, 0x74, 0x5f, 0x69, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x62, 0x06,
    0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -706,7 +801,7 @@
    return file_product_inventory_proto_rawDescData
}
var file_product_inventory_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_product_inventory_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_product_inventory_proto_goTypes = []interface{}{
    (*CreateOperationRequest)(nil),          // 0: CreateOperationRequest
    (*InventoryProduct)(nil),                // 1: InventoryProduct
@@ -714,23 +809,26 @@
    (*GetInventoryProductInfoRequest)(nil),  // 3: GetInventoryProductInfoRequest
    (*ProductInfo)(nil),                     // 4: ProductInfo
    (*GetInventoryProductInfoResponse)(nil), // 5: GetInventoryProductInfoResponse
    (*UpdateSalesDetailStatusRequest)(nil),  // 6: UpdateSalesDetailStatusRequest
    (*UpdateSalesDetailStatusResponse)(nil), // 7: UpdateSalesDetailStatusResponse
    (*WarehouseProducts)(nil),               // 6: WarehouseProducts
    (*UpdateSalesDetailStatusRequest)(nil),  // 7: UpdateSalesDetailStatusRequest
    (*UpdateSalesDetailStatusResponse)(nil), // 8: UpdateSalesDetailStatusResponse
}
var file_product_inventory_proto_depIdxs = []int32{
    1, // 0: CreateOperationRequest.ProductList:type_name -> InventoryProduct
    4, // 1: GetInventoryProductInfoResponse.ProductList:type_name -> ProductInfo
    0, // 2: productInventoryService.CreateOperation:input_type -> CreateOperationRequest
    3, // 3: productInventoryService.GetInventoryProductInfo:input_type -> GetInventoryProductInfoRequest
    6, // 4: productInventoryService.UpdateSalesDetailStatus:input_type -> UpdateSalesDetailStatusRequest
    2, // 5: productInventoryService.CreateOperation:output_type -> CreateOperationResponse
    5, // 6: productInventoryService.GetInventoryProductInfo:output_type -> GetInventoryProductInfoResponse
    7, // 7: productInventoryService.UpdateSalesDetailStatus:output_type -> UpdateSalesDetailStatusResponse
    5, // [5:8] is the sub-list for method output_type
    2, // [2:5] 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
    6, // 2: GetInventoryProductInfoResponse.WarehouseProductsList:type_name -> WarehouseProducts
    4, // 3: WarehouseProducts.ProductList:type_name -> ProductInfo
    0, // 4: productInventoryService.CreateOperation:input_type -> CreateOperationRequest
    3, // 5: productInventoryService.GetInventoryProductInfo:input_type -> GetInventoryProductInfoRequest
    7, // 6: productInventoryService.UpdateSalesDetailStatus:input_type -> UpdateSalesDetailStatusRequest
    2, // 7: productInventoryService.CreateOperation:output_type -> CreateOperationResponse
    5, // 8: productInventoryService.GetInventoryProductInfo:output_type -> GetInventoryProductInfoResponse
    8, // 9: productInventoryService.UpdateSalesDetailStatus:output_type -> UpdateSalesDetailStatusResponse
    7, // [7:10] is the sub-list for method output_type
    4, // [4:7] is the sub-list for method input_type
    4, // [4:4] is the sub-list for extension type_name
    4, // [4:4] is the sub-list for extension extendee
    0, // [0:4] is the sub-list for field type_name
}
func init() { file_product_inventory_proto_init() }
@@ -812,7 +910,7 @@
            }
        }
        file_product_inventory_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
            switch v := v.(*UpdateSalesDetailStatusRequest); i {
            switch v := v.(*WarehouseProducts); i {
            case 0:
                return &v.state
            case 1:
@@ -824,6 +922,18 @@
            }
        }
        file_product_inventory_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
            switch v := v.(*UpdateSalesDetailStatusRequest); i {
            case 0:
                return &v.state
            case 1:
                return &v.sizeCache
            case 2:
                return &v.unknownFields
            default:
                return nil
            }
        }
        file_product_inventory_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
            switch v := v.(*UpdateSalesDetailStatusResponse); i {
            case 0:
                return &v.state
@@ -842,7 +952,7 @@
            GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
            RawDescriptor: file_product_inventory_proto_rawDesc,
            NumEnums:      0,
            NumMessages:   8,
            NumMessages:   9,
            NumExtensions: 0,
            NumServices:   1,
        },
proto/product_inventory/product_inventory_grpc.pb.go
@@ -1,4 +1,8 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc             v3.19.0
// source: product_inventory.proto
package product_inventory
@@ -13,6 +17,12 @@
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
const (
    ProductInventoryService_CreateOperation_FullMethodName         = "/productInventoryService/CreateOperation"
    ProductInventoryService_GetInventoryProductInfo_FullMethodName = "/productInventoryService/GetInventoryProductInfo"
    ProductInventoryService_UpdateSalesDetailStatus_FullMethodName = "/productInventoryService/UpdateSalesDetailStatus"
)
// ProductInventoryServiceClient is the client API for ProductInventoryService service.
//
@@ -33,7 +43,7 @@
func (c *productInventoryServiceClient) CreateOperation(ctx context.Context, in *CreateOperationRequest, opts ...grpc.CallOption) (*CreateOperationResponse, error) {
    out := new(CreateOperationResponse)
    err := c.cc.Invoke(ctx, "/productInventoryService/CreateOperation", in, out, opts...)
    err := c.cc.Invoke(ctx, ProductInventoryService_CreateOperation_FullMethodName, in, out, opts...)
    if err != nil {
        return nil, err
    }
@@ -42,7 +52,7 @@
func (c *productInventoryServiceClient) GetInventoryProductInfo(ctx context.Context, in *GetInventoryProductInfoRequest, opts ...grpc.CallOption) (*GetInventoryProductInfoResponse, error) {
    out := new(GetInventoryProductInfoResponse)
    err := c.cc.Invoke(ctx, "/productInventoryService/GetInventoryProductInfo", in, out, opts...)
    err := c.cc.Invoke(ctx, ProductInventoryService_GetInventoryProductInfo_FullMethodName, in, out, opts...)
    if err != nil {
        return nil, err
    }
@@ -51,7 +61,7 @@
func (c *productInventoryServiceClient) UpdateSalesDetailStatus(ctx context.Context, in *UpdateSalesDetailStatusRequest, opts ...grpc.CallOption) (*UpdateSalesDetailStatusResponse, error) {
    out := new(UpdateSalesDetailStatusResponse)
    err := c.cc.Invoke(ctx, "/productInventoryService/UpdateSalesDetailStatus", in, out, opts...)
    err := c.cc.Invoke(ctx, ProductInventoryService_UpdateSalesDetailStatus_FullMethodName, in, out, opts...)
    if err != nil {
        return nil, err
    }
@@ -105,7 +115,7 @@
    }
    info := &grpc.UnaryServerInfo{
        Server:     srv,
        FullMethod: "/productInventoryService/CreateOperation",
        FullMethod: ProductInventoryService_CreateOperation_FullMethodName,
    }
    handler := func(ctx context.Context, req interface{}) (interface{}, error) {
        return srv.(ProductInventoryServiceServer).CreateOperation(ctx, req.(*CreateOperationRequest))
@@ -123,7 +133,7 @@
    }
    info := &grpc.UnaryServerInfo{
        Server:     srv,
        FullMethod: "/productInventoryService/GetInventoryProductInfo",
        FullMethod: ProductInventoryService_GetInventoryProductInfo_FullMethodName,
    }
    handler := func(ctx context.Context, req interface{}) (interface{}, error) {
        return srv.(ProductInventoryServiceServer).GetInventoryProductInfo(ctx, req.(*GetInventoryProductInfoRequest))
@@ -141,7 +151,7 @@
    }
    info := &grpc.UnaryServerInfo{
        Server:     srv,
        FullMethod: "/productInventoryService/UpdateSalesDetailStatus",
        FullMethod: ProductInventoryService_UpdateSalesDetailStatus_FullMethodName,
    }
    handler := func(ctx context.Context, req interface{}) (interface{}, error) {
        return srv.(ProductInventoryServiceServer).UpdateSalesDetailStatus(ctx, req.(*UpdateSalesDetailStatusRequest))
proto/product_inventory/server.go
@@ -5,11 +5,11 @@
    "errors"
    "github.com/shopspring/decimal"
    "strconv"
    "strings"
    "time"
    "wms/constvar"
    "wms/models"
    "wms/pkg/timex"
    "wms/service"
)
type Server struct {
@@ -45,9 +45,11 @@
    if len(details) == 0 {
        return resp, nil
    }
    var locationIds []int
    var locationId int
    for _, detail := range details {
        productIds = append(productIds, detail.ProductId)
        locationIds = append(locationIds, detail.LocationId)
        locationId = detail.LocationId
    }
    //查询产品信息
@@ -55,27 +57,12 @@
    if err != nil {
        return nil, err
    }
    //查询位置信息
    location, err := models.NewLocationSearch().SetID(locationId).First()
    locationHouseMap, houseLocations, houseMap, err := service.GetWarehouseByLocationIds(locationIds)
    if err != nil {
        return nil, err
    }
    //根据仓库缩写查询仓库
    code := strings.Split(location.JointName, "/")[0]
    warehouse, err := models.NewWarehouseSearch().SetCode(code).First()
    if err != nil {
        return nil, err
    }
    //统计仓库下所有位置的产品在库数量
    locations, err := models.NewLocationSearch().SetJointName(code).FindNotTotal()
    if err != nil {
        return nil, err
    }
    var locationIds []int
    for _, l := range locations {
        locationIds = append(locationIds, l.Id)
    }
    amounts, err := models.NewLocationProductAmountSearch().SetProductIds(productIds).SetLocationIds(locationIds).Find()
    warehouse := locationHouseMap[locationId]
    amounts, err := models.NewLocationProductAmountSearch().SetProductIds(productIds).SetLocationIds(locationIds).SetPreload(true).Find()
    if err != nil {
        return nil, err
    }
@@ -135,6 +122,60 @@
        products = append(products, &p)
    }
    resp.ProductList = products
    if req.GroupByWarehouse {
        canUseMap := make(map[int]map[string]decimal.Decimal) //map[locationID]map[productID]decimal
        for _, v := range canUse {
            if canUseMap[v.LocationId] == nil {
                canUseMap[v.LocationId] = make(map[string]decimal.Decimal)
            }
            canUseMap[v.LocationId][v.ProductId] = canUseMap[v.LocationId][v.ProductId].Add(v.Amount)
        }
        locationProductAmounts := make(map[int][]*models.LocationProductAmount)
        for _, v := range amounts {
            if locationProductAmounts[v.LocationId] == nil {
                locationProductAmounts[v.LocationId] = make([]*models.LocationProductAmount, 0)
            }
            locationProductAmounts[v.LocationId] = append(locationProductAmounts[v.LocationId], v)
        }
        materialMap := service.MaterialMap(materials)
        var warehouseProductsList []*WarehouseProducts
        for houseID, locationIDs := range houseLocations {
            house := houseMap[houseID]
            productAmountMap := make(map[string]decimal.Decimal, 0)
            productAvailableNumberMap := make(map[string]decimal.Decimal, 0)
            productInfoList := make([]*ProductInfo, 0)
            houseProductAmounts := make([]*models.LocationProductAmount, 0)
            for _, lid := range locationIDs {
                houseProductAmounts = append(houseProductAmounts, locationProductAmounts[lid]...)
            }
            for _, v := range houseProductAmounts {
                productAmountMap[v.ProductId] = productAmountMap[v.ProductId].Add(v.Amount)
                productAvailableNumberMap[v.ProductId] = productAvailableNumberMap[v.ProductId].Add(canUseMap[v.LocationId][v.ProductId])
            }
            for productID, amount := range productAvailableNumberMap {
                productInfoList = append(productInfoList, &ProductInfo{
                    Number:          productID,
                    Name:            materialMap[productID].Name,
                    Unit:            materialMap[productID].Unit,
                    Amount:          productAmountMap[productID].String(),
                    AvailableNumber: amount.String(),
                })
            }
            warehouseProducts := &WarehouseProducts{
                WarehouseID:   house.Code,
                WarehouseName: house.Name,
                ProductList:   productInfoList,
            }
            warehouseProductsList = append(warehouseProductsList, warehouseProducts)
        }
        resp.WarehouseProductsList = warehouseProductsList
    }
    return resp, nil
}
service/record_to_map.go
New file
@@ -0,0 +1,11 @@
package service
import "wms/models"
func MaterialMap(materials []*models.Material) (m map[string]*models.Material) {
    m = make(map[string]*models.Material, len(materials))
    for _, v := range materials {
        m[v.ID] = v
    }
    return m
}
service/warehouse.go
New file
@@ -0,0 +1,50 @@
package service
import (
    "strings"
    "wms/models"
)
func GetWarehouseByLocationIds(locationIDs []int) (locationHouseMap map[int]*models.Warehouse, houseLocationIds map[int][]int, houseMap map[int]*models.Warehouse, err error) {
    //查询位置信息
    locations, err := models.NewLocationSearch().SetIds(locationIDs).FindNotTotal()
    if err != nil {
        return
    }
    codes := make([]string, 0)
    codeLocationMap := make(map[string]int, len(locations))
    for _, loc := range locations {
        //根据仓库缩写查询仓库
        code := strings.Split(loc.JointName, "/")[0]
        codes = append(codes, code)
        codeLocationMap[code] = loc.Id
    }
    codeWareHouseMap := make(map[string]*models.Warehouse, len(codes))
    warehouses, err := models.NewWarehouseSearch().SetCodes(codes).FindNotTotal()
    if err != nil {
        return
    }
    houseMap = make(map[int]*models.Warehouse, len(warehouses))
    for _, w := range warehouses {
        codeWareHouseMap[w.Code] = w
        houseMap[w.Id] = w
    }
    locationHouseMap = make(map[int]*models.Warehouse)
    for _, w := range warehouses {
        locationHouseMap[codeLocationMap[w.Code]] = w
    }
    houseLocationIds = make(map[int][]int)
    for locationID, w := range locationHouseMap {
        if houseLocationIds[w.Id] == nil {
            houseLocationIds[w.Id] = make([]int, 0)
        }
        houseLocationIds[w.Id] = append(houseLocationIds[w.Id], locationID)
    }
    return
}