|
|
@@ -276,6 +276,58 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
throw new RuntimeException("更新库存总账失败");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 撤销收货
|
|
|
+ * @param tradeType 单据类型 进口、出口、国内
|
|
|
+ * @param stockId 库存账id
|
|
|
+ * @param deliveryItems 货物明细信息
|
|
|
+ */
|
|
|
+ public void cancelStock(String tradeType,Long stockId,DeliveryItems deliveryItems)
|
|
|
+ {
|
|
|
+ //查询库存账
|
|
|
+ R<StockGoods> stockById = stockGoodsClient.getStockById(stockId);
|
|
|
+ if (!stockById.isSuccess()){
|
|
|
+ throw new RuntimeException("查询库存账出错");
|
|
|
+ }
|
|
|
+ if (stockById.getData() == null){
|
|
|
+ throw new RuntimeException("库存账不存在");
|
|
|
+ }
|
|
|
+ BigDecimal actualQuantity = deliveryItems.getActualQuantity();
|
|
|
+ BigDecimal invoiceWeight = deliveryItems.getInvoiceWeight();
|
|
|
+ BigDecimal billWeight = deliveryItems.getBillWeight();
|
|
|
+ StockGoods stockGoods = stockById.getData();
|
|
|
+ if(actualQuantity.compareTo(stockGoods.getInQuantity())==1)
|
|
|
+ {
|
|
|
+ throw new SecurityException("操作数量大于入库数量,禁止操作");
|
|
|
+ }
|
|
|
+ if(actualQuantity.compareTo(stockGoods.getBalanceQuantity())==1)
|
|
|
+ {
|
|
|
+ throw new SecurityException("操作数量大于结余数量,禁止撤回");
|
|
|
+ }
|
|
|
+ if(actualQuantity.compareTo(stockGoods.getInQuantity())==1)
|
|
|
+ {
|
|
|
+ throw new SecurityException("操作数量大于可用数量,禁止操作");
|
|
|
+ }
|
|
|
+ stockGoods.setInQuantity(stockGoods.getInQuantity().subtract(actualQuantity));//入库数量 减
|
|
|
+ stockGoods.setBalanceQuantity(stockGoods.getBalanceQuantity().subtract(actualQuantity));//结余数量 减
|
|
|
+ stockGoods.setSurplusRouteQuantity(stockGoods.getSurplusRouteQuantity().subtract(actualQuantity));//可用数量 减
|
|
|
+ if (tradeType.equals(OrderTypeEnum.IMPORT.getType())){
|
|
|
+ stockGoods.setInWeight(stockGoods.getInWeight().subtract(invoiceWeight));//入库发票重量 减
|
|
|
+ stockGoods.setBalanceWeight(stockGoods.getBalanceWeight().subtract(invoiceWeight));//结余发票重量 减
|
|
|
+ stockGoods.setInVolumn(stockGoods.getInVolumn().subtract(billWeight));//入库码单重量 减
|
|
|
+ stockGoods.setBalanceVolumn(stockGoods.getBalanceVolumn().subtract(billWeight));//结余码单重量 减
|
|
|
+ }
|
|
|
+ stockGoods.setUpdateTime(new Date());
|
|
|
+ stockGoods.setUpdateUser(SecureUtil.getUserId());
|
|
|
+ R updateStock = stockGoodsClient.updateStock(stockGoods);
|
|
|
+ if (!updateStock.isSuccess()){
|
|
|
+ throw new RuntimeException("更新库存总账失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 收货单新增库存账
|
|
|
* @param tradeType 单据类型 进口、出口、国内
|