xiaoming_global před 4 roky
rodič
revize
270d728154

+ 136 - 10
.idea/workspace.xml Zobrazit soubor

@@ -3,6 +3,17 @@
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="7aa7cc45-aece-4fa3-9063-5e3df12471b4" name="Default" comment="">
5 5
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
6
+<<<<<<< .mine
7
+
8
+
9
+
10
+
11
+=======
12
+      <change beforePath="$PROJECT_DIR$/XT_Admin_Api.exe" beforeDir="false" afterPath="$PROJECT_DIR$/XT_Admin_Api.exe" afterDir="false" />
13
+      <change beforePath="$PROJECT_DIR$/controllers/function_api_controllers/function_api_base_controller.go" beforeDir="false" afterPath="$PROJECT_DIR$/controllers/function_api_controllers/function_api_base_controller.go" afterDir="false" />
14
+      <change beforePath="$PROJECT_DIR$/controllers/function_api_controllers/function_api_router_register.go" beforeDir="false" afterPath="$PROJECT_DIR$/controllers/function_api_controllers/function_api_router_register.go" afterDir="false" />
15
+      <change beforePath="$PROJECT_DIR$/service/function_service.go" beforeDir="false" afterPath="$PROJECT_DIR$/service/function_service.go" afterDir="false" />
16
+>>>>>>> .theirs
6 17
     </list>
7 18
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
8 19
     <option name="TRACKING_ENABLED" value="true" />
@@ -16,7 +27,11 @@
16 27
       <file leaf-file-name="function_api_router_register.go" pinned="false" current-in-tab="false">
17 28
         <entry file="file://$PROJECT_DIR$/controllers/function_api_controllers/function_api_router_register.go">
18 29
           <provider selected="true" editor-type-id="text-editor">
30
+<<<<<<< .mine
19 31
             <state relative-caret-position="1848">
32
+=======
33
+            <state relative-caret-position="47">
34
+>>>>>>> .theirs
20 35
               <caret line="87" column="79" selection-start-line="87" selection-start-column="54" selection-end-line="87" selection-end-column="79" />
21 36
               <folding>
22 37
                 <element signature="e#34#79#0" expanded="true" />
@@ -37,8 +52,13 @@
37 52
       <file leaf-file-name="function_service.go" pinned="false" current-in-tab="true">
38 53
         <entry file="file://$PROJECT_DIR$/service/function_service.go">
39 54
           <provider selected="true" editor-type-id="text-editor">
55
+<<<<<<< .mine
40 56
             <state relative-caret-position="175">
41 57
               <caret line="65" column="138" selection-start-line="65" selection-start-column="122" selection-end-line="65" selection-end-column="138" />
58
+=======
59
+            <state relative-caret-position="296">
60
+              <caret line="137" column="248" selection-start-line="137" selection-start-column="248" selection-end-line="137" selection-end-column="248" />
61
+>>>>>>> .theirs
42 62
               <folding>
43 63
                 <element signature="e#17#73#0" expanded="true" />
44 64
               </folding>
@@ -46,6 +66,7 @@
46 66
           </provider>
47 67
         </entry>
48 68
       </file>
69
+<<<<<<< .mine
49 70
       <file leaf-file-name="admin_api_router_register.go" pinned="false" current-in-tab="false">
50 71
         <entry file="file://$PROJECT_DIR$/controllers/admin_api_controllers/admin_api_router_register.go">
51 72
           <provider selected="true" editor-type-id="text-editor">
@@ -73,11 +94,40 @@
73 94
           </provider>
74 95
         </entry>
75 96
       </file>
97
+=======
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+>>>>>>> .theirs
76 126
       <file leaf-file-name="fuction_query_models.go" pinned="false" current-in-tab="false">
77 127
         <entry file="file://$PROJECT_DIR$/models/function_models/fuction_query_models.go">
78 128
           <provider selected="true" editor-type-id="text-editor">
79
-            <state relative-caret-position="11264">
80
-              <caret line="512" column="5" selection-start-line="512" selection-start-column="5" selection-end-line="512" selection-end-column="5" />
129
+            <state relative-caret-position="11286">
130
+              <caret line="513" column="13" selection-start-line="513" selection-start-column="13" selection-end-line="513" selection-end-column="13" />
81 131
             </state>
82 132
           </provider>
83 133
         </entry>
@@ -85,7 +135,7 @@
85 135
       <file leaf-file-name="function_api_base_controller.go" pinned="false" current-in-tab="false">
86 136
         <entry file="file://$PROJECT_DIR$/controllers/function_api_controllers/function_api_base_controller.go">
87 137
           <provider selected="true" editor-type-id="text-editor">
88
-            <state relative-caret-position="79068">
138
+            <state relative-caret-position="319">
89 139
               <caret line="3601" column="90" selection-start-line="3601" selection-start-column="90" selection-end-line="3601" selection-end-column="90" />
90 140
             </state>
91 141
           </provider>
@@ -120,6 +170,10 @@
120 170
   </component>
121 171
   <component name="FindInProjectRecents">
122 172
     <findStrings>
173
+      <find>SchedualPatient</find>
174
+      <find>patient_count_list</find>
175
+      <find>aaa</find>
176
+      <find>newPatientStatistics</find>
123 177
       <find>/api/dialysis/start_record</find>
124 178
       <find>GetMonthReceiveinfo</find>
125 179
       <find>GetTodayDialysisMachinek</find>
@@ -146,10 +200,6 @@
146 200
       <find>GetYesterdayEntrylist</find>
147 201
       <find>GetYesterdayExitlist</find>
148 202
       <find>/api/function/getyestrdayexitlist</find>
149
-      <find>/org/org_info</find>
150
-      <find>/admin/api/org/adminuser</find>
151
-      <find>GetOrgAdminUser</find>
152
-      <find>import</find>
153 203
     </findStrings>
154 204
     <dirStrings>
155 205
       <dir>D:\goyard\src\XT_Admin_Api\controllers\admin_api_controllers</dir>
@@ -234,7 +284,7 @@
234 284
     <property name="DefaultGoTemplateProperty" value="Go Application" />
235 285
     <property name="go.gopath.indexing.explicitly.defined" value="true" />
236 286
     <property name="go.sdk.automatically.set" value="true" />
237
-    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
287
+    <property name="last_opened_file_path" value="$PROJECT_DIR$/../XT" />
238 288
   </component>
239 289
   <component name="RunDashboard">
240 290
     <option name="ruleStates">
@@ -251,15 +301,23 @@
251 301
   <component name="ToolWindowManager">
252 302
     <frame x="-7" y="-7" width="1550" height="838" extended-state="6" />
253 303
     <layout>
304
+<<<<<<< .mine
254 305
       <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.22050938" />
306
+=======
307
+      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.20710456" />
308
+>>>>>>> .theirs
255 309
       <window_info anchor="bottom" id="TODO" order="6" />
256
-      <window_info anchor="bottom" id="Event Log" order="7" sideWeight="0.11461126" side_tool="true" weight="0.29101285" />
310
+      <window_info anchor="bottom" id="Event Log" order="7" sideWeight="0.113270774" side_tool="true" visible="true" weight="0.39372325" />
257 311
       <window_info anchor="right" id="Database" order="3" />
258 312
       <window_info anchor="bottom" id="Database Changes" order="8" show_stripe_button="false" />
259 313
       <window_info anchor="bottom" id="Version Control" order="9" />
260 314
       <window_info anchor="bottom" id="Run" order="2" />
261 315
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
316
+<<<<<<< .mine
262 317
       <window_info active="true" anchor="bottom" id="Terminal" order="10" sideWeight="0.88538873" visible="true" weight="0.0014265336" />
318
+=======
319
+      <window_info active="true" anchor="bottom" id="Terminal" order="10" sideWeight="0.88672924" visible="true" weight="0.39372325" />
320
+>>>>>>> .theirs
263 321
       <window_info id="Favorites" order="2" side_tool="true" />
264 322
       <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
265 323
       <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
@@ -283,6 +341,20 @@
283 341
     </breakpoint-manager>
284 342
   </component>
285 343
   <component name="editorHistoryManager">
344
+    <entry file="file://$PROJECT_DIR$/controllers/function_api_controllers/function_api_base_controller.go">
345
+      <provider selected="true" editor-type-id="text-editor">
346
+        <state relative-caret-position="65296">
347
+          <caret line="2975" column="6" selection-start-line="2975" selection-start-column="6" selection-end-line="2975" selection-end-column="6" />
348
+        </state>
349
+      </provider>
350
+    </entry>
351
+    <entry file="file://$PROJECT_DIR$/controllers/admin_api_controllers/analysis_api_controller.go">
352
+      <provider selected="true" editor-type-id="text-editor">
353
+        <state relative-caret-position="9240">
354
+          <caret line="427" selection-start-line="427" selection-end-line="427" />
355
+        </state>
356
+      </provider>
357
+    </entry>
286 358
     <entry file="file://$PROJECT_DIR$/controllers/function_api_controllers/function_api_router_register.go">
287 359
       <provider selected="true" editor-type-id="text-editor">
288 360
         <state relative-caret-position="1650">
@@ -516,6 +588,13 @@
516 588
         </state>
517 589
       </provider>
518 590
     </entry>
