|
@@ -351,3 +351,390 @@ func BatchSaveSpecialPermissionAdminUsers(users []*models.AdminUserSpecialPermis
|
351
|
351
|
}
|
352
|
352
|
return tx.Commit().Error
|
353
|
353
|
}
|
|
354
|
+
|
|
355
|
+// 获取一段时间内新增病人数量
|
|
356
|
+func GetNewPatientCount(from int64, to int64) (int, error) {
|
|
357
|
+ var count int
|
|
358
|
+ rows, err := readDb.Raw("SELECT COUNT(DISTINCT id_card_no) AS count FROM xt_patients WHERE status > 0 AND created_time >= ? AND created_time <= ?", from, to).Rows()
|
|
359
|
+ if err != nil {
|
|
360
|
+ return 0, err
|
|
361
|
+ }
|
|
362
|
+ if rows.Next() {
|
|
363
|
+ rows.Scan(&count)
|
|
364
|
+ }
|
|
365
|
+ return count, nil
|
|
366
|
+}
|
|
367
|
+
|
|
368
|
+// 获取所有机构病人数量
|
|
369
|
+func GetPatientTotalCount() (int64, error) {
|
|
370
|
+
|
|
371
|
+ var count int64
|
|
372
|
+ rows, err := readDb.Raw("SELECT COUNT(DISTINCT id_card_no) AS count FROM xt_patients").Rows()
|
|
373
|
+ if err != nil {
|
|
374
|
+ return 0, err
|
|
375
|
+ }
|
|
376
|
+ if rows.Next() {
|
|
377
|
+ rows.Scan(&count)
|
|
378
|
+ }
|
|
379
|
+ return count, nil
|
|
380
|
+
|
|
381
|
+}
|
|
382
|
+
|
|
383
|
+// 获取一段时间内的活跃账户数
|
|
384
|
+func GetActiveAdminUserCount(from int64, to int64) (int64, error) {
|
|
385
|
+ var count int64
|
|
386
|
+ rows, err := readUserDb.Raw("SELECT COUNT(DISTINCT admin_user_id) AS count FROM sgj_user_admin_login_log WHERE ctime >= ? AND ctime <= ? AND operate_type = 1", from, to).Rows()
|
|
387
|
+ if err != nil {
|
|
388
|
+ return 0, err
|
|
389
|
+ }
|
|
390
|
+ if rows.Next() {
|
|
391
|
+ rows.Scan(&count)
|
|
392
|
+ }
|
|
393
|
+ return count, nil
|
|
394
|
+}
|
|
395
|
+
|
|
396
|
+// 获取所有机构账户数量
|
|
397
|
+func GetAdminUserTotalCount() (int64, error) {
|
|
398
|
+ var count int64
|
|
399
|
+ rows, err := readUserDb.Raw("SELECT COUNT(DISTINCT id) AS count FROM sgj_user_admin_login_log").Rows()
|
|
400
|
+ if err != nil {
|
|
401
|
+ return 0, err
|
|
402
|
+ }
|
|
403
|
+ if rows.Next() {
|
|
404
|
+ rows.Scan(&count)
|
|
405
|
+ }
|
|
406
|
+ return count, nil
|
|
407
|
+}
|
|
408
|
+
|
|
409
|
+// 获取一段时间内注册的机构数量
|
|
410
|
+func GetRegistedOrgCount(from int64, to int64) (int64, error) {
|
|
411
|
+ var count int64
|
|
412
|
+ err := readUserDb.Model(&models.Org{}).Where("status <> 0 AND ctime >= ? AND ctime <= ?", from, to).Count(&count).Error
|
|
413
|
+ if err != nil {
|
|
414
|
+ return 0, err
|
|
415
|
+ }
|
|
416
|
+ return count, nil
|
|
417
|
+}
|
|
418
|
+
|
|
419
|
+// 获取一段时间内的活跃机构数
|
|
420
|
+func GetActiveOrgCount(from int64, to int64) (int64, error) {
|
|
421
|
+ var count int64
|
|
422
|
+ rows, err := readUserDb.Raw("SELECT COUNT(DISTINCT org_id) AS count FROM sgj_user_admin_login_log WHERE ctime >= ? AND ctime <= ?", from, to).Joins("JOIN sgj_xt.xt_dialysis_order as order ON sgj_user_admin_login_log.org_id = order.user_org_id").Rows()
|
|
423
|
+ if err != nil {
|
|
424
|
+ return 0, err
|
|
425
|
+ }
|
|
426
|
+ if rows.Next() {
|
|
427
|
+ rows.Scan(&count)
|
|
428
|
+ }
|
|
429
|
+ return count, nil
|
|
430
|
+}
|
|
431
|
+
|
|
432
|
+// 获取所有活跃机构数
|
|
433
|
+func GetActiveOrgTotalCount() (int64, error) {
|
|
434
|
+ var count int64
|
|
435
|
+ rows, err := readUserDb.Raw("SELECT COUNT(DISTINCT org_id) AS count FROM sgj_user_admin_login_log").Joins("JOIN sgj_xt.xt_dialysis_order as order ON sgj_user_admin_login_log.org_id = order.user_org_id").Rows()
|
|
436
|
+ if err != nil {
|
|
437
|
+ return 0, err
|
|
438
|
+ }
|
|
439
|
+ if rows.Next() {
|
|
440
|
+ rows.Scan(&count)
|
|
441
|
+ }
|
|
442
|
+ return count, nil
|
|
443
|
+}
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+//获取近七天每天的注册机构总量
|
|
448
|
+func GetWeekRegistedOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
|
|
449
|
+ err = readUserDb.Raw("select count(id) as count, DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m-%d') as times from sgj_user_org where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(sgj_user_org.ctime)) GROUP BY date(from_unixtime(ctime));").Scan(&weekStatistics).Error
|
|
450
|
+ return
|
|
451
|
+}
|
|
452
|
+
|
|
453
|
+//func GetWeekActiveOrgCount() (weekStatistics []*admin_models.WeekStatistics, err error) {
|
|
454
|
+// err = readUserDb.Raw("select count(id) as count, date(from_unixtime(ctime)) as times from sgj_user_org where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(sgj_user_org.ctime)) GROUP BY date(from_unixtime(ctime));").Scan(&weekStatistics).Error
|
|
455
|
+// return
|
|
456
|
+//}
|
|
457
|
+
|
|
458
|
+//获取近七天每天的机构活跃总量
|
|
459
|
+func GetWeekActiveOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
|
|
460
|
+ db := readUserDb.Raw("select count(DISTINCT(org_id)) as count, DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m-%d') as times from sgj_user_admin_login_log join sgj_xt.xt_dialysis_order ON sgj_xt.xt_dialysis_order.user_org_id = sgj_user_admin_login_log.org_id AND DATE_FORMAT(date(from_unixtime(sgj_user_admin_login_log.ctime)) ,'%Y-%m-%d') = DATE_FORMAT(date(from_unixtime(sgj_xt.xt_dialysis_order.dialysis_date)) ,'%Y-%m-%d') where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(sgj_user_admin_login_log.ctime)) AND operate_type = 1 GROUP BY date(from_unixtime(ctime));")
|
|
461
|
+ err = db.Scan(&weekStatistics).Error
|
|
462
|
+ return
|
|
463
|
+}
|
|
464
|
+
|
|
465
|
+//获取近七天每天的机构活跃账号总量
|
|
466
|
+func GetWeekActiveAdminUserCount() (weekStatistics []*admin_models.Statistics, err error) {
|
|
467
|
+ err = readUserDb.Raw("select count(DISTINCT(admin_user_id)) as count, DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m-%d') as times from sgj_user_admin_login_log where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(sgj_user_admin_login_log.ctime)) AND operate_type = 1 GROUP BY date(from_unixtime(ctime));").Scan(&weekStatistics).Error
|
|
468
|
+ return
|
|
469
|
+}
|
|
470
|
+
|
|
471
|
+//获取近七天每天的机构新增病人总量
|
|
472
|
+func GetWeekNewPatientCount() (weekStatistics []*admin_models.Statistics, err error) {
|
|
473
|
+ err = readDb.Raw("select count(DISTINCT(id_card_no)) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_patients where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(created_time)) GROUP BY date(from_unixtime(created_time));").Scan(&weekStatistics).Error
|
|
474
|
+ return
|
|
475
|
+}
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+//获取近七天每天的注册机构总量
|
|
481
|
+func GetWeekRegistedOrgTotalCount() (int64, error) {
|
|
482
|
+ var result admin_models.Count
|
|
483
|
+ var err error
|
|
484
|
+ err = readUserDb.Raw("select count(id) as count from sgj_user_org where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(sgj_user_org.ctime))").Scan(&result).Error
|
|
485
|
+ return result.Count,err
|
|
486
|
+}
|
|
487
|
+
|
|
488
|
+//获取近七天每天的机构活跃账号总量
|
|
489
|
+func GetWeekActiveAdminUserTotalCount() (int64, error) {
|
|
490
|
+ var result admin_models.Count
|
|
491
|
+ var err error
|
|
492
|
+ err = readUserDb.Raw("select count(DISTINCT(admin_user_id)) as count from sgj_user_admin_login_log where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(sgj_user_admin_login_log.ctime)) AND operate_type = 1 ").Scan(&result).Error
|
|
493
|
+ return result.Count,err
|
|
494
|
+
|
|
495
|
+}
|
|
496
|
+
|
|
497
|
+//获取近七天新增病人总量
|
|
498
|
+func GetWeekPatientTotalCount() (int64, error) {
|
|
499
|
+ var result admin_models.Count
|
|
500
|
+ var err error
|
|
501
|
+ err = readDb.Raw("select count(DISTINCT(id_card_no)) as count from xt_patients where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(created_time))").Scan(&result).Error
|
|
502
|
+ return result.Count,err
|
|
503
|
+
|
|
504
|
+}
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+//获取近30天每天的注册机构总量
|
|
512
|
+func GetMonthRegistedOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
|
|
513
|
+ err = readUserDb.Raw("select count(id) as count,DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m-%d') as times from sgj_user_org where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(from_unixtime(sgj_user_org.ctime)) GROUP BY date(from_unixtime(ctime));").Scan(&weekStatistics).Error
|
|
514
|
+ return
|
|
515
|
+}
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+//获取近30天每天的机构活跃总量
|
|
519
|
+func GetMonthActiveOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
|
|
520
|
+ err = readUserDb.Raw("select DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m') as month,count(DISTINCT(org_id)) as count From (select ctime,org_id FROM sgj_user_admin_login_log where app_type = 3 AND org_id > 0 ) T join sgj_xt.xt_dialysis_order ON sgj_xt.xt_dialysis_order.user_org_id = T.org_id AND DATE_FORMAT(date(from_unixtime(T.ctime)) ,'%Y-%m') =DATE_FORMAT(date(from_unixtime(sgj_xt.xt_dialysis_order.dialysis_date)) ,'%Y-%m') where DATE_FORMAT(date(from_unixtime(T.ctime)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 1 month),'%Y-%m') group by month").Scan(&weekStatistics).Error
|
|
521
|
+ return
|
|
522
|
+}
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+//获取近30天每天的机构活跃账号总量
|
|
526
|
+func GetMonthActiveAdminUserCount() (weekStatistics []*admin_models.Statistics, err error) {
|
|
527
|
+ err = readUserDb.Raw("select count(DISTINCT(admin_user_id)) as count, DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m-%d')as times from sgj_user_admin_login_log where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(from_unixtime(sgj_user_admin_login_log.ctime)) AND operate_type = 1 GROUP BY date(from_unixtime(ctime));").Scan(&weekStatistics).Error
|
|
528
|
+ return
|
|
529
|
+}
|
|
530
|
+
|
|
531
|
+//获取近30天每天的机构新增病人总量
|
|
532
|
+func GetMonthNewPatientCount() (weekStatistics []*admin_models.Statistics, err error) {
|
|
533
|
+ err = readDb.Raw("select count(DISTINCT(id_card_no)) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times from xt_patients where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(from_unixtime(created_time)) GROUP BY date(from_unixtime(created_time));").Scan(&weekStatistics).Error
|
|
534
|
+ return
|
|
535
|
+}
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+//获取近30天每天的注册机构总量
|
|
540
|
+func GetMonthRegistedOrgTotalCount() (int64, error) {
|
|
541
|
+ var result admin_models.Count
|
|
542
|
+ var err error
|
|
543
|
+ err = readUserDb.Raw("select count(id) as count from sgj_user_org where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(from_unixtime(sgj_user_org.ctime))").Scan(&result).Error
|
|
544
|
+ return result.Count,err
|
|
545
|
+}
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+//获取近30天每天的机构活跃账号总量
|
|
549
|
+func GetMonthActiveAdminUserTotalCount() (int64, error) {
|
|
550
|
+ var result admin_models.Count
|
|
551
|
+ var err error
|
|
552
|
+ err = readUserDb.Raw("select count(DISTINCT(admin_user_id)) as count from sgj_user_admin_login_log where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(from_unixtime(sgj_user_admin_login_log.ctime)) AND operate_type = 1 ").Scan(&result).Error
|
|
553
|
+ return result.Count,err
|
|
554
|
+}
|
|
555
|
+
|
|
556
|
+//获取近30天每天的机构新增病人总量
|
|
557
|
+func GetMonthNewPatientTotalCount() (int64, error) {
|
|
558
|
+ var result admin_models.Count
|
|
559
|
+ var err error
|
|
560
|
+ err = readDb.Raw("select count(DISTINCT(id_card_no)) as count from xt_patients where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(from_unixtime(created_time)) ").Scan(&result).Error
|
|
561
|
+ return result.Count,err
|
|
562
|
+}
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+//获取近3个月每个月的注册机构总量
|
|
570
|
+func GetThreeMonthRegistedOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
|
|
571
|
+ err = readUserDb.Raw("select DATE_FORMAT(date(from_unixtime(sgj_user_org.ctime)) ,'%Y-%m') as times,count(DISTINCT(id)) as count from sgj_user_org where DATE_FORMAT(date(from_unixtime(sgj_user_org.ctime)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') group by times").Scan(&weekStatistics).Error
|
|
572
|
+ return
|
|
573
|
+}
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+//获取近3个月每个月的机构活跃账号总量
|
|
577
|
+func GetThreeMonthActiveAdminUserCount() (weekStatistics []*admin_models.Statistics, err error) {
|
|
578
|
+ err = readUserDb.Raw("select DATE_FORMAT(date(from_unixtime(sgj_user_admin_login_log.ctime)) ,'%Y-%m') as times,count(DISTINCT(admin_user_id)) as count from sgj_user_admin_login_log where DATE_FORMAT(date(from_unixtime(sgj_user_admin_login_log.ctime)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') AND operate_type = 1 group by times").Scan(&weekStatistics).Error
|
|
579
|
+ return
|
|
580
|
+}
|
|
581
|
+
|
|
582
|
+//获取近3个月每个月的机构活跃总量
|
|
583
|
+func GetThreeMonthActiveOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
|
|
584
|
+ err = readUserDb.Raw("select DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m') as month,count(DISTINCT(org_id)) as count From (select ctime,org_id FROM sgj_user_admin_login_log where app_type = 3 AND org_id > 0 ) T join sgj_xt.xt_dialysis_order ON sgj_xt.xt_dialysis_order.user_org_id = T.org_id AND DATE_FORMAT(date(from_unixtime(T.ctime)) ,'%Y-%m') =DATE_FORMAT(date(from_unixtime(sgj_xt.xt_dialysis_order.dialysis_date)) ,'%Y-%m') where DATE_FORMAT(date(from_unixtime(T.ctime)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') group by month").Scan(&weekStatistics).Error
|
|
585
|
+ return
|
|
586
|
+}
|
|
587
|
+
|
|
588
|
+//获取近3个月每个月机构新增病人总量
|
|
589
|
+func GetThreeMonthNewPatientCount() (weekStatistics []*admin_models.Statistics, err error) {
|
|
590
|
+ err = readDb.Raw("select DATE_FORMAT(date(from_unixtime(xt_patients.created_time)) ,'%Y-%m') as times,count(DISTINCT(id_card_no)) as count from xt_patients where DATE_FORMAT(date(from_unixtime(xt_patients.created_time)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') group by times").Scan(&weekStatistics).Error
|
|
591
|
+ return
|
|
592
|
+}
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+//获取近3个月每个月的注册机构总量
|
|
596
|
+func GetThreeMonthRegistedOrgTotalCount() (int64, error) {
|
|
597
|
+ var result admin_models.Count
|
|
598
|
+ var err error
|
|
599
|
+ err = readUserDb.Raw("select count(DISTINCT(id)) as count from sgj_user_org where DATE_FORMAT(date(from_unixtime(sgj_user_org.ctime)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m')").Scan(&result).Error
|
|
600
|
+ return result.Count,err
|
|
601
|
+
|
|
602
|
+}
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+//获取近3个月每个月的机构活跃账号总量
|
|
606
|
+func GetThreeMonthActiveAdminUserTotalCount() (int64, error) {
|
|
607
|
+ var result admin_models.Count
|
|
608
|
+ var err error
|
|
609
|
+ err = readUserDb.Raw("select count(DISTINCT(admin_user_id)) as count from sgj_user_admin_login_log where DATE_FORMAT(date(from_unixtime(sgj_user_admin_login_log.ctime)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') AND operate_type = 1 ").Scan(&result).Error
|
|
610
|
+ return result.Count,err
|
|
611
|
+
|
|
612
|
+}
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+//获取近3个月每个月机构新增病人总量
|
|
616
|
+func GetThreeMonthNewPatientTotalCount() (int64, error) {
|
|
617
|
+ var result admin_models.Count
|
|
618
|
+ var err error
|
|
619
|
+ err = readDb.Raw("select count(DISTINCT(id_card_no)) as count from xt_patients where DATE_FORMAT(date(from_unixtime(xt_patients.created_time)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m')").Scan(&result).Error
|
|
620
|
+ return result.Count,err
|
|
621
|
+
|
|
622
|
+}
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+//获取近半年每个月的注册机构总量
|
|
627
|
+func GetSixMonthRegistedOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
|
|
628
|
+ err = readUserDb.Raw("select DATE_FORMAT(date(from_unixtime(sgj_user_org.ctime)) ,'%Y-%m') as times,count(DISTINCT(id)) as count from sgj_user_org where DATE_FORMAT(date(from_unixtime(sgj_user_org.ctime)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m') group by times").Scan(&weekStatistics).Error
|
|
629
|
+ return
|
|
630
|
+}
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+//获取近半年每个月的机构活跃账号总量
|
|
634
|
+func GetSixMonthActiveAdminUserCount() (weekStatistics []*admin_models.Statistics, err error) {
|
|
635
|
+ err = readUserDb.Raw("select DATE_FORMAT(date(from_unixtime(sgj_user_admin_login_log.ctime)) ,'%Y-%m') as times,count(DISTINCT(admin_user_id)) as count from sgj_user_admin_login_log where DATE_FORMAT(date(from_unixtime(sgj_user_admin_login_log.ctime)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m') group by times").Scan(&weekStatistics).Error
|
|
636
|
+ return
|
|
637
|
+}
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+//获取近半年每个月的机构活跃总量
|
|
641
|
+func GetSixMonthActiveOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
|
|
642
|
+ err = readUserDb.Raw("select DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m') as month,count(DISTINCT(org_id)) as count From (select ctime,org_id FROM sgj_user_admin_login_log where app_type = 3 AND org_id > 0 ) T join sgj_xt.xt_dialysis_order ON sgj_xt.xt_dialysis_order.user_org_id = T.org_id AND DATE_FORMAT(date(from_unixtime(T.ctime)) ,'%Y-%m') =DATE_FORMAT(date(from_unixtime(sgj_xt.xt_dialysis_order.dialysis_date)) ,'%Y-%m') where DATE_FORMAT(date(from_unixtime(T.ctime)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m') group by month").Scan(&weekStatistics).Error
|
|
643
|
+ return
|
|
644
|
+}
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+//获取近半年每个月机构新增病人总量
|
|
648
|
+func GetSixMonthNewPatientCount() (weekStatistics []*admin_models.Statistics, err error) {
|
|
649
|
+ err = readDb.Raw("select DATE_FORMAT(date(from_unixtime(xt_patients.created_time)) ,'%Y-%m') as times,count(DISTINCT(id_card_no)) as count from xt_patients where DATE_FORMAT(date(from_unixtime(xt_patients.created_time)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m') group by times").Scan(&weekStatistics).Error
|
|
650
|
+ return
|
|
651
|
+}
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+//获取近半年每个月的注册机构总量
|
|
655
|
+func GetSixMonthRegistedOrgTotalCount() (int64, error) {
|
|
656
|
+ var result admin_models.Count
|
|
657
|
+ var err error
|
|
658
|
+ err = readUserDb.Raw("select DATE_FORMAT(date(from_unixtime(sgj_user_org.ctime)) ,'%Y-%m') as times,count(DISTINCT(id)) as count from sgj_user_org where DATE_FORMAT(date(from_unixtime(sgj_user_org.ctime)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m')").Scan(&result).Error
|
|
659
|
+ return result.Count, err
|
|
660
|
+}
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+ //获取近半年每个月的机构活跃账号总量
|
|
664
|
+func GetSixMonthActiveAdminUserTotalCount() (int64, error) {
|
|
665
|
+ var result admin_models.Count
|
|
666
|
+ var err error
|
|
667
|
+ err = readUserDb.Raw("select DATE_FORMAT(date(from_unixtime(sgj_user_admin_login_log.ctime)) ,'%Y-%m') as times,count(DISTINCT(admin_user_id)) as count from sgj_user_admin_login_log where DATE_FORMAT(date(from_unixtime(sgj_user_admin_login_log.ctime)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m')").Scan(&result).Error
|
|
668
|
+ return result.Count, err
|
|
669
|
+
|
|
670
|
+}
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+//获取近半年每个月机构新增病人总量
|
|
674
|
+func GetSixMonthNewPatientTotalCount() (int64, error) {
|
|
675
|
+ var result admin_models.Count
|
|
676
|
+ var err error
|
|
677
|
+ err = readDb.Raw("select DATE_FORMAT(date(from_unixtime(xt_patients.created_time)) ,'%Y-%m') as times,count(DISTINCT(id_card_no)) as count from xt_patients where DATE_FORMAT(date(from_unixtime(xt_patients.created_time)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m')").Scan(&result).Error
|
|
678
|
+ return result.Count, err
|
|
679
|
+
|
|
680
|
+}
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+//获取近1年每个月的注册机构总量
|
|
686
|
+func GetYearRegistedOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
|
|
687
|
+ err = readUserDb.Raw("select DATE_FORMAT(date(from_unixtime(sgj_user_org.ctime)) ,'%Y-%m') as times,count(DISTINCT(id)) as count from sgj_user_org where DATE_FORMAT(date(from_unixtime(sgj_user_org.ctime)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m') group by times").Scan(&weekStatistics).Error
|
|
688
|
+ return
|
|
689
|
+}
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+//获取近1年每个月的机构活跃账号总量
|
|
693
|
+func GetYearActiveAdminUserCount() (weekStatistics []*admin_models.Statistics, err error) {
|
|
694
|
+ err = readUserDb.Raw("select DATE_FORMAT(date(from_unixtime(sgj_user_admin_login_log.ctime)) ,'%Y-%m') as times,count(DISTINCT(admin_user_id)) as count from sgj_user_admin_login_log where DATE_FORMAT(date(from_unixtime(sgj_user_admin_login_log.ctime)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m') group by times").Scan(&weekStatistics).Error
|
|
695
|
+ return
|
|
696
|
+}
|
|
697
|
+
|
|
698
|
+//获取近1年每个月的机构活跃总量
|
|
699
|
+func GetYearActiveOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
|
|
700
|
+ err = readUserDb.Raw("select DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m') as month,count(DISTINCT(org_id)) as count From (select ctime,org_id FROM sgj_user_admin_login_log where app_type = 3 AND org_id > 0 ) T join sgj_xt.xt_dialysis_order ON sgj_xt.xt_dialysis_order.user_org_id = T.org_id AND DATE_FORMAT(date(from_unixtime(T.ctime)) ,'%Y-%m') =DATE_FORMAT(date(from_unixtime(sgj_xt.xt_dialysis_order.dialysis_date)) ,'%Y-%m') where DATE_FORMAT(date(from_unixtime(T.ctime)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m') group by month").Scan(&weekStatistics).Error
|
|
701
|
+ return
|
|
702
|
+}
|
|
703
|
+
|
|
704
|
+//获取近1年每个月机构新增病人总量
|
|
705
|
+func GetYearNewPatientCount() (weekStatistics []*admin_models.Statistics, err error) {
|
|
706
|
+ err = readDb.Raw("select DATE_FORMAT(date(from_unixtime(xt_patients.created_time)) ,'%Y-%m') as times,count(DISTINCT(id_card_no)) as count from xt_patients where DATE_FORMAT(date(from_unixtime(xt_patients.created_time)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m') AND status > 0 group by times").Scan(&weekStatistics).Error
|
|
707
|
+ return
|
|
708
|
+}
|
|
709
|
+
|
|
710
|
+
|
|
711
|
+//获取近1年每个月的注册机构总量
|
|
712
|
+func GetYearRegistedOrgTotalCount() (int64, error) {
|
|
713
|
+ var result admin_models.Count
|
|
714
|
+ var err error
|
|
715
|
+ err = readUserDb.Raw("select DATE_FORMAT(date(from_unixtime(sgj_user_org.ctime)) ,'%Y-%m') as times,count(DISTINCT(id)) as count from sgj_user_org where DATE_FORMAT(date(from_unixtime(sgj_user_org.ctime)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m')").Scan(&result).Error
|
|
716
|
+ return result.Count, err
|
|
717
|
+
|
|
718
|
+}
|
|
719
|
+
|
|
720
|
+
|
|
721
|
+//获取近1年每个月的机构活跃账号总量
|
|
722
|
+func GetYearActiveAdminUserTotalCount() (int64, error) {
|
|
723
|
+ var result admin_models.Count
|
|
724
|
+ var err error
|
|
725
|
+ err = readUserDb.Raw("select DATE_FORMAT(date(from_unixtime(sgj_user_admin_login_log.ctime)) ,'%Y-%m') as times,count(DISTINCT(admin_user_id)) as count from sgj_user_admin_login_log where DATE_FORMAT(date(from_unixtime(sgj_user_admin_login_log.ctime)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m')").Scan(&result).Error
|
|
726
|
+ return result.Count, err
|
|
727
|
+}
|
|
728
|
+
|
|
729
|
+
|
|
730
|
+//获取近1年每个月机构新增病人总量
|
|
731
|
+func GetYearNewPatientTotalCount() (int64, error) {
|
|
732
|
+ var result admin_models.Count
|
|
733
|
+ var err error
|
|
734
|
+ err = readDb.Raw("select count(DISTINCT(id_card_no)) as count from xt_patients where DATE_FORMAT(date(from_unixtime(xt_patients.created_time)),'%Y-%m')>DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m') AND status > 0").Scan(&result).Error
|
|
735
|
+ return result.Count, err
|
|
736
|
+
|
|
737
|
+}
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
|