|
|
@@ -186,6 +186,7 @@ public class CommodityInOutboundServiceImpl implements CommodityInOutboundServic
|
|
|
inOutbound.setInOutId(inOutboundId);
|
|
|
Short i = 1;
|
|
|
Set<InOutboundDetail> set = new HashSet<>();
|
|
|
+ Set<Product> productSet = new HashSet<>();
|
|
|
if (CollectionUtils.isNotEmpty(prids)) {
|
|
|
List<Product> products = productService.findByProductId(prids);
|
|
|
for (InOutboundDetail inOutboundDetail : detaiList) {
|
|
|
@@ -202,12 +203,14 @@ public class CommodityInOutboundServiceImpl implements CommodityInOutboundServic
|
|
|
|
|
|
}
|
|
|
product.setErpReserve(NumberUtil.add(product.getErpReserve(), inOutboundDetail.getQty()));
|
|
|
+ productSet.add(product);
|
|
|
} else {
|
|
|
//出库
|
|
|
if (NumberUtil.compare(product.getErpReserve(), DoubleConstant.zero) == 0) {
|
|
|
throw new IllegalOperatorException("型号:" + product.getPcmpcode() + ",品牌:" +product.getPbranden()+"的物料为0,不能做出库");
|
|
|
} else if (NumberUtil.compare(product.getErpReserve(), inOutboundDetail.getQty()) > 0) {
|
|
|
product.setErpReserve(NumberUtil.sub(product.getErpReserve(), inOutboundDetail.getQty()));
|
|
|
+ productSet.add(product);
|
|
|
} else {
|
|
|
throw new IllegalOperatorException("型号:" + product.getPcmpcode() + ",品牌:" +product.getPbranden()+"的物料库存数为"+product.getErpReserve() + "出库数是:"+inOutboundDetail.getQty()+"不能做出库");
|
|
|
}
|
|
|
@@ -238,7 +241,14 @@ public class CommodityInOutboundServiceImpl implements CommodityInOutboundServic
|
|
|
//重新计算成本价、在售产品的库存信息需要更新
|
|
|
List<Long> pridList = new ArrayList<>();
|
|
|
pridList.addAll(prids);
|
|
|
- productService.updateProductsByInBound(pridList);
|
|
|
+ List<Product> productList = new ArrayList<>();
|
|
|
+ productList.addAll(productSet);
|
|
|
+ if (CollectionUtils.isNotEmpty(productList)) {
|
|
|
+ productService.save(productList);
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(pridList)) {
|
|
|
+ productService.updateProductsByInBound(pridList);
|
|
|
+ }
|
|
|
return ResultMap.success(commodityInOutbound);
|
|
|
}
|
|
|
}
|