修改 bug--20261202

这个提交包含在:
apple
2026-12-02 10:42:14 +08:00
父节点 17e80cef9c
当前提交 bd87d49778
共修改 28 个文件,包含 441 行新增和 15 行删除
@@ -222,6 +222,7 @@ class SchedulingService {
String requestHash = policy.requestHash(normalized);
RunView replay = repository.replayRun(actor, RunAction.SUBMIT, idempotencyKey, requestHash);
if (replay != null) return replay;
reconcileAutomaticPrevious(actor, scheduleId);
validateReferences(actor, toDefinition(definition), scheduleId);
requireExecutionDependencies(actor, scheduleId, toDefinition(definition));
requireExecutable(toDefinition(definition));
@@ -31,6 +31,8 @@ public class DataSourceService {
private final SeaTunnelAdapter seaTunnelAdapter;
private final SecretProvisioner secretProvisioner;
private final ManagedCredentialReferenceFactory referenceFactory;
@org.springframework.beans.factory.annotation.Autowired
private TransientConnectionReceipts receipts;
public List<DataSourcePublicView> list(String dataDomainCode) {
DataSourceAccessScope scope = accessContext.current();
@@ -69,6 +71,17 @@ public class DataSourceService {
} else {
committed = true;
}
var tested = receipts == null ? null : receipts.find(receipts.fingerprint(scope, command));
if (result.created() && tested != null) {
String reason = "复用新增表单已通过的连接测试";
var start = registry.beginConnectionTest(scope, dataSourceId, "form-test-" + dataSourceId,
reason, DataSourcePolicy.testHash(dataSourceId, reason));
registry.completeConnectionTest(scope, start.view().testId(), result.view().version(),
new SeaTunnelAdapter.ConnectionTestResult(null, "SUCCEEDED", tested.connectivityStatus(),
tested.accountPermissionStatus(), "UNKNOWN", "UNKNOWN", NormalizedExternalStatus.SUCCEEDED,
null, "已复用保存前五分钟内同账号、同配置及同凭据的连接测试"));
return publicView(registry.find(scope, dataSourceId));
}
return publicView(result.view());
} catch (RuntimeException exception) {
if (provisioned && !committed) {
@@ -29,6 +29,8 @@ public class DataSourceTransientConnectionTester {
private final DataSourceAccessContext accessContext;
private final ConnectionProvider connections;
private final HiveProbe hiveProbe;
@Autowired
private TransientConnectionReceipts receipts;
@Autowired
public DataSourceTransientConnectionTester(DataSourceAccessContext accessContext, HiveJdbcRuntime hiveRuntime) {
@@ -55,6 +57,13 @@ public class DataSourceTransientConnectionTester {
}
public DataSourceTransientConnectionTestView test(DataSourceCreateCommand command) {
String fingerprint = receipts == null ? null : receipts.fingerprint(accessContext.current(), command);
DataSourceTransientConnectionTestView result = performTest(command);
if (fingerprint != null) receipts.remember(fingerprint, result);
return result;
}
private DataSourceTransientConnectionTestView performTest(DataSourceCreateCommand command) {
DataSourceAccessScope scope = accessContext.current();
char[] password = DataSourcePolicy.requireCreatePassword(command);
try {
@@ -0,0 +1,53 @@
package cn.aixunkeji.datagov.integration.datasource;
import cn.aixunkeji.datagov.integration.api.datasource.DataSourceCreateCommand;
import cn.aixunkeji.datagov.integration.api.datasource.DataSourceTransientConnectionTestView;
import org.springframework.stereotype.Component;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.HexFormat;
import java.util.LinkedHashMap;
/** Short-lived, process-local proof; no plaintext credential or client-supplied success is retained. */
@Component
public class TransientConnectionReceipts {
private final byte[] secret = new byte[32];
private final LinkedHashMap<String, Receipt> receipts = new LinkedHashMap<>();
private record Receipt(long expiresAt, DataSourceTransientConnectionTestView result) {}
public TransientConnectionReceipts() { new SecureRandom().nextBytes(secret); }
String fingerprint(DataSourceAccessScope scope, DataSourceCreateCommand command) {
char[] password = DataSourcePolicy.requireCreatePassword(command);
byte[] bytes = null;
try {
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(secret, "HmacSHA256"));
mac.update((scope.actorId() + ":" + scope.orgScopeId() + ":" + DataSourcePolicy.createHash(command, scope)).getBytes(StandardCharsets.UTF_8));
var encoded = StandardCharsets.UTF_8.encode(java.nio.CharBuffer.wrap(password));
bytes = new byte[encoded.remaining()]; encoded.get(bytes);
if (encoded.hasArray()) Arrays.fill(encoded.array(), (byte) 0);
return HexFormat.of().formatHex(mac.doFinal(bytes));
} catch (java.security.GeneralSecurityException exception) {
throw new IllegalStateException("Connection receipt unavailable", exception);
} finally {
Arrays.fill(password, '\0');
if (bytes != null) Arrays.fill(bytes, (byte) 0);
}
}
synchronized void remember(String key, DataSourceTransientConnectionTestView result) {
receipts.remove(key);
receipts.entrySet().removeIf(entry -> entry.getValue().expiresAt() < System.currentTimeMillis());
if (!"SUCCEEDED".equals(result.status())) return;
while (receipts.size() >= 256) receipts.remove(receipts.keySet().iterator().next());
receipts.put(key, new Receipt(System.currentTimeMillis() + 300_000, result));
}
synchronized DataSourceTransientConnectionTestView find(String key) {
Receipt receipt = receipts.get(key);
return receipt != null && receipt.expiresAt() >= System.currentTimeMillis() ? receipt.result() : null;
}
}
@@ -58,6 +58,8 @@ class TransformationCleaningSqlCompiler {
? null : new Expression(quoted(source.name()), quoted(source.name())));
}
Map<String, String> mappedSources = new LinkedHashMap<>();
Set<String> maskedTargets = new java.util.HashSet<>();
for (StandardizationRule rule : safe(rules.standardizationRules())) {
if (rule == null || rule.operation() == null) throw invalid("TRANSFORMATION_RULE_INVALID");
Column source = requireColumn(sourceColumns, rule.sourceField());
@@ -73,8 +75,14 @@ class TransformationCleaningSqlCompiler {
&& (!text(source) || !text(target))) {
throw invalid("TRANSFORMATION_FIELD_TYPE_INCOMPATIBLE");
}
String value = quoted(source.name());
String previousSource = mappedSources.putIfAbsent(key(target.name()), key(source.name()));
if (previousSource != null && !previousSource.equals(key(source.name())))
throw invalid("TRANSFORMATION_TARGET_SOURCE_CONFLICT");
if (maskedTargets.contains(key(target.name()))) throw invalid("TRANSFORMATION_MASKING_CHAIN_UNSUPPORTED");
Expression previous = previousSource == null ? null : expressions.get(key(target.name()));
String value = previous == null ? quoted(source.name()) : previous.afterSql();
if (rule.operation() == StandardizationOperation.TEXT_MASK || rule.operation() == StandardizationOperation.TEXT_REPLACE || rule.operation() == StandardizationOperation.TEXT_FORMAT_MASK) {
maskedTargets.add(key(target.name()));
expressions.put(key(target.name()), masking(value, rule, target, validated.hive()));
continue;
}
@@ -84,7 +92,7 @@ class TransformationCleaningSqlCompiler {
case TEXT_CASE -> textCase(value, rule.parameters());
default -> throw unsupported("TRANSFORMATION_RULE_UNSUPPORTED");
};
expressions.put(key(target.name()), new Expression(value, expression));
expressions.put(key(target.name()), new Expression(quoted(source.name()), expression));
}
if (safe(rules.completionRules()).stream().anyMatch(rule -> rule != null
@@ -0,0 +1,37 @@
package cn.aixunkeji.datagov.integration.datasource;
import cn.aixunkeji.datagov.integration.api.datasource.DataSourceCreateCommand;
import cn.aixunkeji.datagov.integration.api.datasource.DataSourceTransientConnectionTestView;
import org.junit.jupiter.api.Test;
import java.time.LocalDateTime;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
class TransientConnectionReceiptsTest {
@Test void successIsBoundToActorOrganizationConfigurationAndCredential() {
var cache = new TransientConnectionReceipts();
var scope = new DataSourceAccessScope(7, 91);
try (var command = command("first", "example.test")) {
var fingerprint = cache.fingerprint(scope, command);
var result = result("SUCCEEDED");
cache.remember(fingerprint, result);
assertThat(cache.find(cache.fingerprint(scope, command))).isEqualTo(result);
assertThat(cache.find(cache.fingerprint(new DataSourceAccessScope(8, 91), command))).isNull();
assertThat(cache.find(cache.fingerprint(new DataSourceAccessScope(7, 92), command))).isNull();
try (var changedPassword = command("second", "example.test"); var changedHost = command("first", "other.test")) {
assertThat(cache.find(cache.fingerprint(scope, changedPassword))).isNull();
assertThat(cache.find(cache.fingerprint(scope, changedHost))).isNull();
}
cache.remember(fingerprint, result("FAILED"));
assertThat(cache.find(fingerprint)).isNull();
assertThat(command.password()).isEqualTo("first".toCharArray());
}
}
private DataSourceCreateCommand command(String password, String host) {
return new DataSourceCreateCommand("source", "MYSQL", host, 3306, "example", "user", password.toCharArray(),
"owner", null, "domain", "JDBC", "PASSWORD", Map.of());
}
private DataSourceTransientConnectionTestView result(String status) {
return new DataSourceTransientConnectionTestView(status, "VERIFIED", "VERIFIED", null, "test", LocalDateTime.now());
}
}
@@ -9,6 +9,15 @@ import static org.assertj.core.api.Assertions.*;
class TransformationCleaningSqlCompilerTest {
private final TransformationCleaningSqlCompiler compiler = new TransformationCleaningSqlCompiler();
@Test void multipleRulesForOneFieldComposeInConfiguredOrder() {
var rules = new RuleSnapshot(List.of(
new StandardizationRule("trim", "value", "value", StandardizationOperation.TEXT_TRIM, Map.of("trimMode", "BOTH")),
new StandardizationRule("upper", "value", "value", StandardizationOperation.TEXT_CASE, Map.of("caseMode", "UPPER"))
), List.of(), List.of(), List.of());
assertThat(compiler.compile(context(new Column("value", "STRING", true)), rules, 10).writeSql())
.contains("UPPER(TRIM(`value`))");
}
@Test void maskingUsesCharacterCountsHidesOriginalAndFullyMasksShortValues() {
var parameters = new java.util.HashMap<>(Map.of("policySha256", "a".repeat(64), "bindingSha256", "b".repeat(64),
"prefixKeep", "2", "suffixKeep", "2", "maskCharacter", "*"));
@@ -65,6 +65,7 @@
</el-table-column>
<el-table-column width="300" class-name="dg-row-actions dg-row-actions-nowrap" label="操作" fixed="right" align="center">
<template #default="{ row }"><RowActions>
<el-button v-if="row.language === 'SQL'" v-hasPermi="['aixun:dataops:code-development:debug']" link type="primary" icon="VideoPlay" @click="openExecution(row)">立即执行</el-button>
<el-tooltip content="编辑" placement="top">
<el-button
v-hasPermi="['aixun:dataops:code-development:update']"
@@ -327,6 +328,10 @@
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane v-if="editorForm.language === 'SQL'" label="定时执行" name="schedule">
<p>为当前代码设置执行时间、参数和目标表,保存并发布调度后生效。</p>
<el-button v-hasPermi="['aixun:dataops:schedule:create']" type="primary" :disabled="editorForm.status !== 'ENABLED'" @click="scheduleCode">配置定时执行</el-button>
</el-tab-pane>
</el-tabs>
</el-drawer>
@@ -722,6 +727,19 @@ async function openEditor(row: CodeSummaryVO) {
await showDetail(response.data);
}
async function openExecution(value: unknown) {
const row = value as CodeSummaryVO;
await openEditor(row);
if (String(editorCodeId.value) === String(row.codeId)) editorTab.value = 'debug';
}
function scheduleCode() {
if (!editorCodeId.value) return;
void router.push({ path: '/datagov/dataops/scheduling/editor', query: {
sourceType: 'CODE_OBJECT', sourceId: String(editorCodeId.value), sourceName: editorForm.name
} });
}
async function showDetail(detail: CodeDetailVO) {
stopDebugConfirmation();
editorEpoch++;
@@ -235,7 +235,7 @@
<el-col :span="24"><el-form-item label="数据所在路径" prop="responseContentField"><el-input v-model="configForm.responseContentField" maxlength="255" placeholder="可选,例如 $.data[*]" /></el-form-item></el-col>
</el-row>
</el-collapse-item>
<el-collapse-item title="高级请求与认证" name="request">
<el-collapse-item title="请求头、认证与签名" name="request">
<el-row :gutter="16">
<el-col :span="12"><el-form-item label="认证方式"><el-select v-model="profileForm.authKind" class="w-full" @change="onApiAuthKindChanged"><el-option label="固定 Bearer" value="STATIC_BEARER" /><el-option label="动态 Token(客户端凭据)" value="CLIENT_CREDENTIALS" /><el-option label="动态 Token(账号密码)" value="PASSWORD_TOKEN" /><el-option label="API Key 请求头" value="API_KEY_HEADER" /><el-option label="仅请求签名" value="SIGN_ONLY" /></el-select></el-form-item></el-col>
<el-col :span="12"><el-form-item label="数据请求方法"><el-select v-model="profileForm.requestMethod" class="w-full"><el-option label="GET" value="GET" /><el-option label="POST" value="POST" /></el-select></el-form-item></el-col>
@@ -689,7 +689,7 @@ const resetConfig = () => {
Object.assign(profileForm, emptyApiProfile());
requestHeadersText.value = '{}';
requestQueryText.value = '{}';
advancedSections.value = [];
advancedSections.value = activeKind.value === 'api' ? ['request'] : [];
pollingEnabled.value = false;
originalPollingEnabled.value = false;
editingIntakeId.value = undefined;
@@ -719,7 +719,7 @@ const openEdit = async (row: FileIntakeVO, enablePolling = false) => {
resetConfig();
originalPollingEnabled.value = pollState?.enabled === true;
pollingEnabled.value = originalPollingEnabled.value || enablePolling;
if (enablePolling) advancedSections.value = ['api'];
if (enablePolling) advancedSections.value = ['api', 'request'];
editingIntakeId.value = detail.intakeId;
originalSourceType.value = detail.sourceType;
currentEndpointConfigured.value = detail.endpointConfigured;
@@ -398,6 +398,16 @@
</el-descriptions>
<el-tabs v-model="detailTab">
<el-tab-pane label="关联表" name="tables">
<el-alert v-if="layerTablesError" :title="layerTablesError" type="error" :closable="false" />
<el-table v-loading="layerTablesLoading" :data="layerTables" border empty-text="该分层暂无已登记表">
<el-table-column prop="name" label="表名称" min-width="180" />
<el-table-column prop="namespaceName" label="数据库" min-width="160" />
<el-table-column prop="engineType" label="引擎" width="100" />
<el-table-column label="登记状态" width="120"><template #default="{ row }">{{ row.executionState === 'CONFIRMED' ? '已确认' : row.executionState === 'REJECTED' ? '失败' : '待核实' }}</template></el-table-column>
</el-table>
<pagination v-if="layerTablesTotal > 0" v-model:page="layerTablesPage" v-model:limit="layerTablesPageSize" :total="layerTablesTotal" @pagination="loadLayerTables" />
</el-tab-pane>
<el-tab-pane label="分层准入" name="admission">
<el-descriptions :column="2" border>
<el-descriptions-item label="数据粒度">{{ detail.admission.granularity }}</el-descriptions-item>
@@ -471,6 +481,8 @@ import type {
StorageFormat
} from '@/api/datagov/lakehouse-layers/types';
import { extractErrorMessage } from '@/utils/request';
import { listTableFiles } from '@/api/datagov/table-files';
import type { TableFileVO } from '@/api/datagov/table-files/types';
const router = useRouter(), route = useRoute();
const canBindExisting = computed(() => ['view', 'create'].every(action => checkPermi([`aixun:dataops:table-file:${action}`])));
@@ -509,7 +521,25 @@ const initializingLayers = ref(false);
const initializationResult = ref<LayerInitializationVO>();
const admissionDialogVisible = ref(false);
const detailDialogVisible = ref(false);
const detailTab = ref('admission');
const detailTab = ref('tables');
const layerTables = ref<TableFileVO[]>([]);
const layerTablesPage = ref(1), layerTablesPageSize = ref(20), layerTablesTotal = ref(0);
const layerTablesLoading = ref(false), layerTablesError = ref('');
let layerTablesSequence = 0;
async function loadLayerTables() {
const sequence = ++layerTablesSequence;
layerTables.value = []; layerTablesTotal.value = 0; layerTablesError.value = '';
if (!detail.value) return;
if (!checkPermi(['aixun:dataops:table-file:view'])) { layerTablesError.value = '暂无查看关联表的权限'; return; }
layerTablesLoading.value = true;
try {
const response = await listTableFiles({ layerId: detail.value.layer.layerId, pageNum: layerTablesPage.value, pageSize: layerTablesPageSize.value });
if (sequence !== layerTablesSequence) return;
layerTables.value = response.data.rows; layerTablesTotal.value = response.data.total;
} catch (error) {
if (sequence === layerTablesSequence) layerTablesError.value = (await extractErrorMessage(error)) || '关联表加载失败';
} finally { if (sequence === layerTablesSequence) layerTablesLoading.value = false; }
}
const detail = ref<LayerDetailVO>();
const editingLayerId = ref<LakehouseId>();
const admissionLayer = ref<LayerVO>();
@@ -992,6 +1022,9 @@ const saveAdmission = async () => {
};
const openDetail = async (row: LayerVO) => {
++layerTablesSequence;
layerTables.value = []; layerTablesTotal.value = 0; layerTablesPage.value = 1;
layerTablesError.value = ''; detailTab.value = 'tables';
detailDialogVisible.value = true;
detailLoading.value = true;
detailError.value = '';
@@ -999,6 +1032,7 @@ const openDetail = async (row: LayerVO) => {
try {
const response = await getLakehouseLayer(row.layerId);
detail.value = response.data;
await loadLayerTables();
} catch (error) {
detailError.value = (await extractErrorMessage(error)) || '湖仓分层详情加载失败';
} finally {
@@ -930,6 +930,13 @@ onMounted(async () => {
} else if (results[1].status === 'rejected') loadError.value = '布局读取失败,请重新打开,避免覆盖未知的已存布局。';
if (!positions.value.length) positions.value = arrangeSchedule(form.nodes, form.edges);
savedDefinition.value = JSON.stringify(requestDefinition()); savedLayout.value = layoutSignature();
if (!scheduleId.value && route.query.sourceType === 'CODE_OBJECT' && typeof route.query.sourceId === 'string' && /^\d+$/.test(route.query.sourceId)) {
const name = typeof route.query.sourceName === 'string' ? route.query.sourceName.slice(0, 100) : '代码执行';
form.name = `${name}定时执行`;
form.nodes = [{ ...emptyNode(), type: 'CODE_OBJECT', name, referenceId: route.query.sourceId }];
form.triggers = [emptyTrigger()];
positions.value = arrangeSchedule(form.nodes, form.edges);
}
loading.value = false; checkpoint();
});
onBeforeUnmount(() => { clearTimeout(historyTimer); window.removeEventListener('beforeunload', beforeUnload); });
@@ -184,6 +184,7 @@
:value="item.tableFileId"
/>
</el-select>
<el-button v-hasPermi="['aixun:dataops:table-file:create']" link type="primary" :loading="creatingOutput" :disabled="!form.sourceTableFileId || creatingOutput" @click="createOutputFromSource">按源表结构新建输出表</el-button>
</el-form-item>
</el-col>
</el-row>
@@ -279,6 +280,21 @@
</div>
<el-tabs v-model="activeRuleTab">
<el-tab-pane label="按字段配置" name="fields">
<el-empty v-if="!sourceFields.length" description="请先选择输入表" />
<el-collapse>
<el-collapse-item v-for="field in sourceFields" :key="field" :name="field" :title="`${field}(${form.rules.standardizationRules.filter(rule => rule.sourceField === field).length} 条标准化规则)`">
<div v-for="rule in form.rules.standardizationRules.filter(item => item.sourceField === field)" :key="rule.ruleCode" class="mb-3 flex gap-2">
<el-select v-model="rule.operation" :disabled="protectedMask(rule)" @change="resetStandardization(rule)"><el-option v-for="item in standardizationOptions" :key="item.value" :label="item.label" :value="item.value" /></el-select>
<el-select v-if="rule.operation === 'TEXT_TRIM'" v-model="rule.parameters.trimMode"><el-option label="两端空格" value="BOTH" /><el-option label="左侧空格" value="LEADING" /><el-option label="右侧空格" value="TRAILING" /></el-select>
<el-select v-if="rule.operation === 'TEXT_CASE'" v-model="rule.parameters.caseMode"><el-option label="大写" value="UPPER" /><el-option label="小写" value="LOWER" /></el-select>
<el-button link type="danger" :disabled="protectedMask(rule)" @click="form.rules.standardizationRules.splice(form.rules.standardizationRules.indexOf(rule), 1)">删除</el-button>
</div>
<el-button plain :icon="Plus" @click="addFieldRule(field)">添加规则</el-button>
<el-text class="ml-3" type="info">按显示顺序执行;未配置规则的同名字段直接保留。</el-text>
</el-collapse-item>
</el-collapse>
</el-tab-pane>
<el-tab-pane label="字段映射图" name="mapping" lazy><TransformationMapping v-if="activeRuleTab === 'mapping'" :rules="form.rules" :scope-key="`transformation:${form.planId || 'draft'}:${form.version || 0}`" /></el-tab-pane>
<el-tab-pane :label="`标准化(${form.rules.standardizationRules.length})`" name="standardization">
<div v-for="(rule, index) in form.rules.standardizationRules" :key="index" class="mb-3">
@@ -652,7 +668,8 @@ import type {
TransformationPreviewVO,
TransformationRuleSet
} from '@/api/datagov/transformation-cleanings/types';
import { getTableFile, listTableFiles } from '@/api/datagov/table-files';
import { createTableFile, getTableFile, listTableFiles } from '@/api/datagov/table-files';
import { extractErrorMessage } from '@/utils/request';
import type { ColumnDefinition, TableFileVO } from '@/api/datagov/table-files/types';
interface DedupEditor extends Omit<DeduplicationRule, 'weights'> { weightsText: string }
@@ -728,6 +745,7 @@ async function openMapping(id: TransformationPlanId, isCurrent: () => boolean =
}
function closeMapping() { visualEpoch++; visualPlan.value = undefined; visualLoadingId.value = ''; }
const tableOptions = ref<TableFileVO[]>([]);
const creatingOutput = ref(false);
const publicationOptions = ref<ReferenceDataPublicationOption[]>([]);
const publicationSourceSystems = reactive<Record<string, string[]>>({});
const ruleTemplates = ref<RuleTemplateVO[]>([]);
@@ -746,7 +764,7 @@ const sourceFields = ref<string[]>([]);
const outputFields = ref<string[]>([]);
const sourceColumns = ref<ColumnDefinition[]>([]);
const outputColumns = ref<ColumnDefinition[]>([]);
const activeRuleTab = ref('standardization');
const activeRuleTab = ref('fields');
const queryFormRef = ref<FormInstance>();
const definitionFormRef = ref<FormInstance>();
const definitionDialog = reactive({ visible: false, title: '', mode: 'create' as 'create' | 'edit' | 'version' });
@@ -1110,6 +1128,36 @@ async function loadSourceFields(id: TransformationPlanId) {
sourceFields.value = sourceColumns.value.map((item) => item.name);
}
async function createOutputFromSource() {
if (!form.sourceTableFileId || creatingOutput.value) return;
creatingOutput.value = true;
try {
const sourceId = form.sourceTableFileId;
const source = (await getTableFile(sourceId)).data;
const answer = await ElMessageBox.prompt('在源表所在分层新建独立输出表,仅复制字段结构,原表不变。', '新建清洗输出表', {
inputValue: `${source.tableFile.name}_clean`, inputPattern: /^[a-zA-Z_][a-zA-Z0-9_]{0,127}$/, inputErrorMessage: '请使用字母、数字和下划线,且不以数字开头'
});
if (String(form.sourceTableFileId) !== String(sourceId)) return;
if (answer.value.toLowerCase() === source.tableFile.name.toLowerCase()) throw new Error('输出表名不能与源表相同');
const response = await createTableFile({ name: answer.value, objectType: 'TABLE',
layerId: source.tableFile.layerId, storageResourceId: source.tableFile.storageResourceId,
storageSpaceId: source.tableFile.storageSpaceId, engineType: source.tableFile.engineType,
storageFormat: source.tableFile.storageFormat, catalogName: source.tableFile.catalogName,
namespaceName: source.tableFile.namespaceName, columns: source.columns,
partitionPolicy: source.partitionPolicy, comment: `清洗输出:${source.tableFile.name}` }, idempotencyKey());
const created = response.data?.result?.tableFile as TableFileVO | undefined;
if (!created || created.executionState !== 'CONFIRMED') {
ElMessage.warning('建表结果尚未确认,请到表文件页面核对,勿重复建表'); return;
}
if (String(form.sourceTableFileId) !== String(sourceId)) return;
tableOptions.value.push(created); form.outputTableFileId = created.tableFileId;
await loadOutputFields(created.tableFileId);
ElMessage.success('输出表已创建,已自动保留源表字段');
} catch (error) {
if (error !== 'cancel' && error !== 'close') ElMessage.error((await extractErrorMessage(error)) || '输出表创建失败');
} finally { creatingOutput.value = false; }
}
async function loadOutputFields(id: TransformationPlanId) {
outputColumns.value = id ? (await getTableFile(id)).data.columns : [];
outputFields.value = outputColumns.value.map((item) => item.name);
@@ -1124,7 +1172,7 @@ async function openCreate() {
outputFields.value = [];
sourceColumns.value = [];
outputColumns.value = [];
activeRuleTab.value = 'standardization';
activeRuleTab.value = 'fields';
definitionDialog.mode = 'create';
definitionDialog.title = '新增转换清洗计划';
definitionDialog.visible = true;
@@ -1201,6 +1249,11 @@ function addStandardization() {
});
}
function addFieldRule(field: string) {
form.rules.standardizationRules.push({ ruleCode: ruleIdentity('standard'), sourceField: field,
targetField: field, operation: 'TEXT_TRIM', parameters: { trimMode: 'BOTH' } });
}
function addDirectMapping(targetField: string) {
if (form.rules.standardizationRules.some((rule) =>
rule.operation === 'DIRECT_COPY' && rule.targetField.toLowerCase() === targetField.toLowerCase()
@@ -34,6 +34,7 @@
<el-table-column width="330" class-name="dg-row-actions dg-row-actions-nowrap" label="操作" align="center" fixed="right">
<template #default="{ row }"><RowActions>
<el-button icon="View" link type="primary" @click="openCollection(row)">详情</el-button>
<el-button v-if="canExecute" icon="VideoPlay" link type="primary" :disabled="Boolean(executingCollectionId) || !['SUCCEEDED', 'FAILED', 'CANCELED'].includes(row.status)" :loading="executingCollectionId === String(row.collectionId)" @click="executeCollection(row)">立即执行</el-button>
<el-button icon="CopyDocument" v-if="canCopy" link type="primary" :disabled="loading || copyDisabled || Boolean(refreshingCollectionId)"
@click="emit('copy-configuration', row.collectionId)">复制配置</el-button>
<el-button icon="View" v-if="canRefresh" link type="primary" :loading="refreshingCollectionId === String(row.collectionId)"
@@ -83,9 +84,9 @@
</template>
<script setup lang="ts">
import { ElMessage } from 'element-plus';
import { ElMessage, ElMessageBox } from 'element-plus';
import { computed, onMounted, onBeforeUnmount, reactive, ref, watch } from 'vue';
import { getIngestionCollection, pageIngestionCollections, refreshIngestionCollection } from '@/api/datagov/unified-ingestion';
import { copyIngestionConfiguration, submitUnifiedIngestion, getIngestionCollection, pageIngestionCollections, refreshIngestionCollection } from '@/api/datagov/unified-ingestion';
import type {
CollectionDetailVO,
CollectionQuery,
@@ -104,6 +105,29 @@ const props = defineProps<{ copyDisabled?: boolean; currentResult?: CollectionDe
const emit = defineEmits<{ 'copy-configuration': [collectionId: Identifier]; 'view-mapping': [taskId: Identifier]; refreshed: [result: CollectionDetailVO] }>();
function viewMapping(taskId: Identifier) { detailDialog.value = false; emit('view-mapping', taskId); }
const canCopy = computed(() => ['view', 'create'].every(action => checkPermi([`aixun:dataops:batch-ingestion:${action}`])));
const canExecute = computed(() => ['view', 'create', 'update', 'submit'].every(action => checkPermi([`aixun:dataops:batch-ingestion:${action}`])));
const executingCollectionId = ref<string>();
const executionKeys = new Map<string, string>();
async function executeCollection(value: unknown) {
const row = value as CollectionSummaryVO;
if (!canExecute.value || executingCollectionId.value) return;
const id = String(row.collectionId);
executingCollectionId.value = id;
try {
await ElMessageBox.confirm(`按保存的配置再次执行“${row.name}”?将向原目标表采集数据。`, '立即执行', { type: 'warning' });
const copied = (await copyIngestionConfiguration(row.collectionId)).data.configuration;
const key = executionKeys.get(id) || `collection-repeat-${crypto.randomUUID()}`;
executionKeys.set(id, key);
const response = await submitUnifiedIngestion({ ...copied, items: copied.items.map(item => ({ ...item, createTarget: false })) }, key);
executionKeys.delete(id);
await loadRecords();
await openCollection({ collectionId: response.data.collectionId });
if (response.data.status === 'FAILED' || response.data.status === 'UNKNOWN') ElMessage.warning('采集未确认成功,请查看新记录中的结果说明');
else ElMessage.success('已提交新的采集记录,请查看执行结果');
} catch (error) {
if (error !== 'cancel' && error !== 'close') ElMessage.error((await extractErrorMessage(error)) || '执行结果未确认,请核对采集记录;配置变化时请复制配置后重新检查');
} finally { executingCollectionId.value = undefined; }
}
const query = reactive<CollectionQuery>({ keyword: undefined, status: undefined, pageNum: 1, pageSize: 20 });
const collections = ref<CollectionSummaryVO[]>([]);
const total = ref(0);
@@ -217,9 +217,9 @@ type CollectionDisplayResult = Omit<SubmitResult, 'items'> & {
items: (SubmitResult['items'][number] | CollectionDetailVO['items'][number])[];
};
const activeView = ref<'create' | 'records' | 'drafts' | 'mapping' | 'originals'>('create');
const activeView = ref<'create' | 'records' | 'drafts' | 'mapping' | 'originals'>('records');
const originalBusy = ref(false);
const recordsVisited = ref(false);
const recordsVisited = ref(true);
const mappingTaskId = ref<string | number>();
const mappingIsCurrent = ref<(() => boolean)>();
const mappingGeneration = ref(0);
@@ -24,7 +24,7 @@
<div class="toolbar-shell">
<div class="table-heading">
<h3>编码标识</h3>
<p>共 {{ (rows)?.length ?? 0 }} 条记录</p>
<p>编码规则用于生成统一标识;建立来源系统与业务主键映射后,主数据维护会自动取得该标识。</p>
</div>
<div class="toolbar-actions">
<el-button
@@ -96,6 +96,17 @@
</header>
<el-skeleton v-if="snapshotLoading" :rows="8" animated />
<el-tabs v-else-if="snapshot" v-model="activeTab">
<el-tab-pane label="来源与去向" name="relations">
<el-alert title="根据已记录的血缘关系展示当前表的来源与下游引用;未采集的关系不会推测生成。" type="info" :closable="false" class="mb-3" />
<h3>上游来源表</h3>
<el-table :data="relatedTables(snapshot.graph, true)" border empty-text="当前快照未记录上游来源表">
<el-table-column prop="name" label="表名称" min-width="160" /><el-table-column prop="fullyQualifiedName" label="完整位置" min-width="240" />
</el-table>
<h3>下游引用表</h3>
<el-table :data="relatedTables(snapshot.graph, false)" border empty-text="当前快照未记录下游引用表">
<el-table-column prop="name" label="表名称" min-width="160" /><el-table-column prop="fullyQualifiedName" label="完整位置" min-width="240" />
</el-table>
</el-tab-pane>
<el-tab-pane label="血缘图" name="graph">
<DgVisualWorkspace
v-if="activeTab === 'graph'"
@@ -344,6 +355,7 @@ import DgVisualEntry from '@/design-system/components/visualization/DgVisualEntr
import '@/design-system/styles/_visualization.scss';
import { defineAsyncComponent } from 'vue';
import { useLineage, entityTypes, nodeLabel, formatTime, entityTypeLabel } from './useLineage';
import { relatedTables } from './projection';
const DgVisualWorkspace = defineAsyncComponent(
() => import('@/design-system/components/visualization/DgVisualWorkspace.vue')
);
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest';
import { fieldEmphasis, projectLineage } from './projection';
import { fieldEmphasis, projectLineage, relatedTables } from './projection';
import type { CanvasGraph } from '@/design-system/components/visualization/types';
import type { MetadataLineageGraph } from '@/api/datagov/metadata-lineage/types';
@@ -14,6 +14,16 @@ const graph: CanvasGraph = {
]
};
describe('字段血缘路径', () => {
it('来源和去向沿有向关系穿过管道,不包含无关表或反向支路', () => {
const nodes = ['source', 'pipeline', 'current', 'target', 'unrelated'].map(externalId => ({ externalId, name: externalId,
fullyQualifiedName: externalId, entityType: externalId === 'pipeline' ? 'PIPELINE' as const : 'TABLE' as const }));
const input: MetadataLineageGraph = { root: nodes[2], nodes, upstreamEdges: [
{ fromExternalId: 'source', toExternalId: 'pipeline' }, { fromExternalId: 'pipeline', toExternalId: 'current' }
], downstreamEdges: [{ fromExternalId: 'current', toExternalId: 'target' }, { fromExternalId: 'unrelated', toExternalId: 'target' }],
fieldMappings: [], upstreamDepth: 2, downstreamDepth: 2, truncated: false };
expect(relatedTables(input, true).map(node => node.externalId)).toEqual(['source']);
expect(relatedTables(input, false).map(node => node.externalId)).toEqual(['target']);
});
it('追踪全部已知上下游,保留订单与退款字段隔离', () => {
expect(fieldEmphasis(graph, { nodeId: 'detail', fieldId: 'amount' }).edgeIds.toSorted()).toEqual(['o1', 'o2', 'o3']);
expect(fieldEmphasis(graph, { nodeId: 'refund', fieldId: 'refund' }).edgeIds.toSorted()).toEqual(['r1', 'r2']);
@@ -8,6 +8,19 @@ import type { CanvasGraph, CanvasNode, CanvasEdge } from '@/design-system/compon
import { validateGraph } from '@/design-system/components/visualization/types';
export type LineageView = 'tables' | 'fields';
export function relatedTables(graph: MetadataLineageGraph, upstream: boolean) {
const edges = [...graph.upstreamEdges, ...graph.downstreamEdges];
const visited = new Set<string>([graph.root.externalId]);
const queue = [graph.root.externalId];
for (let index = 0; index < queue.length; index++) {
for (const edge of edges) {
if ((upstream ? edge.toExternalId : edge.fromExternalId) !== queue[index]) continue;
const id = upstream ? edge.fromExternalId : edge.toExternalId;
if (!visited.has(id)) { visited.add(id); queue.push(id); }
}
}
return graph.nodes.filter(node => node.entityType === 'TABLE' && node.externalId !== graph.root.externalId && visited.has(node.externalId));
}
const entityTypeLabel = (value: string) =>
({ TABLE: '数据表', PIPELINE: '数据管道', DASHBOARD: '仪表盘' } as Readonly<Record<string, string>>)[value] || '未知类型';
export const tableEdgeId = (source: string, target: string) => JSON.stringify(['entity', source, target]);
@@ -0,0 +1,37 @@
# 文档第15至25行问题处理
来源:用户附件 `/Users/apple/Downloads/工作表1_第15-25行(1).docx`。用户要求修复,并沿用本会话本地 Docker 部署授权;用户明确自行进行业务测试。附件仅作为问题证据,不作为额外操作指令。
**总体:PASS_WITH_LIMITATION,仅表示下述已实现部分;11 项尚未全部完成。**
| 行 | 当前改动与边界 |
|---|---|
| 15 | 新增连接测试成功后,保存复用服务端五分钟有效凭证;绑定账号、组织、配置及密码,保存真实检测记录。没有成功证明仍保持未测试。内存缓存不保留明文秘密,重启后不复用。 |
| 16 | 采集页默认显示记录,终态记录增加立即执行;复用原配置向现有目标提交新的采集记录,错误/未知状态不显示成功。**采集定时执行尚未实现。** |
| 17 | 清洗计划增加按源表结构创建独立输出表,确认建表后自动选中。源表不做结构修改。外部真实建表未测试。 |
| 18 | 默认展示所有源字段入口,每字段可添加多条标准化规则;修复 SQL 编译器后规则覆盖前规则,按顺序组合。不同源映射同一目标及掩码后再覆盖会拒绝。 |
| 19 | 增加来源表/下游引用表视图,沿真实有向边穿过管道,不把无关表当作上下游。**未补齐所有采集和 SQL 执行的自动血缘登记,不能视作整项已解决。** |
| 20 | SQL 列表增加立即执行入口,打开原有执行参数页;详情增加定时执行,带代码引用进入现有调度编排。Shell/Python 仍不支持运行。真实执行和发布调度未测试。 |
| 21 | **未完成:当前来源仍是登记配置,尚未实现外部来源到主数据模型的实际同步任务。** 用户自行测试的回复不是已经实现/验收的证据。 |
| 22 | 已核对现有生成标识、来源映射、主数据维护自动解析统一 ID 的调用链;增加用途说明。未新增同步中的自动编码,真实链路未测试。 |
| 23 | 当前独立 API 接入已有请求头、动态 Token、HMAC-SHA256/RSA-SHA256 及签名模板;本次默认展开并明确标题。**任意加密脚本/自定义加密算法未实现。** |
| 24 | 分层详情增加关联表分页查询,使用后端 layerId 过滤;包含数据库、引擎和登记状态,权限不足明确提示。 |
| 25 | 手动提交调度之前,先观察并同步原有活动/未知运行,再由原并发限额检查。没有删记录、强制释放未知占用或放宽限额。原场景的业务复测未运行。 |
## 检查和构建
- PASS:受影响前端文件 `script/quality/check.sh --frontend`;血缘投影 Vitest 5 项。
- PASS:`check.sh --backend aixun-modules/aixun-integration,aixun-modules/aixun-dataops 'DataSourceServiceTest,DataSourceTransientConnectionTesterTest,TransformationCleaningSqlCompilerTest,SchedulingServiceTest'`,实际运行 34 项(不存在的 SchedulingServiceTest 未计入覆盖)。
- PASS:同两模块 `TransientConnectionReceiptsTest,Scheduling*Test`,实际运行 Integration 7 项、DataOps 124 项;两轮共 165 项。
- PASS:前端生产构建;Maven Wrapper 两模块及依赖 `package -DskipTests`(前述测试单独执行)。
- 全量 `vue-tsc --noEmit` 未通过:PageAssist 路由、既有代码列表行类型及其他页面仍有类型错误。本次新增的 3 处类型错误已修正;不得把整体类型检查标记 PASS。
- Browser:BLOCKED,浏览器自动审批以 URL 策略拒绝 `http://localhost:28000/index`;未绕过访问限制。
- 外部源采集、建表/写回、主数据、定时执行及业务终态:NOT_RUN,由用户验收。
## 文件及恢复
主要文件:Integration 的 `TransientConnectionReceipts`、`DataSourceTransientConnectionTester`、`DataSourceService`、`TransformationCleaningSqlCompiler` 及对应测试;DataOps 的 `SchedulingService`;前端 unified-ingestion、transformation-cleaning、code-development、scheduling/editor、lakehouse-layers、metadata-lineage、master-data-identity、file-ingestion 页面。
本地发布版本 `docx-bugs-20261202`;部署状态和精确恢复镜像以 `script/datagov/deployment/releases/docx-bugs-20261202-{frontend,integration,dataops}-result.json` 为准。未执行数据库迁移,未修改其他项目容器及业务数据。需要恢复时,使用记录内 recoveryImageId 通过同一 deploy.sh plan/apply 回退对应服务;不整栈重启。
三个服务均已执行 plan/apply,制品读回及 check-config PASS,容器状态 running。应用就绪及业务 UAT 为 NOT_RUN。初始 Docker 守护进程未启动,已使用 `docker desktop start` 恢复;没有执行整栈启动或全局清理。临时截图提取目录和完整构建日志已清理,仅保留本记录、有效构建及部署/恢复记录。
@@ -0,0 +1,6 @@
{
"sourceContainerId": "ab375a9e94314bd1eb89fe3ac4eddffc10fe42a48fc3696abf099ff58378d959",
"imageId": "sha256:27f238c1f4b3d02ddc8095871c2eba42b76fc195d3f3fb38ba9bf06dc77596fb",
"authorizedBy": "\u7528\u6237\u8981\u6c42\u4fee\u590d\u6587\u6863\u95ee\u9898\u5e76\u90e8\u7f72\u672c\u5730Docker\uff1b\u7528\u6237\u81ea\u884c\u4e1a\u52a1\u6d4b\u8bd5",
"startedAt": 1796178948.518071
}
@@ -0,0 +1,9 @@
{
"service": "dataops",
"containerId": "9a06392c641b31d680d95b38067a7ba5302b58eb76245d3de088b70085f68392",
"imageId": "sha256:27f238c1f4b3d02ddc8095871c2eba42b76fc195d3f3fb38ba9bf06dc77596fb",
"status": "DEPLOYED_FUNCTIONAL_UAT_NOT_RUN",
"artifactReadback": "PASS",
"applicationReadiness": "NOT_RUN",
"recoveryImageId": "sha256:682d385d7159db96ec5370a7f1b7a57fee96999a90878da787254ebeca5c1b9a"
}
@@ -0,0 +1,14 @@
{
"version": 1,
"service": "dataops",
"release": "docx-bugs-20261202",
"imageTag": "aixun-datagov/dataops:docx-bugs-20261202",
"imageId": "sha256:27f238c1f4b3d02ddc8095871c2eba42b76fc195d3f3fb38ba9bf06dc77596fb",
"artifactSha256": "53c2075543de1f39a74078b59a4e3c9e01b0b0dcffd2bf97ddcedf5e74d85754",
"sourceContainerId": "ab375a9e94314bd1eb89fe3ac4eddffc10fe42a48fc3696abf099ff58378d959",
"sourceImageId": "sha256:682d385d7159db96ec5370a7f1b7a57fee96999a90878da787254ebeca5c1b9a",
"sourceImageTag": "sha256:682d385d7159db96ec5370a7f1b7a57fee96999a90878da787254ebeca5c1b9a",
"sourceStateSha256": "674f73b04eebe80b793101dac7c73795ae2d38457d3b2d37faeb43a8cfba4b85",
"modelSha256": "1e6f2ddbb1022b79ae5929a242ead5e65c180e141fdf159b48095f8303fb8ab5",
"identitySha256": "67614e7d93746b5a22a5d41862c4abc089ad5d200b51f64fbf26fa791345b8d5"
}
@@ -0,0 +1,6 @@
{
"sourceContainerId": "de8d0128ed8fe404e8475b0b8afa98ac3df7bd18d3b08a19ceb1b353bc59ceba",
"imageId": "sha256:7cacdb345fd9d4d033027079244847a81c9032aee8e48bea863b0dca245d6ca7",
"authorizedBy": "\u7528\u6237\u8981\u6c42\u4fee\u590d\u6587\u6863\u95ee\u9898\u5e76\u90e8\u7f72\u672c\u5730Docker\uff1b\u7528\u6237\u81ea\u884c\u4e1a\u52a1\u6d4b\u8bd5",
"startedAt": 1796178715.244064
}
@@ -0,0 +1,9 @@
{
"service": "frontend",
"containerId": "6d7aab747ae61a951bb41b27578d284fa82f144b568965c8fb0b86d3882ebbe2",
"imageId": "sha256:7cacdb345fd9d4d033027079244847a81c9032aee8e48bea863b0dca245d6ca7",
"status": "DEPLOYED_FUNCTIONAL_UAT_NOT_RUN",
"artifactReadback": "PASS",
"applicationReadiness": "NOT_RUN",
"recoveryImageId": "sha256:3b54e57c041ca2ac817e0e2c4f489d69d2e17cafc3794608df52652bf5838faa"
}
@@ -0,0 +1,15 @@
{
"version": 1,
"service": "frontend",
"release": "docx-bugs-20261202",
"imageTag": "aixun-datagov/frontend:docx-bugs-20261202",
"imageId": "sha256:7cacdb345fd9d4d033027079244847a81c9032aee8e48bea863b0dca245d6ca7",
"artifactSha256": "401d222abbf2058f31dc20d3c022ad24c61562c11fb1fb4508fb7613b21422d3",
"sourceContainerId": "de8d0128ed8fe404e8475b0b8afa98ac3df7bd18d3b08a19ceb1b353bc59ceba",
"sourceImageId": "sha256:3b54e57c041ca2ac817e0e2c4f489d69d2e17cafc3794608df52652bf5838faa",
"sourceImageTag": "sha256:3b54e57c041ca2ac817e0e2c4f489d69d2e17cafc3794608df52652bf5838faa",
"sourceStateSha256": "d76ee1e7132d0497ebd1e60b86f5dd2183455f20e18aa08bb9d06059dd929b8a",
"modelSha256": "6b5645b1af60dc54db2d9d14a7a57bfcf16b87f16fa3e4b3968ce0b416ae2896",
"identitySha256": "d0c9630a8fcfc59276ca59df8adcf0043ee76a2c5f5ca0eb6745651a651c1f9f",
"artifactPath": "/opt/aixun-datagov/frontend-current"
}
@@ -0,0 +1,6 @@
{
"sourceContainerId": "13f44e0a41fabbf3121cd9636f8175f8077e7169936ff9daa35e00203a56954c",
"imageId": "sha256:f7fd464f3723e7ba15d7c9af076e99e98d29e7c74db9bdb9bc8eeecd80e7a126",
"authorizedBy": "\u7528\u6237\u8981\u6c42\u4fee\u590d\u6587\u6863\u95ee\u9898\u5e76\u90e8\u7f72\u672c\u5730Docker\uff1b\u7528\u6237\u81ea\u884c\u4e1a\u52a1\u6d4b\u8bd5",
"startedAt": 1796178809.7486
}
@@ -0,0 +1,9 @@
{
"service": "integration",
"containerId": "665bfa48b77dd01a493bb0789bd8a979d7457bd0ddeefcafcd5f223605e88f4e",
"imageId": "sha256:f7fd464f3723e7ba15d7c9af076e99e98d29e7c74db9bdb9bc8eeecd80e7a126",
"status": "DEPLOYED_FUNCTIONAL_UAT_NOT_RUN",
"artifactReadback": "PASS",
"applicationReadiness": "NOT_RUN",
"recoveryImageId": "sha256:74b3581e5b5724f092db2bf4f27c55885104456857cc429c29bfbf51de50f316"
}
@@ -0,0 +1,14 @@
{
"version": 1,
"service": "integration",
"release": "docx-bugs-20261202",
"imageTag": "aixun-datagov/integration:docx-bugs-20261202",
"imageId": "sha256:f7fd464f3723e7ba15d7c9af076e99e98d29e7c74db9bdb9bc8eeecd80e7a126",
"artifactSha256": "b815410c7ea1891db28f68025d6e8a99710dd041c264d03e68a01acc4e1074c3",
"sourceContainerId": "13f44e0a41fabbf3121cd9636f8175f8077e7169936ff9daa35e00203a56954c",
"sourceImageId": "sha256:74b3581e5b5724f092db2bf4f27c55885104456857cc429c29bfbf51de50f316",
"sourceImageTag": "sha256:74b3581e5b5724f092db2bf4f27c55885104456857cc429c29bfbf51de50f316",
"sourceStateSha256": "76baf0c5aa5d5180c0d944a8e3352636244659dd89923ee24245e887dacdeeb5",
"modelSha256": "d4ed2e6bbce8c755997779d08cc1ed4cb17a000a1b984a63f7a53a393c64874d",
"identitySha256": "0927fc120834a47a1af316dbf405bc7a67399b92503e786749f5806d0afdedbf"
}