measure.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962
  1. <!-- -->
  2. <template>
  3. <div class=''>
  4. <el-breadcrumb class="divi2" separator-class="el-icon-arrow-right">
  5. <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
  6. <el-breadcrumb-item :to="{ path: '/snoop-home'}">数据质量探测</el-breadcrumb-item>
  7. <el-breadcrumb-item>创建度量标准</el-breadcrumb-item>
  8. </el-breadcrumb>
  9. <el-divider class="divi"></el-divider>
  10. <div v-loading="loading">
  11. <el-steps :active="active" align-center finish-status="success" style="margin: 50px 20px 0px 10px;">
  12. <el-step title="选择目标" description="选择需要度量的目标数据集字段"></el-step>
  13. <el-step title="定义/选择模型" description="定义将应用于所选字段的语法检查逻辑"></el-step>
  14. <el-step title="分区配置" description="设置目标数据集的分区配置"></el-step>
  15. <el-step title="完成" description="设置模型的基本配置"></el-step>
  16. </el-steps>
  17. <div style=" margin: 10px 120px 0px 166px;height: 420px;">
  18. <el-row :gutter="50">
  19. <div v-if="active == 0">
  20. <el-col :span="8" style="height: 100% ">
  21. <h4>1.1 选择数据源</h4>
  22. <div style="height: 360px;border: 1px solid rgb(0, 0, 0);overflow: scroll; ">
  23. <div style="margin: 10px;"> <!-- 控制左边树形区域的下方的div -->
  24. <el-tree
  25. v-if="showTree"
  26. id='tree'
  27. node-key="subEquipmentid"
  28. :props="defaultProps"
  29. ref="tree"
  30. :load="loadTreeNode"
  31. lazy
  32. @node-click="treeNodeClick">
  33. <span class="custom-tree-node" slot-scope="{ node, data }">
  34. <span>
  35. <i :class="data.icon" style="margin-right: 4px"></i>{{ node.label }}
  36. </span>
  37. </span>
  38. </el-tree>
  39. </div>
  40. </div>
  41. </el-col>
  42. <el-col :span="16" style="height: 100%">
  43. <h4>1.2 选择字段</h4>
  44. <div style="height: 360px;border: 1px solid rgb(0, 0, 0) ;padding: 10px; overflow: auto;">
  45. <el-table
  46. ref="multipleTable"
  47. :data="tableData"
  48. tooltip-effect="dark"
  49. style="width: 100%"
  50. @selection-change="handleSelectionChange">
  51. <el-table-column
  52. type="selection"
  53. width="55">
  54. </el-table-column>
  55. <el-table-column
  56. prop="colname"
  57. label="列名"
  58. width="120">
  59. </el-table-column>
  60. <el-table-column
  61. prop="type"
  62. label="类型"
  63. width="120">
  64. </el-table-column>
  65. <el-table-column
  66. prop="comment"
  67. label="备注"
  68. show-overflow-tooltip>
  69. </el-table-column>
  70. </el-table>
  71. </div>
  72. </el-col>
  73. </div>
  74. <div v-if="active == 1">
  75. <el-col :span="16" style="height: 100%;margin-left: 160px;">
  76. <h4>2. 请选择下列其中一种分析模式 :</h4>
  77. <div style="height: 360px;border: 1px solid rgb(0, 0, 0) ;padding: 10px;overflow-scrolling: auto">
  78. <el-table
  79. :data="goal_info.chooseCloum"
  80. style="width: 100%">
  81. <el-table-column prop="colname" label="列名" width="120"></el-table-column>
  82. <el-table-column prop="type" label="类型" width="120"></el-table-column>
  83. <el-table-column prop="comment" label="rule" show-overflow-tooltip>
  84. <template slot="header" slot-scope="scope">
  85. <span>rule</span>
  86. <i class="el-icon-info"
  87. :class="isShowRules"
  88. @mouseover="isShowRules.showRules = true"
  89. @mouseleave="isShowRules.showRules = false"
  90. @click="showrule"
  91. ></i>
  92. </template>
  93. <!-- <template slot="header">-->
  94. <!-- <i class="el-icon-info"-->
  95. <!-- @mouseover="isShowRules.showRules = true"-->
  96. <!-- @mouseleave="isShowRules.showRules = false"-->
  97. <!-- @click="showrule"></i>-->
  98. <!-- </template>-->
  99. <template slot-scope="scope" style="width: 80%">
  100. <!-- <el-button type="text" size="small" @click="userwatch(scope)">查看-->
  101. <!-- </el-button>-->
  102. <el-select
  103. v-model="scope.row.rule"
  104. multiple
  105. filterable
  106. style="width: 80%"
  107. placeholder="请选择">
  108. <el-option-group
  109. v-for="group in scope.row.dropdownList"
  110. :key="group.label"
  111. :label="group.label"
  112. >
  113. <el-option
  114. v-for="item in group.options"
  115. :key="item.value"
  116. :label="item.label"
  117. :value="item.value">
  118. </el-option>
  119. </el-option-group>
  120. </el-select>
  121. </template>
  122. </el-table-column>
  123. </el-table>
  124. </div>
  125. </el-col>
  126. </div>
  127. <div v-if="active == 2">
  128. <el-col :span="16" style="height: 100%;margin-left: 160px;">
  129. <h4>3. 配置信息 :</h4>
  130. <div style="height: 360px;overflow-scrolling: auto">
  131. <h5>度量配置 : </h5>
  132. <el-form ref="form" :model="datacForm" label-width="100px" :rules="rules">
  133. <el-form-item label="度量名称 :" prop="name">
  134. <el-input v-model="datacForm.name"></el-input>
  135. </el-form-item>
  136. <el-form-item label="度量描述 :">
  137. <el-input v-model="datacForm.description" onkeyup="this.value=this.value.replace(/[\u4E00-\u9FA5]/g,'')"></el-input>
  138. </el-form-item>
  139. <h5>数据源配置 : </h5>
  140. <el-form-item label="查询条件 :">
  141. <el-input v-model="datacForm.where"></el-input>
  142. </el-form-item>
  143. <el-form-item label="分区大小 :">
  144. <el-input-number v-model="datacForm.num" controls-position="right" :min="0"></el-input-number>
  145. <el-select v-model="datacForm.timetype" placeholder="请选择">
  146. <el-option label="day" value="day"></el-option>
  147. <el-option label="hour" value="hour"></el-option>
  148. <el-option label="minute" value="minute"></el-option>
  149. </el-select>
  150. </el-form-item>
  151. <el-form-item label="时 区 :">
  152. <el-select v-model="datacForm.timezone" placeholder="请选择">
  153. <el-option
  154. v-for="item in timezones"
  155. :key="item.value"
  156. :label="item.label"
  157. :value="item.value">
  158. </el-option>
  159. </el-select>
  160. </el-form-item>
  161. </el-form>
  162. </div>
  163. </el-col>
  164. </div>
  165. <div v-if="active == 3">
  166. <el-col :span="16" style="height: 100%;margin-left: 160px;">
  167. <h4>4. 信息校对 :</h4>
  168. <div style="height: 360px;overflow-scrolling: auto">
  169. <el-form ref="measureform" :model="goal_info" label-width="100px" :rules="rules">
  170. <el-form-item label="度量名称 :" prop="name">
  171. <!-- <el-input v-model="goal_info.config.name"></el-input>-->
  172. <span>{{ goal_info.config.name }}</span>
  173. </el-form-item>
  174. <el-form-item label="度量描述 :">
  175. <span>{{ goal_info.config.description }}</span>
  176. <!-- <el-input v-model="goal_info.config.description"></el-input>-->
  177. </el-form-item>
  178. <el-form-item label="数据源 :">
  179. <span>{{ goal_info.equipment.name }}</span>
  180. <!-- <el-input v-model="goal_info.equipment.name"></el-input>-->
  181. </el-form-item>
  182. <!-- <el-form-item label="查询条件 :">-->
  183. <!-- <span>{{goal_info.config.where}}</span>-->
  184. <!--&lt;!&ndash; <el-input v-model="goal_info.config.where"></el-input>&ndash;&gt;-->
  185. <!-- </el-form-item>-->
  186. <el-form-item label="分区信息 :">
  187. <span>{{goal_info.config.num + " " + goal_info.config.timetype + " " + goal_info.config.timezone}}</span>
  188. <!-- <el-input v-model="goal_info.config.num" >{{goal_info.config.num + goal_info.config.timetype}}</el-input>-->
  189. <!-- <el-input v-model="goal_info.config.timezone"></el-input>-->
  190. </el-form-item>
  191. <el-form-item label="度量规则 :">
  192. <!-- <el-input-number v-model="datacForm.num" controls-position="right" :min="0"></el-input-number>-->
  193. <div style="height: 100px;overflow: auto">
  194. <template v-for="rule in goal_info.chooseCloum">
  195. <li>{{ rule.colname }} : {{ rule.rule }}</li>
  196. </template>
  197. <!-- <template v-for="rule in timezones" >-->
  198. <!-- <li>{{rule.label}} : {{rule.value}}</li>-->
  199. <!-- </template>-->
  200. </div>
  201. </el-form-item>
  202. </el-form>
  203. </div>
  204. </el-col>
  205. </div>
  206. </el-row>
  207. </div>
  208. <el-form :inline="true">
  209. <el-form-item style="float:left">
  210. <el-button type="primary" @click="preStey()" :disabled = bottonDisable.pre>上一步</el-button>
  211. </el-form-item>
  212. <el-form-item style="float:right">
  213. <el-button v-if="!buttonFinish" ref="buttonFinish" type="primary" @click="next()" :disabled = bottonDisable.next>下一步</el-button>
  214. <el-button v-if="buttonFinish" type="primary" @click="submitForm()" >完成</el-button>
  215. </el-form-item>
  216. </el-form>
  217. </div>
  218. <show-rules v-if="isShowRulesDrog" ref="ShowRulesDrogref"></show-rules>
  219. </div>
  220. </template>
  221. <script>
  222. // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  223. // 例如:import 《组件名称》 from '《组件路径》';
  224. import showRules from './showRules'
  225. import { MessageBox } from 'element-ui'
  226. import { Message } from 'element-ui'
  227. export default {
  228. created () {
  229. },
  230. components: {
  231. showRules
  232. },
  233. data () {
  234. return {
  235. value: [],
  236. loading: false,
  237. showTree: true,
  238. visible: false,
  239. chooseEqpment: '',
  240. active: 0,
  241. goal_info: {},
  242. hiveTable: '',
  243. userID: this.$store.state.user.id, // 用户编号
  244. // userName: this.$store.state.user.name, // 用户编号
  245. userName: 'test', // 用户编号
  246. submit: false,
  247. isShowRules: {
  248. showRules: false
  249. },
  250. transrule: [],
  251. transenumrule: [],
  252. transnullrule: [],
  253. transregexrule: [],
  254. newMeasure: {},
  255. rulesDesc: [],
  256. buttonFinish: false,
  257. bottonDisable: {
  258. pre: true,
  259. next: true
  260. },
  261. rules: {
  262. name: [
  263. {required: true, message: '请输入度量名称', trigger: 'blur'},
  264. {min: 3, max: 18, message: '长度在 3 到 18 个字符', trigger: 'blur'}
  265. ]
  266. },
  267. isShowRulesDrog: false,
  268. datacForm: {
  269. name: '',
  270. description: '',
  271. where: '',
  272. timezone: '',
  273. num: 1,
  274. timetype: 'day',
  275. needpath: false,
  276. path: ''
  277. },
  278. options_int: [{
  279. label: 'Simple Statistics',
  280. options: [{
  281. id: 1,
  282. value: 'Null Count',
  283. label: 'Null Count'
  284. }, {
  285. id: 2,
  286. value: 'Distinct Count',
  287. label: 'Distinct Count'
  288. }]
  289. }, {
  290. label: 'Summary Statistics',
  291. options: [{
  292. id: 3,
  293. value: 'Total Count',
  294. label: 'Total Count'
  295. }, {
  296. id: 4,
  297. value: 'Maximum',
  298. label: 'Maximum'
  299. }, {
  300. id: 5,
  301. value: 'Minimum',
  302. label: 'Minimum'
  303. }, {
  304. id: 6,
  305. value: 'Average',
  306. label: 'Average'
  307. }]
  308. }, {
  309. label: 'Advanced Statistics',
  310. options: [{
  311. id: 7,
  312. value: 'Enum Detection Top10 Count',
  313. label: 'Enum Detection Top10 Count'
  314. }]
  315. }
  316. ],
  317. options_str: [{
  318. label: 'Simple Statistics',
  319. options: [{
  320. id: 1,
  321. value: 'Null Count',
  322. label: 'Null Count'
  323. }, {
  324. id: 2,
  325. value: 'Distinct Count',
  326. label: 'Distinct Count'
  327. }]
  328. }, {
  329. label: 'Summary Statistics',
  330. options: [{
  331. id: 3,
  332. value: 'Total Count',
  333. label: 'Total Count'
  334. }]
  335. }, {
  336. label: 'Advanced Statistics',
  337. options: [{
  338. id: 9,
  339. value: 'Enum Detection Top10 Count',
  340. label: 'Enum Detection Top10 Count'
  341. }]
  342. }
  343. ],
  344. treedata: [{ // 左侧默认树数据'
  345. icon: 'el-icon-success',
  346. name: '煤矿',
  347. limit: '',
  348. children: [{
  349. name: '系统',
  350. limit: '',
  351. children: [{
  352. name: '子系统',
  353. limit: '',
  354. children: [{
  355. name: '设备',
  356. limit: '',
  357. children: [{
  358. name: '子设备',
  359. limit: ''
  360. }]
  361. }]
  362. }]
  363. }]
  364. }, {
  365. name: '系统666',
  366. limit: '',
  367. children: [{
  368. name: '设备2',
  369. limit: ''
  370. }]
  371. }],
  372. defaultProps: {
  373. children: 'children',
  374. label: 'name',
  375. isLeaf: 'leaf'
  376. },
  377. tableData: [],
  378. timezones: [
  379. {label: 'UTC-12(IDL)', value: 'GMT-12'},
  380. {label: 'UTC-11(MIT)', value: 'GMT-11'},
  381. {label: 'UTC-10(HST)', value: 'GMT-10'},
  382. {label: 'UTC-9:30(MSIT)', value: 'GMT-9:30'},
  383. {label: 'UTC-9(AKST)', value: 'GMT-9'},
  384. {label: 'UTC-8(PST)', value: 'GMT-8'},
  385. {label: 'UTC-7(MST)', value: 'GMT-7'},
  386. {label: 'UTC-6(CST)', value: 'GMT-6'},
  387. {label: 'UTC-5(EST)', value: 'GMT-5'},
  388. {label: 'UTC-4(AST)', value: 'GMT-4'},
  389. {label: 'UTC-3:30(NST)', value: 'GMT-3:30'},
  390. {label: 'UTC-3(SAT)', value: 'GMT-3'},
  391. {label: 'UTC-2(BRT)', value: 'GMT-2'},
  392. {label: 'UTC-1(CVT)', value: 'GMT-1'},
  393. {label: 'UTC(WET,GMT)', value: 'GMT'},
  394. {label: 'UTC+1(CET)', value: 'GMT+1'},
  395. {label: 'UTC+2(EET)', value: 'GMT+2'},
  396. {label: 'UTC+3(MSK)', value: 'GMT+3'},
  397. {label: 'UTC+3:30(IRT)', value: 'GMT+3:30'},
  398. {label: 'UTC+4(META)', value: 'GMT+4'},
  399. {label: 'UTC+4:30(AFT)', value: 'GMT+4:30'},
  400. {label: 'UTC+5(METB)', value: 'GMT+5'},
  401. {label: 'UTC+5:30(IDT)', value: 'GMT+5:30'},
  402. {label: 'UTC+5:45(NPT)', value: 'GMT+5:45'},
  403. {label: 'UTC+6(BHT)', value: 'GMT+6'},
  404. {label: 'UTC+6:30(MRT)', value: 'GMT+6:30'},
  405. {label: 'UTC+7(IST)', value: 'GMT+7'},
  406. {label: 'UTC+8(EAT)', value: 'GMT+8'},
  407. {label: 'UTC+8:30(KRT)', value: 'GMT+8:30'},
  408. {label: 'UTC+9(FET)', value: 'GMT+9'},
  409. {label: 'UTC+9:30(ACST)', value: 'GMT+9:30'},
  410. {label: 'UTC+10(AEST)', value: 'GMT+10'},
  411. {label: 'UTC+10:30(FAST)', value: 'GMT+10:30'},
  412. {label: 'UTC+11(VTT)', value: 'GMT+11'},
  413. {label: 'UTC+11:30(NFT)', value: 'GMT+11:30'},
  414. {label: 'UTC+12(PSTB)', value: 'GMT+12'},
  415. {label: 'UTC+12:45(CIT)', value: 'GMT+12:45'},
  416. {label: 'UTC+13(PSTC)', value: 'GMT+13'},
  417. {label: 'UTC+14(PSTD)', value: 'GMT+14'}
  418. ]
  419. }
  420. },
  421. methods: {
  422. next () {
  423. // if (this.active++ > 2) this.active = 0
  424. this.active++
  425. switch (this.active) {
  426. case 0 :
  427. // console.log('000')
  428. break
  429. case 1 :
  430. this.bottonDisable.pre = false
  431. break
  432. case 2 :
  433. break
  434. case 3 :
  435. this.goal_info.config = this.datacForm
  436. this.buttonFinish = true
  437. // console.info(this.$refs.buttonFinish)
  438. break
  439. default :
  440. // console.log('000')
  441. }
  442. },
  443. preStey () {
  444. // if (this.active-- < 0) this.active = 3
  445. this.active--
  446. this.buttonFinish = false
  447. if (this.active <= 0) {
  448. this.bottonDisable.pre = true
  449. this.bottonDisable.next = true
  450. }
  451. },
  452. treeNodeClick (data, node) {
  453. this.tableData = []
  454. if (data.limit === 'children') {
  455. // node.data.icon = 'iconfont icon-xitong4'
  456. this.chooseEqpment = data
  457. // 进行ajax 请求
  458. this.hiveTable = 'ods_' + this.chooseEqpment.hbaseTableName.replaceAll('-', '_')
  459. // table = this.chooseEqpment.hbaseTableName
  460. console.log(this.hiveTable)
  461. var info = {
  462. db: 'db=bigdatawh',
  463. table: 'table=' + this.hiveTable
  464. }
  465. this.$http({
  466. url: this.$http.adornUrl('/v1/metadata/hive/table?') + info.db + '&' + info.table,
  467. method: 'get'
  468. }).then((data) => {
  469. if (data.status === 200) {
  470. var res = data.data.sd.cols
  471. for (const resKey in res) {
  472. var table = {
  473. colname: res[resKey].name,
  474. type: res[resKey].type,
  475. comment: res[resKey].comment
  476. }
  477. this.tableData.push(table)
  478. }
  479. } else {
  480. Message({
  481. message: '获取 ' + this.chooseEqpment.name + ' 列数据失败',
  482. type: 'error'
  483. })
  484. }
  485. })
  486. // this.tableData = [{
  487. // colname: 'id',
  488. // type: 'bigint',
  489. // comment: '测试字段1'
  490. // }, {
  491. // colname: 'age',
  492. // type: 'int',
  493. // comment: '测试字段2'
  494. // }, {
  495. // colname: 'desc',
  496. // type: 'string',
  497. // comment: '测试字段3'
  498. // }]
  499. }
  500. },
  501. handleSelectionChange (data) {
  502. if (data.length > 0) {
  503. this.bottonDisable.next = false
  504. } else {
  505. this.bottonDisable.next = true
  506. }
  507. this.goal_info = {
  508. equipment: this.chooseEqpment,
  509. chooseCloum: data
  510. }
  511. // chooseCloum.cloum = data
  512. var patt = new RegExp('int|double|float/i')
  513. if (patt.test(this.type)) {
  514. this.isNum = true
  515. }
  516. for (let da of data) {
  517. if (patt.test(da.type)) {
  518. da.isNum = true
  519. da.dropdownList = this.options_int
  520. } else {
  521. da.isNum = false
  522. da.dropdownList = this.options_str
  523. }
  524. }
  525. },
  526. showrule () {
  527. this.isShowRulesDrog = true
  528. this.$nextTick(() => {
  529. this.$refs.ShowRulesDrogref.init()
  530. })
  531. },
  532. // 向后台提交数据
  533. async finallySubmit () {
  534. this.loading = true
  535. this.newMeasure = {
  536. 'name': this.goal_info.config.name,
  537. 'measure.type': 'griffin',
  538. 'dq.type': 'PROFILING',
  539. 'rule.description': {
  540. 'details': this.rulesDesc
  541. },
  542. 'process.type': 'BATCH',
  543. 'owner': this.userName,
  544. 'description': this.goal_info.config.description,
  545. 'data.sources': [
  546. {
  547. 'name': 'source',
  548. 'connector': {
  549. 'name': 'source' + new Date().getTime(),
  550. 'type': 'HIVE',
  551. 'version': '1.2',
  552. 'data.unit': this.goal_info.config.num + this.goal_info.config.timetype,
  553. 'data.time.zone': this.goal_info.config.timezone,
  554. 'config': {
  555. 'database': 'bigdatawh',
  556. 'table.name': this.hiveTable,
  557. // 'database': 'default',
  558. // 'table.name': 'demo_src',
  559. 'where': this.goal_info.config.where
  560. }
  561. }
  562. }
  563. ],
  564. 'evaluate.rule': {
  565. 'out.dataframe.name': 'profiling',
  566. rules: []
  567. }
  568. }
  569. this.getGrouprule()
  570. // console.log(666)
  571. // console.log(this.newMeasure)
  572. await this.$http({
  573. url: this.$http.adornUrl('/v1/measures'),
  574. method: 'post',
  575. data: this.$http.adornData(this.newMeasure)
  576. }).then((datas) => {
  577. console.log(datas)
  578. if (datas.status === 201) {
  579. this.submit = true
  580. } else {
  581. this.submit = false
  582. }
  583. })
  584. },
  585. submitForm () {
  586. this.finallySubmit()
  587. setTimeout(() => {
  588. this.loading = true
  589. if (this.submit) {
  590. Message({
  591. message: '度量标准 ' + this.datacForm.name + ' 创建成功',
  592. type: 'success'
  593. })
  594. } else {
  595. Message({
  596. message: '度量标准 ' + this.datacForm.name + ' 创建失败',
  597. type: 'error'
  598. })
  599. }
  600. this.loading = false
  601. this.$router.replace({path: '/snoop-home', query: {'status': '0'}})
  602. this.$destroy()
  603. }, 2 * 1000)
  604. },
  605. getGrouprule () {
  606. var selected = {name: ''}
  607. var value = ''
  608. var nullvalue = ''
  609. var nullname = ''
  610. var enmvalue = ''
  611. var regexvalue = ''
  612. var regexname = ''
  613. var grpname = ''
  614. for (const key in this.goal_info.chooseCloum) {
  615. selected.name = this.goal_info.chooseCloum[key].colname
  616. let info = ''
  617. let otherinfo = ''
  618. for (let i = 0; i < this.goal_info.chooseCloum[key].rule.length; i++) {
  619. const originrule = this.goal_info.chooseCloum[key].rule[i]
  620. info = info + originrule + ','
  621. if (originrule === 'Enum Detection Top10 Count') {
  622. enmvalue = this.transferRule(originrule, selected)
  623. grpname = `${selected.name}_top10count`
  624. this.transenumrule.push(enmvalue)
  625. this.pushEnmRule(enmvalue, grpname)
  626. } else if (originrule === 'Null Count') {
  627. nullvalue = this.transferRule(originrule, selected)
  628. nullname = `${selected.name}_nullcount`
  629. this.transnullrule.push(nullvalue)
  630. this.pushNullRule(nullvalue, nullname)
  631. } else if (originrule === 'Empty Count') {
  632. nullvalue = this.transferRule(originrule, selected)
  633. nullname = `${selected.name}_emptycount`
  634. this.transnullrule.push(nullvalue)
  635. this.pushNullRule(nullvalue, nullname)
  636. } else if (originrule === 'Regular Expression Detection Count') {
  637. selected['regex'] = ''
  638. regexvalue = this.transferRule(originrule, selected)
  639. regexname = `${selected.name}_regexcount`
  640. this.transregexrule.push(regexvalue)
  641. this.pushRegexRule(regexvalue, regexname)
  642. } else {
  643. otherinfo = otherinfo + originrule + ','
  644. value = this.transferRule(originrule, selected)
  645. this.transrule.push(value)
  646. }
  647. }
  648. info = info.substring(0, info.lastIndexOf(','))
  649. this.rulesDesc.push({
  650. name: this.goal_info.chooseCloum[key].colname,
  651. infos: info
  652. })
  653. }
  654. if (this.transrule.length !== 0) {
  655. this.getRule(this.transrule)
  656. }
  657. },
  658. getRule (trans) {
  659. var rule = ''
  660. for (let i of trans) {
  661. rule = rule + i + ','
  662. }
  663. rule = rule.substring(0, rule.lastIndexOf(','))
  664. this.pushRule(rule)
  665. },
  666. pushEnmRule (rule, grpname) {
  667. this.newMeasure['evaluate.rule'].rules.push({
  668. 'dsl.type': 'griffin-dsl',
  669. 'dq.type': 'PROFILING',
  670. rule: rule,
  671. 'out.dataframe.name': grpname,
  672. 'out': [
  673. {
  674. 'type': 'metric',
  675. 'name': grpname,
  676. 'flatten': 'array'
  677. }
  678. ]
  679. })
  680. },
  681. pushNullRule (rule, nullname) {
  682. this.newMeasure['evaluate.rule'].rules.push({
  683. 'dsl.type': 'griffin-dsl',
  684. 'dq.type': 'PROFILING',
  685. rule: rule,
  686. 'out.dataframe.name': nullname
  687. })
  688. },
  689. pushRegexRule (rule, nullname) {
  690. this.newMeasure['evaluate.rule'].rules.push({
  691. 'dsl.type': 'griffin-dsl',
  692. 'dq.type': 'PROFILING',
  693. rule: rule,
  694. 'out.dataframe.name': nullname
  695. })
  696. },
  697. pushRule (rule) {
  698. this.newMeasure['evaluate.rule'].rules.push({
  699. 'dsl.type': 'griffin-dsl',
  700. 'dq.type': 'PROFILING',
  701. rule: rule,
  702. name: 'profiling'
  703. })
  704. },
  705. transferRule (rule, col) {
  706. switch (rule) {
  707. case 'Total Count':
  708. return (
  709. `count(source.${col.name}) AS \`${col.name}_count\``
  710. )
  711. case 'Distinct Count':
  712. return (
  713. `approx_count_distinct(source.${col.name}) AS \`${col.name}_distcount\``
  714. )
  715. case 'Null Count':
  716. return (
  717. `count(source.${col.name}) AS \`${col.name}_nullcount\` WHERE source.${col.name} IS NULL`
  718. )
  719. case 'Maximum':
  720. return (
  721. `max(source.${col.name}) AS \`${col.name}_max\``
  722. )
  723. case 'Minimum':
  724. return (
  725. `min(source.${col.name}) AS \`${col.name}_min\``
  726. )
  727. case 'Average':
  728. return (
  729. `avg(source.${col.name}) AS \`${col.name}_average\``
  730. )
  731. case 'Empty Count':
  732. return (
  733. `count(source.${col.name}) AS \`${col.name}_emptycount\` WHERE source.${col.name} = ''`
  734. )
  735. case 'Regular Expression Detection Count':
  736. return (
  737. `count(source.${col.name}) AS \`${col.name}_regexcount\` WHERE source.${col.name} RLIKE '^[0-9]{4}$'`
  738. )
  739. case 'Enum Detection Top10 Count':
  740. return (
  741. `source.${col.name} AS ${col.name}, count(*) AS count GROUP BY source.${col.name} ORDER BY count DESC LIMIT 10`
  742. )
  743. }
  744. },
  745. getCoal (resolve) {
  746. var coalData = {
  747. userID: this.userID
  748. }
  749. let coalAll = []
  750. this.$http({
  751. url: this.$http.adornUrl('/dataset/tree/getcoal'),
  752. method: 'post',
  753. data: this.$http.adornData(coalData, false)
  754. }).then(({data}) => {
  755. const coalContent = data.info
  756. for (let sign = 0; sign < coalContent.length; sign++) {
  757. var coal = {
  758. name: coalContent[sign].name,
  759. coalid: coalContent[sign].id,
  760. limit: 'coal',
  761. hbaseTableName: '',
  762. icon: 'iconfont icon-xitongfuwu',
  763. leaf: false
  764. }
  765. coalAll.push(coal)
  766. }
  767. return resolve(coalAll)
  768. // console.log('***************')
  769. // console.log(coalAll)
  770. })
  771. },
  772. getSystem (coalId, resolve) {
  773. var coalData = {
  774. userID: this.userID,
  775. coalid: coalId
  776. }
  777. this.$http({
  778. url: this.$http.adornUrl('/dataset/tree/getfisystem'),
  779. method: 'post',
  780. data: this.$http.adornData(coalData, false)
  781. }).then(systemRespond => {
  782. let systemAll = []
  783. const systemContent = systemRespond.data
  784. for (let i = 0; i < systemContent.length; i++) {
  785. var system = {
  786. name: systemContent[i].name,
  787. systemid: systemContent[i].id,
  788. limit: 'system',
  789. icon: 'icon iconfont icon-xitongfuwu',
  790. hbaseTableName: '',
  791. leaf: false
  792. }
  793. systemAll.push(system)
  794. }
  795. return resolve(systemAll)
  796. })
  797. },
  798. getSubSystem (systemid, resolve) {
  799. const systemData = {
  800. systemid: systemid,
  801. userID: this.userID
  802. }
  803. this.$http({
  804. url: this.$http.adornUrl('/dataset/tree/getsubSystem'),
  805. method: 'post',
  806. data: this.$http.adornData(systemData, false)
  807. }).then(subrespond => {
  808. let subSystemAll = []
  809. let subSystemContent = subrespond.data
  810. for (let j = 0; j < subSystemContent.length; j++) {
  811. var subSystem = {
  812. name: subSystemContent[j].name,
  813. subSustemid: subSystemContent[j].id,
  814. limit: 'subSystem',
  815. icon: 'iconfont icon-xitongfuwu',
  816. leaf: false
  817. }
  818. subSystemAll.push(subSystem)
  819. }
  820. return resolve(subSystemAll)
  821. })
  822. },
  823. getEquipment (subSustemid, resolve) {
  824. const subSystemData = {
  825. subSystemid: subSustemid,
  826. userID: this.userID
  827. }
  828. this.$http({
  829. url: this.$http.adornUrl('/dataset/tree/getequipment'),
  830. method: 'post',
  831. data: this.$http.adornData(subSystemData, false)
  832. }).then(eqprespond => {
  833. let equipmentAll = []
  834. const eqpSystemContent = eqprespond.data
  835. if (eqpSystemContent.length !== 0) {
  836. for (let k = 0; k < eqpSystemContent.length; k++) {
  837. var equipment = {
  838. name: eqpSystemContent[k].name,
  839. equipmentid: eqpSystemContent[k].id,
  840. limit: 'equipment',
  841. hbaseTableName: '',
  842. icon: 'iconfont icon-xitongfuwu',
  843. leaf: false
  844. }
  845. equipmentAll.push(equipment)
  846. }
  847. }
  848. return resolve(equipmentAll)
  849. })
  850. },
  851. getSubEquipment (equipmentid, resolve) {
  852. const equimentData = {
  853. userID: this.userID,
  854. equipment: equipmentid
  855. }
  856. this.$http({
  857. url: this.$http.adornUrl('/dataset/tree/getsubequipment'),
  858. method: 'post',
  859. data: this.$http.adornData(equimentData, false)
  860. }).then(subEqpRespond => {
  861. let subEquimentAll = []
  862. const subEqpSystemContent = subEqpRespond.data
  863. for (let m = 0; m < subEqpSystemContent.length; m++) {
  864. var subEquiment = {
  865. name: subEqpSystemContent[m].name,
  866. subEquipmentid: subEqpSystemContent[m].id,
  867. hbaseTableName: subEqpSystemContent[m].hbaseTableName,
  868. limit: 'children',
  869. icon: 'iconfont icon-xitong3',
  870. leaf: true
  871. }
  872. subEquimentAll.push(subEquiment)
  873. }
  874. return resolve(subEquimentAll)
  875. })
  876. },
  877. // 左侧树的懒加载 五层结构
  878. loadTreeNode (node, resolve) {
  879. if (node.level === 0) {
  880. this.getCoal(resolve)
  881. } else if (node.level === 1) {
  882. this.getSystem(node.data.coalid, resolve)
  883. } else if (node.level === 2) {
  884. this.getSubSystem(node.data.systemid, resolve)
  885. } else if (node.level === 3) {
  886. this.getEquipment(node.data.subSustemid, resolve)
  887. } else {
  888. this.getSubEquipment(node.data.equipmentid, resolve)
  889. }
  890. }
  891. // // 左侧树的懒加载 三层结构
  892. // loadTreeNode (node, resolve) {
  893. // if (node.level === 0) {
  894. // this.getSubSystem(resolve)
  895. // } else if (node.level === 1) {
  896. // this.getEquipment(node.data.subSustemid, resolve)
  897. // } else {
  898. // this.getSubEquipment(node.data.equipmentid, resolve)
  899. // }
  900. // }
  901. },
  902. watch: {
  903. chooseEqpment (newVal, oldVal) {
  904. if (oldVal.hasOwnProperty('icon')) {
  905. oldVal.icon = 'iconfont icon-xitong3'
  906. }
  907. newVal.icon = 'iconfont icon-xitong4'
  908. }
  909. }
  910. }
  911. </script>
  912. <style scoped>
  913. .divi {
  914. display: block;
  915. height: 1px;
  916. width: 100%;
  917. margin: 24px 0;
  918. background-color: #dcdfe6;
  919. position: relative;
  920. }
  921. .divi2 {
  922. display: block;
  923. height: 1px;
  924. width: 100%;
  925. position: relative;
  926. }
  927. .showRules {
  928. color: #409eff
  929. }
  930. </style>