591
+    <entry file="file://$PROJECT_DIR$/controllers/admin_api_controllers/admin_api_router_register.go">
592
+      <provider selected="true" editor-type-id="text-editor">
593
+        <state relative-caret-position="308">
594
+          <caret line="19" lean-forward="true" selection-start-line="19" selection-end-line="19" />
595
+        </state>
596
+      </provider>
597
+    </entry>
519 598
     <entry file="file://$PROJECT_DIR$/controllers/admin_api_controllers/login_api_controller.go">
520 599
       <provider selected="true" editor-type-id="text-editor">
521 600
         <state relative-caret-position="110">
@@ -586,6 +665,13 @@
586 665
         </state>
587 666
       </provider>
588 667
     </entry>
668
+    <entry file="file://$PROJECT_DIR$/models/function_models/fuction_query_models.go">
669
+      <provider selected="true" editor-type-id="text-editor">
670
+        <state relative-caret-position="11286">
671
+          <caret line="513" column="13" selection-start-line="513" selection-start-column="13" selection-end-line="513" selection-end-column="13" />
672
+        </state>
673
+      </provider>
674
+    </entry>
589 675
     <entry file="file://$PROJECT_DIR$/service/admin_service.go">
590 676
       <provider selected="true" editor-type-id="text-editor">
591 677
         <state relative-caret-position="572">
@@ -602,11 +688,12 @@
602 688
     </entry>
603 689
     <entry file="file://$PROJECT_DIR$/controllers/function_api_controllers/function_api_base_controller.go">
604 690
       <provider selected="true" editor-type-id="text-editor">
605
-        <state relative-caret-position="79068">
691
+        <state relative-caret-position="319">
606 692
           <caret line="3601" column="90" selection-start-line="3601" selection-start-column="90" selection-end-line="3601" selection-end-column="90" />
607 693
         </state>
608 694
       </provider>
609 695
     </entry>
696
+<<<<<<< .mine
610 697
     <entry file="file://$PROJECT_DIR$/models/function_models/fuction_query_models.go">
611 698
       <provider selected="true" editor-type-id="text-editor">
612 699
         <state relative-caret-position="11264">
@@ -635,9 +722,43 @@
635 722
         </state>
636 723
       </provider>
637 724
     </entry>
725
+=======
726
+
727
+
728
+
729
+
730
+
731
+
732
+
733
+
734
+
735
+
736
+
737
+
738
+
739
+
740
+
741
+
742
+
743
+
744
+
745
+
746
+
747
+
748
+
749
+
750
+
751
+
752
+
753
+
754
+>>>>>>> .theirs
638 755
     <entry file="file://$PROJECT_DIR$/controllers/function_api_controllers/function_api_router_register.go">
639 756
       <provider selected="true" editor-type-id="text-editor">
757
+<<<<<<< .mine
640 758
         <state relative-caret-position="1848">
759
+=======
760
+        <state relative-caret-position="47">
761
+>>>>>>> .theirs
641 762
           <caret line="87" column="79" selection-start-line="87" selection-start-column="54" selection-end-line="87" selection-end-column="79" />
642 763
           <folding>
643 764
             <element signature="e#34#79#0" expanded="true" />
@@ -647,8 +768,13 @@
647 768
     </entry>
648 769
     <entry file="file://$PROJECT_DIR$/service/function_service.go">
649 770
       <provider selected="true" editor-type-id="text-editor">
771
+<<<<<<< .mine
650 772
         <state relative-caret-position="175">
651 773
           <caret line="65" column="138" selection-start-line="65" selection-start-column="122" selection-end-line="65" selection-end-column="138" />
774
+=======
775
+        <state relative-caret-position="296">
776
+          <caret line="137" column="248" selection-start-line="137" selection-start-column="248" selection-end-line="137" selection-end-column="248" />
777
+>>>>>>> .theirs
652 778
           <folding>
653 779
             <element signature="e#17#73#0" expanded="true" />
654 780
           </folding>

binární
XT_Admin_Api.exe Zobrazit soubor


+ 3 - 0
controllers/admin_api_controllers/admin_api_router_register.go Zobrazit soubor

@@ -42,4 +42,7 @@ func AdminAPIControllersRegisterRouters() {
42 42
 	beego.Router("/admin/api/user/get", &SystemApiController{}, "get:GetAdminUserById")
43 43
 	beego.Router("/admin/api/follow/cancel", &SystemApiController{}, "post:CancelFollowInfo")
44 44
 
45
+	beego.Router("/admin/api/followorg/list", &SystemApiController{}, "get:GetWaitFollowOrg")
46
+	beego.Router("/admin/api/unfolloworg/list", &SystemApiController{}, "get:GetAllFollowOrg")
47
+
45 48
 }

+ 28 - 29
controllers/admin_api_controllers/analysis_api_controller.go Zobrazit soubor

@@ -6,7 +6,6 @@ import (
6 6
 	"XT_Admin_Api/service"
7 7
 	"XT_Admin_Api/utils"
8 8
 	"time"
9
-	"fmt"
10 9
 )
11 10
 
