|
|
@@ -222,6 +222,8 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
List<StockGoods> stockGoodsList = castToList(redisTemplate.opsForValue().get("stockGoods"), StockGoods.class);
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(collect)) {
|
|
|
+ List<DeliveryItems> deliveryItemsList1 = new ArrayList<>();
|
|
|
+ List<StockGoods> stockGoodsList1 = new ArrayList<>();
|
|
|
for (DeliveryItems deliveryItems : collect) {
|
|
|
if (deliveryItems.getItemId() == null) {
|
|
|
throw new RuntimeException("发货明细中商品id不能为空");
|
|
|
@@ -234,11 +236,11 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
if (deliveryItems.getId() == null) {
|
|
|
deliveryItems.setCreateUser(SecureUtil.getUserId());
|
|
|
deliveryItems.setCreateTime(new Date());
|
|
|
- baseMapper.insert(deliveryItems);
|
|
|
+// baseMapper.insert(deliveryItems);
|
|
|
} else {
|
|
|
deliveryItems.setUpdateTime(new Date());
|
|
|
deliveryItems.setUpdateUser(SecureUtil.getUserId());
|
|
|
- baseMapper.updateById(deliveryItems);
|
|
|
+// baseMapper.updateById(deliveryItems);
|
|
|
}
|
|
|
StockGoods stockGoods = null;
|
|
|
StockGoodsVO stock = null;
|
|
|
@@ -270,10 +272,10 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
// 发货
|
|
|
if (stock != null && delivery.getDeliveryType().equals(DeliveryEnum.DELIVER.getType())) {
|
|
|
// 更新库存账
|
|
|
- stockGoods = this.deliverGoods(delivery.getTradeType(), stock.getId(), deliveryItems, null);
|
|
|
+ stockGoods = this.deliverGoods(delivery.getTradeType(), stock, deliveryItems, null);
|
|
|
// 撤销发货
|
|
|
} else if (stock != null && delivery.getDeliveryType().equals(DeliveryEnum.REPEAL.getType())) {
|
|
|
- stockGoods = this.revocationDeliverGoods(delivery.getTradeType(), stock.getId(), deliveryItems, null);
|
|
|
+ stockGoods = this.revocationDeliverGoods(delivery.getTradeType(), stock, deliveryItems, null);
|
|
|
} else {
|
|
|
//新增库存账
|
|
|
throw new RuntimeException("库存为空");
|
|
|
@@ -284,10 +286,10 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
// 发货
|
|
|
if (stock != null && delivery.getDeliveryType().equals(DeliveryEnum.DELIVER.getType())) {
|
|
|
// 更新库存账
|
|
|
- stockGoods = this.deliverGoods(delivery.getTradeType(), stock.getId(), deliveryItems, delivery.getDeliveryType());
|
|
|
+ stockGoods = this.deliverGoods(delivery.getTradeType(), stock, deliveryItems, delivery.getDeliveryType());
|
|
|
// 撤销发货
|
|
|
} else if (stock != null && delivery.getDeliveryType().equals(DeliveryEnum.REPEAL.getType())) {
|
|
|
- stockGoods = this.revocationDeliverGoods(delivery.getTradeType(), stock.getId(), deliveryItems, delivery.getDeliveryType());
|
|
|
+ stockGoods = this.revocationDeliverGoods(delivery.getTradeType(), stock, deliveryItems, delivery.getDeliveryType());
|
|
|
} else {
|
|
|
//新增库存账
|
|
|
throw new RuntimeException("库存为空");
|
|
|
@@ -331,8 +333,12 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- baseMapper.updateById(deliveryItems);
|
|
|
+ stockGoodsList1.add(stockGoods);
|
|
|
+ deliveryItemsList1.add(deliveryItems);
|
|
|
+// baseMapper.updateById(deliveryItems);
|
|
|
}
|
|
|
+ stockGoodsClient.updateStockList(stockGoodsList1);
|
|
|
+ this.saveOrUpdateBatch(deliveryItemsList1);
|
|
|
}
|
|
|
if (CollectionUtils.isNotEmpty(itemsList)) {
|
|
|
itemsList.forEach(item -> {
|
|
|
@@ -437,19 +443,13 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
* 发货减少库存账
|
|
|
*
|
|
|
* @param tradeType 单据类型 进口、出口、国内
|
|
|
- * @param stockId 库存账id
|
|
|
+ * @param stockGoods 库存账id
|
|
|
* @param deliveryItems 货物明细信息
|
|
|
*/
|
|
|
- public StockGoods deliverGoods(String tradeType, Long stockId, DeliveryItems deliveryItems, Integer deliveryType) {
|
|
|
- //查询库存账
|
|
|
- R<StockGoods> stockById = stockGoodsClient.getStockById(stockId);
|
|
|
- if (!stockById.isSuccess()) {
|
|
|
- throw new RuntimeException("查询库存账出错");
|
|
|
- }
|
|
|
- if (stockById.getData() == null) {
|
|
|
+ public StockGoods deliverGoods(String tradeType, StockGoods stockGoods, DeliveryItems deliveryItems, Integer deliveryType) {
|
|
|
+ if (stockGoods == null) {
|
|
|
throw new RuntimeException("库存账不存在");
|
|
|
}
|
|
|
- StockGoods stockGoods = stockById.getData();
|
|
|
//判断出库数量和结余数量的大小
|
|
|
if (stockGoods.getBalanceQuantity().compareTo(deliveryItems.getActualQuantity()) < 0) {
|
|
|
throw new RuntimeException("当前结余数量为:" + stockGoods.getBalanceQuantity() + "小于发货数量,发货数量为:" + deliveryItems.getActualQuantity());
|
|
|
@@ -463,7 +463,7 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
stockGoods.setBalanceQuantity(stockGoods.getBalanceQuantity().subtract(deliveryItems.getArrivalQuantity()));//结余数量 减
|
|
|
stockGoods.setSurplusRouteQuantity(stockGoods.getSurplusRouteQuantity().add(deliveryItems.getActualQuantity()).subtract(deliveryItems.getArrivalQuantity()));//可用数量 减
|
|
|
stockGoods.setLockingQuantity(stockGoods.getLockingQuantity().subtract(deliveryItems.getActualQuantity()));//锁定数量 减
|
|
|
- stockGoods.setBalanceAmount(stockGoods.getBalanceAmount().subtract(deliveryItems.getPurchaseAmount()));
|
|
|
+ stockGoods.setBalanceAmount(stockGoods.getBalanceAmount().subtract(deliveryItems.getPurchaseTotalAmount()));
|
|
|
} else {
|
|
|
stockGoods.setBalanceQuantity(stockGoods.getBalanceQuantity().subtract(deliveryItems.getArrivalQuantity()));//结余数量 减
|
|
|
stockGoods.setSurplusRouteQuantity(stockGoods.getSurplusRouteQuantity().add(deliveryItems.getActualQuantity()).subtract(deliveryItems.getArrivalQuantity()));//可用数量 减
|
|
|
@@ -494,12 +494,12 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
//stockGoods.setLockingVolumn(stockGoods.getLockingVolumn().subtract(deliveryItems.getBillWeight()));//锁定码单重量
|
|
|
stockGoods.setBalanceVolumn(stockGoods.getBalanceVolumn().subtract(deliveryItems.getBillWeight()));//结余码单重量
|
|
|
}
|
|
|
- stockGoods.setUpdateTime(new Date());
|
|
|
- stockGoods.setUpdateUser(SecureUtil.getUserId());
|
|
|
- boolean updateStock = stockGoodsClient.updateStock(stockGoods);
|
|
|
+ stockGoods.setUpdateTime(new Date());/*boolean updateStock = stockGoodsClient.updateStock(stockGoods);
|
|
|
if (!updateStock) {
|
|
|
throw new RuntimeException("更新库存总账失败");
|
|
|
- }
|
|
|
+ }*/
|
|
|
+ stockGoods.setUpdateUser(SecureUtil.getUserId());
|
|
|
+
|
|
|
return stockGoods;
|
|
|
}
|
|
|
|
|
|
@@ -507,19 +507,13 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
* 撤销发货
|
|
|
*
|
|
|
* @param tradeType 单据类型 进口、出口、国内
|
|
|
- * @param stockId 库存账id
|
|
|
+ * @param stockGoods 库存账id
|
|
|
* @param deliveryItems 货物明细信息
|
|
|
*/
|
|
|
- public StockGoods revocationDeliverGoods(String tradeType, Long stockId, DeliveryItems deliveryItems, Integer deliveryType) {
|
|
|
- //查询库存账
|
|
|
- R<StockGoods> stockById = stockGoodsClient.getStockById(stockId);
|
|
|
- if (!stockById.isSuccess()) {
|
|
|
- throw new RuntimeException("查询库存账出错");
|
|
|
- }
|
|
|
- if (stockById.getData() == null) {
|
|
|
+ public StockGoods revocationDeliverGoods(String tradeType, StockGoods stockGoods, DeliveryItems deliveryItems, Integer deliveryType) {
|
|
|
+ if (stockGoods == null) {
|
|
|
throw new RuntimeException("库存账不存在");
|
|
|
}
|
|
|
- StockGoods stockGoods = stockById.getData();
|
|
|
//判断出库数量和结余数量的大小
|
|
|
if (stockGoods.getOutQuantity().compareTo(deliveryItems.getActualQuantity()) < 0) {
|
|
|
throw new RuntimeException("当前可减少出库数量为:" + stockGoods.getOutQuantity() + "小于发货数量,发货数量为:" + deliveryItems.getActualQuantity());
|
|
|
@@ -530,7 +524,7 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
&& "1".equals(sysClient.getParamService("synchronous"))) {
|
|
|
stockGoods.setLockingQuantity(stockGoods.getLockingQuantity().add(deliveryItems.getActualQuantity()));//锁定数量 加
|
|
|
stockGoods.setSurplusRouteQuantity(stockGoods.getBalanceQuantity().subtract(stockGoods.getLockingQuantity()));//可用数量 加
|
|
|
- stockGoods.setBalanceAmount(stockGoods.getBalanceAmount().add(deliveryItems.getPurchaseAmount()));
|
|
|
+ stockGoods.setBalanceAmount(stockGoods.getBalanceAmount().add(deliveryItems.getPurchaseTotalAmount()));
|
|
|
}
|
|
|
} else {
|
|
|
stockGoods.setBalanceQuantity(stockGoods.getBalanceQuantity().subtract(deliveryItems.getArrivalQuantity()));//结余数量 加
|
|
|
@@ -562,10 +556,10 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
}
|
|
|
stockGoods.setUpdateTime(new Date());
|
|
|
stockGoods.setUpdateUser(SecureUtil.getUserId());
|
|
|
- boolean updateStock = stockGoodsClient.updateStock(stockGoods);
|
|
|
+ /*boolean updateStock = stockGoodsClient.updateStock(stockGoods);
|
|
|
if (!updateStock) {
|
|
|
throw new RuntimeException("更新库存总账失败");
|
|
|
- }
|
|
|
+ }*/
|
|
|
return stockGoods;
|
|
|
}
|
|
|
|
|
|
@@ -573,16 +567,12 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
* 撤销收货
|
|
|
*
|
|
|
* @param tradeType 单据类型 进口、出口、国内
|
|
|
- * @param stockId 库存账id
|
|
|
+ * @param stockGoods 库存账id
|
|
|
* @param deliveryItems 货物明细信息
|
|
|
*/
|
|
|
- public StockGoods cancelStock(String tradeType, Long stockId, DeliveryItems deliveryItems) {
|
|
|
- //查询库存账
|
|
|
- R<StockGoods> stockById = stockGoodsClient.getStockById(stockId);
|
|
|
- if (!stockById.isSuccess()) {
|
|
|
- throw new RuntimeException("查询库存账出错");
|
|
|
- }
|
|
|
- if (stockById.getData() == null) {
|
|
|
+ public StockGoods cancelStock(String tradeType, StockGoods stockGoods, DeliveryItems deliveryItems) {
|
|
|
+
|
|
|
+ if (stockGoods == null) {
|
|
|
throw new RuntimeException("库存账不存在");
|
|
|
}
|
|
|
BigDecimal actualQuantity = new BigDecimal("0.00");
|
|
|
@@ -594,7 +584,6 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
BigDecimal invoiceWeight = deliveryItems.getInvoiceWeight() == null ? new BigDecimal("0") : deliveryItems.getInvoiceWeight();
|
|
|
BigDecimal billWeight = deliveryItems.getBillWeight() == null ? new BigDecimal("0") : deliveryItems.getBillWeight();
|
|
|
|
|
|
- StockGoods stockGoods = stockById.getData();
|
|
|
if (!tradeType.equals(OrderTypeEnum.DOMESTIC.getType())) {
|
|
|
if (actualQuantity.compareTo(stockGoods.getInQuantity()) > 0) {
|
|
|
throw new SecurityException("操作数量大于入库数量,禁止操作");
|
|
|
@@ -632,10 +621,10 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
|
|
|
stockGoods.setUpdateTime(new Date());
|
|
|
stockGoods.setUpdateUser(SecureUtil.getUserId());
|
|
|
- boolean updateStock = stockGoodsClient.updateStock(stockGoods);
|
|
|
+ /*boolean updateStock = stockGoodsClient.updateStock(stockGoods);
|
|
|
if (!updateStock) {
|
|
|
throw new RuntimeException("更新库存总账失败");
|
|
|
- }
|
|
|
+ }*/
|
|
|
return stockGoods;
|
|
|
}
|
|
|
|
|
|
@@ -644,20 +633,13 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
* 收货单新增库存账
|
|
|
*
|
|
|
* @param tradeType 单据类型 进口、出口、国内
|
|
|
- * @param stockId 库存账id
|
|
|
+ * @param stockGoods 库存账
|
|
|
* @param deliveryItems 货物明细信息
|
|
|
*/
|
|
|
- public StockGoods receiving(String tradeType, Long stockId, DeliveryItems deliveryItems) {
|
|
|
- //查询库存账
|
|
|
- R<StockGoods> stockById = stockGoodsClient.getStockById(stockId);
|
|
|
- if (!stockById.isSuccess()) {
|
|
|
- throw new RuntimeException("查询库存账出错");
|
|
|
- }
|
|
|
- if (stockById.getData() == null) {
|
|
|
+ public StockGoods receiving(String tradeType, StockGoods stockGoods, DeliveryItems deliveryItems) {
|
|
|
+ if (stockGoods == null) {
|
|
|
throw new RuntimeException("库存账不存在");
|
|
|
}
|
|
|
-
|
|
|
- StockGoods stockGoods = stockById.getData();
|
|
|
if (!tradeType.equals(OrderTypeEnum.DOMESTIC.getType())) {
|
|
|
stockGoods.setInQuantity(stockGoods.getInQuantity().add(deliveryItems.getActualQuantity()));//入库数量 加
|
|
|
stockGoods.setBalanceQuantity(stockGoods.getBalanceQuantity().add(deliveryItems.getActualQuantity()));//结余数量 加
|
|
|
@@ -1100,16 +1082,10 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public StockGoods receivingInventory(String tradeType, Long id, OrderItems e) {
|
|
|
- //查询库存账
|
|
|
- R<StockGoods> stockById = stockGoodsClient.getStockById(id);
|
|
|
- if (!stockById.isSuccess()) {
|
|
|
- throw new RuntimeException("查询库存账出错");
|
|
|
- }
|
|
|
- if (stockById.getData() == null) {
|
|
|
+ public StockGoods receivingInventory(StockGoods stockGoods, OrderItems e) {
|
|
|
+ if (stockGoods == null) {
|
|
|
throw new RuntimeException("库存账不存在");
|
|
|
}
|
|
|
- StockGoods stockGoods = stockById.getData();
|
|
|
|
|
|
if (stockGoods.getLockingQuantity().compareTo(e.getOrderQuantity()) < 0) {
|
|
|
throw new RuntimeException(stockGoods.getCode() + "更新库存总账失败,锁定库存不足");
|