dw.html
7.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DWS/DWM/DWA 任务 - 问界门店运营数据分析平台</title>
<link rel="stylesheet" href="./static/css/style.css">
</head>
<body>
<header>
<div class="logo">问界运营分析平台</div>
<nav class="nav-links">
<a class="nav-item" href="./">首页</a>
<a class="nav-item" href="./ods">ODS 同步任务</a>
<a class="nav-item active" href="./dw">DWS/DWM/DWA 任务</a>
<a class="nav-item" href="./analysis">问界生态系数分析</a>
<a class="nav-item" href="./harmony">鸿蒙生态分析</a>
<a class="nav-item" href="./harmony/sub-brand">鸿蒙子品牌分析</a>
<a class="nav-item" href="./strategy">策略效果盯防(开发中)</a>
</nav>
<div class="user-info" id="user-info">管理员</div>
</header>
<main>
<section id="content-area">
<div class="card">
<h2>DWS/DWM/DWA 加工任务</h2>
<div>
<!-- DW 加工控制 -->
<div style="margin-bottom: 30px; background: #f0f5ff; padding: 20px; border-radius: 8px;">
<h3 style="margin-bottom:15px; font-size: 16px; color: #1890ff;">数据加工控制</h3>
<div style="display: flex; gap: 15px; align-items: center; flex-wrap: wrap;">
<div>
<label>加工层级: </label>
<select id="dw-layer-select" style="padding: 5px;">
<option value="DWS">DWS (宽表层)</option>
<option value="DWM">DWM (指标层)</option>
<option value="DWA">DWA (应用层)</option>
</select>
</div>
<div>
<label>开始日期: </label>
<input type="date" id="dw-start-date" style="padding: 4px;">
</div>
<div>
<label>结束日期: </label>
<input type="date" id="dw-end-date" style="padding: 4px;">
</div>
<div>
<label style="display: flex; align-items: center; gap: 4px; cursor: pointer; font-weight: normal;">
<input type="checkbox" id="dw-full-sync" style="width: 16px; height: 16px;">
全量覆盖
</label>
</div>
<button id="btn-run-dw" style="padding: 6px 20px; background: #52c41a; color: white; border: none; border-radius: 4px; cursor: pointer;">开始加工</button>
</div>
<p style="margin-top: 10px; font-size: 12px; color: #888;">* 提示:默认执行增量同步(最近一天),勾选"全量覆盖"后执行全量覆盖加工。指定日期范围时按日期范围处理。</p>
</div>
<!-- 历史记录 -->
<div>
<h3 style="margin-bottom:15px; font-size: 16px; color: #666;">执行历史记录</h3>
<table class="data-table" style="width: 100%; border-collapse: collapse;">
<thead>
<tr style="background: #fafafa; border-bottom: 1px solid #f0f0f0;">
<th style="padding: 12px; text-align: left;">开始时间</th>
<th style="padding: 12px; text-align: left;">数据范围</th>
<th style="padding: 12px; text-align: left;">涉及表数</th>
<th style="padding: 12px; text-align: left;">状态</th>
<th style="padding: 12px; text-align: left;">详情</th>
</tr>
</thead>
<tbody id="history-tbody"></tbody>
</table>
</div>
</div>
</div>
</section>
</main>
<!-- 任务详情弹窗 -->
<div id="detail-modal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h3>任务执行详情</h3>
<span class="close-btn" onclick="closeModal()">×</span>
</div>
<div class="modal-body">
<table class="detail-table">
<thead><tr><th>源表/内容</th><th>目标表</th><th>时间范围</th><th>影响行数</th><th>状态</th></tr></thead>
<tbody id="detail-tbody"></tbody>
</table>
</div>
</div>
</div>
<script>var APP_ROOT = '..';</script>
<script src="./static/js/common.js"></script>
<script src="./static/js/auth.js"></script>
<script>
// 只匹配 DW 加工任务:manual_dws_sync / manual_dwm_sync / manual_dwa_sync / scheduler_dws_sync
const DW_FILTER = item => /_(dws|dwm|dwa)_sync$/.test(item.task_id);
document.addEventListener('DOMContentLoaded', () => {
const now = new Date();
const lastMonth26 = new Date(now.getFullYear(), now.getMonth()-1, 26);
const start = document.getElementById('dw-start-date');
const end = document.getElementById('dw-end-date');
if (start && !start.value) start.value = fmtDate(lastMonth26);
if (end && !end.value) end.value = fmtDate(now);
fetchHistory(DW_FILTER, '%_dw%_sync');
});
document.getElementById('btn-run-dw').addEventListener('click', async () => {
const layer = document.getElementById('dw-layer-select').value;
const startDate = document.getElementById('dw-start-date').value;
const endDate = document.getElementById('dw-end-date').value;
const fullSync = document.getElementById('dw-full-sync').checked;
const formData = new FormData();
formData.append('layer', layer);
if (fullSync) {
formData.append('full_sync', 'true');
} else if (startDate && endDate) {
formData.append('start_date', startDate);
formData.append('end_date', endDate);
}
const btn = document.getElementById('btn-run-dw');
btn.disabled = true;
btn.textContent = '加工中...';
try {
const res = await fetch(window.API_BASE + '/etl/run-dw', { method: 'POST', body: formData });
const data = await res.json();
if (data.status === 'success') {
setTimeout(() => { btn.disabled = false; btn.textContent = '开始加工'; }, 2000);
fetchHistory(DW_FILTER, '%_dw%_sync');
startPolling(DW_FILTER, '%_dw%_sync');
} else {
alert('执行失败: ' + data.detail);
btn.disabled = false;
}
} catch (err) {
alert('请求出错: ' + err);
btn.disabled = false;
}
});
</script>
</body>
</html>