|
|
@ -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,9 +199,9 @@ 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']) |
|
|
@ -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 |
|
|
|