Browse Source

功能查询

xiaoming_global 5 years ago
parent
commit
270d728154

+ 136 - 10
.idea/workspace.xml View File

3
   <component name="ChangeListManager">
3
   <component name="ChangeListManager">
4
     <list default="true" id="7aa7cc45-aece-4fa3-9063-5e3df12471b4" name="Default" comment="">
4
     <list default="true" id="7aa7cc45-aece-4fa3-9063-5e3df12471b4" name="Default" comment="">
5
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
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
     </list>
17
     </list>
7
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
18
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
8
     <option name="TRACKING_ENABLED" value="true" />
19
     <option name="TRACKING_ENABLED" value="true" />
16
       <file leaf-file-name="function_api_router_register.go" pinned="false" current-in-tab="false">
27
       <file leaf-file-name="function_api_router_register.go" pinned="false" current-in-tab="false">
17
         <entry file="file://$PROJECT_DIR$/controllers/function_api_controllers/function_api_router_register.go">
28
         <entry file="file://$PROJECT_DIR$/controllers/function_api_controllers/function_api_router_register.go">
18
           <provider selected="true" editor-type-id="text-editor">
29
           <provider selected="true" editor-type-id="text-editor">
30
+<<<<<<< .mine
19
             <state relative-caret-position="1848">
31
             <state relative-caret-position="1848">
32
+=======
33
+            <state relative-caret-position="47">
34
+>>>>>>> .theirs
20
               <caret line="87" column="79" selection-start-line="87" selection-start-column="54" selection-end-line="87" selection-end-column="79" />
35
               <caret line="87" column="79" selection-start-line="87" selection-start-column="54" selection-end-line="87" selection-end-column="79" />
21
               <folding>
36
               <folding>
22
                 <element signature="e#34#79#0" expanded="true" />
37
                 <element signature="e#34#79#0" expanded="true" />
37
       <file leaf-file-name="function_service.go" pinned="false" current-in-tab="true">
52
       <file leaf-file-name="function_service.go" pinned="false" current-in-tab="true">
38
         <entry file="file://$PROJECT_DIR$/service/function_service.go">
53
         <entry file="file://$PROJECT_DIR$/service/function_service.go">
39
           <provider selected="true" editor-type-id="text-editor">
54
           <provider selected="true" editor-type-id="text-editor">
55
+<<<<<<< .mine
40
             <state relative-caret-position="175">
56
             <state relative-caret-position="175">
41
               <caret line="65" column="138" selection-start-line="65" selection-start-column="122" selection-end-line="65" selection-end-column="138" />
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
               <folding>
62
               <folding>
43
                 <element signature="e#17#73#0" expanded="true" />
63
                 <element signature="e#17#73#0" expanded="true" />
44
               </folding>
64
               </folding>
46
           </provider>
66
           </provider>
47
         </entry>
67
         </entry>
48
       </file>
68
       </file>
69
+<<<<<<< .mine
49
       <file leaf-file-name="admin_api_router_register.go" pinned="false" current-in-tab="false">
70
       <file leaf-file-name="admin_api_router_register.go" pinned="false" current-in-tab="false">
50
         <entry file="file://$PROJECT_DIR$/controllers/admin_api_controllers/admin_api_router_register.go">
71
         <entry file="file://$PROJECT_DIR$/controllers/admin_api_controllers/admin_api_router_register.go">
51
           <provider selected="true" editor-type-id="text-editor">
72
           <provider selected="true" editor-type-id="text-editor">
73
           </provider>
94
           </provider>
74
         </entry>
95
         </entry>
75
       </file>
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
       <file leaf-file-name="fuction_query_models.go" pinned="false" current-in-tab="false">
126
       <file leaf-file-name="fuction_query_models.go" pinned="false" current-in-tab="false">
77
         <entry file="file://$PROJECT_DIR$/models/function_models/fuction_query_models.go">
127
         <entry file="file://$PROJECT_DIR$/models/function_models/fuction_query_models.go">
78
           <provider selected="true" editor-type-id="text-editor">
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
             </state>
131
             </state>
82
           </provider>
132
           </provider>
83
         </entry>
133
         </entry>
85
       <file leaf-file-name="function_api_base_controller.go" pinned="false" current-in-tab="false">
