|
@@ -87,6 +87,11 @@ public class CheckInfoServiceImpl extends ServiceImpl<CheckInfoMapper, CheckInfo
|
|
|
// 盘亏金额
|
|
|
BigDecimal lossAmount = BigDecimal.ZERO;
|
|
|
|
|
|
+ /**
|
|
|
+ * 盘点金额
|
|
|
+ */
|
|
|
+ BigDecimal checkAmount = BigDecimal.ZERO;
|
|
|
+
|
|
|
// 获取商品加权平均价
|
|
|
List<Long> productIdList = checkDetailsList.stream().map(CheckDetails::getProductId).collect(Collectors.toList());
|
|
|
Map<Long, BigDecimal> kv = stockService.getKV(Stock::getGoodsId, Stock::getWeightingAveragePrice,
|
|
@@ -104,20 +109,23 @@ public class CheckInfoServiceImpl extends ServiceImpl<CheckInfoMapper, CheckInfo
|
|
|
|
|
|
checkDetails.setCheckInfoId(id);
|
|
|
|
|
|
+ // 产品加权平均价
|
|
|
+ BigDecimal weightingAveragePrice = ObjectUtil.defaultIfNull(kv.get(productId), BigDecimal.ZERO);
|
|
|
+
|
|
|
+ checkAmount = checkAmount.add(weightingAveragePrice.multiply(checkQuantity));
|
|
|
+
|
|
|
int flag = inventoryQuantity.compareTo(checkQuantity);
|
|
|
if (flag > 0) {
|
|
|
checkDetails.setResultType(2);
|
|
|
checkResultType = 1;
|
|
|
|
|
|
// 添加盘亏金额
|
|
|
- BigDecimal weightingAveragePrice = ObjectUtil.defaultIfNull(kv.get(productId), BigDecimal.ZERO);
|
|
|
lossAmount = lossAmount.add(inventoryQuantity.subtract(checkQuantity).multiply(weightingAveragePrice));
|
|
|
} else if (flag < 0) {
|
|
|
checkDetails.setResultType(1);
|
|
|
checkResultType = 1;
|
|
|
|
|
|
// 添加盘盈金额
|
|
|
- BigDecimal weightingAveragePrice = ObjectUtil.defaultIfNull(kv.get(productId), BigDecimal.ZERO);
|
|
|
overflowAmount = overflowAmount.add(checkQuantity.subtract(inventoryQuantity).multiply(weightingAveragePrice));
|
|
|
} else {
|
|
|
checkDetails.setResultType(0);
|
|
@@ -129,6 +137,7 @@ public class CheckInfoServiceImpl extends ServiceImpl<CheckInfoMapper, CheckInfo
|
|
|
checkInfoVo.setId(id);
|
|
|
checkInfoVo.setResultType(checkResultType);
|
|
|
checkInfoVo.setCode(CodeEnum.CHECK_CODE.getCode());
|
|
|
+ checkInfoVo.setAmount(checkAmount);
|
|
|
save(checkInfoVo);
|
|
|
}
|
|
|
|