From 77e4d672d703565f01ff76e867862e49dfc4a1fd Mon Sep 17 00:00:00 2001 From: xueyinfei <1207092115@qq.com> Date: Thu, 18 Sep 2025 11:20:49 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=8F=91=E5=8C=85=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0,=E7=A9=BA=E5=80=BC=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/meta_controller.py | 6 +- .../module_admin/dao/meta_dao.py | 35 +++++---- .../module_admin/entity/vo/meta_vo.py | 8 ++ .../module_admin/service/approval_service.py | 3 +- .../module_admin/service/meta_service.py | 77 ++++++++++++------- .../src/views/system/flow/index.vue | 57 ++++++++++---- 6 files changed, 126 insertions(+), 60 deletions(-) diff --git a/vue-fastapi-backend/module_admin/controller/meta_controller.py b/vue-fastapi-backend/module_admin/controller/meta_controller.py index c5d5c21..30c8235 100644 --- a/vue-fastapi-backend/module_admin/controller/meta_controller.py +++ b/vue-fastapi-backend/module_admin/controller/meta_controller.py @@ -8,7 +8,7 @@ from utils.common_util import bytes2file_response from module_admin.service.meta_service import MetaService from module_admin.entity.vo.meta_vo import MetaPageObject, MetaColObject, SuppleModel, MetaBusinessRelShipObject, \ - MetaProcQueryObject + MetaProcQueryObject, MetaBusinessDetail metaController = APIRouter(prefix='/dasset', dependencies=[Depends(LoginService.get_current_user)]) @@ -45,9 +45,9 @@ async def meta_supp(request: Request, @metaController.get("/meta/getMetaInfoApplyBusinessDetail") async def getMetaInfoApplyBusinessDetail(request: Request, - businessId: str, + metaBusinessDetail: MetaBusinessDetail = Depends(MetaBusinessDetail.as_query), query_db: AsyncSession = Depends(get_db)): - result = await MetaService.get_meta_apply_detail_services(query_db, businessId) + result = await MetaService.get_meta_apply_detail_services(query_db, metaBusinessDetail) return ResponseUtil.success(data=result) diff --git a/vue-fastapi-backend/module_admin/dao/meta_dao.py b/vue-fastapi-backend/module_admin/dao/meta_dao.py index 147bead..3a26e34 100644 --- a/vue-fastapi-backend/module_admin/dao/meta_dao.py +++ b/vue-fastapi-backend/module_admin/dao/meta_dao.py @@ -1,6 +1,6 @@ from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy import select, text, cast, Integer, and_, or_, outerjoin, func, join, update, desc -from module_admin.entity.vo.meta_vo import MetaPageObject, MetaColObject +from module_admin.entity.vo.meta_vo import MetaPageObject, MetaColObject, MetaBusinessDetail from module_admin.entity.do.datastd_do import DataStdDict from module_admin.entity.do.meta_do import MetadataExtractInfo, MetadataSuppInfo, MetadataFldTabExtractInfo, \ MetadataFldSuppInfo, MetadataClas, MetadataSuppInfoVett, MetadataFldSuppInfoVett, MetaBatchTabClas, \ @@ -291,15 +291,22 @@ class MetaDao: return query_result @classmethod - async def get_supp_table_vett_by_businessId(cls, businessId: str, db: AsyncSession): - query_result = ( - ( - await db.execute( - select(MetadataSuppInfoVett).where(MetadataSuppInfoVett.business_id == businessId).distinct() - ) - ).scalars().all() + async def get_supp_table_vett_by_businessId(cls, metaBusinessDetail: MetaBusinessDetail, db: AsyncSession): + query = ( + select(MetadataSuppInfoVett).where( + MetadataSuppInfoVett.business_id == metaBusinessDetail.business_id).distinct() ) - return query_result + result = await PageUtil.paginate(db, query, metaBusinessDetail.page_num, metaBusinessDetail.page_size, True) + return result + + @classmethod + async def get_supp_table_vett_by_businessId_no_page(cls, businuessId: str, db: AsyncSession): + query = ( + select(MetadataSuppInfoVett).where( + MetadataSuppInfoVett.business_id == businuessId).distinct() + ) + result = await PageUtil.paginate(db, query, 0, 0, False) + return result @classmethod async def get_supp_column_vett_by_tableInfo(cls, db: AsyncSession, tableInfo): @@ -430,9 +437,10 @@ class MetaDao: @classmethod async def get_meta_col_supp_vett(cls, table: MetadataSuppInfoVett, db: AsyncSession): - sql_query = text("select max(apply_time) from t_metadata_fld_supp_info_vett where ssys_id =" + str(table.ssys_id) + - " and mdl_name = '" + table.mdl_name + "' and tab_eng_name = '" + table.tab_eng_name + - "'") + sql_query = text( + "select max(apply_time) from t_metadata_fld_supp_info_vett where ssys_id =" + str(table.ssys_id) + + " and mdl_name = '" + table.mdl_name + "' and tab_eng_name = '" + table.tab_eng_name + + "'") maxTime = (await db.execute(sql_query)).scalar() query_result = ( @@ -464,7 +472,8 @@ class MetaDao: return query_result @classmethod - async def get_supp_column_by_columnInfo(cls, ssys_id: int, mdlName: str, tabEngName: str, fldEngName: str, db: AsyncSession): + async def get_supp_column_by_columnInfo(cls, ssys_id: int, mdlName: str, tabEngName: str, fldEngName: str, + db: AsyncSession): query_result = ( ( await db.execute( diff --git a/vue-fastapi-backend/module_admin/entity/vo/meta_vo.py b/vue-fastapi-backend/module_admin/entity/vo/meta_vo.py index e600787..b428331 100644 --- a/vue-fastapi-backend/module_admin/entity/vo/meta_vo.py +++ b/vue-fastapi-backend/module_admin/entity/vo/meta_vo.py @@ -73,3 +73,11 @@ class MetaProcQueryObject(BaseModel): ssys_id: Optional[int] mdl_name: Optional[str] tab_eng_name: Optional[str] + + +@as_query +class MetaBusinessDetail(BaseModel): + model_config = ConfigDict(alias_generator=to_camel, from_attributes=True) + business_id: Optional[str] + page_num: Optional[int] + page_size: Optional[int] diff --git a/vue-fastapi-backend/module_admin/service/approval_service.py b/vue-fastapi-backend/module_admin/service/approval_service.py index 2286a5f..34a07b3 100644 --- a/vue-fastapi-backend/module_admin/service/approval_service.py +++ b/vue-fastapi-backend/module_admin/service/approval_service.py @@ -4,6 +4,7 @@ import uuid from typing import Optional from sqlalchemy.ext.asyncio import AsyncSession from module_admin.entity.vo.common_vo import CrudResponseModel +from module_admin.entity.vo.meta_vo import MetaBusinessDetail from module_admin.entity.vo.approval_vo import ApplyModel, OperateModel, ApprovalQueryObject, EditObjectModel, \ SaveConfModel from module_admin.entity.vo.user_vo import CurrentUserModel @@ -113,7 +114,7 @@ class ApprovalService: @classmethod async def syncSuppInfo(cls, result_db: AsyncSession, businessId: str, operateType: str): - tableList = await MetaDao.get_supp_table_vett_by_businessId(businessId, result_db) + tableList = await MetaDao.get_supp_table_vett_by_businessId_no_page(businessId, result_db) if tableList is None or len(tableList) == 0: raise ServiceException(message='所查询的业务数据不存在') if tableList[0].apply_status == 'succeed' or tableList[0].apply_status == 'rejected': diff --git a/vue-fastapi-backend/module_admin/service/meta_service.py b/vue-fastapi-backend/module_admin/service/meta_service.py index 4082173..0be3fe3 100644 --- a/vue-fastapi-backend/module_admin/service/meta_service.py +++ b/vue-fastapi-backend/module_admin/service/meta_service.py @@ -5,7 +5,7 @@ import uuid import pandas as pd from fastapi import UploadFile from module_admin.entity.vo.meta_vo import MetaPageObject, MetaColObject, SuppleModel, MetaBusinessRelShipObject, \ - MetaProcQueryObject + MetaProcQueryObject, MetaBusinessDetail from module_admin.entity.do.meta_do import MetadataSuppInfo, MetadataFldSuppInfo, MetadataSuppInfoVett, \ MetadataFldSuppInfoVett, MetadataExtractInfo, MetadataFldTabExtractInfo from module_admin.dao.meta_dao import MetaDao @@ -199,12 +199,12 @@ class MetaService: return json.dumps(columnDict) @classmethod - async def get_meta_apply_detail_services(cls, result_db: AsyncSession, businessId: str): - tableDataList = await MetaDao.get_supp_table_vett_by_businessId(businessId, result_db) - tableList = CamelCaseUtil.transform_result(tableDataList) + async def get_meta_apply_detail_services(cls, result_db: AsyncSession, metaBusinessDetail: MetaBusinessDetail): + tableResult = await MetaDao.get_supp_table_vett_by_businessId(metaBusinessDetail, result_db) + tableList = CamelCaseUtil.transform_result(tableResult.rows) for tableData in tableList: clas_list = await MetaDao.get_meta_tab_clas(result_db, tableData['ssysId'], tableData['mdlName'], - tableData['tabEngName']) + tableData['tabEngName']) tableData['batchTabClas'] = CamelCaseUtil.transform_result(clas_list) columnData = await MetaDao.get_supp_column_vett_by_tableInfo(result_db, tableData) column_list = CamelCaseUtil.transform_result(columnData) @@ -213,7 +213,14 @@ class MetaService: column['tabEngName'], column['fldEngName']) column['batchColClas'] = CamelCaseUtil.transform_result(col_list) tableData['columnList'] = column_list - return tableList + result = dict( + rows=tableList, + pageNum=tableResult.page_num, + pageSize=tableResult.page_size, + total=tableResult.total, + hasNext=tableResult.has_next, + ) + return result @classmethod async def get_table_by_id(cls, result_db: AsyncSession, tableId: int): @@ -597,35 +604,36 @@ class MetaService: # 校验, 1、各必填内容不能为空, 2.系统代码映射的系统是否存在 3.表是否存在 4.字段是否存在5.引用的字典标准是否存在6.标准的系统与表系统是否对应 if tableSheet == '表信息': # 表信息补录 - df = excel_file.parse(sheet_name=tableSheet) + df = excel_file.parse(sheet_name=tableSheet, dtype=str, keep_default_na=False, na_values=[]) df.rename(columns=table_header_dict, inplace=True) for index, row in df.iterrows(): noneValid = '' if row['ssys_cd'] is None or len(row['ssys_cd']) == 0: - noneValid += "sheet[表信息]中行:" + str(index+1) + "中的系统代码不能为空" + noneValid += "sheet[表信息]中行:" + str(index + 2) + "中的系统代码不能为空" if row['mdl_name'] is None or len(row['mdl_name']) == 0: if len(noneValid) > 0: noneValid += ",模式名称不能为空" else: - noneValid += "sheet[表信息]中行:" + str(index+1) + "中的模式名称不能为空" + noneValid += "sheet[表信息]中行:" + str(index + 2) + "中的模式名称不能为空" if row['tab_eng_name'] is None or len(row['tab_eng_name']) == 0: if len(noneValid) > 0: noneValid += ",表英文名称不能为空" else: - noneValid += "sheet[表信息]中行:" + str(index+1) + "中的表英文名不能为空" + noneValid += "sheet[表信息]中行:" + str(index + 2) + "中的表英文名不能为空" if len(noneValid) > 0: import_err_msg.append(noneValid) continue ssysId = next((item["id"] for item in dataSourceList if item["name"] == row['ssys_cd']), None) if ssysId is None: - import_err_msg.append("行:" + str(index+1) + "中的系统不存在,需重新修正") + import_err_msg.append("行:" + str(index + 2) + "中的系统不存在,需重新修正") continue hasTable = await MetaDao.get_lastest_meta_data_supp_vett(result_db, ssysId, row['mdl_name'], row['tab_eng_name']) if hasTable: if hasTable.apply_status == 'waiting': import_err_msg.append( - 'sheet[表信息]中行:' + str(index+1) + ' 导入的系统代码:' + row['ssys_cd'] + ',模式名称:' + row['mdl_name'] + + 'sheet[表信息]中行:' + str(index + 2) + ' 导入的系统代码:' + row['ssys_cd'] + ',模式名称:' + + row['mdl_name'] + ',对象英文名:' + row['tab_eng_name'] + '已存在补录待审核记录,请等待审批完成或撤回申请后,再行导入') skip_table.append({'ssys_id': ssysId, 'mdl_name': row['mdl_name'], @@ -633,7 +641,8 @@ class MetaService: continue if hasTable.apply_status == 'pending': import_err_msg.append( - 'sheet[字段信息]中行:' + str(index+1) + ' 导入的系统代码:' + row['ssys_cd'] + ',模式名称:' + row['mdl_name'] + + 'sheet[字段信息]中行:' + str(index + 2) + ' 导入的系统代码:' + row[ + 'ssys_cd'] + ',模式名称:' + row['mdl_name'] + ',对象英文名:' + row['tab_eng_name'] + '已存在待审核记录,请等待审批完成或撤回申请后,再行导入') skip_table.append({'ssys_id': ssysId, 'mdl_name': row['mdl_name'], @@ -645,7 +654,7 @@ class MetaService: tableInfo = await MetaDao.get_meta_table(ssysId, row['mdl_name'], row['tab_eng_name'], result_db) if tableInfo is None: - import_err_msg.append("sheet[表信息]中行:"+str(index+1) + "中所对应的表不存在,无法上传补录") + import_err_msg.append("sheet[表信息]中行:" + str(index + 2) + "中所对应的表不存在,无法上传补录") continue tableOnum = uuid.uuid4() suppTableInfo = MetadataSuppInfoVett() @@ -659,11 +668,14 @@ class MetaService: suppTableInfo.rec_subm_prsn = row['rec_subm_prsn'] else: suppTableInfo.tab_crrct_name = row['tab_crrct_name'] if row['tab_crrct_name'] and \ - str(row['tab_crrct_name']).strip() != '' else oldTable.tab_crrct_name if oldTable else None + str(row[ + 'tab_crrct_name']).strip() != '' else oldTable.tab_crrct_name if oldTable else None suppTableInfo.tab_desc = row['tab_desc'] if row['tab_desc'] and \ - str(row['tab_desc']).strip() != '' else oldTable.tab_desc if oldTable else None + str(row[ + 'tab_desc']).strip() != '' else oldTable.tab_desc if oldTable else None suppTableInfo.rec_subm_prsn = row['rec_subm_prsn'] if row['rec_subm_prsn'] and \ - str(row['rec_subm_prsn']).strip() != '' else oldTable.rec_subm_prsn if oldTable else None + str(row[ + 'rec_subm_prsn']).strip() != '' else oldTable.rec_subm_prsn if oldTable else None suppTableInfo.pic = oldTable.pic if oldTable else None suppTableInfo.gov_flag = oldTable.gov_flag if oldTable else None suppTableInfo.tab_clas = oldTable.tab_clas if oldTable else None @@ -675,22 +687,22 @@ class MetaService: successCount += 1 if columnSheet == '字段信息': # 字段信息补录 - df = excel_file.parse(sheet_name=columnSheet) + df = excel_file.parse(sheet_name=columnSheet, dtype=str, keep_default_na=False, na_values=[]) df.rename(columns=column_header_dict, inplace=True) for index, row in df.iterrows(): noneValid = '' if row['ssys_cd'] is None or len(row['ssys_cd']) == 0: - noneValid += "sheet[字段信息]中行:" + str(index+1) + "中的系统代码不能为空" + noneValid += "sheet[字段信息]中行:" + str(index + 2) + "中的系统代码不能为空" if row['mdl_name'] is None or len(row['mdl_name']) == 0: if len(noneValid) > 0: noneValid += ",模式名称不能为空" else: - noneValid += "sheet[字段信息]中行:" + str(index+1) + "中的模式名称不能为空" + noneValid += "sheet[字段信息]中行:" + str(index + 2) + "中的模式名称不能为空" if row['tab_eng_name'] is None or len(row['tab_eng_name']) == 0: if len(noneValid) > 0: noneValid += ",表英文名称不能为空" else: - noneValid += "sheet[字段信息]中行:" + str(index+1) + "中的表英文名不能为空" + noneValid += "sheet[字段信息]中行:" + str(index + 2) + "中的表英文名不能为空" if len(noneValid) > 0: import_err_msg.append(noneValid) continue @@ -713,17 +725,19 @@ class MetaService: row['tab_eng_name'], row['fld_eng_name'], result_db) if columnInfo is None: - import_err_msg.append("sheet[字段信息]中行:"+str(index+1) + "中所对应的字段不存在,无法上传补录") + import_err_msg.append("sheet[字段信息]中行:" + str(index + 2) + "中所对应的字段不存在,无法上传补录") continue dataDictId = '' if row['data_dict_id'] and len(row['data_dict_id']) > 0: dataDict = await DataStdDao.get_data_dict_by_code(result_db, row['data_dict_id']) if dataDict is None: - import_err_msg.append("sheet[字段信息]中行:"+str(index+1) + "中所对应的数据字典不存在,无法上传补录") + import_err_msg.append( + "sheet[字段信息]中行:" + str(index + 2) + "中所对应的数据字典不存在,无法上传补录") continue else: if int(dataDict.src_sys) != ssysId: - import_err_msg.append("sheet[字段信息]中行:"+str(index+1) + "中所对应的数据字典所属系统与表所属系统不一致,无法上传补录") + import_err_msg.append("sheet[字段信息]中行:" + str( + index + 2) + "中所对应的数据字典所属系统与表所属系统不一致,无法上传补录") continue else: dataDictId = dataDict.onum @@ -735,22 +749,27 @@ class MetaService: suppColumnInfo.fld_eng_name = row['fld_eng_name'] if overWrite: suppColumnInfo.fld_crrct_name = row['fld_crrct_name'] - suppColumnInfo.crrct_pk_flag = True if row['crrct_pk_flag'] and row['crrct_pk_flag'] == '是' else False + suppColumnInfo.crrct_pk_flag = True if row['crrct_pk_flag'] and row[ + 'crrct_pk_flag'] == '是' else False suppColumnInfo.fld_desc = row['fld_desc'] suppColumnInfo.data_sec_lvl = row['data_sec_lvl'] suppColumnInfo.rec_subm_prsn = row['rec_subm_prsn'] suppColumnInfo.data_dict_id = dataDictId if dataDictId != '' else None else: suppColumnInfo.fld_crrct_name = row['fld_crrct_name'] if row['fld_crrct_name'] and \ - str(row['fld_crrct_name']).strip() != '' else oldColumn.fld_crrct_name if oldColumn else None + str(row[ + 'fld_crrct_name']).strip() != '' else oldColumn.fld_crrct_name if oldColumn else None suppColumnInfo.crrct_pk_flag = oldColumn.crrct_pk_flag if row['crrct_pk_flag'] is None \ else True if row['crrct_pk_flag'] and row['crrct_pk_flag'] == '是' else False suppColumnInfo.fld_desc = row['fld_desc'] if row['fld_desc'] and \ - str(row['fld_desc']).strip() != '' else oldColumn.fld_desc if oldColumn else None + str(row[ + 'fld_desc']).strip() != '' else oldColumn.fld_desc if oldColumn else None suppColumnInfo.data_sec_lvl = row['data_sec_lvl'] if row['data_sec_lvl'] and \ - str(row['data_sec_lvl'].strip()) != '' else oldColumn.data_sec_lvl if oldColumn else None + str(row[ + 'data_sec_lvl'].strip()) != '' else oldColumn.data_sec_lvl if oldColumn else None suppColumnInfo.rec_subm_prsn = row['rec_subm_prsn'] if row['rec_subm_prsn'] and \ - str(row['rec_subm_prsn']).strip() != '' else oldColumn.rec_subm_prsn if oldColumn else None + str(row[ + 'rec_subm_prsn']).strip() != '' else oldColumn.rec_subm_prsn if oldColumn else None suppColumnInfo.data_dict_id = dataDictId if dataDictId != '' else oldColumn.data_dict_id \ if oldColumn else None suppColumnInfo.pic = oldColumn.pic if oldColumn else None diff --git a/vue-fastapi-frontend/src/views/system/flow/index.vue b/vue-fastapi-frontend/src/views/system/flow/index.vue index 9ed1541..c63f631 100644 --- a/vue-fastapi-frontend/src/views/system/flow/index.vue +++ b/vue-fastapi-frontend/src/views/system/flow/index.vue @@ -539,9 +539,9 @@ - + @@ -573,12 +573,12 @@ - + - - + + - +