measure.vue 32 KB

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