无关风月
2026-01-14 4b3d78ea91a12c3d4dcaab7b897125182bbc6342
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java
@@ -23,6 +23,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
@@ -191,9 +192,13 @@
        List<TErpGoodsType> typeList = erpGoodsTypeMapper.selectBatchIds(typeIds);
        for (TErpGoodsVO tErpGoodsVO : list) {
            List<TErpProcurementGoods> tErpProcurementGoods = goodsSalesMap.get(tErpGoodsVO.getId());
            // 计算采购数量
            tErpGoodsVO.setSalesCount(tErpProcurementGoods.stream().filter(e->e.getPurchaseCount()!=null).mapToInt(TErpProcurementGoods::getPurchaseCount).sum());
            typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName()));
            if(!CollectionUtils.isEmpty(tErpProcurementGoods)){
                // 计算采购数量
                tErpGoodsVO.setSalesCount(tErpProcurementGoods.stream().filter(e->e.getPurchaseCount()!=null).mapToInt(TErpProcurementGoods::getPurchaseCount).sum());
                typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName()));
            }else {
                tErpGoodsVO.setSalesCount(0);
            }
        }
        pageInfo.setRecords(list);
        return pageInfo;
@@ -213,9 +218,13 @@
        List<TErpGoodsType> typeList = erpGoodsTypeMapper.selectBatchIds(typeIds);
        for (TErpGoodsVO tErpGoodsVO : list) {
            List<TErpProcurementGoods> tErpProcurementGoods = goodsSalesMap.get(tErpGoodsVO.getId());
            // 计算采购数量
            tErpGoodsVO.setSalesCount(tErpProcurementGoods.stream().filter(e->e.getPurchaseCount()!=null).mapToInt(TErpProcurementGoods::getPurchaseCount).sum());
            typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName()));
            if(!CollectionUtils.isEmpty(tErpProcurementGoods)){
                // 计算采购数量
                tErpGoodsVO.setSalesCount(tErpProcurementGoods.stream().filter(e->e.getPurchaseCount()!=null).mapToInt(TErpProcurementGoods::getPurchaseCount).sum());
                typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName()));
            }else {
                tErpGoodsVO.setSalesCount(0);
            }
        }
        return list;
    }