|
@@ -528,15 +528,23 @@ public class PurchaseServiceImpl extends ServiceImpl<PurchaseMapper, Purchase> i
|
|
|
.add(vo.getSafetyStock());
|
|
|
vo.setActualShortageQuantity(actualShortageQuantity.compareTo(BigDecimal.ZERO) < 0 ? BigDecimal.ZERO : actualShortageQuantity);
|
|
|
// 经济采购批量 = 短缺数量合计(销售预测)/60*采购周期
|
|
|
- vo.setEconomicOrderQuantity(
|
|
|
- vo.getForecastShortageQuantity()
|
|
|
- .divide(BigDecimal.valueOf(60), 4, RoundingMode.HALF_UP)
|
|
|
- .multiply(vo.getPurchaseCycle())
|
|
|
- .setScale(0, RoundingMode.HALF_UP));
|
|
|
+ if (vo.getForecastShortageQuantity().compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ vo.setEconomicOrderQuantity(BigDecimal.ZERO);
|
|
|
+ } else {
|
|
|
+ vo.setEconomicOrderQuantity(
|
|
|
+ vo.getForecastShortageQuantity()
|
|
|
+ .divide(BigDecimal.valueOf(60), 4, RoundingMode.HALF_UP)
|
|
|
+ .multiply(vo.getPurchaseCycle())
|
|
|
+ .setScale(0, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
// 采购批次 = 短缺数量合计(销售预测)/经济采购批量
|
|
|
- vo.setPurchaseBatches(
|
|
|
- vo.getForecastShortageQuantity()
|
|
|
- .divide(vo.getEconomicOrderQuantity(), 0, RoundingMode.UP));
|
|
|
+ if (vo.getEconomicOrderQuantity().compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ vo.setPurchaseBatches(BigDecimal.ZERO);
|
|
|
+ } else {
|
|
|
+ vo.setPurchaseBatches(
|
|
|
+ vo.getForecastShortageQuantity()
|
|
|
+ .divide(vo.getEconomicOrderQuantity(), 0, RoundingMode.UP));
|
|
|
+ }
|
|
|
|
|
|
exportDataList.add(vo);
|
|
|
}
|