StatisticalAnalysis.vue 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220
  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: 33%; 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: 33%; 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. </div>
  250. </template>
  251. <script>
  252. import card from "@/components/yxgl/card.vue";
  253. import EchartsDome from "@/components/yxgl/EchartsDome.vue";
  254. import Table from "@/components/yxgl/table.vue";
  255. import appCenter from "@/api/appCenter";
  256. import { countlmType } from "@/api/count";
  257. export default {
  258. name: "",
  259. components: {
  260. card,
  261. EchartsDome,
  262. Table,
  263. },
  264. data() {
  265. return {
  266. // 导出Loading状态
  267. exportLoading: false,
  268. // 弹窗加载状态
  269. dialogLoading: false,
  270. // 获取数据状态
  271. getDataStatus: false,
  272. // 比较的时间范围(默认60天到30天前,主要跟nowTimes有关系)
  273. lastTimes: [],
  274. // 当前选中的时间范围
  275. nowTimes: [],
  276. // 服务调用详情弹窗是否显示
  277. showServerDetailReport: false,
  278. // 服务调用详情数据
  279. serverData: [],
  280. // 展示的详细数据(能根据时间和字段模糊筛选)
  281. showServerData: [],
  282. // 筛选条件下拉框选项
  283. selectOptions: {
  284. application: [],
  285. path_comment: [],
  286. unit: [],
  287. type: [],
  288. },
  289. selectKeyName: {
  290. application: "应用名称",
  291. path_comment: "服务名称",
  292. unit: "委办单位",
  293. count: "调用次数",
  294. type: "服务类型",
  295. },
  296. // 筛选条件下拉框选中的值
  297. selectedModel: {
  298. application: "",
  299. path_comment: "",
  300. unit: "",
  301. type: "",
  302. count: "",
  303. date: "",
  304. },
  305. // 调用次数范围的最小值和最大值
  306. countMin: 0,
  307. countMax: 0,
  308. tableColumns: ["application", "path_comment", "unit", "count", "type", "date"],
  309. // 分页大小
  310. pageSize: 50,
  311. // 当前页码
  312. currentPage: 1,
  313. // 表格数据总条数
  314. tableDataTotal: 0,
  315. TopCardDatas: [
  316. {
  317. name: "委办总数",
  318. value: "0",
  319. growth: "--",
  320. iconColor: "#2563db",
  321. iconName: "OfficeBuilding",
  322. upStatus: 0,
  323. },
  324. {
  325. name: "系统总数",
  326. value: "0",
  327. growth: "--",
  328. iconColor: "#16a34a",
  329. iconName: "WalletFilled",
  330. upStatus: 0,
  331. },
  332. {
  333. name: "服务总数",
  334. value: "0",
  335. growth: "--",
  336. iconColor: "#9333ea",
  337. iconName: "CollectionTag",
  338. upStatus: 0,
  339. },
  340. {
  341. name: "服务调用总数",
  342. value: "0",
  343. growth: "--",
  344. iconColor: "#ca8a04",
  345. iconName: "Paperclip",
  346. upStatus: 0,
  347. },
  348. ],
  349. shortcutsFun: this.shortcuts(),
  350. chartOptions: {},
  351. tableDatas: [],
  352. };
  353. },
  354. watch: {
  355. nowTimes: {
  356. handler(newVal, oldVal) {
  357. if (newVal !== oldVal && newVal.length > 0) {
  358. // 计算出比较的时间范围
  359. this.lastTimes = [
  360. this.$moment(
  361. new Date(
  362. new Date(newVal[0]).setTime(
  363. new Date(newVal[0]).getTime() - (newVal[1] - newVal[0]) - 24 * 60 * 60 * 1000
  364. )
  365. )
  366. ).format("YYYY-MM-DD 00:00:00"),
  367. this.$moment(new Date(newVal[0])).format("YYYY-MM-DD 00:00:00"),
  368. ];
  369. this.initChart();
  370. // 栏目统计分布
  371. this.getColumnCount();
  372. }
  373. },
  374. deep: true,
  375. // immediate: true,
  376. },
  377. },
  378. mounted() {
  379. this.$nextTick(() => {
  380. this.nowTimes = [
  381. new Date(new Date().setTime(new Date() - 3600 * 1000 * 24 * 30)),
  382. new Date(),
  383. ];
  384. });
  385. },
  386. methods: {
  387. // 禁用日期选择器中未来的日期(不能选择nowTimes以外的时间)
  388. disabledDate(time) {
  389. return (
  390. time.getTime() > this.nowTimes[1].getTime() ||
  391. time.getTime() < this.nowTimes[0].getTime() - 24 * 60 * 60 * 1000
  392. );
  393. },
  394. // 分页大小改变时,更新展示数据
  395. handleSizeChange() {
  396. this.dialogLoading = true;
  397. let searchDatas = this.serverData.filter((item) => {
  398. return (
  399. (!this.selectedModel.application ||
  400. item.application === this.selectedModel.application) &&
  401. (!this.selectedModel.path_comment ||
  402. item.path_comment === this.selectedModel.path_comment) &&
  403. (!this.selectedModel.unit || item.unit === this.selectedModel.unit) &&
  404. (!this.selectedModel.type || item.type === this.selectedModel.type)
  405. );
  406. });
  407. // 添加时间范围搜索逻辑
  408. if (this.selectedModel.date) {
  409. searchDatas = searchDatas.filter((item) => {
  410. return (
  411. new Date(item.date).getTime() >=
  412. new Date(
  413. this.$moment(new Date(this.selectedModel.date[0])).format("YYYY-MM-DD 00:00:00")
  414. ).getTime() &&
  415. new Date(item.date).getTime() <=
  416. new Date(
  417. this.$moment(new Date(this.selectedModel.date[1])).format("YYYY-MM-DD 23:59:59")
  418. ).getTime()
  419. );
  420. });
  421. }
  422. // 添加调用次数范围搜索逻辑
  423. if (this.selectedModel.count) {
  424. searchDatas = searchDatas.filter((item) => {
  425. return (
  426. item.count >= this.selectedModel.count[0] && item.count <= this.selectedModel.count[1]
  427. );
  428. });
  429. }
  430. // 格式化日期为YYYY-MM-DD格式
  431. searchDatas.forEach((item) => {
  432. item.date = this.$moment(new Date(item.date)).format("YYYY-MM-DD");
  433. });
  434. // 分页展示数据
  435. this.showServerData = searchDatas.slice(
  436. (this.currentPage - 1) * this.pageSize,
  437. this.currentPage * this.pageSize
  438. );
  439. // 遍历筛选条件下拉框选项,更新每个选项的数组
  440. for (let key in this.selectOptions) {
  441. this.selectOptions[key] = [
  442. ...new Set(searchDatas.map((item) => (item[key] ? item[key] : "未知"))),
  443. ];
  444. }
  445. // 更新分页组件数据
  446. this.tableDataTotal = searchDatas.length;
  447. this.showServerDetailReport = true;
  448. this.dialogLoading = false;
  449. },
  450. handleCurrentChange() {
  451. this.handleSizeChange();
  452. },
  453. // 筛选条件下拉框选中值改变时,触发的事件
  454. changeSelectModel() {
  455. console.log(this.selectedModel);
  456. // 重置当前页码为第一页
  457. this.currentPage = 1;
  458. // 处理分页数据
  459. this.handleSizeChange();
  460. },
  461. // 重置筛选条件下拉框选中的值
  462. resetSelectModel() {
  463. for (let key in this.selectedModel) {
  464. this.selectedModel[key] = "";
  465. }
  466. this.selectedModel.count = [this.countMin, this.countMax];
  467. this.handleSizeChange();
  468. },
  469. // 打开弹窗,渲染table列表,展示查询时间的所有数据详情
  470. showDetailReport() {
  471. this.dialogLoading = true;
  472. // 要先请求,然后时间排序一下。
  473. appCenter
  474. .getServiceDataByDate({
  475. nowTimes: [
  476. this.$moment(new Date(this.nowTimes[0])).format("YYYY-MM-DD 00:00:00"),
  477. this.$moment(new Date(this.nowTimes[1])).format("YYYY-MM-DD 23:59:59"),
  478. ],
  479. })
  480. .then((res) => {
  481. if (res && res.code == 200) {
  482. if (res.content && res.content.length > 0) {
  483. res.content.forEach((item) => {
  484. this.tableColumns.forEach((key) => {
  485. if (item[key] == undefined) {
  486. item[key] = "未知";
  487. }
  488. });
  489. });
  490. this.serverData = res.content;
  491. // 得到count的最大值和最小值
  492. this.countMax = Math.max(...this.serverData.map((item) => item.count));
  493. this.countMin = Math.min(...this.serverData.map((item) => item.count));
  494. this.resetSelectModel();
  495. this.handleSizeChange();
  496. } else {
  497. this.$message({
  498. message: "暂无数据",
  499. type: "warning",
  500. });
  501. }
  502. }
  503. })
  504. .catch((e) => {
  505. this.$message({
  506. message: e,
  507. type: "error",
  508. });
  509. })
  510. .finally(() => {
  511. this.dialogLoading = false;
  512. });
  513. },
  514. initChart() {
  515. this.getDataStatus = true;
  516. // 获取运行管理页面数据
  517. appCenter
  518. .getAllYxglDatas({
  519. nowTimes: [
  520. this.$moment(new Date(this.nowTimes[0])).format("YYYY-MM-DD 00:00:00"),
  521. this.$moment(new Date(this.nowTimes[1])).format("YYYY-MM-DD 23:59:59"),
  522. ],
  523. lastTimes: this.lastTimes,
  524. })
  525. .then((res) => {
  526. if (res && res.code == 200) {
  527. if (res.content.TopCardDatas && typeof res.content.TopCardDatas === "object") {
  528. // 不能覆盖iconName
  529. this.TopCardDatas.forEach((cardItem) => {
  530. res.content.TopCardDatas.forEach((cardData) => {
  531. if (cardItem.name == cardData.name) {
  532. cardItem.value = cardData.value;
  533. cardItem.growth = cardData.growth;
  534. cardItem.upStatus = cardData.upStatus;
  535. }
  536. });
  537. });
  538. }
  539. this.dataToOption("服务调用趋势", "line", [...res.content.serviceCountTrend], {
  540. legend: { data: ["调用次数"] },
  541. xData: [],
  542. xKey: "date",
  543. xFormart: "YYYY-MM-DD",
  544. yAxis: {
  545. type: "value",
  546. name: "调用次数",
  547. axisLine: { lineStyle: { color: "#42a5f5" } }, // 区分样式
  548. },
  549. yData: {
  550. key: "count",
  551. name: "调用次数",
  552. color: "#42a5f5",
  553. data: [],
  554. yAxisIndex: 0,
  555. },
  556. });
  557. let serviceCountType = [];
  558. serviceCountType = res.content.serviceCountType;
  559. if (res.content.serviceCountType && res.content.serviceCountType.length > 0) {
  560. serviceCountType.forEach((item) => {
  561. if (!item.type) {
  562. item.type = "未知";
  563. }
  564. });
  565. }
  566. // 初始化服务类别分布,这个地方需要先根据serviceType进行groupBy统计调用次数
  567. this.dataToOption("服务类别分布", "pie", serviceCountType, {
  568. pieKey: { value: "count", name: "type" },
  569. pieData: [],
  570. padAngle: 0,
  571. borderRadius: 0,
  572. label: {},
  573. });
  574. // 服务调用TOP10
  575. let serviceDatas = [];
  576. serviceDatas = res.content.serviceCountTop;
  577. if (serviceDatas && serviceDatas.length > 0) {
  578. serviceDatas.forEach((item) => {
  579. if (!item.path_comment) {
  580. item.path_comment = "未知";
  581. }
  582. if (!item.type) {
  583. item.type = "未知";
  584. }
  585. });
  586. }
  587. // 排序
  588. serviceDatas.sort((a, b) => b.count - a.count);
  589. this.initTableDatas(serviceDatas.slice(0, 10));
  590. let serviceCountUnit = [];
  591. serviceCountUnit = res.content.serviceCountUnit;
  592. if (serviceCountUnit && serviceCountUnit.length > 0) {
  593. serviceCountUnit.forEach((item) => {
  594. if (!item.unit) {
  595. item.unit = "未知";
  596. }
  597. });
  598. }
  599. // 委办分布
  600. this.dataToOption("委办分布", "pie", serviceCountUnit, {
  601. pieKey: { value: "count", name: "unit" },
  602. pieData: [],
  603. legend: {
  604. show: false,
  605. bottom: 10,
  606. },
  607. radius: "60%",
  608. padAngle: 0,
  609. borderRadius: 0,
  610. label: {},
  611. });
  612. // 先同步一下legend
  613. let serviceCountUnitTrendLegend = [];
  614. serviceCountUnit.forEach((item) => {
  615. serviceCountUnitTrendLegend.push(item.unit);
  616. });
  617. this.dataToOption("委办活跃度趋势", "line", [...res.content.serviceCountUnitTrend], {
  618. legend: { data: serviceCountUnitTrendLegend },
  619. xData: [],
  620. xKey: "date",
  621. xFormart: "YYYY-MM-DD",
  622. yAxis: {
  623. type: "value",
  624. axisLine: { lineStyle: { color: "#42a5f5" } }, // 区分样式
  625. },
  626. yDatas: { auto: true },
  627. });
  628. let serviceDatas2 = [];
  629. serviceDatas2 = res.content.serviceCountApplicationTop;
  630. // 排序
  631. serviceDatas2.sort((a, b) => b.count - a.count);
  632. let forData = serviceDatas2.slice(0, 10);
  633. let showApplicationTopDatas = [];
  634. for (let i = forData.length - 1; i >= 0; i--) {
  635. showApplicationTopDatas.push(forData[i]);
  636. }
  637. // 用户部门分布
  638. this.dataToOption("热点应用TOP10排名", "bar", showApplicationTopDatas, {
  639. showLegend: false,
  640. xData: [],
  641. xKey: "application",
  642. yData: {
  643. key: "count",
  644. name: "调用次数",
  645. color: "#42a5f5",
  646. data: [],
  647. },
  648. });
  649. // 数据类别分布
  650. if (res.content.dataTypes && res.content.dataTypes.length > 0) {
  651. this.dataToOption("数据类别分布", "pie", [...res.content.dataTypes], {
  652. pieKey: { value: "count", name: "service_name" },
  653. pieData: [],
  654. legend: {
  655. bottom: 10,
  656. },
  657. radius: "60%",
  658. padAngle: 0,
  659. borderRadius: 0,
  660. label: {},
  661. });
  662. }
  663. // console.log("getAllYxglDatas", res);
  664. }
  665. this.getDataStatus = false;
  666. })
  667. .catch((error) => {
  668. this.getDataStatus = false;
  669. this.$message({
  670. type: "error",
  671. message: "服务器忙碌,请稍后重试!",
  672. });
  673. });
  674. // 应用状态分布,cloumnId:1659
  675. appCenter
  676. .getDmsDataList({
  677. columnId: systemConfig.columnIds[1],
  678. pageSize: 1000,
  679. page: 0,
  680. })
  681. .then((res) => {
  682. if (res.code == 200) {
  683. let dmsDatas = res.content.data;
  684. let tableDatas = [];
  685. // 根据状态进行groupBy统计个数
  686. let statusMap = {};
  687. dmsDatas.forEach((item) => {
  688. if (statusMap[item.appstauts + ""]) {
  689. statusMap[item.appstauts + ""] += 1;
  690. } else {
  691. statusMap[item.appstauts + ""] = 1;
  692. }
  693. });
  694. // 转换为数组
  695. for (let key in statusMap) {
  696. if (statusMap[key] && key) {
  697. tableDatas.push({
  698. name: this.$getDmsTypes("appstatus", key),
  699. value: statusMap[key],
  700. });
  701. }
  702. }
  703. this.dataToOption("应用状态分布", "pie", tableDatas, {
  704. pieKey: { value: "value", name: "name" },
  705. pieData: [],
  706. });
  707. } else {
  708. this.$message({
  709. type: "error",
  710. message: "服务器忙碌,请稍后重试!",
  711. });
  712. }
  713. });
  714. this.dataToOption("数据质量评分", "radar", null, null);
  715. },
  716. getColumnCount() {
  717. // this.$moment(new Date(this.nowTimes[0])).format("YYYY-MM-DD 00:00:00"),
  718. // this.$moment(new Date(this.nowTimes[1])).format("YYYY-MM-DD 23:59:59"),
  719. let param = {
  720. start: "2000-01-01",
  721. end: this.$moment(new Date(this.nowTimes[1])).format("YYYY-MM-DD"),
  722. };
  723. countlmType(param.start, param.end).then((res) => {
  724. console.log("========栏目统计分布=========", res);
  725. })
  726. let columnDatas = [
  727. {count: 3, service_name: "任务"},
  728. {count: 5, service_name: "反馈信息"},
  729. {count: 7, service_name: "其它"},
  730. ];
  731. // console.log("========栏目统计分布=========", res.content.dataTypes);
  732. if (columnDatas && columnDatas.length > 0) {
  733. this.dataToOption("栏目统计分布", "pie", [...columnDatas], {
  734. pieKey: { value: "count", name: "service_name" },
  735. pieData: [],
  736. legend: {
  737. bottom: 10,
  738. },
  739. radius: "60%",
  740. padAngle: 0,
  741. borderRadius: 0,
  742. label: {},
  743. });
  744. }
  745. },
  746. // 导出所选时间范围内的所有服务数据
  747. downFileAllServiceDatas() {
  748. this.exportLoading = true;
  749. appCenter
  750. .downFileAllServiceDatas({ nowTimes: this.nowTimes })
  751. .then((res) => {
  752. const blob = res; // 响应体是 Blob 类型
  753. if (!blob) {
  754. that.$message.error("下载失败:文件流为空");
  755. reject("文件流为空");
  756. return;
  757. }
  758. if (!(blob instanceof Blob) || blob.size === 0) {
  759. this.$message.error("文件流解析失败,无法生成下载链接");
  760. return;
  761. }
  762. const url = window.URL.createObjectURL(blob); // 将 Blob 转为临时 URL
  763. const link = document.createElement("a");
  764. link.href = url;
  765. link.download = "服务信息统计.xlsx"; // 设置下载文件名
  766. link.style.display = "none";
  767. document.body.appendChild(link);
  768. link.click(); // 触发点击下载
  769. document.body.removeChild(link);
  770. window.URL.revokeObjectURL(url); // 销毁临时 URL,避免内存泄漏
  771. })
  772. .catch((e) => {
  773. this.$message({
  774. message: "导出数据失败",
  775. type: "error",
  776. });
  777. })
  778. .finally(() => {
  779. this.exportLoading = false;
  780. });
  781. },
  782. /**
  783. * 数据转换为图表选项
  784. * @param title 图表标题
  785. * @param type 图表类型
  786. * @param datas 原始数据
  787. * @param keyRule 解析规则
  788. */
  789. async dataToOption(title, type, datas, keyRule) {
  790. // 根据规则解析数据
  791. if (keyRule) {
  792. datas.forEach((item) => {
  793. // 有的图表没有X轴
  794. if (keyRule.xKey) {
  795. if (keyRule.xFormart) {
  796. item[keyRule.xKey] = this.$moment(item[keyRule.xKey]).format(keyRule.xFormart);
  797. }
  798. keyRule.xData.push(item[keyRule.xKey]);
  799. }
  800. if (keyRule.yData) {
  801. keyRule.yData.data.push(item[keyRule.yData.key]);
  802. keyRule.series = [
  803. {
  804. name: keyRule.yData.name,
  805. type: "line",
  806. smooth: true,
  807. data: keyRule.yData.data,
  808. lineStyle: {
  809. color: keyRule.yData.color ? keyRule.yData.color : "",
  810. type: keyRule.yData.ifDashed ? "dashed" : "",
  811. }, // 蓝色线条
  812. itemStyle: keyRule.yData.color,
  813. symbol: "circle", // 节点形状
  814. symbolSize: 6, // 节点大小
  815. },
  816. ];
  817. }
  818. if (keyRule.yDatas) {
  819. // 先根据lenged得到data集合
  820. for (let name of keyRule.legend.data) {
  821. if (keyRule.yDatas[name]) {
  822. keyRule.yDatas[name].data.push(item[name]);
  823. } else {
  824. keyRule.yDatas[name] = {
  825. name: name,
  826. data: [item[name]],
  827. };
  828. }
  829. }
  830. }
  831. if (keyRule.pieKey) {
  832. keyRule.pieData.push({
  833. value: item[keyRule.pieKey.value],
  834. name: item[keyRule.pieKey.name],
  835. });
  836. }
  837. });
  838. // 专门用来处理多y数据的series
  839. if (keyRule.yDatas) {
  840. keyRule.series = [];
  841. for (let name of keyRule.legend.data) {
  842. keyRule.series.push({
  843. name: name,
  844. type: "line",
  845. smooth: true,
  846. data: keyRule.yDatas[name].data,
  847. symbol: "circle", // 节点形状
  848. symbolSize: 6, // 节点大小
  849. });
  850. }
  851. }
  852. }
  853. let _option = {};
  854. switch (type) {
  855. case "line":
  856. // 折线图基础
  857. _option = {
  858. legend: {
  859. data: keyRule.legend.data,
  860. },
  861. tooltip: {
  862. show: true,
  863. trigger: "axis",
  864. axisPointer: { type: "shadow" },
  865. },
  866. // 默认样式
  867. xAxis: {
  868. type: "category",
  869. data: keyRule.xData,
  870. axisTick: { show: false }, // 隐藏刻度
  871. splitLine: { show: false }, // 隐藏分割线
  872. axisLabel: {
  873. color: "#F2F3F5cc", // 字体颜色(支持十六进制、RGB、颜色名)
  874. fontSize: 14, // 可选:字体大小
  875. fontWeight: "normal", // 可选:字体粗细
  876. },
  877. },
  878. yAxis: {
  879. type: "value",
  880. axisLabel: {
  881. color: "#42a5f5cc", // 字体颜色(支持十六进制、RGB、颜色名)
  882. fontSize: 14, // 可选:字体大小
  883. fontWeight: "normal", // 可选:字体粗细
  884. },
  885. splitLine: { lineStyle: { color: "#42a5f532" } },
  886. },
  887. series: keyRule.series,
  888. };
  889. break;
  890. case "pie":
  891. // 饼状图
  892. _option = {
  893. tooltip: {
  894. trigger: "item",
  895. },
  896. legend: keyRule.legend
  897. ? keyRule.legend
  898. : {
  899. orient: "vertical",
  900. top: "50%",
  901. right: 10,
  902. },
  903. series: [
  904. {
  905. name: title,
  906. type: "pie",
  907. radius: keyRule.radius ? keyRule.radius : ["40%", "70%"],
  908. avoidLabelOverlap: false,
  909. padAngle: keyRule.padAngle != undefined ? keyRule.padAngle : 5,
  910. itemStyle: {
  911. borderRadius: keyRule.borderRadius != undefined ? keyRule.borderRadius : 10,
  912. },
  913. label:
  914. keyRule.label != undefined
  915. ? keyRule.label
  916. : {
  917. show: false,
  918. position: "center",
  919. },
  920. emphasis: {
  921. label: {
  922. show: true,
  923. fontSize: 20,
  924. fontWeight: "bold",
  925. },
  926. },
  927. labelLine: {
  928. show: true,
  929. },
  930. data: keyRule.pieData,
  931. },
  932. ],
  933. };
  934. break;
  935. case "bar":
  936. // 柱状图
  937. _option = {
  938. tooltip: {
  939. trigger: "axis",
  940. axisPointer: {
  941. type: "shadow",
  942. },
  943. },
  944. legend: {
  945. show: keyRule.showLegend ? keyRule.showLegend : false,
  946. data: keyRule.legend,
  947. },
  948. xAxis: {
  949. type: "value",
  950. axisLabel: {
  951. color: "#42a5f5cc", // 字体颜色(支持十六进制、RGB、颜色名)
  952. fontSize: 14, // 可选:字体大小
  953. fontWeight: "normal", // 可选:字体粗细
  954. },
  955. splitLine: { lineStyle: { color: "#42a5f532" } },
  956. },
  957. yAxis: {
  958. type: "category",
  959. data: keyRule.xData,
  960. axisLabel: {
  961. color: "#F2F3F5cc", // 字体颜色(支持十六进制、RGB、颜色名)
  962. fontSize: 14, // 可选:字体大小
  963. fontWeight: "normal", // 可选:字体粗细
  964. },
  965. },
  966. series: [
  967. {
  968. name: keyRule.yData.name,
  969. type: "bar",
  970. label: {
  971. show: true,
  972. },
  973. emphasis: {
  974. focus: "series",
  975. },
  976. data: keyRule.yData.data,
  977. },
  978. ],
  979. };
  980. break;
  981. default:
  982. // 雷达图
  983. _option = {
  984. tooltip: {
  985. trigger: "axis",
  986. },
  987. legend: {
  988. show: false,
  989. left: "center",
  990. },
  991. radar: [
  992. {
  993. indicator: [
  994. { name: "健壮性", max: 100 },
  995. { name: "完整性", max: 100 },
  996. { name: "一致性", max: 100 },
  997. { name: "及时性", max: 100 },
  998. { name: "准确性", max: 100 },
  999. ],
  1000. },
  1001. ],
  1002. series: [
  1003. {
  1004. type: "radar",
  1005. areaStyle: {},
  1006. data: [
  1007. {
  1008. value: [93, 85, 92, 95, 93],
  1009. name: "",
  1010. },
  1011. ],
  1012. },
  1013. ],
  1014. };
  1015. break;
  1016. }
  1017. this.chartOptions[title] = _option;
  1018. },
  1019. // 服务调用列表
  1020. initTableDatas(serviceTypeDatas2) {
  1021. this.tableDatas = serviceTypeDatas2;
  1022. },
  1023. // 时间范围自定义时间
  1024. shortcuts() {
  1025. return [
  1026. {
  1027. text: "当天",
  1028. value: () => {
  1029. const end = new Date();
  1030. const start = new Date();
  1031. return [start, end];
  1032. },
  1033. },
  1034. {
  1035. text: "最近7天",
  1036. value: () => {
  1037. const end = new Date();
  1038. const start = new Date();
  1039. start.setTime(start.getTime() - 3600 * 1000 * 24 * 6);
  1040. return [start, end];
  1041. },
  1042. },
  1043. {
  1044. text: "最近30天",
  1045. value: () => {
  1046. const end = new Date();
  1047. const start = new Date();
  1048. start.setTime(start.getTime() - 3600 * 1000 * 24 * 29);
  1049. return [start, end];
  1050. },
  1051. },
  1052. {
  1053. text: "最近90天",
  1054. value: () => {
  1055. const end = new Date();
  1056. const start = new Date();
  1057. start.setTime(start.getTime() - 3600 * 1000 * 24 * 89);
  1058. return [start, end];
  1059. },
  1060. },
  1061. {
  1062. text: "最近1年",
  1063. value: () => {
  1064. const end = new Date();
  1065. const start = new Date();
  1066. start.setTime(start.getTime() - 3600 * 1000 * 24 * 364);
  1067. return [start, end];
  1068. },
  1069. },
  1070. ];
  1071. },
  1072. },
  1073. };
  1074. </script>
  1075. <style lang="less" scoped>
  1076. .mainBox {
  1077. width: calc(100% - 60px);
  1078. margin: 30px;
  1079. padding-bottom: 80px;
  1080. & > div {
  1081. margin: 20px 0;
  1082. display: flex;
  1083. }
  1084. .card {
  1085. width: calc(25% - 56px);
  1086. border-radius: 5px;
  1087. padding: 20px 18px;
  1088. // background: #00000032;
  1089. background: #eeeeee0b;
  1090. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  1091. }
  1092. .card2 {
  1093. width: 100%;
  1094. border-radius: 5px;
  1095. padding: 20px 18px;
  1096. // background: rgba(255, 255, 255, 0.1);
  1097. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  1098. }
  1099. .bigCard {
  1100. width: calc(100% - 36px);
  1101. border-radius: 5px;
  1102. padding: 20px 18px;
  1103. // background: #00000032;
  1104. position: relative;
  1105. flex-direction: column;
  1106. background: #eeeeee0b;
  1107. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  1108. .tools {
  1109. position: absolute;
  1110. top: 20px;
  1111. right: 20px;
  1112. display: flex;
  1113. flex-direction: row;
  1114. justify-content: flex-end;
  1115. }
  1116. &_title {
  1117. font-size: 20px;
  1118. font-weight: bold;
  1119. }
  1120. }
  1121. .flex {
  1122. display: flex;
  1123. flex-direction: row;
  1124. justify-content: space-between;
  1125. }
  1126. .flex_column {
  1127. display: flex;
  1128. flex-direction: column;
  1129. justify-content: space-between;
  1130. align-items: flex-start;
  1131. box-sizing: border-box;
  1132. }
  1133. .searchBox {
  1134. width: 100%;
  1135. height: 50px;
  1136. line-height: 50px;
  1137. text-align: center;
  1138. font-size: 20px;
  1139. font-weight: bold;
  1140. flex-direction: row-reverse;
  1141. display: flex;
  1142. }
  1143. }
  1144. // 日期选择框样式
  1145. .demo-date-picker {
  1146. display: flex;
  1147. width: 100%;
  1148. padding: 0;
  1149. flex-wrap: wrap;
  1150. }
  1151. .demo-date-picker .block {
  1152. padding: 1.5rem 0;
  1153. text-align: center;
  1154. border-right: solid 1px var(--el-border-color);
  1155. flex: 1;
  1156. min-width: 400px;
  1157. display: flex;
  1158. flex-direction: column;
  1159. align-items: center;
  1160. }
  1161. .demo-date-picker .block:last-child {
  1162. border-right: none;
  1163. }
  1164. .demo-date-picker .demonstration {
  1165. display: block;
  1166. color: var(--el-text-color-secondary);
  1167. font-size: 14px;
  1168. margin-bottom: 1rem;
  1169. }
  1170. @media screen and (max-width: 1200px) {
  1171. .demo-date-picker .block {
  1172. flex: 0 0 100%;
  1173. padding: 1rem 0;
  1174. min-width: auto;
  1175. border-right: none;
  1176. border-bottom: solid 1px var(--el-border-color);
  1177. }
  1178. .demo-date-picker .block:last-child {
  1179. border-bottom: none;
  1180. }
  1181. }
  1182. // 弹窗加载状态图标
  1183. .loading-icon {
  1184. // 图标顺时针旋转动画
  1185. animation: loading-icon-spin 2s linear infinite;
  1186. }
  1187. @keyframes loading-icon-spin {
  1188. 0% {
  1189. transform: rotate(0deg);
  1190. }
  1191. 100% {
  1192. transform: rotate(360deg);
  1193. }
  1194. }
  1195. </style>