Browse Source

发包脚本上传,空值覆盖问题

master
xueyinfei 4 weeks ago
parent
commit
77e4d672d7
  1. 6
      vue-fastapi-backend/module_admin/controller/meta_controller.py
  2. 29
      vue-fastapi-backend/module_admin/dao/meta_dao.py
  3. 8
      vue-fastapi-backend/module_admin/entity/vo/meta_vo.py
  4. 3
      vue-fastapi-backend/module_admin/service/approval_service.py
  5. 75
      vue-fastapi-backend/module_admin/service/meta_service.py
  6. 57
      vue-fastapi-frontend/src/views/system/flow/index.vue

6
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)

29
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()
async def get_supp_table_vett_by_businessId(cls, metaBusinessDetail: MetaBusinessDetail, db: AsyncSession):
query = (
select(MetadataSuppInfoVett).where(
MetadataSuppInfoVett.business_id == metaBusinessDetail.business_id).distinct()
)
).scalars().all()
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()
)
return query_result
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,7 +437,8 @@ 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) +
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()
@ -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(

8
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]

3
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':

75
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,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

57
vue-fastapi-frontend/src/views/system/flow/index.vue

@ -539,9 +539,9 @@
</el-table>
</div>
</el-dialog>
<el-dialog v-model="metaDataListDialog" width="80%" title="导入元数据">
<el-dialog v-model="metaData.metaDataListDialog" width="80%" title="导入元数据">
<el-table
:data="metaDataList"
:data="metaData.metaDataList"
style="width: 100%"
>
<el-table-column type="expand">
@ -573,12 +573,12 @@
</el-table-column>
<el-table-column prop="mdlName" label="模式名称" align="center" />
<el-table-column prop="tabEngName" label="表英文名" align="center" />
<el-table-column prop="tabCnName" label="表中文名" align="center" />
<!-- <el-table-column prop="tabCnName" label="表中文名" align="center" />-->
<el-table-column prop="tabCrrctName" label="表补录名" align="center" />
<el-table-column prop="tabRecNum" label="记录数" align="center" />
<el-table-column prop="tabType" label="对象类型" align="center" />
<!-- <el-table-column prop="tabRecNum" label="记录数" align="center" />-->
<!-- <el-table-column prop="tabType" label="对象类型" align="center" />-->
<el-table-column prop="govFlag" label="对象治理标志" align="center" />
<el-table-column prop="pic" label="负责人" align="center" />
<el-table-column prop="recSubmPrsn" label="负责人" align="center" />
<el-table-column prop="pic" label="对象标签" align="center" >
<template #default="scope">
<template v-if="scope.row.showTabClas && scope.row.showTabClas.length > 0">
@ -596,6 +596,13 @@
</template>
</el-table-column>
</el-table>
<pagination
v-show="metaData.total > 0"
:total="metaData.total"
v-model:page="metaData.pageNum"
v-model:limit="metaData.pageSize"
@pagination="getMetaDataList"
/>
</el-dialog>
<!-- 弹窗 -->
@ -648,9 +655,15 @@ const data = reactive({
});
const showFlowDialog = ref(false);
const businessDialog = ref(false);
const metaDataListDialog = ref(false);
const metaData = ref({
metaDataListDialog: false,
metaDataList:[],
pageNum: 1,
pageSize: 10,
total: 0,
businessId: ''
});
const oldTableInfo = ref([]);
const metaDataList = ref([]);
const oldColumnList = ref([]);
const newTableInfo = ref([]);
const newColumnList = ref([]);
@ -1065,18 +1078,34 @@ function transformMetaDetailData(data){
}
businessDialog.value = true
}
function getMetaDataList(){
let param = {
businessId: metaData.value.businessId,
pageNum: metaData.value.pageNum,
pageSize: metaData.value.pageSize
}
getMetaInfoApplyBusinessDetail(param).then(res=>{
let data = JSON.parse(JSON.stringify(res.data))
metaData.value.metaDataList = data.rows
metaData.value.total = data.total
})
}
function showBusinessDataDialog(row){
if (row.businessType === 'metaDataInfo'){
metaData.value.businessId = row.businessId
let param = {
businessId: row.businessId
businessId: row.businessId,
pageNum: metaData.value.pageNum,
pageSize: metaData.value.pageSize
}
getMetaInfoApplyBusinessDetail(param).then(res=>{
let data = JSON.parse(JSON.stringify(res.data))
if (data.length === 1){
transformMetaDetailData(data[0])
}else if (data.length > 1){
metaDataList.value = data
metaDataListDialog.value = true
if (data.rows.length === 1){
transformMetaDetailData(data.rows[0])
}else if (data.rows.length > 1){
metaData.value.metaDataList = data.rows
metaData.value.total = data.total
metaData.value.metaDataListDialog = true
}
})
}else if(row.businessType ==="dataStdMain"){

Loading…
Cancel
Save