12 11
 type AnalysisAPIController struct {
@@ -469,9 +468,7 @@ func (this *AnalysisAPIController) PatientAnalysis() {
469 468
 
470 469
 func (this *AnalysisAPIController) HomeStatistics() {
471 470
 	range_data := this.GetString("range_data")
472
-	fmt.Println("range_data是什么",range_data)
473 471
 	range_type, _ := this.GetInt64("range_type")
474
-    fmt.Println("range_type是设么",range_type)
475 472
 	var rangeDate *time.Time
476 473
 	var parseDateErr error
477 474
 	var rangeTimeStamp int64
@@ -498,8 +495,7 @@ func (this *AnalysisAPIController) HomeStatistics() {
498 495
 	activeAdminCount, _ := service.GetActiveAdminUserCount(rangeTimeStamp, now)
499 496
 	adminTotalCount, _ := service.GetAdminUserTotalCount()
500 497
 
501
-	patientCount, _ :=service.GetNewPatientCount(rangeTimeStamp, now)
502
-	fmt.Println("patientCout",patientCount)
498
+	patientCount, _ := service.GetNewPatientCount(rangeTimeStamp, now)
503 499
 	patientTotalCount, _ := service.GetPatientTotalCount()
504 500
 
505 501
 	var orgRegisterStatistics []*admin_models.Statistics
@@ -508,63 +504,66 @@ func (this *AnalysisAPIController) HomeStatistics() {
508 504
 	var orgActiveStatistics []*admin_models.Statistics
509 505
 
510 506
 	switch range_type {
507
+	case 1:
508
+
509
+		break
510
+
511
+	case 2:
512
+		orgRegisterStatistics, _ = service.GetYesterDayRegistedOrgCount()
513
+		newPatientStatistics, _ = service.GetYesterDayNewPatientCount()
514
+		orgActiveAdminStatistics, _ = service.GetYesterDayActiveAdminUserCount()
515
+		orgActiveStatistics, _ = service.GetYesterDayActiveOrgCount()
516
+
517
+		break
511 518
 	case 3:
512 519
 		orgRegisterStatistics, _ = service.GetWeekRegistedOrgCount()
513 520
 		newPatientStatistics, _ = service.GetWeekNewPatientCount()
514 521
 		orgActiveAdminStatistics, _ = service.GetWeekActiveAdminUserCount()
515
-		orgActiveStatistics,_ = service.GetWeekActiveOrgCount()
516
-
517
-		//newOrgCount, _ = service.GetWeekRegistedOrgTotalCount()
518
-		//activeOrgCount, _ = service.GetWeekRegistedOrgTotalCount()
519
-		//activeAdminCount, _ = service.GetWeekRegistedOrgTotalCount()
520
-		//activeAdminCount, _ = service.GetWeekRegistedOrgTotalCount()
521
-		//
522
-		//
522
+		orgActiveStatistics, _ = service.GetWeekActiveOrgCount()
523 523
 
524 524
 		break
525 525
 	case 4:
526 526
 		orgRegisterStatistics, _ = service.GetMonthRegistedOrgCount()
527 527
 		newPatientStatistics, _ = service.GetMonthNewPatientCount()
528 528
 		orgActiveAdminStatistics, _ = service.GetMonthActiveAdminUserCount()
529
-		orgActiveStatistics,_ = service.GetMonthActiveOrgCount()
529
+		orgActiveStatistics, _ = service.GetMonthActiveOrgCount()
530 530
 
531 531
 		break
532 532
 	case 5:
533 533
 		orgRegisterStatistics, _ = service.GetThreeMonthRegistedOrgCount()
534 534
 		newPatientStatistics, _ = service.GetThreeMonthNewPatientCount()
535 535
 		orgActiveAdminStatistics, _ = service.GetThreeMonthActiveAdminUserCount()
536
-		orgActiveStatistics,_ = service.GetThreeMonthActiveOrgCount()
536
+		orgActiveStatistics, _ = service.GetThreeMonthActiveOrgCount()
537 537
 
538 538
 		break
539 539
 	case 6:
540 540
 		orgRegisterStatistics, _ = service.GetSixMonthRegistedOrgCount()
541 541
 		newPatientStatistics, _ = service.GetSixMonthNewPatientCount()
542 542
 		orgActiveAdminStatistics, _ = service.GetSixMonthActiveAdminUserCount()
543
-		orgActiveStatistics,_ = service.GetSixMonthActiveOrgCount()
543
+		orgActiveStatistics, _ = service.GetSixMonthActiveOrgCount()
544 544
 
545 545
 		break
546 546
 	case 7:
547 547
 		orgRegisterStatistics, _ = service.GetYearRegistedOrgCount()
548 548
 		newPatientStatistics, _ = service.GetYearNewPatientCount()
549 549
 		orgActiveAdminStatistics, _ = service.GetYearActiveAdminUserCount()
550
-		orgActiveStatistics,_ = service.GetYearActiveOrgCount()
551
-
550
+		orgActiveStatistics, _ = service.GetYearActiveOrgCount()
552 551
 		break
553 552
 	}
554 553
 
555 554
 	this.ServeSuccessJSON(map[string]interface{}{
556
-		"org_count":  newOrgCount,
557
-		"org_total_count":   totalOrg,
558
-		"active_org_count":  activeOrgCount,
559
-		"active_org_total_count": totalActiveOrg,
560
-		"active_admin_count":   activeAdminCount,
555
+		"org_count":                newOrgCount,
556
+		"org_total_count":          totalOrg,
557
+		"active_org_count":         activeOrgCount,
558
+		"active_org_total_count":   totalActiveOrg,
559
+		"active_admin_count":       activeAdminCount,
561 560
 		"active_admin_total_count": adminTotalCount,
562
-		"patient_count":  patientCount,
563
-		"patient_total_count":  patientTotalCount,
564
-		"org_count_list": orgRegisterStatistics,
565
-		"patient_count_list": newPatientStatistics,
566
-		"active_count_list": orgActiveAdminStatistics,
567
-		"active_org_list": orgActiveStatistics,
561
+		"patient_count":            patientCount,
562
+		"patient_total_count":      patientTotalCount,
563
+		"org_count_list":           orgRegisterStatistics,
564
+		"patient_count_list":       newPatientStatistics,
565
+		"active_count_list":        orgActiveAdminStatistics,
566
+		"active_org_list":          orgActiveStatistics,
568 567
 	})
569 568
 
570 569
 }

+ 4 - 15
controllers/admin_api_controllers/org_api_controller.go Zobrazit soubor

@@ -29,7 +29,7 @@ func (this *OrgAPIController) GetOrgList() {
29 29
 		page = 1
30 30
 	}
31 31
 	if limit <= 0 {
32
-		limit = 7
32
+		limit = 10
33 33
 	}
34 34
 
35 35
 	timeLayout := "2006-01-02"
@@ -124,25 +124,14 @@ func (this *OrgAPIController) GetOrgDialysisOrderStatistics() {
124 124
 		}
125 125
 		break
126 126
 	case 2: //昨天
127
-		if len(range_data) > 0 {
128
-			rangeDate, parseDateErr = utils.ParseTimeStringToTime("2006-01-02", range_data)
129
-			if parseDateErr != nil {
130
-				this.ErrorLog("日期(%v)解析错误:%v", range_data, parseDateErr)
131
-				return
132
-			}
133
-			rangeTimeStamp = rangeDate.Unix()
134
-		} else {
135
-			rangeTimeStamp = 0
136
-		}
137
-		now := time.Now().Unix()
138
-		count, err := service.GetOrgDialysisCount(statistics_type, org_id, rangeTimeStamp, now)
127
+		var err error
128
+		orgDialysisOrderStatistics, err = service.GetYesterDayOrgDialysisCount(statistics_type, org_id)
139 129
 		if err != nil {
140 130
 			this.ErrorLog("错误:%v", err)
141 131
 			return
142
-
143 132
 		} else {
144 133
 			this.ServeSuccessJSON(map[string]interface{}{
145
-				"count": count,
134
+				"list": orgDialysisOrderStatistics,
146 135
 			})
147 136
 		}
148 137
 		break

+ 59 - 7
controllers/admin_api_controllers/system_api_controller.go Zobrazit soubor

@@ -72,10 +72,13 @@ func (this *SystemApiController) ModifyAdminUser() {
72 72
 		Mtime:        time.Now().Unix(),
73 73
 	}
74 74
 
75
-	info, _ := service.FindUserInfoByAccount(mobile)
76
-	if info.ID > 0 {
77
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNameException)
78
-		return
75
+	if admins.Account != mobile {
76
+		info, _ := service.FindUserInfoByAccount(mobile)
77
+		if info.ID > 0 {
78
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNameException)
79
+			return
80
+
81
+		}
79 82
 
80 83
 	}
81 84
 
@@ -343,9 +346,6 @@ func (this *SystemApiController) ModifyFollowInfo() {
343 346
 			}
344 347
 		}
345 348
 	}
346
-
347
-	fmt.Println(orgFollow)
348
-
349 349
 	//防止数据冗余,先查出之前被删的数据是否存在,存在则直接改变删除状态,不插入新数据
350 350
 	for index, follow := range orgFollow {
351 351
 		info, err := service.FindFollowRecordByID(follow)
@@ -382,3 +382,55 @@ func (this *SystemApiController) ModifyFollowInfo() {
382 382
 	}
383 383
 
384 384
 }
385
+
386
+func (this *SystemApiController) GetWaitFollowOrg() {
387
+	admin_id, _ := this.GetInt64("admin_id", 0)
388
+	keyword := this.GetString("keyword")
389
+	page, _ := this.GetInt64("page", 0)
390
+	limit, _ := this.GetInt64("limit", 0)
391
+	if page <= 0 {
392
+		page = 1
393
+	}
394
+	if limit <= 0 {
395
+		limit = 7
396
+	}
397
+
398
+	list, err, total := service.GetAllWaitFollowOrgList(keyword, page, limit, admin_id)
399
+	if err != nil {
400
+
401
+	} else {
402
+		this.ServeSuccessJSON(map[string]interface{}{
403
+			"list":  list,
404
+			"total": total,
405
+		})
406
+	}
407
+
408
+}
409
+
410
+func (this *SystemApiController) GetAllFollowOrg() {
411
+	admin_id, _ := this.GetInt64("admin_id", 0)
412
+	keyword := this.GetString("keyword")
413
+	page, _ := this.GetInt64("page", 0)
414
+	limit, _ := this.GetInt64("limit", 0)
415
+	if page <= 0 {
416
+		page = 1
417
+	}
418
+	if limit <= 0 {
419
+		limit = 7
420
+	}
421
+
422
+	list, err, total := service.FindAllFollowOrg(keyword, page, limit, admin_id)
423
+	fmt.Println(list)
424
+	fmt.Println(err)
425
+	fmt.Println(total)
426
+
427
+	if err != nil {
428
+
429
+	} else {
430
+		this.ServeSuccessJSON(map[string]interface{}{
431
+			"list":  list,
432
+			"total": total,
433
+		})
434
+	}
435
+
436
+}

+ 1 - 1
models/org_models.go Zobrazit soubor

@@ -29,7 +29,7 @@ type Org struct {
29 29
 	ContactName       string            `gorm:"column:contact_name" json:"contact_name"`
30 30
 	OrgGallery        []*OrgGallery     `gorm:"ForeignKey:OrgId" json:"org_gallery"`
31 31
 	AdminUserLoginLog AdminUserLoginLog `gorm:"ForeignKey:OrgId" json:"log"`
32
-	AdminUser         AdminUser         `gorm:"ForeignKey:Id" json:"admin"`
32
+	AdminUser         AdminUser         `gorm:"ForeignKey:Id;AssociationForeignKey:Creator" json:"admin"`
33 33
 	OrgFollow         []*OrgFollow      `gorm:"ForeignKey:OrgId" json:"follow"`
34 34
 }
35 35
 

+ 1 - 1
routers/router.go Zobrazit soubor

@@ -10,7 +10,7 @@ import (
10 10
 func init() {
11 11
 	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
12 12
 		// AllowAllOrigins:  true,
13
-		AllowOrigins:     []string{"https://xt.kuyicloud.com", "http://localhost:9527", "http://xt.test.shengws.com", "https://xt.test.shengws.com", "http://xt.test.sgjyun.com", "https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com", "https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com", "http://api.szjkhd.com"},
13
+		AllowOrigins:     []string{"http://api.szjkhd.com", "http://admin.xt.test.szjkhd.com", "http://localhost:9527"},
14 14
 		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
15 15
 		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
16 16
 		ExposeHeaders:    []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},

+ 111 - 143
service/admin_service.go Zobrazit soubor

@@ -5,6 +5,7 @@ package service
5 5
 import (
6 6
 	"XT_Admin_Api/models"
7 7
 	"XT_Admin_Api/models/admin_models"
8
+	"database/sql"
8 9
 	"fmt"
9 10
 	"strings"
10 11
 	"time"
@@ -27,7 +28,7 @@ func GetAdminAccount(account string, password string) (*admin_models.AdminAccoun
27 28
 // 获取总机构数
28 29
 func GetTotalOrgCount() (int, error) {
29 30
 	var count int
30
-	err := readUserDb.Model(&models.Org{}).Where("status <> 0").Count(&count).Error
31
+	err := readUserDb.Model(&models.Org{}).Where("status <> 0 AND import <> 1").Count(&count).Error
31 32
 	if err != nil {
32 33
 		return 0, err
33 34
 	}
@@ -412,7 +413,7 @@ func GetAdminUserTotalCount() (int64, error) {
412 413
 func GetRegistedOrgCount(from int64, to int64) (int64, error) {
413 414
 
414 415
 	var count int64
415
-	err := readUserDb.Model(&models.Org{}).Where("status <> 0 AND ctime >= ? AND ctime <= ?", from, to).Count(&count).Error
416
+	err := readUserDb.Model(&models.Org{}).Where("status <> 0 AND ctime >= ? AND ctime <= ? AND AND import <> 1", from, to).Count(&count).Error
416 417
 	if err != nil {
417 418
 		return 0, err
418 419
 	}
@@ -422,7 +423,7 @@ func GetRegistedOrgCount(from int64, to int64) (int64, error) {
422 423
 // 获取一段时间内的活跃机构数
423 424
 func GetActiveOrgCount(from int64, to int64) (int64, error) {
424 425
 	var count int64
425
-	rows, err := readUserDb.Raw("SELECT COUNT(DISTINCT org_id) AS count FROM sgj_user_admin_login_log  JOIN sgj_xt.xt_dialysis_order  ON sgj_user_admin_login_log.org_id = sgj_xt.xt_dialysis_order.user_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 sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1 AND sgj_user_admin_login_log.ctime >= ? AND sgj_user_admin_login_log.ctime <= ? ", from, to).Rows()
426
+	rows, err := readDb.Raw("SELECT COUNT(DISTINCT user_org_id) AS count FROM  xt_dialysis_order where  created_time >= ? AND created_time <= ? AND status = 1 ", from, to).Rows()
426 427
 	if err != nil {
427 428
 		return 0, err
428 429
 	}
@@ -435,7 +436,7 @@ func GetActiveOrgCount(from int64, to int64) (int64, error) {
435 436
 // 获取所有活跃机构数
436 437
 func GetActiveOrgTotalCount() (int64, error) {
437 438
 	var count int64
438
-	rows, err := readUserDb.Raw("SELECT COUNT(DISTINCT org_id) AS count FROM sgj_user_admin_login_log  JOIN sgj_xt.xt_dialysis_order ON sgj_user_admin_login_log.org_id = sgj_xt.xt_dialysis_order.user_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 sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1").Rows()
439
+	rows, err := readDb.Raw("SELECT COUNT(DISTINCT user_org_id) AS count FROM sgj_xt.xt_dialysis_order Where status = 1").Rows()
439 440
 	if err != nil {
440 441
 		return 0, err
441 442
 	}
@@ -445,9 +446,34 @@ func GetActiveOrgTotalCount() (int64, error) {
445 446
 	return count, nil
446 447
 }
447 448
 
449
+//获取昨天的注册机构总量
450
+func GetYesterDayRegistedOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
451
+	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 1 DAY) = date(from_unixtime(sgj_user_org.ctime)) AND sgj_user_org.status = 1 AND sgj_user_org.import <> 1  GROUP BY date(from_unixtime(ctime));").Scan(&weekStatistics).Error
452
+	return
453
+}
454
+
455
+//获取近昨天的的机构活跃总量
456
+func GetYesterDayActiveOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
457
+	db := readDb.Raw("select count(DISTINCT(user_org_id)) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times  from  xt_dialysis_order   where DATE_SUB(CURDATE(), INTERVAL 1 DAY) = date(from_unixtime(created_time)) AND status = 1 GROUP BY date(from_unixtime(created_time));")
458
+	err = db.Scan(&weekStatistics).Error
459
+	return
460
+}
461
+
462
+//获取昨天的的机构活跃账号总量
463
+func GetYesterDayActiveAdminUserCount() (weekStatistics []*admin_models.Statistics, err error) {
464
+	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 1 DAY) = date(from_unixtime(sgj_user_admin_login_log.ctime))  AND operate_type = 1 AND app_type = 3 GROUP BY date(from_unixtime(ctime));").Scan(&weekStatistics).Error
465
+	return
466
+}
467
+
468
+//获取昨天的的机构新增病人总量
469
+func GetYesterDayNewPatientCount() (weekStatistics []*admin_models.Statistics, err error) {
470
+	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 1 DAY) = date(from_unixtime(created_time)) GROUP BY date(from_unixtime(created_time));").Scan(&weekStatistics).Error
471
+	return
472
+}
473
+
448 474
 //获取近七天每天的注册机构总量
449 475
 func GetWeekRegistedOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
450
-	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
476
+	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)) AND sgj_user_org.status = 1 AND sgj_user_org.import <> 1 GROUP BY date(from_unixtime(ctime));").Scan(&weekStatistics).Error
451 477
 	return
452 478
 }
453 479
 
@@ -458,7 +484,7 @@ func GetWeekRegistedOrgCount() (weekStatistics []*admin_models.Statistics, err e
458 484
 
459 485
 //获取近七天每天的机构活跃总量
460 486
 func GetWeekActiveOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
461
-	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 AND app_type = 3 GROUP BY date(from_unixtime(ctime));")
487
+	db := readDb.Raw("select count(DISTINCT(user_org_id)) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times  from  xt_dialysis_order   where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(created_time)) AND status = 1 GROUP BY date(from_unixtime(created_time));")
462 488
 	err = db.Scan(&weekStatistics).Error
463 489
 	return
464 490
 }
@@ -475,41 +501,15 @@ func GetWeekNewPatientCount() (weekStatistics []*admin_models.Statistics, err er
475 501
 	return
476 502
 }
477 503
 
478
-//获取近七天每天的注册机构总量
479
-func GetWeekRegistedOrgTotalCount() (int64, error) {
480
-	var result admin_models.Count
481
-	var err error
482
-	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
483
-	return result.Count, err
484
-}
485
-
486
-//获取近七天每天的机构活跃账号总量
487
-func GetWeekActiveAdminUserTotalCount() (int64, error) {
488
-	var result admin_models.Count
489
-	var err error
490
-	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
491
-	return result.Count, err
492
-
493
-}
494
-
495
-//获取近七天新增病人总量
496
-func GetWeekPatientTotalCount() (int64, error) {
497
-	var result admin_models.Count
498
-	var err error
499
-	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
500
-	return result.Count, err
501
-
502
-}
503
-
504 504
 //获取近30天每天的注册机构总量
505 505
 func GetMonthRegistedOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
506
-	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
506
+	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)) AND sgj_user_org.status = 1 AND sgj_user_org.import <> 1 GROUP BY date(from_unixtime(ctime));").Scan(&weekStatistics).Error
507 507
 	return
508 508
 }
