修复:补齐测试批次恢复锁定
This commit is contained in:
@@ -304,6 +304,7 @@ class FillingService:
|
||||
test_scope: TestBatchScope,
|
||||
) -> CrudResponseModel:
|
||||
try:
|
||||
await TestBatchAccessService.lock_active_batch(query_db, test_scope)
|
||||
warehouse_ids = await cls._warehouse_scope(query_db, current_user)
|
||||
if warehouse_ids is not None and page_object.warehouse_id not in warehouse_ids:
|
||||
raise PermissionException(data='', message='无权访问该仓库')
|
||||
@@ -509,7 +510,7 @@ class FillingService:
|
||||
request_hash=request_hash,
|
||||
test_batch_id=test_scope.batch_id,
|
||||
)
|
||||
await InventoryDao.add_event(query_db, inventory, event)
|
||||
await InventoryDao.add_event(query_db, inventory, event, test_scope)
|
||||
await query_db.commit()
|
||||
return cls._success(filling_id)
|
||||
except IntegrityError:
|
||||
|
||||
@@ -502,6 +502,7 @@ class InboundService:
|
||||
test_scope: TestBatchScope,
|
||||
) -> CrudResponseModel:
|
||||
try:
|
||||
await TestBatchAccessService.lock_active_batch(query_db, test_scope)
|
||||
warehouse_ids = await cls._warehouse_scope(query_db, current_user)
|
||||
current = await OperationDao.get_inbound_by_id(
|
||||
query_db,
|
||||
@@ -694,7 +695,7 @@ class InboundService:
|
||||
request_hash=request_hash,
|
||||
test_batch_id=test_scope.batch_id,
|
||||
)
|
||||
await InventoryDao.add_event(query_db, inventory, event)
|
||||
await InventoryDao.add_event(query_db, inventory, event, test_scope)
|
||||
|
||||
await query_db.commit()
|
||||
return cls._success('确认成功')
|
||||
|
||||
@@ -585,7 +585,6 @@ class ReturnService:
|
||||
) -> None:
|
||||
site = await MasterDao.get_site(query_db, return_order.source_site_id, test_scope, for_update=True)
|
||||
try:
|
||||
await TestBatchAccessService.lock_active_batch(query_db, test_scope)
|
||||
await AccessService.assert_site_access(
|
||||
query_db,
|
||||
current_user,
|
||||
@@ -607,6 +606,7 @@ class ReturnService:
|
||||
test_scope: TestBatchScope,
|
||||
) -> CrudResponseModel:
|
||||
try:
|
||||
await TestBatchAccessService.lock_active_batch(query_db, test_scope)
|
||||
site_ids = await cls._site_scope(query_db, current_user)
|
||||
request_warehouse_ids = None if site_ids is None else []
|
||||
recovered = None
|
||||
@@ -678,6 +678,7 @@ class ReturnService:
|
||||
preflight_existing_id = int(existing.return_id) if existing is not None else None
|
||||
|
||||
await query_db.rollback()
|
||||
await TestBatchAccessService.lock_active_batch(query_db, test_scope)
|
||||
if preflight_existing_id is not None:
|
||||
locked_existing = await OperationDao.get_return_for_update(
|
||||
query_db,
|
||||
@@ -802,7 +803,7 @@ class ReturnService:
|
||||
request_hash=request_hash,
|
||||
test_batch_id=test_scope.batch_id,
|
||||
)
|
||||
await InventoryDao.add_event(query_db, inventory, event)
|
||||
await InventoryDao.add_event(query_db, inventory, event, test_scope)
|
||||
|
||||
await query_db.commit()
|
||||
return cls._success('申请成功', return_id)
|
||||
@@ -813,6 +814,7 @@ class ReturnService:
|
||||
page_object,
|
||||
cls._build_request_hash(page_object),
|
||||
current_user,
|
||||
test_scope,
|
||||
)
|
||||
except Exception:
|
||||
await query_db.rollback()
|
||||
@@ -941,6 +943,7 @@ class ReturnService:
|
||||
test_scope: TestBatchScope,
|
||||
) -> CrudResponseModel:
|
||||
try:
|
||||
await TestBatchAccessService.lock_active_batch(query_db, test_scope)
|
||||
warehouse_ids = await cls._warehouse_scope(query_db, current_user)
|
||||
confirm_site_ids = None if warehouse_ids is None else []
|
||||
route = await OperationDao.get_return_by_id(
|
||||
@@ -1040,6 +1043,7 @@ class ReturnService:
|
||||
raise ServiceException(message='确认退回失败,幂等键已被其他请求使用')
|
||||
|
||||
await query_db.rollback()
|
||||
await TestBatchAccessService.lock_active_batch(query_db, test_scope)
|
||||
locked = await OperationDao.get_return_for_update(
|
||||
query_db,
|
||||
return_id,
|
||||
@@ -1146,7 +1150,7 @@ class ReturnService:
|
||||
request_hash=request_hash,
|
||||
test_batch_id=test_scope.batch_id,
|
||||
)
|
||||
await InventoryDao.add_event(query_db, inventory, event)
|
||||
await InventoryDao.add_event(query_db, inventory, event, test_scope)
|
||||
|
||||
await query_db.commit()
|
||||
return cls._success('确认成功', return_id)
|
||||
|
||||
@@ -738,6 +738,7 @@ class ShipmentService:
|
||||
test_scope: TestBatchScope,
|
||||
) -> CrudResponseModel:
|
||||
try:
|
||||
await TestBatchAccessService.lock_active_batch(query_db, test_scope)
|
||||
warehouse_ids, site_ids = await cls._scopes(query_db, current_user)
|
||||
current = await OperationDao.get_shipment_by_id(
|
||||
query_db,
|
||||
@@ -932,7 +933,7 @@ class ShipmentService:
|
||||
request_hash=request_hash,
|
||||
test_batch_id=test_scope.batch_id,
|
||||
)
|
||||
await InventoryDao.add_event(query_db, inventory, event)
|
||||
await InventoryDao.add_event(query_db, inventory, event, test_scope)
|
||||
|
||||
await query_db.commit()
|
||||
return cls._success('确认成功')
|
||||
|
||||
@@ -177,6 +177,7 @@ class UsageService:
|
||||
test_scope: TestBatchScope,
|
||||
) -> CrudResponseModel:
|
||||
try:
|
||||
await TestBatchAccessService.lock_active_batch(query_db, test_scope)
|
||||
site_ids = await cls._site_scope(query_db, current_user)
|
||||
if site_ids is not None and expected_site_id not in site_ids:
|
||||
cls._raise_pallet_not_accessible(current_user)
|
||||
@@ -403,6 +404,7 @@ class UsageService:
|
||||
cls._raise_pallet_not_accessible(current_user)
|
||||
scanned_pallet_id = int(scanned_pallet.pallet_id)
|
||||
await query_db.rollback()
|
||||
await TestBatchAccessService.lock_active_batch(query_db, test_scope)
|
||||
|
||||
inventory = await InventoryDao.get_inventory_for_update(
|
||||
query_db,
|
||||
@@ -579,7 +581,7 @@ class UsageService:
|
||||
request_hash=request_hash,
|
||||
test_batch_id=test_scope.batch_id,
|
||||
)
|
||||
await InventoryDao.add_event(query_db, inventory, event)
|
||||
await InventoryDao.add_event(query_db, inventory, event, test_scope)
|
||||
await query_db.commit()
|
||||
return result
|
||||
except IntegrityError:
|
||||
|
||||
Reference in New Issue
Block a user