|
@@ -0,0 +1,515 @@
|
|
1
|
+import { Router } from '@angular/router';
|
|
2
|
+import { format, addMonths, startOfMonth, endOfMonth } from 'date-fns';
|
|
3
|
+import { Component, OnInit } from "@angular/core";
|
|
4
|
+import { MainService } from 'src/app/services/main.service';
|
|
5
|
+import { TabService } from '../../services/tab.service';
|
|
6
|
+@Component({
|
|
7
|
+ selector: "app-distribution-synthesize-statistics",
|
|
8
|
+ templateUrl: "./distribution-synthesize-statistics.component.html",
|
|
9
|
+ styleUrls: ["./distribution-synthesize-statistics.component.less"],
|
|
10
|
+})
|
|
11
|
+export class DistributionSynthesizeStatisticsComponent implements OnInit {
|
|
12
|
+ constructor(
|
|
13
|
+ private mainService: MainService,
|
|
14
|
+ private tabService: TabService,
|
|
15
|
+ public router: Router,
|
|
16
|
+ ) {}
|
|
17
|
+
|
|
18
|
+ isLoading:Boolean = false;
|
|
19
|
+ workData:any = []; //工单统计
|
|
20
|
+ businessData:any = []; //业务统计
|
|
21
|
+ listOfData: any[] = []; //表格数据
|
|
22
|
+ pageIndex: number = 1; //表格当前页码
|
|
23
|
+ pageSize: number = 10; //表格每页展示条数
|
|
24
|
+ listLength: number = 10; //表格总数据量
|
|
25
|
+ activeIndex:any = 'day';
|
|
26
|
+ applyOptions:any={} //申请来源 option
|
|
27
|
+ trendOptions:any={} //日趋势图 option
|
|
28
|
+ businessOptions:any={} //业务分类 option
|
|
29
|
+ deptTopData:any = [
|
|
30
|
+ {
|
|
31
|
+ name:'王'
|
|
32
|
+ },
|
|
33
|
+ {
|
|
34
|
+ name:'王'
|
|
35
|
+ },
|
|
36
|
+ {
|
|
37
|
+ name:'王'
|
|
38
|
+ },
|
|
39
|
+ {
|
|
40
|
+ name:'王'
|
|
41
|
+ },
|
|
42
|
+ {
|
|
43
|
+ name:'王'
|
|
44
|
+ }
|
|
45
|
+ ] //科室top5
|
|
46
|
+ userTopData:any = [
|
|
47
|
+ {
|
|
48
|
+ name:'王'
|
|
49
|
+ },
|
|
50
|
+ {
|
|
51
|
+ name:'王'
|
|
52
|
+ },
|
|
53
|
+ {
|
|
54
|
+ name:'王'
|
|
55
|
+ },
|
|
56
|
+ {
|
|
57
|
+ name:'王'
|
|
58
|
+ },
|
|
59
|
+ {
|
|
60
|
+ name:'王'
|
|
61
|
+ }
|
|
62
|
+ ] //人员top5
|
|
63
|
+ ngOnInit() {
|
|
64
|
+ this.search();
|
|
65
|
+ }
|
|
66
|
+
|
|
67
|
+ // 维修处理类型切换
|
|
68
|
+ selectCheck(type){
|
|
69
|
+ this.activeIndex = type
|
|
70
|
+ this.trendChart();
|
|
71
|
+ }
|
|
72
|
+
|
|
73
|
+ // 申请来源
|
|
74
|
+ applyChart() {
|
|
75
|
+ let postData:any = {
|
|
76
|
+ startDate: this.dateRange[0],
|
|
77
|
+ endDate: this.dateRange[1],
|
|
78
|
+ type: 'sourceCount',
|
|
79
|
+ hosId: this.getHosId,
|
|
80
|
+ businessType: 'hsms',
|
|
81
|
+ };
|
|
82
|
+ this.mainService
|
|
83
|
+ .getReportData(postData)
|
|
84
|
+ .subscribe((result:any) => {
|
|
85
|
+ let datas = result.data.map(i=>{
|
|
86
|
+ return{
|
|
87
|
+ name:i.name,
|
|
88
|
+ value:i.sum
|
|
89
|
+ }
|
|
90
|
+ });
|
|
91
|
+ this.applyOptions = {
|
|
92
|
+ tooltip: {
|
|
93
|
+ trigger: "item",
|
|
94
|
+ formatter: "{b}: {c} ({d}%)",
|
|
95
|
+ },
|
|
96
|
+ legend: {
|
|
97
|
+ data: datas,
|
|
98
|
+ left: 'left',
|
|
99
|
+ },
|
|
100
|
+ series: [
|
|
101
|
+ {
|
|
102
|
+ name: "",
|
|
103
|
+ type: "pie",
|
|
104
|
+ radius: ["30%", "50%"],
|
|
105
|
+ center:["50%","60%"],
|
|
106
|
+ data: datas,
|
|
107
|
+ emphasis: {
|
|
108
|
+ itemStyle: {
|
|
109
|
+ shadowBlur: 10,
|
|
110
|
+ shadowOffsetX: 0,
|
|
111
|
+ shadowColor: 'rgba(0, 0, 0, 0.5)'
|
|
112
|
+ }
|
|
113
|
+ },
|
|
114
|
+ label: {
|
|
115
|
+ show: true,
|
|
116
|
+ formatter: '{b}: {c} {d}%'
|
|
117
|
+ },
|
|
118
|
+ itemStyle: {
|
|
119
|
+ normal: {
|
|
120
|
+ //每根柱子颜色设置
|
|
121
|
+ color: function (params) {
|
|
122
|
+ let colorList = [
|
|
123
|
+ "#33CC85",
|
|
124
|
+ "#72C0DD",
|
|
125
|
+ "#FAC958",
|
|
126
|
+ "#546FC6",
|
|
127
|
+ "#d35b7e",
|
|
128
|
+ "#778ccC",
|
|
129
|
+ "#fad354",
|
|
130
|
+ "#aldee0",
|
|
131
|
+ "#ee84a8",
|
|
132
|
+ "#8475c5",
|
|
133
|
+ "#b0d097",
|
|
134
|
+ "#ffadbb",
|
|
135
|
+ "#fd8c67",
|
|
136
|
+ "#d495e0",
|
|
137
|
+ ];
|
|
138
|
+ return colorList[params.dataIndex];
|
|
139
|
+ },
|
|
140
|
+ },
|
|
141
|
+ },
|
|
142
|
+ },
|
|
143
|
+ ],
|
|
144
|
+ };
|
|
145
|
+ });
|
|
146
|
+ }
|
|
147
|
+
|
|
148
|
+ // 日趋势图
|
|
149
|
+ trendChart(){
|
|
150
|
+ let postData:any = {
|
|
151
|
+ startDate: this.dateRange[0],
|
|
152
|
+ endDate: this.dateRange[1],
|
|
153
|
+ type: 'dateTimeTrend',
|
|
154
|
+ hosId: this.getHosId,
|
|
155
|
+ businessType: 'hsms',
|
|
156
|
+ dateType: this.activeIndex,
|
|
157
|
+ statisticsTypeId: this.statisticsTypeId || undefined,
|
|
158
|
+ };
|
|
159
|
+ this.mainService
|
|
160
|
+ .getReportData(postData)
|
|
161
|
+ .subscribe((result:any) => {
|
|
162
|
+ let datas = []
|
|
163
|
+ let title = []
|
|
164
|
+ for(let i of result.data){
|
|
165
|
+ datas.push(i.sum)
|
|
166
|
+ title.push(i.date)
|
|
167
|
+ }
|
|
168
|
+ this.trendOptions = {
|
|
169
|
+ tooltip: {
|
|
170
|
+ trigger: 'axis',
|
|
171
|
+ axisPointer: {
|
|
172
|
+ type: 'shadow'
|
|
173
|
+ }
|
|
174
|
+ },
|
|
175
|
+ grid: {
|
|
176
|
+ top: '10%',
|
|
177
|
+ left: '0%', // grid布局设置适当调整避免X轴文字只能部分显示
|
|
178
|
+ right: '0%', // grid布局设置适当调整避免X轴文字只能部分显示
|
|
179
|
+ bottom: '2%',
|
|
180
|
+ containLabel: true,
|
|
181
|
+ },
|
|
182
|
+ xAxis: [
|
|
183
|
+ {
|
|
184
|
+ type: 'category',
|
|
185
|
+ data: title,
|
|
186
|
+ axisTick: {
|
|
187
|
+ show:false,
|
|
188
|
+ alignWithLabel: true
|
|
189
|
+ },
|
|
190
|
+ axisLabel: {
|
|
191
|
+ show: true, // 是否显示刻度标签,默认显示
|
|
192
|
+ interval: 0, // 坐标轴刻度标签的显示间隔,在类目轴中有效;默认会采用标签不重叠的策略间隔显示标签;可以设置成0强制显示所有标签;如果设置为1,表示『隔一个标签显示一个标签』,如果值为2,表示隔两个标签显示一个标签,以此类推。
|
|
193
|
+ rotate: 0, // 刻度标签旋转的角度,在类目轴的类目标签显示不下的时候可以通过旋转防止标签之间重叠;旋转的角度从-90度到90度
|
|
194
|
+ inside: false, // 刻度标签是否朝内,默认朝外
|
|
195
|
+ margin: 6, // 刻度标签与轴线之间的距离
|
|
196
|
+ }
|
|
197
|
+ }
|
|
198
|
+ ],
|
|
199
|
+ yAxis: [
|
|
200
|
+ {
|
|
201
|
+ type: 'value',
|
|
202
|
+ axisLine: {
|
|
203
|
+ show:false
|
|
204
|
+ },
|
|
205
|
+ axisTick:{
|
|
206
|
+ show:false
|
|
207
|
+ },
|
|
208
|
+ splitLine: {
|
|
209
|
+ lineStyle: {
|
|
210
|
+ type: 'dotted',
|
|
211
|
+ }
|
|
212
|
+ }
|
|
213
|
+ }
|
|
214
|
+ ],
|
|
215
|
+ series: [
|
|
216
|
+ {
|
|
217
|
+ type: 'line',
|
|
218
|
+ color: '#3AACFF',
|
|
219
|
+ data: datas,
|
|
220
|
+ label:{
|
|
221
|
+ show: true,
|
|
222
|
+ position: "top", // 展示在上方
|
|
223
|
+ color: "#333"
|
|
224
|
+ },
|
|
225
|
+ }
|
|
226
|
+ ]
|
|
227
|
+ }
|
|
228
|
+ });
|
|
229
|
+ }
|
|
230
|
+
|
|
231
|
+ // 业务分类
|
|
232
|
+ businessChart(){
|
|
233
|
+ let postData:any = {
|
|
234
|
+ startDate: this.dateRange[0],
|
|
235
|
+ endDate: this.dateRange[1],
|
|
236
|
+ type: 'statisticsDateTypeTop5',
|
|
237
|
+ hosId: this.getHosId,
|
|
238
|
+ businessType: 'hsms',
|
|
239
|
+ };
|
|
240
|
+ this.mainService
|
|
241
|
+ .getReportData(postData)
|
|
242
|
+ .subscribe((result:any) => {
|
|
243
|
+ let datas = []
|
|
244
|
+ let title = []
|
|
245
|
+ for(let i of result.data){
|
|
246
|
+ datas.push(i.sum)
|
|
247
|
+ title.push(i.statisticsDateType)
|
|
248
|
+ }
|
|
249
|
+ this.businessOptions = {
|
|
250
|
+ tooltip: {
|
|
251
|
+ trigger: 'axis',
|
|
252
|
+ axisPointer: {
|
|
253
|
+ type: 'shadow'
|
|
254
|
+ }
|
|
255
|
+ },
|
|
256
|
+ grid: {
|
|
257
|
+ top: '10%',
|
|
258
|
+ left: '0%', // grid布局设置适当调整避免X轴文字只能部分显示
|
|
259
|
+ right: '0%', // grid布局设置适当调整避免X轴文字只能部分显示
|
|
260
|
+ bottom: '6%',
|
|
261
|
+ containLabel: true
|
|
262
|
+ },
|
|
263
|
+ xAxis: [
|
|
264
|
+ {
|
|
265
|
+ type: 'category',
|
|
266
|
+ data: title,
|
|
267
|
+ axisTick: {
|
|
268
|
+ show:false,
|
|
269
|
+ alignWithLabel: true
|
|
270
|
+ },
|
|
271
|
+ axisLabel: {
|
|
272
|
+ show: true, // 是否显示刻度标签,默认显示
|
|
273
|
+ interval: 0, // 坐标轴刻度标签的显示间隔,在类目轴中有效;默认会采用标签不重叠的策略间隔显示标签;可以设置成0强制显示所有标签;如果设置为1,表示『隔一个标签显示一个标签』,如果值为2,表示隔两个标签显示一个标签,以此类推。
|
|
274
|
+ rotate: 0, // 刻度标签旋转的角度,在类目轴的类目标签显示不下的时候可以通过旋转防止标签之间重叠;旋转的角度从-90度到90度
|
|
275
|
+ inside: false, // 刻度标签是否朝内,默认朝外
|
|
276
|
+ margin: 6, // 刻度标签与轴线之间的距离
|
|
277
|
+ }
|
|
278
|
+ }
|
|
279
|
+ ],
|
|
280
|
+ yAxis: [
|
|
281
|
+ {
|
|
282
|
+ type: 'value',
|
|
283
|
+ axisLine: {
|
|
284
|
+ show:false
|
|
285
|
+ },
|
|
286
|
+ axisTick:{
|
|
287
|
+ show:false
|
|
288
|
+ },
|
|
289
|
+ splitLine: {
|
|
290
|
+ lineStyle: {
|
|
291
|
+ type: 'dotted',
|
|
292
|
+ }
|
|
293
|
+ }
|
|
294
|
+ }
|
|
295
|
+ ],
|
|
296
|
+ series: [
|
|
297
|
+ {
|
|
298
|
+ type: 'bar',
|
|
299
|
+ barWidth: 20,
|
|
300
|
+ color: '#FFD68D',
|
|
301
|
+ data: datas,
|
|
302
|
+ label:{
|
|
303
|
+ show:true,
|
|
304
|
+ position: "top", // 展示在柱子的上方
|
|
305
|
+ color: "#333"
|
|
306
|
+ }
|
|
307
|
+ }
|
|
308
|
+ ]
|
|
309
|
+ }
|
|
310
|
+ });
|
|
311
|
+ }
|
|
312
|
+
|
|
313
|
+ // 科室Top5
|
|
314
|
+ getDeptTopData() {
|
|
315
|
+ let postData:any = {
|
|
316
|
+ startDate: this.dateRange[0],
|
|
317
|
+ endDate: this.dateRange[1],
|
|
318
|
+ type: 'deptTop5',
|
|
319
|
+ hosId: this.getHosId,
|
|
320
|
+ businessType: 'hsms',
|
|
321
|
+ };
|
|
322
|
+ this.mainService
|
|
323
|
+ .getReportData(postData)
|
|
324
|
+ .subscribe((result:any) => {
|
|
325
|
+ this.deptTopData = result.data || [];
|
|
326
|
+ });
|
|
327
|
+ }
|
|
328
|
+
|
|
329
|
+ // 人员Top5
|
|
330
|
+ getUserTopData() {
|
|
331
|
+ let postData:any = {
|
|
332
|
+ startDate: this.dateRange[0],
|
|
333
|
+ endDate: this.dateRange[1],
|
|
334
|
+ type: 'userTop5',
|
|
335
|
+ hosId: this.getHosId,
|
|
336
|
+ businessType: 'hsms',
|
|
337
|
+ };
|
|
338
|
+ this.mainService
|
|
339
|
+ .getReportData(postData)
|
|
340
|
+ .subscribe((result:any) => {
|
|
341
|
+ this.isLoading = false;
|
|
342
|
+ this.userTopData = result.data || [];
|
|
343
|
+ });
|
|
344
|
+ }
|
|
345
|
+
|
|
346
|
+ // 更多跳转
|
|
347
|
+ toPath(path){
|
|
348
|
+ let flag = this.tabService.tabs.some(v => v.path === path);
|
|
349
|
+ flag && this.tabService.deleteRouteSnapshot(path);
|
|
350
|
+ this.tabService.setQueryParams('dateRange', this.dateRange);
|
|
351
|
+ this.router.navigate([path], { replaceUrl: true });
|
|
352
|
+ }
|
|
353
|
+
|
|
354
|
+ // 判断更多是否显示
|
|
355
|
+ showMore(path){
|
|
356
|
+ let menus = JSON.parse(localStorage.getItem("menu"));
|
|
357
|
+ return menus.find(v => v.link === 'distributionInspectionStatistics').childrens.some(v => v.link === path);
|
|
358
|
+ }
|
|
359
|
+
|
|
360
|
+ get getHosId(){
|
|
361
|
+ return this.parentDutyId || this.dutyId || this.hosId;
|
|
362
|
+ }
|
|
363
|
+
|
|
364
|
+ // 初始化缓存数据
|
|
365
|
+ queryType:any;
|
|
366
|
+ hosId:any;
|
|
367
|
+ dutyId:any;
|
|
368
|
+ parentDutyId:any;
|
|
369
|
+ initSessionData(){
|
|
370
|
+ let newStatistics = JSON.parse(sessionStorage.getItem('newStatistics'));
|
|
371
|
+ let queryType:any = newStatistics.queryType;
|
|
372
|
+ let hosId:any = newStatistics.hospitalId;
|
|
373
|
+ let dutyId:any = newStatistics.dutyId;
|
|
374
|
+
|
|
375
|
+ queryType = queryType ? +queryType : undefined;
|
|
376
|
+ hosId = hosId ? +hosId : undefined;
|
|
377
|
+ dutyId = dutyId ? +dutyId : undefined;
|
|
378
|
+
|
|
379
|
+ this.queryType = queryType;
|
|
380
|
+ if(queryType == 1){
|
|
381
|
+ this.hosId = undefined;
|
|
382
|
+ this.dutyId = undefined;
|
|
383
|
+ this.parentDutyId = undefined;
|
|
384
|
+ }else if(queryType == 2){
|
|
385
|
+ this.hosId = hosId;
|
|
386
|
+ this.dutyId = undefined;
|
|
387
|
+ this.parentDutyId = undefined;
|
|
388
|
+ }else if(queryType == 3){
|
|
389
|
+ this.hosId = undefined;
|
|
390
|
+ this.dutyId = dutyId;
|
|
391
|
+ this.parentDutyId = undefined;
|
|
392
|
+ }else if(queryType == 4){
|
|
393
|
+ this.hosId = undefined;
|
|
394
|
+ this.dutyId = undefined;
|
|
395
|
+ this.parentDutyId = dutyId;
|
|
396
|
+ }
|
|
397
|
+
|
|
398
|
+ this.isLoading = true
|
|
399
|
+ this.getStatisticsTypeList();
|
|
400
|
+ this.getWorkData();
|
|
401
|
+ this.getBusinessData();
|
|
402
|
+ this.applyChart();
|
|
403
|
+ this.trendChart();
|
|
404
|
+ this.businessChart();
|
|
405
|
+ this.getDeptTopData();
|
|
406
|
+ this.getUserTopData();
|
|
407
|
+ }
|
|
408
|
+
|
|
409
|
+ // 表格数据
|
|
410
|
+ loading1 = false;
|
|
411
|
+ getList(num?: number, field?: string, sort?: string) {
|
|
412
|
+ if (num !== undefined) {
|
|
413
|
+ this.pageIndex = num;
|
|
414
|
+ }
|
|
415
|
+ let postData:any = {
|
|
416
|
+ idx: this.pageIndex - 1,
|
|
417
|
+ sum: this.pageSize,
|
|
418
|
+ startDate: this.dateRange[0],
|
|
419
|
+ endDate: this.dateRange[1],
|
|
420
|
+ hosId: this.hosId,
|
|
421
|
+ dutyId: this.dutyId,
|
|
422
|
+ parentDutyId: this.parentDutyId,
|
|
423
|
+ };
|
|
424
|
+ this.loading1 = true;
|
|
425
|
+ this.mainService
|
|
426
|
+ .postCustom("itsm/report", "incidentWorkOrder", postData)
|
|
427
|
+ .subscribe((result) => {
|
|
428
|
+ this.loading1 = false;
|
|
429
|
+ this.listOfData = result.dataList || [];
|
|
430
|
+ this.listLength = result.totalCount;
|
|
431
|
+ });
|
|
432
|
+ }
|
|
433
|
+
|
|
434
|
+ // 头部工单数据
|
|
435
|
+ getWorkData() {
|
|
436
|
+ let postData:any = {
|
|
437
|
+ startDate: this.dateRange[0],
|
|
438
|
+ endDate: this.dateRange[1],
|
|
439
|
+ type: 'headerCount',
|
|
440
|
+ hosId: this.getHosId,
|
|
441
|
+ businessType: 'hsms',
|
|
442
|
+ };
|
|
443
|
+ this.mainService
|
|
444
|
+ .getReportData(postData)
|
|
445
|
+ .subscribe((result:any) => {
|
|
446
|
+ this.workData = result.data[0] || [];
|
|
447
|
+ });
|
|
448
|
+ }
|
|
449
|
+
|
|
450
|
+ // 头部业务数据
|
|
451
|
+ getBusinessData() {
|
|
452
|
+ let postData:any = {
|
|
453
|
+ startDate: this.dateRange[0],
|
|
454
|
+ endDate: this.dateRange[1],
|
|
455
|
+ type: 'businessCount',
|
|
456
|
+ hosId: this.getHosId,
|
|
457
|
+ businessType: 'hsms',
|
|
458
|
+ };
|
|
459
|
+ this.mainService
|
|
460
|
+ .getReportData(postData)
|
|
461
|
+ .subscribe((result:any) => {
|
|
462
|
+ this.businessData = result.data[0] || [];
|
|
463
|
+ });
|
|
464
|
+ }
|
|
465
|
+
|
|
466
|
+ // 重置
|
|
467
|
+ reset(){
|
|
468
|
+ this.dateRange = [format(startOfMonth(addMonths(new Date(), -1)), 'yyyy-MM-dd HH:mm:ss'), format(endOfMonth(addMonths(new Date(), -1)), 'yyyy-MM-dd HH:mm:ss')];
|
|
469
|
+ this.activeIndex = 'day';
|
|
470
|
+ this.search();
|
|
471
|
+ }
|
|
472
|
+
|
|
473
|
+ // 搜索
|
|
474
|
+ search() {
|
|
475
|
+ this.initSessionData();
|
|
476
|
+ }
|
|
477
|
+
|
|
478
|
+ // 日期选择 日
|
|
479
|
+ dateRange: any = [format(startOfMonth(addMonths(new Date(), -1)), 'yyyy-MM-dd HH:mm:ss'), format(endOfMonth(addMonths(new Date(), -1)), 'yyyy-MM-dd HH:mm:ss')]; //发起时间区间 天
|
|
480
|
+ changeDate(result?): void {
|
|
481
|
+ result[0] = format(result[0], 'yyyy-MM-dd') + ' ' + '00:00:00';
|
|
482
|
+ result[1] = format(result[1], 'yyyy-MM-dd') + ' ' + '23:59:59';
|
|
483
|
+ this.dateRange = result;
|
|
484
|
+ // this.search();
|
|
485
|
+ console.log(this.dateRange);
|
|
486
|
+ }
|
|
487
|
+
|
|
488
|
+ onCalendarChangeDate(dateArr){
|
|
489
|
+ // console.log(dateArr)
|
|
490
|
+ // if(dateArr.length == 2){
|
|
491
|
+ // let dateStart = new Date(dateArr[0]);
|
|
492
|
+ // let dateEnd = new Date(dateArr[1]);
|
|
493
|
+ // dateStart.setHours(0,0,0);
|
|
494
|
+ // dateEnd.setHours(23,59,59);
|
|
495
|
+ // this.dateRange = [dateStart,dateEnd];
|
|
496
|
+ // }
|
|
497
|
+ }
|
|
498
|
+
|
|
499
|
+ // 获取统计分类列表
|
|
500
|
+ statisticsTypeList:any[] = [];
|
|
501
|
+ statisticsTypeId;//统计分类id
|
|
502
|
+ getStatisticsTypeList(keyword?) {
|
|
503
|
+ this.isLoading = true;
|
|
504
|
+ this.mainService
|
|
505
|
+ .getDictionary("list", "statistics_date_type")
|
|
506
|
+ .subscribe((data) => {
|
|
507
|
+ this.isLoading = false;
|
|
508
|
+ this.statisticsTypeList = data;
|
|
509
|
+ });
|
|
510
|
+ }
|
|
511
|
+
|
|
512
|
+ changeStatisticsType(id){
|
|
513
|
+ this.trendChart();
|
|
514
|
+ }
|
|
515
|
+}
|