Browse Source

库存账逻辑修改

lazhaoqian 4 years ago
parent
commit
c8e46298e0

+ 16 - 12
blade-service/blade-deliver-goods/src/main/java/org/springblade/deliver/goods/service/impl/DeliveryItemsServiceImpl.java

@@ -191,16 +191,21 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
 		if (stockGoods.getBalanceQuantity().compareTo(deliveryItems.getActualQuantity()) < 0){
 		if (stockGoods.getBalanceQuantity().compareTo(deliveryItems.getActualQuantity()) < 0){
 			throw  new RuntimeException("当前结余数量为:"+stockGoods.getBalanceQuantity() +"小于出库数量,出库数量为:" +deliveryItems.getActualQuantity());
 			throw  new RuntimeException("当前结余数量为:"+stockGoods.getBalanceQuantity() +"小于出库数量,出库数量为:" +deliveryItems.getActualQuantity());
 		}
 		}
-		stockGoods.setOutQuantity(stockGoods.getOutQuantity().add( deliveryItems.getActualQuantity()));//出库数量
-		stockGoods.setLockingQuantity(new BigDecimal(0.00));//锁定数量
-		stockGoods.setBalanceQuantity(stockGoods.getBalanceQuantity().subtract(deliveryItems.getActualQuantity()));//结余数量
-		stockGoods.setEnRouteQuantity(stockGoods.getEnRouteQuantity().subtract(deliveryItems.getActualQuantity()));//在途数量
-		stockGoods.setSurplusRouteQuantity(stockGoods.getSurplusRouteQuantity().subtract(deliveryItems.getActualQuantity()));//可用数量
+		if (stockGoods.getLockingQuantity().compareTo(deliveryItems.getActualQuantity()) < 0){
+			throw  new RuntimeException("当前可用数量为:"+stockGoods.getLockingQuantity() +"小于出库数量,出库数量为:" +deliveryItems.getActualQuantity());
+		}
+		stockGoods.setOutQuantity(stockGoods.getOutQuantity().add( deliveryItems.getActualQuantity()));//出库数量 加
+		stockGoods.setLockingQuantity(stockGoods.getLockingQuantity().subtract(deliveryItems.getActualQuantity()));//锁定数量 减
+		stockGoods.setBalanceQuantity(stockGoods.getBalanceQuantity().subtract(deliveryItems.getActualQuantity()));//结余数量 减
+		stockGoods.setSurplusRouteQuantity(stockGoods.getSurplusRouteQuantity().subtract(deliveryItems.getActualQuantity()));//可用数量 减
 		if (tradeType.equals(OrderTypeEnum.IMPORT.getType())){
 		if (tradeType.equals(OrderTypeEnum.IMPORT.getType())){
 			//判断出库发票重量和结余发票重量
 			//判断出库发票重量和结余发票重量
 			if (stockGoods.getBalanceWeight().compareTo(deliveryItems.getInvoiceWeight()) < 0){
 			if (stockGoods.getBalanceWeight().compareTo(deliveryItems.getInvoiceWeight()) < 0){
 				throw  new RuntimeException("当前结余发票重量为:"+stockGoods.getBalanceWeight() +"小于出库发票重量,出库发票重量为:" +deliveryItems.getInvoiceWeight());
 				throw  new RuntimeException("当前结余发票重量为:"+stockGoods.getBalanceWeight() +"小于出库发票重量,出库发票重量为:" +deliveryItems.getInvoiceWeight());
 			}
 			}
+			if (stockGoods.getLockingWeight().compareTo(deliveryItems.getInvoiceWeight()) < 0){
+				throw  new RuntimeException("当前结余发票重量为:"+stockGoods.getLockingWeight() +"小于出库发票重量,出库发票重量为:" +deliveryItems.getInvoiceWeight());
+			}
 			stockGoods.setOutWeight(stockGoods.getOutWeight().add(deliveryItems.getInvoiceWeight()));//出库发票重量
 			stockGoods.setOutWeight(stockGoods.getOutWeight().add(deliveryItems.getInvoiceWeight()));//出库发票重量
 			stockGoods.setLockingWeight(stockGoods.getLockingWeight().subtract(deliveryItems.getInvoiceWeight()));//锁定发票重量
 			stockGoods.setLockingWeight(stockGoods.getLockingWeight().subtract(deliveryItems.getInvoiceWeight()));//锁定发票重量
 			stockGoods.setBalanceWeight(stockGoods.getBalanceWeight().subtract(deliveryItems.getInvoiceWeight()));//结余发票重量
 			stockGoods.setBalanceWeight(stockGoods.getBalanceWeight().subtract(deliveryItems.getInvoiceWeight()));//结余发票重量
@@ -208,6 +213,9 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
 			if (stockGoods.getBalanceVolumn().compareTo(deliveryItems.getBillWeight()) < 0){
 			if (stockGoods.getBalanceVolumn().compareTo(deliveryItems.getBillWeight()) < 0){
 				throw  new RuntimeException("当前结余码单重量为:"+stockGoods.getBalanceVolumn() +"小于出库码单重量,出库码单重量为:" +deliveryItems.getBillWeight());
 				throw  new RuntimeException("当前结余码单重量为:"+stockGoods.getBalanceVolumn() +"小于出库码单重量,出库码单重量为:" +deliveryItems.getBillWeight());
 			}
 			}
+			if (stockGoods.getLockingVolumn().compareTo(deliveryItems.getBillWeight()) < 0){
+				throw  new RuntimeException("当前结余码单重量为:"+stockGoods.getLockingVolumn() +"小于出库码单重量,出库码单重量为:" +deliveryItems.getBillWeight());
+			}
 			stockGoods.setOutVolumn(stockGoods.getOutVolumn().add(deliveryItems.getBillWeight()));//出库码单重量
 			stockGoods.setOutVolumn(stockGoods.getOutVolumn().add(deliveryItems.getBillWeight()));//出库码单重量
 			stockGoods.setLockingVolumn(stockGoods.getLockingVolumn().subtract(deliveryItems.getBillWeight()));//锁定码单重量
 			stockGoods.setLockingVolumn(stockGoods.getLockingVolumn().subtract(deliveryItems.getBillWeight()));//锁定码单重量
 			stockGoods.setBalanceVolumn(stockGoods.getBalanceVolumn().subtract(deliveryItems.getBillWeight()));//结余码单重量
 			stockGoods.setBalanceVolumn(stockGoods.getBalanceVolumn().subtract(deliveryItems.getBillWeight()));//结余码单重量
@@ -236,16 +244,12 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
 		}
 		}
 		StockGoods stockGoods = stockById.getData();
 		StockGoods stockGoods = stockById.getData();
 		stockGoods.setInQuantity(stockGoods.getInQuantity().add(deliveryItems.getActualQuantity()));//入库数量
 		stockGoods.setInQuantity(stockGoods.getInQuantity().add(deliveryItems.getActualQuantity()));//入库数量
