-
Notifications
You must be signed in to change notification settings - Fork 0
/
avoid_lose.html
278 lines (219 loc) · 11.4 KB
/
avoid_lose.html
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<title>疯狂JOIN - Tools for SQL</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700" rel="stylesheet">
<link rel="stylesheet" href="fonts/icomoon/style.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/jquery-ui.css">
<link rel="stylesheet" href="css/owl.carousel.min.css">
<link rel="stylesheet" href="css/owl.theme.default.min.css">
<link rel="stylesheet" href="css/owl.theme.default.min.css">
<link rel="stylesheet" href="css/jquery.fancybox.min.css">
<link rel="stylesheet" href="css/bootstrap-datepicker.css">
<link rel="stylesheet" href="fonts/flaticon/font/flaticon.css">
<link rel="stylesheet" href="css/aos.css">
<link rel="stylesheet" href="css/style.css">
<link rel="icon" href="case_when.ico">
</head>
<body data-spy="scroll" data-target=".site-navbar-target" data-offset="300">
<div class="site-wrap" id="home-section">
<div class="site-mobile-menu site-navbar-target">
<div class="site-mobile-menu-header">
<div class="site-mobile-menu-close mt-3">
<span class="icon-close2 js-menu-toggle"></span>
</div>
</div>
<div class="site-mobile-menu-body"></div>
</div>
<div class="container d-none d-lg-block">
<div class="row">
<div class="col-12 text-center mb-4 mt-5">
<h1 class="mb-0 site-logo"><a href="index.html" class="text-black h2 mb-0">Tools for SQL<span class="text-primary">.</span> </a></h1>
</div>
</div>
</div>
<header class="site-navbar py-md-4 js-sticky-header site-navbar-target" role="banner">
<div class="container">
<div class="row align-items-center">
<div class="col-6 col-md-6 col-xl-2 d-block d-lg-none">
<h1 class="mb-0 site-logo"><a href="index.html" class="text-black h2 mb-0">Tools for SQL<span class="text-primary">.</span> </a></h1>
</div>
<div class="col-12 col-md-12 main-menu">
<nav class="site-navigation position-relative text-right" role="navigation">
<ul class="site-menu main-menu js-clone-nav mr-auto d-none d-lg-block">
<li><a class="nav-link" href="index.html">首页</a></li>
<li><a class="nav-link" href="case_when.html" data-toggle="tooltip" title="不想写case when的时候">快速 CASE WHEN</a></li>
<li><a class="nav-link" href="avoid_lose.html" data-toggle="tooltip" title="一次使用N张表" style="color:#00d2b5">疯狂JOIN</a></li>
<li><a class="nav-link" href="lab_date.html" data-toggle="tooltip" title="时间生成器" >最近N天</a></li>
<li><a class="nav-link" href="lab_join.html" data-toggle="tooltip" title="多表相似关联" >多表相似关联</a></li>
<li><a class="nav-link" href="beauty_sql.html" data-toggle="tooltip" title="SQL美化">SQL美化</a></li>
<li><a class="nav-link" href="lab.html" data-toggle="tooltip" title="sql实验室" >实验室</a></li>
<li><a class="nav-link" href="https://regex101.com/" data-toggle="tooltip" title="正则表达实验室" target="_blank">REGEX101</a></li>
</ul>
</nav>
</div>
<div class="col-6 col-md-6 d-inline-block d-lg-none ml-md-0" ><a href="#" class="site-menu-toggle js-menu-toggle text-black float-right"><span class="icon-menu h3"></span></a></div>
</div>
</div>
</header>
<div class="site-section bg-light" id="contact-section" style="padding-top:5em">
<div class="container">
<div class="py-5 text-center">
<!-- <h2>疯狂 LEFT JOIN</h2> -->
<p class="lead">输入相应的表名,自动生成全关联表<i style="padding-left:10px;" class="fa fa-question-circle" aria-hidden="true" data-toggle="popover" title="内部使用指南"></i></p>
<div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="leftclose" id="leftclose1" value=1 checked="checked">
<label class="form-check-label" for="leftclose1">select法</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="leftclose" id="leftclose2" value=2>
<label class="form-check-label" for="leftclose2">left join法</label>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 order-md-2 mb-4">
<textarea class="form-control rounded-0" id="inputtextarea" rows="25" placeholder="请输入你的全部表名,一行一张表! 注意,如果分区格式不是 yyyy-MM-dd请自行调整!"></textarea>
</div>
<div class="col-md-6 order-md-2 mb-4">
<textarea class="form-control rounded-0 " id="textarea" rows="25" placeholder=""></textarea>
</div>
</div>
<button class="btn btn-primary btn-lg btn-block" id="button1" type="submit" onclick="generate();return false;">一键生成</button>
</div>
</div>
<div class="footer py-5 border-top text-center">
<div class="container">
<div class="row">
<div class="col-md-12">
<p class="mb-0">
<p class="mb-1">© 2018-2019 Clark Yu · <span><a href="update_log.html" data-toggle="tooltip" title="又有新的更新啦!" target="_blank" style='text-decoration:none;'>更新日志</a></span> · <span><a href="https://zhuanlan.zhihu.com/p/44502560" data-toggle="tooltip" title="提个意见!" target="_blank" style='text-decoration:none;'>给我留言</a></span> · <span id="busuanzi_container_site_pv">
本站总访问量<span id="busuanzi_value_site_pv"></span>次
</p>
</div>
<div class="col-md-12">
<img src="images/wechat.png" alt="Image" class = "wechat_img">
<p class="mb-1"><span style="color: #00d2b5;">微信</span>打赏,手有余香</p>
</div>
</div>
</div>
</div>
</div> <!-- .site-wrap -->
<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/jquery-migrate-3.0.1.min.js"></script>
<script src="js/jquery-ui.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/owl.carousel.min.js"></script>
<script src="js/jquery.stellar.min.js"></script>
<script src="js/jquery.countdown.min.js"></script>
<script src="js/bootstrap-datepicker.min.js"></script>
<script src="js/jquery.easing.1.3.js"></script>
<script src="js/aos.js"></script>
<script src="js/jquery.fancybox.min.js"></script>
<script src="js/jquery.sticky.js"></script>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<script src="js/main.js"></script>
<script>
function generate() {
function getNowFormatDate() {
var date = new Date(new Date()-24*60*60*1000*2);
var seperator1 = "-";
var year = date.getFullYear();
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var currentdate = year + seperator1 + month + seperator1 + strDate;
return currentdate;
}
var yesterday = getNowFormatDate();
function getRadioValue(radioName)
{
var radios = document.getElementsByName(radioName);
if(!radios)
return '';
for (var i = 0; i < radios.length; i++)
{
if (radios[i].checked)
return radios[i].value;
}
return '';
}
var raw_text = document.getElementById('inputtextarea').value;
var table_list = raw_text.split("\n");
var if_mail = 0 //判断是否直接粘贴自邮箱
var leftclose = getRadioValue("leftclose") * 1;
var lg = table_list.length;
for (var i = 0; i < lg; i++){
if(table_list[i].indexOf("权限类型")!= -1){
if_mail = 1;
break;
}
}
if (if_mail == 0){
var text = '';
for (var i = 1; i < lg; i++){
if(table_list[i].length>0)
{
text += `\nleft join` + `\n(\n\tSELECT pt \n\tFROM ${table_list[i]}\n\tWHERE pt = '${yesterday}'\n\tlimit 1\n) t${i+1} \non t1.pt = t${i+1}.pt` ;
}
}
var first_text = `\n(\n\tSELECT pt \n\tFROM ${table_list[0]}\n\tWHERE pt = '${yesterday}'\n\tlimit 1\n) t1` ;
} else {
console.log(if_mail);
var text = '';
var text_1 = ''
var first_start = 0;
// 获取起始列
for (var i = 1; i < lg; i++){
if(table_list[i].length>0&&table_list[i].indexOf("权限类型")== -1&&table_list[i].indexOf("权限过期策略")==-1&&table_list[i].indexOf("过期之后如有需要")== -1&&table_list[i].indexOf("本邮件发自")== -1&&table_list[i].indexOf("注意")== -1){
first_start = i;
break;
}
}
for (var i = first_start + 1 ; i < lg; i++){
var mail_split = table_list[i].split("\t");
if(table_list[i].length>0&&table_list[i].indexOf("权限类型")== -1&&table_list[i].indexOf("权限过期策略")==-1&&table_list[i].indexOf("过期之后如有需要")== -1&&table_list[i].indexOf("本邮件发自")== -1&&table_list[i].indexOf("注意")== -1)
{
text += `\nleft join` + `\n(\n\tSELECT pt \n\tFROM ${mail_split[2]}\n\tWHERE pt = '${yesterday}'\n\tlimit 1\n) t${i+1} \non t1.pt = t${i+1}.pt` ;
text_1 += ` SELECT pt FROM ${mail_split[2]} WHERE pt = '${yesterday}' limit 1;\n` ;
}
}
var mail_split_2 = table_list[first_start].split("\t");
var first_text = `\n(\n\tSELECT pt \n\tFROM ${mail_split_2[2]}\n\tWHERE pt = '${yesterday}'\n\tlimit 1\n) t1` ;
var first_text_1 = `SELECT pt FROM ${mail_split_2[2]} WHERE pt = '${yesterday}' limit 1;\n` ;
}
var tObj = document.getElementById('textarea');
if(raw_text.length > 0 && leftclose == 2){
tObj.value = 'SELECT t1.pt\nFROM' + first_text + text + '\n;';
}
else if(raw_text.length > 0 && leftclose == 1){
tObj.value = first_text_1 + text_1;}
else{
tObj.value = '请输入表名!'
}
}
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
$(document).ready(function(){
$('[data-toggle="popover"]').popover({
placement : 'bottom',
trigger : 'hover',
html : true,
//content : '<img src="test.gif" style="width:100%">'
content : '在foxmail或者腾讯邮箱中点击表过期的邮件正文,全选(ctrl+A)复制粘贴即可!'
});
})
</script>
</body>
</html>