509 509
 
510 510
 //获取近30天每天的机构活跃总量
511 511
 func GetMonthActiveOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
512
-	err = readUserDb.Raw("select DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m') as times,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 times").Scan(&weekStatistics).Error
512
+	err = readDb.Raw("select count(DISTINCT(user_org_id)) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times  from  xt_dialysis_order   where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(from_unixtime(created_time)) AND status = 1 GROUP BY date(from_unixtime(created_time));").Scan(&weekStatistics).Error
513 513
 	return
514 514
 }
515 515
 
@@ -525,33 +525,9 @@ func GetMonthNewPatientCount() (weekStatistics []*admin_models.Statistics, err e
525 525
 	return
526 526
 }
527 527
 
528
-//获取近30天每天的注册机构总量
529
-func GetMonthRegistedOrgTotalCount() (int64, error) {
530
-	var result admin_models.Count
531
-	var err error
532
-	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
533
-	return result.Count, err
534
-}
535
-
536
-//获取近30天每天的机构活跃账号总量
537
-func GetMonthActiveAdminUserTotalCount() (int64, error) {
538
-	var result admin_models.Count
539
-	var err error
540
-	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
541
-	return result.Count, err
542
-}
543
-
544
-//获取近30天每天的机构新增病人总量
545
-func GetMonthNewPatientTotalCount() (int64, error) {
546
-	var result admin_models.Count
547
-	var err error
548
-	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
549
-	return result.Count, err
550
-}
551
-
552 528
 //获取近3个月每个月的注册机构总量
553 529
 func GetThreeMonthRegistedOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
554
-	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
530
+	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') AND sgj_user_org.status = 1 AND sgj_user_org.import <> 1 group by times").Scan(&weekStatistics).Error
555 531
 	return
556 532
 }
557 533
 
@@ -563,7 +539,7 @@ func GetThreeMonthActiveAdminUserCount() (weekStatistics []*admin_models.Statist
563 539
 
564 540
 //获取近3个月每个月的机构活跃总量
565 541
 func GetThreeMonthActiveOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
566
-	err = readUserDb.Raw("select DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m') as times,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 AND operate_type = 1 ) 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 times").Scan(&weekStatistics).Error
542
+	err = readDb.Raw("select DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times,count(DISTINCT(user_org_id)) as count From  xt_dialysis_order  where  DATE_FORMAT(date(from_unixtime(created_time)),'%Y-%m')>=DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') AND status = 1  group by times").Scan(&weekStatistics).Error
567 543
 	return
568 544
 }
569 545
 
@@ -573,36 +549,9 @@ func GetThreeMonthNewPatientCount() (weekStatistics []*admin_models.Statistics,
573 549
 	return
574 550
 }
575 551
 
576
-//获取近3个月每个月的注册机构总量
577
-func GetThreeMonthRegistedOrgTotalCount() (int64, error) {
578
-	var result admin_models.Count
579
-	var err error
580
-	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
581
-	return result.Count, err
582
-
583
-}
584
-
585
-//获取近3个月每个月的机构活跃账号总量
586
-func GetThreeMonthActiveAdminUserTotalCount() (int64, error) {
587
-	var result admin_models.Count
588
-	var err error
589
-	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
590
-	return result.Count, err
591
-
592
-}
593
-
594
-//获取近3个月每个月机构新增病人总量
595
-func GetThreeMonthNewPatientTotalCount() (int64, error) {
596
-	var result admin_models.Count
597
-	var err error
598
-	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
599
-	return result.Count, err
600
-
601
-}
602
-
603 552
 //获取近半年每个月的注册机构总量
