| 对比新文件 |
| | |
| | | package com.ruoyi.procurementrecord.utils; |
| | | |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordMapper; |
| | | import com.ruoyi.procurementrecord.mapper.ProcurementRecordOutMapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | @Component |
| | | @RequiredArgsConstructor |
| | | public class StockUtils { |
| | | private final ProcurementRecordOutMapper procurementRecordOutMapper; |
| | | private final ProcurementRecordMapper procurementRecordMapper; |
| | | |
| | | // 鑾峰彇鍟嗗搧鍓╀綑搴撳瓨 |
| | | public BigDecimal getStockQuantity(Long productModelId) { |
| | | // 鍏ュ簱鏁伴噺 |
| | | BigDecimal sumQuantity = procurementRecordMapper.getSumQuantity(productModelId); |
| | | // 鍑哄簱鏁伴噺 |
| | | BigDecimal outQuantity = procurementRecordOutMapper.getSumQuantity(productModelId); |
| | | return outQuantity.compareTo(sumQuantity) > 0 ? BigDecimal.ZERO : sumQuantity.subtract(outQuantity); |
| | | } |
| | | } |