|
|
@@ -2293,62 +2293,13 @@ public class ProductServiceImpl implements ProductService {
|
|
|
return;
|
|
|
} else {
|
|
|
List<Product> products = productDao.findProductInId(prids);
|
|
|
- Set<Long> idSet = new HashSet<>();
|
|
|
- idSet.addAll(prids);
|
|
|
- List<InOutboundDetail> inOutboundDetails = inOutboundDetailService.findByProductId(idSet);
|
|
|
- Map<Long, List<Double>> map = new HashMap<>();
|
|
|
- Double qtyContainPrice = 0.0d;
|
|
|
- Double qty = 0.0d;
|
|
|
- Double totalPrice = 0.0d;
|
|
|
- List<Double> doubleList = null;
|
|
|
- for (InOutboundDetail inOutboundDetail : inOutboundDetails) {
|
|
|
- doubleList = map.get(inOutboundDetail.getProductId());
|
|
|
- qtyContainPrice = 0.0d; qty = 0.0d; totalPrice = 0.0d;
|
|
|
- if (doubleList == null) {
|
|
|
- doubleList = new ArrayList<>();
|
|
|
- doubleList.add(qtyContainPrice);
|
|
|
- doubleList.add(qty);
|
|
|
- doubleList.add(totalPrice);
|
|
|
- } else {
|
|
|
- qtyContainPrice = doubleList.get(0);
|
|
|
- qty = doubleList.get(1);
|
|
|
- totalPrice = doubleList.get(2);
|
|
|
- }
|
|
|
- if (InOutBoundType.INBOUND.equals(inOutboundDetail.getCommodityInOutbound().getType())) {
|
|
|
- qty = NumberUtil.add(qty, inOutboundDetail.getQty());
|
|
|
- if (inOutboundDetail.getPrice() != null) {
|
|
|
- qtyContainPrice = NumberUtil.add(qtyContainPrice, inOutboundDetail.getQty());
|
|
|
- totalPrice = NumberUtil.add(totalPrice, NumberUtil.mul(inOutboundDetail.getPrice(), inOutboundDetail.getQty()));
|
|
|
- }
|
|
|
- } else {
|
|
|
- qty = NumberUtil.sub(qty, inOutboundDetail.getQty());
|
|
|
- }
|
|
|
- doubleList.set(0, qtyContainPrice);
|
|
|
- doubleList.set(1, qty);
|
|
|
- doubleList.set(2, totalPrice);
|
|
|
- map.put(inOutboundDetail.getProductId(), doubleList);
|
|
|
- }
|
|
|
-
|
|
|
- for (Product product : products) {
|
|
|
- List<Double> list = map.get(product.getId());
|
|
|
- if (CollectionUtils.isNotEmpty(list)) {
|
|
|
- qty = list.get(1);
|
|
|
- if (NumberUtil.compare(qty, DoubleConstant.zero) < 1) {
|
|
|
- product.setErpReserve(DoubleConstant.zero);
|
|
|
- } else {
|
|
|
- product.setErpReserve(qty);
|
|
|
- }
|
|
|
- double price = NumberUtil.div(list.get(2), list.get(0));
|
|
|
- product.setPrice(price);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
List<Goods> goodsList = goodsService.findByProductids(prids);
|
|
|
for (Product product : products) {
|
|
|
for (Goods goods : goodsList) {
|
|
|
if (goods.getProductid().longValue() == product.getId().longValue()) {
|
|
|
goods.setReserve(product.getErpReserve());
|
|
|
goods.setStatus();
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|