-		stockGoods.setLockingQuantity(stockGoods.getLockingQuantity().add(deliveryItems.getActualQuantity()));//锁定数量
 		stockGoods.setBalanceQuantity(stockGoods.getBalanceQuantity().add(deliveryItems.getActualQuantity()));//结余数量
 		stockGoods.setBalanceQuantity(stockGoods.getBalanceQuantity().add(deliveryItems.getActualQuantity()));//结余数量
-		stockGoods.setEnRouteQuantity(stockGoods.getEnRouteQuantity().add(deliveryItems.getActualQuantity()));//在途数量
 		stockGoods.setSurplusRouteQuantity(stockGoods.getSurplusRouteQuantity().add(deliveryItems.getActualQuantity()));//可用数量
 		stockGoods.setSurplusRouteQuantity(stockGoods.getSurplusRouteQuantity().add(deliveryItems.getActualQuantity()));//可用数量
 		if (tradeType.equals(OrderTypeEnum.IMPORT.getType())){
 		if (tradeType.equals(OrderTypeEnum.IMPORT.getType())){
 			stockGoods.setInWeight(stockGoods.getInWeight().add(deliveryItems.getInvoiceWeight()));//入库发票重量
 			stockGoods.setInWeight(stockGoods.getInWeight().add(deliveryItems.getInvoiceWeight()));//入库发票重量
-			stockGoods.setLockingWeight(stockGoods.getLockingWeight().add(deliveryItems.getInvoiceWeight()));//锁定发票重量
 			stockGoods.setBalanceWeight(stockGoods.getBalanceWeight().add(deliveryItems.getInvoiceWeight()));//结余发票重量
 			stockGoods.setBalanceWeight(stockGoods.getBalanceWeight().add(deliveryItems.getInvoiceWeight()));//结余发票重量
 			stockGoods.setInVolumn(stockGoods.getInVolumn().add(deliveryItems.getBillWeight()));//入库码单重量
 			stockGoods.setInVolumn(stockGoods.getInVolumn().add(deliveryItems.getBillWeight()));//入库码单重量
-			stockGoods.setLockingVolumn(stockGoods.getLockingVolumn().add(deliveryItems.getBillWeight()));//锁定码单重量
 			stockGoods.setBalanceVolumn(stockGoods.getBalanceVolumn().add(deliveryItems.getBillWeight()));//结余码单重量
 			stockGoods.setBalanceVolumn(stockGoods.getBalanceVolumn().add(deliveryItems.getBillWeight()));//结余码单重量
 		}
 		}
 		stockGoods.setUpdateTime(new Date());
 		stockGoods.setUpdateTime(new Date());