135
       <file leaf-file-name="function_api_base_controller.go" pinned="false" current-in-tab="false">
86
         <entry file="file://$PROJECT_DIR$/controllers/function_api_controllers/function_api_base_controller.go">
136
         <entry file="file://$PROJECT_DIR$/controllers/function_api_controllers/function_api_base_controller.go">
87
           <provider selected="true" editor-type-id="text-editor">
137
           <provider selected="true" editor-type-id="text-editor">
88
-            <state relative-caret-position="79068">
138
+            <state relative-caret-position="319">
89
               <caret line="3601" column="90" selection-start-line="3601" selection-start-column="90" selection-end-line="3601" selection-end-column="90" />
139
               <caret line="3601" column="90" selection-start-line="3601" selection-start-column="90" selection-end-line="3601" selection-end-column="90" />
90
             </state>
140
             </state>
91
           </provider>
141
           </provider>
120
   </component>
170
   </component>
121
   <component name="FindInProjectRecents">
171
   <component name="FindInProjectRecents">
122
     <findStrings>
172
     <findStrings>
173
+      <find>SchedualPatient</find>
174
+      <find>patient_count_list</find>
175
+      <find>aaa</find>
176
+      <find>newPatientStatistics</find>
123
       <find>/api/dialysis/start_record</find>
177
       <find>/api/dialysis/start_record</find>
124
       <find>GetMonthReceiveinfo</find>
178
       <find>GetMonthReceiveinfo</find>
125
       <find>GetTodayDialysisMachinek</find>
179
       <find>GetTodayDialysisMachinek</find>
146
       <find>GetYesterdayEntrylist</find>
200
       <find>GetYesterdayEntrylist</find>
147
       <find>GetYesterdayExitlist</find>
201
       <find>GetYesterdayExitlist</find>
148
       <find>/api/function/getyestrdayexitlist</find>
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
     </findStrings>
203
     </findStrings>
154
     <dirStrings>
204
     <dirStrings>
155
       <dir>D:\goyard\src\XT_Admin_Api\controllers\admin_api_controllers</dir>
205
       <dir>D:\goyard\src\XT_Admin_Api\controllers\admin_api_controllers</dir>
234
     <property name="DefaultGoTemplateProperty" value="Go Application" />
284
     <property name="DefaultGoTemplateProperty" value="Go Application" />
235
     <property name="go.gopath.indexing.explicitly.defined" value="true" />
285
     <property name="go.gopath.indexing.explicitly.defined" value="true" />
236
     <property name="go.sdk.automatically.set" value="true" />
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
   </component>
288
   </component>
239
   <component name="RunDashboard">
289
   <component name="RunDashboard">
240
     <option name="ruleStates">
290
     <option name="ruleStates">
251
   <component name="ToolWindowManager">
301
   <component name="ToolWindowManager">
252
     <frame x="-7" y="-7" width="1550" height="838" extended-state="6" />
302
     <frame x="-7" y="-7" width="1550" height="838" extended-state="6" />
253
     <layout>
303
     <layout>
304
+<<<<<<< .mine
254
       <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.22050938" />
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
       <window_info anchor="bottom" id="TODO" order="6" />
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
       <window_info anchor="right" id="Database" order="3" />
311
       <window_info anchor="right" id="Database" order="3" />
258
       <window_info anchor="bottom" id="Database Changes" order="8" show_stripe_button="false" />
312
       <window_info anchor="bottom" id="Database Changes" order="8" show_stripe_button="false" />
259
       <window_info anchor="bottom" id="Version Control" order="9" />
313
       <window_info anchor="bottom" id="Version Control" order="9" />
260
       <window_info anchor="bottom" id="Run" order="2" />
314
       <window_info anchor="bottom" id="Run" order="2" />
261
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
315
       <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
316
+<<<<<<< .mine
262
       <window_info active="true" anchor="bottom" id="Terminal" order="10" sideWeight="0.88538873" visible="true" weight="0.0014265336" />
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
       <window_info id="Favorites" order="2" side_tool="true" />
321
       <window_info id="Favorites" order="2" side_tool="true" />
264
       <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
322
       <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
265
       <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
323
       <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
