yzc %!s(int64=2) %!d(string=hai) anos
pai
achega
a2d1c7cf26

+ 12 - 1
hx-victoriatourist/src/main/java/com/fjhx/victoriatourist/service/deliver/impl/DeliverGoodsServiceImpl.java

@@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 import java.util.function.Function;
@@ -84,9 +85,19 @@ public class DeliverGoodsServiceImpl extends ServiceImpl<DeliverGoodsMapper, Del
                 deliverGoodsDetailsVo.setSpec(productInfo.getSpec());
                 deliverGoodsDetailsVo.setUnit(productInfo.getUnit());
             }
-            //赋值采购数量,现在在途数量
+            //赋值采购数量
             PurchaseDetail purchaseDetail = purchaseDetailMap.get(deliverGoodsDetailsVo.getPurchaseDetailId());
             deliverGoodsDetailsVo.setCount(purchaseDetail.getCount());
+            //赋值在途数量
+            IWrapper<DeliverGoods> wrapper1 = IWrapper.getWrapper();
+            wrapper1.eq("dgd",DeliverGoodsDetails::getPurchaseDetailId, deliverGoodsDetailsVo.getPurchaseDetailId());
+            wrapper1.eq("dg.status",0);
+            List<DeliverGoodsDetailsVo> list = baseMapper.listDeliverGoodsDetails(wrapper);
+            BigDecimal count = list.stream()
+                    .map(DeliverGoodsDetails::getDeliverGoodsQuantity)
+                    .reduce(BigDecimal.ZERO, BigDecimal::add);
+            BigDecimal subtract = count.subtract(deliverGoodsDetailsVo.getDeliverGoodsQuantity());
+            deliverGoodsDetailsVo.setTransitQuantity(subtract);
         }
         return deliverGoodsDetailsVos;
     }