| | |
| | | LocationId int `json:"locationId"` |
| | | } |
| | | |
| | | func (s *Server) GetProductInfo(ctx context.Context, req *GetInventoryProductInfoRequest) (*GetInventoryProductInfoResponse, error) { |
| | | func (s *Server) GetInventoryProductInfo(ctx context.Context, req *GetInventoryProductInfoRequest) (*GetInventoryProductInfoResponse, error) { |
| | | if req.Number == "" { |
| | | return nil, errors.New("参数不能为空") |
| | | } |
| | |
| | | var details []ProductAndLocationInfo |
| | | var productIds []string |
| | | err := models.NewOperationDetailsSearch().Orm.Model(&models.OperationDetails{}). |
| | | Select("wms_operation_details.product_id,wms_operation_details.amount,wms_operation.from_location_id"). |
| | | Select("wms_operation_details.product_id,wms_operation_details.amount,wms_operation.from_location_id as location_id"). |
| | | Joins("left join wms_operation on wms_operation.id = wms_operation_details.operation_id"). |
| | | Where("wms_operation.source_number = ?", req.Number).Find(&details).Error |
| | | if err != nil { |
| | |
| | | } |
| | | products := make([]*ProductInfo, 0) |
| | | for _, material := range materials { |
| | | var p *ProductInfo |
| | | var p ProductInfo |
| | | p.Id = material.ID |
| | | p.Name = material.Name |
| | | for _, detail := range details { |
| | |
| | | } |
| | | p.AvailableNumber = cu.String() |
| | | |
| | | products = append(products, p) |
| | | products = append(products, &p) |
| | | } |
| | | resp := new(GetInventoryProductInfoResponse) |
| | | resp.ProductList = products |
| | |
| | | operation.BaseOperationType = constvar.BaseOperationTypeOutgoing |
| | | if req.DeliverType == 1 { |
| | | for _, product := range req.ProductList { |
| | | var detail *models.OperationDetails |
| | | var detail models.OperationDetails |
| | | detail.ProductId = product.Id |
| | | amount, _ := decimal.NewFromString(product.Amount) |
| | | detail.Amount = amount |
| | | details = append(details, detail) |
| | | details = append(details, &detail) |
| | | } |
| | | operation.Details = details |
| | | operations = append(operations, &operation) |
| | | } else { |
| | | for _, product := range req.ProductList { |
| | | newOperation := operation |
| | | var detail *models.OperationDetails |
| | | var detail models.OperationDetails |
| | | detail.ProductId = product.Id |
| | | amount, _ := decimal.NewFromString(product.Amount) |
| | | detail.Amount = amount |
| | | details = append(details, detail) |
| | | newOperation.Details = append(newOperation.Details, detail) |
| | | details = append(details, &detail) |
| | | newOperation.Details = append(newOperation.Details, &detail) |
| | | operations = append(operations, &newOperation) |
| | | } |
| | | } |