StatisticalAnalysis.vue 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358
  1. <template>
  2. <div class="mainBox" v-loading="getDataStatus">
  3. <!-- 搜索区域 -->
  4. <div class="searchBox">
  5. <div style="font-size: large">
  6. <!-- 对比时间:
  7. <el-date-picker
  8. v-model="lastTimes"
  9. type="daterange"
  10. unlink-panels
  11. range-separator="到"
  12. start-placeholder="开始时间"
  13. end-placeholder="结束时间"
  14. disabled
  15. size="large"
  16. style="margin-right: 30px"
  17. /> -->
  18. 搜索时间:
  19. <el-date-picker
  20. v-model="nowTimes"
  21. type="daterange"
  22. :clearable="false"
  23. unlink-panels
  24. range-separator="到"
  25. start-placeholder="开始时间"
  26. end-placeholder="结束时间"
  27. :shortcuts="shortcutsFun"
  28. size="large"
  29. />
  30. </div>
  31. </div>
  32. <!-- 服务调用card -->
  33. <div class="flex">
  34. <card
  35. v-for="item in TopCardDatas"
  36. :key="item.name"
  37. class="card flex"
  38. :title="item.name"
  39. :value="item.value"
  40. :growth="item.growth"
  41. :iconName="item.iconName"
  42. :iconColor="item.iconColor"
  43. :upStatus="item.upStatus"
  44. />
  45. </div>
  46. <!-- 服务类信息统计 -->
  47. <div class="bigCard">
  48. <div class="bigCard_title">服务类信息统计</div>
  49. <div class="tools">
  50. <el-button @click="downFileAllServiceDatas" :disabled="exportLoading">
  51. <!-- 这个要查询查询时间范围内的所有服务数据 -->
  52. <el-icon v-if="!exportLoading"><Upload /></el-icon>
  53. <el-icon v-else><Loading class="loading-icon" /></el-icon>
  54. 导出数据
  55. </el-button>
  56. <el-button :disabled="dialogLoading" type="primary" @click="showDetailReport">
  57. <!-- 这个直接弹窗展示所有的服务调用数据,而不是下载 -->
  58. <el-icon v-if="!dialogLoading"><TrendCharts /></el-icon>
  59. <!-- 让图标旋转 -->
  60. <el-icon v-else><Loading class="loading-icon" /></el-icon>
  61. 详细报告
  62. </el-button>
  63. </div>
  64. <div class="flex">
  65. <div style="width: 48%; height: 400px">
  66. <EchartsDome :chartOption="chartOptions['服务调用趋势']" title="服务调用趋势" />
  67. </div>
  68. <div style="width: 48%; height: 400px">
  69. <EchartsDome title="服务类别分布" :chartOption="chartOptions['服务类别分布']" />
  70. </div>
  71. </div>
  72. <div style="width: 100%; height: 400px">
  73. <Table title="服务调用TOP10" :tableData="tableDatas" />
  74. </div>
  75. </div>
  76. <!-- 服务调用详情弹窗 -->
  77. <el-dialog
  78. v-model="showServerDetailReport"
  79. width="80%"
  80. :close-on-click-modal="false"
  81. :close-on-press-escape="false"
  82. :show-close="true"
  83. title="服务调用详情"
  84. >
  85. <div style="width: 100%; position: relative; padding-bottom: 30px" v-loading="dialogLoading">
  86. <!-- 过滤条件,全字段(除了调用时间)下拉框选择 -->
  87. <div style="width: 100%; margin-bottom: 10px; z-index: 1000">
  88. <!-- 再添加一个调用次数筛选 -->
  89. <div style="display: flex; align-items: center; margin-bottom: 10px">
  90. <span style="margin-right: 10px">调用次数:</span>
  91. <el-slider
  92. v-model="selectedModel['count']"
  93. :min="countMin"
  94. :max="countMax"
  95. range
  96. @change="changeSelectModel"
  97. style="width: calc(60%); margin: 0 20px"
  98. />
  99. 最小值:
  100. <el-input-number
  101. v-model="selectedModel.count[0]"
  102. :min="countMin"
  103. :max="selectedModel.count[1]"
  104. @change="changeSelectModel"
  105. />
  106. 最大值:
  107. <el-input-number
  108. v-model="selectedModel.count[1]"
  109. :min="selectedModel.count[0]"
  110. :max="countMax"
  111. @change="changeSelectModel"
  112. />
  113. </div>
  114. <!-- 支持筛选条件清空 -->
  115. <el-select
  116. style="width: 200px; margin-right: 10px"
  117. v-for="(value, key, index) in selectOptions"
  118. :key="key + index"
  119. v-model="selectedModel[key]"
  120. @change="changeSelectModel"
  121. :placeholder="'请选择' + selectKeyName[key]"
  122. filterable
  123. clearable
  124. >
  125. <el-option v-for="item in value" :key="item" :label="item" :value="item" />
  126. </el-select>
  127. <!-- 再添加一个时间搜索范围,字段是date, 格式是YYYY-MM-DD -->
  128. <el-date-picker
  129. style="margin-right: 10px"
  130. v-model="selectedModel['date']"
  131. type="daterange"
  132. clearable
  133. unlink-panels
  134. @change="changeSelectModel"
  135. :disabled-date="disabledDate"
  136. range-separator="到"
  137. start-placeholder="开始时间"
  138. end-placeholder="结束时间"
  139. />
  140. <!-- 重置按钮 -->
  141. <el-button type="primary" @click="resetSelectModel">重置</el-button>
  142. </div>
  143. <el-table
  144. :data="showServerData"
  145. style="width: 100%"
  146. height="500px"
  147. border
  148. fit
  149. highlight-current-row
  150. >
  151. <el-table-column prop="application" label="应用名称" />
  152. <el-table-column prop="path_comment" label="服务名称" />
  153. <el-table-column prop="unit" label="委办单位" width="200" />
  154. <el-table-column prop="type" label="服务类别" width="120" />
  155. <el-table-column prop="count" label="调用次数" width="100" />
  156. <el-table-column prop="date" label="调用时间" width="120" />
  157. </el-table>
  158. <div style="float: right; padding-top: 10px">
  159. <el-pagination
  160. v-model:current-page="currentPage"
  161. v-model:page-size="pageSize"
  162. :page-sizes="[50, 100, 200, 500]"
  163. background
  164. layout="total, sizes, prev, pager, next, jumper"
  165. :total="tableDataTotal"
  166. @size-change="handleSizeChange"
  167. @current-change="handleCurrentChange"
  168. />
  169. </div>
  170. </div>
  171. </el-dialog>
  172. <!-- 委办信息统计 -->
  173. <div class="bigCard">
  174. <div class="bigCard_title">委办信息统计</div>
  175. <div class="flex">
  176. <div style="width: 28%; height: 400px">
  177. <EchartsDome :chartOption="chartOptions['委办分布']" title="委办分布" />
  178. </div>
  179. <div style="width: 68%; height: 400px">
  180. <EchartsDome :chartOption="chartOptions['委办活跃度趋势']" title="委办活跃度趋势" />
  181. </div>
  182. </div>
  183. <!-- <div style="width: 100%; height: 400px">
  184. <EchartsDome :chartOption="chartOptions['用户部门分布']" title="用户部门分布" />
  185. </div> -->
  186. </div>
  187. <!-- 应用类信息统计 -->
  188. <div class="bigCard">
  189. <div class="bigCard_title">应用类信息统计</div>
  190. <div class="flex">
  191. <div style="width: 48%; height: 400px">
  192. <EchartsDome :chartOption="chartOptions['热点应用TOP10排名']" title="热点应用TOP10排名" />
  193. </div>
  194. <!-- <div style="width: 33%; height: 400px">
  195. <EchartsDome :chartOption="chartOptions['栏目统计分布']" title="栏目统计分布" />
  196. </div> -->
  197. <div style="width: 48%; height: 400px">
  198. <EchartsDome :chartOption="chartOptions['应用状态分布']" title="应用状态分布" />
  199. </div>
  200. </div>
  201. </div>
  202. <!-- 数据类信息统计 -->
  203. <div class="bigCard">
  204. <div class="bigCard_title">数据类信息统计</div>
  205. <div class="flex">
  206. <div style="width: 50%; height: 400px">
  207. <EchartsDome :chartOption="chartOptions['数据类别分布']" title="数据类别分布" />
  208. </div>
  209. <div style="width: 50%; height: 400px">
  210. <EchartsDome :chartOption="chartOptions['数据质量评分']" title="数据质量评分" />
  211. </div>
  212. </div>
  213. </div>
  214. <!-- 区级特色信息统计 -->
  215. <div class="bigCard">
  216. <div class="bigCard_title">区级特色信息统计</div>
  217. <div class="flex" style="margin-top: 20px">
  218. <div class="flex_column" style="width: 28%; height: 420px">
  219. <card
  220. class="card2 flex"
  221. :title="'服务机构总数'"
  222. value="8"
  223. :growth="'较上个月增长了12%'"
  224. iconColor="#2563db"
  225. :upStatus="1"
  226. />
  227. <card
  228. class="card2 flex"
  229. :title="'服务总数'"
  230. value="100"
  231. :growth="'较上个月下降了12%'"
  232. iconColor="#16a34a"
  233. :upStatus="-1"
  234. />
  235. <card
  236. class="card2 flex"
  237. :title="'服务调用总次数'"
  238. value="1000"
  239. :growth="'较上个月增长了12%'"
  240. iconColor="#9333ea"
  241. :upStatus="1"
  242. />
  243. </div>
  244. <div style="width: 68%; height: 420px">
  245. <EchartsDome :chartOption="chartOptions['服务调用趋势']" title="服务调用趋势" />
  246. </div>
  247. </div>
  248. </div>
  249. <!-- 验收版-隐藏 演示版-显示 -->
  250. <!-- <HomePage_Demo /> -->
  251. </div>
  252. </template>
  253. <script>
  254. import card from "@/components/yxgl/card.vue";
  255. import EchartsDome from "@/components/yxgl/EchartsDome.vue";
  256. import Table from "@/components/yxgl/table.vue";
  257. import appCenter from "@/api/appCenter";
  258. import { countlmType } from "@/api/count";
  259. import HomePage_Demo from "@/views/HomePage_Demo.vue";
  260. export default {
  261. name: "",
  262. components: {
  263. card,
  264. EchartsDome,
  265. Table,
  266. HomePage_Demo,
  267. },
  268. data() {
  269. return {
  270. // 导出Loading状态
  271. exportLoading: false,
  272. // 弹窗加载状态
  273. dialogLoading: false,
  274. // 获取数据状态
  275. getDataStatus: false,
  276. // 比较的时间范围(默认60天到30天前,主要跟nowTimes有关系)
  277. lastTimes: [],
  278. // 当前选中的时间范围
  279. nowTimes: [],
  280. // 服务调用详情弹窗是否显示
  281. showServerDetailReport: false,
  282. // 服务调用详情数据
  283. serverData: [],
  284. // 展示的详细数据(能根据时间和字段模糊筛选)
  285. showServerData: [],
  286. // 筛选条件下拉框选项
  287. selectOptions: {
  288. application: [],
  289. path_comment: [],
  290. unit: [],
  291. type: [],
  292. },
  293. selectKeyName: {
  294. application: "应用名称",
  295. path_comment: "服务名称",
  296. unit: "委办单位",
  297. count: "调用次数",
  298. type: "服务类型",
  299. },
  300. // 筛选条件下拉框选中的值
  301. selectedModel: {
  302. application: "",
  303. path_comment: "",
  304. unit: "",
  305. type: "",
  306. count: "",
  307. date: "",
  308. },
  309. // 调用次数范围的最小值和最大值
  310. countMin: 0,
  311. countMax: 0,
  312. tableColumns: ["application", "path_comment", "unit", "count", "type", "date"],
  313. // 分页大小
  314. pageSize: 50,
  315. // 当前页码
  316. currentPage: 1,
  317. // 表格数据总条数
  318. tableDataTotal: 0,
  319. TopCardDatas: [
  320. {
  321. name: "委办总数",
  322. value: "0",
  323. growth: "--",
  324. iconColor: "#2563db",
  325. iconName: "OfficeBuilding",
  326. upStatus: 0,
  327. },
  328. {
  329. name: "系统总数",
  330. value: "0",
  331. growth: "--",
  332. iconColor: "#16a34a",
  333. iconName: "WalletFilled",
  334. upStatus: 0,
  335. },
  336. {
  337. name: "服务总数",
  338. value: "0",
  339. growth: "--",
  340. iconColor: "#9333ea",
  341. iconName: "CollectionTag",
  342. upStatus: 0,
  343. },
  344. {
  345. name: "服务调用总数",
  346. value: "0",
  347. growth: "--",
  348. iconColor: "#ca8a04",
  349. iconName: "Paperclip",
  350. upStatus: 0,
  351. },
  352. ],
  353. shortcutsFun: this.shortcuts(),
  354. chartOptions: {},
  355. tableDatas: [],
  356. columnList: [],
  357. };
  358. },
  359. watch: {
  360. nowTimes: {
  361. handler(newVal, oldVal) {
  362. if (newVal !== oldVal && newVal.length > 0) {
  363. // 计算出比较的时间范围
  364. this.lastTimes = [
  365. this.$moment(
  366. new Date(
  367. new Date(newVal[0]).setTime(
  368. new Date(newVal[0]).getTime() - (newVal[1] - newVal[0]) - 24 * 60 * 60 * 1000
  369. )
  370. )
  371. ).format("YYYY-MM-DD 00:00:00"),
  372. this.$moment(new Date(newVal[0])).format("YYYY-MM-DD 00:00:00"),
  373. ];
  374. // this.getColumnListDate();
  375. this.initChart();
  376. // 栏目统计分布
  377. this.getColumnCount();
  378. }
  379. },
  380. deep: true,
  381. // immediate: true,
  382. },
  383. },
  384. mounted() {
  385. this.$nextTick(() => {
  386. this.nowTimes = [
  387. new Date(new Date().setTime(new Date() - 3600 * 1000 * 24 * 30)),
  388. new Date(),
  389. ];
  390. });
  391. },
  392. methods: {
  393. getColumnListDate(){
  394. let that = this;
  395. that.columnList = [];
  396. appCenter.getColumnListDate().then((res) => {
  397. // console.log("====getColumnListDate====="+res);
  398. if (res.code === 200) {
  399. // this.serverData = res.content;
  400. res.content.forEach(e => {
  401. that.getChildren(e)
  402. });
  403. }
  404. });
  405. },
  406. //递归查找子目录
  407. getChildren(e){
  408. let that = this;
  409. if(e.columnList.length>0){
  410. e.value=e.id
  411. e.label=e.title
  412. e.children = e.columnList;
  413. e.columnList.forEach(e2 => {
  414. that.getChildren(e2)
  415. });
  416. }else{
  417. e.value=e.modelId
  418. e.label=e.title
  419. e.children = []
  420. let str = {id:e.id,mid:e.modelId,title:e.title}
  421. that.columnList.push(str);
  422. }
  423. },
  424. // 禁用日期选择器中未来的日期(不能选择nowTimes以外的时间)
  425. disabledDate(time) {
  426. return (
  427. time.getTime() > this.nowTimes[1].getTime() ||
  428. time.getTime() < this.nowTimes[0].getTime() - 24 * 60 * 60 * 1000
  429. );
  430. },
  431. // 分页大小改变时,更新展示数据
  432. handleSizeChange() {
  433. this.dialogLoading = true;
  434. let searchDatas = this.serverData.filter((item) => {
  435. return (
  436. (!this.selectedModel.application ||
  437. item.application === this.selectedModel.application) &&
  438. (!this.selectedModel.path_comment ||
  439. item.path_comment === this.selectedModel.path_comment) &&
  440. (!this.selectedModel.unit || item.unit === this.selectedModel.unit) &&
  441. (!this.selectedModel.type || item.type === this.selectedModel.type)
  442. );
  443. });
  444. // 添加时间范围搜索逻辑
  445. if (this.selectedModel.date) {
  446. searchDatas = searchDatas.filter((item) => {
  447. return (
  448. new Date(item.date).getTime() >=
  449. new Date(
  450. this.$moment(new Date(this.selectedModel.date[0])).format("YYYY-MM-DD 00:00:00")
  451. ).getTime() &&
  452. new Date(item.date).getTime() <=
  453. new Date(
  454. this.$moment(new Date(this.selectedModel.date[1])).format("YYYY-MM-DD 23:59:59")
  455. ).getTime()
  456. );
  457. });
  458. }
  459. // 添加调用次数范围搜索逻辑
  460. if (this.selectedModel.count) {
  461. searchDatas = searchDatas.filter((item) => {
  462. return (
  463. item.count >= this.selectedModel.count[0] && item.count <= this.selectedModel.count[1]
  464. );
  465. });
  466. }
  467. // 格式化日期为YYYY-MM-DD格式
  468. searchDatas.forEach((item) => {
  469. item.date = this.$moment(new Date(item.date)).format("YYYY-MM-DD");
  470. });
  471. // 分页展示数据
  472. this.showServerData = searchDatas.slice(
  473. (this.currentPage - 1) * this.pageSize,
  474. this.currentPage * this.pageSize
  475. );
  476. // 遍历筛选条件下拉框选项,更新每个选项的数组
  477. for (let key in this.selectOptions) {
  478. this.selectOptions[key] = [
  479. ...new Set(searchDatas.map((item) => (item[key] ? item[key] : "未知"))),
  480. ];
  481. }
  482. // 更新分页组件数据
  483. this.tableDataTotal = searchDatas.length;
  484. this.showServerDetailReport = true;
  485. this.dialogLoading = false;
  486. },
  487. handleCurrentChange() {
  488. this.handleSizeChange();
  489. },
  490. // 筛选条件下拉框选中值改变时,触发的事件
  491. changeSelectModel() {
  492. // console.log(this.selectedModel);
  493. // 重置当前页码为第一页
  494. this.currentPage = 1;
  495. // 处理分页数据
  496. this.handleSizeChange();
  497. },
  498. // 重置筛选条件下拉框选中的值
  499. resetSelectModel() {
  500. for (let key in this.selectedModel) {
  501. this.selectedModel[key] = "";
  502. }
  503. this.selectedModel.count = [this.countMin, this.countMax];
  504. this.handleSizeChange();
  505. },
  506. // 打开弹窗,渲染table列表,展示查询时间的所有数据详情
  507. showDetailReport() {
  508. this.dialogLoading = true;
  509. // 要先请求,然后时间排序一下。
  510. appCenter
  511. .getServiceDataByDate({
  512. nowTimes: [
  513. this.$moment(new Date(this.nowTimes[0])).format("YYYY-MM-DD 00:00:00"),
  514. this.$moment(new Date(this.nowTimes[1])).format("YYYY-MM-DD 23:59:59"),
  515. ],
  516. })
  517. .then((res) => {
  518. if (res && res.code == 200) {
  519. if (res.content && res.content.length > 0) {
  520. res.content.forEach((item) => {
  521. this.tableColumns.forEach((key) => {
  522. if (item[key] == undefined) {
  523. item[key] = "未知";
  524. }
  525. });
  526. });
  527. this.serverData = res.content;
  528. // 得到count的最大值和最小值
  529. this.countMax = Math.max(...this.serverData.map((item) => item.count));
  530. this.countMin = Math.min(...this.serverData.map((item) => item.count));
  531. this.resetSelectModel();
  532. this.handleSizeChange();
  533. } else {
  534. this.$message({
  535. message: "暂无数据",
  536. type: "warning",
  537. });
  538. }
  539. }
  540. })
  541. .catch((e) => {
  542. this.$message({
  543. message: e,
  544. type: "error",
  545. });
  546. })
  547. .finally(() => {
  548. this.dialogLoading = false;
  549. });
  550. },
  551. initChart() {
  552. this.getDataStatus = true;
  553. // 获取运行管理页面数据
  554. appCenter
  555. .getAllYxglDatas({
  556. nowTimes: [
  557. this.$moment(new Date(this.nowTimes[0])).format("YYYY-MM-DD 00:00:00"),
  558. this.$moment(new Date(this.nowTimes[1])).format("YYYY-MM-DD 23:59:59"),
  559. ],
  560. lastTimes: this.lastTimes,
  561. })
  562. .then((res) => {
  563. if (res && res.code == 200) {
  564. if (res.content.TopCardDatas && typeof res.content.TopCardDatas === "object") {
  565. // 不能覆盖iconName
  566. this.TopCardDatas.forEach((cardItem) => {
  567. res.content.TopCardDatas.forEach((cardData) => {
  568. if (cardItem.name == cardData.name) {
  569. cardItem.value = cardData.value;
  570. cardItem.growth = cardData.growth;
  571. cardItem.upStatus = cardData.upStatus;
  572. }
  573. });
  574. });
  575. }
  576. this.dataToOption("服务调用趋势", "line", [...res.content.serviceCountTrend], {
  577. legend: { data: ["调用次数"] },
  578. xData: [],
  579. xKey: "date",
  580. xFormart: "YYYY-MM-DD",
  581. yAxis: {
  582. type: "value",
  583. name: "调用次数",
  584. axisLine: { lineStyle: { color: "#42a5f5" } }, // 区分样式
  585. },
  586. yData: {
  587. key: "count",
  588. name: "调用次数",
  589. color: "#42a5f5",
  590. data: [],
  591. yAxisIndex: 0,
  592. },
  593. });
  594. let serviceCountType = [];
  595. serviceCountType = res.content.serviceCountType;
  596. if (res.content.serviceCountType && res.content.serviceCountType.length > 0) {
  597. serviceCountType.forEach((item) => {
  598. if (!item.type) {
  599. item.type = "未知";
  600. }
  601. });
  602. }
  603. let serverObj = {};
  604. serverObj["proxy"] = 'proxy代理服务';
  605. serverObj["api"] = '一张图鉴权系统';
  606. serverObj["icon"] = '一张图符号精灵';
  607. serverObj["dms"] = '一张图数据中台';
  608. serverObj["oauth"] = '一张图鉴权系统';
  609. serverObj["proxy"] = '转发服务';
  610. serviceCountType.forEach((item) => {
  611. item.name = serverObj[item.type];
  612. if (!item.name) {
  613. item.name = "其它";
  614. }
  615. })
  616. // 初始化服务类别分布,这个地方需要先根据serviceType进行groupBy统计调用次数
  617. this.dataToOption("服务类别分布", "pie", serviceCountType, {
  618. pieKey: { value: "count", name: "name" },
  619. pieData: [],
  620. padAngle: 0,
  621. borderRadius: 0,
  622. label: {
  623. textStyle: {
  624. textShadow: 'none',
  625. color: '#fff'
  626. }
  627. },
  628. });
  629. // 服务调用TOP10
  630. let serviceDatas = [];
  631. serviceDatas = res.content.serviceCountTop;
  632. if (serviceDatas && serviceDatas.length > 0) {
  633. serviceDatas.forEach((item) => {
  634. if (!item.path_comment) {
  635. item.path_comment = "未知";
  636. }
  637. if (!item.type) {
  638. item.type = "未知";
  639. }
  640. });
  641. }
  642. // 排序
  643. serviceDatas.sort((a, b) => b.count - a.count);
  644. this.initTableDatas(serviceDatas.slice(0, 10));
  645. let serviceCountUnit = [];
  646. serviceCountUnit = res.content.serviceCountUnit;
  647. if (serviceCountUnit && serviceCountUnit.length > 0) {
  648. serviceCountUnit.forEach((item) => {
  649. if (!item.unit) {
  650. item.unit = "未知";
  651. }
  652. });
  653. }
  654. // 委办分布
  655. this.dataToOption("委办分布", "pie", serviceCountUnit, {
  656. pieKey: { value: "count", name: "unit" },
  657. pieData: [],
  658. legend: {
  659. show: false,
  660. bottom: 10,
  661. },
  662. radius: "60%",
  663. padAngle: 0,
  664. borderRadius: 0,
  665. label: {
  666. textStyle: {
  667. textShadow: 'none',
  668. color: '#fff'
  669. }
  670. },
  671. });
  672. // 先同步一下legend
  673. let serviceCountUnitTrendLegend = [];
  674. serviceCountUnit.forEach((item) => {
  675. serviceCountUnitTrendLegend.push(item.unit);
  676. });
  677. this.dataToOption("委办活跃度趋势", "line", [...res.content.serviceCountUnitTrend], {
  678. legend: { data: serviceCountUnitTrendLegend },
  679. xData: [],
  680. xKey: "date",
  681. xFormart: "YYYY-MM-DD",
  682. yAxis: {
  683. type: "value",
  684. axisLine: { lineStyle: { color: "#fff" } }, // 区分样式
  685. },
  686. yDatas: { auto: true },
  687. });
  688. let serviceDatas2 = [];
  689. serviceDatas2 = res.content.serviceCountApplicationTop;
  690. // 排序
  691. serviceDatas2.sort((a, b) => b.count - a.count);
  692. let forData = serviceDatas2.slice(0, 10);
  693. let showApplicationTopDatas = [];
  694. for (let i = forData.length - 1; i >= 0; i--) {
  695. showApplicationTopDatas.push(forData[i]);
  696. }
  697. // 用户部门分布
  698. this.dataToOption("热点应用TOP10排名", "bar", showApplicationTopDatas, {
  699. showLegend: false,
  700. xData: [],
  701. xKey: "application",
  702. yData: {
  703. key: "count",
  704. name: "调用次数",
  705. color: "#42a5f5",
  706. data: [],
  707. },
  708. });
  709. // 数据类别分布
  710. if (res.content.dataTypes && res.content.dataTypes.length > 0) {
  711. this.dataToOption("数据类别分布", "pie", [...res.content.dataTypes], {
  712. pieKey: { value: "count", name: "service_name" },
  713. pieData: [],
  714. legend: {
  715. bottom: 10,
  716. },
  717. radius: "60%",
  718. padAngle: 0,
  719. borderRadius: 0,
  720. label: {
  721. textStyle: {
  722. textShadow: 'none',
  723. color: '#fff'
  724. }
  725. },
  726. });
  727. }
  728. // console.log("getAllYxglDatas", res);
  729. }
  730. this.getDataStatus = false;
  731. })
  732. .catch((error) => {
  733. this.getDataStatus = false;
  734. this.$message({
  735. type: "error",
  736. message: "服务器忙碌,请稍后重试!",
  737. });
  738. });
  739. // 应用状态分布,cloumnId:1659
  740. appCenter
  741. .getDmsDataList({
  742. columnId: systemConfig.columnIds[1],
  743. pageSize: 1000,
  744. page: 0,
  745. })
  746. .then((res) => {
  747. if (res.code == 200) {
  748. let dmsDatas = res.content.data;
  749. let tableDatas = [];
  750. // 根据状态进行groupBy统计个数
  751. let statusMap = {};
  752. dmsDatas.forEach((item) => {
  753. if (statusMap[item.appstauts + ""]) {
  754. statusMap[item.appstauts + ""] += 1;
  755. } else {
  756. statusMap[item.appstauts + ""] = 1;
  757. }
  758. });
  759. // 转换为数组
  760. for (let key in statusMap) {
  761. if (statusMap[key] && key) {
  762. tableDatas.push({
  763. name: this.$getDmsTypes("appstatus", key),
  764. value: statusMap[key],
  765. });
  766. }
  767. }
  768. this.dataToOption("应用状态分布", "pie", tableDatas, {
  769. pieKey: { value: "value", name: "name" },
  770. pieData: [],
  771. });
  772. } else {
  773. this.$message({
  774. type: "error",
  775. message: "服务器忙碌,请稍后重试!",
  776. });
  777. }
  778. });
  779. this.dataToOption("数据质量评分", "radar", null, null);
  780. },
  781. getColumnCount() {
  782. let param = {
  783. start: this.$moment(new Date(this.nowTimes[0])).format("YYYY-MM-DD"),
  784. end: this.$moment(new Date(this.nowTimes[1])).format("YYYY-MM-DD"),
  785. };
  786. countlmType(param.start, param.end).then((res) => {
  787. if (res.length > 0) {
  788. this.dataToOption("栏目统计分布", "pie", [...res], {
  789. pieKey: { value: "count", name: "column" },
  790. pieData: [],
  791. legend: {
  792. type: 'scroll',
  793. bottom: 0,
  794. // orient: 'vertical', // 水平布局 horizontal 垂直 vertical
  795. pageButtonPosition: 'end', // 翻页按钮放右侧
  796. pageIconColor: '#fff',
  797. pageIconInactiveColor: '#999',
  798. itemWidth: 10, // 图例标记宽度
  799. itemHeight: 10, // 图例标记高度
  800. pageTextStyle: {
  801. color: '#fff'
  802. },
  803. pageIconSize: 12 // 翻页图标大小
  804. },
  805. radius: "60%",
  806. padAngle: 0,
  807. borderRadius: 0,
  808. label: {
  809. textStyle: {
  810. textShadow: 'none',
  811. color: '#fff'
  812. }
  813. },
  814. });
  815. }
  816. })
  817. },
  818. // 导出所选时间范围内的所有服务数据
  819. downFileAllServiceDatas() {
  820. this.exportLoading = true;
  821. appCenter
  822. .downFileAllServiceDatas({ nowTimes: this.nowTimes })
  823. .then((res) => {
  824. const blob = res; // 响应体是 Blob 类型
  825. if (!blob) {
  826. that.$message.error("下载失败:文件流为空");
  827. reject("文件流为空");
  828. return;
  829. }
  830. if (!(blob instanceof Blob) || blob.size === 0) {
  831. this.$message.error("文件流解析失败,无法生成下载链接");
  832. return;
  833. }
  834. const url = window.URL.createObjectURL(blob); // 将 Blob 转为临时 URL
  835. const link = document.createElement("a");
  836. link.href = url;
  837. link.download = "服务信息统计.xlsx"; // 设置下载文件名
  838. link.style.display = "none";
  839. document.body.appendChild(link);
  840. link.click(); // 触发点击下载
  841. document.body.removeChild(link);
  842. window.URL.revokeObjectURL(url); // 销毁临时 URL,避免内存泄漏
  843. })
  844. .catch((e) => {
  845. this.$message({
  846. message: "导出数据失败",
  847. type: "error",
  848. });
  849. })
  850. .finally(() => {
  851. this.exportLoading = false;
  852. });
  853. },
  854. /**
  855. * 数据转换为图表选项
  856. * @param title 图表标题
  857. * @param type 图表类型
  858. * @param datas 原始数据
  859. * @param keyRule 解析规则
  860. */
  861. async dataToOption(title, type, datas, keyRule) {
  862. // 根据规则解析数据
  863. if (keyRule) {
  864. datas.forEach((item) => {
  865. // 有的图表没有X轴
  866. if (keyRule.xKey) {
  867. if (keyRule.xFormart) {
  868. item[keyRule.xKey] = this.$moment(item[keyRule.xKey]).format(keyRule.xFormart);
  869. }
  870. keyRule.xData.push(item[keyRule.xKey]);
  871. }
  872. if (keyRule.yData) {
  873. keyRule.yData.data.push(item[keyRule.yData.key]);
  874. keyRule.series = [
  875. {
  876. name: keyRule.yData.name,
  877. type: "line",
  878. smooth: true,
  879. data: keyRule.yData.data,
  880. lineStyle: {
  881. color: keyRule.yData.color ? keyRule.yData.color : "",
  882. type: keyRule.yData.ifDashed ? "dashed" : "",
  883. }, // 蓝色线条
  884. itemStyle: keyRule.yData.color,
  885. symbol: "circle", // 节点形状
  886. symbolSize: 6, // 节点大小
  887. },
  888. ];
  889. }
  890. if (keyRule.yDatas) {
  891. // 先根据lenged得到data集合
  892. for (let name of keyRule.legend.data) {
  893. if (keyRule.yDatas[name]) {
  894. keyRule.yDatas[name].data.push(item[name]);
  895. } else {
  896. keyRule.yDatas[name] = {
  897. name: name,
  898. data: [item[name]],
  899. };
  900. }
  901. }
  902. }
  903. if (keyRule.pieKey) {
  904. keyRule.pieData.push({
  905. value: item[keyRule.pieKey.value],
  906. name: item[keyRule.pieKey.name],
  907. });
  908. }
  909. });
  910. // 专门用来处理多y数据的series
  911. if (keyRule.yDatas) {
  912. keyRule.series = [];
  913. for (let name of keyRule.legend.data) {
  914. keyRule.series.push({
  915. name: name,
  916. type: "line",
  917. smooth: true,
  918. data: keyRule.yDatas[name].data,
  919. symbol: "circle", // 节点形状
  920. symbolSize: 6, // 节点大小
  921. });
  922. }
  923. }
  924. }
  925. let _option = {};
  926. switch (type) {
  927. case "line":
  928. // 折线图基础
  929. _option = {
  930. legend: {
  931. data: keyRule.legend.data,
  932. // type: 'scroll',
  933. // top: 0,
  934. // // orient: 'vertical', // 水平布局 horizontal 垂直 vertical
  935. // pageButtonPosition: 'end', // 翻页按钮放右侧
  936. // pageIconColor: '#fff',
  937. // pageIconInactiveColor: '#999',
  938. // itemWidth: 10, // 图例标记宽度
  939. // itemHeight: 10, // 图例标记高度
  940. // pageTextStyle: {
  941. // color: '#fff'
  942. // },
  943. // pageIconSize: 12 // 翻页图标大小
  944. },
  945. tooltip: {
  946. show: true,
  947. trigger: "axis",
  948. axisPointer: { type: "shadow" },
  949. },
  950. // 默认样式
  951. xAxis: {
  952. type: "category",
  953. data: keyRule.xData,
  954. axisTick: { show: false }, // 隐藏刻度
  955. splitLine: { show: false }, // 隐藏分割线
  956. axisLabel: {
  957. color: "#fff", // 字体颜色(支持十六进制、RGB、颜色名)
  958. fontSize: 14, // 可选:字体大小
  959. fontWeight: "normal", // 可选:字体粗细
  960. textShadow: 'none'
  961. },
  962. },
  963. yAxis: {
  964. type: "value",
  965. axisLabel: {
  966. color: "#fff", // 字体颜色(支持十六进制、RGB、颜色名)
  967. fontSize: 14, // 可选:字体大小
  968. fontWeight: "normal", // 可选:字体粗细
  969. textShadow: 'none'
  970. },
  971. splitLine: {
  972. lineStyle: {
  973. type: "dashed", // 虚线网格
  974. color: "#113761",
  975. },
  976. },
  977. },
  978. series: keyRule.series,
  979. };
  980. break;
  981. case "pie":
  982. // 饼状图
  983. _option = {
  984. tooltip: {
  985. trigger: "item",
  986. },
  987. legend: keyRule.legend
  988. ? keyRule.legend
  989. : {
  990. orient: "vertical",
  991. top: "50%",
  992. right: 10,
  993. },
  994. series: [
  995. {
  996. name: title,
  997. type: "pie",
  998. radius: keyRule.radius ? keyRule.radius : ["40%", "70%"],
  999. avoidLabelOverlap: false,
  1000. padAngle: keyRule.padAngle != undefined ? keyRule.padAngle : 5,
  1001. itemStyle: {
  1002. borderRadius: keyRule.borderRadius != undefined ? keyRule.borderRadius : 10,
  1003. },
  1004. label:
  1005. keyRule.label != undefined
  1006. ? keyRule.label
  1007. : {
  1008. show: false,
  1009. position: "center",
  1010. textStyle: {
  1011. textShadow: 'none',
  1012. color: '#fff'
  1013. }
  1014. },
  1015. emphasis: {
  1016. label: {
  1017. show: true,
  1018. fontSize: 20,
  1019. fontWeight: "bold",
  1020. textStyle: {
  1021. textShadow: 'none',
  1022. color: '#fff'
  1023. }
  1024. },
  1025. },
  1026. labelLine: {
  1027. show: true,
  1028. },
  1029. data: keyRule.pieData,
  1030. },
  1031. ],
  1032. };
  1033. break;
  1034. case "bar":
  1035. // 柱状图
  1036. _option = {
  1037. tooltip: {
  1038. trigger: "axis",
  1039. axisPointer: {
  1040. type: "shadow",
  1041. },
  1042. },
  1043. legend: {
  1044. show: keyRule.showLegend ? keyRule.showLegend : false,
  1045. data: keyRule.legend,
  1046. },
  1047. xAxis: {
  1048. type: "value",
  1049. interval: 0,
  1050. axisLabel: {
  1051. color: "#fff", // 字体颜色(支持十六进制、RGB、颜色名)
  1052. fontSize: 12, // 可选:字体大小
  1053. fontWeight: "normal", // 可选:字体粗细
  1054. rotate: 30, // 旋转30度
  1055. textShadow: 'none',
  1056. textStyle: {
  1057. textShadow: 'none',
  1058. color: '#fff'
  1059. }
  1060. },
  1061. splitLine: { lineStyle: { color: "#fff" } },
  1062. },
  1063. yAxis: {
  1064. type: "category",
  1065. data: keyRule.xData,
  1066. axisLabel: {
  1067. color: "#F2F3F5cc", // 字体颜色(支持十六进制、RGB、颜色名)
  1068. fontSize: 14, // 可选:字体大小
  1069. fontWeight: "normal", // 可选:字体粗细
  1070. textShadow: 'none',
  1071. textStyle: {
  1072. textShadow: 'none',
  1073. color: '#fff'
  1074. }
  1075. },
  1076. },
  1077. series: [
  1078. {
  1079. name: keyRule.yData.name,
  1080. type: "bar",
  1081. label: {
  1082. show: true,
  1083. position: 'right',
  1084. valueAnimation: true,
  1085. textStyle: {
  1086. textShadow: 'none',
  1087. color: '#fff'
  1088. }
  1089. },
  1090. emphasis: {
  1091. focus: "series",
  1092. },
  1093. data: keyRule.yData.data,
  1094. },
  1095. ],
  1096. };
  1097. break;
  1098. default:
  1099. // 雷达图
  1100. _option = {
  1101. tooltip: {
  1102. trigger: "axis",
  1103. },
  1104. legend: {
  1105. show: false,
  1106. left: "center",
  1107. },
  1108. radar: [
  1109. {
  1110. indicator: [
  1111. { name: "健壮性", max: 100 },
  1112. { name: "完整性", max: 100 },
  1113. { name: "一致性", max: 100 },
  1114. { name: "及时性", max: 100 },
  1115. { name: "准确性", max: 100 },
  1116. ],
  1117. axisLabel: {
  1118. color: '#fff',
  1119. fontSize: 14,
  1120. fontWeight: 'bold'
  1121. },
  1122. },
  1123. ],
  1124. series: [
  1125. {
  1126. type: "radar",
  1127. tooltip: {
  1128. trigger: 'item'
  1129. },
  1130. itemStyle: {
  1131. color: '#4169E1',
  1132. borderColor: '#4169E1',
  1133. borderWidth: 2
  1134. },
  1135. areaStyle: {},
  1136. data: [
  1137. {
  1138. value: [93, 85, 92, 95, 93],
  1139. name: "数据质量评分",
  1140. },
  1141. ],
  1142. },
  1143. ],
  1144. };
  1145. break;
  1146. }
  1147. this.chartOptions[title] = _option;
  1148. },
  1149. // 服务调用列表
  1150. initTableDatas(serviceTypeDatas2) {
  1151. this.tableDatas = serviceTypeDatas2;
  1152. },
  1153. // 时间范围自定义时间
  1154. shortcuts() {
  1155. return [
  1156. {
  1157. text: "当天",
  1158. value: () => {
  1159. const end = new Date();
  1160. const start = new Date();
  1161. return [start, end];
  1162. },
  1163. },
  1164. {
  1165. text: "最近7天",
  1166. value: () => {
  1167. const end = new Date();
  1168. const start = new Date();
  1169. start.setTime(start.getTime() - 3600 * 1000 * 24 * 6);
  1170. return [start, end];
  1171. },
  1172. },
  1173. {
  1174. text: "最近30天",
  1175. value: () => {
  1176. const end = new Date();
  1177. const start = new Date();
  1178. start.setTime(start.getTime() - 3600 * 1000 * 24 * 29);
  1179. return [start, end];
  1180. },
  1181. },
  1182. {
  1183. text: "最近90天",
  1184. value: () => {
  1185. const end = new Date();
  1186. const start = new Date();
  1187. start.setTime(start.getTime() - 3600 * 1000 * 24 * 89);
  1188. return [start, end];
  1189. },
  1190. },
  1191. {
  1192. text: "最近1年",
  1193. value: () => {
  1194. const end = new Date();
  1195. const start = new Date();
  1196. start.setTime(start.getTime() - 3600 * 1000 * 24 * 364);
  1197. return [start, end];
  1198. },
  1199. },
  1200. ];
  1201. },
  1202. },
  1203. };
  1204. </script>
  1205. <style lang="less" scoped>
  1206. .mainBox {
  1207. width: calc(100% - 60px);
  1208. margin: 30px;
  1209. padding-bottom: 80px;
  1210. & > div {
  1211. margin: 20px 0;
  1212. display: flex;
  1213. }
  1214. .card {
  1215. width: calc(25% - 56px);
  1216. border-radius: 5px;
  1217. padding: 20px 18px;
  1218. // background: #00000032;
  1219. background: #eeeeee0b;
  1220. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  1221. }
  1222. .card2 {
  1223. width: 100%;
  1224. border-radius: 5px;
  1225. padding: 20px 18px;
  1226. // background: rgba(255, 255, 255, 0.1);
  1227. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  1228. }
  1229. .bigCard {
  1230. width: calc(100% - 36px);
  1231. border-radius: 5px;
  1232. padding: 20px 18px;
  1233. // background: #00000032;
  1234. position: relative;
  1235. flex-direction: column;
  1236. background: #eeeeee0b;
  1237. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  1238. .tools {
  1239. position: absolute;
  1240. top: 20px;
  1241. right: 20px;
  1242. display: flex;
  1243. flex-direction: row;
  1244. justify-content: flex-end;
  1245. }
  1246. &_title {
  1247. font-size: 20px;
  1248. font-weight: bold;
  1249. }
  1250. }
  1251. .flex {
  1252. display: flex;
  1253. flex-direction: row;
  1254. justify-content: space-between;
  1255. }
  1256. .flex_column {
  1257. display: flex;
  1258. flex-direction: column;
  1259. justify-content: space-between;
  1260. align-items: flex-start;
  1261. box-sizing: border-box;
  1262. }
  1263. .searchBox {
  1264. width: 100%;
  1265. height: 50px;
  1266. line-height: 50px;
  1267. text-align: center;
  1268. font-size: 20px;
  1269. font-weight: bold;
  1270. flex-direction: row-reverse;
  1271. display: flex;
  1272. }
  1273. }
  1274. // 日期选择框样式
  1275. .demo-date-picker {
  1276. display: flex;
  1277. width: 100%;
  1278. padding: 0;
  1279. flex-wrap: wrap;
  1280. }
  1281. .demo-date-picker .block {
  1282. padding: 1.5rem 0;
  1283. text-align: center;
  1284. border-right: solid 1px var(--el-border-color);
  1285. flex: 1;
  1286. min-width: 400px;
  1287. display: flex;
  1288. flex-direction: column;
  1289. align-items: center;
  1290. }
  1291. .demo-date-picker .block:last-child {
  1292. border-right: none;
  1293. }
  1294. .demo-date-picker .demonstration {
  1295. display: block;
  1296. color: var(--el-text-color-secondary);
  1297. font-size: 14px;
  1298. margin-bottom: 1rem;
  1299. }
  1300. @media screen and (max-width: 1200px) {
  1301. .demo-date-picker .block {
  1302. flex: 0 0 100%;
  1303. padding: 1rem 0;
  1304. min-width: auto;
  1305. border-right: none;
  1306. border-bottom: solid 1px var(--el-border-color);
  1307. }
  1308. .demo-date-picker .block:last-child {
  1309. border-bottom: none;
  1310. }
  1311. }
  1312. // 弹窗加载状态图标
  1313. .loading-icon {
  1314. // 图标顺时针旋转动画
  1315. animation: loading-icon-spin 2s linear infinite;
  1316. }
  1317. @keyframes loading-icon-spin {
  1318. 0% {
  1319. transform: rotate(0deg);
  1320. }
  1321. 100% {
  1322. transform: rotate(360deg);
  1323. }
  1324. }
  1325. </style>