|  |  | @ -1,6 +1,9 @@ | 
			
		
	
		
			
				
					|  |  |  | import io | 
			
		
	
		
			
				
					|  |  |  | import json | 
			
		
	
		
			
				
					|  |  |  | import uuid | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import pandas as pd | 
			
		
	
		
			
				
					|  |  |  | from fastapi import UploadFile | 
			
		
	
		
			
				
					|  |  |  | from module_admin.entity.vo.meta_vo import MetaPageObject, MetaColObject, SuppleModel, MetaBusinessRelShipObject, \ | 
			
		
	
		
			
				
					|  |  |  |     MetaProcQueryObject | 
			
		
	
		
			
				
					|  |  |  | from module_admin.entity.do.meta_do import MetadataSuppInfo, MetadataFldSuppInfo, MetadataSuppInfoVett, \ | 
			
		
	
	
		
			
				
					|  |  | @ -21,6 +24,8 @@ from module_admin.service.approval_service import ApprovalService | 
			
		
	
		
			
				
					|  |  |  | from module_admin.entity.vo.common_vo import CrudResponseModel | 
			
		
	
		
			
				
					|  |  |  | from module_admin.entity.vo.user_vo import CurrentUserModel | 
			
		
	
		
			
				
					|  |  |  | from utils.common_util import CamelCaseUtil | 
			
		
	
		
			
				
					|  |  |  | from config.env import AppConfig | 
			
		
	
		
			
				
					|  |  |  | import requests | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | class MetaService: | 
			
		
	
	
		
			
				
					|  |  | @ -81,6 +86,7 @@ class MetaService: | 
			
		
	
		
			
				
					|  |  |  |         oldTable = await MetaDao.get_supp_table_by_vett(supple.ssys_id, supple.mdl_name, supple.tab_eng_name, result_db) | 
			
		
	
		
			
				
					|  |  |  |         tableInfo = await MetaDao.get_meta_table(supple.ssys_id, supple.mdl_name, supple.tab_eng_name, result_db) | 
			
		
	
		
			
				
					|  |  |  |         tableOnum = uuid.uuid4() | 
			
		
	
		
			
				
					|  |  |  |         businessId = uuid.uuid4() | 
			
		
	
		
			
				
					|  |  |  |         if hasTable is not None: | 
			
		
	
		
			
				
					|  |  |  |             if hasTable.apply_status == 'waiting': | 
			
		
	
		
			
				
					|  |  |  |                 raise ServiceException(message=f'所补录对象已存在补录待审核记录,请等待审批完成或撤回申请后,再行补录') | 
			
		
	
	
		
			
				
					|  |  | @ -99,6 +105,7 @@ class MetaService: | 
			
		
	
		
			
				
					|  |  |  |         suppTableInfo.tab_clas = supple.tab_clas | 
			
		
	
		
			
				
					|  |  |  |         suppTableInfo.rec_subm_prsn = current_user.user.user_name | 
			
		
	
		
			
				
					|  |  |  |         suppTableInfo.apply_time = applyTime | 
			
		
	
		
			
				
					|  |  |  |         suppTableInfo.business_id = businessId | 
			
		
	
		
			
				
					|  |  |  |         suppTableInfo.apply_status = 'waiting' | 
			
		
	
		
			
				
					|  |  |  |         suppTableInfo.oldTableData = cls.castToTableStr(oldTable, tableInfo) | 
			
		
	
		
			
				
					|  |  |  |         await MetaDao.insertMetadataSuppInfoVett(suppTableInfo, result_db) | 
			
		
	
	
		
			
				
					|  |  | @ -135,7 +142,7 @@ class MetaService: | 
			
		
	
		
			
				
					|  |  |  |                 await MetaDao.insertMetadataFldSuppInfoVett(suppColumnInfo, result_db) | 
			
		
	
		
			
				
					|  |  |  |         applyModel = ApplyModel() | 
			
		
	
		
			
				
					|  |  |  |         applyModel.businessType = "metaDataInfo" | 
			
		
	
		
			
				
					|  |  |  |         applyModel.businessId = tableOnum | 
			
		
	
		
			
				
					|  |  |  |         applyModel.businessId = businessId | 
			
		
	
		
			
				
					|  |  |  |         applyModel.applicant = current_user.user.user_name | 
			
		
	
		
			
				
					|  |  |  |         await ApprovalService.apply_services(result_db, applyModel, 'metaDataInfo') | 
			
		
	
		
			
				
					|  |  |  |         await result_db.commit() | 
			
		
	
	
		
			
				
					|  |  | @ -193,22 +200,20 @@ class MetaService: | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @classmethod | 
			
		
	
		
			
				
					|  |  |  |     async def get_meta_apply_detail_services(cls, result_db: AsyncSession, businessId: str): | 
			
		
	
		
			
				
					|  |  |  |         tableData = await MetaDao.get_supp_table_vett_by_id(businessId, result_db) | 
			
		
	
		
			
				
					|  |  |  |         table = CamelCaseUtil.transform_result(tableData) | 
			
		
	
		
			
				
					|  |  |  |         clas_list = await MetaDao.get_meta_tab_clas(result_db, tableData.ssys_id, tableData.mdl_name, | 
			
		
	
		
			
				
					|  |  |  |                                                     tableData.tab_eng_name) | 
			
		
	
		
			
				
					|  |  |  |         table['batchTabClas'] = CamelCaseUtil.transform_result(clas_list) | 
			
		
	
		
			
				
					|  |  |  |         tableDataList = await MetaDao.get_supp_table_vett_by_businessId(businessId, result_db) | 
			
		
	
		
			
				
					|  |  |  |         tableList = CamelCaseUtil.transform_result(tableDataList) | 
			
		
	
		
			
				
					|  |  |  |         for tableData in tableList: | 
			
		
	
		
			
				
					|  |  |  |             clas_list = await MetaDao.get_meta_tab_clas(result_db, tableData['ssysId'], tableData['mdlName'], | 
			
		
	
		
			
				
					|  |  |  |                                                     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) | 
			
		
	
		
			
				
					|  |  |  |             for column in column_list: | 
			
		
	
		
			
				
					|  |  |  |                 col_list = await MetaDao.get_meta_fld_clas(result_db, column['ssysId'], column['mdlName'], | 
			
		
	
		
			
				
					|  |  |  |                                                            column['tabEngName'], column['fldEngName']) | 
			
		
	
		
			
				
					|  |  |  |                 column['batchColClas'] = CamelCaseUtil.transform_result(col_list) | 
			
		
	
		
			
				
					|  |  |  |         result = dict( | 
			
		
	
		
			
				
					|  |  |  |             table=table, | 
			
		
	
		
			
				
					|  |  |  |             column=column_list | 
			
		
	
		
			
				
					|  |  |  |         ) | 
			
		
	
		
			
				
					|  |  |  |         return result | 
			
		
	
		
			
				
					|  |  |  |             tableData['columnList'] = column_list | 
			
		
	
		
			
				
					|  |  |  |         return tableList | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @classmethod | 
			
		
	
		
			
				
					|  |  |  |     async def get_table_by_id(cls, result_db: AsyncSession, tableId: int): | 
			
		
	
	
		
			
				
					|  |  | @ -513,3 +518,234 @@ class MetaService: | 
			
		
	
		
			
				
					|  |  |  |             "tableList": tableList | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         return result | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @staticmethod | 
			
		
	
		
			
				
					|  |  |  |     async def get_meta_import_template_services(): | 
			
		
	
		
			
				
					|  |  |  |         """ | 
			
		
	
		
			
				
					|  |  |  |         获取元数据导入模板service | 
			
		
	
		
			
				
					|  |  |  |         :return: 元数据导入模板excel的二进制数据 | 
			
		
	
		
			
				
					|  |  |  |         """ | 
			
		
	
		
			
				
					|  |  |  |         table_header_list = ['系统代码', '模式名称', '对象英文名', '补录对象名称', '补录对象描述', '负责人'] | 
			
		
	
		
			
				
					|  |  |  |         column_header_list = ['系统代码', '模式名称', '对象英文名', '字段英文名', '字段补录名', '补录主键', | 
			
		
	
		
			
				
					|  |  |  |                               '补录字段描述', '引用字典/标准', '安全等级', '负责人'] | 
			
		
	
		
			
				
					|  |  |  |         selector_header_list = ['补录主键', '安全等级'] | 
			
		
	
		
			
				
					|  |  |  |         option_list = [{}, {'补录主键': ['是', '否'], '安全等级': ['S1', 'S2', 'S3', 'S4']}] | 
			
		
	
		
			
				
					|  |  |  |         sheet_config1 = dict( | 
			
		
	
		
			
				
					|  |  |  |             sheet_name="表信息", header_list=table_header_list, selector_header_list=[] | 
			
		
	
		
			
				
					|  |  |  |         ) | 
			
		
	
		
			
				
					|  |  |  |         sheet_config2 = dict( | 
			
		
	
		
			
				
					|  |  |  |             sheet_name="字段信息", header_list=column_header_list, selector_header_list=selector_header_list | 
			
		
	
		
			
				
					|  |  |  |         ) | 
			
		
	
		
			
				
					|  |  |  |         sheet_configs = [sheet_config1, sheet_config2] | 
			
		
	
		
			
				
					|  |  |  |         binary_data = get_excel_template_with_sheets( | 
			
		
	
		
			
				
					|  |  |  |             sheet_configs,  # 每个Sheet的配置(包含表头、选择器等) | 
			
		
	
		
			
				
					|  |  |  |             option_list | 
			
		
	
		
			
				
					|  |  |  |         ) | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         return binary_data | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @classmethod | 
			
		
	
		
			
				
					|  |  |  |     async def batch_import_meta_services(cls, | 
			
		
	
		
			
				
					|  |  |  |                                          result_db: AsyncSession, | 
			
		
	
		
			
				
					|  |  |  |                                          file: UploadFile, | 
			
		
	
		
			
				
					|  |  |  |                                          current_user: CurrentUserModel): | 
			
		
	
		
			
				
					|  |  |  |         import_err_msg = [] | 
			
		
	
		
			
				
					|  |  |  |         # 调用DS接口通过系统代码查询系统ID | 
			
		
	
		
			
				
					|  |  |  |         url = f'{AppConfig.ds_server_url}/dolphinscheduler/datasources?pageNo=1&pageSize=100' | 
			
		
	
		
			
				
					|  |  |  |         headers = {'dashUserName': current_user.user.user_name, 'dashPassword': current_user.user.password} | 
			
		
	
		
			
				
					|  |  |  |         response = requests.get(url, headers=headers, verify=False) | 
			
		
	
		
			
				
					|  |  |  |         dataSourceList = [] | 
			
		
	
		
			
				
					|  |  |  |         if response.reason == 'OK': | 
			
		
	
		
			
				
					|  |  |  |             response_text = response.text | 
			
		
	
		
			
				
					|  |  |  |             data = json.loads(response_text) | 
			
		
	
		
			
				
					|  |  |  |             dataSourceList = data["data"]["totalList"] | 
			
		
	
		
			
				
					|  |  |  |         else: | 
			
		
	
		
			
				
					|  |  |  |             raise ServiceException(message=f'系统异常,获取数据源失败') | 
			
		
	
		
			
				
					|  |  |  |         skip_table = [] | 
			
		
	
		
			
				
					|  |  |  |         businessId = uuid.uuid4() | 
			
		
	
		
			
				
					|  |  |  |         applyTime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") | 
			
		
	
		
			
				
					|  |  |  |         table_header_dict = { | 
			
		
	
		
			
				
					|  |  |  |             '系统代码': 'ssys_cd', | 
			
		
	
		
			
				
					|  |  |  |             '模式名称': 'mdl_name', | 
			
		
	
		
			
				
					|  |  |  |             '对象英文名': 'tab_eng_name', | 
			
		
	
		
			
				
					|  |  |  |             '补录对象名称': 'tab_crrct_name', | 
			
		
	
		
			
				
					|  |  |  |             '补录对象描述': 'tab_desc', | 
			
		
	
		
			
				
					|  |  |  |             '负责人': 'rec_subm_prsn' | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         column_header_dict = { | 
			
		
	
		
			
				
					|  |  |  |             '系统代码': 'ssys_cd', | 
			
		
	
		
			
				
					|  |  |  |             '模式名称': 'mdl_name', | 
			
		
	
		
			
				
					|  |  |  |             '对象英文名': 'tab_eng_name', | 
			
		
	
		
			
				
					|  |  |  |             '字段英文名': 'fld_eng_name', | 
			
		
	
		
			
				
					|  |  |  |             '字段补录名': 'fld_crrct_name', | 
			
		
	
		
			
				
					|  |  |  |             '补录主键': 'crrct_pk_flag', | 
			
		
	
		
			
				
					|  |  |  |             '补录字段描述': 'fld_desc', | 
			
		
	
		
			
				
					|  |  |  |             '引用字典/标准': 'data_dict_id', | 
			
		
	
		
			
				
					|  |  |  |             '安全等级': 'data_sec_lvl', | 
			
		
	
		
			
				
					|  |  |  |             '负责人': 'rec_subm_prsn' | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         contents = await file.read() | 
			
		
	
		
			
				
					|  |  |  |         excel_file = pd.ExcelFile(io.BytesIO(contents)) | 
			
		
	
		
			
				
					|  |  |  |         await file.close() | 
			
		
	
		
			
				
					|  |  |  |         # 获取所有sheet名称 | 
			
		
	
		
			
				
					|  |  |  |         sheet_names = excel_file.sheet_names | 
			
		
	
		
			
				
					|  |  |  |         # 逐个读取 | 
			
		
	
		
			
				
					|  |  |  |         tableSheet = sheet_names[0] | 
			
		
	
		
			
				
					|  |  |  |         columnSheet = sheet_names[1] | 
			
		
	
		
			
				
					|  |  |  |         successCount = 0 | 
			
		
	
		
			
				
					|  |  |  |         # 校验, 1、各必填内容不能为空, 2.系统代码映射的系统是否存在 3.表是否存在 4.字段是否存在5.引用的字典标准是否存在6.标准的系统与表系统是否对应 | 
			
		
	
		
			
				
					|  |  |  |         if tableSheet == '表信息': | 
			
		
	
		
			
				
					|  |  |  |             # 表信息补录 | 
			
		
	
		
			
				
					|  |  |  |             df = excel_file.parse(sheet_name=tableSheet) | 
			
		
	
		
			
				
					|  |  |  |             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) + "中的系统代码不能为空" | 
			
		
	
		
			
				
					|  |  |  |                 if row['mdl_name'] is None or len(row['mdl_name']) == 0: | 
			
		
	
		
			
				
					|  |  |  |                     if len(noneValid) > 0: | 
			
		
	
		
			
				
					|  |  |  |                         noneValid += ",模式名称不能为空" | 
			
		
	
		
			
				
					|  |  |  |                     else: | 
			
		
	
		
			
				
					|  |  |  |                         noneValid += "sheet[表信息]中行:" + str(index+1) + "中的模式名称不能为空" | 
			
		
	
		
			
				
					|  |  |  |                 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) + "中的表英文名不能为空" | 
			
		
	
		
			
				
					|  |  |  |                 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) + "中的系统不存在,需重新修正") | 
			
		
	
		
			
				
					|  |  |  |                     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'] + | 
			
		
	
		
			
				
					|  |  |  |                             ',对象英文名:' + row['tab_eng_name'] + | 
			
		
	
		
			
				
					|  |  |  |                             '已存在补录待审核记录,请等待审批完成或撤回申请后,再行导入') | 
			
		
	
		
			
				
					|  |  |  |                     if hasTable.apply_status == 'pending': | 
			
		
	
		
			
				
					|  |  |  |                         import_err_msg.append( | 
			
		
	
		
			
				
					|  |  |  |                             'sheet[字段信息]中行:' + str(index+1) + ' 导入的系统代码:' + row['ssys_cd'] + ',模式名称:' + row['mdl_name'] + | 
			
		
	
		
			
				
					|  |  |  |                             ',对象英文名:' + row['tab_eng_name'] + | 
			
		
	
		
			
				
					|  |  |  |                             '已存在待审核记录,请等待审批完成或撤回申请后,再行导入') | 
			
		
	
		
			
				
					|  |  |  |                     skip_table.append({'ssys_id': ssysId, 'mdl_name': row['mdl_name'], | 
			
		
	
		
			
				
					|  |  |  |                                        'tab_eng_name': row['tab_eng_name']}) | 
			
		
	
		
			
				
					|  |  |  |                     continue | 
			
		
	
		
			
				
					|  |  |  |                 oldTable = await MetaDao.get_supp_table_by_vett(ssysId, row['mdl_name'], | 
			
		
	
		
			
				
					|  |  |  |                                                                 row['tab_eng_name'], result_db) | 
			
		
	
		
			
				
					|  |  |  |                 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) + "中所对应的表不存在,无法上传补录") | 
			
		
	
		
			
				
					|  |  |  |                     continue | 
			
		
	
		
			
				
					|  |  |  |                 tableOnum = uuid.uuid4() | 
			
		
	
		
			
				
					|  |  |  |                 suppTableInfo = MetadataSuppInfoVett() | 
			
		
	
		
			
				
					|  |  |  |                 suppTableInfo.onum = tableOnum | 
			
		
	
		
			
				
					|  |  |  |                 suppTableInfo.ssys_id = ssysId | 
			
		
	
		
			
				
					|  |  |  |                 suppTableInfo.mdl_name = row['mdl_name'] | 
			
		
	
		
			
				
					|  |  |  |                 suppTableInfo.tab_eng_name = row['tab_eng_name'] | 
			
		
	
		
			
				
					|  |  |  |                 suppTableInfo.tab_crrct_name = row['tab_crrct_name'] | 
			
		
	
		
			
				
					|  |  |  |                 suppTableInfo.tab_desc = row['tab_desc'] | 
			
		
	
		
			
				
					|  |  |  |                 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 | 
			
		
	
		
			
				
					|  |  |  |                 suppTableInfo.rec_subm_prsn = row['rec_subm_prsn'] | 
			
		
	
		
			
				
					|  |  |  |                 suppTableInfo.apply_time = applyTime | 
			
		
	
		
			
				
					|  |  |  |                 suppTableInfo.apply_status = 'waiting' | 
			
		
	
		
			
				
					|  |  |  |                 suppTableInfo.business_id = businessId | 
			
		
	
		
			
				
					|  |  |  |                 suppTableInfo.oldTableData = cls.castToTableStr(oldTable, tableInfo) | 
			
		
	
		
			
				
					|  |  |  |                 await MetaDao.insertMetadataSuppInfoVett(suppTableInfo, result_db) | 
			
		
	
		
			
				
					|  |  |  |                 successCount += 1 | 
			
		
	
		
			
				
					|  |  |  |         if columnSheet == '字段信息': | 
			
		
	
		
			
				
					|  |  |  |             # 字段信息补录 | 
			
		
	
		
			
				
					|  |  |  |             df = excel_file.parse(sheet_name=columnSheet) | 
			
		
	
		
			
				
					|  |  |  |             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) + "中的系统代码不能为空" | 
			
		
	
		
			
				
					|  |  |  |                 if row['mdl_name'] is None or len(row['mdl_name']) == 0: | 
			
		
	
		
			
				
					|  |  |  |                     if len(noneValid) > 0: | 
			
		
	
		
			
				
					|  |  |  |                         noneValid += ",模式名称不能为空" | 
			
		
	
		
			
				
					|  |  |  |                     else: | 
			
		
	
		
			
				
					|  |  |  |                         noneValid += "sheet[字段信息]中行:" + str(index+1) + "中的模式名称不能为空" | 
			
		
	
		
			
				
					|  |  |  |                 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) + "中的表英文名不能为空" | 
			
		
	
		
			
				
					|  |  |  |                 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 any( | 
			
		
	
		
			
				
					|  |  |  |                         table['ssys_id'] == ssysId | 
			
		
	
		
			
				
					|  |  |  |                         and table['mdl_name'] == row['mdl_name'] | 
			
		
	
		
			
				
					|  |  |  |                         and table['tab_eng_name'] == row['tab_eng_name'] | 
			
		
	
		
			
				
					|  |  |  |                         for table in skip_table | 
			
		
	
		
			
				
					|  |  |  |                 ): | 
			
		
	
		
			
				
					|  |  |  |                     continue | 
			
		
	
		
			
				
					|  |  |  |                 oldColumn = await MetaDao.get_supp_column_by_columnInfo(ssysId, row['mdl_name'], | 
			
		
	
		
			
				
					|  |  |  |                                                                         row['tab_eng_name'], | 
			
		
	
		
			
				
					|  |  |  |                                                                         row['fld_eng_name'], result_db) | 
			
		
	
		
			
				
					|  |  |  |                 data_dict_name = '' | 
			
		
	
		
			
				
					|  |  |  |                 if oldColumn and oldColumn.data_dict_id and oldColumn.data_dict_id != '': | 
			
		
	
		
			
				
					|  |  |  |                     oldDict = await DataStdDao.get_data_dict_by_id(result_db, oldColumn.data_dict_id) | 
			
		
	
		
			
				
					|  |  |  |                     data_dict_name = oldDict.data_dict_cn_name if oldDict else '' | 
			
		
	
		
			
				
					|  |  |  |                 columnInfo = await MetaDao.get_meta_column(ssysId, row['mdl_name'], | 
			
		
	
		
			
				
					|  |  |  |                                                            row['tab_eng_name'], | 
			
		
	
		
			
				
					|  |  |  |                                                            row['fld_eng_name'], result_db) | 
			
		
	
		
			
				
					|  |  |  |                 if columnInfo is None: | 
			
		
	
		
			
				
					|  |  |  |                     import_err_msg.append("sheet[字段信息]中行:"+str(index+1) + "中所对应的字段不存在,无法上传补录") | 
			
		
	
		
			
				
					|  |  |  |                     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) + "中所对应的数据字典不存在,无法上传补录") | 
			
		
	
		
			
				
					|  |  |  |                         continue | 
			
		
	
		
			
				
					|  |  |  |                     else: | 
			
		
	
		
			
				
					|  |  |  |                         if int(dataDict.src_sys) != ssysId: | 
			
		
	
		
			
				
					|  |  |  |                             import_err_msg.append("sheet[字段信息]中行:"+str(index+1) + "中所对应的数据字典所属系统与表所属系统不一致,无法上传补录") | 
			
		
	
		
			
				
					|  |  |  |                             continue | 
			
		
	
		
			
				
					|  |  |  |                         else: | 
			
		
	
		
			
				
					|  |  |  |                             dataDictId = dataDict.onum | 
			
		
	
		
			
				
					|  |  |  |                 suppColumnInfo = MetadataFldSuppInfoVett() | 
			
		
	
		
			
				
					|  |  |  |                 suppColumnInfo.onum = uuid.uuid4() | 
			
		
	
		
			
				
					|  |  |  |                 suppColumnInfo.ssys_id = ssysId | 
			
		
	
		
			
				
					|  |  |  |                 suppColumnInfo.mdl_name = row['mdl_name'] | 
			
		
	
		
			
				
					|  |  |  |                 suppColumnInfo.tab_eng_name = row['tab_eng_name'] | 
			
		
	
		
			
				
					|  |  |  |                 suppColumnInfo.fld_eng_name = row['fld_eng_name'] | 
			
		
	
		
			
				
					|  |  |  |                 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.fld_desc = row['fld_desc'] | 
			
		
	
		
			
				
					|  |  |  |                 suppColumnInfo.pic = oldColumn.pic if oldColumn else None | 
			
		
	
		
			
				
					|  |  |  |                 suppColumnInfo.fld_clas = oldColumn.fld_clas if oldColumn else None | 
			
		
	
		
			
				
					|  |  |  |                 suppColumnInfo.fld_null_rate = oldColumn.fld_null_rate if oldColumn else None | 
			
		
	
		
			
				
					|  |  |  |                 suppColumnInfo.data_dict_id = dataDictId if dataDictId != '' else None | 
			
		
	
		
			
				
					|  |  |  |                 suppColumnInfo.data_sec_lvl = row['data_sec_lvl'] | 
			
		
	
		
			
				
					|  |  |  |                 suppColumnInfo.rec_stat = oldColumn.rec_stat if oldColumn else None | 
			
		
	
		
			
				
					|  |  |  |                 suppColumnInfo.rec_subm_prsn = row['rec_subm_prsn'] | 
			
		
	
		
			
				
					|  |  |  |                 suppColumnInfo.business_id = businessId | 
			
		
	
		
			
				
					|  |  |  |                 suppColumnInfo.apply_time = applyTime | 
			
		
	
		
			
				
					|  |  |  |                 suppColumnInfo.apply_status = 'waiting' | 
			
		
	
		
			
				
					|  |  |  |                 suppColumnInfo.oldColumnData = cls.castToColumnStr(oldColumn, columnInfo, data_dict_name) | 
			
		
	
		
			
				
					|  |  |  |                 await MetaDao.insertMetadataFldSuppInfoVett(suppColumnInfo, result_db) | 
			
		
	
		
			
				
					|  |  |  |                 successCount += 1 | 
			
		
	
		
			
				
					|  |  |  |         if successCount > 0: | 
			
		
	
		
			
				
					|  |  |  |             applyModel = ApplyModel() | 
			
		
	
		
			
				
					|  |  |  |             applyModel.businessType = "metaDataInfo" | 
			
		
	
		
			
				
					|  |  |  |             applyModel.businessId = businessId | 
			
		
	
		
			
				
					|  |  |  |             applyModel.applicant = current_user.user.user_name | 
			
		
	
		
			
				
					|  |  |  |             await ApprovalService.apply_services(result_db, applyModel, 'metaDataInfo') | 
			
		
	
		
			
				
					|  |  |  |             await result_db.commit() | 
			
		
	
		
			
				
					|  |  |  |         else: | 
			
		
	
		
			
				
					|  |  |  |             import_err_msg.append("上传的数据均有问题,本次导入0条") | 
			
		
	
		
			
				
					|  |  |  |         if len(import_err_msg) > 0: | 
			
		
	
		
			
				
					|  |  |  |             return ";".join(import_err_msg) | 
			
		
	
		
			
				
					|  |  |  |         else: | 
			
		
	
		
			
				
					|  |  |  |             return "操作成功" | 
			
		
	
	
		
			
				
					|  |  | 
 |