283
     </breakpoint-manager>
341
     </breakpoint-manager>
284
   </component>
342
   </component>
285
   <component name="editorHistoryManager">
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
     <entry file="file://$PROJECT_DIR$/controllers/function_api_controllers/function_api_router_register.go">
358
     <entry file="file://$PROJECT_DIR$/controllers/function_api_controllers/function_api_router_register.go">
287
       <provider selected="true" editor-type-id="text-editor">
359
       <provider selected="true" editor-type-id="text-editor">
288
         <state relative-caret-position="1650">
360
         <state relative-caret-position="1650">
516
         </state>
588
         </state>
517
       </provider>
589
       </provider>
518
     </entry>
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
     <entry file="file://$PROJECT_DIR$/controllers/admin_api_controllers/login_api_controller.go">
598
     <entry file="file://$PROJECT_DIR$/controllers/admin_api_controllers/login_api_controller.go">
520
       <provider selected="true" editor-type-id="text-editor">
599
       <provider selected="true" editor-type-id="text-editor">
521
         <state relative-caret-position="110">
600
         <state relative-caret-position="110">
586
         </state>
665
         </state>
587
       </provider>
666
       </provider>
588
     </entry>
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
     <entry file="file://$PROJECT_DIR$/service/admin_service.go">
675
     <entry file="file://$PROJECT_DIR$/service/admin_service.go">
590
       <provider selected="true" editor-type-id="text-editor">
676
       <provider selected="true" editor-type-id="text-editor">
591
         <state relative-caret-position="572">
677
         <state relative-caret-position="572">
602
     </entry>
688
     </entry>
603
     <entry file="file://$PROJECT_DIR$/controllers/function_api_controllers/function_api_base_controller.go">
689
     <entry file="file://$PROJECT_DIR$/controllers/function_api_controllers/function_api_base_controller.go">
604
       <provider selected="true" editor-type-id="text-editor">
690
       <provider selected="true" editor-type-id="text-editor">
605
-        <state relative-caret-position="79068">
691
+        <state relative-caret-position="319">
606
           <caret line="3601" column="90" selection-start-line="3601" selection-start-column="90" selection-end-line="3601" selection-end-column="90" />
692
           <caret line="3601" column="90" selection-start-line="3601" selection-start-column="90" selection-end-line="3601" selection-end-column="90" />
607
         </state>
693
         </state>
608
       </provider>
694
       </provider>
609
     </entry>
695
     </entry>
696
+<<<<<<< .mine
610
     <entry file="file://$PROJECT_DIR$/models/function_models/fuction_query_models.go">
697
     <entry file="file://$PROJECT_DIR$/models/function_models/fuction_query_models.go">
611
       <provider selected="true" editor-type-id="text-editor">
698
       <provider selected="true" editor-type-id="text-editor">
612
         <state relative-caret-position="11264">
699
         <state relative-caret-position="11264">
635
         </state>
722
         </state>
636
       </provider>
723
       </provider>
637
     </entry>
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
     <entry file="file://$PROJECT_DIR$/controllers/function_api_controllers/function_api_router_register.go">
755
     <entry file="file://$PROJECT_DIR$/controllers/function_api_controllers/function_api_router_register.go">
639
       <provider selected="true" editor-type-id="text-editor">
756
       <provider selected="true" editor-type-id="text-editor">
757
+<<<<<<< .mine
640
         <state relative-caret-position="1848">
758
         <state relative-caret-position="1848">
759
+=======
760
+        <state relative-caret-position="47">
761
+>>>>>>> .theirs
641
           <caret line="87" column="79" selection-start-line="87" selection-start-column="54" selection-end-line="87" selection-end-column="79" />
762
           <caret line="87" column="79" selection-start-line="87" selection-start-column="54" selection-end-line="87" selection-end-column="79" />
642
           <folding>
763
           <folding>
643
             <element signature="e#34#79#0" expanded="true" />
764
             <element signature="e#34#79#0" expanded="true" />
647
     </entry>
768
     </entry>
648
     <entry file="file://$PROJECT_DIR$/service/function_service.go">
769
     <entry file="file://$PROJECT_DIR$/service/function_service.go">
649
       <provider selected="true" editor-type-id="text-editor">