604 553
 func GetSixMonthRegistedOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
605
-	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
554
+	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') AND sgj_user_org.status = 1 AND sgj_user_org.import <> 1 group by times").Scan(&weekStatistics).Error
606 555
 	return
607 556
 }
608 557
 
@@ -614,7 +563,7 @@ func GetSixMonthActiveAdminUserCount() (weekStatistics []*admin_models.Statistic
614 563
 
615 564
 //获取近半年每个月的机构活跃总量
616 565
 func GetSixMonthActiveOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
617
-	err = readUserDb.Raw("select DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m') as times,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 AND operate_type = 1  ) 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 times").Scan(&weekStatistics).Error
566
+	err = readDb.Raw("select DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times,count(DISTINCT(user_org_id)) as count From  xt_dialysis_order  where  DATE_FORMAT(date(from_unixtime(created_time)),'%Y-%m')>=DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m') AND status = 1  group by times").Scan(&weekStatistics).Error
618 567
 	return
619 568
 }
620 569
 
@@ -624,35 +573,9 @@ func GetSixMonthNewPatientCount() (weekStatistics []*admin_models.Statistics, er
624 573
 	return
625 574
 }
626 575
 
627
-//获取近半年每个月的注册机构总量
628
-func GetSixMonthRegistedOrgTotalCount() (int64, error) {
629
-	var result admin_models.Count
630
-	var err error
631
-	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
632
-	return result.Count, err
633
-}
634
-
635
-//获取近半年每个月的机构活跃账号总量
636
-func GetSixMonthActiveAdminUserTotalCount() (int64, error) {
637
-	var result admin_models.Count
638
-	var err error
639
-	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
640
-	return result.Count, err
641
-
642
-}
643
-
644
-//获取近半年每个月机构新增病人总量
645
-func GetSixMonthNewPatientTotalCount() (int64, error) {
646
-	var result admin_models.Count
647
-	var err error
648
-	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
649
-	return result.Count, err
650
-
651
-}
652
-
653 576
 //获取近1年每个月的注册机构总量
654 577
 func GetYearRegistedOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
655
-	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
578
+	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') AND sgj_user_org.status = 1 AND sgj_user_org.import <> 1 group by times").Scan(&weekStatistics).Error
656 579
 	return
657 580
 }
658 581
 
@@ -664,7 +587,7 @@ func GetYearActiveAdminUserCount() (weekStatistics []*admin_models.Statistics, e
664 587
 
665 588
 //获取近1年每个月的机构活跃总量
666 589
 func GetYearActiveOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
667
-	err = readUserDb.Raw("select DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m') as times,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 AND operate_type = 1 ) 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 times").Scan(&weekStatistics).Error
590
+	err = readDb.Raw("select DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m') as times,count(DISTINCT(user_org_id)) as count From  xt_dialysis_order  where  DATE_FORMAT(date(from_unixtime(created_time)),'%Y-%m')>=DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m') AND status = 1  group by times").Scan(&weekStatistics).Error
668 591
 	return
669 592
 }
670 593
 
@@ -674,32 +597,6 @@ func GetYearNewPatientCount() (weekStatistics []*admin_models.Statistics, err er
674 597
 	return
675 598
 }
676 599
 
