StatisticalAnalysis.vue 42 KB

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