770
       <provider selected="true" editor-type-id="text-editor">
771
+<<<<<<< .mine
650
         <state relative-caret-position="175">
772
         <state relative-caret-position="175">
651
           <caret line="65" column="138" selection-start-line="65" selection-start-column="122" selection-end-line="65" selection-end-column="138" />
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
           <folding>
778
           <folding>
653
             <element signature="e#17#73#0" expanded="true" />
779
             <element signature="e#17#73#0" expanded="true" />
654
           </folding>
780
           </folding>

BIN
XT_Admin_Api.exe View File


+ 3 - 0
controllers/admin_api_controllers/admin_api_router_register.go View File

42
 	beego.Router("/admin/api/user/get", &SystemApiController{}, "get:GetAdminUserById")
42
 	beego.Router("/admin/api/user/get", &SystemApiController{}, "get:GetAdminUserById")
43
 	beego.Router("/admin/api/follow/cancel", &SystemApiController{}, "post:CancelFollowInfo")
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 View File

6
 	"XT_Admin_Api/service"
6
 	"XT_Admin_Api/service"
7
 	"XT_Admin_Api/utils"
7
 	"XT_Admin_Api/utils"
8
 	"time"
8
 	"time"
9
-	"fmt"
10
 )
9
 )
11
 
10
 