@@ -273,16 +277,16 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
 		stockGoods.setOutQuantity(new BigDecimal(0.00));//出库数量
 		stockGoods.setOutQuantity(new BigDecimal(0.00));//出库数量
 		stockGoods.setLockingQuantity(new BigDecimal(0.00));//锁定数量
 		stockGoods.setLockingQuantity(new BigDecimal(0.00));//锁定数量
 		stockGoods.setBalanceQuantity(deliveryItems.getActualQuantity());//结余数量
 		stockGoods.setBalanceQuantity(deliveryItems.getActualQuantity());//结余数量
-		stockGoods.setEnRouteQuantity(deliveryItems.getActualQuantity());//在途数量
+		stockGoods.setEnRouteQuantity(new BigDecimal(0.00));//在途数量
 		stockGoods.setSurplusRouteQuantity(deliveryItems.getActualQuantity());//可用数量
 		stockGoods.setSurplusRouteQuantity(deliveryItems.getActualQuantity());//可用数量
 		if (tradeType.equals(OrderTypeEnum.IMPORT.getType())){
 		if (tradeType.equals(OrderTypeEnum.IMPORT.getType())){
 			stockGoods.setInWeight(deliveryItems.getInvoiceWeight());//入库发票重量
 			stockGoods.setInWeight(deliveryItems.getInvoiceWeight());//入库发票重量
 			stockGoods.setOutWeight(new BigDecimal(0.00));//出库发票重量
 			stockGoods.setOutWeight(new BigDecimal(0.00));//出库发票重量
-			stockGoods.setLockingWeight(deliveryItems.getInvoiceWeight());//锁定发票重量
+			stockGoods.setLockingWeight(new BigDecimal(0.00));//锁定发票重量
 			stockGoods.setBalanceWeight(deliveryItems.getInvoiceWeight());//结余发票重量
 			stockGoods.setBalanceWeight(deliveryItems.getInvoiceWeight());//结余发票重量
 			stockGoods.setInVolumn(deliveryItems.getBillWeight());//入库码单重量
 			stockGoods.setInVolumn(deliveryItems.getBillWeight());//入库码单重量
 			stockGoods.setOutVolumn(new BigDecimal(0.00));//出库码单重量
 			stockGoods.setOutVolumn(new BigDecimal(0.00));//出库码单重量
-			stockGoods.setLockingVolumn(deliveryItems.getBillWeight());//锁定码单重量
+			stockGoods.setLockingVolumn(new BigDecimal(0.00));//锁定码单重量
 			stockGoods.setBalanceVolumn(deliveryItems.getBillWeight());//结余码单重量
 			stockGoods.setBalanceVolumn(deliveryItems.getBillWeight());//结余码单重量
 		}
 		}
 		stockGoods.setCreateUser(SecureUtil.getUserId());
 		stockGoods.setCreateUser(SecureUtil.getUserId());