synthesize-statistics.component.ts 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. import { Router } from '@angular/router';
  2. import { Component, OnInit, ViewChild, AfterViewInit } from "@angular/core";
  3. import { MainService } from 'src/app/services/main.service';
  4. import { TabService } from '../../services/tab.service';
  5. import { CustomChangeDateComponent } from '../../components/custom-change-date/custom-change-date.component';
  6. @Component({
  7. selector: "app-synthesize-statistics",
  8. templateUrl: "./synthesize-statistics.component.html",
  9. styleUrls: ["./synthesize-statistics.component.less"],
  10. })
  11. export class SynthesizeStatisticsComponent implements OnInit, AfterViewInit {
  12. @ViewChild('customChangeDate', { static: false }) customChangeDateComponent!: CustomChangeDateComponent;
  13. constructor(
  14. private mainService: MainService,
  15. private tabService: TabService,
  16. public router: Router,
  17. ) {}
  18. isLoading:Boolean = false;
  19. workData:any = []; //工单统计
  20. listOfData: any[] = []; //表格数据
  21. pageIndex: number = 1; //表格当前页码
  22. pageSize: number = 10; //表格每页展示条数
  23. listLength: number = 10; //表格总数据量
  24. activeIndex:any = 0;
  25. maintainData:any = []; //维修处理数据
  26. repairsOptions:any={} //报修来源 option
  27. malfunctionOptions:any={} //一级故障 option
  28. buildingOptions:any={} //楼栋报修 option
  29. deptCostData:any = [
  30. {
  31. name:'王'
  32. },
  33. {
  34. name:'王'
  35. },
  36. {
  37. name:'王'
  38. },
  39. {
  40. name:'王'
  41. },
  42. {
  43. name:'王'
  44. }
  45. ] //科室费用
  46. consumableData:any = [
  47. {
  48. name:'王'
  49. },
  50. {
  51. name:'王'
  52. },
  53. {
  54. name:'王'
  55. },
  56. {
  57. name:'王'
  58. },
  59. {
  60. name:'王'
  61. }
  62. ] //报修耗材
  63. ngOnInit() {}
  64. ngAfterViewInit(){
  65. setTimeout(() => {
  66. this.search();
  67. }, 0)
  68. }
  69. /*========= 数据下钻 ========*/
  70. // 汇总
  71. viewDetail1(){
  72. let query = {
  73. }
  74. let path = '/newStatistics/maintenanceStatistics/incidentList'
  75. let flag = this.tabService.tabs.some(v => v.path === path);
  76. flag && this.tabService.deleteRouteSnapshot(path);
  77. this.tabService.setQueryParams('dateRange', [this.customChangeDateComponent.startDate, this.customChangeDateComponent.endDate]);
  78. this.tabService.setQueryParams('defRange', this.customChangeDateComponent.defRange);
  79. sessionStorage.setItem('maintenanceData', JSON.stringify(query))
  80. this.router.navigate([path], { replaceUrl: true });
  81. // this.router.navigateByUrl('/newStatistics/maintenanceStatistics/incidentList')
  82. }
  83. // 挂起
  84. viewDetail2(){
  85. let query = {
  86. startDate: this.customChangeDateComponent.startDate,
  87. endDate: this.customChangeDateComponent.endDate,
  88. searchQuery:{
  89. isHangId: 1,
  90. isHangDTO:{
  91. id: 1,
  92. name: "是"
  93. }
  94. }
  95. }
  96. let path = '/newStatistics/maintenanceStatistics/incidentList'
  97. let flag = this.tabService.tabs.some(v => v.path === path);
  98. flag && this.tabService.deleteRouteSnapshot(path);
  99. this.tabService.setQueryParams('dateRange', [this.customChangeDateComponent.startDate, this.customChangeDateComponent.endDate]);
  100. this.tabService.setQueryParams('defRange', this.customChangeDateComponent.defRange);
  101. sessionStorage.setItem('maintenanceData', JSON.stringify(query))
  102. this.router.navigate([path], { replaceUrl: true });
  103. }
  104. // 超时
  105. viewDetail3(){
  106. let query = {
  107. startDate: this.customChangeDateComponent.startDate,
  108. endDate: this.customChangeDateComponent.endDate,
  109. searchQuery:{
  110. overtimeId: 1,
  111. overtimeDTO:{
  112. id: 1,
  113. name: "是"
  114. }
  115. }
  116. }
  117. let path = '/newStatistics/maintenanceStatistics/incidentList'
  118. let flag = this.tabService.tabs.some(v => v.path === path);
  119. flag && this.tabService.deleteRouteSnapshot(path);
  120. this.tabService.setQueryParams('dateRange', [this.customChangeDateComponent.startDate, this.customChangeDateComponent.endDate]);
  121. this.tabService.setQueryParams('defRange', this.customChangeDateComponent.defRange);
  122. sessionStorage.setItem('maintenanceData', JSON.stringify(query))
  123. this.router.navigate([path], { replaceUrl: true });
  124. }
  125. // 差评
  126. viewDetail4(){
  127. let query = {
  128. startDate: this.customChangeDateComponent.startDate,
  129. endDate: this.customChangeDateComponent.endDate,
  130. searchQuery:{
  131. evaluateId: 20424,
  132. evaluateDTO: {
  133. "id": 20424,
  134. "key": "incident_degree",
  135. "name": "不满意",
  136. "value": "1",
  137. "orders": 5,
  138. "extra1": "",
  139. "extra2": ""
  140. }
  141. }
  142. }
  143. let path = '/newStatistics/maintenanceStatistics/incidentList'
  144. let flag = this.tabService.tabs.some(v => v.path === path);
  145. flag && this.tabService.deleteRouteSnapshot(path);
  146. this.tabService.setQueryParams('dateRange', [this.customChangeDateComponent.startDate, this.customChangeDateComponent.endDate]);
  147. this.tabService.setQueryParams('defRange', this.customChangeDateComponent.defRange);
  148. sessionStorage.setItem('maintenanceData', JSON.stringify(query))
  149. this.router.navigate([path], { replaceUrl: true });
  150. }
  151. // 维修处理top5
  152. viewMaintain1(data){
  153. let query = {
  154. startDate: this.customChangeDateComponent.startDate,
  155. endDate: this.customChangeDateComponent.endDate,
  156. searchQuery:{
  157. statusValue: 'close',
  158. groupId:null,
  159. groupDTO:null,
  160. userId:null,
  161. userDTO:null
  162. }
  163. }
  164. if(this.activeIndex==0){
  165. query.searchQuery.userId = data.userId ? data.userId : -1
  166. query.searchQuery.userDTO = {
  167. name: data.name,
  168. id: data.userId
  169. }
  170. delete query.searchQuery.groupId
  171. delete query.searchQuery.groupDTO
  172. }else{
  173. query.searchQuery.groupId = data.groupId ? data.groupId: -1
  174. query.searchQuery.groupDTO = {
  175. groupName: data.name,
  176. id: data.groupId
  177. }
  178. delete query.searchQuery.userId
  179. delete query.searchQuery.userDTO
  180. }
  181. let path = '/newStatistics/maintenanceStatistics/incidentList'
  182. let flag = this.tabService.tabs.some(v => v.path === path);
  183. flag && this.tabService.deleteRouteSnapshot(path);
  184. this.tabService.setQueryParams('dateRange', [this.customChangeDateComponent.startDate, this.customChangeDateComponent.endDate]);
  185. this.tabService.setQueryParams('defRange', this.customChangeDateComponent.defRange);
  186. sessionStorage.setItem('maintenanceData', JSON.stringify(query))
  187. this.router.navigate([path], { replaceUrl: true });
  188. }
  189. viewMaintain2(data){
  190. let query = {
  191. startDate: this.customChangeDateComponent.startDate,
  192. endDate: this.customChangeDateComponent.endDate,
  193. searchQuery:{
  194. statusValue: 'close',
  195. groupId:null,
  196. userId:null,
  197. groupDTO:null,
  198. userDTO:null,
  199. overtimeId: 1,
  200. overtimeDTO:{
  201. id: 1,
  202. name: "是"
  203. }
  204. }
  205. }
  206. if(this.activeIndex==0){
  207. query.searchQuery.userId = data.userId ? data.userId : -1
  208. query.searchQuery.userDTO = {
  209. name: data.name,
  210. id: data.userId
  211. }
  212. delete query.searchQuery.groupId
  213. delete query.searchQuery.groupDTO
  214. }else{
  215. query.searchQuery.groupId = data.groupId ? data.groupId: -1
  216. query.searchQuery.groupDTO = {
  217. groupName: data.name,
  218. id: data.groupId
  219. }
  220. delete query.searchQuery.userId
  221. delete query.searchQuery.userDTO
  222. }
  223. let path = '/newStatistics/maintenanceStatistics/incidentList'
  224. let flag = this.tabService.tabs.some(v => v.path === path);
  225. flag && this.tabService.deleteRouteSnapshot(path);
  226. this.tabService.setQueryParams('dateRange', [this.customChangeDateComponent.startDate, this.customChangeDateComponent.endDate]);
  227. this.tabService.setQueryParams('defRange', this.customChangeDateComponent.defRange);
  228. sessionStorage.setItem('maintenanceData', JSON.stringify(query))
  229. this.router.navigate([path], { replaceUrl: true });
  230. }
  231. // 课科室费用top5
  232. viewDept(data){
  233. let query = {
  234. startDate: this.customChangeDateComponent.startDate,
  235. endDate: this.customChangeDateComponent.endDate,
  236. repairDeptId: data.repairDeptId ? data.repairDeptId : -1,
  237. searchQuery:{
  238. statusValue: 'close',
  239. }
  240. }
  241. let path = '/newStatistics/maintenanceStatistics/incidentList'
  242. let flag = this.tabService.tabs.some(v => v.path === path);
  243. flag && this.tabService.deleteRouteSnapshot(path);
  244. this.tabService.setQueryParams('dateRange', [this.customChangeDateComponent.startDate, this.customChangeDateComponent.endDate]);
  245. this.tabService.setQueryParams('defRange', this.customChangeDateComponent.defRange);
  246. sessionStorage.setItem('maintenanceData', JSON.stringify(query))
  247. this.router.navigate([path], { replaceUrl: true });
  248. }
  249. // 维修处理类型切换
  250. selectCheck(type){
  251. this.activeIndex = type
  252. this.getMaintainData();
  253. }
  254. // 故障来源
  255. repairsChart() {
  256. let postData:any = {
  257. startDate: this.customChangeDateComponent.startDate || undefined,
  258. endDate: this.customChangeDateComponent.endDate || undefined,
  259. type: 'sourceTop5',
  260. hosId: this.hosId,
  261. dutyId: this.dutyId,
  262. parentDutyId: this.parentDutyId,
  263. };
  264. this.mainService
  265. .getReportData(postData)
  266. .subscribe((result:any) => {
  267. let datas = result.data.map(i=>{
  268. return{
  269. name:i.name,
  270. value:i.sum
  271. }
  272. });
  273. this.repairsOptions = {
  274. tooltip: {
  275. trigger: "item",
  276. formatter: "{b}: {c} ({d}%)",
  277. },
  278. legend: {
  279. data: datas,
  280. left: 'left',
  281. },
  282. series: [
  283. {
  284. name: "",
  285. type: "pie",
  286. radius: ["30%", "50%"],
  287. center:["50%","55%"],
  288. data: datas,
  289. emphasis: {
  290. itemStyle: {
  291. shadowBlur: 10,
  292. shadowOffsetX: 0,
  293. shadowColor: 'rgba(0, 0, 0, 0.5)'
  294. }
  295. },
  296. label: {
  297. show: true,
  298. formatter: '{b}: {c} {d}%'
  299. },
  300. itemStyle: {
  301. normal: {
  302. //每根柱子颜色设置
  303. color: function (params) {
  304. let colorList = [
  305. "#33CC85",
  306. "#72C0DD",
  307. "#FAC958",
  308. "#546FC6",
  309. "#d35b7e",
  310. "#778ccC",
  311. "#fad354",
  312. "#aldee0",
  313. "#ee84a8",
  314. "#8475c5",
  315. "#b0d097",
  316. "#ffadbb",
  317. "#fd8c67",
  318. "#d495e0",
  319. ];
  320. return colorList[params.dataIndex];
  321. },
  322. },
  323. },
  324. },
  325. ],
  326. };
  327. });
  328. }
  329. // 一级故障
  330. malfunctionChart(){
  331. let postData:any = {
  332. startDate: this.customChangeDateComponent.startDate || undefined,
  333. endDate: this.customChangeDateComponent.endDate || undefined,
  334. type: 'firstCategoryTop5',
  335. hosId: this.hosId,
  336. dutyId: this.dutyId,
  337. parentDutyId: this.parentDutyId,
  338. };
  339. this.mainService
  340. .getReportData(postData)
  341. .subscribe((result:any) => {
  342. let datas = []
  343. let title = []
  344. for(let i of result.data){
  345. datas.push(i.sum)
  346. title.push(i.category)
  347. }
  348. this.malfunctionOptions = {
  349. tooltip: {
  350. trigger: 'axis',
  351. axisPointer: {
  352. type: 'shadow'
  353. }
  354. },
  355. grid: {
  356. top: '10%',
  357. left: '3%', // grid布局设置适当调整避免X轴文字只能部分显示
  358. right: '3%', // grid布局设置适当调整避免X轴文字只能部分显示
  359. bottom: '6%',
  360. containLabel: true
  361. },
  362. xAxis: [
  363. {
  364. type: 'category',
  365. data: title,
  366. axisTick: {
  367. show:false,
  368. alignWithLabel: true
  369. },
  370. axisLabel: {
  371. show: true, // 是否显示刻度标签,默认显示
  372. interval: 0, // 坐标轴刻度标签的显示间隔,在类目轴中有效;默认会采用标签不重叠的策略间隔显示标签;可以设置成0强制显示所有标签;如果设置为1,表示『隔一个标签显示一个标签』,如果值为2,表示隔两个标签显示一个标签,以此类推。
  373. rotate: 0, // 刻度标签旋转的角度,在类目轴的类目标签显示不下的时候可以通过旋转防止标签之间重叠;旋转的角度从-90度到90度
  374. inside: false, // 刻度标签是否朝内,默认朝外
  375. margin: 6, // 刻度标签与轴线之间的距离
  376. }
  377. }
  378. ],
  379. yAxis: [
  380. {
  381. type: 'value',
  382. axisLine: {
  383. show:false
  384. },
  385. axisTick:{
  386. show:false
  387. }
  388. }
  389. ],
  390. series: [
  391. {
  392. type: 'bar',
  393. barWidth: '30%',
  394. color: '#FFD68D',
  395. data: datas,
  396. label:{
  397. show:true,
  398. position: "top", // 展示在柱子的上方
  399. color: "#333"
  400. }
  401. }
  402. ]
  403. }
  404. });
  405. }
  406. // 楼栋报修
  407. buildingChart(){
  408. let postData:any = {
  409. startDate: this.customChangeDateComponent.startDate || undefined,
  410. endDate: this.customChangeDateComponent.endDate || undefined,
  411. type: 'buildingTop5',
  412. hosId: this.hosId,
  413. dutyId: this.dutyId,
  414. parentDutyId: this.parentDutyId,
  415. };
  416. this.mainService
  417. .getReportData(postData)
  418. .subscribe((result:any) => {
  419. let datas = []
  420. let title = []
  421. for(let i of result.data){
  422. datas.push(i.sum)
  423. title.push(i.name)
  424. }
  425. this.buildingOptions = {
  426. tooltip: {
  427. trigger: 'axis',
  428. axisPointer: {
  429. type: 'shadow'
  430. }
  431. },
  432. grid: {
  433. top: '10%',
  434. left: '3%', // grid布局设置适当调整避免X轴文字只能部分显示
  435. right: '3%', // grid布局设置适当调整避免X轴文字只能部分显示
  436. bottom: '6%',
  437. containLabel: true
  438. },
  439. xAxis: [
  440. {
  441. type: 'category',
  442. data: title,
  443. axisTick: {
  444. show:false,
  445. alignWithLabel: true
  446. },
  447. axisLabel: {
  448. show: true, // 是否显示刻度标签,默认显示
  449. interval: 0, // 坐标轴刻度标签的显示间隔,在类目轴中有效;默认会采用标签不重叠的策略间隔显示标签;可以设置成0强制显示所有标签;如果设置为1,表示『隔一个标签显示一个标签』,如果值为2,表示隔两个标签显示一个标签,以此类推。
  450. rotate: 0, // 刻度标签旋转的角度,在类目轴的类目标签显示不下的时候可以通过旋转防止标签之间重叠;旋转的角度从-90度到90度
  451. inside: false, // 刻度标签是否朝内,默认朝外
  452. margin: 6, // 刻度标签与轴线之间的距离
  453. }
  454. }
  455. ],
  456. yAxis: [
  457. {
  458. type: 'value',
  459. axisLine: {
  460. show:false
  461. },
  462. axisTick:{
  463. show:false
  464. }
  465. }
  466. ],
  467. series: [
  468. {
  469. type: 'bar',
  470. barWidth: '30%',
  471. color: '#72C0DD',
  472. data: datas,
  473. label:{
  474. show:true,
  475. position: "top", // 展示在柱子的上方
  476. color: "#333"
  477. }
  478. }
  479. ]
  480. }
  481. });
  482. }
  483. // 科室费用
  484. getDeptCostData() {
  485. let postData:any = {
  486. startDate: this.customChangeDateComponent.startDate || undefined,
  487. endDate: this.customChangeDateComponent.endDate || undefined,
  488. type: 'deptTop5',
  489. hosId: this.hosId,
  490. dutyId: this.dutyId,
  491. parentDutyId: this.parentDutyId,
  492. };
  493. this.mainService
  494. .getReportData(postData)
  495. .subscribe((result:any) => {
  496. this.deptCostData = result.data || [];
  497. });
  498. }
  499. // 耗材
  500. getConsumableData() {
  501. let postData:any = {
  502. startDate: this.customChangeDateComponent.startDate || undefined,
  503. endDate: this.customChangeDateComponent.endDate || undefined,
  504. type: 'consumableTop5',
  505. hosId: this.hosId,
  506. dutyId: this.dutyId,
  507. parentDutyId: this.parentDutyId,
  508. };
  509. this.mainService
  510. .getReportData(postData)
  511. .subscribe((result:any) => {
  512. this.isLoading = false;
  513. this.consumableData = result.data || [];
  514. });
  515. }
  516. // 更多跳转
  517. toPath(path){
  518. let flag = this.tabService.tabs.some(v => v.path === path);
  519. flag && this.tabService.deleteRouteSnapshot(path);
  520. this.tabService.setQueryParams('dateRange', [this.customChangeDateComponent.startDate, this.customChangeDateComponent.endDate]);
  521. this.tabService.setQueryParams('defRange', this.customChangeDateComponent.defRange);
  522. this.router.navigate([path], { replaceUrl: true });
  523. }
  524. // 判断更多是否显示
  525. showMore(path){
  526. let menus = JSON.parse(localStorage.getItem("menu"));
  527. return menus.find(v => v.link === 'maintenanceStatistics').childrens.some(v => v.link === path);
  528. }
  529. // 初始化缓存数据
  530. queryType:any;
  531. hosId:any;
  532. dutyId:any;
  533. parentDutyId:any;
  534. initSessionData(){
  535. let newStatistics = JSON.parse(sessionStorage.getItem('newStatistics'));
  536. let queryType:any = newStatistics.queryType;
  537. let hosId:any = newStatistics.hospitalId;
  538. let dutyId:any = newStatistics.dutyId;
  539. queryType = queryType ? +queryType : undefined;
  540. hosId = hosId ? +hosId : undefined;
  541. dutyId = dutyId ? +dutyId : undefined;
  542. this.queryType = queryType;
  543. if(queryType == 1){
  544. this.hosId = undefined;
  545. this.dutyId = undefined;
  546. this.parentDutyId = undefined;
  547. }else if(queryType == 2){
  548. this.hosId = hosId;
  549. this.dutyId = undefined;
  550. this.parentDutyId = undefined;
  551. }else if(queryType == 3){
  552. this.hosId = undefined;
  553. this.dutyId = dutyId;
  554. this.parentDutyId = undefined;
  555. }else if(queryType == 4){
  556. this.hosId = undefined;
  557. this.dutyId = undefined;
  558. this.parentDutyId = dutyId;
  559. }
  560. this.isLoading = true
  561. this.getWorkData();
  562. this.getMaintainData();
  563. this.repairsChart();
  564. this.malfunctionChart();
  565. this.buildingChart();
  566. this.getDeptCostData();
  567. this.getConsumableData();
  568. }
  569. // 表格数据
  570. loading1 = false;
  571. getList(num?: number, field?: string, sort?: string) {
  572. if (num !== undefined) {
  573. this.pageIndex = num;
  574. }
  575. let postData:any = {
  576. idx: this.pageIndex - 1,
  577. sum: this.pageSize,
  578. startDate: this.customChangeDateComponent.startDate || undefined,
  579. endDate: this.customChangeDateComponent.endDate || undefined,
  580. hosId: this.hosId,
  581. dutyId: this.dutyId,
  582. parentDutyId: this.parentDutyId,
  583. };
  584. this.loading1 = true;
  585. this.mainService
  586. .postCustom("itsm/report", "incidentWorkOrder", postData)
  587. .subscribe((result) => {
  588. this.loading1 = false;
  589. this.listOfData = result.dataList || [];
  590. this.listLength = result.totalCount;
  591. });
  592. }
  593. // 头部工单数据
  594. getWorkData() {
  595. let postData:any = {
  596. startDate: this.customChangeDateComponent.startDate || undefined,
  597. endDate: this.customChangeDateComponent.endDate || undefined,
  598. type: 'headerCount',
  599. hosId: this.hosId,
  600. dutyId: this.dutyId,
  601. parentDutyId: this.parentDutyId,
  602. };
  603. this.mainService
  604. .getReportData(postData)
  605. .subscribe((result:any) => {
  606. this.workData = result.data[0] || [];
  607. });
  608. }
  609. // 维修处理
  610. getMaintainData() {
  611. let postData:any = {
  612. startDate: this.customChangeDateComponent.startDate || undefined,
  613. endDate: this.customChangeDateComponent.endDate || undefined,
  614. type: 'userHandleTop5',
  615. groupType: this.activeIndex==0?'user':'group',
  616. hosId: this.hosId,
  617. dutyId: this.dutyId,
  618. parentDutyId: this.parentDutyId,
  619. };
  620. this.mainService
  621. .getReportData(postData)
  622. .subscribe((result:any) => {
  623. this.maintainData = result.data || [];
  624. });
  625. }
  626. // 重置
  627. reset(){
  628. this.dateRange = [];
  629. this.activeIndex = 0;
  630. this.customChangeDateComponent.resetByDate();
  631. sessionStorage.removeItem('maintenanceData');
  632. setTimeout(_=>{
  633. this.search();
  634. })
  635. }
  636. // 搜索
  637. search() {
  638. this.initSessionData();
  639. }
  640. // 日期选择 日
  641. dateRange: any = []; //发起时间区间 天
  642. }