12
 type AnalysisAPIController struct {
11
 type AnalysisAPIController struct {
469
 
468
 
470
 func (this *AnalysisAPIController) HomeStatistics() {
469
 func (this *AnalysisAPIController) HomeStatistics() {
471
 	range_data := this.GetString("range_data")
470
 	range_data := this.GetString("range_data")
472
-	fmt.Println("range_data是什么",range_data)
473
 	range_type, _ := this.GetInt64("range_type")
471
 	range_type, _ := this.GetInt64("range_type")
474
-    fmt.Println("range_type是设么",range_type)
475
 	var rangeDate *time.Time
472
 	var rangeDate *time.Time
476
 	var parseDateErr error
473
 	var parseDateErr error
477
 	var rangeTimeStamp int64
474
 	var rangeTimeStamp int64
498
 	activeAdminCount, _ := service.GetActiveAdminUserCount(rangeTimeStamp, now)
495
 	activeAdminCount, _ := service.GetActiveAdminUserCount(rangeTimeStamp, now)
499
 	adminTotalCount, _ := service.GetAdminUserTotalCount()
496
 	adminTotalCount, _ := service.GetAdminUserTotalCount()
500
 
497
 
501
-	patientCount, _ :=service.GetNewPatientCount(rangeTimeStamp, now)
502
-	fmt.Println("patientCout",patientCount)
498
+	patientCount, _ := service.GetNewPatientCount(rangeTimeStamp, now)
503
 	patientTotalCount, _ := service.GetPatientTotalCount()
499
 	patientTotalCount, _ := service.GetPatientTotalCount()
504
 
500
 
505
 	var orgRegisterStatistics []*admin_models.Statistics
501
 	var orgRegisterStatistics []*admin_models.Statistics
508
 	var orgActiveStatistics []*admin_models.Statistics
504
 	var orgActiveStatistics []*admin_models.Statistics
509
 
505
 
510
 	switch range_type {
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
 	case 3:
518
 	case 3:
512
 		orgRegisterStatistics, _ = service.GetWeekRegistedOrgCount()
519
 		orgRegisterStatistics, _ = service.GetWeekRegistedOrgCount()
513
 		newPatientStatistics, _ = service.GetWeekNewPatientCount()
520
 		newPatientStatistics, _ = service.GetWeekNewPatientCount()
514
 		orgActiveAdminStatistics, _ = service.GetWeekActiveAdminUserCount()
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
 		break
524
 		break
525
 	case 4:
525
 	case 4:
526
 		orgRegisterStatistics, _ = service.GetMonthRegistedOrgCount()
526
 		orgRegisterStatistics, _ = service.GetMonthRegistedOrgCount()
527
 		newPatientStatistics, _ = service.GetMonthNewPatientCount()
527
 		newPatientStatistics, _ = service.GetMonthNewPatientCount()
528
 		orgActiveAdminStatistics, _ = service.GetMonthActiveAdminUserCount()
528
 		orgActiveAdminStatistics, _ = service.GetMonthActiveAdminUserCount()
529
-		orgActiveStatistics,_ = service.GetMonthActiveOrgCount()
529
+		orgActiveStatistics, _ = service.GetMonthActiveOrgCount()
530
 
530
 
531
 		break
531
 		break
532
 	case 5:
532
 	case 5:
533
 		orgRegisterStatistics, _ = service.GetThreeMonthRegistedOrgCount()
533
 		orgRegisterStatistics, _ = service.GetThreeMonthRegistedOrgCount()
534
 		newPatientStatistics, _ = service.GetThreeMonthNewPatientCount()
534
 		newPatientStatistics, _ = service.GetThreeMonthNewPatientCount()
535
 		orgActiveAdminStatistics, _ = service.GetThreeMonthActiveAdminUserCount()
535
 		orgActiveAdminStatistics, _ = service.GetThreeMonthActiveAdminUserCount()
536
-		orgActiveStatistics,_ = service.GetThreeMonthActiveOrgCount()
536
+		orgActiveStatistics, _ = service.GetThreeMonthActiveOrgCount()
537
 
537
 
538
 		break
538
 		break
539
 	case 6:
539
 	case 6:
540
 		orgRegisterStatistics, _ = service.GetSixMonthRegistedOrgCount()
540
 		orgRegisterStatistics, _ = service.GetSixMonthRegistedOrgCount()
541
 		newPatientStatistics, _ = service.GetSixMonthNewPatientCount()
541
 		newPatientStatistics, _ = service.GetSixMonthNewPatientCount()
542
 		orgActiveAdminStatistics, _ = service.GetSixMonthActiveAdminUserCount()
542
 		orgActiveAdminStatistics, _ = service.GetSixMonthActiveAdminUserCount()
543
-		orgActiveStatistics,_ = service.GetSixMonthActiveOrgCount()
543
+		orgActiveStatistics, _ = service.GetSixMonthActiveOrgCount()
544
 
544
 
545
 		break
545
 		break
546
 	case 7:
546
 	case 7:
547
 		orgRegisterStatistics, _ = service.GetYearRegistedOrgCount()
547
 		orgRegisterStatistics, _ = service.GetYearRegistedOrgCount()
548
 		newPatientStatistics, _ = service.GetYearNewPatientCount()
548
 		newPatientStatistics, _ = service.GetYearNewPatientCount()
549
 		orgActiveAdminStatistics, _ = service.GetYearActiveAdminUserCount()
549
 		orgActiveAdminStatistics, _ = service.GetYearActiveAdminUserCount()
550
-		orgActiveStatistics,_ = service.GetYearActiveOrgCount()
551
-
550
+		orgActiveStatistics, _ = service.GetYearActiveOrgCount()
552
 		break
551
 		break
553
 	}
552
 	}
554
 
553
 
555
 	this.ServeSuccessJSON(map[string]interface{}{
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
 		"active_admin_total_count": adminTotalCount,
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 View File

29
 		page = 1
29
 		page = 1
30
 	}
30
 	}
31
 	if limit <= 0 {
31
 	if limit <= 0 {
32
-		limit = 7
32
+		limit = 10
33
 	}
33
 	}
34
 
34
 
35
 	timeLayout := "2006-01-02"
35
 	timeLayout := "2006-01-02"
124
 		}
124
 		}
125
 		break
125
 		break
126
 	case 2: //昨天
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
 		if err != nil {
129
 		if err != nil {
140
 			this.ErrorLog("错误:%v", err)
130
 			this.ErrorLog("错误:%v", err)
141
 			return
131
 			return
142
-
143
 		} else {
132
 		} else {
144
 			this.ServeSuccessJSON(map[string]interface{}{
133
 			this.ServeSuccessJSON(map[string]interface{}{
145
-				"count": count,
134
+				"list": orgDialysisOrderStatistics,
146
 			})
135
 			})
147
 		}
136
 		}
148
 		break
137
 		break

+ 59 - 7
controllers/admin_api_controllers/system_api_controller.go View File

72
 		Mtime:        time.Now().Unix(),
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
 			}
346
 			}
344
 		}
