zhangqian
2024-07-05 d91f181819984ed68d928bec6e926da6566e7a3f
controllers/operation.go
@@ -287,12 +287,11 @@
// GetOperationInfo
// @Tags      入库/出库
// @Summary   入库/出库列表
// @Summary   操作详情接口
// @Produce   application/json
//
//   @Param      id   path      string         true   "id"
//
// @Success   200 {object} util.Response   "成功"
// @Param     id path  string true "id"
// @Param     Authorization   header string true "token"
// @Success   200 {object} util.Response{data=models.Operation}   "成功"
// @Router    /api-wms/v1/operation/getOperationInfo/{id} [get]
func (slf OperationController) GetOperationInfo(c *gin.Context) {
   number := c.Param("id")
@@ -306,6 +305,26 @@
      util.ResponseFormat(c, code.RequestParamError, err.Error())
      return
   }
   if operation.BaseOperationType == constvar.BaseOperationTypeOutgoing || operation.BaseOperationType == constvar.BaseOperationTypeInternal { //查询实时在库库存
      productIds := make([]string, 0)
      locationIds := make([]int, 0)
      for _, v := range operation.Details {
         productIds = append(productIds, v.ProductId)
         locationIds = append(locationIds, v.FromLocationID)
      }
      locationAmountMap, err := service.GetLocationAmounts(productIds, locationIds)
      if err != nil {
         util.ResponseFormat(c, code.RequestParamError, "查询产品库存错误")
         return
      }
      for _, v := range operation.Details {
         if locationAmountMap[v.ProductId] != nil {
            v.StockAmount = locationAmountMap[v.ProductId][v.FromLocationID]
         }
      }
   }
   util.ResponseFormat(c, code.Success, operation)
}