原始数据分表处理
This commit is contained in:
@@ -121,10 +121,24 @@ def batch_import_level_data(request: BatchLevelDataImportRequest, db: Session =
|
||||
|
||||
@router.post("/batch_import_original_data", response_model=DataImportResponse)
|
||||
def batch_import_original_data(request: BatchOriginalDataImportRequest, db: Session = Depends(get_db)):
|
||||
"""批量导入原始数据"""
|
||||
"""批量导入原始数据 - 数据中必须包含account_id字段"""
|
||||
try:
|
||||
logger.info(f"Starting batch import original data, count: {len(request.data)}")
|
||||
|
||||
# 验证数据中是否包含account_id
|
||||
if not request.data or len(request.data) == 0:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="导入数据不能为空"
|
||||
)
|
||||
|
||||
# 检查第一条数据是否包含account_id
|
||||
if 'account_id' not in request.data[0]:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="数据中必须包含account_id字段"
|
||||
)
|
||||
|
||||
# 直接使用字典列表,不需要转换
|
||||
data_list = request.data
|
||||
|
||||
@@ -133,6 +147,8 @@ def batch_import_original_data(request: BatchOriginalDataImportRequest, db: Sess
|
||||
logger.info(f"Batch import original data completed: {result['message']}")
|
||||
return DataImportResponse(**result)
|
||||
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception as e:
|
||||
logger.error(f"Batch import original data failed: {str(e)}")
|
||||
raise HTTPException(
|
||||
@@ -246,13 +262,21 @@ def get_settlement_checkpoint(request: SettlementDataCheckpointQueryRequest, db:
|
||||
# 根据期数id获取原始数据
|
||||
@router.post("/get_original", response_model=DataResponse)
|
||||
def get_original(request: OriginalDataQueryRequest, db: Session = Depends(get_db)):
|
||||
"""获取水准数据+原始数据"""
|
||||
"""获取水准数据+原始数据 - 必须提供account_id"""
|
||||
try:
|
||||
logger.info(f"Querying original data with params: {request.dict()}")
|
||||
|
||||
# 验证account_id
|
||||
if not request.account_id:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="必须提供account_id参数"
|
||||
)
|
||||
|
||||
# 调用综合服务的业务方法
|
||||
result = comprehensive_service.get_level_and_original_data(
|
||||
db,
|
||||
account_id=request.account_id,
|
||||
id=request.id,
|
||||
bfpcode=request.bfpcode,
|
||||
bffb=request.bffb,
|
||||
@@ -268,6 +292,8 @@ def get_original(request: OriginalDataQueryRequest, db: Session = Depends(get_db
|
||||
data=result["data"]
|
||||
)
|
||||
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception as e:
|
||||
logger.error(f"Query original data failed: {str(e)}")
|
||||
raise HTTPException(
|
||||
|
||||
Reference in New Issue
Block a user