347
 		}
345
 	}
348
 	}
346
-
347
-	fmt.Println(orgFollow)
348
-
349
 	//防止数据冗余,先查出之前被删的数据是否存在,存在则直接改变删除状态,不插入新数据
349
 	//防止数据冗余,先查出之前被删的数据是否存在,存在则直接改变删除状态,不插入新数据
350
 	for index, follow := range orgFollow {
350
 	for index, follow := range orgFollow {
351
 		info, err := service.FindFollowRecordByID(follow)
351
 		info, err := service.FindFollowRecordByID(follow)
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 View File

29
 	ContactName       string            `gorm:"column:contact_name" json:"contact_name"`
29
 	ContactName       string            `gorm:"column:contact_name" json:"contact_name"`
30
 	OrgGallery        []*OrgGallery     `gorm:"ForeignKey:OrgId" json:"org_gallery"`
30
 	OrgGallery        []*OrgGallery     `gorm:"ForeignKey:OrgId" json:"org_gallery"`
31
 	AdminUserLoginLog AdminUserLoginLog `gorm:"ForeignKey:OrgId" json:"log"`
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
 	OrgFollow         []*OrgFollow      `gorm:"ForeignKey:OrgId" json:"follow"`
33
 	OrgFollow         []*OrgFollow      `gorm:"ForeignKey:OrgId" json:"follow"`
34
 }
34
 }
35
 
35
 

+ 1 - 1
routers/router.go View File

10
 func init() {
10
 func init() {
11
 	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
11
 	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
12
 		// AllowAllOrigins:  true,
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
 		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
14
 		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
15
 		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
15
 		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
16
 		ExposeHeaders:    []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
16
 		ExposeHeaders:    []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},

+ 111 - 143
service/admin_service.go View File

5
 import (
5
 import (
6
 	"XT_Admin_Api/models"
6
 	"XT_Admin_Api/models"
7
 	"XT_Admin_Api/models/admin_models"
7
 	"XT_Admin_Api/models/admin_models"
8
+	"database/sql"
8
 	"fmt"
9
 	"fmt"
9
 	"strings"
10
 	"strings"
10
 	"time"
11
 	"time"
27
 // 获取总机构数
28
 // 获取总机构数
28
 func GetTotalOrgCount() (int, error) {
29
 func GetTotalOrgCount() (int, error) {
29
 	var count int
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
 	if err != nil {
32
 	if err != nil {
32
 		return 0, err
33
 		return 0, err
33
 	}
34
 	}
412
 func GetRegistedOrgCount(from int64, to int64) (int64, error) {
413
 func GetRegistedOrgCount(from int64, to int64) (int64, error) {
413
 
414
 
414
 	var count int64
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
 	if err != nil {
417
 	if err != nil {
417
 		return 0, err
418
 		return 0, err
418
 	}
419
 	}
422
 // 获取一段时间内的活跃机构数
423
 // 获取一段时间内的活跃机构数
423
 func GetActiveOrgCount(from int64, to int64) (int64, error) {
424
 func GetActiveOrgCount(from int64, to int64) (int64, error) {
424
 	var count int64
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
 	if err != nil {
427
 	if err != nil {
427
 		return 0, err
428
 		return 0, err
428
 	}
429
 	}
435
 // 获取所有活跃机构数
436
 // 获取所有活跃机构数
436
 func GetActiveOrgTotalCount() (int64, error) {
437
 func GetActiveOrgTotalCount() (int64, error) {
437
 	var count int64
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
 	if err != nil {
440
 	if err != nil {
440
 		return 0, err
441
 		return 0, err
441
 	}
442
 	}
445
 	return count, nil
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
 func GetWeekRegistedOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
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
 	return
477
 	return
452
 }
478
 }
453
 
479
 
458
 
484
 
459
 //获取近七天每天的机构活跃总量
485
 //获取近七天每天的机构活跃总量
460
 func GetWeekActiveOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
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
 	err = db.Scan(&weekStatistics).Error
488
 	err = db.Scan(&weekStatistics).Error
463
 	return
489
 	return
464
 }
490
 }
475
 	return
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
 //获取近30天每天的注册机构总量
504
 //获取近30天每天的注册机构总量
505
 func GetMonthRegistedOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
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
 	return
507
 	return
508
 }
508
 }
509
 
509
 
510
 //获取近30天每天的机构活跃总量
510
 //获取近30天每天的机构活跃总量
511
 func GetMonthActiveOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
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
 	return
513
 	return
514
 }
514
 }
515
 
515
 
525
 	return
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
 //获取近3个月每个月的注册机构总量
528
 //获取近3个月每个月的注册机构总量
553
 func GetThreeMonthRegistedOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
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
 	return
531
 	return
556
 }
532
 }
557
 
533
 
563
 
539
 
564
 //获取近3个月每个月的机构活跃总量
540
 //获取近3个月每个月的机构活跃总量
565
 func GetThreeMonthActiveOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
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
 	return
543
 	return
568
 }
