From d91f181819984ed68d928bec6e926da6566e7a3f Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期五, 05 七月 2024 14:53:02 +0800 Subject: [PATCH] 当操作为出库或调拨时,操作详情明细返回产品相应位置的实时库存 --- controllers/operation.go | 29 ++++++++++++++++++++++++----- 1 files changed, 24 insertions(+), 5 deletions(-) diff --git a/controllers/operation.go b/controllers/operation.go index f0afda4..5efb66b 100644 --- a/controllers/operation.go +++ b/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) } -- Gitblit v1.8.0