677
-//获取近1年每个月的注册机构总量
678
-func GetYearRegistedOrgTotalCount() (int64, error) {
679
-	var result admin_models.Count
680
-	var err error
681
-	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
682
-	return result.Count, err
683
-
684
-}
685
-
686
-//获取近1年每个月的机构活跃账号总量
687
-func GetYearActiveAdminUserTotalCount() (int64, error) {
688
-	var result admin_models.Count
689
-	var err error
690
-	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
691
-	return result.Count, err
692
-}
693
-
694
-//获取近1年每个月机构新增病人总量
695
-func GetYearNewPatientTotalCount() (int64, error) {
696
-	var result admin_models.Count
697
-	var err error
698
-	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
699
-	return result.Count, err
700
-
701
-}
702
-
703 600
 func GetAllAdmin() (admin []*admin_models.AdminAccount, err error) {
704 601
 	err = readUserDb.Model(&admin_models.AdminAccount{}).Where("is_super_admin <> 1 AND (status = 1 OR status = 2)").Find(&admin).Error
705 602
 	return
@@ -810,3 +707,74 @@ func FindFollowInfoById(org_id int64, admin_user_id int64) (info models.OrgFollo
810 707
 	err = readUserDb.Model(&models.OrgFollow{}).Where("org_id = ? AND status = 1 AND admin_user_id = ?", org_id, admin_user_id).First(&info).Error
811 708
 	return
812 709
 }
710
+
711
+func GetAllWaitFollowOrgList(keyword string, page int64, limit int64, id int64) (orgViewModel []*OrgViewModel, err error, total int64) {
712
+	type Total struct {
713
+		Count int64
714
+	}
715
+	var totals Total
716
+	offset := (page - 1) * limit
717
+	db := readUserDb
718
+	if len(keyword) > 0 {
719
+		likeKey := "%" + keyword + "%"
720
+		err = db.Raw("Select id, org_name From  sgj_user_org  Where NOT EXISTS (Select id, org_name FROM sgj_org_follow Where sgj_org_follow.org_id = sgj_user_org.id AND sgj_org_follow.admin_user_id = ? AND sgj_org_follow.status = 1 ) AND import <> 1 AND (sgj_user_org.org_name Like ? OR sgj_user_org.org_short_name Like ?)", id, likeKey, likeKey).Offset(offset).Limit(limit).Scan(&orgViewModel).Error
721
+		readUserDb.Raw("Select count(id) as count From  sgj_user_org  Where NOT EXISTS (Select id, org_name FROM sgj_org_follow Where sgj_org_follow.org_id = sgj_user_org.id AND sgj_org_follow.admin_user_id = ? AND sgj_org_follow.status = 1)  AND import <> 1 AND (sgj_user_org.org_name Like ? OR sgj_user_org.org_short_name Like ?)", id, likeKey, likeKey).Scan(&totals)
722
+
723
+	} else {
724
+		db = db.Raw("Select id, org_name From  sgj_user_org  Where NOT EXISTS (Select id, org_name FROM sgj_org_follow Where sgj_org_follow.org_id = sgj_user_org.id AND sgj_org_follow.admin_user_id = ? AND sgj_org_follow.status = 1)  AND import <> 1", id)
725
+		err = db.Offset(offset).Limit(limit).Scan(&orgViewModel).Error
726
+		readUserDb.Raw("Select count(id) as count From  sgj_user_org  Where NOT EXISTS (Select id, org_name FROM sgj_org_follow Where sgj_org_follow.org_id = sgj_user_org.id AND sgj_org_follow.admin_user_id = ? AND sgj_org_follow.status = 1)  AND import <> 1", id).Scan(&totals)
727
+
728
+	}
729
+
730
+	return orgViewModel, err, totals.Count
731
+}
732
+
733
+func FindAllFollowOrg(keyword string, page int64, limit int64, admin_id int64) (follow []*FollowViewModel, err error, total int64) {
734
+	type Total struct {
735
+		Count int64
736
+	}
737
+	var totals Total
738
+
739
+	offset := (page - 1) * limit
740
+
741
+	if len(keyword) > 0 {
742
+		var vms []*FollowViewModel = make([]*FollowViewModel, 0)
743
+		var rows *sql.Rows
744
+		var errs error
745
+		likeKey := "%" + keyword + "%"
746
+		rows, errs = readUserDb.Raw("SELECT follow.*, org.org_name as org_name FROM sgj_org_follow as follow join sgj_user_org as org on org.id = follow.org_id AND (org.org_name Like ? OR org.org_short_name Like ?) AND org.import <> 1 WHERE (follow.admin_user_id = ? AND follow.status = 1)", likeKey, likeKey, admin_id).Offset(offset).Limit(limit).Rows()
747
+		readUserDb.Raw("SELECT count(follow.id) as count FROM sgj_org_follow as follow join sgj_user_org as org on org.id = follow.org_id AND (org.org_name Like ? OR org.org_short_name Like ?) AND org.import <> 1  WHERE follow.admin_user_id = ? AND follow.status = 1", likeKey, likeKey, admin_id).Scan(&totals)
748
+
749
+		defer rows.Close()
750
+		if errs != nil {
751
+			return nil, errs, totals.Count
752
+		}
753
+		for rows.Next() {
754
+			var vm FollowViewModel
755
+			readDb.ScanRows(rows, &vm)
756
+			vms = append(vms, &vm)
757
+		}
758
+
759
+		return vms, nil, totals.Count
760
+	} else {
761
+		var vms []*FollowViewModel = make([]*FollowViewModel, 0)
762
+		var rows *sql.Rows
763
+		var errs error
764
+		rows, errs = readUserDb.Raw("SELECT follow.*, org.org_name as org_name FROM sgj_org_follow as follow join sgj_user_org as org on org.id = follow.org_id   AND org.import <> 1 WHERE follow.admin_user_id = ? AND follow.status = 1", admin_id).Offset(offset).Limit(limit).Rows()
765
+		readUserDb.Raw("SELECT count(follow.id) as count FROM sgj_org_follow as follow join sgj_user_org as org on org.id = follow.org_id  AND org.import <> 1  WHERE follow.admin_user_id = ? AND follow.status = 1", admin_id).Scan(&totals)
766
+
767
+		defer rows.Close()
768
+		if errs != nil {
769
+			return nil, errs, totals.Count
770
+		}
771
+		for rows.Next() {
772
+			var vm FollowViewModel
773
+			readDb.ScanRows(rows, &vm)
774
+			vms = append(vms, &vm)
775
+		}
776
+
777
+		return vms, nil, totals.Count
778
+	}
779
+
780
+}

+ 45 - 45
service/function_service.go Zobrazit soubor

@@ -6,151 +6,151 @@ import (
6 6
 )
7 7
 
8 8
 //病人管理
9
-func GetTodayInfo(to int64,ctime int64,page int64,limit int64)(patientinfo []function_models.PatientInfo,total int64,err error) {
9
+func GetTodayInfo(to int64, ctime int64, page int64, limit int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
10 10
 
11 11
 	offset := (page - 1) * limit
12
-	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id left join sgj_xt.xt_patients as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?  GROUP BY x.user_org_id",to,ctime).Scan(&patientinfo).Error
12
+	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id left join sgj_xt.xt_patients as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?  GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
13 13
 	rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_patients as x on x.user_org_id = u.id where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
14
-	fmt.Println("rows是什么",rows)
15 14
 	if rows.Next() {
16 15
 		rows.Scan(&total)
17 16
 	}
18
-	fmt.Println("&total是什么",total)
19
-	return patientinfo,total,err
17
+	fmt.Println("&total是什么", total)
18
+	return patientinfo, total, err
20 19
 }
21 20
 
22
-   //透析处方
23
-func GetTodayDialysisPatientsInfo(to int64,ctime int64,page int64,limit int64)(patientinfo []function_models.PatientInfo,total int64,err error)  {
21
+//透析处方
22
+func GetTodayDialysisPatientsInfo(to int64, ctime int64, page int64, limit int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
24 23
 
25 24
 	offset := (page - 1) * limit
26
-	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id left join sgj_xt.xt_dialysis_prescription as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id  where x.created_time >= ? AND x.created_time <= ? GROUP BY x.user_org_id",to,ctime).Scan(&patientinfo).Error
25
+	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id left join sgj_xt.xt_dialysis_prescription as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id  where x.created_time >= ? AND x.created_time <= ? GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
27 26
 	rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_dialysis_prescription as x on x.user_org_id = u.id  where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
28 27
 	if rows.Next() {
29 28
 		rows.Scan(&total)
30 29
 	}
31 30
 
32
-	return patientinfo,total,err
31
+	return patientinfo, total, err
33 32
 }
34 33
 
35
-
36
-   //接诊评估
37
-func GetTodayReceivePatientsInfo(to int64,ctime int64,page int64,limit int64)(patientinfo []function_models.PatientInfo,total int64,err error)  {
34
+//接诊评估
35
+func GetTodayReceivePatientsInfo(to int64, ctime int64, page int64, limit int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
38 36
 
39 37
 	offset := (page - 1) * limit
40
-	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u  left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id left join sgj_xt.xt_receive_treatment_asses as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id  where x.created_time >= ? AND x.created_time <= ? GROUP BY x.user_org_id",to,ctime).Scan(&patientinfo).Error
38
+	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u  left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id left join sgj_xt.xt_receive_treatment_asses as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id  where x.created_time >= ? AND x.created_time <= ? GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
41 39
 	rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_receive_treatment_asses as x on x.user_org_id = u.id  where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
42 40
 	if rows.Next() {
43 41
 		rows.Scan(&total)
44 42
 	}
45 43
 
46
-	return patientinfo,total,err
44
+	return patientinfo, total, err
47 45
 }
46
+
48 47
 // 透前评估
49
-func GetTodayBeforDislysisInfo(to int64,ctime int64,page int64,limit int64)(patientinfo []function_models.PatientInfo,total int64,err error)  {
48
+func GetTodayBeforDislysisInfo(to int64, ctime int64, page int64, limit int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
50 49
 	offset := (page - 1) * limit
51
-	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id left join sgj_xt.xt_assessment_before_dislysis as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id  where x.created_time >= ? AND x.created_time <= ? GROUP BY x.user_org_id",to,ctime).Scan(&patientinfo).Error
50
+	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id left join sgj_xt.xt_assessment_before_dislysis as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id  where x.created_time >= ? AND x.created_time <= ? GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
52 51
 	rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_assessment_before_dislysis as x on x.user_org_id = u.id  where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
53 52
 	if rows.Next() {
54 53
 		rows.Scan(&total)
55 54
 	}
56 55
 
57
-	return patientinfo,total,err
56
+	return patientinfo, total, err
58 57
 }
59 58
 
60
- //零食医嘱
61
-func GetTodayDoctorsOrderInfo(to int64,ctime int64,page int64,limit int64)(patientinfo []function_models.PatientInfo,total int64,err error)  {
62
-
59
+//零食医嘱
60
+func GetTodayDoctorsOrderInfo(to int64, ctime int64, page int64, limit int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
63 61
 
64 62
 	offset := (page - 1) * limit
65
-	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id join sgj_xt.xt_doctor_advice as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id  where x.created_time >= ? AND x.created_time <= ? GROUP BY x.user_org_id",to,ctime).Scan(&patientinfo).Error
63
+	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id join sgj_xt.xt_doctor_advice as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id  where x.created_time >= ? AND x.created_time <= ? GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
66 64
 	rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_doctor_advice as x on x.user_org_id = u.id  where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
67 65
 	if rows.Next() {
68 66
 		rows.Scan(&total)
69 67
 	}
70 68
 
71
-	return patientinfo,total,err
69
+	return patientinfo, total, err
72 70
 }
71
+
73 72
 //双人核对
74
-func GetTodayDoubleCheckInfo(to int64,ctime int64,page int64,limit int64)(patientinfo []function_models.PatientInfo,total int64,err error)  {
73
+func GetTodayDoubleCheckInfo(to int64, ctime int64, page int64, limit int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
75 74
 
76 75
 	offset := (page - 1) * limit
77
-	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id join sgj_xt.xt_double_check as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id  where x.created_time >= ? AND x.created_time <= ? GROUP BY x.user_org_id",to,ctime).Scan(&patientinfo).Error
76
+	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id join sgj_xt.xt_double_check as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id  where x.created_time >= ? AND x.created_time <= ? GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
78 77
 	rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_double_check as x on x.user_org_id = u.id  where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
79 78
 	if rows.Next() {
80 79
 		rows.Scan(&total)
81 80
 	}
82 81
 
83
-	return patientinfo,total,err
82
+	return patientinfo, total, err
84 83
 }
84
+
85 85
 //透析上机
86
-func GetTodayDialysisMachinek(to int64,ctime int64,page int64,limit int64)(patientinfo []function_models.PatientInfo,total int64,err error)  {
86
+func GetTodayDialysisMachinek(to int64, ctime int64, page int64, limit int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
87 87
 
88 88
 	offset := (page - 1) * limit
89
-	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id left join sgj_xt.xt_dialysis_order as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id  where x.created_time >= ? AND x.created_time <= ? GROUP BY x.user_org_id",to,ctime).Scan(&patientinfo).Error
89
+	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id left join sgj_xt.xt_dialysis_order as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id  where x.created_time >= ? AND x.created_time <= ? GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
90 90
 	rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_dialysis_order as x on x.user_org_id = u.id  where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
91 91
 	if rows.Next() {
92 92
 		rows.Scan(&total)
93 93
 	}
94 94
 
95
-	return patientinfo,total,err
95
+	return patientinfo, total, err
96 96
 }
97 97
 
98 98
 //透析检测
99
-func GetTodayDialysisExamination(to int64,ctime int64,page int64,limit int64)(patientinfo []function_models.PatientInfo,total int64,err error) {
99
+func GetTodayDialysisExamination(to int64, ctime int64, page int64, limit int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
100 100
 
101 101
 	offset := (page - 1) * limit
102
-	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id join sgj_xt.xt_monitoring_record as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id  where x.created_time >= ? AND x.created_time <= ? GROUP BY x.user_org_id",to,ctime).Scan(&patientinfo).Error
102
+	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id join sgj_xt.xt_monitoring_record as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id  where x.created_time >= ? AND x.created_time <= ? GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
103 103
 	rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_monitoring_record as x on x.user_org_id = u.id  where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
104 104
 	if rows.Next() {
105 105
 		rows.Scan(&total)
106 106
 	}
107 107
 
108
-	return patientinfo,total,err
108
+	return patientinfo, total, err
109 109
 }
110 110
 
111 111
 //透析下机
112
-func GetTodayBeforOrpenetration(to int64,ctime int64,page int64,limit int64)(patientinfo []function_models.PatientInfo,total int64,err error)  {
112
+func GetTodayBeforOrpenetration(to int64, ctime int64, page int64, limit int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
113 113
 
114 114
 	offset := (page - 1) * limit
115
-	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id join sgj_xt.xt_dialysis_order as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id  where x.created_time >= ? AND x.created_time <= ? GROUP BY x.user_org_id",to,ctime).Scan(&patientinfo).Error
115
+	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id join sgj_xt.xt_dialysis_order as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id  where x.created_time >= ? AND x.created_time <= ? GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
116 116
 	rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_dialysis_order as x on x.user_org_id = u.id  where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
117 117
 	if rows.Next() {
118 118
 		rows.Scan(&total)
119 119
 	}
120 120
 
121
-	return patientinfo,total,err
121
+	return patientinfo, total, err
122 122
 }
123 123
 
124 124
 //透后评估
125
-func GetTodayPostAssessment(to int64,ctime int64,page int64,limit int64)(patientinfo []function_models.PatientInfo,total int64,err error)  {
125
+func GetTodayPostAssessment(to int64, ctime int64, page int64, limit int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
126 126
 	offset := (page - 1) * limit
127
-	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id join sgj_xt.xt_assessment_after_dislysis as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id  where x.created_time >= ? AND x.created_time <= ? GROUP BY x.user_org_id",to,ctime).Scan(&patientinfo).Error
127
+	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u left join sgj_org_follow as f On f.org_id = u.id left JoIN sgj_admin as a On a.id = f.admin_user_id join sgj_xt.xt_assessment_after_dislysis as x on x.user_org_id = u.id left JOIN sgj_xt.xt_patients as p On p.id = x.patient_id  where x.created_time >= ? AND x.created_time <= ? GROUP BY x.user_org_id", to, ctime).Scan(&patientinfo).Error
128 128
 	rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_assessment_after_dislysis as x on x.user_org_id = u.id  where x.created_time >= ? AND x.created_time <= ?", to, ctime).Rows()
129 129
 	if rows.Next() {
130 130
 		rows.Scan(&total)
131 131
 	}
132 132
 
133
-	return patientinfo,total,err
133
+	return patientinfo, total, err
134 134
 }
135 135
 
136
-func GetTodayEntrylist(to int64,ctime int64,limit int64,page int64)(patientinfo []function_models.PatientInfo,total int64, err error)  {
137
-	 offset := (page - 1) * limit
138
-	 err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u  join sgj_xt.xt_warehouse as x on x.org_id = u.id  LEFT JOIN  sgj_users.sgj_org_follow as f ON f.org_id = u.id  LEFT JOIN   sgj_users.sgj_admin as a on a.id = f.admin_user_id  where x.ctime >= ? AND x.ctime<= ? GROUP BY x.org_id",to,ctime).Scan(&patientinfo).Error
136
+func GetTodayEntrylist(to int64, ctime int64, limit int64, page int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
137
+	offset := (page - 1) * limit
138
+	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u  join sgj_xt.xt_warehouse as x on x.org_id = u.id  LEFT JOIN  sgj_users.sgj_org_follow as f ON f.org_id = u.id  LEFT JOIN   sgj_users.sgj_admin as a on a.id = f.admin_user_id  where x.ctime >= ? AND x.ctime<= ? GROUP BY x.org_id", to, ctime).Scan(&patientinfo).Error
139 139
 	rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_warehouse as x on x.org_id = u.id where x.ctime >= ? AND x.ctime <= ?", to, ctime).Rows()
140 140
 	if rows.Next() {
141 141
 		rows.Scan(&total)
142 142
 	}
143 143
 
144
-	return patientinfo,total,err
144
+	return patientinfo, total, err
145 145
 }
146 146
 
147
-func GetTodayExitlist(to int64,ctime int64,limit int64,page int64)(patientinfo []function_models.PatientInfo,total int64,err error)  {
147
+func GetTodayExitlist(to int64, ctime int64, limit int64, page int64) (patientinfo []function_models.PatientInfo, total int64, err error) {
148 148
 	offset := (page - 1) * limit
149
-	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u  join sgj_xt.xt_warehouse_out as x on x.org_id = u.id  LEFT JOIN  sgj_users.sgj_org_follow as f ON f.org_id = u.id  LEFT JOIN   sgj_users.sgj_admin as a on a.id = f.admin_user_id  where x.ctime >= ? AND x.ctime<= ? GROUP BY x.org_id",to,ctime).Scan(&patientinfo).Error
149
+	err = readUserDb.Raw("select * from sgj_users.sgj_user_org as u  join sgj_xt.xt_warehouse_out as x on x.org_id = u.id  LEFT JOIN  sgj_users.sgj_org_follow as f ON f.org_id = u.id  LEFT JOIN   sgj_users.sgj_admin as a on a.id = f.admin_user_id  where x.ctime >= ? AND x.ctime<= ? GROUP BY x.org_id", to, ctime).Scan(&patientinfo).Error
150 150
 	rows, err := readUserDb.Offset(offset).Limit(limit).Raw("select Count(1) from sgj_users.sgj_user_org as u join sgj_xt.xt_warehouse_out as x on x.org_id = u.id where x.ctime >= ? AND x.ctime <= ?", to, ctime).Rows()
151 151
 	if rows.Next() {
152 152
 		rows.Scan(&total)
153 153
 	}
154 154
 
155
-	return patientinfo,total,err
156
-}
155
+	return patientinfo, total, err
156
+}

+ 65 - 14
service/org_service.go Zobrazit soubor

@@ -40,26 +40,22 @@ func GetAllOrgList(active_status int64, depth_active_status int64, start_time in
40 40
 		case 1:
41 41
 			now := time.Now()
42 42
 			zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
43
-			db = db.Joins("JOIN sgj_user_admin_login_log on sgj_user_admin_login_log.org_id = sgj_user_org.id AND sgj_user_admin_login_log.ctime >= ? AND sgj_user_admin_login_log.ctime <= ? AND sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1 ", zeroHourTimeOfToday.Unix(), now.Unix())
44
-			db = db.Joins("JOIN sgj_xt.xt_dialysis_order on sgj_xt.xt_dialysis_order.user_org_id = sgj_user_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') AND sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1 ")
43
+			db = db.Joins("JOIN sgj_xt.xt_dialysis_order ON sgj_xt.xt_dialysis_order.user_org_id = sgj_user_org.id AND sgj_xt.xt_dialysis_order.created_time >= ? AND sgj_xt.xt_dialysis_order.created_time <= ?", zeroHourTimeOfToday.Unix(), now.Unix())
45 44
 
46 45
 			break
47 46
 		case 2:
48
-			db = db.Joins("JOIN sgj_user_admin_login_log on sgj_user_admin_login_log.org_id = sgj_user_org.id AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(sgj_user_admin_login_log.ctime)) AND sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1 ")
49
-			db = db.Joins("JOIN sgj_xt.xt_dialysis_order on sgj_xt.xt_dialysis_order.user_org_id = sgj_user_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') AND sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1 ")
47
+			db = db.Joins("JOIN sgj_xt.xt_dialysis_order ON sgj_xt.xt_dialysis_order.user_org_id = sgj_user_org.id  AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(from_unixtime(sgj_xt.xt_dialysis_order.created_time)) AND sgj_xt.xt_dialysis_order.status = 1")
50 48
 
51 49
 			break
52 50
 		case 3:
53
-			db = db.Joins("JOIN sgj_user_admin_login_log on sgj_user_admin_login_log.org_id = sgj_user_org.id AND DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= date(from_unixtime(sgj_user_admin_login_log.ctime)) AND sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1 ")
54
-			db = db.Joins("JOIN sgj_xt.xt_dialysis_order on sgj_xt.xt_dialysis_order.user_org_id = sgj_user_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') AND sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1 ")
51
+			db = db.Joins("JOIN sgj_xt.xt_dialysis_order ON sgj_xt.xt_dialysis_order.user_org_id = sgj_user_org.id  AND DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(from_unixtime(sgj_xt.xt_dialysis_order.created_time)) AND sgj_xt.xt_dialysis_order.status = 1")
55 52
 
56 53
 			break
57 54
 		case 4:
58
-			db = db.Joins("JOIN sgj_user_admin_login_log on sgj_user_admin_login_log.org_id = sgj_user_org.id AND DATE_SUB(CURDATE(), INTERVAL 1 Year) <= date(from_unixtime(sgj_user_admin_login_log.ctime)) AND sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1 ")
59
-			db = db.Joins("JOIN sgj_xt.xt_dialysis_order on sgj_xt.xt_dialysis_order.user_org_id = sgj_user_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') AND sgj_user_admin_login_log.app_type = 3 AND sgj_user_admin_login_log.operate_type = 1 ")
60
-
55
+			db = db.Joins("JOIN sgj_xt.xt_dialysis_order on sgj_xt.xt_dialysis_order.user_org_id = sgj_user_org.id AND DATE_SUB(CURDATE(), INTERVAL 1 Year) <= date(from_unixtime(sgj_xt.xt_dialysis_order.created_time)) AND sgj_xt.xt_dialysis_order.status = 1")
61 56
 			break
62 57
 		}
58
+
63 59
 		if province > 0 {
64 60
 			db = db.Where("sgj_user_org.province = ?", province)
65 61
 		}
@@ -84,7 +80,7 @@ func GetAllOrgList(active_status int64, depth_active_status int64, start_time in
84 80
 		}
85 81
 
86 82
 	}
87
-	err = db.Where("sgj_user_org.status = 1").Preload("OrgFollow", func(db *gorm.DB) *gorm.DB {
83
+	err = db.Where("sgj_user_org.status = 1 AND sgj_user_org.import <> 1").Preload("OrgFollow", func(db *gorm.DB) *gorm.DB {
88 84
 		return db.Model(&models.OrgFollow{}).Where("status = 1").Preload("AdminAccount", "status = 1")
89 85
 	}).Preload("AdminUserLoginLog", func(db *gorm.DB) *gorm.DB {
90 86
 		return db.Model(&models.AdminUserLoginLog{}).Where("id = (SELECT max(id))")
@@ -93,7 +89,7 @@ func GetAllOrgList(active_status int64, depth_active_status int64, start_time in
93 89
 }
94 90
 
95 91
 func GetOrgDetailInfo(org_id int64) (info models.Org, err error) {
96
-	err = readUserDb.Model(&models.Org{}).Where("id = ? AND status = 1", org_id).Preload("AdminUserLoginLog", func(db *gorm.DB) *gorm.DB {
92
+	err = readUserDb.Model(&models.Org{}).Where("id = ? AND status = 1 AND import <> 1", org_id).Preload("AdminUserLoginLog", func(db *gorm.DB) *gorm.DB {
97 93
 		return db.Model(&models.AdminUserLoginLog{}).Where("id = (SELECT max(id))")
98 94
 	}).Preload("AdminUser", "status = 1").Find(&info).Error
99 95
 	return
@@ -109,7 +105,7 @@ func GetAllOrgType() (types []*models.OrgType, err error) {
109 105
 	return
110 106
 }
111 107
 
112
-//设置今天和昨天的数据
108
+//设置今天
113 109
 func GetOrgDialysisCount(statices_type int64, org_id int64, from int64, to int64) (count int64, err error) {
114 110
 	var counts int64
115 111
 
@@ -227,6 +223,60 @@ func GetOrgDialysisCount(statices_type int64, org_id int64, from int64, to int64
227 223
 	return counts, nil
228 224
 }
229 225
 
226
+//获取昨天的数据
227
+func GetYesterDayOrgDialysisCount(statices_type int64, org_id int64) (weekStatistics []*admin_models.Statistics, err error) {
228
+	fmt.Println(statices_type)
229
+
230
+	switch statices_type {
231
+	case 1: //病人管理
232
+		err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times  from xt_patients  where DATE_SUB(CURDATE(), INTERVAL 1 DAY) = date(from_unixtime(created_time)) AND status = 1  AND user_org_id = ? GROUP BY times", org_id).Scan(&weekStatistics).Error
233
+
234
+		break
235
+	case 2: //透析处方
236
+		err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times  from xt_dialysis_prescription  where DATE_SUB(CURDATE(), INTERVAL 1 DAY) = date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times", org_id).Scan(&weekStatistics).Error
237
+
238
+		break
239
+	case 3: //接诊评估
240
+		err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times  from xt_receive_treatment_asses  where DATE_SUB(CURDATE(), INTERVAL 1 DAY) = date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times", org_id).Scan(&weekStatistics).Error
241
+
242
+		break
243
+	case 4: //透前评估
244
+		err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times  from xt_assessment_before_dislysis  where DATE_SUB(CURDATE(), INTERVAL 1 DAY) = date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times", org_id).Scan(&weekStatistics).Error
245
+		break
246
+
247
+	case 5: //临时医嘱
248
+		err = readDb.Raw("select count(distinct patient_id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times  from xt_doctor_advice  where DATE_SUB(CURDATE(), INTERVAL 1 DAY) = date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times", org_id).Scan(&weekStatistics).Error
249
+
250
+		break
251
+	case 6: //双人核对
252
+		err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times  from xt_double_check  where DATE_SUB(CURDATE(), INTERVAL 1 DAY) = date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ? GROUP BY times", org_id).Scan(&weekStatistics).Error
253
+
254
+		break
255
+	case 7: //透析上机
256
+		err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times  from xt_dialysis_order  where DATE_SUB(CURDATE(), INTERVAL 1 DAY) = date(from_unixtime(created_time))  AND status = 1  AND user_org_id = ? AND (stage = 2 OR stage = 1)  GROUP BY times", org_id).Scan(&weekStatistics).Error
257
+		break
258
+
259
+	case 8: //透析监测
260
+		err = readDb.Raw("select count(distinct patient_id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times  from xt_monitoring_record  where DATE_SUB(CURDATE(), INTERVAL 1 DAY) = date(from_unixtime(created_time)) AND status = 1 AND user_org_id = ?  GROUP BY times", org_id).Scan(&weekStatistics).Error
261
+		break
262
+	case 9: //透析下机
263
+		err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times  from xt_dialysis_order  where DATE_SUB(CURDATE(), INTERVAL 1 DAY) = date(from_unixtime(created_time)) AND stage = 2 AND status = 1  AND user_org_id = ? GROUP BY times", org_id).Scan(&weekStatistics).Error
264
+
265
+		break
266
+	case 10: //透后评估
267
+		err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(created_time)) ,'%Y-%m-%d') as times  from xt_assessment_after_dislysis  where DATE_SUB(CURDATE(), INTERVAL 1 DAY) = date(from_unixtime(created_time)) AND status = 1  AND user_org_id = ? GROUP BY times", org_id).Scan(&weekStatistics).Error
268
+		break
269
+	case 11: //入库单
270
+		err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m-%d') as times  from xt_warehouse  where DATE_SUB(CURDATE(), INTERVAL 1 DAY) = date(from_unixtime(ctime)) AND status = 1 AND org_id = ?  GROUP BY times", org_id).Scan(&weekStatistics).Error
271
+		break
272
+	case 12: //出库单
273
+		err = readDb.Raw("select count(distinct id) as count, DATE_FORMAT(date(from_unixtime(ctime)) ,'%Y-%m-%d') as times  from xt_warehouse_out  where DATE_SUB(CURDATE(), INTERVAL 1 DAY) = date(from_unixtime(ctime)) AND status = 1 AND org_id = ? GROUP BY times", org_id).Scan(&weekStatistics).Error
274
+		break
275
+	}
276
+
277
+	return
278
+}
279
+
230 280
 //获取近七天的数据
231 281
 func GetWeekOrgDialysisCount(statices_type int64, org_id int64) (weekStatistics []*admin_models.Statistics, err error) {
232 282
 	fmt.Println(statices_type)
@@ -549,8 +599,9 @@ type AdminUserManageViewModel struct {
549 599
 	RoleName    string `gorm:"role_name" json:"role_name"`
550 600
 	UserTitle   int    `gorm:"user_title" json:"user_title"`
551 601
 	Ip          string `gorm:"ip" json:"ip"`
552
-	Ctime       int64  `gorm:"ctime" json:"last_login_time"`
602
+	LastTime    int64  `gorm:"ctime" json:"last_login_time"`
553 603
 	Status      int    `gorm:"status" json:"status"`
604
+	Mobile      string `gorm:"mobile" json:"mobile"`
554 605
 
555 606
 	// LastLoginTimeStr string `gorm:"-" json:"last_login_time_formatted"`
556 607
 	TitleName string `gorm:"-" json:"title_name"`
@@ -564,7 +615,7 @@ func GetAdminUsersAndLoginInfo(orgID int64, appID int64, page int64, count int64
564 615
 		page = 1
565 616
 	}
566 617
 	var viewModels []*AdminUserManageViewModel = make([]*AdminUserManageViewModel, 0)
567
-	rows, err := readUserDb.Raw("SELECT u_a_r.admin_user_id, u_a_r.user_name, u_r.role_name, u_a_r.user_title, u_l.ip, u_l.ctime, u_a_r.status FROM sgj_user_admin_role AS u_a_r INNER JOIN sgj_user_role AS u_r ON u_a_r.org_id = u_r.org_id AND u_a_r.app_id = u_r.app_id AND u_r.id = u_a_r.role_id LEFT JOIN (SELECT * FROM (SELECT admin_user_id, org_id, app_id, ip, ctime FROM sgj_user_admin_login_log WHERE org_id = ? AND app_id = ? ORDER BY ctime DESC) AS t GROUP BY admin_user_id) AS u_l ON u_a_r.org_id = u_l.org_id AND u_a_r.app_id = u_l.app_id AND u_a_r.admin_user_id = u_l.admin_user_id WHERE u_a_r.org_id = ? AND u_a_r.app_id = ? GROUP BY u_a_r.admin_user_id LIMIT ? OFFSET ?;", orgID, appID, orgID, appID, count, (page-1)*count).Rows()
618
+	rows, err := readUserDb.Raw("SELECT u_a_r.admin_user_id, u_a_r.user_name, u_r.role_name, u_a_r.user_title, u_l.ip, u_l.last_time, u_a_r.status, admin.mobile FROM sgj_user_admin_role AS u_a_r JOIN sgj_user_admin AS admin ON admin.id = u_a_r.admin_user_id  INNER JOIN sgj_user_role AS u_r ON u_a_r.org_id = u_r.org_id AND u_a_r.app_id = u_r.app_id AND u_r.id = u_a_r.role_id LEFT JOIN (SELECT * FROM (SELECT admin_user_id, org_id, app_id, ip, MAX(ctime) as last_time FROM sgj_user_admin_login_log WHERE org_id = ? AND app_id = ? GROUP BY admin_user_id ORDER BY ctime DESC) AS t GROUP BY admin_user_id) AS u_l ON u_a_r.org_id = u_l.org_id AND u_a_r.app_id = u_l.app_id AND u_a_r.admin_user_id = u_l.admin_user_id WHERE u_a_r.org_id = ? AND u_a_r.app_id = ? GROUP BY u_a_r.admin_user_id LIMIT ? OFFSET ?;", orgID, appID, orgID, appID, count, (page-1)*count).Rows()
568 619
 	defer rows.Close()
569 620
 	if err != nil {
570 621
 		if err == gorm.ErrRecordNotFound {