544
 }
569
 
545
 
573
 	return
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
 func GetSixMonthRegistedOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
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
 	return
555
 	return
607
 }
556
 }
608
 
557
 
614
 
563
 
615
 //获取近半年每个月的机构活跃总量
564
 //获取近半年每个月的机构活跃总量
616
 func GetSixMonthActiveOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
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
 	return
567
 	return
619
 }
568
 }
620
 
569
 
624
 	return
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
 //获取近1年每个月的注册机构总量
576
 //获取近1年每个月的注册机构总量
654
 func GetYearRegistedOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
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
 	return
579
 	return
657
 }
580
 }
658
 
581
 
664
 
587
 
665
 //获取近1年每个月的机构活跃总量
588
 //获取近1年每个月的机构活跃总量
666
 func GetYearActiveOrgCount() (weekStatistics []*admin_models.Statistics, err error) {
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
 	return
591
 	return
669
 }
592
 }
670
 
593
 
674
 	return
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
 func GetAllAdmin() (admin []*admin_models.AdminAccount, err error) {
600
 func GetAllAdmin() (admin []*admin_models.AdminAccount, err error) {
704
 	err = readUserDb.Model(&admin_models.AdminAccount{}).Where("is_super_admin <> 1 AND (status = 1 OR status = 2)").Find(&admin).Error
601
 	err = readUserDb.Model(&admin_models.AdminAccount{}).Where("is_super_admin <> 1 AND (status = 1 OR status = 2)").Find(&admin).Error
705
 	return
602
 	return
810
 	err = readUserDb.Model(&models.OrgFollow{}).Where("org_id = ? AND status = 1 AND admin_user_id = ?", org_id, admin_user_id).First(&info).Error
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
 	return
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 View File

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
 	offset := (page - 1) * limit
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
 	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()
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
 	if rows.Next() {
14
 	if rows.Next() {
16
 		rows.Scan(&total)
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
 	offset := (page - 1) * limit
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
 	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()
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
 	if rows.Next() {
27
 	if rows.Next() {
29
 		rows.Scan(&total)
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
 	offset := (page - 1) * limit
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
 	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()
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
 	if rows.Next() {
40
 	if rows.Next() {
43
 		rows.Scan(&total)
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
 	offset := (page - 1) * limit
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
 	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()
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
 	if rows.Next() {
52
 	if rows.Next() {
54
 		rows.Scan(&total)
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
 	offset := (page - 1) * limit
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
 	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()
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
 	if rows.Next() {
65
 	if rows.Next() {
68
 		rows.Scan(&total)
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
 	offset := (page - 1) * limit
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
 	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()
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
 	if rows.Next() {
78
 	if rows.Next() {
80
 		rows.Scan(&total)
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
 	offset := (page - 1) * limit
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
 	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()
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
 	if rows.Next() {
91
 	if rows.Next() {
92
 		rows.Scan(&total)
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
 	offset := (page - 1) * limit
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
 	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()
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
 	if rows.Next() {
104
 	if rows.Next() {
105
 		rows.Scan(&total)
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
 	offset := (page - 1) * limit
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
 	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()
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
 	if rows.Next() {
117
 	if rows.Next() {
118
 		rows.Scan(&total)
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
 	offset := (page - 1) * limit
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
 	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()
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
 	if rows.Next() {
129
 	if rows.Next() {
130
 		rows.Scan(&total)
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
 	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()
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
 	if rows.Next() {
140
 	if rows.Next() {
141
 		rows.Scan(&total)
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
 	offset := (page - 1) * limit
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
 	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()
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
 	if rows.Next() {
151
 	if rows.Next() {
152
 		rows.Scan(&total)
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 View File

40
 		case 1:
40
 		case 1:
41
 			now := time.Now()
41
 			now := time.Now()
42
 			zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
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
 			break
45
 			break
47
 		case 2:
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
 			break
49
 			break
52
 		case 3:
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
 			break
53
 			break
57
 		case 4:
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
 			break
56
 			break
62
 		}
57
 		}
58
+
63
 		if province > 0 {
59
 		if province > 0 {
64
 			db = db.Where("sgj_user_org.province = ?", province)
60
 			db = db.Where("sgj_user_org.province = ?", province)
65
 		}
61
 		}
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
 		return db.Model(&models.OrgFollow{}).Where("status = 1").Preload("AdminAccount", "status = 1")
84
 		return db.Model(&models.OrgFollow{}).Where("status = 1").Preload("AdminAccount", "status = 1")
89
 	}).Preload("AdminUserLoginLog", func(db *gorm.DB) *gorm.DB {
85
 	}).Preload("AdminUserLoginLog", func(db *gorm.DB) *gorm.DB {
90
 		return db.Model(&models.AdminUserLoginLog{}).Where("id = (SELECT max(id))")
86
 		return db.Model(&models.AdminUserLoginLog{}).Where("id = (SELECT max(id))")
93
 }
89
 }
94
 
90
 
95
 func GetOrgDetailInfo(org_id int64) (info models.Org, err error) {
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
 		return db.Model(&models.AdminUserLoginLog{}).Where("id = (SELECT max(id))")
93
 		return db.Model(&models.AdminUserLoginLog{}).Where("id = (SELECT max(id))")
98
 	}).Preload("AdminUser", "status = 1").Find(&info).Error
94
 	}).Preload("AdminUser", "status = 1").Find(&info).Error
99
 	return
95
 	return
109
 	return
105
 	return
110
 }
106
 }
111
 
107
 
112
-//设置今天和昨天的数据
108
+//设置今天
113
 func GetOrgDialysisCount(statices_type int64, org_id int64, from int64, to int64) (count int64, err error) {
109
 func GetOrgDialysisCount(statices_type int64, org_id int64, from int64, to int64) (count int64, err error) {
114
 	var counts int64
110
 	var counts int64
115
 
111
 
227
 	return counts, nil
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
 func GetWeekOrgDialysisCount(statices_type int64, org_id int64) (weekStatistics []*admin_models.Statistics, err error) {
281
 func GetWeekOrgDialysisCount(statices_type int64, org_id int64) (weekStatistics []*admin_models.Statistics, err error) {
232
 	fmt.Println(statices_type)
282
 	fmt.Println(statices_type)
549
 	RoleName    string `gorm:"role_name" json:"role_name"`
599
 	RoleName    string `gorm:"role_name" json:"role_name"`
550
 	UserTitle   int    `gorm:"user_title" json:"user_title"`
600
 	UserTitle   int    `gorm:"user_title" json:"user_title"`
551
 	Ip          string `gorm:"ip" json:"ip"`
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
 	Status      int    `gorm:"status" json:"status"`
603
 	Status      int    `gorm:"status" json:"status"`
604
+	Mobile      string `gorm:"mobile" json:"mobile"`
554
 
605
 
555
 	// LastLoginTimeStr string `gorm:"-" json:"last_login_time_formatted"`
606
 	// LastLoginTimeStr string `gorm:"-" json:"last_login_time_formatted"`
556
 	TitleName string `gorm:"-" json:"title_name"`
607
 	TitleName string `gorm:"-" json:"title_name"`
564
 		page = 1
615
 		page = 1
565
 	}
616
 	}
566
 	var viewModels []*AdminUserManageViewModel = make([]*AdminUserManageViewModel, 0)
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
 	defer rows.Close()
619
 	defer rows.Close()
569
 	if err != nil {
620
 	if err != nil {
570
 		if err == gorm.ErrRecordNotFound {
621
 		if err == gorm.ErrRecordNotFound {