Browse Source

体积小

XMLWAN 2 years ago
parent
commit
32ec699c62
85 changed files with 73598 additions and 371 deletions
  1. 29 0
      controllers/admin_api_controllers/admin_api_base_controller.go
  2. 16 0
      controllers/admin_api_controllers/admin_api_router_register.go
  3. 466 0
      controllers/admin_api_controllers/analysis_api_controller.go
  4. 0 9
      controllers/admin_api_controllers/api_router_register.go
  5. 0 11
      controllers/admin_api_controllers/city_data_upload_api_controller.go
  6. 35 0
      controllers/admin_api_controllers/login_api_controller.go
  7. 2223 0
      controllers/advice_template.json
  8. 311 1
      controllers/base_api_controller.go
  9. 11 0
      controllers/base_controller.go
  10. 1786 0
      controllers/data_api_controller.go
  11. 15 0
      controllers/default.go
  12. 1256 0
      controllers/device_api_controller.go
  13. 3563 0
      controllers/dialysis_api_controller.go
  14. 58 0
      controllers/dialysis_board_api_controller.go
  15. 437 0
      controllers/dialysis_parameter_api_controller.go
  16. 1366 0
      controllers/dialysis_record_api_controller.go
  17. 25 0
      controllers/district_api_controller.go
  18. 658 0
      controllers/doctor_schedule_api_controller.go
  19. 1111 0
      controllers/doctors_api_controller.go
  20. 3050 0
      controllers/drug_stock_api_contorller.go
  21. 472 0
      controllers/gdyb_controller.go
  22. 2202 0
      controllers/gobal_config_api_controller.go
  23. 5181 0
      controllers/his_api_controller.go
  24. 411 0
      controllers/his_config_api_controller.go
  25. 317 0
      controllers/his_hospital_api_controller.go
  26. 1675 0
      controllers/his_project_api_controller.go
  27. 634 0
      controllers/inspection_api_controller.go
  28. 435 0
      controllers/integration_config_api_controller.go
  29. 164 0
      controllers/invoice_api_controller.go
  30. 4133 0
      controllers/manage_api_controller.go
  31. 2230 0
      controllers/manager_center_api_controller.go
  32. 0 20
      controllers/mobile_api_controller.go
  33. 2141 0
      controllers/new_mobile_api_controllers/common_api_controller.go
  34. 62 0
      controllers/new_mobile_api_controllers/common_api_router.go
  35. 258 0
      controllers/new_mobile_api_controllers/dialysis_parameter_api_controller.go
  36. 15 0
      controllers/new_mobile_api_controllers/dialysis_parameter_api_router.go
  37. 7 0
      controllers/new_mobile_api_controllers/dialysis_process_api_controller.go
  38. 260 0
      controllers/new_mobile_api_controllers/forget_password_controller.go
  39. 197 0
      controllers/new_mobile_api_controllers/good_types.json
  40. 806 0
      controllers/new_mobile_api_controllers/home_api_controller.go
  41. 925 0
      controllers/new_mobile_api_controllers/index_evaluation_api_controller.go
  42. 139 0
      controllers/new_mobile_api_controllers/management_analyse_api_controller.go
  43. 1084 0
      controllers/new_mobile_api_controllers/mobile_his_api_controller.go
  44. 1280 0
      controllers/new_mobile_api_controllers/mobile_regist_controller.go
  45. 2159 0
      controllers/new_mobile_api_controllers/new_common_api_controller.go
  46. 48 0
      controllers/new_mobile_api_controllers/new_common_api_router.go
  47. 2856 0
      controllers/new_mobile_api_controllers/new_dialysis_api_controller.go
  48. 589 0
      controllers/new_mobile_api_controllers/new_login_api_controller.go
  49. 241 0
      controllers/new_mobile_api_controllers/new_manage_api_controller.go
  50. 11 0
      controllers/new_mobile_api_controllers/new_manage_api_router.go
  51. 13 0
      controllers/new_mobile_api_controllers/new_mobile_api_base_controller.go
  52. 181 0
      controllers/new_mobile_api_controllers/new_mobile_api_router_register.go
  53. 747 0
      controllers/new_mobile_api_controllers/new_role_api_controller.go
  54. 50 0
      controllers/new_mobile_api_controllers/new_self_drug_api_controller.go
  55. 170 0
      controllers/new_mobile_api_controllers/patient.json
  56. 73 0
      controllers/new_mobile_api_controllers/role.json
  57. 86 0
      controllers/new_mobile_api_controllers/schedule_template.json
  58. 354 0
      controllers/new_mobile_api_controllers/staff_schedule_api_controller.go
  59. 23 0
      controllers/new_mobile_api_controllers/staff_schedule_api_router.go
  60. 44 0
      controllers/new_mobile_api_controllers/statistics_api_controllers.go
  61. 57 0
      controllers/new_mobile_api_controllers/system_dialysis_prescription.json
  62. 296 0
      controllers/orginfo_api_controller.go
  63. 4515 0
      controllers/patient_api_controller.go
  64. 371 0
      controllers/patient_dataconfig_api_controller.go
  65. 620 0
      controllers/pay_api_controller.go
  66. 922 0
      controllers/pc_index_evaluation_api_controller.go
  67. 222 0
      controllers/print_data_api_controller.go
  68. 1745 0
      controllers/public_api_controller.go
  69. 864 0
      controllers/qcd_api_controller.go
  70. 36 0
      controllers/qiniiu_api_controller.go
  71. 71 0
      controllers/role.json
  72. 1559 0
      controllers/role_controller.go
  73. 2673 0
      controllers/schedule_api_controller.go
  74. 398 0
      controllers/schedule_template_api_controller.go
  75. 2157 0
      controllers/self_drug_api_congtroller.go
  76. 599 0
      controllers/sign_weigh_api_controller.go
  77. 69 0
      controllers/statistics_api_controller.go
  78. 379 0
      controllers/stock_api_controller.go
  79. 228 0
      controllers/stock_good_api_controller.go
  80. 6137 0
      controllers/stock_in_api_controller.go
  81. 5 0
      controllers/stock_warrhouse_contorller.go
  82. 0 325
      controllers/sync.go
  83. 441 0
      controllers/verify_login_controller.go
  84. BIN
      db/xtdb.docx
  85. 145 5
      enums/error_code.go

+ 29 - 0
controllers/admin_api_controllers/admin_api_base_controller.go View File

@@ -2,6 +2,8 @@ package admin_api_controllers
2 2
 
3 3
 import (
4 4
 	"Xcx_New/controllers"
5
+	"Xcx_New/enums"
6
+	"Xcx_New/models/admin_models"
5 7
 )
6 8
 
7 9
 type AdminBaseAPIController struct {
@@ -27,3 +29,30 @@ func (this *AdminBaseAPIController) DebugLog(format string, a ...interface{}) {
27 29
 func (this *AdminBaseAPIController) TraceLog(format string, a ...interface{}) {
28 30
 	//beego.Trace(fmt.Sprintf("[管理员后台] %v", fmt.Sprintf(format, a...)))
29 31
 }
32
+
33
+func (this *AdminBaseAPIController) GetAdminInfo() *AdminInfo {
34
+	userInfo := this.GetSession("admin_info")
35
+	if userInfo == nil {
36
+		return nil
37
+	} else {
38
+		return userInfo.(*AdminInfo)
39
+	}
40
+}
41
+
42
+type AdminInfo struct {
43
+	Admin *admin_models.AdminAccount
44
+}
45
+
46
+type AdminBaseAPIAuthController struct {
47
+	AdminBaseAPIController
48
+}
49
+
50
+func (this *AdminBaseAPIAuthController) Prepare() {
51
+	this.AdminBaseAPIController.Prepare()
52
+
53
+	adminInfo := this.GetAdminInfo()
54
+	if adminInfo == nil {
55
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
56
+		this.StopRun()
57
+	}
58
+}

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

@@ -0,0 +1,16 @@
1
+package admin_api_controllers
2
+
3
+import "github.com/astaxie/beego"
4
+
5
+// 管理员后台路由,以 /admin/api 为前缀
6
+func AdminAPIControllersRegisterRouters() {
7
+	beego.Router("/admin/api/login/pwd", &LoginAPIController{}, "post:LoginByPwd")
8
+
9
+	beego.Router("/admin/api/org/regist", &AnalysisAPIController{}, "get:RegistOrg")
10
+	beego.Router("/admin/api/org/active", &AnalysisAPIController{}, "get:ActiveOrg")
11
+	beego.Router("/admin/api/user/active", &AnalysisAPIController{}, "get:ActiveUser")
12
+	beego.Router("/admin/api/org/expiring", &AnalysisAPIController{}, "get:ExpiringOrg")
13
+	beego.Router("/admin/api/dialysis/analysis", &AnalysisAPIController{}, "get:DialysisAnalysis")
14
+	beego.Router("/admin/api/monitor/analysis", &AnalysisAPIController{}, "get:MonitorAnalysis")
15
+	beego.Router("/admin/api/patient/analysis", &AnalysisAPIController{}, "get:PatientAnalysis")
16
+}

+ 466 - 0
controllers/admin_api_controllers/analysis_api_controller.go View File

@@ -0,0 +1,466 @@
1
+package admin_api_controllers
2
+
3
+import (
4
+	"Xcx_New/models"
5
+	"Xcx_New/service"
6
+	"Xcx_New/utils"
7
+	"time"
8
+)
9
+
10
+type AnalysisAPIController struct {
11
+	AdminBaseAPIAuthController
12
+	// AdminBaseAPIController
13
+}
14
+
15
+// /admin/api/org/regist [get] RegistOrg
16
+func (this *AnalysisAPIController) RegistOrg() {
17
+	totalOrg, getTotalOrgErr := service.GetTotalOrgCount()
18
+	if getTotalOrgErr != nil {
19
+		this.ErrorLog("获取总机构数失败:%v", getTotalOrgErr)
20
+	}
21
+
22
+	now := time.Now()
23
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
24
+	registOrgCountToday, getRegistOrgCountTodayErr := service.GetRegistedOrgCountFromDayToDay(zeroHourTimeOfToday, now)
25
+	if getRegistOrgCountTodayErr != nil {
26
+		this.ErrorLog("获取今日注册机构数失败:%v", getRegistOrgCountTodayErr)
27
+	}
28
+
29
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
30
+	registOrgCountThisWeek, getRegistOrgCountThisWeekErr := service.GetRegistedOrgCountFromDayToDay(monday, sunday)
31
+	if getRegistOrgCountThisWeekErr != nil {
32
+		this.ErrorLog("获取本周注册机构数失败:%v", getRegistOrgCountThisWeekErr)
33
+	}
34
+
35
+	thisYear := now.Year()
36
+	thisMonth := int(now.Month())
37
+	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
38
+	registOrgCountThisMonth, getRegistOrgCountThisMonthErr := service.GetRegistedOrgCountFromDayToDay(beginningOfMonth, endOfMonth)
39
+	if getRegistOrgCountThisMonthErr != nil {
40
+		this.ErrorLog("获取本月注册机构数失败:%v", getRegistOrgCountThisMonthErr)
41
+	}
42
+
43
+	monthRegistOrgCounts := make([]map[string]interface{}, 0, 12)
44
+	for m := 1; m < 12; m++ {
45
+		if m > thisMonth {
46
+			break
47
+		}
48
+		if m == thisMonth {
49
+			monthRegistOrgCounts = append(monthRegistOrgCounts, map[string]interface{}{
50
+				"month": m,
51
+				"count": registOrgCountThisMonth,
52
+			})
53
+
54
+		} else {
55
+			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
56
+			registOrgCount, getRegistOrgCountErr := service.GetRegistedOrgCountFromDayToDay(BOM, EOM)
57
+			if getRegistOrgCountErr != nil {
58
+				this.ErrorLog("获取%v月注册机构数失败:%v", m, getRegistOrgCountErr)
59
+			}
60
+			monthRegistOrgCounts = append(monthRegistOrgCounts, map[string]interface{}{
61
+				"month": m,
62
+				"count": registOrgCount,
63
+			})
64
+		}
65
+	}
66
+
67
+	registOrgsThisWeek, getRegistOrgThisWeekErr := service.GetRegistedOrgsFromDayToDay(monday, sunday)
68
+	if getRegistOrgThisWeekErr != nil {
69
+		this.ErrorLog("获取本周注册机构失败:%v", getRegistOrgThisWeekErr)
70
+		registOrgsThisWeek = make([]*models.Org, 0)
71
+	}
72
+
73
+	registOrgsThisMonth, getRegistOrgThisMonthErr := service.GetRegistedOrgsFromDayToDay(beginningOfMonth, endOfMonth)
74
+	if getRegistOrgThisMonthErr != nil {
75
+		this.ErrorLog("获取本月注册机构失败:%v", getRegistOrgThisMonthErr)
76
+		registOrgsThisMonth = make([]*models.Org, 0)
77
+	}
78
+
79
+	this.ServeSuccessJSON(map[string]interface{}{
80
+		"total_org_count":         totalOrg,
81
+		"regist_org_count_today":  registOrgCountToday,
82
+		"regist_org_count_week":   registOrgCountThisWeek,
83
+		"regist_org_count_month":  registOrgCountThisMonth,
84
+		"regist_org_count_months": monthRegistOrgCounts,
85
+		"regist_orgs_week":        registOrgsThisWeek,
86
+		"regist_orgs_month":       registOrgsThisMonth,
87
+	})
88
+}
89
+
90
+// /admin/api/org/active [get] ActiveOrg
91
+func (this *AnalysisAPIController) ActiveOrg() {
92
+	now := time.Now()
93
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
94
+	activeOrgCountToday, getActiveTodayErr := service.GetActiveOrgCountFromDayToDay(zeroHourTimeOfToday, now)
95
+	if getActiveTodayErr != nil {
96
+		this.ErrorLog("获取今日活跃机构数失败:%v", getActiveTodayErr)
97
+	}
98
+
99
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
100
+	activeOrgCountThisWeek, getActiveOrgCountThisWeekErr := service.GetActiveOrgCountFromDayToDay(monday, sunday)
101
+	if getActiveOrgCountThisWeekErr != nil {
102
+		this.ErrorLog("获取本周活跃机构数失败:%v", getActiveOrgCountThisWeekErr)
103
+	}
104
+
105
+	thisYear := now.Year()
106
+	thisMonth := int(now.Month())
107
+	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
108
+	activeOrgCountThisMonth, getActiveOrgCountThisMonthErr := service.GetActiveOrgCountFromDayToDay(beginningOfMonth, endOfMonth)
109
+	if getActiveOrgCountThisMonthErr != nil {
110
+		this.ErrorLog("获取本月活跃机构数失败:%v", getActiveOrgCountThisMonthErr)
111
+	}
112
+
113
+	monthActiveOrgCounts := make([]map[string]interface{}, 0, 12)
114
+	for m := 1; m < 12; m++ {
115
+		if m > thisMonth {
116
+			break
117
+		}
118
+		if m == thisMonth {
119
+			monthActiveOrgCounts = append(monthActiveOrgCounts, map[string]interface{}{
120
+				"month": m,
121
+				"count": activeOrgCountThisMonth,
122
+			})
123
+
124
+		} else {
125
+			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
126
+			activeOrgCount, getActiveOrgCountErr := service.GetActiveOrgCountFromDayToDay(BOM, EOM)
127
+			if getActiveOrgCountErr != nil {
128
+				this.ErrorLog("获取%v月活跃机构数失败:%v", m, getActiveOrgCountErr)
129
+			}
130
+			monthActiveOrgCounts = append(monthActiveOrgCounts, map[string]interface{}{
131
+				"month": m,
132
+				"count": activeOrgCount,
133
+			})
134
+		}
135
+	}
136
+
137
+	activeOrgsThisWeek, getActiveOrgThisWeekErr := service.GetActiveOrgsFromDayToDay(monday, sunday)
138
+	if getActiveOrgThisWeekErr != nil {
139
+		this.ErrorLog("获取本周活跃机构失败:%v", getActiveOrgThisWeekErr)
140
+		activeOrgsThisWeek = make([]*service.ActiveOrgListVM, 0)
141
+	}
142
+
143
+	activeOrgsThisMonth, getActiveOrgThisMonthErr := service.GetActiveOrgsFromDayToDay(beginningOfMonth, endOfMonth)
144
+	if getActiveOrgThisMonthErr != nil {
145
+		this.ErrorLog("获取本月活跃机构失败:%v", getActiveOrgThisMonthErr)
146
+		activeOrgsThisMonth = make([]*service.ActiveOrgListVM, 0)
147
+	}
148
+
149
+	this.ServeSuccessJSON(map[string]interface{}{
150
+		"active_org_count_today":  activeOrgCountToday,
151
+		"active_org_count_week":   activeOrgCountThisWeek,
152
+		"active_org_count_month":  activeOrgCountThisMonth,
153
+		"active_org_count_months": monthActiveOrgCounts,
154
+		"active_orgs_week":        activeOrgsThisWeek,
155
+		"active_orgs_month":       activeOrgsThisMonth,
156
+	})
157
+}
158
+
159
+// /admin/api/user/active [get] ActiveUser
160
+func (this *AnalysisAPIController) ActiveUser() {
161
+	now := time.Now()
162
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
163
+	activeAdminCountToday, getActiveTodayErr := service.GetActiveAdminUserCountFromDayToDay(zeroHourTimeOfToday, now)
164
+	if getActiveTodayErr != nil {
165
+		this.ErrorLog("获取今日活跃账户数失败:%v", getActiveTodayErr)
166
+	}
167
+
168
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
169
+	activeAdminCountThisWeek, getActiveAdminCountThisWeekErr := service.GetActiveAdminUserCountFromDayToDay(monday, sunday)
170
+	if getActiveAdminCountThisWeekErr != nil {
171
+		this.ErrorLog("获取本周活跃账户数失败:%v", getActiveAdminCountThisWeekErr)
172
+	}
173
+
174
+	thisYear := now.Year()
175
+	thisMonth := int(now.Month())
176
+	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
177
+	activeAdminCountThisMonth, getActiveAdminCountThisMonthErr := service.GetActiveAdminUserCountFromDayToDay(beginningOfMonth, endOfMonth)
178
+	if getActiveAdminCountThisMonthErr != nil {
179
+		this.ErrorLog("获取本月活跃账户数失败:%v", getActiveAdminCountThisMonthErr)
180
+	}
181
+
182
+	monthActiveAdminCounts := make([]map[string]interface{}, 0, 12)
183
+	for m := 1; m < 12; m++ {
184
+		if m > thisMonth {
185
+			break
186
+		}
187
+		if m == thisMonth {
188
+			monthActiveAdminCounts = append(monthActiveAdminCounts, map[string]interface{}{
189
+				"month": m,
190
+				"count": activeAdminCountThisMonth,
191
+			})
192
+
193
+		} else {
194
+			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
195
+			activeAdminCount, getActiveAdminCountErr := service.GetActiveAdminUserCountFromDayToDay(BOM, EOM)
196
+			if getActiveAdminCountErr != nil {
197
+				this.ErrorLog("获取%v月活跃账户数失败:%v", m, getActiveAdminCountErr)
198
+			}
199
+			monthActiveAdminCounts = append(monthActiveAdminCounts, map[string]interface{}{
200
+				"month": m,
201
+				"count": activeAdminCount,
202
+			})
203
+		}
204
+	}
205
+
206
+	activeAdminsThisWeek, getActiveAdminThisWeekErr := service.GetActiveAdminUsersFromDayToDay(monday, sunday)
207
+	if getActiveAdminThisWeekErr != nil {
208
+		this.ErrorLog("获取本周活跃账户失败:%v", getActiveAdminThisWeekErr)
209
+		activeAdminsThisWeek = make([]*service.ActiveAdminUserListVM, 0)
210
+	}
211
+
212
+	activeAdminsThisMonth, getActiveAdminThisMonthErr := service.GetActiveAdminUsersFromDayToDay(beginningOfMonth, endOfMonth)
213
+	if getActiveAdminThisMonthErr != nil {
214
+		this.ErrorLog("获取本月活跃账户失败:%v", getActiveAdminThisMonthErr)
215
+		activeAdminsThisMonth = make([]*service.ActiveAdminUserListVM, 0)
216
+	}
217
+
218
+	this.ServeSuccessJSON(map[string]interface{}{
219
+		"active_admin_count_today":  activeAdminCountToday,
220
+		"active_admin_count_week":   activeAdminCountThisWeek,
221
+		"active_admin_count_month":  activeAdminCountThisMonth,
222
+		"active_admin_count_months": monthActiveAdminCounts,
223
+		"active_admins_week":        activeAdminsThisWeek,
224
+		"active_admins_month":       activeAdminsThisMonth,
225
+	})
226
+}
227
+
228
+// /admin/api/org/expiring [get] ExpiringOrg
229
+func (this *AnalysisAPIController) ExpiringOrg() {
230
+	now := time.Now()
231
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
232
+	// endTimeOfToday := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 999, time.Local)
233
+	timeAfter15Days := zeroHourTimeOfToday.AddDate(0, 0, 15)
234
+	timeBefore15Days := zeroHourTimeOfToday.AddDate(0, 0, -15)
235
+
236
+	countOfWillExpireOrg, getWillExpireOrgCountErr := service.GetWillExpireOrgCountFromDayToDay(zeroHourTimeOfToday, timeAfter15Days)
237
+	if getWillExpireOrgCountErr != nil {
238
+		this.ErrorLog("获取即将到期机构数失败:%v", getWillExpireOrgCountErr)
239
+	}
240
+
241
+	countOfExpiredOrg, getExpiredOrgCountErr := service.GetDidExpiredOrgCountFromDayToDay(timeBefore15Days, zeroHourTimeOfToday)
242
+	if getExpiredOrgCountErr != nil {
243
+		this.ErrorLog("获取刚到期机构数失败:%v", getExpiredOrgCountErr)
244
+	}
245
+
246
+	willExpireOrgs, getWillExpireOrgsErr := service.GetWillExpireOrgsFromDayToDay(zeroHourTimeOfToday, timeAfter15Days)
247
+	if getWillExpireOrgsErr != nil {
248
+		this.ErrorLog("获取即将到期机构失败:%v", getWillExpireOrgsErr)
249
+		willExpireOrgs = make([]*service.ExpireOrgListVM, 0, 0)
250
+	}
251
+
252
+	expiredOrgs, getExpiredOrgsErr := service.GetDidExpireOrgsFromDayToDay(timeBefore15Days, zeroHourTimeOfToday)
253
+	if getExpiredOrgsErr != nil {
254
+		this.ErrorLog("获取已到期机构失败:%v", getExpiredOrgsErr)
255
+		expiredOrgs = make([]*service.ExpireOrgListVM, 0, 0)
256
+	}
257
+
258
+	this.ServeSuccessJSON(map[string]interface{}{
259
+		"will_expire_org_count": countOfWillExpireOrg,
260
+		"did_expired_org_count": countOfExpiredOrg,
261
+		"will_expire_orgs":      willExpireOrgs,
262
+		"did_expired_orgs":      expiredOrgs,
263
+	})
264
+}
265
+
266
+// /admin/api/dialysis/analysis [get] DialysisAnalysis
267
+func (this *AnalysisAPIController) DialysisAnalysis() {
268
+	now := time.Now()
269
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
270
+	endTimeOfToday := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 999, time.Local)
271
+
272
+	timesToday, getTimesTodayErr := service.GetDialysisTimesFromDayToDay(zeroHourTimeOfToday, endTimeOfToday)
273
+	if getTimesTodayErr != nil {
274
+		this.ErrorLog("获取今日透析次数失败:%v", getTimesTodayErr)
275
+	}
276
+
277
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
278
+	timesThisWeek, getTimesThisWeekErr := service.GetDialysisTimesFromDayToDay(monday, sunday)
279
+	if getTimesThisWeekErr != nil {
280
+		this.ErrorLog("获取本周透析次数失败:%v", getTimesThisWeekErr)
281
+	}
282
+
283
+	thisYear := now.Year()
284
+	thisMonth := int(now.Month())
285
+	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
286
+	timesThisMonth, getTimesThisMonthErr := service.GetDialysisTimesFromDayToDay(beginningOfMonth, endOfMonth)
287
+	if getTimesThisMonthErr != nil {
288
+		this.ErrorLog("获取本月透析次数失败:%v", getTimesThisMonthErr)
289
+	}
290
+
291
+	monthTimes := make([]map[string]interface{}, 0, 12)
292
+	for m := 1; m < 12; m++ {
293
+		if m > thisMonth {
294
+			break
295
+		}
296
+		if m == thisMonth {
297
+			monthTimes = append(monthTimes, map[string]interface{}{
298
+				"month": m,
299
+				"count": timesThisMonth,
300
+			})
301
+
302
+		} else {
303
+			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
304
+			times, getTimesErr := service.GetDialysisTimesFromDayToDay(BOM, EOM)
305
+			if getTimesErr != nil {
306
+				this.ErrorLog("获取%v月透析次数失败:%v", m, getTimesErr)
307
+			}
308
+			monthTimes = append(monthTimes, map[string]interface{}{
309
+				"month": m,
310
+				"count": times,
311
+			})
312
+		}
313
+	}
314
+
315
+	this.ServeSuccessJSON(map[string]interface{}{
316
+		"times_today":  timesToday,
317
+		"times_week":   timesThisWeek,
318
+		"times_month":  timesThisMonth,
319
+		"times_months": monthTimes,
320
+	})
321
+}
322
+
323
+// /admin/api/monitor/analysis [get] MonitorAnalysis
324
+func (this *AnalysisAPIController) MonitorAnalysis() {
325
+	now := time.Now()
326
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
327
+	endTimeOfToday := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 999, time.Local)
328
+
329
+	timesToday, getTimesTodayErr := service.GetMonitoringTimesFromDayToDay(zeroHourTimeOfToday, endTimeOfToday)
330
+	if getTimesTodayErr != nil {
331
+		this.ErrorLog("获取今日监控次数失败:%v", getTimesTodayErr)
332
+	}
333
+
334
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
335
+	timesThisWeek, getTimesThisWeekErr := service.GetMonitoringTimesFromDayToDay(monday, sunday)
336
+	if getTimesThisWeekErr != nil {
337
+		this.ErrorLog("获取本周监控次数失败:%v", getTimesThisWeekErr)
338
+	}
339
+
340
+	thisYear := now.Year()
341
+	thisMonth := int(now.Month())
342
+	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
343
+	timesThisMonth, getTimesThisMonthErr := service.GetMonitoringTimesFromDayToDay(beginningOfMonth, endOfMonth)
344
+	if getTimesThisMonthErr != nil {
345
+		this.ErrorLog("获取本月监控次数失败:%v", getTimesThisMonthErr)
346
+	}
347
+
348
+	monthTimes := make([]map[string]interface{}, 0, 12)
349
+	for m := 1; m < 12; m++ {
350
+		if m > thisMonth {
351
+			break
352
+		}
353
+		if m == thisMonth {
354
+			monthTimes = append(monthTimes, map[string]interface{}{
355
+				"month": m,
356
+				"count": timesThisMonth,
357
+			})
358
+
359
+		} else {
360
+			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
361
+			times, getTimesErr := service.GetMonitoringTimesFromDayToDay(BOM, EOM)
362
+			if getTimesErr != nil {
363
+				this.ErrorLog("获取%v月监控次数失败:%v", m, getTimesErr)
364
+			}
365
+			monthTimes = append(monthTimes, map[string]interface{}{
366
+				"month": m,
367
+				"count": times,
368
+			})
369
+		}
370
+	}
371
+
372
+	this.ServeSuccessJSON(map[string]interface{}{
373
+		"times_today":  timesToday,
374
+		"times_week":   timesThisWeek,
375
+		"times_month":  timesThisMonth,
376
+		"times_months": monthTimes,
377
+	})
378
+}
379
+
380
+// /admin/api/patient/analysis [get] PatientAnalysis
381
+func (this *AnalysisAPIController) PatientAnalysis() {
382
+	now := time.Now()
383
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
384
+	newCountToday, getNewCountTodayErr := service.GetNewPatientCountFromDayToDay(zeroHourTimeOfToday, now)
385
+	if getNewCountTodayErr != nil {
386
+		this.ErrorLog("获取今日新增病人数失败:%v", getNewCountTodayErr)
387
+	}
388
+
389
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
390
+	newCountThisWeek, getNewCountThisWeekErr := service.GetNewPatientCountFromDayToDay(monday, sunday)
391
+	if getNewCountThisWeekErr != nil {
392
+		this.ErrorLog("获取本周新增病人数失败:%v", getNewCountThisWeekErr)
393
+	}
394
+
395
+	thisYear := now.Year()
396
+	thisMonth := int(now.Month())
397
+	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
398
+	newCountThisMonth, getNewCountThisMonthErr := service.GetNewPatientCountFromDayToDay(beginningOfMonth, endOfMonth)
399
+	if getNewCountThisMonthErr != nil {
400
+		this.ErrorLog("获取本月新增病人数失败:%v", getNewCountThisMonthErr)
401
+	}
402
+
403
+	monthNewCounts := make([]map[string]interface{}, 0, 12)
404
+	for m := 1; m < 12; m++ {
405
+		if m > thisMonth {
406
+			break
407
+		}
408
+		if m == thisMonth {
409
+			monthNewCounts = append(monthNewCounts, map[string]interface{}{
410
+				"month": m,
411
+				"count": newCountThisMonth,
412
+			})
413
+
414
+		} else {
415
+			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
416
+			newCount, getNewCountErr := service.GetNewPatientCountFromDayToDay(BOM, EOM)
417
+			if getNewCountErr != nil {
418
+				this.ErrorLog("获取%v月新增病人数失败:%v", m, getNewCountErr)
419
+			}
420
+			monthNewCounts = append(monthNewCounts, map[string]interface{}{
421
+				"month": m,
422
+				"count": newCount,
423
+			})
424
+		}
425
+	}
426
+
427
+	maleCount, femaleCount, unknowGenderCount, getGenderCountErr := service.GetPatientGenderDistribution()
428
+	if getGenderCountErr != nil {
429
+		this.ErrorLog("获取病人性别分布失败:%v", getGenderCountErr)
430
+	}
431
+
432
+	// 1乙肝 2丙肝 3艾滋病 4肺结核 5梅毒
433
+	// 不写错误日志了,累了
434
+	normalPCount, _ := service.GetInfectiousDiseasePatientCount(0)
435
+	type1PCount, _ := service.GetInfectiousDiseasePatientCount(1)
436
+	type2PCount, _ := service.GetInfectiousDiseasePatientCount(2)
437
+	type3PCount, _ := service.GetInfectiousDiseasePatientCount(3)
438
+	type4PCount, _ := service.GetInfectiousDiseasePatientCount(4)
439
+	type5PCount, _ := service.GetInfectiousDiseasePatientCount(5)
440
+
441
+	ageDistribution, getAgeDistributionErr := service.GetPatientAgeDistribution()
442
+	if getAgeDistributionErr != nil {
443
+		this.ErrorLog("获取病人年龄分布失败:%v", getAgeDistributionErr)
444
+		ageDistribution = make([]*service.PatientAgeCountStruct, 0, 0)
445
+	}
446
+
447
+	this.ServeSuccessJSON(map[string]interface{}{
448
+		"new_patient_count_today":  newCountToday,
449
+		"new_patient_count_week":   newCountThisWeek,
450
+		"new_patient_count_month":  newCountThisMonth,
451
+		"new_patient_count_months": monthNewCounts,
452
+
453
+		"male_count":   maleCount,
454
+		"female_count": femaleCount,
455
+		"total_count":  maleCount + femaleCount + unknowGenderCount,
456
+
457
+		"disease_type_0_count": normalPCount,
458
+		"disease_type_1_count": type1PCount,
459
+		"disease_type_2_count": type2PCount,
460
+		"disease_type_3_count": type3PCount,
461
+		"disease_type_4_count": type4PCount,
462
+		"disease_type_5_count": type5PCount,
463
+
464
+		"age_counts": ageDistribution,
465
+	})
466
+}

+ 0 - 9
controllers/admin_api_controllers/api_router_register.go View File

@@ -1,9 +0,0 @@
1
-package admin_api_controllers
2
-
3
-import "github.com/astaxie/beego"
4
-
5
-// 管理员后台路由,以 /admin/api 为前缀
6
-func AdminAPIControllersRegisterRouters() {
7
-	beego.Router("/data/upload/api/city", &CityDataUploadAPIController{}, "post:UploadCityData")
8
-
9
-}

+ 0 - 11
controllers/admin_api_controllers/city_data_upload_api_controller.go View File

@@ -1,11 +0,0 @@
1
-package admin_api_controllers
2
-
3
-import "Data_Upload_Api/controllers"
4
-
5
-type CityDataUploadAPIController struct {
6
-	controllers.BaseAPIController
7
-}
8
-
9
-func (this *CityDataUploadAPIController) UploadCityData() {
10
-
11
-}

+ 35 - 0
controllers/admin_api_controllers/login_api_controller.go View File

@@ -0,0 +1,35 @@
1
+package admin_api_controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/service"
6
+)
7
+
8
+type LoginAPIController struct {
9
+	AdminBaseAPIController
10
+}
11
+
12
+// /admin/api/login/pwd [post] LoginByPwd
13
+// @param account:string
14
+// @param password:string
15
+func (this *LoginAPIController) LoginByPwd() {
16
+	account := this.GetString("account")
17
+	password := this.GetString("password")
18
+
19
+	admin, getAdminErr := service.GetAdminAccount(account, password)
20
+	if getAdminErr != nil {
21
+		this.ErrorLog("获取管理员信息失败:%v", getAdminErr)
22
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
23
+		return
24
+	} else if admin == nil {
25
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAccountOrPasswordWrong)
26
+		return
27
+	}
28
+
29
+	this.SetSession("admin_info", &AdminInfo{
30
+		Admin: admin,
31
+	})
32
+	this.ServeSuccessJSON(map[string]interface{}{
33
+		"admin": admin,
34
+	})
35
+}

File diff suppressed because it is too large
+ 2223 - 0
controllers/advice_template.json


+ 311 - 1
controllers/base_api_controller.go View File

@@ -1,7 +1,11 @@
1 1
 package controllers
2 2
 
3 3
 import (
4
-	"Data_Upload_Api/enums"
4
+	"Xcx_New/enums"
5
+	"Xcx_New/service"
6
+	"fmt"
7
+	"strconv"
8
+	"strings"
5 9
 )
6 10
 
7 11
 type BaseAPIController struct {
@@ -53,13 +57,255 @@ func (this *BaseAPIController) ServeFailJsonSend(code int, msg string) {
53 57
 	this.ServeJSON()
54 58
 }
55 59
 
60
+func (this *BaseAPIController) ServeDynamicFailJsonSend(msg string) {
61
+	this.Data["json"] = enums.MakeDynamicFailResponseJSON(msg)
62
+	this.ServeJSON()
63
+}
64
+
56 65
 type BaseAuthAPIController struct {
57 66
 	BaseAPIController
58 67
 }
59 68
 
60 69
 func (this *BaseAuthAPIController) Prepare() {
61 70
 	this.BaseAPIController.Prepare()
71
+	if this.GetAdminUserInfo() == nil {
72
+		//var userAdmin models.AdminUser
73
+		//userAdmin.Id = 1448
74
+		//userAdmin.Mobile = "13318599895"
75
+		//
76
+		//userAdmin.Id = 597
77
+		//userAdmin.Mobile = "19874122664"
78
+		//userAdmin.IsSuperAdmin = false
79
+		//userAdmin.Status = 1
80
+		//userAdmin.CreateTime = 1530786071
81
+		//userAdmin.ModifyTime = 1530786071
82
+		//var subscibe models.ServeSubscibe
83
+		//subscibe.ID = 1
84
+		//subscibe.OrgId = 4
85
+		//subscibe.PeriodStart = 1538035409
86
+		//subscibe.PeriodEnd = 1569571409
87
+		//subscibe.State = 1
88
+		//subscibe.Status = 1
89
+		//subscibe.CreatedTime = 1538035409
90
+		//subscibe.UpdatedTime = 1538035409
91
+		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
92
+		//subscibes[4] = &subscibe
93
+		//var adminUserInfo service.AdminUserInfo
94
+		//adminUserInfo.CurrentOrgId = 4
95
+		//adminUserInfo.CurrentAppId = 4
96
+		//adminUserInfo.AdminUser = &userAdmin
97
+		//adminUserInfo.Subscibes = subscibes
98
+		//this.SetSession("admin_user_info", &adminUserInfo)
99
+
100
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
101
+		this.StopRun()
102
+
103
+	}
104
+
105
+	adminUserInfo := this.GetAdminUserInfo()
106
+
107
+	if this.Ctx.Request.Header.Get("Permission") == "2" {
108
+		org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
109
+		if adminUserInfo.AdminUser.Id != org.Creator { //超级管理员不受此限制
110
+
111
+			isPermission := false
112
+			adminUserInfo := this.GetAdminUserInfo()
113
+			//该机构下该用户有多少个
114
+			role, _ := service.GetUserAllRole(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id)
115
+			var roles []string
116
+			if len(role.RoleIds) <= 0 { //该用户没有设置角色
117
+
118
+			} else {
119
+				roles = strings.Split(role.RoleIds, ",")
120
+			}
121
+			fmt.Println(roles)
122
+
123
+			//获取该用户下所有角色的权限总集
124
+			var userRolePurviews string
125
+			var userRolePurviewsArr []string
126
+			for _, item := range roles {
127
+				role_id, _ := strconv.ParseInt(item, 10, 64)
128
+				purviews, _ := service.GetRoleFuncPurviewIds(role_id)
129
+				if len(userRolePurviews) == 0 {
130
+					userRolePurviews = purviews
131
+				} else {
132
+					userRolePurviews = userRolePurviews + "," + purviews
133
+				}
134
+			}
135
+			//该用户所拥有角色的权限的总集
136
+			userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
137
+			fmt.Println(userRolePurviewsArr)
138
+			//系统所记录的权限列表
139
+			allPermission, _ := service.GetAllFunctionPurview()
140
+
141
+			for _, item := range allPermission {
142
+				// fmt.Println(len(strings.Split(item.Urlfor, ",")))
143
+
144
+				// fmt.Println(strings.Split(item.Urlfor, ","))
145
+				//fmt.Println(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
146
+
147
+				//判断当前路由是否在权限路由列表里面
148
+				if strings.Split(item.Urlfor, ",")[1] == strings.Split(this.Ctx.Request.RequestURI, "?")[0]+"?"+"mode="+this.GetString("mode") {
149
+
150
+					//获取该角色的所有权限
151
+					for _, items := range userRolePurviewsArr {
152
+						id, _ := strconv.ParseInt(items, 10, 64)
153
+						if id == item.ID {
154
+							isPermission = true
155
+						}
156
+					}
157
+					if !isPermission {
158
+						msg, _ := service.FindErrorMsgByStr(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
159
+						json := make(map[string]interface{})
160
+						json["msg"] = msg
161
+						json["code"] = 0
162
+						json["state"] = 0
163
+						this.Data["json"] = json
164
+						this.ServeJSON()
165
+						this.StopRun()
166
+					}
167
+				}
168
+			}
169
+		}
170
+	}
171
+
172
+	if this.Ctx.Request.Header.Get("Permission") == "3" {
173
+		org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
174
+		if adminUserInfo.AdminUser.Id != org.Creator { //超级管理员不受此限制
175
+
176
+			isPermission := false
177
+			adminUserInfo := this.GetAdminUserInfo()
178
+			//该机构下该用户有多少个
179
+			role, _ := service.GetUserAllRole(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id)
180
+			var roles []string
181
+			if len(role.RoleIds) <= 0 { //该用户没有设置角色
182
+
183
+			} else {
184
+				roles = strings.Split(role.RoleIds, ",")
185
+			}
186
+			fmt.Println(roles)
62 187
 
188
+			//获取该用户下所有角色的权限总集
189
+			var userRolePurviews string
190
+			var userRolePurviewsArr []string
191
+			for _, item := range roles {
192
+				role_id, _ := strconv.ParseInt(item, 10, 64)
193
+				purviews, _ := service.GetRoleFuncPurviewIds(role_id)
194
+				if len(userRolePurviews) == 0 {
195
+					userRolePurviews = purviews
196
+				} else {
197
+					userRolePurviews = userRolePurviews + "," + purviews
198
+				}
199
+			}
200
+			//该用户所拥有角色的权限的总集
201
+			userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
202
+			fmt.Println(userRolePurviewsArr)
203
+			//系统所记录的权限列表
204
+			allPermission, _ := service.GetAllFunctionPurview()
205
+
206
+			for _, item := range allPermission {
207
+				// fmt.Println(strings.Split(item.Urlfor, ",")[2])
208
+				// fmt.Println(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
209
+
210
+				//判断当前路由是否在权限路由列表里面
211
+				if strings.Split(item.Urlfor, ",")[2] == strings.Split(this.Ctx.Request.RequestURI, "?")[0]+"?"+"mode="+this.GetString("mode") {
212
+
213
+					//获取该角色的所有权限
214
+					for _, items := range userRolePurviewsArr {
215
+						id, _ := strconv.ParseInt(items, 10, 64)
216
+						if id == item.ID {
217
+							isPermission = true
218
+						}
219
+					}
220
+					if !isPermission {
221
+						msg, _ := service.FindErrorMsgByStr(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
222
+						json := make(map[string]interface{})
223
+						json["msg"] = msg
224
+						json["code"] = 0
225
+						json["state"] = 0
226
+						this.Data["json"] = json
227
+						this.ServeJSON()
228
+						this.StopRun()
229
+					}
230
+				}
231
+			}
232
+		}
233
+	}
234
+
235
+	//if this.Ctx.Request.Method != "GET" {
236
+	//	adminUserInfo := this.GetAdminUserInfo()
237
+	//
238
+	//	err := service.GetOrgSubscibeState(adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId])
239
+	//	if err != nil || adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId].State == 3 {
240
+	//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotSubscibe)
241
+	//		this.StopRun()
242
+	//	}
243
+	//}
244
+
245
+	//if this.Ctx.Request.Header.Get("Permission") == "1" {
246
+	//	isPermission := false
247
+	//
248
+	//	//adminUserInfo := this.GetAdminUserInfo()
249
+	//
250
+	//	//service.GetUserAllRole(adminUserInfo.CurrentOrgId)
251
+	//
252
+	//
253
+	//
254
+	//
255
+	//	roles := []int64{1,2}		//模拟该用户有多少角色
256
+	//	var targetRole models.RolePurview
257
+	//	var userRolePurview []string
258
+	//
259
+	//	//用户角色1对应的权限
260
+	//	role1 := models.RolePurview{PurviewIds:"11,12,13"}
261
+	//
262
+	//	//用户角色2对应的权限
263
+	//	role2 := models.RolePurview{PurviewIds:"11,15,16"}
264
+	//
265
+	//
266
+	//	//模拟角色2
267
+	//	//判断该用户有多少个角色,合并最大角色权限
268
+	//	if len(roles) == 1{ //单个
269
+	//		targetRole = role1
270
+	//		userRolePurview = strings.Split(targetRole.PurviewIds, ",")
271
+	//
272
+	//	}else{ //多个
273
+	//		targetRole = role1
274
+	//		targetRole.PurviewIds = targetRole.PurviewIds + "," + role2.PurviewIds
275
+	//		userRolePurview = strings.Split(targetRole.PurviewIds, ",")
276
+	//	}
277
+	//
278
+	//	userRolePurview = RemoveRepeatedElement2(userRolePurview)
279
+	//
280
+	//	fmt.Println(userRolePurview)
281
+	//	//所有权限列表
282
+	//	allPermission := []models.Purview{{Id:10,Urlfor:"/m/api/dialysis/dialysisPrescription-/api/dialysis/prescription"},
283
+	//		{Id:11,Urlfor:"/m/api/dialysis/dialysisPrescription1-/api/dialysis/prescription1"},
284
+	//		{Id:12,Urlfor:"/m/api/dialysis/dialysisPrescription2-/api/dialysis/prescription2"},
285
+	//		{Id:13,Urlfor:"/m/api/dialysis/dialysisPrescription3-/api/dialysis/prescription3"},
286
+	//		{Id:14,Urlfor:"/m/api/dialysis/dialysisPrescription4-/api/dialysis/prescription4"},
287
+	//		{Id:15,Urlfor:"/m/api/dialysis/dialysisPrescription5-/api/dialysis/prescription5"},
288
+	//		{Id:16,Urlfor:"/m/api/dialysis/dialysisPrescription6-/api/dialysis/prescription6"}}
289
+	//	for _, item := range allPermission {
290
+	//		//判断当前路由是否在权限路由列表里面
291
+	//		if strings.Split(item.Urlfor, "-")[1] == strings.Split(this.Ctx.Request.RequestURI , "?")[0]{
292
+	//			fmt.Println(strings.Split(this.Ctx.Request.RequestURI , "?")[0])
293
+	//
294
+	//			//获取该角色的所有权限
295
+	//			for _, items := range userRolePurview{
296
+	//				id, _ := strconv.ParseInt(items, 10, 64)
297
+	//				if id == item.Id{
298
+	//					isPermission = true
299
+	//				}
300
+	//			}
301
+	//			if !isPermission{
302
+	//				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreExist)
303
+	//				this.StopRun()
304
+	//			}
305
+	//		}
306
+	//
307
+	//	}
308
+	//}
63 309
 }
64 310
 
65 311
 type BaseServeAPIController struct {
@@ -68,5 +314,69 @@ type BaseServeAPIController struct {
68 314
 
69 315
 func (this *BaseServeAPIController) Prepare() {
70 316
 	this.BaseAPIController.Prepare()
317
+	if this.GetAdminUserInfo() == nil {
318
+		//var userAdmin models.AdminUser
319
+		//userAdmin.Id = 1448
320
+		//userAdmin.Mobile = "13318599895"
321
+		//
322
+		//userAdmin.Id = 597
323
+		//userAdmin.Mobile = "19874122664"
324
+		//userAdmin.IsSuperAdmin = false
325
+		//userAdmin.Status = 1
326
+		//userAdmin.CreateTime = 1530786071
327
+		//userAdmin.ModifyTime = 1530786071
328
+		//var subscibe models.ServeSubscibe
329
+		//subscibe.ID = 1
330
+		//subscibe.OrgId = 4
331
+		//subscibe.PeriodStart = 1538035409
332
+		//subscibe.PeriodEnd = 1569571409
333
+		//subscibe.State = 1
334
+		//subscibe.Status = 1
335
+		//subscibe.CreatedTime = 1538035409
336
+		//subscibe.UpdatedTime = 1538035409
337
+		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
338
+		//subscibes[4] = &subscibe
339
+		//var adminUserInfo service.AdminUserInfo
340
+		//adminUserInfo.CurrentOrgId = 4
341
+		//adminUserInfo.CurrentAppId = 4
342
+		//adminUserInfo.AdminUser = &userAdmin
343
+		//adminUserInfo.Subscibes = subscibes
344
+		//this.SetSession("admin_user_info", &adminUserInfo)
345
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
346
+		this.StopRun()
347
+	}
348
+
349
+	//if adminUserInfo.AppRole != nil {
350
+	//	if adminUserInfo.AppRole.Id > 0 {
351
+	//		app_role, _ := service.FindAppRoleById(adminUserInfo.AppRole.Id)
352
+	//		if app_role != nil {
353
+	//			if app_role.Status != 1 {
354
+	//				this.DelSession("mobile_admin_user_info")
355
+	//				this.Ctx.SetCookie("token_cookie", "")
356
+	//				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeForbidden)
357
+	//				this.StopRun()
358
+	//			}
359
+	//		}
360
+	//	}
361
+	//
362
+	//}
363
+	//fmt.Println("222222222")
71 364
 
72 365
 }
366
+
367
+func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
368
+	newArr = make([]string, 0)
369
+	for i := 0; i < len(arr); i++ {
370
+		repeat := false
371
+		for j := i + 1; j < len(arr); j++ {
372
+			if arr[i] == arr[j] {
373
+				repeat = true
374
+				break
375
+			}
376
+		}
377
+		if !repeat {
378
+			newArr = append(newArr, arr[i])
379
+		}
380
+	}
381
+	return
382
+}

+ 11 - 0
controllers/base_controller.go View File

@@ -1,6 +1,8 @@
1 1
 package controllers
2 2
 
3 3
 import (
4
+	"Xcx_New/service"
5
+
4 6
 	"github.com/astaxie/beego"
5 7
 )
6 8
 
@@ -8,6 +10,15 @@ type BaseController struct {
8 10
 	beego.Controller
9 11
 }
10 12
 
13
+func (this *BaseController) GetAdminUserInfo() *service.AdminUserInfo {
14
+	userInfo := this.GetSession("admin_user_info")
15
+	if userInfo == nil {
16
+		return nil
17
+	} else {
18
+		return userInfo.(*service.AdminUserInfo)
19
+	}
20
+}
21
+
11 22
 func (this *BaseController) ErrorLog(format string, a ...interface{}) {
12 23
 	//beego.Error(fmt.Sprintf(format, a...))
13 24
 }

File diff suppressed because it is too large
+ 1786 - 0
controllers/data_api_controller.go


+ 15 - 0
controllers/default.go View File

@@ -0,0 +1,15 @@
1
+package controllers
2
+
3
+import (
4
+	"github.com/astaxie/beego"
5
+)
6
+
7
+type MainController struct {
8
+	beego.Controller
9
+}
10
+
11
+func (c *MainController) Get() {
12
+	c.Data["Website"] = "beego.me"
13
+	c.Data["Email"] = "astaxie@gmail.com"
14
+	c.TplName = "index.tpl"
15
+}

File diff suppressed because it is too large
+ 1256 - 0
controllers/device_api_controller.go


File diff suppressed because it is too large
+ 3563 - 0
controllers/dialysis_api_controller.go


+ 58 - 0
controllers/dialysis_board_api_controller.go View File

@@ -0,0 +1,58 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/service"
6
+	"Xcx_New/utils"
7
+	"time"
8
+
9
+	"github.com/astaxie/beego"
10
+)
11
+
12
+func DialysisBoardAPIControllerRegistRouter() {
13
+	beego.Router("/api/dialysis/board", &DialysisBoardAPIController{}, "get:BoardData")
14
+}
15
+
16
+type DialysisBoardAPIController struct {
17
+	BaseAuthAPIController
18
+}
19
+
20
+func (c *DialysisBoardAPIController) BoardData() {
21
+	page, _ := c.GetInt64("page", 0)
22
+	if page <= 0 {
23
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
24
+		return
25
+	}
26
+	nowTimeUinx := time.Now()
27
+	today := nowTimeUinx.Format("2006-01-02")
28
+	week := nowTimeUinx.Weekday()
29
+
30
+	timeLayout := "2006-01-02"
31
+	loc, _ := time.LoadLocation("Local")
32
+
33
+	todayTime, err := time.ParseInLocation(timeLayout, today, loc)
34
+	if err != nil {
35
+		utils.ErrorLog("%v", err)
36
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
37
+		return
38
+	}
39
+	var limit int64 = 10
40
+	offset := (page - 1) * limit
41
+	todayTimeStamp := todayTime.Unix()
42
+
43
+	adminUserInfo := c.GetAdminUserInfo()
44
+
45
+	boards, err := service.GetDialysisBoard(adminUserInfo.CurrentOrgId, todayTimeStamp, offset, limit)
46
+	if err != nil {
47
+		utils.ErrorLog("%v", err)
48
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
49
+		return
50
+	}
51
+
52
+	c.ServeSuccessJSON(map[string]interface{}{
53
+		"today":  today,
54
+		"week":   week,
55
+		"boards": boards,
56
+	})
57
+
58
+}

+ 437 - 0
controllers/dialysis_parameter_api_controller.go View File

@@ -0,0 +1,437 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/service"
6
+	"fmt"
7
+	"github.com/astaxie/beego"
8
+	"github.com/jinzhu/gorm"
9
+	"strings"
10
+	"time"
11
+)
12
+
13
+type DialysisPrameterApiController struct {
14
+	BaseAuthAPIController
15
+}
16
+
17
+func DialysisPrameteRoutes() {
18
+	beego.Router("/api/dialysis/getdialysisparameters", &DialysisPrameterApiController{}, "Get:GetDialysisParameters")
19
+	beego.Router("/api/dialysis/getdialysisbatchparameters", &DialysisPrameterApiController{}, "Get:GetDialysisBatchParameters")
20
+	beego.Router("/api/dialysis/getwarehouseoutlist", &DialysisPrameterApiController{}, "Get:GetWareHouseOutList")
21
+	beego.Router("/api/dialysis/getallmaterial", &DialysisPrameterApiController{}, "Get:GetAllMaterial")
22
+	beego.Router("/api/dialysis/getcollectlist", &DialysisPrameterApiController{}, "Get:GetCollectList")
23
+	beego.Router("/api/dialysis/getbatchcollection", &DialysisPrameterApiController{}, "Get:GetBatchCollection")
24
+	beego.Router("/api/dialysis/getgatherlist", &DialysisPrameterApiController{}, "Get:GetGatherList")
25
+	beego.Router("/api/dialysis/getanticoagulantcount", &DialysisPrameterApiController{}, "Get:GetAnticoagulantCount")
26
+}
27
+
28
+func (this *DialysisPrameterApiController) GetDialysisParameters() {
29
+	timeLayout := "2006-01-02"
30
+	loc, _ := time.LoadLocation("Local")
31
+	page, _ := this.GetInt64("page")
32
+	limit, _ := this.GetInt64("limit")
33
+	schedulType, _ := this.GetInt64("scheduleType")
34
+	start_time := this.GetString("start_time")
35
+	partitionType, _ := this.GetInt64("partitionType")
36
+	keywords := this.GetString("keyword")
37
+	adminUserInfo := this.GetAdminUserInfo()
38
+	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
39
+
40
+	fmt.Println("scheduletype", schedulType, start_time, partitionType, keywords, theTime.Unix())
41
+	if len(keywords) > 0 {
42
+		dialysisSchedule, err, total := service.GetDialysisParametersByKeyword(adminUserInfo.CurrentOrgId, keywords, schedulType, partitionType, page, limit, theTime.Unix())
43
+		patient, err := service.GetDialysisTodaySchedulePatient(adminUserInfo.CurrentOrgId, theTime.Unix(), page, limit, keywords, schedulType, partitionType)
44
+		var vlist []interface{}
45
+		var elist []interface{}
46
+		for _, item := range patient {
47
+			prescription, _ := service.GetDialysisPrescriptionList(item.PatientId, adminUserInfo.CurrentOrgId, theTime.Unix())
48
+			vlist = append(vlist, prescription)
49
+			dialysis, _ := service.GetAssessmentBeforDialysisByStartime(item.PatientId, adminUserInfo.CurrentOrgId, theTime.Unix())
50
+			elist = append(elist, dialysis)
51
+		}
52
+		if err == nil {
53
+			this.ServeSuccessJSON(map[string]interface{}{
54
+				"schedule":     dialysisSchedule,
55
+				"total":        total,
56
+				"prescription": vlist,
57
+				"dialysbefor":  elist,
58
+				"patient":      patient,
59
+			})
60
+		} else {
61
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
62
+		}
63
+	} else {
64
+		dialysisSchedule, err, total := service.GetDialysisParameter(adminUserInfo.CurrentOrgId, theTime.Unix(), schedulType, partitionType, page, limit)
65
+
66
+		//查询今日排班的病人
67
+		patient, err := service.GetDialysisTodaySchedulePatient(adminUserInfo.CurrentOrgId, theTime.Unix(), page, limit, keywords, schedulType, partitionType)
68
+
69
+		var vlist []interface{}
70
+		var elist []interface{}
71
+		for _, item := range patient {
72
+			//查询当前日期的病人是否存在数据
73
+			//_, errcode := service.GetToDayDialysisPrescription(item.PatientId, adminUserInfo.CurrentOrgId, theTime.Unix())
74
+			//if errcode == gorm.ErrRecordNotFound {
75
+			//	//查询每个病人透析处方的最后一次数据
76
+			//	prescription, _ := service.GetLastDialysisPrescription(item.PatientId, adminUserInfo.CurrentOrgId)
77
+			//	vlist = append(vlist, prescription)
78
+			//} else if errcode == nil {
79
+			//	//获取当前日期
80
+			//	prescription, _ := service.GetDialysisPrescriptionList(item.PatientId, adminUserInfo.CurrentOrgId, theTime.Unix())
81
+			//	vlist = append(vlist, prescription)
82
+			//}
83
+
84
+			//_, errcodes := service.GetTodayAssessmentBeforDialysis(item.PatientId, adminUserInfo.CurrentOrgId, theTime.Unix())
85
+			//if errcodes == gorm.ErrRecordNotFound {
86
+			//	//查询每个病人透前评估的最后一次数据
87
+			//	dialysis, _ := service.GetLastAssessmentBeforDialysis(item.PatientId, adminUserInfo.CurrentOrgId)
88
+			//	elist = append(elist, dialysis)
89
+			//} else if errcodes == nil {
90
+			//	dialysis, _ := service.GetAssessmentBeforDialysisByStartime(item.PatientId, adminUserInfo.CurrentOrgId, theTime.Unix())
91
+			//	elist = append(elist, dialysis)
92
+			//}
93
+
94
+			prescription, _ := service.GetDialysisPrescriptionList(item.PatientId, adminUserInfo.CurrentOrgId, theTime.Unix())
95
+			vlist = append(vlist, prescription)
96
+			dialysis, _ := service.GetAssessmentBeforDialysisByStartime(item.PatientId, adminUserInfo.CurrentOrgId, theTime.Unix())
97
+			elist = append(elist, dialysis)
98
+		}
99
+
100
+		if err == nil {
101
+			this.ServeSuccessJSON(map[string]interface{}{
102
+				"schedule":     dialysisSchedule,
103
+				"total":        total,
104
+				"prescription": vlist,
105
+				"dialysbefor":  elist,
106
+				"patient":      patient,
107
+			})
108
+		} else {
109
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
110
+		}
111
+	}
112
+
113
+}
114
+
115
+func (this *DialysisPrameterApiController) GetDialysisBatchParameters() {
116
+	timeLayout := "2006-01-02"
117
+	loc, _ := time.LoadLocation("Local")
118
+	adminUser := this.GetAdminUserInfo()
119
+	orgId := adminUser.CurrentOrgId
120
+	schIDStr := this.GetString("ids")
121
+	if len(schIDStr) == 0 {
122
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
123
+		return
124
+	}
125
+	idStrs := strings.Split(schIDStr, ",")
126
+	startime := this.GetString("startime")
127
+	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", startime+" 00:00:00", loc)
128
+	parameters, err := service.GetDialysisBatchParameters(idStrs, orgId)
129
+	var vlist []interface{}
130
+	var elist []interface{}
131
+	for _, item := range parameters {
132
+		//查询当前日期的病人是否存在数据
133
+		_, errcode := service.GetToDayDialysisPrescription(item.PatientId, orgId, theTime.Unix())
134
+		if errcode == gorm.ErrRecordNotFound {
135
+			//查询每个病人透析处方的最后一次数据
136
+			prescription, _ := service.GetLastDialysisPrescription(item.PatientId, orgId)
137
+			vlist = append(vlist, prescription)
138
+		} else if errcode == nil {
139
+			//获取当前日期
140
+			prescription, _ := service.GetDialysisPrescriptionList(item.PatientId, orgId, theTime.Unix())
141
+			vlist = append(vlist, prescription)
142
+		}
143
+
144
+		_, errcodes := service.GetTodayAssessmentBeforDialysis(item.PatientId, orgId, theTime.Unix())
145
+		if errcodes == gorm.ErrRecordNotFound {
146
+			//查询每个病人透前评估的最后一次数据
147
+			dialysis, _ := service.GetLastAssessmentBeforDialysis(item.PatientId, orgId)
148
+			elist = append(elist, dialysis)
149
+		} else if errcodes == nil {
150
+			dialysis, _ := service.GetAssessmentBeforDialysisByStartime(item.PatientId, orgId, theTime.Unix())
151
+			elist = append(elist, dialysis)
152
+		}
153
+
154
+	}
155
+	if err == nil {
156
+		this.ServeSuccessJSON(map[string]interface{}{
157
+			"schedule":     parameters,
158
+			"prescription": vlist,
159
+			"dialysbefor":  elist,
160
+		})
161
+	}
162
+}
163
+
164
+func (this *DialysisPrameterApiController) GetWareHouseOutList() {
165
+
166
+	timeLayout := "2006-01-02"
167
+	loc, _ := time.LoadLocation("Local")
168
+	start_time := this.GetString("start_time")
169
+	startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
170
+	end_time := this.GetString("end_time")
171
+	endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
172
+	fmt.Println(start_time, end_time)
173
+	adminUserInfo := this.GetAdminUserInfo()
174
+	orgId := adminUserInfo.CurrentOrgId
175
+	wareoutlist, err := service.GetWareHouseOutList(startime.Unix(), endtime.Unix(), orgId)
176
+	if err == nil {
177
+		this.ServeSuccessJSON(map[string]interface{}{
178
+			"wareoutlist": wareoutlist,
179
+		})
180
+	}
181
+}
182
+
183
+func (this *DialysisPrameterApiController) GetAllMaterial() {
184
+
185
+	timeLayout := "2006-01-02"
186
+	loc, _ := time.LoadLocation("Local")
187
+	start_time := this.GetString("startime")
188
+	startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
189
+	endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 23:59:59", loc)
190
+	orgId := this.GetAdminUserInfo().CurrentOrgId
191
+	material, err := service.GetAllMaterial(startime.Unix(), endtime.Unix(), orgId)
192
+	if err == nil {
193
+		this.ServeSuccessJSON(map[string]interface{}{
194
+			"material": material,
195
+		})
196
+	}
197
+}
198
+
199
+func (this *DialysisPrameterApiController) GetCollectList() {
200
+
201
+	timeLayout := "2006-01-02"
202
+	loc, _ := time.LoadLocation("Local")
203
+	limit, _ := this.GetInt64("limit")
204
+	fmt.Println(limit)
205
+	page, _ := this.GetInt64("page")
206
+	fmt.Println("page", page)
207
+	partitiontype, _ := this.GetInt64("partitionType")
208
+	fmt.Println(partitiontype)
209
+	scheduletype, _ := this.GetInt64("scheduleType")
210
+	fmt.Println(scheduletype)
211
+	start_time := this.GetString("start_time")
212
+	fmt.Println(start_time)
213
+	startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
214
+	fmt.Println("startime", startime.Unix())
215
+	orgId := this.GetAdminUserInfo().CurrentOrgId
216
+	endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 23:59:59", loc)
217
+	keyword := this.GetString("keyword")
218
+	//获取透析参数数据
219
+	schedule, err, _ := service.GetCollectList(limit, page, partitiontype, scheduletype, startime.Unix(), orgId, keyword)
220
+
221
+	//查询今日排班的病人
222
+	patient, err := service.GetDialysisTodaySchedulePatient(orgId, startime.Unix(), page, limit, keyword, scheduletype, partitiontype)
223
+	var vlist []interface{}
224
+	var clist []interface{}
225
+	for _, item := range patient {
226
+		fmt.Println("---------", item.PatientId)
227
+		//查询当前日期的病人是否存在数据
228
+		//_, errcode := service.GetToDayDialysisPrescription(item.PatientId, orgId, startime.Unix())
229
+		//if errcode == gorm.ErrRecordNotFound {
230
+		//	//查询每个病人透析处方的最后一次数据
231
+		//	prescription, _ := service.GetLastDialysisPrescription(item.PatientId, orgId)
232
+		//	vlist = append(vlist, prescription)
233
+		//} else if errcode == nil {
234
+		//	//获取当前日期
235
+		//	prescription, _ := service.GetDialysisPrescriptionList(item.PatientId, orgId, startime.Unix())
236
+		//	vlist = append(vlist, prescription)
237
+		//}
238
+
239
+		//查询每个病人当前日期是否存在数据
240
+		//_, errco := service.GetAotoMaticReduceByPatientId(item.PatientId, orgId, startime.Unix(), endtime.Unix())
241
+		//fmt.Println("errco--------------------------", errco)
242
+		//if errco == gorm.ErrRecordNotFound {
243
+		//	reduece, _ := service.GetMaticReduece(item.PatientId, orgId)
244
+		//	clist = append(clist, reduece)
245
+		//} else if errco == nil {
246
+		//	reduece, _ := service.GetMaticeReduceByPatientId(item.PatientId, orgId, startime.Unix(), endtime.Unix())
247
+		//	clist = append(clist, reduece)
248
+		//}
249
+
250
+		prescription, _ := service.GetDialysisPrescriptionList(item.PatientId, orgId, startime.Unix())
251
+		vlist = append(vlist, prescription)
252
+
253
+		reduece, _ := service.GetMaticeReduceByPatientId(item.PatientId, orgId, startime.Unix(), endtime.Unix())
254
+		clist = append(clist, reduece)
255
+	}
256
+	//获取透析耗材数据
257
+	//consumables, err := service.GetDialysisConsumables(startime.Unix(), endtime.Unix(), orgId)
258
+
259
+	//if err == nil {
260
+	// this.ServeSuccessJSON(map[string]interface{}{
261
+	//   "schedule":     schedule,
262
+	//   "total":        total,
263
+	//   "consumables":  consumables,
264
+	//   "prescription": vlist,
265
+	//   "reducelist":   clist,
266
+	// })
267
+	//}
268
+
269
+	_, errors := service.FindStockOutByIsSys(orgId, 1, startime.Unix())
270
+
271
+	goodTypes, _ := service.FindAllGoodType(orgId) //two, err, i := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
272
+
273
+	if errors == gorm.ErrRecordNotFound {
274
+
275
+		dialysisGoods, _, total := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
276
+		for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
277
+			goodUser, _ := service.GetLastDialysisGoodsTwo(item.PatientId, orgId, startime.Unix())
278
+			lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepareTwo(item.PatientId, orgId, startime.Unix())
279
+			item.LastAutomaticReduceDetail = goodUser
280
+			item.LastDialysisBeforePrepare = lastGoodUserDetial
281
+		}
282
+		this.ServeSuccessJSON(map[string]interface{}{
283
+			"dialysis_goods": dialysisGoods,
284
+			"good_type":      goodTypes,
285
+			"total":          total,
286
+			"schedule":       schedule,
287
+			//"consumables":    consumables,
288
+			"prescription": vlist,
289
+			"reducelist":   clist,
290
+		})
291
+		return
292
+
293
+	} else if err == nil {
294
+		//获取当天排班的每个患者的库存使用情况
295
+		dialysisGoods, err, total := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
296
+		for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
297
+			goodUser, _ := service.GetLastDialysisGoodsTwo(item.PatientId, orgId, startime.Unix())
298
+			lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepareTwo(item.PatientId, orgId, startime.Unix())
299
+
300
+			fmt.Println(goodUser)
301
+			fmt.Println(lastGoodUserDetial)
302
+
303
+			item.LastAutomaticReduceDetail = goodUser
304
+			item.LastDialysisBeforePrepare = lastGoodUserDetial
305
+		}
306
+		if err == nil {
307
+			this.ServeSuccessJSON(map[string]interface{}{
308
+				"dialysis_goods": dialysisGoods,
309
+				"good_type":      goodTypes,
310
+				"total":          total,
311
+				"schedule":       schedule,
312
+				//"consumables":    consumables,
313
+				"prescription": vlist,
314
+				"reducelist":   clist,
315
+			})
316
+			return
317
+
318
+		} else {
319
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
320
+			return
321
+		}
322
+	} else if err != nil {
323
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
324
+		return
325
+
326
+	}
327
+
328
+}
329
+
330
+func (this *DialysisPrameterApiController) GetBatchCollection() {
331
+	timeLayout := "2006-01-02"
332
+	loc, _ := time.LoadLocation("Local")
333
+	adminUser := this.GetAdminUserInfo()
334
+	orgId := adminUser.CurrentOrgId
335
+	fmt.Println(orgId)
336
+	start_time := this.GetString("startime")
337
+	startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
338
+	endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 23:59:59", loc)
339
+	schIDStr := this.GetString("ids")
340
+	//获取透析耗材数据
341
+	consumables, err := service.GetDialysisConsumables(startime.Unix(), endtime.Unix(), orgId)
342
+
343
+	if len(schIDStr) == 0 {
344
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
345
+		return
346
+	}
347
+	idStrs := strings.Split(schIDStr, ",")
348
+	fmt.Println(idStrs)
349
+	var vlist []interface{}
350
+	var clist []interface{}
351
+	schedule, err := service.GetBatchCollection(orgId, idStrs)
352
+	for _, item := range schedule {
353
+		//查询当前日期的病人是否存在数据
354
+		_, errcode := service.GetToDayDialysisPrescription(item.PatientId, orgId, startime.Unix())
355
+		if errcode == gorm.ErrRecordNotFound {
356
+			//查询每个病人透析处方的最后一次数据
357
+			prescription, _ := service.GetLastDialysisPrescription(item.PatientId, orgId)
358
+			vlist = append(vlist, prescription)
359
+		} else if errcode == nil {
360
+			//获取当前日期
361
+			prescription, _ := service.GetDialysisPrescriptionList(item.PatientId, orgId, startime.Unix())
362
+			vlist = append(vlist, prescription)
363
+		}
364
+
365
+		//查询每个病人当前日期是否存在数据
366
+		_, errco := service.GetAotoMaticReduceByPatientId(item.PatientId, orgId, startime.Unix(), endtime.Unix())
367
+		fmt.Println("errco", errco)
368
+		if errco == gorm.ErrRecordNotFound {
369
+			reduece, _ := service.GetMaticReduece(item.PatientId, orgId)
370
+			clist = append(clist, reduece)
371
+		} else if errco == nil {
372
+			reduece, _ := service.GetMaticeReduceByPatientId(item.PatientId, orgId, startime.Unix(), endtime.Unix())
373
+			clist = append(clist, reduece)
374
+		}
375
+
376
+	}
377
+	if err == nil {
378
+		this.ServeSuccessJSON(map[string]interface{}{
379
+			"schedule":     schedule,
380
+			"consumables":  consumables,
381
+			"prescripiton": vlist,
382
+			"reducelist":   clist,
383
+		})
384
+	}
385
+}
386
+
387
+func (this *DialysisPrameterApiController) GetGatherList() {
388
+
389
+	timeLayout := "2006-01-02"
390
+	loc, _ := time.LoadLocation("Local")
391
+	adminUser := this.GetAdminUserInfo()
392
+	orgId := adminUser.CurrentOrgId
393
+	fmt.Println(orgId)
394
+	start_time := this.GetString("start_time")
395
+	end_time := this.GetString("end_time")
396
+	startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
397
+	endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
398
+	fmt.Println("开始时间", startime)
399
+	fmt.Println("结束时间", endtime)
400
+
401
+	warehouselist, err := service.GetWareHouseOutList(startime.Unix(), endtime.Unix(), orgId)
402
+
403
+	//获取透析耗材数据
404
+	consumables, err := service.GetDialysisConsumables(startime.Unix(), endtime.Unix(), orgId)
405
+
406
+	//统计抗凝剂数据
407
+	count, err := service.GetAnticoagulantCount(startime.Unix(), endtime.Unix(), orgId)
408
+
409
+	if err == nil {
410
+		this.ServeSuccessJSON(map[string]interface{}{
411
+			"warehouselist": warehouselist,
412
+			"consumables":   consumables,
413
+			"count":         count,
414
+		})
415
+	}
416
+}
417
+
418
+func (this *DialysisPrameterApiController) GetAnticoagulantCount() {
419
+	timeLayout := "2006-01-02"
420
+	loc, _ := time.LoadLocation("Local")
421
+	adminUser := this.GetAdminUserInfo()
422
+	orgId := adminUser.CurrentOrgId
423
+	fmt.Println(orgId)
424
+	start_time := this.GetString("start_time")
425
+	end_time := this.GetString("end_time")
426
+	startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
427
+	endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
428
+	fmt.Println("开始时间2222", startime)
429
+	fmt.Println("结束时间3333", endtime)
430
+	//统计抗凝剂数据
431
+	count, err := service.GetAnticoagulantCount(startime.Unix(), endtime.Unix(), orgId)
432
+	if err == nil {
433
+		this.ServeSuccessJSON(map[string]interface{}{
434
+			"count": count,
435
+		})
436
+	}
437
+}

File diff suppressed because it is too large
+ 1366 - 0
controllers/dialysis_record_api_controller.go


+ 25 - 0
controllers/district_api_controller.go View File

@@ -0,0 +1,25 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/service"
5
+
6
+	"github.com/astaxie/beego"
7
+)
8
+
9
+type DistrictApiController struct {
10
+	BaseAuthAPIController
11
+}
12
+
13
+func DistrictApiRegistRouters() {
14
+	beego.Router("/api/district/getdistrictsbyupid", &DistrictApiController{}, "get:GetDistrictsByUpid")
15
+}
16
+
17
+func (c *DistrictApiController) GetDistrictsByUpid() {
18
+	id, _ := c.GetInt64("id", 0)
19
+	citys, _ := service.GetDistrictsByUpid(id)
20
+
21
+	c.ServeSuccessJSON(map[string]interface{}{
22
+		"citys": citys,
23
+	})
24
+	return
25
+}

+ 658 - 0
controllers/doctor_schedule_api_controller.go View File

@@ -0,0 +1,658 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/models"
6
+	"Xcx_New/service"
7
+	"fmt"
8
+	"github.com/astaxie/beego"
9
+	"github.com/jinzhu/gorm"
10
+	"time"
11
+)
12
+
13
+type DoctorScheduleApiController struct {
14
+	BaseAuthAPIController
15
+}
16
+
17
+func DoctorScheduleRouters() {
18
+
19
+	beego.Router("/api/schedules/savedoctorschedules", &DoctorScheduleApiController{}, "Get:SaveDoctorSchedules")
20
+	beego.Router("/api/schedules/getdoctorschedulelist", &DoctorScheduleApiController{}, "Get:GetDoctorScheduleList")
21
+	beego.Router("/api/schedules/getscheduledetail", &DoctorScheduleApiController{}, "Get:GetScheduleDetail")
22
+	beego.Router("/api/schedules/updateschedule", &DoctorScheduleApiController{}, "Get:UpdateSchedule")
23
+	beego.Router("/api/schedule/deleteschedule", &DoctorScheduleApiController{}, "Get:DeleteSchedule")
24
+	beego.Router("/api/schedule/getdoctorlist", &DoctorScheduleApiController{}, "Get:GetDoctorList")
25
+	beego.Router("/api/schedule/getschedulelist", &DoctorScheduleApiController{}, "Get:GetScheduleList")
26
+	beego.Router("/api/schedule/addschedule", &DoctorScheduleApiController{}, "Get:AddSchedule")
27
+	beego.Router("/api/schedule/getstaffschedulelist", &DoctorScheduleApiController{}, "Get:GetStaffScheduleList")
28
+	beego.Router("/api/schedule/getnextweeklist", &DoctorScheduleApiController{}, "Get:GetNextWeekList")
29
+	beego.Router("/api/schedule/getschedulebydoctorid", &DoctorScheduleApiController{}, "Get:GetScheduleByDoctorId")
30
+	beego.Router("/api/schedule/tosearchsechedulelist", &DoctorScheduleApiController{}, "Get:ToSearchScheduleList")
31
+	beego.Router("api/schedule/deletestaffschedule", &DoctorScheduleApiController{}, "Get:DeleteStaffSchedule")
32
+	beego.Router("/api/schedule/copystaffschedule", &DoctorScheduleApiController{}, "Get:CopyStaffSchedule")
33
+	beego.Router("/api/scheudle/updatecontinusschedule", &DoctorScheduleApiController{}, "Get:UpdateContinusSchedule")
34
+	beego.Router("/api/schedule/savenursesort", &DoctorScheduleApiController{}, "Get:SaveNureSort")
35
+	beego.Router("/api/schedule/saveisschedule", &DoctorScheduleApiController{}, "Get:SaveIsSchedule")
36
+	beego.Router("/api/schedule/getscheudlelisttotal", &DoctorScheduleApiController{}, "Get:GetScheduleListTotal")
37
+	beego.Router("/api/schedule/tosearchtotal", &DoctorScheduleApiController{}, "Get:ToSeachTotal")
38
+	beego.Router("/api/schedule/changeoption", &DoctorScheduleApiController{}, "Get:ChangeOption")
39
+	beego.Router("/api/schedule/getchartlist", &DoctorScheduleApiController{}, "Get:GetChartlist")
40
+
41
+}
42
+
43
+func (this *DoctorScheduleApiController) SaveDoctorSchedules() {
44
+	adminUser := this.GetAdminUserInfo()
45
+	orgId := adminUser.CurrentOrgId
46
+	class_name := this.GetString("class_name")
47
+	class_attributes, _ := this.GetInt64("class_attributes")
48
+	timeone_start := this.GetString("timeone_start")
49
+	timeone_type, _ := this.GetInt64("timeone_type")
50
+	timeone_end := this.GetString("timeone_end")
51
+	timetwo_start := this.GetString("timetwo_start")
52
+	timetwo_type, _ := this.GetInt64("timetwo_type")
53
+	timetwo_end := this.GetString("timetwo_end")
54
+	work_time := this.GetString("work_time")
55
+	remarks := this.GetString("remarks")
56
+	minute, _ := this.GetInt64("minute")
57
+	schedules := models.DoctorSchedules{
58
+		ClassName:       class_name,
59
+		ClassAttributes: class_attributes,
60
+		TimeoneStart:    timeone_start,
61
+		TimeoneType:     timeone_type,
62
+		TimeoneEnd:      timeone_end,
63
+		TimetwoStart:    timetwo_start,
64
+		TimetwoEnd:      timetwo_end,
65
+		TimetwoType:     timetwo_type,
66
+		WorkTime:        work_time,
67
+		Remarks:         remarks,
68
+		UserOrgId:       orgId,
69
+		Status:          1,
70
+		Ctime:           time.Now().Unix(),
71
+		Minute:          minute,
72
+	}
73
+
74
+	//查询班种名称是否存在
75
+	_, errcode := service.GetClassName(orgId, class_name)
76
+	//如果不存在
77
+	if errcode == gorm.ErrRecordNotFound {
78
+		err := service.CreateDotorSchedule(&schedules)
79
+		if err != nil {
80
+			this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
81
+			return
82
+		}
83
+
84
+		this.ServeSuccessJSON(map[string]interface{}{
85
+			"schedules": schedules,
86
+		})
87
+	} else if errcode == nil {
88
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "班种名称已存在")
89
+		return
90
+	}
91
+
92
+}
93
+
94
+func (this *DoctorScheduleApiController) GetDoctorScheduleList() {
95
+	adminUserInfo := this.GetAdminUserInfo()
96
+	orgId := adminUserInfo.CurrentOrgId
97
+	page, _ := this.GetInt64("page")
98
+	limit, _ := this.GetInt64("limit")
99
+	schedules, total, err := service.GetDoctorScheduleList(orgId, page, limit)
100
+	if err != nil {
101
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
102
+		return
103
+	}
104
+
105
+	this.ServeSuccessJSON(map[string]interface{}{
106
+		"schedules": schedules,
107
+		"total":     total,
108
+	})
109
+	//查询该机构是否有班种,如果没有去读系统默认的
110
+	//_, errcode := service.GetDoctorScheduleByOrgId(orgId)
111
+	//if errcode == gorm.ErrRecordNotFound{
112
+	//  schedules, total, err := service.GetDoctorScheduleList(0,page, limit)
113
+	//  if err != nil {
114
+	//    this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
115
+	//    return
116
+	//  }
117
+	//
118
+	//  this.ServeSuccessJSON(map[string]interface{}{
119
+	//    "schedules": schedules,
120
+	//    "total":total,
121
+	//  })
122
+	//}else if errcode == nil{
123
+	//  schedules, total, err := service.GetDoctorScheduleList(orgId, page, limit)
124
+	//  if err != nil {
125
+	//    this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
126
+	//    return
127
+	//  }
128
+	//
129
+	//  this.ServeSuccessJSON(map[string]interface{}{
130
+	//    "schedules": schedules,
131
+	//    "total":total,
132
+	//  })
133
+	//}
134
+}
135
+
136
+func (this *DoctorScheduleApiController) GetScheduleDetail() {
137
+
138
+	id, _ := this.GetInt64("id")
139
+	scheduleDetail, err := service.GetScheduleDetail(id)
140
+	if err != nil {
141
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
142
+		return
143
+	}
144
+
145
+	this.ServeSuccessJSON(map[string]interface{}{
146
+		"scheduleDetail": scheduleDetail,
147
+	})
148
+}
149
+
150
+func (this *DoctorScheduleApiController) UpdateSchedule() {
151
+
152
+	id, _ := this.GetInt64("id")
153
+	class_name := this.GetString("class_name")
154
+	class_attributes, _ := this.GetInt64("class_attributes")
155
+	timeone_start := this.GetString("timeone_start")
156
+	timeone_type, _ := this.GetInt64("timeone_type")
157
+	timeone_end := this.GetString("timeone_end")
158
+	timetwo_start := this.GetString("timetwo_start")
159
+	timetwo_type, _ := this.GetInt64("timetwo_type")
160
+	timetwo_end := this.GetString("timetwo_end")
161
+	work_time := this.GetString("work_time")
162
+	remarks := this.GetString("remarks")
163
+	user_org_id, _ := this.GetInt64("user_org_id")
164
+	minute, _ := this.GetInt64("minute")
165
+	schedules := models.DoctorSchedules{
166
+		ClassName:       class_name,
167
+		ClassAttributes: class_attributes,
168
+		TimeoneStart:    timeone_start,
169
+		TimeoneType:     timeone_type,
170
+		TimeoneEnd:      timeone_end,
171
+		TimetwoStart:    timetwo_start,
172
+		TimetwoEnd:      timetwo_end,
173
+		TimetwoType:     timetwo_type,
174
+		WorkTime:        work_time,
175
+		Remarks:         remarks,
176
+		Minute:          minute,
177
+	}
178
+
179
+	if user_org_id == 0 {
180
+		err := service.CreateDotorSchedule(&schedules)
181
+		if err != nil {
182
+			this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
183
+			return
184
+		}
185
+	} else {
186
+		//查询是否班种名称已存在
187
+		scheduledata, _ := service.GetClassNameIsExsit(class_name, user_org_id, id)
188
+
189
+		if scheduledata.ID > 0 && scheduledata.ID != id {
190
+			this.ServeFailJsonSend(enums.ErrorCodeDataException, "班种名称已存在")
191
+			return
192
+		}
193
+
194
+		err := service.UpdateScheduleList(id, &schedules)
195
+		if err != nil {
196
+			this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
197
+			return
198
+		}
199
+	}
200
+	this.ServeSuccessJSON(map[string]interface{}{
201
+		"schedules": schedules,
202
+	})
203
+}
204
+
205
+func (this *DoctorScheduleApiController) DeleteSchedule() {
206
+	adminUserInfo := this.GetAdminUserInfo()
207
+	orgId := adminUserInfo.CurrentOrgId
208
+	id, _ := this.GetInt64("id")
209
+	//产寻该班种是否存在排班,如果存在不能删除
210
+	_, errcode := service.GetStaffScheduleByScheduleType(id, orgId)
211
+	if errcode == gorm.ErrRecordNotFound {
212
+		err := service.DeleteScheduleById(id)
213
+		if err != nil {
214
+			this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
215
+			return
216
+		}
217
+		returnData := make(map[string]interface{}, 0)
218
+		returnData["msg"] = "ok"
219
+		this.ServeSuccessJSON(returnData)
220
+		return
221
+	} else if errcode == nil {
222
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "该班种已存在排班,不能删除")
223
+		return
224
+	}
225
+
226
+}
227
+
228
+func (this *DoctorScheduleApiController) GetDoctorList() {
229
+
230
+	orgId := this.GetAdminUserInfo().CurrentOrgId
231
+	appId := this.GetAdminUserInfo().CurrentAppId
232
+	//admin_user_id := this.GetAdminUserInfo().AdminUser.Id
233
+	list, err := service.GetDoctorList(orgId, appId)
234
+
235
+	//获取所有的医生
236
+	doctorList, err := service.GetAllDoctorList(orgId, appId)
237
+
238
+	//获取所有的护士
239
+	nurseList, err := service.GetAllNurseList(orgId, appId)
240
+	if err != nil {
241
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
242
+		return
243
+	}
244
+
245
+	this.ServeSuccessJSON(map[string]interface{}{
246
+		"list":       list,
247
+		"doctorlist": doctorList,
248
+		"nurselist":  nurseList,
249
+	})
250
+}
251
+
252
+func (this *DoctorScheduleApiController) GetScheduleList() {
253
+
254
+	orgId := this.GetAdminUserInfo().CurrentOrgId
255
+	_, errcode := service.GetDoctorScheduleByOrgId(orgId)
256
+	if errcode == gorm.ErrRecordNotFound {
257
+		scheduleList, err := service.GetScheduleList(0)
258
+		if err != nil {
259
+			this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
260
+			return
261
+		}
262
+
263
+		this.ServeSuccessJSON(map[string]interface{}{
264
+			"scheduleList": scheduleList,
265
+		})
266
+	} else {
267
+		scheduleList, err := service.GetScheduleList(orgId)
268
+		if err != nil {
269
+			this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
270
+			return
271
+		}
272
+
273
+		this.ServeSuccessJSON(map[string]interface{}{
274
+			"scheduleList": scheduleList,
275
+		})
276
+	}
277
+}
278
+
279
+func (this *DoctorScheduleApiController) AddSchedule() {
280
+
281
+	orgId := this.GetAdminUserInfo().CurrentOrgId
282
+	doctor_id, _ := this.GetInt64("doctor_id")
283
+	fmt.Println("doctor_id", doctor_id)
284
+	doctor_type, _ := this.GetInt64("doctor_type")
285
+	fmt.Println("doctor_type", doctor_type)
286
+	start_time, _ := this.GetInt64("start_time")
287
+	fmt.Println("start_time", start_time)
288
+	end_time, _ := this.GetInt64("end_time")
289
+	fmt.Println("end_time", end_time)
290
+	schedule_type, _ := this.GetInt64("schedule_type")
291
+	fmt.Println("schedule_type", schedule_type)
292
+	schedule_week, _ := this.GetInt64("schedule_week")
293
+	fmt.Println("schedule_week", schedule_week)
294
+	schedule_date, _ := this.GetInt64("schedule_date")
295
+	schedule := models.StaffSchedule{
296
+		DoctorId:     doctor_id,
297
+		DoctorType:   doctor_type,
298
+		ScheduleType: schedule_type,
299
+		ScheduleWeek: schedule_week,
300
+		UserOrgId:    orgId,
301
+		StartTime:    start_time,
302
+		EndTime:      end_time,
303
+		Status:       1,
304
+		Ctime:        time.Now().Unix(),
305
+		ScheduleDate: schedule_date,
306
+	}
307
+
308
+	_, errcode := service.GetScheduleListDetail(doctor_id, orgId, schedule_date)
309
+	fmt.Println("errcode-----", errcode)
310
+	if errcode == gorm.ErrRecordNotFound {
311
+		err := service.AddSchedule(&schedule)
312
+		if err != nil {
313
+			this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
314
+			return
315
+		}
316
+
317
+		this.ServeSuccessJSON(map[string]interface{}{
318
+			"schedule": schedule,
319
+		})
320
+	} else if errcode == nil {
321
+		schedules, _ := service.GetScheduleListDetail(doctor_id, orgId, schedule_date)
322
+		err := service.UpdateStaffList(&schedule, schedules.ID)
323
+		if err != nil {
324
+			this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
325
+			return
326
+		}
327
+
328
+		this.ServeSuccessJSON(map[string]interface{}{
329
+			"schedule": schedule,
330
+		})
331
+	}
332
+
333
+}
334
+
335
+func (this *DoctorScheduleApiController) GetStaffScheduleList() {
336
+
337
+	start_time, _ := this.GetInt64("start_time")
338
+	fmt.Println("start_time", start_time)
339
+	end_time, _ := this.GetInt64("end_time")
340
+	fmt.Println("end_time", end_time)
341
+	orgId := this.GetAdminUserInfo().CurrentOrgId
342
+	staffList, err := service.GetStaffScheduleList(orgId, start_time, end_time)
343
+	if err != nil {
344
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
345
+		return
346
+	}
347
+
348
+	this.ServeSuccessJSON(map[string]interface{}{
349
+		"staffList": staffList,
350
+	})
351
+}
352
+
353
+func (this *DoctorScheduleApiController) GetNextWeekList() {
354
+	start_time, _ := this.GetInt64("start_time")
355
+	fmt.Println("start_time", start_time)
356
+	end_time, _ := this.GetInt64("end_time")
357
+	fmt.Println("end_time", end_time)
358
+	orgId := this.GetAdminUserInfo().CurrentOrgId
359
+	staffList, err := service.GetStaffScheduleList(orgId, start_time, end_time)
360
+	if err != nil {
361
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
362
+		return
363
+	}
364
+
365
+	this.ServeSuccessJSON(map[string]interface{}{
366
+		"staffList": staffList,
367
+	})
368
+}
369
+
370
+func (this *DoctorScheduleApiController) GetScheduleByDoctorId() {
371
+
372
+	doctor_id, _ := this.GetInt64("doctor_id")
373
+	start_time, _ := this.GetInt64("start_time")
374
+	end_time, _ := this.GetInt64("end_time")
375
+	orgId := this.GetAdminUserInfo().CurrentOrgId
376
+	staffList, err := service.GetScheduleByDoctorId(doctor_id, start_time, end_time, orgId)
377
+	if err != nil {
378
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
379
+		return
380
+	}
381
+
382
+	this.ServeSuccessJSON(map[string]interface{}{
383
+		"staffList": staffList,
384
+	})
385
+}
386
+
387
+func (this *DoctorScheduleApiController) ToSearchScheduleList() {
388
+
389
+	//doctor_id, _ := this.GetInt64("doctor_id")
390
+	user_name := this.GetString("user_name")
391
+	start_time, _ := this.GetInt64("start_time")
392
+	end_time, _ := this.GetInt64("end_time")
393
+	orgId := this.GetAdminUserInfo().CurrentOrgId
394
+	staffList, err := service.ToSearchSeacheduleList(user_name, start_time, end_time, orgId)
395
+	if err != nil {
396
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
397
+		return
398
+	}
399
+
400
+	this.ServeSuccessJSON(map[string]interface{}{
401
+		"staffList": staffList,
402
+	})
403
+}
404
+
405
+func (this *DoctorScheduleApiController) DeleteStaffSchedule() {
406
+	adminUserInfo := this.GetAdminUserInfo()
407
+	orgId := adminUserInfo.CurrentOrgId
408
+	start_time, _ := this.GetInt64("start_time")
409
+	fmt.Println("start_time", start_time)
410
+	end_time, _ := this.GetInt64("end_time")
411
+	err := service.DeleteStaffSchedule(orgId, start_time, end_time)
412
+	if err != nil {
413
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
414
+		return
415
+	}
416
+	returnData := make(map[string]interface{}, 0)
417
+	returnData["msg"] = "ok"
418
+	this.ServeSuccessJSON(returnData)
419
+	return
420
+}
421
+
422
+func (this *DoctorScheduleApiController) CopyStaffSchedule() {
423
+
424
+	adminUserInfo := this.GetAdminUserInfo()
425
+	orgId := adminUserInfo.CurrentOrgId
426
+	start_time, _ := this.GetInt64("start_time")
427
+	fmt.Println("start_time", start_time)
428
+	end_time, _ := this.GetInt64("end_time")
429
+	fmt.Println("end_time", end_time)
430
+	copy_startime, _ := this.GetInt64("copy_startime")
431
+	fmt.Println("copy_startime", copy_startime)
432
+	copy_endtime, _ := this.GetInt64("copy_endtime")
433
+	schedule, err := service.GetStaffScheduleListTwo(orgId, start_time, end_time)
434
+	//查询选中日期的排班是否存在
435
+	_, errcode := service.GetNextWeekSchedule(orgId, copy_startime, copy_endtime)
436
+	if errcode == gorm.ErrRecordNotFound {
437
+		for _, item := range schedule {
438
+			//fmt.Println(item.StartTime+604800)
439
+			//礼拜1
440
+			if item.ScheduleWeek == 1 {
441
+				item.ScheduleDate = copy_startime
442
+			}
443
+			if item.ScheduleWeek == 2 {
444
+				item.ScheduleDate = copy_startime + 86400
445
+			}
446
+			if item.ScheduleWeek == 3 {
447
+				item.ScheduleDate = copy_startime + 172800
448
+			}
449
+			if item.ScheduleWeek == 4 {
450
+				item.ScheduleDate = copy_startime + 259200
451
+			}
452
+			if item.ScheduleWeek == 5 {
453
+				item.ScheduleDate = copy_startime + 345600
454
+			}
455
+
456
+			if item.ScheduleWeek == 6 {
457
+				item.ScheduleDate = copy_startime + 432000
458
+			}
459
+			//礼拜天
460
+			if item.ScheduleWeek == 0 {
461
+				item.ScheduleDate = copy_endtime
462
+			}
463
+			staffSchedule := models.StaffSchedule{
464
+				DoctorId:     item.DoctorId,
465
+				DoctorType:   item.DoctorType,
466
+				ScheduleType: item.ScheduleType,
467
+				ScheduleWeek: item.ScheduleWeek,
468
+				UserOrgId:    item.UserOrgId,
469
+				StartTime:    copy_startime,
470
+				EndTime:      copy_endtime,
471
+				Status:       1,
472
+				Ctime:        time.Now().Unix(),
473
+				ScheduleDate: item.ScheduleDate,
474
+			}
475
+			service.AddSchedule(&staffSchedule)
476
+		}
477
+		if err != nil {
478
+			this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
479
+			return
480
+		}
481
+		returnData := make(map[string]interface{}, 0)
482
+		returnData["msg"] = "ok"
483
+		this.ServeSuccessJSON(returnData)
484
+		return
485
+	} else if errcode == nil {
486
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "排班数据已存在")
487
+		fmt.Print("下周排班已存在")
488
+		return
489
+	}
490
+
491
+}
492
+
493
+func (this *DoctorScheduleApiController) UpdateContinusSchedule() {
494
+	adminUserInfo := this.GetAdminUserInfo()
495
+	orgId := adminUserInfo.CurrentOrgId
496
+	is_status, _ := this.GetInt64("is_status")
497
+	fmt.Println("is_status", is_status)
498
+	schedule := models.ContinueSchedule{
499
+		IsStatus: is_status,
500
+	}
501
+	err := service.UpdateContinusSchedule(&schedule, orgId)
502
+	if err != nil {
503
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
504
+		return
505
+	}
506
+
507
+	this.ServeSuccessJSON(map[string]interface{}{
508
+		"schedule": schedule,
509
+	})
510
+}
511
+
512
+func (this *DoctorScheduleApiController) SaveNureSort() {
513
+
514
+	id, _ := this.GetInt64("id")
515
+	fmt.Println("id", id)
516
+	sort, _ := this.GetInt64("sort")
517
+	fmt.Println("sort", sort)
518
+	role := models.App_Role{
519
+		Sort: sort,
520
+	}
521
+	err := service.SaveNurseSort(&role, id)
522
+	if err != nil {
523
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
524
+		return
525
+	}
526
+
527
+	this.ServeSuccessJSON(map[string]interface{}{
528
+		"role": role,
529
+	})
530
+}
531
+
532
+func (this *DoctorScheduleApiController) SaveIsSchedule() {
533
+
534
+	id, _ := this.GetInt64("id")
535
+	fmt.Println("id", id)
536
+	is_sort, _ := this.GetInt64("is_sort")
537
+	fmt.Println("is_sort", is_sort)
538
+	role := models.App_Role{
539
+		IsSort: is_sort,
540
+	}
541
+	err := service.SaveIsSchedule(id, &role)
542
+	if err != nil {
543
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
544
+		return
545
+	}
546
+
547
+	this.ServeSuccessJSON(map[string]interface{}{
548
+		"role": role,
549
+	})
550
+}
551
+
552
+func (this *DoctorScheduleApiController) GetScheduleListTotal() {
553
+
554
+	start_time, _ := this.GetInt64("start_time")
555
+	fmt.Println(start_time)
556
+	end_time, _ := this.GetInt64("end_time")
557
+	fmt.Println("end_time", end_time)
558
+	adminUserInfo := this.GetAdminUserInfo()
559
+	orgId := adminUserInfo.CurrentOrgId
560
+	//统计班次
561
+	scheudletotal, err := service.GetScheduleListTotal(orgId, start_time, end_time)
562
+	//统计总工时
563
+	list, err := service.GetTotalMinutes(orgId, start_time, end_time)
564
+	//统计出勤天数
565
+	workDay, err := service.GetTotalWorkDay(orgId, start_time, end_time)
566
+	//统计缺勤天数
567
+	noWorkDay, err := service.GetTotalNoWorkDay(orgId, start_time, end_time)
568
+	if err != nil {
569
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
570
+		return
571
+	}
572
+
573
+	this.ServeSuccessJSON(map[string]interface{}{
574
+		"scheudletotal": scheudletotal,
575
+		"list":          list,
576
+		"workDay":       workDay,
577
+		"noWorkDay":     noWorkDay,
578
+	})
579
+}
580
+
581
+func (this *DoctorScheduleApiController) ToSeachTotal() {
582
+	start_time, _ := this.GetInt64("start_time")
583
+	end_time, _ := this.GetInt64("end_time")
584
+	adminUserInfo := this.GetAdminUserInfo()
585
+	orgId := adminUserInfo.CurrentOrgId
586
+	keyword := this.GetString("keyword")
587
+	//统计表
588
+	scheduletotal, err := service.GetSearchScheduleListTotal(orgId, start_time, end_time, keyword)
589
+	list, err := service.GeSearchtTotalMinutes(orgId, start_time, end_time, keyword)
590
+	workDay, err := service.GetSearchWorkDay(orgId, start_time, end_time, keyword)
591
+	noWorkDay, err := service.GetSearchWorkNoDay(orgId, start_time, end_time, keyword)
592
+
593
+	//统计图
594
+	chartTotalMinute, err := service.GetChartTotalMinutesOne(orgId, start_time, end_time, keyword)
595
+	chartWorkDayMinute, err := service.GetChartTotalMinutesTwo(orgId, start_time, end_time, keyword)
596
+
597
+	if err != nil {
598
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
599
+		return
600
+	}
601
+	this.ServeSuccessJSON(map[string]interface{}{
602
+		"scheduletotal":      scheduletotal,
603
+		"list":               list,
604
+		"workDay":            workDay,
605
+		"noWorkDay":          noWorkDay,
606
+		"chartTotalMinute":   chartTotalMinute,
607
+		"chartWorkDayMinute": chartWorkDayMinute,
608
+	})
609
+}
610
+
611
+func (this *DoctorScheduleApiController) ChangeOption() {
612
+
613
+	start_time, _ := this.GetInt64("start_time")
614
+	end_time, _ := this.GetInt64("end_time")
615
+	adminUserInfo := this.GetAdminUserInfo()
616
+	orgId := adminUserInfo.CurrentOrgId
617
+	doctor_type, _ := this.GetInt64("doctor_type")
618
+	//统计图
619
+	scheduletotal, err := service.ChagneScheduleListTotal(orgId, start_time, end_time, doctor_type)
620
+	list, err := service.ChangeScheduleMinute(orgId, start_time, end_time, doctor_type)
621
+	workday, err := service.ChangeWorkDay(orgId, start_time, end_time, doctor_type)
622
+	worknoday, err := service.ChangeNoWorkDay(orgId, start_time, end_time, doctor_type)
623
+
624
+	//统计表
625
+	chartotalminute, err := service.ChartTotalMinute(orgId, start_time, end_time, doctor_type)
626
+	chartworkdayminute, err := service.ChartWorkDayMinute(orgId, start_time, end_time, doctor_type)
627
+	if err != nil {
628
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
629
+		return
630
+	}
631
+	this.ServeSuccessJSON(map[string]interface{}{
632
+		"scheduletotal":      scheduletotal,
633
+		"list":               list,
634
+		"workday":            workday,
635
+		"worknoday":          worknoday,
636
+		"chartotalminute":    chartotalminute,
637
+		"chartworkdayminute": chartworkdayminute,
638
+	})
639
+}
640
+
641
+func (this *DoctorScheduleApiController) GetChartlist() {
642
+	start_time, _ := this.GetInt64("start_time")
643
+	end_time, _ := this.GetInt64("end_time")
644
+	adminUserInfo := this.GetAdminUserInfo()
645
+	orgId := adminUserInfo.CurrentOrgId
646
+	//统计总工时
647
+	list, err := service.GetTotalMinutesOne(orgId, start_time, end_time)
648
+	//统计出勤的总工时
649
+	workDaylist, err := service.GetTotalMinutesTwo(orgId, start_time, end_time)
650
+	if err != nil {
651
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
652
+		return
653
+	}
654
+	this.ServeSuccessJSON(map[string]interface{}{
655
+		"list":        list,
656
+		"workDaylist": workDaylist,
657
+	})
658
+}

File diff suppressed because it is too large
+ 1111 - 0
controllers/doctors_api_controller.go


File diff suppressed because it is too large
+ 3050 - 0
controllers/drug_stock_api_contorller.go


+ 472 - 0
controllers/gdyb_controller.go View File

@@ -0,0 +1,472 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/models"
5
+	"Xcx_New/service"
6
+	"Xcx_New/utils"
7
+	"encoding/json"
8
+	"fmt"
9
+	"github.com/astaxie/beego"
10
+	"io/ioutil"
11
+)
12
+
13
+type GdybController struct {
14
+	BaseAuthAPIController
15
+}
16
+
17
+func GdybRegistRouters() {
18
+	beego.Router("/gdyb/one", &GdybController{}, "get:PostOne")
19
+	beego.Router("/gdyb/two", &GdybController{}, "get:PostTwo")
20
+	beego.Router("/gdyb/three", &GdybController{}, "get:PostThree")
21
+	beego.Router("/gdyb/four", &GdybController{}, "get:PostFour")
22
+	beego.Router("/gdyb/five", &GdybController{}, "post:PostFive")
23
+	beego.Router("/gdyb/six", &GdybController{}, "get:PostSix")
24
+	beego.Router("/gdyb/seven", &GdybController{}, "get:PostSeven")
25
+	beego.Router("/gdyb/eight", &GdybController{}, "get:PostEight")
26
+	beego.Router("/gdyb/nine", &GdybController{}, "get:PostNine")
27
+	beego.Router("/gdyb/ten", &GdybController{}, "get:PostTen")
28
+	beego.Router("/gdyb/eleven", &GdybController{}, "get:PostEleven")
29
+	beego.Router("/gdyb/twelve", &GdybController{}, "get:PostTwelve")
30
+
31
+}
32
+
33
+type Result struct {
34
+	ErrMsg      interface{} `json:"err_msg"`
35
+	InfRefmsgid string      `json:"inf_refmsgid"`
36
+	Infcode     int64       `json:"infcode"`
37
+	Output      struct {
38
+		Baseinfo struct {
39
+			Age         float64 `json:"age"`
40
+			Brdy        string  `json:"brdy"`
41
+			Certno      string  `json:"certno"`
42
+			Gend        string  `json:"gend"`
43
+			Naty        string  `json:"naty"`
44
+			PsnCertType string  `json:"psn_cert_type"`
45
+			PsnName     string  `json:"psn_name"`
46
+			PsnNo       string  `json:"psn_no"`
47
+		} `json:"baseinfo"`
48
+		Idetinfo []interface{} `json:"idetinfo"`
49
+		Iinfo    []struct {
50
+			Balc                   int64       `json:"balc"`
51
+			CvlservFlag            string      `json:"cvlserv_flag"`
52
+			EmpName                string      `json:"emp_name"`
53
+			InsuplcAdmdvs          string      `json:"insuplc_admdvs"`
54
+			Insutype               string      `json:"insutype"`
55
+			PausInsuDansuplcAdmdvs string      `json:"paus_insu_dansuplc_admdvs"`
56
+			PausInsuDate           interface{} `json:"paus_insu_date"`
57
+			PsnInsuDate            string      `json:"psn_insu_date"`
58
+			PsnInsuStas            string      `json:"psn_insu_stas"`
59
+			PsnType                string      `json:"psn_type"`
60
+		} `json:"iinfo"`
61
+	} `json:"output"`
62
+	RefmsgTime  string      `json:"refmsg_time"`
63
+	RespondTime string      `json:"respond_time"`
64
+	Signtype    interface{} `json:"signtype"`
65
+	WarnInfo    interface{} `json:"warn_info"`
66
+}
67
+
68
+func (c *GdybController) PostOne() {
69
+	certNo := c.GetString("cert_no")
70
+	org_name := c.GetString("org_name")
71
+	doctor := c.GetString("doctor")
72
+	fixmedins_code := c.GetString("fixmedins_code")
73
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
74
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
75
+	secret_key := c.GetString("secret_key")
76
+	result := service.Gdyb1101(certNo, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key)
77
+	var dat map[string]interface{}
78
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
79
+
80
+	} else {
81
+
82
+	}
83
+
84
+	c.ServeSuccessJSON(map[string]interface{}{
85
+		"pre": dat,
86
+	})
87
+}
88
+
89
+func (c *GdybController) PostTwo() {
90
+	psnNo := c.GetString("psn_no")
91
+	insutype := c.GetString("insutype")
92
+	certNo := c.GetString("cert_no")
93
+	org_name := c.GetString("org_name")
94
+	doctor := c.GetString("doctor")
95
+	ipt_otp_no := c.GetString("ipt_otp_no")
96
+	dept := c.GetString("dept")
97
+	fixmedins_code := c.GetString("fixmedins_code")
98
+
99
+	dept_code := c.GetString("dept_code")
100
+	doctor_id := c.GetString("doctor_id")
101
+
102
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
103
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
104
+
105
+	secret_key := c.GetString("secret_key")
106
+
107
+	result := service.Gdyb2201(psnNo, insutype, certNo, org_name, doctor, ipt_otp_no, dept, fixmedins_code, dept_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key)
108
+
109
+	var dat map[string]interface{}
110
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
111
+		//fmt.Println(dat["status"])
112
+	} else {
113
+	}
114
+
115
+	c.ServeSuccessJSON(map[string]interface{}{
116
+		"pre": dat,
117
+	})
118
+}
119
+
120
+func (c *GdybController) PostThree() {
121
+	psnNo := c.GetString("psn_no")
122
+	mdtrtId := c.GetString("mdtrt_id")
123
+	iptOtpNo := c.GetString("ipt_otp_no")
124
+	org_name := c.GetString("org_name")
125
+	doctor := c.GetString("doctor")
126
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
127
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
128
+	secret_key := c.GetString("secret_key")
129
+
130
+	result := service.Gdyb2202(psnNo, mdtrtId, iptOtpNo, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key)
131
+	c.ServeSuccessJSON(map[string]interface{}{
132
+		"pre": result,
133
+	})
134
+}
135
+
136
+func (c *GdybController) PostFour() {
137
+	psnNo := c.GetString("psn_no")
138
+	mdtrtId := c.GetString("mdtrt_id")
139
+	doctor := c.GetString("doctor")
140
+	department := c.GetString("department")
141
+	diag := c.GetString("diag")
142
+	org_name := c.GetString("org_name")
143
+	med_type := c.GetString("med_type")
144
+	doctor_id, _ := c.GetInt64("doctor_id", 0)
145
+	fixmedins_code := c.GetString("fixmedins_code")
146
+
147
+	diag_code := c.GetString("diag_code")
148
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
149
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
150
+	secret_key := c.GetString("secret_key")
151
+
152
+	result := service.Gdyb2203(psnNo, mdtrtId, doctor, department, diag, org_name, med_type, doctor_id, fixmedins_code, diag_code, insuplc_admdvs, mdtrtarea_admvs, secret_key)
153
+	var dat map[string]interface{}
154
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
155
+	} else {
156
+	}
157
+	c.ServeSuccessJSON(map[string]interface{}{
158
+		"pre": dat,
159
+	})
160
+}
161
+
162
+type All struct {
163
+	HisPrescription HisPrescription
164
+	mdtrt_id        string
165
+	psn_no          string
166
+}
167
+
168
+type HisPrescription struct {
169
+	ID                     int64                            `gorm:"column:id" json:"id" form:"id"`
170
+	UserOrgId              int64                            `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
171
+	RecordDate             int64                            `gorm:"column:record_date" json:"record_date" form:"record_date"`
172
+	PatientId              int64                            `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
173
+	HisPatientId           int64                            `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
174
+	Status                 int64                            `gorm:"column:status" json:"status" form:"status"`
175
+	Ctime                  int64                            `gorm:"column:ctime" json:"ctime" form:"ctime"`
176
+	Mtime                  int64                            `gorm:"column:mtime" json:"mtime" form:"mtime"`
177
+	Number                 string                           `gorm:"column:number" json:"number" form:"number"`
178
+	Type                   int64                            `gorm:"column:type" json:"type" form:"type"`
179
+	Doctor                 int64                            `gorm:"column:doctor" json:"doctor" form:"doctor"`
180
+	Creator                int64                            `gorm:"column:creator" json:"creator" form:"creator"`
181
+	Modifier               int64                            `gorm:"column:modifier" json:"modifier" form:"modifier"`
182
+	HisDoctorAdviceInfo    []*models.HisDoctorAdviceInfo    `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"advices"`
183
+	HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"project"`
184
+}
185
+
186
+func (c *GdybController) PostFive() {
187
+	body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
188
+	var respJSON map[string]interface{}
189
+	if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
190
+		utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
191
+		return
192
+	}
193
+	userJSONBytes, _ := json.Marshal(respJSON["pre"])
194
+	var hp []*models.HisPrescription
195
+	if err := json.Unmarshal(userJSONBytes, &hp); err != nil {
196
+		utils.ErrorLog("解析失败:%v", err)
197
+		return
198
+	}
199
+	fmt.Println(respJSON["psn_no"].(string))
200
+	fmt.Println(respJSON["mdtrt_id"].(string))
201
+
202
+	fmt.Println(respJSON["chrg_bchno"].(string))
203
+	fmt.Println(respJSON["org_name"].(string))
204
+	fmt.Println(respJSON["doctor"].(string))
205
+	fmt.Println(respJSON["dept"].(string))
206
+
207
+	fmt.Println(respJSON["fixmedins_code"].(string))
208
+	fmt.Println(respJSON["dept_code"].(string))
209
+	fmt.Println(respJSON["doctor_id"].(string))
210
+
211
+	fmt.Println(respJSON["insuplc_admdvs"].(string))
212
+	fmt.Println(respJSON["mdtrtarea_admvs"].(string))
213
+	fmt.Println(respJSON["secret_key"].(string))
214
+
215
+	result := service.Gdyb2204(respJSON["psn_no"].(string), respJSON["mdtrt_id"].(string), hp, respJSON["chrg_bchno"].(string), respJSON["org_name"].(string),
216
+		respJSON["doctor"].(string), respJSON["dept"].(string), respJSON["fixmedins_code"].(string), respJSON["dept_code"].(string), respJSON["doctor_id"].(string), respJSON["insuplc_admdvs"].(string), respJSON["mdtrtarea_admvs"].(string), respJSON["secret_key"].(string))
217
+
218
+	var dat map[string]interface{}
219
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
220
+		fmt.Println(dat)
221
+	} else {
222
+		fmt.Println(err)
223
+	}
224
+	c.ServeSuccessJSON(map[string]interface{}{
225
+		"pre": dat,
226
+	})
227
+}
228
+
229
+func (c *GdybController) PostSix() {
230
+	psnNo := c.GetString("psn_no")
231
+	mdtrtId := c.GetString("mdtrt_id")
232
+	chrgBchno := c.GetString("chrg_bchno")
233
+	org_name := c.GetString("org_name")
234
+	doctor := c.GetString("doctor")
235
+
236
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
237
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
238
+
239
+	secret_key := c.GetString("secret_key")
240
+	fixmedins_code := c.GetString("fixmedins_code")
241
+
242
+	result := service.Gdyb2205(psnNo, mdtrtId, chrgBchno, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code)
243
+	var dat map[string]interface{}
244
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
245
+		fmt.Println(dat)
246
+	} else {
247
+		fmt.Println(err)
248
+	}
249
+	c.ServeSuccessJSON(map[string]interface{}{
250
+		"pre": result,
251
+	})
252
+}
253
+
254
+func (c *GdybController) PostSeven() {
255
+	psnNo := c.GetString("psn_no")
256
+	mdtrtId := c.GetString("mdtrt_id")
257
+	chrgBchno := c.GetString("chrg_bchno")
258
+	certNo := c.GetString("cert_no")
259
+	insutype := c.GetString("insutype")
260
+	total := c.GetString("total")
261
+	org_name := c.GetString("org_name")
262
+	doctor := c.GetString("doctor")
263
+	secret_key := c.GetString("secret_key")
264
+
265
+	result := service.Gdyb2206(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, secret_key)
266
+	var dat map[string]interface{}
267
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
268
+		fmt.Println(dat)
269
+	} else {
270
+		fmt.Println(err)
271
+	}
272
+	c.ServeSuccessJSON(map[string]interface{}{
273
+		"pre": dat,
274
+	})
275
+}
276
+
277
+func (c *GdybController) PostEight() {
278
+	psnNo := c.GetString("psn_no")
279
+	mdtrtId := c.GetString("mdtrt_id")
280
+	chrgBchno := c.GetString("chrg_bchno")
281
+	certNo := c.GetString("cert_no")
282
+	insutype := c.GetString("insutype")
283
+	total := c.GetString("total")
284
+	org_name := c.GetString("org_name")
285
+	doctor := c.GetString("doctor")
286
+	fixmedins_code := c.GetString("fixmedins_code")
287
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
288
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
289
+	secret_key := c.GetString("secret_key")
290
+
291
+	result := service.Gdyb2207(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key)
292
+	var dat map[string]interface{}
293
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
294
+		fmt.Println(dat)
295
+	} else {
296
+		fmt.Println(err)
297
+	}
298
+
299
+	c.ServeSuccessJSON(map[string]interface{}{
300
+		"pre": dat,
301
+	})
302
+}
303
+
304
+func (c *GdybController) PostNine() {
305
+	psnNo := c.GetString("psn_no")
306
+	mdtrtId := c.GetString("mdtrt_id")
307
+	setlId := c.GetString("setl_id")
308
+	org_name := c.GetString("org_name")
309
+	doctor := c.GetString("doctor")
310
+	secret_key := c.GetString("secret_key")
311
+	fixmedins_code := c.GetString("fixmedins_code")
312
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
313
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
314
+	result := service.Gdyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
315
+	var dat map[string]interface{}
316
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
317
+		fmt.Println(dat)
318
+	} else {
319
+		fmt.Println(err)
320
+	}
321
+	c.ServeSuccessJSON(map[string]interface{}{
322
+		"pre": dat,
323
+	})
324
+}
325
+
326
+func (c *GdybController) PostTen() {
327
+	fmt.Println("11222333-----")
328
+
329
+	insutype := c.GetString("insutype")
330
+	clrType := c.GetString("clr_type")
331
+	setlOptins := c.GetString("setl_optins")
332
+	stmtBegndate := c.GetString("stmt_begndate")
333
+	stmtEnddate := c.GetString("stm_enddate")
334
+	medfeeSumamt, _ := c.GetFloat("medfee_sumamt", 0)
335
+	fundPaySumamt, _ := c.GetFloat("fund_pay_sumamt", 0)
336
+	acctPay, _ := c.GetFloat("acct_pay", 0)
337
+	fixmedinsSetlCnt, _ := c.GetInt64("fixmedins_setl_cnt", 0)
338
+	fixmedins_code := c.GetString("fixmedins_code")
339
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
340
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
341
+	secret_key := c.GetString("secret_key")
342
+	org_name := c.GetString("org_name")
343
+	doctor := c.GetString("doctor")
344
+
345
+	fmt.Println(insutype)
346
+	fmt.Println(clrType)
347
+	fmt.Println(setlOptins)
348
+	fmt.Println(stmtBegndate)
349
+	fmt.Println(stmtEnddate)
350
+	fmt.Println(medfeeSumamt)
351
+
352
+	baseParams := models.BaseParams{
353
+		SecretKey:      secret_key,
354
+		FixmedinsCode:  fixmedins_code,
355
+		InsuplcAdmdvs:  insuplc_admdvs,
356
+		MdtrtareaAdmvs: mdtrtarea_admvs,
357
+		OrgName:        org_name,
358
+		Doctor:         doctor,
359
+	}
360
+	businessParams := models.BusinessParams{
361
+		Insutype:         insutype,
362
+		ClrType:          clrType,
363
+		SetlOptins:       setlOptins,
364
+		StmtBegndate:     stmtBegndate,
365
+		StmtEnddate:      stmtEnddate,
366
+		MedfeeSumamt:     medfeeSumamt,
367
+		FundPaySumamt:    fundPaySumamt,
368
+		AcctPay:          acctPay,
369
+		FixmedinsSetlCnt: fixmedinsSetlCnt,
370
+	}
371
+	fmt.Println(baseParams)
372
+	fmt.Println(businessParams)
373
+
374
+	fmt.Println("11222333--33333---")
375
+
376
+	result := service.Gdyb3201(baseParams, businessParams)
377
+	fmt.Println("11222333--33333---555555")
378
+
379
+	var dat map[string]interface{}
380
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
381
+		fmt.Println(dat)
382
+	} else {
383
+		fmt.Println(err)
384
+	}
385
+	c.ServeSuccessJSON(map[string]interface{}{
386
+		"pre": dat,
387
+	})
388
+}
389
+
390
+func (c *GdybController) PostEleven() {
391
+	//fmt.Println("777777666666-----")
392
+	//
393
+	//file_byte := c.GetString("file_byte")
394
+	//file_name := c.GetString("file_name")
395
+	//fixmedins_code := c.GetString("fixmedins_code")
396
+	//insuplc_admdvs := c.GetString("insuplc_admdvs")
397
+	//mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
398
+	//secret_key := c.GetString("secret_key")
399
+	//org_name := c.GetString("org_name")
400
+	//doctor := c.GetString("doctor")
401
+	//
402
+	//baseParams := models.BaseParams{
403
+	//	SecretKey:      secret_key,
404
+	//	FixmedinsCode:  fixmedins_code,
405
+	//	InsuplcAdmdvs:  insuplc_admdvs,
406
+	//	MdtrtareaAdmvs: mdtrtarea_admvs,
407
+	//	OrgName:        org_name,
408
+	//	Doctor:         doctor,
409
+	//}
410
+
411
+	//x := (*[2]uintptr)(unsafe.Pointer(&file_byte))
412
+	//h := [3]uintptr{x[0], x[1], x[1]}
413
+	//bytes := *(*[]byte)(unsafe.Pointer(&h))
414
+
415
+	//result := service.Gdyb9101(baseParams, file_name, []byte(file_byte))
416
+	//var dat map[string]interface{}
417
+	//if err := json.Unmarshal([]byte(result), &dat); err == nil {
418
+	//	fmt.Println(dat)
419
+	//} else {
420
+	//	fmt.Println(err)
421
+	//}
422
+	//c.ServeSuccessJSON(map[string]interface{}{
423
+	//	"pre": dat,
424
+	//})
425
+}
426
+
427
+func (c *GdybController) PostTwelve() {
428
+	fileQuryNo := c.GetString("file_qury_no")
429
+	setlOptins := c.GetString("setl_optins")
430
+	stmtBegndate := c.GetString("stmt_begndate")
431
+	stmtEnddate := c.GetString("stm_enddate")
432
+	medfeeSumamt, _ := c.GetFloat("medfee_sumamt", 0)
433
+	fundPaySumamt, _ := c.GetFloat("fund_pay_sumamt", 0)
434
+	fixmedinsSetlCnt, _ := c.GetInt64("fixmedins_setl_cnt", 0)
435
+	fixmedins_code := c.GetString("fixmedins_code")
436
+	insuplc_admdvs := c.GetString("insuplc_admdvs")
437
+	mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
438
+	secret_key := c.GetString("secret_key")
439
+	org_name := c.GetString("org_name")
440
+	doctor := c.GetString("doctor")
441
+	cashPayamt, _ := c.GetFloat("cash_payamt", 0)
442
+
443
+	baseParams := models.BaseParams{
444
+		SecretKey:      secret_key,
445
+		FixmedinsCode:  fixmedins_code,
446
+		InsuplcAdmdvs:  insuplc_admdvs,
447
+		MdtrtareaAdmvs: mdtrtarea_admvs,
448
+		OrgName:        org_name,
449
+		Doctor:         doctor,
450
+	}
451
+	businessParams := models.BusinessParams{
452
+		FileQuryNo:       fileQuryNo,
453
+		SetlOptins:       setlOptins,
454
+		StmtBegndate:     stmtBegndate,
455
+		StmtEnddate:      stmtEnddate,
456
+		MedfeeSumamt:     medfeeSumamt,
457
+		FundPaySumamt:    fundPaySumamt,
458
+		FixmedinsSetlCnt: fixmedinsSetlCnt,
459
+		CashPayamt:       cashPayamt,
460
+	}
461
+
462
+	result := service.Gdyb3202(baseParams, businessParams)
463
+	var dat map[string]interface{}
464
+	if err := json.Unmarshal([]byte(result), &dat); err == nil {
465
+		fmt.Println(dat)
466
+	} else {
467
+		fmt.Println(err)
468
+	}
469
+	c.ServeSuccessJSON(map[string]interface{}{
470
+		"pre": dat,
471
+	})
472
+}

File diff suppressed because it is too large
+ 2202 - 0
controllers/gobal_config_api_controller.go


File diff suppressed because it is too large
+ 5181 - 0
controllers/his_api_controller.go


+ 411 - 0
controllers/his_config_api_controller.go View File

@@ -0,0 +1,411 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/models"
6
+	"Xcx_New/service"
7
+	"Xcx_New/utils"
8
+	"encoding/json"
9
+	"github.com/astaxie/beego"
10
+	"reflect"
11
+	"strconv"
12
+	"time"
13
+)
14
+
15
+type HisConfigApiController struct {
16
+	BaseAuthAPIController
17
+}
18
+
19
+func HisConfigApiRegistRouters() {
20
+	beego.Router("/api/his/patient/list", &HisConfigApiController{}, "get:GetAllHisPatientsList")
21
+	beego.Router("/api/his/prescriptiontemplate/list", &HisConfigApiController{}, "get:GetPrescriptionTemplateList")
22
+	beego.Router("/api/his/prescriptiontemplate/info", &HisConfigApiController{}, "get:GetPrescriptionTemplateInfo")
23
+	beego.Router("/api/his/prescriptiontemplate/create", &HisConfigApiController{}, "post:CreatePrescriptionTemplate")
24
+	beego.Router("/api/his/prescriptiontemplate/delete", &HisConfigApiController{}, "post:DeletePrescriptionTemplate")
25
+	beego.Router("/api/his/prescriptioninfotemplate/delete", &HisConfigApiController{}, "post:DeletePrescriptionInfoTemplate")
26
+	beego.Router("/api/his/advicetemplate/delete", &HisConfigApiController{}, "post:DeleteAdviceTemplate")
27
+	beego.Router("/api/his/projecttemplate/delete", &HisConfigApiController{}, "post:DeleteProjectTemplate")
28
+
29
+}
30
+
31
+func (c *HisConfigApiController) GetAllHisPatientsList() {
32
+	patients, _, _ := service.GetAllPatientList(c.GetAdminUserInfo().CurrentOrgId)
33
+	c.ServeSuccessJSON(map[string]interface{}{
34
+		"list": patients,
35
+	})
36
+}
37
+
38
+func (c *HisConfigApiController) GetPrescriptionTemplateList() {
39
+	patient_id, _ := c.GetInt64("patient_id", 0)
40
+	page, _ := c.GetInt64("page", 0)
41
+	limit, _ := c.GetInt64("limit", 0)
42
+
43
+	if page <= 0 {
44
+		page = 1
45
+	}
46
+	if limit <= 0 {
47
+		limit = 10
48
+	}
49
+	if patient_id <= 0 {
50
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
51
+		return
52
+	}
53
+
54
+	templates, total, _ := service.GetHisPrescriptionTemplatesList(patient_id, c.GetAdminUserInfo().CurrentOrgId, page, limit)
55
+
56
+	c.ServeSuccessJSON(map[string]interface{}{
57
+		"list":  templates,
58
+		"total": total,
59
+	})
60
+
61
+}
62
+
63
+func (c *HisConfigApiController) GetPrescriptionTemplateInfo() {
64
+	id, _ := c.GetInt64("id", 0)
65
+	template, _ := service.GetHisPrescriptionTemplateByID(id)
66
+	prescriptions, _ := service.GetHisPrescriptionTemplate(template.ID, c.GetAdminUserInfo().CurrentOrgId)
67
+
68
+	c.ServeSuccessJSON(map[string]interface{}{
69
+		"template":      template,
70
+		"prescriptions": prescriptions,
71
+	})
72
+}
73
+
74
+func (c *HisConfigApiController) CreatePrescriptionTemplate() {
75
+	id, _ := c.GetInt64("id")
76
+	name := c.GetString("name")
77
+	mode_id, _ := c.GetInt64("mode_id", 0)
78
+	types, _ := c.GetInt64("type", 0)
79
+	patient_id, _ := c.GetInt64("patient_id", 0)
80
+	types = 1
81
+	adminInfo := c.GetAdminUserInfo()
82
+
83
+	src_template, _ := service.GetHisPrescriptionTemplateByID(id)
84
+
85
+	if src_template.ID == 0 {
86
+		template := models.HisPrescriptionTemplate{
87
+			UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
88
+			PatientId: patient_id,
89
+			Type:      types,
90
+			Status:    1,
91
+			Ctime:     time.Now().Unix(),
92
+			Mtime:     time.Now().Unix(),
93
+			Name:      name,
94
+			Mode:      mode_id,
95
+		}
96
+		src_template = template
97
+		service.CreateHisPrescriptionTemplate(&src_template)
98
+	} else {
99
+		src_template.Name = name
100
+		src_template.Mode = mode_id
101
+		service.SaveHisPrescriptionTemplate(&src_template)
102
+	}
103
+
104
+	dataBody := make(map[string]interface{}, 0)
105
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
106
+	if err != nil {
107
+		utils.ErrorLog(err.Error())
108
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
109
+		return
110
+	}
111
+
112
+	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
113
+		prescriptions, _ := dataBody["prescriptions"].([]interface{})
114
+		if len(prescriptions) > 0 {
115
+			for _, item := range prescriptions {
116
+				items := item.(map[string]interface{})
117
+
118
+				if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
119
+					utils.ErrorLog("id")
120
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
121
+					return
122
+				}
123
+
124
+				id := int64(items["id"].(float64))
125
+
126
+				if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
127
+					utils.ErrorLog("type")
128
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
129
+					return
130
+				}
131
+				types := int64(items["type"].(float64))
132
+
133
+				if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
134
+					utils.ErrorLog("med_type")
135
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
136
+					return
137
+				}
138
+				med_type := strconv.Itoa(int(items["med_type"].(float64)))
139
+
140
+				ctime := time.Now().Unix()
141
+				prescription := &models.HisPrescriptionInfoTemplate{
142
+					ID:          id,
143
+					PatientId:   patient_id,
144
+					UserOrgId:   adminInfo.CurrentOrgId,
145
+					Ctime:       ctime,
146
+					Mtime:       ctime,
147
+					Type:        types,
148
+					Modifier:    adminInfo.AdminUser.Id,
149
+					Creator:     adminInfo.AdminUser.Id,
150
+					Status:      1,
151
+					PTemplateId: src_template.ID,
152
+					MedType:     med_type,
153
+				}
154
+				service.CreateHisPrescriptionInfoTemplate(prescription)
155
+
156
+				if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
157
+					advices := items["advices"].([]interface{})
158
+					//group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
159
+					groupNo := int64(0)
160
+					ctime := time.Now().Unix()
161
+					mtime := ctime
162
+					if len(advices) > 0 {
163
+						for _, advice := range advices {
164
+							var s models.HisPrescriptionAdviceTemplate
165
+							s.PrescriptionId = prescription.ID
166
+							s.AdviceType = 2
167
+							s.StopState = 2
168
+							s.ExecutionState = 2
169
+							s.Status = 1
170
+							s.UserOrgId = adminInfo.CurrentOrgId
171
+							s.Groupno = groupNo
172
+							s.CreatedTime = ctime
173
+							s.UpdatedTime = mtime
174
+							s.PatientId = patient_id
175
+							errcode := c.setAdviceTemplateWithJSON(&s, advice.(map[string]interface{}))
176
+							if errcode > 0 {
177
+								c.ServeFailJSONWithSGJErrorCode(errcode)
178
+								return
179
+							}
180
+							service.CreateHisPrescriptionAdviceTemplate(&s)
181
+						}
182
+					}
183
+				}
184
+				if items["project"] != nil && reflect.TypeOf(items["project"]).String() == "[]interface {}" {
185
+					projects := items["project"].([]interface{})
186
+					if len(projects) > 0 {
187
+						for _, project := range projects {
188
+							var p models.HisPrescriptionProjectTemplate
189
+							p.PrescriptionId = prescription.ID
190
+							p.Ctime = time.Now().Unix()
191
+							p.Mtime = time.Now().Unix()
192
+							p.PatientId = patient_id
193
+							p.UserOrgId = adminInfo.CurrentOrgId
194
+							p.Status = 1
195
+							errcode := c.setProjectTemplateWithJSON(&p, project.(map[string]interface{}))
196
+							if errcode > 0 {
197
+								c.ServeFailJSONWithSGJErrorCode(errcode)
198
+								return
199
+							}
200
+							service.CreateHisPrescriptionProjectTemplate(&p)
201
+
202
+						}
203
+					}
204
+				}
205
+			}
206
+			c.ServeSuccessJSON(map[string]interface{}{
207
+				"msg": "创建成功",
208
+			})
209
+		}
210
+	}
211
+
212
+}
213
+
214
+func (c *HisConfigApiController) DeletePrescriptionTemplate() {
215
+	id, _ := c.GetInt64("id")
216
+	err := service.DelelteHisPrescriptionTemplate(id, c.GetAdminUserInfo().CurrentOrgId)
217
+	if err == nil {
218
+		c.ServeSuccessJSON(map[string]interface{}{
219
+			"msg": "删除成功",
220
+		})
221
+		return
222
+	} else {
223
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
224
+		return
225
+	}
226
+
227
+}
228
+
229
+func (c *HisConfigApiController) DeletePrescriptionInfoTemplate() {
230
+
231
+	prescription_id, _ := c.GetInt64("id")
232
+	err := service.DelelteHisPrescriptionInfoTemplate(prescription_id, c.GetAdminUserInfo().CurrentOrgId)
233
+	if err == nil {
234
+		c.ServeSuccessJSON(map[string]interface{}{
235
+			"msg": "删除成功",
236
+		})
237
+		return
238
+	} else {
239
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
240
+		return
241
+	}
242
+}
243
+
244
+func (c *HisConfigApiController) DeleteAdviceTemplate() {
245
+	id, _ := c.GetInt64("id")
246
+	err := service.DelelteHisPrescriptionAdviceTemplate(id, c.GetAdminUserInfo().CurrentOrgId)
247
+	if err == nil {
248
+		c.ServeSuccessJSON(map[string]interface{}{
249
+			"msg": "删除成功",
250
+		})
251
+		return
252
+	} else {
253
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
254
+		return
255
+	}
256
+
257
+}
258
+
259
+func (c *HisConfigApiController) DeleteProjectTemplate() {
260
+	id, _ := c.GetInt64("id")
261
+	err := service.DelelteHisPrescriptionProjectTemplate(id, c.GetAdminUserInfo().CurrentOrgId)
262
+	if err == nil {
263
+		c.ServeSuccessJSON(map[string]interface{}{
264
+			"msg": "删除成功",
265
+		})
266
+		return
267
+	} else {
268
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
269
+		return
270
+	}
271
+}
272
+
273
+func (c *HisConfigApiController) setAdviceTemplateWithJSON(advice *models.HisPrescriptionAdviceTemplate, json map[string]interface{}) int {
274
+
275
+	if json["advice_id"] != nil || reflect.TypeOf(json["advice_id"]).String() == "float64" {
276
+		advice_id := int64(json["advice_id"].(float64))
277
+		advice.ID = advice_id
278
+	}
279
+
280
+	if json["drug_name"] == nil || reflect.TypeOf(json["drug_name"]).String() != "string" {
281
+		utils.ErrorLog("drug_name")
282
+		return enums.ErrorCodeParamWrong
283
+	}
284
+	adviceName, _ := json["drug_name"].(string)
285
+	if len(adviceName) == 0 {
286
+		utils.ErrorLog("len(advice_name) == 0")
287
+		return enums.ErrorCodeParamWrong
288
+	}
289
+	advice.AdviceName = adviceName
290
+	adviceDesc, _ := json["advice_desc"].(string)
291
+	advice.AdviceDesc = adviceDesc
292
+	if json["drug_spec"] != nil && reflect.TypeOf(json["drug_spec"]).String() == "string" {
293
+		drugSpec, _ := strconv.ParseFloat(json["drug_spec"].(string), 64)
294
+		advice.DrugSpec = drugSpec
295
+	}
296
+	if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
297
+		remark, _ := json["remark"].(string)
298
+		advice.Remark = remark
299
+	}
300
+	if json["id"] == nil {
301
+		advice.DrugId = 0
302
+	} else {
303
+		if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
304
+			drug_id := int64(json["id"].(float64))
305
+			advice.DrugId = drug_id
306
+		}
307
+	}
308
+
309
+	if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
310
+		drugSpecUnit, _ := json["min_unit"].(string)
311
+		advice.DrugSpecUnit = drugSpecUnit
312
+	}
313
+	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
314
+		singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
315
+		advice.SingleDose = singleDose
316
+	}
317
+	if json["single_dose_unit"] != nil && reflect.TypeOf(json["single_dose_unit"]).String() == "string" {
318
+		singleDoseUnit, _ := json["single_dose_unit"].(string)
319
+		advice.SingleDoseUnit = singleDoseUnit
320
+	}
321
+	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
322
+		prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
323
+		advice.PrescribingNumber = prescribingNumber
324
+	}
325
+	if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
326
+		prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
327
+		advice.PrescribingNumberUnit = prescribingNumberUnit
328
+	}
329
+	if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
330
+		deliveryWay, _ := json["delivery_way"].(string)
331
+		advice.DeliveryWay = deliveryWay
332
+	}
333
+	if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
334
+		executionFrequency, _ := json["execution_frequency"].(string)
335
+		advice.ExecutionFrequency = executionFrequency
336
+	}
337
+
338
+	if json["retail_price"] != nil || reflect.TypeOf(json["retail_price"]).String() == "string" {
339
+		price, _ := strconv.ParseFloat(json["retail_price"].(string), 64)
340
+		advice.Price = price
341
+	}
342
+	if json["medical_insurance_number"] != nil || reflect.TypeOf(json["medical_insurance_number"]).String() == "string" {
343
+		med_list_codg, _ := json["medical_insurance_number"].(string)
344
+		advice.MedListCodg = med_list_codg
345
+	}
346
+	if json["day"] != nil || reflect.TypeOf(json["day"]).String() == "float64" {
347
+		day := int64(json["day"].(float64))
348
+		advice.Day = day
349
+	}
350
+	return 0
351
+}
352
+
353
+func (c *HisConfigApiController) setProjectTemplateWithJSON(project *models.HisPrescriptionProjectTemplate, json map[string]interface{}) int {
354
+
355
+	if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
356
+		id := int64(json["id"].(float64))
357
+		project.ID = id
358
+	}
359
+
360
+	if json["type"] != nil || reflect.TypeOf(json["type"]).String() == "float64" {
361
+		types := int64(json["type"].(float64))
362
+		project.Type = types
363
+	}
364
+	if json["project_id"] != nil || reflect.TypeOf(json["project_id"]).String() == "float64" {
365
+		project_id := int64(json["project_id"].(float64))
366
+		project.ProjectId = project_id
367
+	}
368
+
369
+	if json["price"] != nil || reflect.TypeOf(json["price"]).String() == "string" {
370
+		price, _ := strconv.ParseFloat(json["price"].(string), 64)
371
+		project.Price = price
372
+	}
373
+
374
+	if json["total"] != nil && reflect.TypeOf(json["total"]).String() == "string" {
375
+		total, _ := json["total"].(string)
376
+		totals, _ := strconv.ParseInt(total, 10, 64)
377
+		project.Count = totals
378
+	}
379
+
380
+	if json["medical_code"] != nil && reflect.TypeOf(json["medical_code"]).String() == "string" {
381
+		medical_code, _ := json["medical_code"].(string)
382
+		project.MedListCodg = medical_code
383
+	}
384
+	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
385
+		single_dose, _ := json["single_dose"].(string)
386
+		project.SingleDose = single_dose
387
+	}
388
+
389
+	if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
390
+		delivery_way, _ := json["delivery_way"].(string)
391
+		project.DeliveryWay = delivery_way
392
+	}
393
+	if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
394
+		execution_frequency, _ := json["execution_frequency"].(string)
395
+		project.ExecutionFrequency = execution_frequency
396
+	}
397
+	if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
398
+		remark, _ := json["remark"].(string)
399
+		project.Remark = remark
400
+	}
401
+	if json["number_days"] != nil && reflect.TypeOf(json["number_days"]).String() == "string" {
402
+		day, _ := json["number_days"].(string)
403
+		project.Day = day
404
+	}
405
+
406
+	if json["unit"] != nil && reflect.TypeOf(json["unit"]).String() == "string" {
407
+		unit, _ := json["unit"].(string)
408
+		project.Unit = unit
409
+	}
410
+	return 0
411
+}

+ 317 - 0
controllers/his_hospital_api_controller.go View File

@@ -0,0 +1,317 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/models"
6
+	"Xcx_New/service"
7
+	"fmt"
8
+	"github.com/astaxie/beego"
9
+	"time"
10
+)
11
+
12
+type HisHospitalApiController struct {
13
+	BaseAuthAPIController
14
+}
15
+
16
+func HisHospitalManagerApiRegistRouters() {
17
+
18
+	beego.Router("/api/hishospitalpatient/list", &HisHospitalApiController{}, "get:GetHisHospitalPatientList")
19
+
20
+	//beego.Router("/api/hishospitalprescription/list", &HisHospitalApiController{}, "get:GetHisHospitalPrescriptionList")
21
+
22
+	beego.Router("/api/hospitalcharge/list", &HisHospitalApiController{}, "get:GetHisHospitalChargePatientList")
23
+	beego.Router("/api/hospotalcharge/info", &HisHospitalApiController{}, "get:GetHisHospitalChargePatientInfo")
24
+
25
+	beego.Router("/api/hospitalprescription/list", &HisHospitalApiController{}, "get:GetHisHospitalPrescriptionList")
26
+	//beego.Router("/api/hishospitalprescription/info", &HisApiController{}, "get:GetHisHospitalPrescriptionInfo")
27
+
28
+	//beego.Router("/api/hisprescription/create", &HisApiController{}, "post:CreateHisPrescription")
29
+	//beego.Router("/api/hisprescription/edit", &HisApiController{}, "post:EditHisPrescription")
30
+
31
+	//beego.Router("/api/doctorworkstation/casehistory/list", &HisApiController{}, "get:GetHisPatientCaseHistoryList")
32
+	//beego.Router("/api/doctorworkstation/casehistory/get", &HisApiController{}, "get:GetHisPatientCaseHistory")
33
+	//beego.Router("/api/doctorworkstation/casehistory/create", &HisApiController{}, "get:CreateHisPatientCaseHistory")
34
+
35
+	//beego.Router("/api/doctorworkstation/casehistorytemplate/create", &HisApiController{}, "get:CreateCaseHistoryTemplate")
36
+	//beego.Router("/api/doctorworkstation/casehistorytemplate/get", &HisApiController{}, "get:GetCaseHistoryTemplate")
37
+
38
+	//beego.Router("/api/hisorder/list", &HisApiController{}, "get:GetHisOrderList")
39
+	//beego.Router("/api/hisorder/get", &HisApiController{}, "get:GetHisOrder")
40
+
41
+	//beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
42
+	//
43
+	//beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
44
+	//
45
+	//beego.Router("/api/refund/post", &HisApiController{}, "post:Refund")
46
+	//
47
+	//beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
48
+	//
49
+	//beego.Router("/api/doctor/list", &HisApiController{}, "get:GetAdminUsers")
50
+
51
+	//beego.Router("/api/medicalinsurance/config", &HisApiController{}, "get:GetMedicalInsuranceConfig")
52
+	//新增附加费用
53
+	//beego.Router("/api/his/additionalcharge", &HisApiController{}, "Post:AdditionalCharge")
54
+	//beego.Router("/api/additionalcharge/get", &HisApiController{}, "Get:GetAdditionalcharge")
55
+	//beego.Router("/api/hisprescription/get", &HisApiController{}, "Get:GetLastOrNextHisPrescription")
56
+	//beego.Router("/api/callhisprescription/get", &HisApiController{}, "Get:GetCallHisPrescription")
57
+	//beego.Router("/api/dayprescription/get", &HisApiController{}, "get:GetHisDayPrescription")
58
+	//beego.Router("/api/charge/list", &HisApiController{}, "get:GetHisChargePatientList")
59
+	//beego.Router("/api/charge/info", &HisApiController{}, "get:GetHisChargePatientInfo")
60
+	//beego.Router("/api/unregister/list", &HisApiController{}, "get:GetHisUnRegisterPatientList")
61
+	//beego.Router("/api/orderdetail/get", &HisApiController{}, "get:GetAllOrderDetail")
62
+	//beego.Router("/api/orderdetaicollect/get", &HisApiController{}, "get:GetAllOrderDetailCollect")
63
+	//beego.Router("/api/cost/compare", &HisApiController{}, "get:GetMedicalInsuranceCostCompareList")
64
+	//beego.Router("/api/record/list", &HisApiController{}, "get:GetPutOnRecordList")
65
+	//
66
+	//beego.Router("/api/comparedata/get", &HisApiController{}, "get:GetCompareData")
67
+	//beego.Router("/api/fapiao/get", &HisApiController{}, "get:GetFaPiaoData")
68
+	//
69
+	//beego.Router("/api/incomestatistics/get", &HisApiController{}, "get:GetIncomeStatisticsData")
70
+	//
71
+	//beego.Router("/api/postprojectinformation", &HisApiController{}, "post:PostProjectInformation")
72
+
73
+}
74
+
75
+func (c *HisHospitalApiController) GetHisHospitalPatientList() {
76
+	record_date := c.GetString("record_date")
77
+	types, _ := c.GetInt64("type", 0)
78
+
79
+	timeLayout := "2006-01-02"
80
+	loc, _ := time.LoadLocation("Local")
81
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
82
+	if err != nil {
83
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
84
+		return
85
+	}
86
+	recordDateTime := theTime.Unix()
87
+	adminInfo := c.GetAdminUserInfo()
88
+	var patients []*service.HospitalPatient
89
+	tempPatients, _ := service.GetHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime)
90
+
91
+	for _, item := range tempPatients {
92
+		if item.HisHospitalCheckRecord.ID > 0 && item.HisHospitalCheckRecord.InHospitalStatus == 1 && item.HisHospitalCheckRecord.OutHospitalStatus == 0 {
93
+			patients = append(patients, item)
94
+
95
+		}
96
+
97
+	}
98
+
99
+	var total_one int64
100
+	var total_two int64
101
+
102
+	for _, item := range patients {
103
+
104
+		if item.VMHisPrescriptionInfo.ID == 0 {
105
+			total_one = total_one + 1
106
+		}
107
+		if item.VMHisPrescriptionInfo.ID > 0 {
108
+			total_two = total_two + 1
109
+		}
110
+	}
111
+
112
+	adminUserInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
113
+	doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
114
+	department, _ := service.GetAllDepartMent(adminInfo.CurrentOrgId)
115
+
116
+	if types == 0 {
117
+		c.ServeSuccessJSON(map[string]interface{}{
118
+			"list":       patients,
119
+			"total_one":  total_one,
120
+			"total_two":  total_two,
121
+			"info":       adminUserInfo,
122
+			"doctors":    doctors,
123
+			"department": department,
124
+		})
125
+
126
+	} else if types == 1 { //未就诊
127
+		var patientsOne []*service.HospitalPatient
128
+		for _, item := range tempPatients {
129
+			if item.VMHisPrescriptionInfo.ID == 0 {
130
+				patientsOne = append(patientsOne, item)
131
+			}
132
+		}
133
+		c.ServeSuccessJSON(map[string]interface{}{
134
+			"list":       patientsOne,
135
+			"total_one":  total_one,
136
+			"total_two":  total_two,
137
+			"info":       adminUserInfo,
138
+			"doctors":    doctors,
139
+			"department": department,
140
+		})
141
+
142
+	} else if types == 2 { //已就诊
143
+		var patientsTwo []*service.HospitalPatient
144
+		for _, item := range tempPatients {
145
+
146
+			if item.VMHisPrescriptionInfo.ID > 0 {
147
+				patientsTwo = append(patientsTwo, item)
148
+			}
149
+		}
150
+		c.ServeSuccessJSON(map[string]interface{}{
151
+			"list":       patientsTwo,
152
+			"total_one":  total_one,
153
+			"total_two":  total_two,
154
+			"info":       adminUserInfo,
155
+			"doctors":    doctors,
156
+			"department": department,
157
+		})
158
+	}
159
+}
160
+
161
+func (c *HisHospitalApiController) GetHisHospitalChargePatientList() {
162
+	record_date := c.GetString("record_date")
163
+	timeLayout := "2006-01-02"
164
+	loc, _ := time.LoadLocation("Local")
165
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
166
+	if err != nil {
167
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
168
+		return
169
+	}
170
+	recordDateTime := theTime.Unix()
171
+	adminInfo := c.GetAdminUserInfo()
172
+	//tempPatients, _ := service.GetAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
173
+	tempPatients, _ := service.GetNewAllChargeHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime)
174
+
175
+	var patients []*service.HospitalPatient
176
+	for _, item := range tempPatients {
177
+		fmt.Println(item.ID)
178
+		if item.HisHospitalCheckRecord.ID > 0 && item.HisHospitalCheckRecord.InHospitalStatus == 1 &&
179
+			item.HisHospitalCheckRecord.HisHospitalOrder.ID == 0 {
180
+			patients = append(patients, item)
181
+		}
182
+	}
183
+
184
+	c.ServeSuccessJSON(map[string]interface{}{
185
+		"list":     patients,
186
+		"list_two": patients,
187
+	})
188
+}
189
+
190
+func (c *HisHospitalApiController) GetHisHospitalChargePatientInfo() {
191
+	patient_id, _ := c.GetInt64("patient_id")
192
+	his_patient_id, _ := c.GetInt64("his_patient_id")
193
+	record_date := c.GetString("record_date")
194
+	start_time := c.GetString("start_time")
195
+	end_time := c.GetString("end_time")
196
+	order_status, _ := c.GetInt64("type", 0)
197
+	p_type, _ := c.GetInt64("p_type", 0)
198
+
199
+	timeLayout := "2006-01-02"
200
+	loc, _ := time.LoadLocation("Local")
201
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
202
+	if err != nil {
203
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
204
+		return
205
+	}
206
+	recordDateTime := theTime.Unix()
207
+
208
+	startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
209
+	if err != nil {
210
+
211
+	}
212
+	startRecordDateTime := startTime.Unix()
213
+
214
+	endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
215
+	if err != nil {
216
+
217
+	}
218
+	endRecordDateTime := endTime.Unix()
219
+
220
+	admin := c.GetAdminUserInfo()
221
+	his_patient_info, _ := service.GetNewHisHospitalPatientInfo(his_patient_id)
222
+	xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
223
+
224
+	var prescriptions []*models.HisPrescription
225
+
226
+	if order_status == 1 || order_status == 0 {
227
+		prescriptions, _ = service.GetUnChargeHisHospitalPrescriptionFive(admin.CurrentOrgId, patient_id, his_patient_id, recordDateTime)
228
+	} else if order_status == 2 {
229
+		prescriptions, _ = service.GetChargeHisHospitalPrescriptionFive(admin.CurrentOrgId, patient_id, his_patient_id, recordDateTime)
230
+	}
231
+
232
+	var monthPrescriptions []*models.HisPrescription
233
+	if order_status == 1 || order_status == 0 {
234
+		monthPrescriptions, _ = service.GetUnChargeMonthHisPrescriptionThree(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, p_type)
235
+	} else if order_status == 2 {
236
+		monthPrescriptions, _ = service.GetChargeMonthHisPrescriptionFour(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, p_type)
237
+	}
238
+	case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
239
+	patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
240
+	order, _ := service.GetNewHisOrder(admin.CurrentOrgId, his_patient_info.Number, patient_id)
241
+	doctors, _ := service.GetHisAdminUserDoctors(admin.CurrentOrgId)
242
+	//获取所有科室信息
243
+	department, _ := service.GetAllDepartMent(admin.CurrentOrgId)
244
+
245
+	c.ServeSuccessJSON(map[string]interface{}{
246
+		"his_info":            his_patient_info,
247
+		"xt_info":             xt_patient_info,
248
+		"prescription":        prescriptions,
249
+		"case_history":        case_history,
250
+		"info":                patientPrescriptionInfo,
251
+		"month_prescriptions": monthPrescriptions,
252
+		"order":               order,
253
+		"doctors":             doctors,
254
+		"department":          department,
255
+	})
256
+	return
257
+
258
+}
259
+
260
+func (c *HisHospitalApiController) GetHisHospitalrescriptionList() {
261
+	record_date := c.GetString("record_date")
262
+	keywords := c.GetString("keywords")
263
+	page, _ := c.GetInt64("page")
264
+	limit, _ := c.GetInt64("limit")
265
+
266
+	timeLayout := "2006-01-02"
267
+	loc, _ := time.LoadLocation("Local")
268
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
269
+	if err != nil {
270
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
271
+		return
272
+	}
273
+	recordDateTime := theTime.Unix()
274
+	adminInfo := c.GetAdminUserInfo()
275
+	prescriptionOrder, err, total := service.GetHisPatientPrescriptionList(adminInfo.CurrentOrgId, keywords, recordDateTime, page, limit)
276
+
277
+	//adminInfo := c.GetAdminUserInfo()
278
+	//prescriptionOrder, err := service.GetHisPrescriptionOrderList(adminInfo.CurrentOrgId)
279
+	//fmt.Println(prescriptionOrder)
280
+	if err == nil {
281
+		c.ServeSuccessJSON(map[string]interface{}{
282
+			"order": prescriptionOrder,
283
+			"total": total,
284
+		})
285
+	} else {
286
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
287
+		return
288
+	}
289
+}
290
+
291
+func (c *HisHospitalApiController) GetHisHospitalPrescriptionList() {
292
+	record_date := c.GetString("record_date")
293
+	keywords := c.GetString("keywords")
294
+	page, _ := c.GetInt64("page")
295
+	limit, _ := c.GetInt64("limit")
296
+
297
+	timeLayout := "2006-01-02"
298
+	loc, _ := time.LoadLocation("Local")
299
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
300
+	if err != nil {
301
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
302
+		return
303
+	}
304
+	recordDateTime := theTime.Unix()
305
+	adminInfo := c.GetAdminUserInfo()
306
+	prescriptionOrder, err, total := service.GetHisHospitalPatientPrescriptionList(adminInfo.CurrentOrgId, keywords, recordDateTime, page, limit)
307
+	if err == nil {
308
+		c.ServeSuccessJSON(map[string]interface{}{
309
+			"order": prescriptionOrder,
310
+			"total": total,
311
+		})
312
+	} else {
313
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
314
+		return
315
+	}
316
+
317
+}

File diff suppressed because it is too large
+ 1675 - 0
controllers/his_project_api_controller.go


+ 634 - 0
controllers/inspection_api_controller.go View File

@@ -0,0 +1,634 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/models"
6
+	"Xcx_New/service"
7
+	"Xcx_New/utils"
8
+	"encoding/json"
9
+	"fmt"
10
+	"github.com/astaxie/beego"
11
+	"strconv"
12
+	"strings"
13
+	"time"
14
+)
15
+
16
+type InspectionApiController struct {
17
+	BaseAuthAPIController
18
+}
19
+
20
+func InspectionApiRegistRouters() {
21
+	beego.Router("/api/patient/inspection/list", &InspectionApiController{}, "Get:GetPatientInspections")
22
+	beego.Router("/api/patient/inspection/reference", &InspectionApiController{}, "Get:PatientInspectionReference")
23
+	beego.Router("/api/patient/inspection/create", &InspectionApiController{}, "Post:CreatePatientInspection")
24
+	beego.Router("/api/patient/inspection/edit", &InspectionApiController{}, "Put:EditPatientInspection")
25
+	beego.Router("/api/patient/inspection/delete", &InspectionApiController{}, "Delete:DeletePatientInspection")
26
+
27
+	beego.Router("/api/patient/inspection/get", &InspectionApiController{}, "Get:GetAllPatientInspection")
28
+	beego.Router("/api/patient/inspectioninit/get", &InspectionApiController{}, "Get:GetInitInsepction")
29
+
30
+}
31
+
32
+//PatientInspectionReference 请求检验检查大小项目
33
+//[get]: /api/patient/inspection/reference
34
+func (c *InspectionApiController) PatientInspectionReference() {
35
+	patient, _ := c.GetInt64("patient")
36
+	if patient <= 0 {
37
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
38
+		return
39
+	}
40
+
41
+	adminUserInfo := c.GetAdminUserInfo()
42
+
43
+	references, err := service.GetInspectionReference(adminUserInfo.CurrentOrgId)
44
+	if err != nil {
45
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
46
+		return
47
+	}
48
+
49
+	patient_info, _ := service.GetPatientByID(adminUserInfo.CurrentOrgId, patient)
50
+
51
+	counts, err := service.GetPatientInspectionProjectCount(adminUserInfo.CurrentOrgId, patient)
52
+	if err != nil {
53
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
54
+		return
55
+	}
56
+	countsMap := make(map[int64]int64, 0)
57
+	for _, count := range counts {
58
+		countsMap[count.ProjectId] = count.Count
59
+	}
60
+
61
+	referenceMap := make(map[string]*models.InspectionReferenceMap, 0)
62
+
63
+	for _, reference := range references {
64
+		if _, exist := referenceMap[reference.Project]; !exist {
65
+			referenceMap[reference.Project] = new(models.InspectionReferenceMap)
66
+			referenceMap[reference.Project].Project = reference.Project
67
+			referenceMap[reference.Project].ProjectId = reference.ProjectId
68
+			referenceMap[reference.Project].ProjectName = reference.ProjectName
69
+			if _, cexit := countsMap[reference.ProjectId]; cexit {
70
+				referenceMap[reference.Project].Count = countsMap[reference.ProjectId]
71
+			}
72
+			referenceMap[reference.Project].InspectionReference = make([]models.InspectionReference, 0)
73
+		}
74
+		referenceMap[reference.Project].InspectionReference = append(referenceMap[reference.Project].InspectionReference, *reference)
75
+
76
+	}
77
+
78
+	reference := make([]*models.InspectionReferenceMap, 0)
79
+	for _, item := range referenceMap {
80
+		reference = append(reference, item)
81
+	}
82
+
83
+	rl := len(reference)
84
+	for index := 0; index < rl-1; index++ {
85
+		for jndex := 0; jndex < rl-1-index; jndex++ {
86
+			if reference[jndex].ProjectId > reference[jndex+1].ProjectId {
87
+				var item models.InspectionReferenceMap
88
+				item = *reference[jndex]
89
+				reference[jndex] = reference[jndex+1]
90
+				reference[jndex+1] = &item
91
+			}
92
+		}
93
+	}
94
+
95
+	list, err := service.GetInspectionReferenceByOrgId(0)
96
+	c.ServeSuccessJSON(map[string]interface{}{
97
+		"reference":    reference,
98
+		"patient_info": patient_info,
99
+		"list":         list,
100
+	})
101
+	return
102
+
103
+}
104
+
105
+func (c *InspectionApiController) CreatePatientInspection() {
106
+	patient, _ := c.GetInt64("patient", 0)
107
+	remind_cycle, _ := c.GetInt64("remind_cycle", 0)
108
+
109
+	if patient <= 0 {
110
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
111
+		return
112
+	}
113
+
114
+	adminUserInfo := c.GetAdminUserInfo()
115
+	patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
116
+	if patientInfo.ID == 0 {
117
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
118
+		return
119
+	}
120
+
121
+	var from models.InepectionForm
122
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &from)
123
+	if err != nil {
124
+		utils.ErrorLog("%v", err)
125
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
126
+		return
127
+	}
128
+
129
+	timeLayout := "2006-01-02 15:04"
130
+	loc, _ := time.LoadLocation("Local")
131
+
132
+	theTime, err := time.ParseInLocation(timeLayout, from.InspectDate, loc)
133
+	if err != nil {
134
+		utils.ErrorLog(err.Error())
135
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")
136
+		return
137
+	}
138
+
139
+	if len(from.FormItem) == 0 {
140
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "未填写项目")
141
+		return
142
+	}
143
+
144
+	date := theTime.Unix()
145
+	insp, err := service.GetPatientInspectionByDate(adminUserInfo.CurrentOrgId, patient, date, from.ProjectId)
146
+	if err != nil {
147
+		utils.ErrorLog("%v", err)
148
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
149
+		return
150
+	}
151
+	if len(insp) > 0 {
152
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionDateExit)
153
+		return
154
+	}
155
+
156
+	inspections := make([]models.Inspection, 0)
157
+	for _, item := range from.FormItem {
158
+		var inspection models.Inspection
159
+		inspection.OrgId = adminUserInfo.CurrentOrgId
160
+		inspection.PatientId = patient
161
+		inspection.ProjectId = from.ProjectId
162
+		inspection.ItemId = item.ItemId
163
+		inspection.ItemName = item.ItemName
164
+		inspection.ProjectName = item.ProjectName
165
+		inspection.InspectType = item.RangeType
166
+		inspection.InspectValue = item.Value
167
+		inspection.InspectDate = date
168
+		inspection.Status = 1
169
+		inspection.CreatedTime = time.Now().Unix()
170
+		inspection.UpdatedTime = time.Now().Unix()
171
+		inspections = append(inspections, inspection)
172
+	}
173
+
174
+	err = service.CreatePatientInspection(inspections)
175
+	if err != nil {
176
+		utils.ErrorLog("%v", err)
177
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionAddFail)
178
+		return
179
+	}
180
+
181
+	if remind_cycle > 0 {
182
+		infectiousRecord, _ := service.FindLastRecordDate(adminUserInfo.CurrentOrgId, patient, 14)
183
+		fmt.Println(infectiousRecord.InspectDate)
184
+		var record_time int64
185
+		switch remind_cycle {
186
+		case 1: //1个月
187
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
188
+			record_time = ts.AddDate(0, 1, 0).Unix()
189
+			fmt.Println(record_time)
190
+			break
191
+		case 2: //2个月
192
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
193
+			record_time = ts.AddDate(0, 2, 0).Unix()
194
+			fmt.Println(record_time)
195
+
196
+			break
197
+		case 3: //3个月
198
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
199
+			record_time = ts.AddDate(0, 3, 0).Unix()
200
+			fmt.Println(record_time)
201
+
202
+			break
203
+		case 4: //6个月
204
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
205
+			record_time = ts.AddDate(0, 6, 0).Unix()
206
+			fmt.Println(record_time)
207
+
208
+			break
209
+		case 5: //12个月
210
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
211
+			record_time = ts.AddDate(0, 12, 0).Unix()
212
+			fmt.Println(record_time)
213
+
214
+			break
215
+		}
216
+
217
+		errs := service.UpDateInfectiousRecordTime(adminUserInfo.CurrentOrgId, patient, record_time, remind_cycle)
218
+		if errs != nil {
219
+			utils.ErrorLog("更新日期出错:%v", errs)
220
+		}
221
+	}
222
+
223
+	c.ServeSuccessJSON(map[string]interface{}{
224
+		"inspections":  inspections,
225
+		"remind_cycle": remind_cycle,
226
+	})
227
+	return
228
+}
229
+
230
+func (c *InspectionApiController) EditPatientInspection() {
231
+	patient, _ := c.GetInt64("patient", 0)
232
+	remind_cycle, _ := c.GetInt64("remind_cycle", 0)
233
+	// dates := c.GetString("dates")
234
+	// projectid := c.GetString("projectid")
235
+
236
+	if patient <= 0 {
237
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
238
+		return
239
+	}
240
+
241
+	adminUserInfo := c.GetAdminUserInfo()
242
+	patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
243
+	if patientInfo.ID == 0 {
244
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
245
+		return
246
+	}
247
+
248
+	var from models.InepectionForm
249
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &from)
250
+	if err != nil {
251
+		utils.ErrorLog("%v", err)
252
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
253
+		return
254
+	}
255
+
256
+	timeLayout := "2006-01-02 15:04"
257
+	loc, _ := time.LoadLocation("Local")
258
+
259
+	theTime, err := time.ParseInLocation(timeLayout, from.InspectDate, loc)
260
+	if err != nil {
261
+		utils.ErrorLog(err.Error())
262
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")
263
+		return
264
+	}
265
+
266
+	oldTime, olderr := time.ParseInLocation(timeLayout, from.OldInspectDate, loc)
267
+	if olderr != nil {
268
+		utils.ErrorLog(olderr.Error())
269
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")
270
+		return
271
+	}
272
+
273
+	if len(from.FormItem) == 0 {
274
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "未填写项目")
275
+		return
276
+	}
277
+
278
+	date := theTime.Unix()
279
+	oldDate := oldTime.Unix()
280
+	insp, err := service.GetPatientInspectionByDate(adminUserInfo.CurrentOrgId, patient, oldDate, from.ProjectId)
281
+	if err != nil {
282
+		utils.ErrorLog("%v", err)
283
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
284
+		return
285
+	}
286
+	if len(insp) == 0 {
287
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionDateNotExit)
288
+		return
289
+	}
290
+	inspMap := make(map[int64]*models.Inspection)
291
+	for _, item := range insp {
292
+		inspMap[item.ID] = item
293
+	}
294
+
295
+	addinsp := make([]models.Inspection, 0)
296
+	editinsp := make([]models.Inspection, 0)
297
+	noMap := make([]int64, 0)
298
+	fmt.Println(from.FormItem)
299
+
300
+	for _, item := range from.FormItem {
301
+		fmt.Println(item.ID)
302
+		if item.ID == 0 {
303
+			var inspection models.Inspection
304
+			inspection.OrgId = adminUserInfo.CurrentOrgId
305
+			inspection.PatientId = patient
306
+			inspection.ProjectId = from.ProjectId
307
+			inspection.ItemId = item.ItemId
308
+			inspection.ItemName = item.ItemName
309
+			inspection.ProjectName = item.ProjectName
310
+			inspection.InspectType = item.RangeType
311
+			inspection.InspectValue = item.Value
312
+			inspection.InspectDate = date
313
+			inspection.Status = 1
314
+			inspection.CreatedTime = time.Now().Unix()
315
+			inspection.UpdatedTime = time.Now().Unix()
316
+			addinsp = append(addinsp, inspection)
317
+		} else {
318
+			inspection := *inspMap[item.ID]
319
+			inspection.InspectValue = item.Value
320
+			inspection.InspectDate = date
321
+			inspection.UpdatedTime = time.Now().Unix()
322
+			editinsp = append(editinsp, inspection)
323
+			noMap = append(noMap, item.ID)
324
+		}
325
+
326
+	}
327
+
328
+	err = service.EditPatientInspection(addinsp, editinsp, noMap, patient, adminUserInfo.CurrentOrgId, from.ProjectId, date)
329
+	if err != nil {
330
+		utils.ErrorLog("%v", err)
331
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionEditFail)
332
+		return
333
+	}
334
+
335
+	inspections := make([]models.Inspection, 0)
336
+	inspections = append(inspections, editinsp...)
337
+	inspections = append(inspections, addinsp...)
338
+
339
+	if remind_cycle > 0 {
340
+		infectiousRecord, _ := service.FindLastRecordDate(adminUserInfo.CurrentOrgId, patient, 14)
341
+		fmt.Println(infectiousRecord.InspectDate)
342
+		var record_time int64
343
+		switch remind_cycle {
344
+		case 1: //1个月
345
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
346
+			record_time = ts.AddDate(0, 1, 0).Unix()
347
+
348
+			break
349
+		case 2: //2个月
350
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
351
+			record_time = ts.AddDate(0, 2, 0).Unix()
352
+			break
353
+		case 3: //3个月
354
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
355
+			record_time = ts.AddDate(0, 3, 0).Unix()
356
+			break
357
+		case 4: //6个月
358
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
359
+			record_time = ts.AddDate(0, 6, 0).Unix()
360
+			break
361
+		case 5: //12个月
362
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
363
+			record_time = ts.AddDate(0, 12, 0).Unix()
364
+			break
365
+		}
366
+		fmt.Println(record_time)
367
+		errs := service.UpDateInfectiousRecordTime(adminUserInfo.CurrentOrgId, patient, record_time, remind_cycle)
368
+		if errs != nil {
369
+			utils.ErrorLog("更新日期出错:%v", errs)
370
+		}
371
+	}
372
+
373
+	c.ServeSuccessJSON(map[string]interface{}{
374
+		"inspections":  inspections,
375
+		"remind_cycle": remind_cycle,
376
+	})
377
+	return
378
+}
379
+
380
+func (c *InspectionApiController) DeletePatientInspection() {
381
+	patient, _ := c.GetInt64("patient", 0)
382
+	ProjectId, _ := c.GetInt64("project_id", 0)
383
+	InspectDate := c.GetString("date")
384
+	if patient <= 0 || ProjectId <= 0 || len(InspectDate) < 10 {
385
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
386
+		return
387
+	}
388
+
389
+	timeLayout := "2006-01-02 15:04"
390
+	loc, _ := time.LoadLocation("Local")
391
+
392
+	theTime, err := time.ParseInLocation(timeLayout, InspectDate, loc)
393
+	if err != nil {
394
+		utils.ErrorLog(err.Error())
395
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")
396
+		return
397
+	}
398
+
399
+	adminUserInfo := c.GetAdminUserInfo()
400
+
401
+	date := theTime.Unix()
402
+	insp, err := service.GetPatientInspectionByDate(adminUserInfo.CurrentOrgId, patient, date, ProjectId)
403
+	if err != nil {
404
+		utils.ErrorLog("%v", err)
405
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
406
+		return
407
+	}
408
+	if len(insp) == 0 {
409
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionDateNotExit)
410
+		return
411
+	}
412
+
413
+	err = service.DeletePatientInspection(adminUserInfo.CurrentOrgId, patient, ProjectId, date)
414
+	if err != nil {
415
+		utils.ErrorLog("%v", err)
416
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionDeleteFail)
417
+		return
418
+	}
419
+
420
+	c.ServeSuccessJSON(map[string]interface{}{
421
+		"msg": "ok",
422
+	})
423
+	return
424
+}
425
+
426
+func (c *InspectionApiController) GetPatientInspections() {
427
+	patient, _ := c.GetInt64("patient", 0)
428
+	projectId, _ := c.GetInt64("project_id", 0)
429
+	if patient <= 0 || projectId <= 0 {
430
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
431
+		return
432
+	}
433
+	page, _ := c.GetInt64("page", 0)
434
+	if page <= 0 {
435
+		page = 1
436
+	}
437
+
438
+	adminUserInfo := c.GetAdminUserInfo()
439
+	inspections, total, dateTime, err := service.GetPatientInspections(adminUserInfo.CurrentOrgId, patient, projectId, page)
440
+	if err != nil {
441
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
442
+		return
443
+	}
444
+
445
+	date := ""
446
+	if len(inspections) > 0 {
447
+		date = time.Unix(dateTime, 0).Format("2006-01-02 15:04")
448
+	}
449
+
450
+	c.ServeSuccessJSON(map[string]interface{}{
451
+		"inspections": inspections,
452
+		"total":       total,
453
+		"date":        date,
454
+	})
455
+	return
456
+
457
+}
458
+
459
+func (c *InspectionApiController) GetAllPatientInspection() {
460
+	patient, _ := c.GetInt64("patient", 0)
461
+	projectStr := c.GetString("project")
462
+	start_time, _ := c.GetInt64("start_time")
463
+	end_time, _ := c.GetInt64("end_time")
464
+	upload_type, _ := c.GetInt64("type")
465
+
466
+	ids := strings.Split(projectStr, "-")
467
+
468
+	if patient <= 0 {
469
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
470
+		return
471
+	}
472
+	page, _ := c.GetInt64("page", 0)
473
+	if page <= 0 {
474
+		page = 1
475
+	}
476
+
477
+	adminUserInfo := c.GetAdminUserInfo()
478
+
479
+	switch upload_type {
480
+	case 1:
481
+		var inspections []*models.Inspection
482
+
483
+		for _, item := range ids {
484
+			id, _ := strconv.ParseInt(item, 10, 64)
485
+			inspection, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id, start_time, end_time)
486
+			//fmt.Println(err)
487
+			//if err != nil {
488
+			//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
489
+			//	return
490
+			//}
491
+			for _, inspection_item := range inspection {
492
+				inspections = append(inspections, inspection_item)
493
+			}
494
+		}
495
+
496
+		c.ServeSuccessJSON(map[string]interface{}{
497
+			"inspections": inspections,
498
+			"type":        upload_type,
499
+		})
500
+		break
501
+
502
+	case 2:
503
+		id_one, _ := strconv.ParseInt(ids[0], 10, 64)
504
+		id_two, _ := strconv.ParseInt(ids[1], 10, 64)
505
+		id_three, _ := strconv.ParseInt(ids[2], 10, 64)
506
+		inspection_one, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_one, start_time, end_time)
507
+		inspection_two, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_two, start_time, end_time)
508
+		inspection_three, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_three, start_time, end_time)
509
+
510
+		c.ServeSuccessJSON(map[string]interface{}{
511
+			"inspections_one":   inspection_one,
512
+			"inspections_two":   inspection_two,
513
+			"inspections_three": inspection_three,
514
+			"type":              upload_type,
515
+		})
516
+
517
+		break
518
+	case 3:
519
+		var inspections []*models.Inspection
520
+
521
+		for _, item := range ids {
522
+			id, _ := strconv.ParseInt(item, 10, 64)
523
+			inspection, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id, start_time, end_time)
524
+			//fmt.Println(err)
525
+			//if err != nil {
526
+			//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
527
+			//	return
528
+			//}
529
+			for _, inspection_item := range inspection {
530
+				inspections = append(inspections, inspection_item)
531
+			}
532
+		}
533
+
534
+		c.ServeSuccessJSON(map[string]interface{}{
535
+			"inspections": inspections,
536
+			"type":        upload_type,
537
+		})
538
+
539
+		break
540
+	case 4:
541
+		id_one, _ := strconv.ParseInt(ids[0], 10, 64)
542
+		id_two, _ := strconv.ParseInt(ids[1], 10, 64)
543
+		id_three, _ := strconv.ParseInt(ids[2], 10, 64)
544
+		id_four, _ := strconv.ParseInt(ids[3], 10, 64)
545
+		id_five, _ := strconv.ParseInt(ids[4], 10, 64)
546
+
547
+		inspection_one, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_one, start_time, end_time)
548
+		inspection_two, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_two, start_time, end_time)
549
+		inspection_three, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_three, start_time, end_time)
550
+		inspection_four, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_four, start_time, end_time)
551
+		inspection_five, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_five, start_time, end_time)
552
+
553
+		c.ServeSuccessJSON(map[string]interface{}{
554
+			"inspections_one":   inspection_one,
555
+			"inspections_two":   inspection_two,
556
+			"inspections_three": inspection_three,
557
+			"inspections_four":  inspection_four,
558
+			"inspections_five":  inspection_five,
559
+			"type":              upload_type,
560
+		})
561
+
562
+		break
563
+	case 5:
564
+		id_one, _ := strconv.ParseInt(ids[0], 10, 64)
565
+		id_two, _ := strconv.ParseInt(ids[1], 10, 64)
566
+		inspection_one, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_one, start_time, end_time)
567
+		inspection_two, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_two, start_time, end_time)
568
+
569
+		c.ServeSuccessJSON(map[string]interface{}{
570
+			"inspections_one": inspection_one,
571
+			"inspections_two": inspection_two,
572
+			"type":            upload_type,
573
+		})
574
+
575
+		break
576
+	case 6:
577
+		var inspections []*models.Inspection
578
+
579
+		for _, item := range ids {
580
+			id, _ := strconv.ParseInt(item, 10, 64)
581
+			inspection, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id, start_time, end_time)
582
+			//fmt.Println(err)
583
+			//if err != nil {
584
+			//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
585
+			//	return
586
+			//}
587
+			for _, inspection_item := range inspection {
588
+				inspections = append(inspections, inspection_item)
589
+			}
590
+		}
591
+
592
+		c.ServeSuccessJSON(map[string]interface{}{
593
+			"inspections": inspections,
594
+			"type":        upload_type,
595
+		})
596
+
597
+		break
598
+	case 7:
599
+		var inspections []*models.Inspection
600
+
601
+		for _, item := range ids {
602
+			id, _ := strconv.ParseInt(item, 10, 64)
603
+			inspection, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id, start_time, end_time)
604
+			//fmt.Println(err)
605
+			//if err != nil {
606
+			//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
607
+			//	return
608
+			//}
609
+			for _, inspection_item := range inspection {
610
+				inspections = append(inspections, inspection_item)
611
+			}
612
+		}
613
+
614
+		c.ServeSuccessJSON(map[string]interface{}{
615
+			"inspections": inspections,
616
+			"type":        upload_type,
617
+		})
618
+
619
+		break
620
+
621
+	}
622
+
623
+	return
624
+
625
+}
626
+
627
+func (c *InspectionApiController) GetInitInsepction() {
628
+	references, _ := service.GetAllInspectionReference(0)
629
+	c.ServeSuccessJSON(map[string]interface{}{
630
+		"references": references,
631
+	})
632
+	return
633
+
634
+}

+ 435 - 0
controllers/integration_config_api_controller.go View File

@@ -0,0 +1,435 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/models"
6
+	"Xcx_New/service"
7
+	"github.com/astaxie/beego"
8
+	"time"
9
+)
10
+
11
+type IntegrationConfigApiController struct {
12
+	BaseAuthAPIController
13
+}
14
+
15
+func IntegrationConfigRegistRouters() {
16
+
17
+	beego.Router("/api/integration/patients", &IntegrationConfigApiController{}, "get:GetPatientsList")
18
+	beego.Router("/api/patienthis/edit", &IntegrationConfigApiController{}, "post:EditPatientHis")
19
+	beego.Router("/api/patienthis/create", &IntegrationConfigApiController{}, "post:CreatePatientHis")
20
+
21
+	beego.Router("/api/integration/admin", &IntegrationConfigApiController{}, "get:GetAdminsList")
22
+	beego.Router("/api/adminhis/edit", &IntegrationConfigApiController{}, "post:EditAdminHis")
23
+	beego.Router("/api/adminhis/create", &IntegrationConfigApiController{}, "post:CreateAdminHis")
24
+
25
+	beego.Router("/api/patienthis/getinterface", &IntegrationConfigApiController{}, "post:GetInterface")
26
+	beego.Router("/api/patienthis/saveinterface", &IntegrationConfigApiController{}, "post:SaveInterface")
27
+	beego.Router("/api/integration/synclist", &IntegrationConfigApiController{}, "get:GetSyncList")
28
+	beego.Router("/api/integration/sysinspectionlist", &IntegrationConfigApiController{}, "get:GetSysInspectionList")
29
+	beego.Router("/api/patienthis/saveinspectionsysitemid", &IntegrationConfigApiController{}, "post:SaveInspectionSysItemId")
30
+}
31
+
32
+func (c *IntegrationConfigApiController) SaveInspectionSysItemId() {
33
+	adminUserInfo := c.GetAdminUserInfo()
34
+	org_id, _ := c.GetInt64("org_id", 0)
35
+	sys_item_id, _ := c.GetInt64("sys_item_id", 0)
36
+	id, _ := c.GetInt64("id", 0)
37
+	if org_id != adminUserInfo.CurrentOrgId || sys_item_id <= 0 || id <= 0 {
38
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
39
+	}
40
+
41
+	inspection_reference := &models.InspectionReference{
42
+		ID:          id,
43
+		SysItemId:   sys_item_id,
44
+		UpdatedTime: time.Now().Unix(),
45
+	}
46
+	err := service.UpdateSysItemIdByID(inspection_reference)
47
+	if err != nil {
48
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
49
+	}
50
+	c.ServeSuccessJSON(map[string]interface{}{
51
+		"inspection_reference": inspection_reference,
52
+	})
53
+	return
54
+}
55
+
56
+func (c *IntegrationConfigApiController) GetSysInspectionList() {
57
+	adminUserInfo := c.GetAdminUserInfo()
58
+	sysInspection, ownerInspection, err := service.GetSysInspectionList(adminUserInfo.CurrentOrgId)
59
+	if err != nil {
60
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
61
+	}
62
+
63
+	type InspectionStruce struct {
64
+		ProjectName         string                        `gorm:"-" json:"project_name" form:"project_name"`
65
+		ProjectId           int64                         `gorm:"-" json:"project_id" form:"project_id"`
66
+		InspectionReference []*models.InspectionReference `gorm:"-" json:"inspection_reference" form:"inspection_reference"`
67
+	}
68
+
69
+	sysInspec := make(map[int64]*InspectionStruce, 0)
70
+	ownerInspec := make(map[int64]*InspectionStruce, 0)
71
+
72
+	for _, item := range sysInspection {
73
+		result := sysInspec[item.ProjectId]
74
+		if result == nil {
75
+			result = new(InspectionStruce)
76
+			result.ProjectName = item.ProjectName
77
+			result.ProjectId = item.ProjectId
78
+		}
79
+		result.InspectionReference = append(result.InspectionReference, item)
80
+		sysInspec[item.ProjectId] = result
81
+	}
82
+
83
+	for _, oitem := range ownerInspection {
84
+		oresult := ownerInspec[oitem.ProjectId]
85
+		if oresult == nil {
86
+			oresult = new(InspectionStruce)
87
+			oresult.ProjectName = oitem.ProjectName
88
+			oresult.ProjectId = oitem.ProjectId
89
+		}
90
+		oresult.InspectionReference = append(oresult.InspectionReference, oitem)
91
+		ownerInspec[oitem.ProjectId] = oresult
92
+	}
93
+
94
+	c.ServeSuccessJSON(map[string]interface{}{
95
+		"sysInspec":   sysInspec,
96
+		"ownerInspec": ownerInspec,
97
+	})
98
+	return
99
+}
100
+
101
+func (c *IntegrationConfigApiController) GetSyncList() {
102
+	page, _ := c.GetInt64("page", 1)
103
+	limit, _ := c.GetInt64("limit", 10)
104
+
105
+	if page <= 0 {
106
+		page = 1
107
+	}
108
+	if limit <= 0 {
109
+		limit = 10
110
+	}
111
+
112
+	adminUserInfo := c.GetAdminUserInfo()
113
+	patients, total, _ := service.GetSyncList(adminUserInfo.CurrentOrgId, page, limit)
114
+
115
+	c.ServeSuccessJSON(map[string]interface{}{
116
+		"list":  patients,
117
+		"total": total,
118
+	})
119
+	return
120
+}
121
+
122
+func (c *IntegrationConfigApiController) SaveInterface() {
123
+	adminUserInfo := c.GetAdminUserInfo()
124
+	ID, _ := c.GetInt64("id", 0)
125
+	OrgId := adminUserInfo.CurrentOrgId
126
+	Creater := adminUserInfo.AdminUser.Id
127
+	Pattern, _ := c.GetInt("pattern", 0)
128
+	Dbhost := c.GetString("dbhost")
129
+	Dbuser := c.GetString("dbuser")
130
+	Dbpassword := c.GetString("dbpassword")
131
+	Dbname := c.GetString("dbname")
132
+	InterfaceUrl := c.GetString("interface_url")
133
+	InterFaceToken := c.GetString("interface_token")
134
+	AllowIp := c.GetString("allow_ip")
135
+	AllowToken := c.GetString("allow_token")
136
+	SyncFrequency, _ := c.GetInt("sync_frequency")
137
+	Status := 1
138
+	UpdatedTime := time.Now().Unix()
139
+	interfaceinfo := &models.MiddleInterface{
140
+		ID:             ID,
141
+		OrgId:          OrgId,
142
+		Creater:        Creater,
143
+		Pattern:        Pattern,
144
+		Dbhost:         Dbhost,
145
+		Dbuser:         Dbuser,
146
+		Dbpassword:     Dbpassword,
147
+		Dbname:         Dbname,
148
+		InterfaceUrl:   InterfaceUrl,
149
+		InterFaceToken: InterFaceToken,
150
+		AllowIp:        AllowIp,
151
+		AllowToken:     AllowToken,
152
+		SyncFrequency:  SyncFrequency,
153
+		Status:         Status,
154
+		UpdatedTime:    UpdatedTime,
155
+	}
156
+	if ID <= 0 {
157
+		interfaceinfo.CreatedTime = time.Now().Unix()
158
+	}
159
+	err := service.SaveInterface(interfaceinfo)
160
+
161
+	if err == nil {
162
+		c.ServeSuccessJSON(map[string]interface{}{
163
+			"interfaceinfo": interfaceinfo,
164
+		})
165
+	} else {
166
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
167
+	}
168
+	return
169
+}
170
+
171
+func (c *IntegrationConfigApiController) GetInterface() {
172
+	adminUserInfo := c.GetAdminUserInfo()
173
+	interfaceinfo, _ := service.GetInterface(adminUserInfo.CurrentOrgId)
174
+	c.ServeSuccessJSON(map[string]interface{}{
175
+		"interfaceinfo": interfaceinfo,
176
+	})
177
+	return
178
+
179
+}
180
+
181
+func (c *IntegrationConfigApiController) GetPatientsList() {
182
+	page, _ := c.GetInt64("page", 1)
183
+	limit, _ := c.GetInt64("limit", 10)
184
+
185
+	if page <= 0 {
186
+		page = 1
187
+	}
188
+	if limit <= 0 {
189
+		limit = 10
190
+	}
191
+
192
+	adminUserInfo := c.GetAdminUserInfo()
193
+	patients, total, _ := service.GetIntegrationPatientList(adminUserInfo.CurrentOrgId, page, limit)
194
+
195
+	c.ServeSuccessJSON(map[string]interface{}{
196
+		"list":  patients,
197
+		"total": total,
198
+	})
199
+	return
200
+}
201
+
202
+func (c *IntegrationConfigApiController) EditPatientHis() {
203
+	his_user_id := c.GetString("his_user_id")
204
+	id, _ := c.GetInt64("id", 0)
205
+
206
+	adminUserInfo := c.GetAdminUserInfo()
207
+
208
+	total, _ := service.FindHisPatientByHisId(adminUserInfo.CurrentOrgId, his_user_id)
209
+
210
+	if total > 0 {
211
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisIdExist)
212
+		return
213
+
214
+	}
215
+
216
+	err := service.UpdatePatientsHis(adminUserInfo.CurrentOrgId, his_user_id, id)
217
+	if err == nil {
218
+		c.ServeSuccessJSON(map[string]interface{}{
219
+			"his_user_id": his_user_id,
220
+		})
221
+	} else {
222
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
223
+
224
+	}
225
+	return
226
+
227
+}
228
+
229
+func (c *IntegrationConfigApiController) CreatePatientHis() {
230
+	his_user_id := c.GetString("his_user_id")
231
+	id, _ := c.GetInt64("id", 0)
232
+
233
+	adminUserInfo := c.GetAdminUserInfo()
234
+	patient, _ := service.FindVMPatientById(adminUserInfo.CurrentOrgId, id)
235
+
236
+	total, _ := service.FindHisPatientByHisId(adminUserInfo.CurrentOrgId, his_user_id)
237
+
238
+	if total > 0 {
239
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisIdExist)
240
+		return
241
+
242
+	}
243
+
244
+	hisPatient := &models.HisPatients{
245
+		UserOrgId:                    adminUserInfo.CurrentOrgId,
246
+		UserId:                       patient.UserId,
247
+		Avatar:                       patient.Avatar,
248
+		PatientType:                  patient.PatientType,
249
+		DialysisNo:                   patient.DialysisNo,
250
+		AdmissionNumber:              patient.AdmissionNumber,
251
+		Source:                       patient.Source,
252
+		Lapseto:                      patient.Lapseto,
253
+		PartitionId:                  patient.PartitionId,
254
+		BedId:                        patient.BedId,
255
+		Name:                         patient.Name,
256
+		Alias:                        patient.Alias,
257
+		Gender:                       patient.Gender,
258
+		Nation:                       patient.Nation,
259
+		NativePlace:                  patient.NativePlace,
260
+		MaritalStatus:                patient.MaritalStatus,
261
+		IdCardNo:                     patient.IdCardNo,
262
+		Birthday:                     patient.Birthday,
263
+		ReimbursementWayId:           patient.ReimbursementWayId,
264
+		HealthCareType:               patient.HealthCareType,
265
+		HealthCareNo:                 patient.HealthCareNo,
266
+		HealthCareDueDate:            patient.HealthCareDueDate,
267
+		Height:                       patient.Height,
268
+		BloodType:                    patient.BloodType,
269
+		Rh:                           patient.Rh,
270
+		HealthCareDueAlertDate:       patient.HealthCareDueAlertDate,
271
+		EducationLevel:               patient.EducationLevel,
272
+		Profession:                   patient.Profession,
273
+		Phone:                        patient.Phone,
274
+		HomeTelephone:                patient.HomeTelephone,
275
+		RelativePhone:                patient.RelativePhone,
276
+		HomeAddress:                  patient.HomeAddress,
277
+		WorkUnit:                     patient.WorkUnit,
278
+		UnitAddress:                  patient.UnitAddress,
279
+		ReceivingDate:                patient.ReceivingDate,
280
+		IsHospitalFirstDialysis:      patient.IsHospitalFirstDialysis,
281
+		FirstDialysisDate:            patient.FirstDialysisDate,
282
+		FirstDialysisHospital:        patient.FirstDialysisHospital,
283
+		PredialysisCondition:         patient.PredialysisCondition,
284
+		PreHospitalDialysisFrequency: patient.PreHospitalDialysisFrequency,
285
+		PreHospitalDialysisTimes:     patient.PreHospitalDialysisTimes,
286
+		HospitalFirstDialysisDate:    patient.HospitalFirstDialysisDate,
287
+		InductionPeriod:              patient.InductionPeriod,
288
+		InitialDialysis:              patient.InitialDialysis,
289
+		TotalDialysis:                patient.TotalDialysis,
290
+		AttendingDoctorId:            patient.AttendingDoctorId,
291
+		HeadNurseId:                  patient.HeadNurseId,
292
+		Evaluate:                     patient.Evaluate,
293
+		Diagnose:                     patient.Diagnose,
294
+		Remark:                       patient.Remark,
295
+		RegistrarsId:                 patient.RegistrarsId,
296
+		Registrars:                   patient.Registrars,
297
+		QrCode:                       patient.QrCode,
298
+		BindingState:                 patient.BindingState,
299
+		PatientComplains:             patient.PatientComplains,
300
+		PresentHistory:               patient.PresentHistory,
301
+		PastHistory:                  patient.PastHistory,
302
+		Temperature:                  patient.Temperature,
303
+		Pulse:                        patient.Pulse,
304
+		Respiratory:                  patient.Respiratory,
305
+		Sbp:                          patient.SBP,
306
+		Dbp:                          patient.DBP,
307
+		Status:                       1,
308
+		CreatedTime:                  time.Now().Unix(),
309
+		UpdatedTime:                  time.Now().Unix(),
310
+		Age:                          patient.Age,
311
+		InfectiousNextRecordTime:     patient.InfectiousNextRecordTime,
312
+		IsInfectious:                 patient.IsInfectious,
313
+		RemindCycle:                  patient.RemindCycle,
314
+		ResponseResult:               patient.ResponseResult,
315
+		IsOpenRemind:                 patient.IsOpenRemind,
316
+		DialysisAge:                  patient.DialysisAge,
317
+		ExpenseKind:                  patient.ExpenseKind,
318
+		TellPhone:                    patient.TellPhone,
319
+		FirstTreatmentDate:           patient.FirstTreatmentDate,
320
+		ContactName:                  patient.ContactName,
321
+		HisUserId:                    his_user_id,
322
+		XtPatientId:                  patient.ID,
323
+	}
324
+
325
+	err := service.CreatePatientsHis(hisPatient)
326
+	if err == nil {
327
+		c.ServeSuccessJSON(map[string]interface{}{
328
+			"patient": hisPatient,
329
+		})
330
+	} else {
331
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
332
+
333
+	}
334
+	return
335
+
336
+}
337
+
338
+func (c *IntegrationConfigApiController) GetAdminsList() {
339
+	page, _ := c.GetInt("page", 1)
340
+	limit, _ := c.GetInt("limit", 10)
341
+
342
+	if page <= 0 {
343
+		page = 1
344
+	}
345
+	if limit <= 0 {
346
+		limit = 10
347
+	}
348
+
349
+	adminUserInfo := c.GetAdminUserInfo()
350
+
351
+	viewModels, total, getAdminsErr := service.GetAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, page, limit)
352
+	if getAdminsErr != nil {
353
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
354
+		return
355
+	}
356
+	c.ServeSuccessJSON(map[string]interface{}{
357
+		"admins":      viewModels,
358
+		"total_count": total,
359
+	})
360
+
361
+	return
362
+
363
+}
364
+
365
+func (c *IntegrationConfigApiController) EditAdminHis() {
366
+	his_user_id := c.GetString("his_user_id")
367
+	id, _ := c.GetInt64("id", 0)
368
+
369
+	adminUserInfo := c.GetAdminUserInfo()
370
+
371
+	total, _ := service.FindHisAdminByHisId(adminUserInfo.CurrentOrgId, his_user_id, adminUserInfo.CurrentAppId)
372
+
373
+	if total > 0 {
374
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisIdExist)
375
+		return
376
+
377
+	}
378
+
379
+	err := service.UpdateAdminsHis(adminUserInfo.CurrentOrgId, his_user_id, id)
380
+	if err == nil {
381
+		c.ServeSuccessJSON(map[string]interface{}{
382
+			"his_user_id": his_user_id,
383
+		})
384
+	} else {
385
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
386
+
387
+	}
388
+	return
389
+
390
+}
391
+
392
+func (c *IntegrationConfigApiController) CreateAdminHis() {
393
+	his_user_id := c.GetString("his_user_id")
394
+	id, _ := c.GetInt64("id", 0)
395
+
396
+	adminUserInfo := c.GetAdminUserInfo()
397
+	adminRole, _ := service.FindVMAdminRoleById(adminUserInfo.CurrentOrgId, id, adminUserInfo.CurrentAppId)
398
+
399
+	total, _ := service.FindHisAdminByHisId(adminUserInfo.CurrentOrgId, his_user_id, adminUserInfo.CurrentAppId)
400
+
401
+	if total > 0 {
402
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisIdExist)
403
+		return
404
+
405
+	}
406
+
407
+	hisAdminRole := &models.HisUserAdminRole{
408
+		OrgId:       adminUserInfo.CurrentOrgId,
409
+		AdminUserId: adminRole.AdminUserId,
410
+		AppId:       adminRole.AppId,
411
+		RoleId:      adminRole.RoleId,
412
+		UserName:    adminRole.UserName,
413
+		Avatar:      adminRole.Avatar,
414
+		UserType:    adminRole.UserType,
415
+		UserTitle:   adminRole.UserTitle,
416
+		Intro:       adminRole.Intro,
417
+		Status:      1,
418
+		Ctime:       time.Now().Unix(),
419
+		Mtime:       time.Now().Unix(),
420
+		XtRoleId:    adminRole.ID,
421
+		HisUserId:   his_user_id,
422
+	}
423
+
424
+	err := service.CreateAdminsHis(hisAdminRole)
425
+	if err == nil {
426
+		c.ServeSuccessJSON(map[string]interface{}{
427
+			"his_role": hisAdminRole,
428
+		})
429
+	} else {
430
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
431
+
432
+	}
433
+	return
434
+
435
+}

+ 164 - 0
controllers/invoice_api_controller.go View File

@@ -0,0 +1,164 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/models"
6
+	"Xcx_New/service"
7
+	"encoding/json"
8
+	"fmt"
9
+	"github.com/astaxie/beego"
10
+	"regexp"
11
+	"strconv"
12
+	"strings"
13
+	"time"
14
+)
15
+
16
+type InvoiceApiController struct {
17
+	BaseServeAPIController
18
+}
19
+
20
+func InvoiceApiRegistRouters() {
21
+	beego.Router("/api/invoice/applies", &InvoiceApiController{}, "Get:GetApplies")
22
+	beego.Router("/api/invoice/apply", &InvoiceApiController{}, "Post:CreateInvoice")
23
+	beego.Router("/api/invoice/noinvorders", &InvoiceApiController{}, "Get:GetNoInvOrders")
24
+	beego.Router("/api/invoices", &InvoiceApiController{}, "Get:GetInvoices")
25
+}
26
+
27
+func (c *InvoiceApiController) GetApplies() {
28
+	orders := c.GetString("orders")
29
+	if len(orders) == 0 {
30
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
31
+		return
32
+	}
33
+
34
+	if match, _ := regexp.MatchString("^([0-9]+[,])*([0-9]+)$", orders); !match {
35
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
36
+		return
37
+	}
38
+
39
+	adminUserInfo := c.GetAdminUserInfo()
40
+
41
+	ordersIDSlipe := make([]int64, 0)
42
+	ordersSlipe := strings.Split(orders, ",")
43
+	for index := range ordersSlipe {
44
+		orderid, _ := strconv.ParseInt(ordersSlipe[index], 10, 64)
45
+		if orderid > 0 {
46
+			ordersIDSlipe = append(ordersIDSlipe, orderid)
47
+		}
48
+	}
49
+	if len(ordersIDSlipe) == 0 {
50
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
51
+		return
52
+	}
53
+
54
+	has, nos, err := service.FindServeOrdersByIDs(adminUserInfo.CurrentOrgId, ordersIDSlipe)
55
+	if err != nil {
56
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
57
+		return
58
+	}
59
+
60
+	c.ServeSuccessJSON(map[string]interface{}{
61
+		"has": has,
62
+		"nos": nos,
63
+	})
64
+}
65
+
66
+func (c *InvoiceApiController) CreateInvoice() {
67
+	orders := c.GetString("orders")
68
+	if len(orders) == 0 {
69
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
70
+		return
71
+	}
72
+
73
+	if match, _ := regexp.MatchString("^([0-9]+[,])*([0-9]+)$", orders); !match {
74
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
75
+		return
76
+	}
77
+
78
+	adminUserInfo := c.GetAdminUserInfo()
79
+
80
+	ordersIDSlipe := make([]int64, 0)
81
+	ordersSlipe := strings.Split(orders, ",")
82
+	for index := range ordersSlipe {
83
+		orderid, _ := strconv.ParseInt(ordersSlipe[index], 10, 64)
84
+		if orderid > 0 {
85
+			ordersIDSlipe = append(ordersIDSlipe, orderid)
86
+		}
87
+	}
88
+	if len(ordersIDSlipe) == 0 {
89
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
90
+		return
91
+	}
92
+
93
+	_, nos, err := service.FindServeOrdersByIDs(adminUserInfo.CurrentOrgId, ordersIDSlipe)
94
+	if err != nil {
95
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
96
+		return
97
+	}
98
+	if len(nos) == 0 {
99
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
100
+		return
101
+	}
102
+
103
+	var invoiceData models.ServeInvoice
104
+	err = json.Unmarshal(c.Ctx.Input.RequestBody, &invoiceData)
105
+	if err != nil {
106
+		fmt.Println(err)
107
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
108
+		return
109
+	}
110
+
111
+	inds := make([]string, 0)
112
+	var inc float64
113
+	for index := range nos {
114
+		inds = append(inds, strconv.FormatInt(nos[index].ID, 10))
115
+		inc += nos[index].PayableAmount
116
+	}
117
+
118
+	invoiceData.OrgId = adminUserInfo.CurrentOrgId
119
+	invoiceData.Status = 1
120
+	invoiceData.CreatedTime = time.Now().Unix()
121
+	invoiceData.UpdatedTime = time.Now().Unix()
122
+	invoiceData.InvoiceAmountGross = inc
123
+	orders = "," + strings.Join(inds, ",") + ","
124
+	invoiceData.Orders = orders
125
+	invoiceData.InvoiceStatus = 1
126
+
127
+	err = service.CreateInvoice(&invoiceData)
128
+	if err != nil {
129
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeApplyInvoiceFail)
130
+		return
131
+	}
132
+
133
+	c.ServeSuccessJSON(map[string]interface{}{
134
+		"invoice": invoiceData,
135
+	})
136
+}
137
+
138
+func (c *InvoiceApiController) GetNoInvOrders() {
139
+	adminUserInfo := c.GetAdminUserInfo()
140
+
141
+	orders, err := service.FindUnInvoiceOrders(adminUserInfo.CurrentOrgId)
142
+	if err != nil {
143
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
144
+		return
145
+	}
146
+
147
+	c.ServeSuccessJSON(map[string]interface{}{
148
+		"orders": orders,
149
+	})
150
+}
151
+
152
+func (c *InvoiceApiController) GetInvoices() {
153
+	adminUserInfo := c.GetAdminUserInfo()
154
+
155
+	invoices, err := service.FindInvoices(adminUserInfo.CurrentOrgId)
156
+	if err != nil {
157
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
158
+		return
159
+	}
160
+
161
+	c.ServeSuccessJSON(map[string]interface{}{
162
+		"invoices": invoices,
163
+	})
164
+}

File diff suppressed because it is too large
+ 4133 - 0
controllers/manage_api_controller.go


File diff suppressed because it is too large
+ 2230 - 0
controllers/manager_center_api_controller.go


+ 0 - 20
controllers/mobile_api_controller.go View File

@@ -1,20 +0,0 @@
1
-package controllers
2
-
3
-import (
4
-	"fmt"
5
-	"github.com/astaxie/beego"
6
-)
7
-
8
-type MobileController struct {
9
-	BaseAPIController
10
-}
11
-
12
-func MobileRegisterRouters() {
13
-
14
-	beego.Router("/api/mobile/login", &MobileController{}, "Get:GetMobileLogin")
15
-}
16
-
17
-func (this *MobileController) GetMobileLogin() {
18
-
19
-	fmt.Println("出发多舒服的方式大发阿凡达")
20
-}

File diff suppressed because it is too large
+ 2141 - 0
controllers/new_mobile_api_controllers/common_api_controller.go


+ 62 - 0
controllers/new_mobile_api_controllers/common_api_router.go View File

@@ -0,0 +1,62 @@
1
+package new_mobile_api_controllers
2
+
3
+import (
4
+	"github.com/astaxie/beego"
5
+)
6
+
7
+func CommonApiControllersRegisterRouters() {
8
+
9
+	beego.Router("/com/api/getinspectionmajor", &CommonApiController{}, "Get:GetInspectionMajor")
10
+	beego.Router("/com/api/getinspectionminor", &CommonApiController{}, "Get:GetInspectionMinor")
11
+	beego.Router("/com/api/getinspectionrange", &CommonApiController{}, "Get:GetInspectionRange")
12
+	beego.Router("/com/api/saveconfiguration", &CommonApiController{}, "Post:SaveConfiguration")
13
+	beego.Router("com/api/getconfigurationlist", &CommonApiController{}, "Get:GetConfigurationlist")
14
+	beego.Router("com/api/getconfigurationdetail", &CommonApiController{}, "Get:GetConfigurationDetail")
15
+	beego.Router("com/api/getallinspectionminor", &CommonApiController{}, "Get:GetAllInspectionminor")
16
+	beego.Router("com/api/updateconfiguration", &CommonApiController{}, "Post:UpdateConfiguration")
17
+	beego.Router("com/api/deleteconfiguration", &CommonApiController{}, "Delete:DeleteConfiguration")
18
+	beego.Router("com/api/getallinspectiondata", &CommonApiController{}, "Get:GetAllInspectiondata")
19
+	beego.Router("/com/api/savecheckconfiguration", &CommonApiController{}, "Post:SaveCheckConfiguration")
20
+	beego.Router("/com/api/getallchecklist", &CommonApiController{}, "Get:GetAllCheckList")
21
+	beego.Router("/com/api/getcheckdetail", &CommonApiController{}, "Get:GetCheckdetail")
22
+	beego.Router("/com/api/updatecheck", &CommonApiController{}, "Post:UpdateCheck")
23
+	beego.Router("/com/api/deletecheck", &CommonApiController{}, "Delete:DeleteCheck")
24
+	beego.Router("/com/api/getdialysismodetype", &CommonApiController{}, "Get:GetDialysisModeType")
25
+	beego.Router("/com/api/gettotallapsecount", &CommonApiController{}, "Get:GetTotalLapseCount")
26
+	beego.Router("/com/api/gettotalsexcount", &CommonApiController{}, "Get:GetTotalSexCount")
27
+	beego.Router("/com/api/gettoalinfectiouscount", &CommonApiController{}, "Get:GetTotalInfectiouscount")
28
+	beego.Router("/com/api/gettotalagecount", &CommonApiController{}, "Get:GetTotalAgeCount")
29
+	beego.Router("/com/api/gettotaldialysiscount", &CommonApiController{}, "Get:GetTotalDialysisCount")
30
+	beego.Router("/com/api/getcurentorgpatients", &CommonApiController{}, "Get:GetCurentOrgPatients")
31
+	beego.Router("/com/api/getdialysislist", &CommonApiController{}, "Get:GetDialysislist")
32
+	beego.Router("/com/api/getlastsort", &CommonApiController{}, "Get:GetLastSort")
33
+	beego.Router("/com/api/getlastchecklist", &CommonApiController{}, "Get:GetLastCheckList")
34
+	beego.Router("/com/api/getdialysisdetailbyid", &CommonApiController{}, "Get:GetDialysisDetailById")
35
+	beego.Router("/com/api/getprescriptionbyname", &CommonApiController{}, "Get:GetPrescritionByName")
36
+	beego.Router("/com/api/getstatistics", &CommonApiController{}, "Get:GetStatistics")
37
+	beego.Router("/com/api/getinspectiontotalcount", &CommonApiController{}, "Get:GetInspectionTatolCount")
38
+	beego.Router("/com/api/getinspectionDetailById", &CommonApiController{}, "Get:GetInspectionDetailById")
39
+	beego.Router("/com/api/getsearchpatientinfo", &CommonApiController{}, "Get:GetSearchPatientInfo")
40
+	beego.Router("/com/api/getallmajorInspection", &CommonApiController{}, "Get:GetAllMajorInspection")
41
+	beego.Router("/com/api/getpatientlist", &CommonApiController{}, "Get:GetPatientList")
42
+	beego.Router("/com/api/getPatientDetailCheck", &CommonApiController{}, "Get:GetPatientDetailCheck")
43
+	beego.Router("/com/api/searchdetailcheck", &CommonApiController{}, "Get:GetSearchDetailCheck")
44
+	beego.Router("/com/api/getnormdata", &CommonApiController{}, "Get:GetNormData")
45
+	beego.Router("/com/api/getfirstquarter", &CommonApiController{}, "Get:GetFirstQuarter")
46
+	beego.Router("/com/api/getprojectlist", &CommonApiController{}, "Get:GetProjectList")
47
+	beego.Router("/com/api/getmonthprojectlist", &CommonApiController{}, "Get:GetMonthProjectList")
48
+	beego.Router("/com/api/getpatientscontrol", &CommonApiController{}, "Get:GetPatientscontrol")
49
+	beego.Router("/com/api/getcartogramlist", &CommonApiController{}, "Get:GetCartogramList")
50
+	beego.Router("/com/api/getpatientcontor", &CommonApiController{}, "Get:GetPatientContor")
51
+	beego.Router("/com/api/getqualitycontrol", &CommonApiController{}, "Get:GetQualityControl")
52
+	beego.Router("/com/api/gettreatlist", &CommonApiController{}, "Get:GetTreatlist")
53
+	beego.Router("/com/api/getpatientcompliancedetal", &CommonApiController{}, "Get:GetPatientComplianceDetail")
54
+	beego.Router("/com/api/getbloodpressuredetail", &CommonApiController{}, "Get:GetBloodPressureDetail")
55
+	beego.Router("/com/api/updatebloodprussre", &CommonApiController{}, "Post:UpdateBloodPrussre")
56
+	beego.Router("/com/api/getbloodpressurelist", &CommonApiController{}, "Get:GetBloodPressureList")
57
+	beego.Router("/com/api/getmonthbloodlist", &CommonApiController{}, "Get:GetMonthBloodList")
58
+	beego.Router("/com/api/getidslist", &CommonApiController{}, "Post:GetIdsListTwo")
59
+	beego.Router("/com/api/getreatmodelist", &CommonApiController{}, "Get:GetTreatModeList")
60
+	beego.Router("/com/api/getcountmodeid", &CommonApiController{}, "Get:GetCountModeId")
61
+	beego.Router("/com/api/getrolloutcount", &CommonApiController{}, "Get:GetRolloutCount")
62
+}

+ 258 - 0
controllers/new_mobile_api_controllers/dialysis_parameter_api_controller.go View File

@@ -0,0 +1,258 @@
1
+package new_mobile_api_controllers
2
+
3
+import (
4
+	"Xcx_New/controllers/mobile_api_controllers"
5
+	"Xcx_New/enums"
6
+	"Xcx_New/service"
7
+	"fmt"
8
+	"github.com/jinzhu/gorm"
9
+	"time"
10
+)
11
+
12
+type DialysisParamerterApiController struct {
13
+	mobile_api_controllers.MobileBaseAPIAuthController
14
+}
15
+
16
+func (this *DialysisParamerterApiController) GetAllMobileZon() {
17
+
18
+	adminUserInfo := this.GetMobileAdminUserInfo()
19
+	orgid := adminUserInfo.Org.Id
20
+	err, zone := service.GetAllDeviceZone(orgid)
21
+	if err == nil {
22
+		this.ServeSuccessJSON(map[string]interface{}{
23
+			"zone": zone,
24
+		})
25
+	}
26
+}
27
+
28
+func (this *DialysisParamerterApiController) GetMobileDialysisParameters() {
29
+	timeLayout := "2006-01-02"
30
+	loc, _ := time.LoadLocation("Local")
31
+	adminUserInfo := this.GetMobileAdminUserInfo()
32
+	orgid := adminUserInfo.Org.Id
33
+	fmt.Println(orgid)
34
+	keywords := this.GetString("keyword")
35
+	start_time := this.GetString("start_time")
36
+	fmt.Println("start_time", start_time)
37
+	limit, _ := this.GetInt64("limit")
38
+	fmt.Println(limit)
39
+	page, _ := this.GetInt64("page")
40
+	fmt.Println(page)
41
+	partitionType, _ := this.GetInt64("partitionType")
42
+	fmt.Println("partiontype", partitionType)
43
+	scheduleType, _ := this.GetInt64("scheduleType")
44
+	fmt.Println(scheduleType)
45
+
46
+	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
47
+	if len(keywords) > 0 {
48
+
49
+		//dialysisSchedule, err, total := service.GetDialysisParametersByKeyword(orgid, keywords, scheduleType, partitionType, page, limit, theTime.Unix())
50
+		//查询今日排班的病人
51
+		patient, err := service.GetDialysisTodaySchedulePatient(orgid, theTime.Unix(), page, limit, keywords, scheduleType, partitionType)
52
+		var vlist []interface{}
53
+		var elist []interface{}
54
+		for _, item := range patient {
55
+			prescription, _ := service.GetDialysisPrescriptionList(item.PatientId, orgid, theTime.Unix())
56
+			vlist = append(vlist, prescription)
57
+			dialysis, _ := service.GetAssessmentBeforDialysisByStartime(item.PatientId, orgid, theTime.Unix())
58
+			elist = append(elist, dialysis)
59
+			if err == nil {
60
+				this.ServeSuccessJSON(map[string]interface{}{
61
+					//"schedule":     dialysisSchedule,
62
+					//"total":        total,
63
+					"prescription": vlist,
64
+					"dialysbefor":  elist,
65
+					"patient":      patient,
66
+				})
67
+			} else {
68
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
69
+			}
70
+		}
71
+	} else {
72
+		dialysisSchedule, err, total := service.GetDialysisParameter(orgid, theTime.Unix(), scheduleType, partitionType, page, limit)
73
+		//查询今日排班的病人
74
+		patient, err := service.GetDialysisTodaySchedulePatient(orgid, theTime.Unix(), page, limit, keywords, scheduleType, partitionType)
75
+		var vlist []interface{}
76
+		var elist []interface{}
77
+		for _, item := range patient {
78
+			prescription, _ := service.GetDialysisPrescriptionList(item.PatientId, orgid, theTime.Unix())
79
+			vlist = append(vlist, prescription)
80
+			dialysis, _ := service.GetAssessmentBeforDialysisByStartime(item.PatientId, orgid, theTime.Unix())
81
+			elist = append(elist, dialysis)
82
+		}
83
+		if err == nil {
84
+			this.ServeSuccessJSON(map[string]interface{}{
85
+				"schedule":     dialysisSchedule,
86
+				"total":        total,
87
+				"prescription": vlist,
88
+				"dialysbefor":  elist,
89
+				"patient":      patient,
90
+			})
91
+		} else {
92
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
93
+		}
94
+	}
95
+}
96
+
97
+func (this *DialysisParamerterApiController) GetMobileWareHouseOutList() {
98
+
99
+	timeLayout := "2006-01-02"
100
+	loc, _ := time.LoadLocation("Local")
101
+	start_time := this.GetString("start_time")
102
+	startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
103
+	end_time := this.GetString("end_time")
104
+	endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
105
+	fmt.Println(start_time, end_time)
106
+	orgId := this.GetMobileAdminUserInfo().Org.Id
107
+	wareoutlist, err := service.GetWareHouseOutList(startime.Unix(), endtime.Unix(), orgId)
108
+	count, err := service.GetAnticoagulantCount(startime.Unix(), endtime.Unix(), orgId)
109
+	if err == nil {
110
+		this.ServeSuccessJSON(map[string]interface{}{
111
+			"wareoutlist": wareoutlist,
112
+			"count":       count,
113
+		})
114
+	}
115
+
116
+}
117
+
118
+func (this *DialysisParamerterApiController) GetAllMobileMaterial() {
119
+
120
+	timeLayout := "2006-01-02"
121
+	loc, _ := time.LoadLocation("Local")
122
+	start_time := this.GetString("startime")
123
+	startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
124
+	fmt.Println("开始时间", startime)
125
+	endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 23:59:59", loc)
126
+	fmt.Println("结束时间", endtime)
127
+	adminUserInfo := this.GetMobileAdminUserInfo()
128
+	orgId := adminUserInfo.Org.Id
129
+	material, err := service.GetAllMaterial(startime.Unix(), endtime.Unix(), orgId)
130
+	if err == nil {
131
+		this.ServeSuccessJSON(map[string]interface{}{
132
+			"material": material,
133
+		})
134
+	}
135
+}
136
+
137
+func (this *DialysisParamerterApiController) GetMobileCollectList() {
138
+
139
+	timeLayout := "2006-01-02"
140
+	loc, _ := time.LoadLocation("Local")
141
+	limit, _ := this.GetInt64("limit")
142
+	fmt.Println(limit)
143
+	page, _ := this.GetInt64("page")
144
+	fmt.Println("page", page)
145
+	partitiontype, _ := this.GetInt64("partitionType")
146
+	fmt.Println(partitiontype)
147
+	scheduletype, _ := this.GetInt64("scheduleType")
148
+	fmt.Println(scheduletype)
149
+	start_time := this.GetString("start_time")
150
+	fmt.Println(start_time)
151
+	startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
152
+	orgId := this.GetMobileAdminUserInfo().Org.Id
153
+	keyword := this.GetString("keyword")
154
+	//获取透析参数数据
155
+	//schedule, err, _ := service.GetCollectList(limit, page, partitiontype, scheduletype, startime.Unix(), orgId, keyword)
156
+	//查询今日排班的病人
157
+	patient, err := service.GetDialysisTodaySchedulePatient(orgId, startime.Unix(), page, limit, keyword, scheduletype, partitiontype)
158
+	var vlist []interface{}
159
+	var clist []interface{}
160
+	for _, item := range patient {
161
+		prescription, _ := service.GetDialysisPrescriptionList(item.PatientId, orgId, startime.Unix())
162
+		vlist = append(vlist, prescription)
163
+	}
164
+	_, errors := service.FindStockOutByIsSys(orgId, 1, startime.Unix())
165
+
166
+	goodTypes, _ := service.FindAllGoodType(orgId) //two, err, i := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
167
+
168
+	if errors == gorm.ErrRecordNotFound {
169
+		dialysisGoods, _, total := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
170
+		for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
171
+			goodUser, _ := service.GetLastDialysisGoods(item.PatientId, orgId, startime.Unix())
172
+			lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, orgId, startime.Unix())
173
+			item.LastAutomaticReduceDetail = goodUser
174
+			item.LastDialysisBeforePrepare = lastGoodUserDetial
175
+		}
176
+		this.ServeSuccessJSON(map[string]interface{}{
177
+			"dialysis_goods": dialysisGoods,
178
+			"good_type":      goodTypes,
179
+			"total":          total,
180
+			//"schedule":       schedule,
181
+			"prescription": vlist,
182
+			"patient":      patient,
183
+		})
184
+		return
185
+
186
+	} else if err == nil {
187
+		//获取当天排班的每个患者的库存使用情况
188
+		dialysisGoods, err, total := service.PCGetDialysisGoodsTwo(orgId, startime.Unix(), scheduletype, partitiontype, page, limit, keyword)
189
+		for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
190
+			goodUser, _ := service.GetLastDialysisGoods(item.PatientId, orgId, startime.Unix())
191
+			lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, orgId, startime.Unix())
192
+
193
+			fmt.Println(goodUser)
194
+			fmt.Println(lastGoodUserDetial)
195
+
196
+			item.LastAutomaticReduceDetail = goodUser
197
+			item.LastDialysisBeforePrepare = lastGoodUserDetial
198
+		}
199
+		if err == nil {
200
+			this.ServeSuccessJSON(map[string]interface{}{
201
+				"dialysis_goods": dialysisGoods,
202
+				"good_type":      goodTypes,
203
+				"total":          total,
204
+				//"schedule":       schedule,
205
+				//"consumables":    consumables,
206
+				"prescription": vlist,
207
+				"reducelist":   clist,
208
+			})
209
+			return
210
+
211
+		} else {
212
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
213
+			return
214
+		}
215
+	} else if err != nil {
216
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
217
+		return
218
+
219
+	}
220
+	//if err == nil {
221
+	//	this.ServeSuccessJSON(map[string]interface{}{
222
+	//		"schedule":     schedule,
223
+	//		"total":        total,
224
+	//		"consumables":  consumables,
225
+	//		"prescription": vlist,
226
+	//		"reducelist":   clist,
227
+	//	})
228
+	//}
229
+}
230
+
231
+func (this *DialysisParamerterApiController) GetMobileGatherList() {
232
+
233
+	timeLayout := "2006-01-02"
234
+	loc, _ := time.LoadLocation("Local")
235
+	start_time := this.GetString("start_time")
236
+	end_time := this.GetString("end_time")
237
+	startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
238
+	endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
239
+	adminUserInfo := this.GetMobileAdminUserInfo()
240
+	orgId := adminUserInfo.Org.Id
241
+	fmt.Println("开始时间", startime)
242
+	fmt.Println("结束时间", endtime)
243
+	warehouselist, err := service.GetWareHouseOutList(startime.Unix(), endtime.Unix(), orgId)
244
+
245
+	//获取透析耗材数据
246
+	consumables, err := service.GetDialysisConsumables(startime.Unix(), endtime.Unix(), orgId)
247
+
248
+	//统计抗凝剂数据
249
+	count, err := service.GetAnticoagulantCount(startime.Unix(), endtime.Unix(), orgId)
250
+
251
+	if err == nil {
252
+		this.ServeSuccessJSON(map[string]interface{}{
253
+			"warehouselist": warehouselist,
254
+			"consumables":   consumables,
255
+			"count":         count,
256
+		})
257
+	}
258
+}

+ 15 - 0
controllers/new_mobile_api_controllers/dialysis_parameter_api_router.go View File

@@ -0,0 +1,15 @@
1
+package new_mobile_api_controllers
2
+
3
+import (
4
+	"github.com/astaxie/beego"
5
+)
6
+
7
+func DialysisParameterApiControllersRegisterRouters() {
8
+
9
+	beego.Router("/m/api/getallmobilezone", &DialysisParamerterApiController{}, "Get:GetAllMobileZon")
10
+	beego.Router("/m/api/getmobiledialysisparameters", &DialysisParamerterApiController{}, "Get:GetMobileDialysisParameters")
11
+	beego.Router("/m/api/getmobilewarehouseoutlist", &DialysisParamerterApiController{}, "Get:GetMobileWareHouseOutList")
12
+	beego.Router("/m/api/getallmobilematerial", &DialysisParamerterApiController{}, "Get:GetAllMobileMaterial")
13
+	beego.Router("/m/api/getmobilecollectlist", &DialysisParamerterApiController{}, "Get:GetMobileCollectList")
14
+	beego.Router("/m/api/getmobilegatherlist", &DialysisParamerterApiController{}, "Get:GetMobileGatherList")
15
+}

+ 7 - 0
controllers/new_mobile_api_controllers/dialysis_process_api_controller.go View File

@@ -0,0 +1,7 @@
1
+package new_mobile_api_controllers
2
+
3
+import "Xcx_New/controllers/mobile_api_controllers"
4
+
5
+type DialysisProcessApiController struct {
6
+	mobile_api_controllers.MobileBaseAPIController
7
+}

+ 260 - 0
controllers/new_mobile_api_controllers/forget_password_controller.go View File

@@ -0,0 +1,260 @@
1
+package new_mobile_api_controllers
2
+
3
+import (
4
+	"Xcx_New/controllers/mobile_api_controllers"
5
+	"Xcx_New/enums"
6
+	"Xcx_New/models"
7
+	"Xcx_New/service"
8
+	"Xcx_New/utils"
9
+	"encoding/json"
10
+	"fmt"
11
+	"github.com/astaxie/beego"
12
+	"io/ioutil"
13
+	"net/http"
14
+	"net/url"
15
+	"strconv"
16
+)
17
+
18
+type ForgetPwdController struct {
19
+	mobile_api_controllers.MobileBaseAPIController
20
+}
21
+
22
+func (this *ForgetPwdController) ModifyPassword() {
23
+	mobile := this.GetString("mobile")
24
+	code := this.GetString("code")
25
+	password := this.GetString("password")
26
+	checkErr := this.checkParams(mobile, code, password)
27
+	if checkErr != nil {
28
+		this.ServeFailJSONWithSGJErrorCode(checkErr.Code)
29
+		return
30
+	}
31
+
32
+	adminUser, _ := service.GetValidAdminUserByMobileReturnErr(mobile)
33
+
34
+	modifyErr := service.ModifyPassword(adminUser.Id, password)
35
+	if modifyErr != nil {
36
+		utils.ErrorLog("修改mobile=%v的用户的密码时失败: %v", mobile, modifyErr)
37
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
38
+		return
39
+	} else {
40
+		// 修改成功后验证码就要使其失效
41
+		redisClient := service.RedisClient()
42
+		defer redisClient.Close()
43
+		redisClient.Del("code_msg_" + mobile)
44
+
45
+		ip := utils.GetIP(this.Ctx.Request)
46
+		ssoDomain := beego.AppConfig.String("sso_domain")
47
+		api := ssoDomain + "/m/login/pwd"
48
+		values := make(url.Values)
49
+		values.Set("mobile", mobile)
50
+		values.Set("password", password)
51
+		values.Set("app_type", "3")
52
+		values.Set("ip", ip)
53
+		resp, requestErr := http.PostForm(api, values)
54
+
55
+		if requestErr != nil {
56
+			utils.ErrorLog("请求SSO登录接口失败: %v", requestErr)
57
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
58
+			return
59
+		}
60
+		defer resp.Body.Close()
61
+		body, ioErr := ioutil.ReadAll(resp.Body)
62
+		if ioErr != nil {
63
+			utils.ErrorLog("SSO登录接口返回数据读取失败: %v", ioErr)
64
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
65
+			return
66
+		}
67
+		var respJSON map[string]interface{}
68
+		utils.InfoLog(string(body))
69
+		if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
70
+			utils.ErrorLog("SSO登录接口返回数据解析JSON失败: %v", err)
71
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
72
+			return
73
+		}
74
+
75
+		if respJSON["state"].(float64) != 1 {
76
+			msg := respJSON["msg"].(string)
77
+			utils.ErrorLog("SSO登录接口请求失败: %v", msg)
78
+			if int(respJSON["code"].(float64)) == 609 {
79
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAccountOrPasswordWrong)
80
+				return
81
+			}
82
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
83
+			return
84
+		} else {
85
+			utils.SuccessLog("SSO登录成功")
86
+			// 下面这几段 Map=>JSON=>Struct 的流程可能会造成速度很慢
87
+			userJSON := respJSON["data"].(map[string]interface{})["admin"].(map[string]interface{})
88
+			userJSONBytes, _ := json.Marshal(userJSON)
89
+			var adminUser models.AdminUser
90
+			if err := json.Unmarshal(userJSONBytes, &adminUser); err != nil {
91
+				utils.ErrorLog("解析管理员失败:%v", err)
92
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
93
+				return
94
+			}
95
+
96
+			var org models.Org
97
+			if respJSON["data"].(map[string]interface{})["org"] != nil {
98
+				orgJSON := respJSON["data"].(map[string]interface{})["org"].(map[string]interface{})
99
+				orgJSONBytes, _ := json.Marshal(orgJSON)
100
+				if err := json.Unmarshal(orgJSONBytes, &org); err != nil {
101
+					utils.ErrorLog("解析机构失败:%v", err)
102
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
103
+					return
104
+				}
105
+			}
106
+
107
+			var app models.OrgApp
108
+
109
+			if respJSON["data"].(map[string]interface{})["app"] != nil {
110
+				appJSON := respJSON["data"].(map[string]interface{})["app"].(map[string]interface{})
111
+				appJSONBytes, _ := json.Marshal(appJSON)
112
+				if err := json.Unmarshal(appJSONBytes, &app); err != nil {
113
+					utils.ErrorLog("解析应用失败:%v", err)
114
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
115
+					return
116
+				}
117
+			}
118
+
119
+			var appRole models.App_Role
120
+
121
+			if respJSON["data"].(map[string]interface{})["app_role"] != nil {
122
+				appRoleJSON := respJSON["data"].(map[string]interface{})["app_role"].(map[string]interface{})
123
+				appRoleJSONBytes, _ := json.Marshal(appRoleJSON)
124
+				if err := json.Unmarshal(appRoleJSONBytes, &appRole); err != nil {
125
+					utils.ErrorLog("解析AppRole失败:%v", err)
126
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
127
+					return
128
+				}
129
+			}
130
+
131
+			var subscibe models.ServeSubscibe
132
+			if respJSON["data"].(map[string]interface{})["subscibe"] != nil {
133
+				subscibeJSON := respJSON["data"].(map[string]interface{})["subscibe"].(map[string]interface{})
134
+				subscibeJSONBytes, _ := json.Marshal(subscibeJSON)
135
+				if err := json.Unmarshal(subscibeJSONBytes, &subscibe); err != nil {
136
+					utils.ErrorLog("解析Subscibe失败:%v", err)
137
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
138
+					return
139
+				}
140
+
141
+			}
142
+			//service.GetOrgSubscibeState(&subscibe)
143
+			templateInfo, _ := service.GetOrgInfoTemplate(org.Id)
144
+
145
+			mobileAdminUserInfo := &mobile_api_controllers.MobileAdminUserInfo{
146
+				AdminUser:    &adminUser,
147
+				Org:          &org,
148
+				App:          &app,
149
+				AppRole:      &appRole,
150
+				Subscibe:     &subscibe,
151
+				TemplateInfo: &templateInfo,
152
+			}
153
+			//设置seesion
154
+			this.SetSession("mobile_admin_user_info", mobileAdminUserInfo)
155
+
156
+			//设置cookie
157
+			mobile = mobile + "-" + strconv.FormatInt(org.Id, 10) + "-" + strconv.FormatInt(appRole.Id, 10)
158
+			token := utils.GenerateLoginToken(mobile)
159
+			expiration, _ := beego.AppConfig.Int64("mobile_token_expiration_second")
160
+			this.Ctx.SetCookie("token_cookie", token, expiration, "/")
161
+
162
+			var configList interface{}
163
+			var dict_configList interface{}
164
+
165
+			var FiledList []*models.FiledConfig
166
+
167
+			if org.Id > 0 {
168
+				configList, _ = service.GetConfigList(org.Id)
169
+				dict_configList, _ = service.GetDictConfigList(org.Id)
170
+
171
+				FiledList, _ = service.FindFiledByOrgId(org.Id)
172
+			}
173
+			if len(FiledList) == 0 {
174
+				var err error
175
+				if org.Id > 0 {
176
+					err = service.BatchInsertFiledConfig(org.Id)
177
+					if err == nil {
178
+						FiledList, _ = service.FindFiledByOrgId(org.Id)
179
+					} else {
180
+						utils.ErrorLog("字段批量插入失败:%v", err)
181
+					}
182
+				} else {
183
+					FiledList = make([]*models.FiledConfig, 0)
184
+				}
185
+			}
186
+
187
+			if org.Id > 0 {
188
+				//产寻该机构是否有收缩压和舒张压
189
+				pressure, err := service.GetDefaultSystolicPressure(org.Id)
190
+				fmt.Println(err)
191
+				if len(pressure) == 0 {
192
+					err = service.BathInsertQualityControlTwo(org.Id)
193
+				} else {
194
+					utils.ErrorLog("字段批量插入失败:%v", err)
195
+				}
196
+				major, requestErr := service.GetInspectionMajor(org.Id)
197
+				if len(major) == 0 {
198
+					QualityeList, err := service.FindQualityByOrgId(org.Id)
199
+					if len(QualityeList) == 0 {
200
+						err = service.BatchInsertQualityControl(org.Id)
201
+					} else {
202
+						utils.ErrorLog("字段批量插入失败:%v", err)
203
+					}
204
+
205
+					InspectionList, err := service.FindeInspectionByOrgId(org.Id)
206
+					if len(InspectionList) == 0 {
207
+						err = service.BatchInspectionConfiguration(org.Id)
208
+					} else {
209
+						utils.ErrorLog("字段批量插入失败:%v", err)
210
+					}
211
+				} else {
212
+					utils.ErrorLog("字段批量插入失败:%v", requestErr)
213
+				}
214
+
215
+			}
216
+
217
+			this.ServeSuccessJSON(map[string]interface{}{
218
+				"admin": adminUser,
219
+				"user":  appRole,
220
+				"org":   org,
221
+				"template_info": map[string]interface{}{
222
+					"id":          templateInfo.ID,
223
+					"org_id":      templateInfo.OrgId,
224
+					"template_id": templateInfo.TemplateId,
225
+				},
226
+				"config_list":      configList,
227
+				"dict_config_list": dict_configList,
228
+
229
+				"filed_list": FiledList,
230
+			})
231
+		}
232
+
233
+		//this.ServeSuccessJSON(map[string]interface{}{
234
+		//	"msg":"修改成功",
235
+		//})
236
+		return
237
+	}
238
+}
239
+
240
+func (this *ForgetPwdController) checkParams(mobile string, code string, password string) *enums.SGJError {
241
+	if utils.CellPhoneRegexp().MatchString(mobile) == false {
242
+		return &enums.SGJError{Code: enums.ErrorCodeMobileFormat}
243
+	}
244
+	if len(code) == 0 {
245
+		return &enums.SGJError{Code: enums.ErrorCodeVerificationCodeWrong}
246
+	}
247
+	if len(password) == 0 {
248
+		return &enums.SGJError{Code: enums.ErrorCodePasswordEmpty}
249
+	}
250
+	if service.IsMobileRegister(mobile) == false {
251
+		return &enums.SGJError{Code: enums.ErrorCodeMobileNotExit}
252
+	}
253
+	redisClient := service.RedisClient()
254
+	defer redisClient.Close()
255
+	cache_code, _ := redisClient.Get("code_msg_" + mobile).Result()
256
+	if cache_code != code {
257
+		return &enums.SGJError{Code: enums.ErrorCodeVerificationCodeWrong}
258
+	}
259
+	return nil
260
+}

+ 197 - 0
controllers/new_mobile_api_controllers/good_types.json View File

@@ -0,0 +1,197 @@
1
+{
2
+  "types": [
3
+    {
4
+      "id": 10000,
5
+      "type_code": "14000000",
6
+      "type_name": "穿刺针",
7
+      "remark": "",
8
+      "ctime": 0,
9
+      "mtime": 1568080321,
10
+      "creater": 0,
11
+      "modifier": 0,
12
+      "org_id": 0,
13
+      "status": 1,
14
+      "type": 1,
15
+      "number": 1,
16
+      "out_stock": 1
17
+    },
18
+    {
19
+      "id": 10001,
20
+      "type_code": "14000001",
21
+      "type_name": "透析器",
22
+      "remark": "",
23
+      "ctime": 0,
24
+      "mtime": 1568080335,
25
+      "creater": 0,
26
+      "modifier": 0,
27
+      "org_id": 0,
28
+      "status": 1,
29
+      "type": 1,
30
+      "number": 2,
31
+      "out_stock": 1,
32
+      "stock_attribute": 2,
33
+    },
34
+    {
35
+      "id": 10002,
36
+      "type_code": "14000002",
37
+      "type_name": "灌流器",
38
+      "remark": "",
39
+      "ctime": 0,
40
+      "mtime": 1568080349,
41
+      "creater": 0,
42
+      "modifier": 0,
43
+      "org_id": 0,
44
+      "status": 1,
45
+      "type": 1,
46
+      "number": 3,
47
+      "out_stock": 1,
48
+      "stock_attribute": 3,
49
+    },
50
+    {
51
+      "id": 10003,
52
+      "type_code": "14000003",
53
+      "type_name": "血路管",
54
+      "remark": "",
55
+      "ctime": 0,
56
+      "mtime": 1568080361,
57
+      "creater": 0,
58
+      "modifier": 0,
59
+      "org_id": 0,
60
+      "status": 1,
61
+      "type": 1,
62
+      "number": 4,
63
+      "out_stock": 1
64
+    },
65
+    {
66
+      "id": 10004,
67
+      "type_code": "14000004",
68
+      "type_name": "血滤补液管",
69
+      "remark": "",
70
+      "ctime": 0,
71
+      "mtime": 1568081853,
72
+      "creater": 0,
73
+      "modifier": 0,
74
+      "org_id": 0,
75
+      "status": 1,
76
+      "type": 1,
77
+      "number": 5,
78
+      "out_stock": 1
79
+    },
80
+    {
81
+      "id": 10005,
82
+      "type_code": "14000005",
83
+      "type_name": "注射器",
84
+      "remark": "",
85
+      "ctime": 0,
86
+      "mtime": 1568081870,
87
+      "creater": 0,
88
+      "modifier": 0,
89
+      "org_id": 13,
90
+      "status": 1,
91
+      "type": 1,
92
+      "number": 6,
93
+      "out_stock": 1
94
+    },
95
+    {
96
+      "id": 79,
97
+      "type_code": "14000006",
98
+      "type_name": "护理包(内瘘穿刺包)",
99
+      "remark": "",
100
+      "ctime": 0,
101
+      "mtime": 1559699564,
102
+      "creater": 0,
103
+      "modifier": 0,
104
+      "org_id": 0,
105
+      "status": 1,
106
+      "type": 1,
107
+      "number": 7,
108
+      "out_stock": 1
109
+    },
110
+    {
111
+      "id": 80,
112
+      "type_code": "14000007",
113
+      "type_name": "细菌过滤器",
114
+      "remark": "",
115
+      "ctime": 0,
116
+      "mtime": 1559699718,
117
+      "creater": 0,
118
+      "modifier": 0,
119
+      "org_id": 0,
120
+      "status": 1,
121
+      "type": 1,
122
+      "number": 8,
123
+      "out_stock": 1
124
+    },
125
+    {
126
+      "id": 81,
127
+      "type_code": "14000008",
128
+      "type_name": "血液透析干粉",
129
+      "remark": "",
130
+      "ctime": 0,
131
+      "mtime": 1559699621,
132
+      "creater": 0,
133
+      "modifier": 0,
134
+      "org_id": 0,
135
+      "status": 1,
136
+      "type": 1,
137
+      "number": 9,
138
+      "out_stock": 1
139
+    }, {
140
+      "id": 81,
141
+      "type_code": "14000009",
142
+      "type_name": "A液",
143
+      "remark": "",
144
+      "ctime": 0,
145
+      "mtime": 1559699621,
146
+      "creater": 0,
147
+      "modifier": 0,
148
+      "org_id": 0,
149
+      "status": 1,
150
+      "type": 1,
151
+      "number": 10,
152
+      "out_stock": 1
153
+    },{
154
+      "id": 81,
155
+      "type_code": "14000010",
156
+      "type_name": "B液",
157
+      "remark": "",
158
+      "ctime": 0,
159
+      "mtime": 1559699621,
160
+      "creater": 0,
161
+      "modifier": 0,
162
+      "org_id": 0,
163
+      "status": 1,
164
+      "type": 1,
165
+      "number": 11,
166
+      "out_stock": 1
167
+    },{
168
+      "id": 81,
169
+      "type_code": "14000011",
170
+      "type_name": "导管包",
171
+      "remark": "",
172
+      "ctime": 0,
173
+      "mtime": 1559699621,
174
+      "creater": 0,
175
+      "modifier": 0,
176
+      "org_id": 0,
177
+      "status": 1,
178
+      "type": 1,
179
+      "number": 12,
180
+      "out_stock": 1
181
+    },{
182
+      "id": 81,
183
+      "type_code": "14000012",
184
+      "type_name": "血液透析导管",
185
+      "remark": "",
186
+      "ctime": 0,
187
+      "mtime": 1559699621,
188
+      "creater": 0,
189
+      "modifier": 0,
190
+      "org_id": 0,
191
+      "status": 1,
192
+      "type": 1,
193
+      "number": 13,
194
+      "out_stock": 1
195
+    }
196
+  ]
197
+}

+ 806 - 0
controllers/new_mobile_api_controllers/home_api_controller.go View File

@@ -0,0 +1,806 @@
1
+package new_mobile_api_controllers
2
+
3
+import (
4
+	"Xcx_New/controllers/mobile_api_controllers"
5
+	"Xcx_New/enums"
6
+	"Xcx_New/models"
7
+	"Xcx_New/service"
8
+	"Xcx_New/utils"
9
+	"encoding/json"
10
+	"fmt"
11
+	"github.com/astaxie/beego"
12
+	"io/ioutil"
13
+	"net/http"
14
+	"net/url"
15
+	"strconv"
16
+	"strings"
17
+	"time"
18
+)
19
+
20
+//func InitGoodTypesConfig(org *models.Org){
21
+//
22
+//
23
+//}
24
+
25
+type HomeController struct {
26
+	NewMobileBaseAPIAuthController
27
+}
28
+
29
+func (this *HomeController) GetHomeData() {
30
+
31
+	adminUserInfo := this.GetMobileAdminUserInfo()
32
+	if adminUserInfo.Org != nil && adminUserInfo.Org.Id != 0 {
33
+		//获取该管理员所有机构列表
34
+		var orgs []*models.Org
35
+		adminUser, err := service.GetHomeData(adminUserInfo.AdminUser.Id)
36
+		if err != nil {
37
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
38
+			return
39
+		}
40
+		for _, item := range adminUser.Org {
41
+			orgs = append(orgs, item)
42
+		}
43
+		for _, item := range adminUser.VMApp_Role {
44
+			for _, subItem := range item.Org {
45
+				orgs = append(orgs, subItem)
46
+			}
47
+		}
48
+		orgs = RemoveRepeatedOrgElement(orgs)
49
+
50
+		var isSubSuperAdmin bool = false
51
+		if adminUserInfo.AppRole != nil && adminUserInfo.AppRole.Id > 0 {
52
+			app_role, _ := service.GetAppRoleById(adminUserInfo.AppRole.Id)
53
+			if len(app_role.RoleIds) > 0 {
54
+				role_ids := strings.Split(app_role.RoleIds, ",")
55
+				if adminUserInfo.AdminUser.Id != adminUserInfo.Org.Creator {
56
+					for _, item := range role_ids {
57
+						id, _ := strconv.ParseInt(item, 10, 64)
58
+						if id > 0 {
59
+							role, _ := service.GetRoleByRoleID(id)
60
+							if role != nil {
61
+								if role.IsSystem == 1 && role.RoleName == "子管理员" {
62
+									isSubSuperAdmin = true
63
+								}
64
+							}
65
+						}
66
+					}
67
+				}
68
+			}
69
+		}
70
+
71
+		apps, err := service.GetAllApp(adminUserInfo.Org.Id)
72
+		if err != nil {
73
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
74
+			return
75
+		}
76
+
77
+		banners, err := service.GetSystemBanner()
78
+		if err != nil {
79
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
80
+			return
81
+		}
82
+
83
+		cretor := adminUserInfo.AdminUser.Id
84
+		this.ServeSuccessJSON(map[string]interface{}{
85
+			"orgs":            orgs,
86
+			"apps":            apps,
87
+			"banners":         banners,
88
+			"isCreateOrg":     true,
89
+			"isSubSuperAdmin": isSubSuperAdmin,
90
+			"cretor":          cretor,
91
+		})
92
+	} else {
93
+
94
+		apps, err := service.GetAllApp(0)
95
+		if err != nil {
96
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
97
+			return
98
+		}
99
+		banners, err := service.GetSystemBanner()
100
+		if err != nil {
101
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
102
+			return
103
+		}
104
+
105
+		this.ServeSuccessJSON(map[string]interface{}{
106
+			"isCreateOrg":     false,
107
+			"apps":            apps,
108
+			"banners":         banners,
109
+			"isSubSuperAdmin": false,
110
+		})
111
+	}
112
+
113
+}
114
+
115
+func RemoveRepeatedOrgElement(orgs []*models.Org) (newOrgs []*models.Org) {
116
+	newOrgs = make([]*models.Org, 0)
117
+	for i := 0; i < len(orgs); i++ {
118
+		repeat := false
119
+		for j := i + 1; j < len(orgs); j++ {
120
+			if orgs[i].Id == orgs[j].Id {
121
+				repeat = true
122
+				break
123
+			}
124
+		}
125
+		if !repeat {
126
+			newOrgs = append(newOrgs, orgs[i])
127
+		}
128
+	}
129
+	return
130
+}
131
+
132
+func (this *HomeController) ChangeOrg() {
133
+	org_id, _ := this.GetInt64("org_id")
134
+	adminUserInfo := this.GetMobileAdminUserInfo()
135
+
136
+	tempOrg, err := service.GetOrgById(org_id)
137
+	if err != nil {
138
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
139
+		return
140
+	}
141
+
142
+	if tempOrg == nil {
143
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoExist)
144
+		return
145
+	}
146
+
147
+	mobile := adminUserInfo.AdminUser.Mobile
148
+	// 只取最近被创建的 admin_role
149
+	adminUser, getAdminErr := service.GetValidAdminUserByMobileReturnErr(mobile) //账号信息唯一值
150
+	if getAdminErr != nil {
151
+		utils.ErrorLog("获取管理员失败:%v", getAdminErr)
152
+		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
153
+		this.ServeJSON()
154
+		return
155
+	} else if adminUser == nil {
156
+		utils.ErrorLog("查找不到 mobile = %v 的用户", mobile)
157
+		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeAccountOrPasswordWrong)
158
+		this.ServeJSON()
159
+		return
160
+	} else {
161
+
162
+		var appRole *models.App_Role
163
+		var org *models.Org
164
+		var subscibe *models.ServeSubscibe
165
+		var app *models.OrgApp
166
+
167
+		//根据登录信息的机构和用户id,去获取对应用户信息和机构信息
168
+		tempApp, _ := service.GetOrgApp(tempOrg.Id, 3)
169
+		tempRole, _ := service.GetAppRole(tempOrg.Id, tempApp.Id, adminUser.Id)
170
+
171
+		tempSubscibe, getSubscibeErr := service.GetOrgServeSubscibe(tempOrg.Id)
172
+		if getSubscibeErr != nil {
173
+			utils.ErrorLog("获取机构订阅信息失败:%v", getSubscibeErr)
174
+			this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
175
+			this.ServeJSON()
176
+			return
177
+		}
178
+
179
+		subscibe = tempSubscibe
180
+		org = tempOrg
181
+		appRole = tempRole
182
+		app = tempApp
183
+
184
+		templateInfo, _ := service.GetOrgInfoTemplate(org.Id)
185
+
186
+		mobileAdminUserInfo := &mobile_api_controllers.MobileAdminUserInfo{
187
+			AdminUser:    adminUser,
188
+			Org:          org,
189
+			App:          app,
190
+			AppRole:      appRole,
191
+			Subscibe:     subscibe,
192
+			TemplateInfo: &templateInfo,
193
+		}
194
+
195
+		if org != nil && appRole != nil {
196
+			// 插入一条登录记录
197
+			ip := this.GetString("ip")
198
+			loginLog := &models.AdminUserLoginLog{
199
+				AdminUserId: adminUser.Id,
200
+				OrgId:       org.Id,
201
+				AppId:       appRole.AppId,
202
+				IP:          ip,
203
+				OperateType: 3,
204
+				AppType:     3,
205
+				CreateTime:  time.Now().Unix(),
206
+			}
207
+			if insertErr := service.InsertLoginLog(loginLog); insertErr != nil {
208
+				utils.ErrorLog("为手机号为%v的用户插入一条登录记录失败:%v", mobile, insertErr)
209
+			}
210
+		}
211
+
212
+		//删除session和cookie
213
+		this.DelSession("mobile_admin_user_info")
214
+		this.Ctx.SetCookie("token_cookie", "")
215
+
216
+		//设置new seesion
217
+		this.SetSession("mobile_admin_user_info", mobileAdminUserInfo)
218
+		//设置new cookie
219
+		mobile := adminUser.Mobile + "-" + strconv.FormatInt(org.Id, 10) + "-" + strconv.FormatInt(appRole.Id, 10)
220
+		token := utils.GenerateLoginToken(mobile)
221
+		expiration, _ := beego.AppConfig.Int64("mobile_token_expiration_second")
222
+		this.Ctx.SetCookie("token_cookie", token, expiration, "/")
223
+
224
+		var configList interface{}
225
+		var dict_config_list interface{}
226
+		var FiledList []*models.FiledConfig
227
+
228
+		if org.Id > 0 {
229
+			dict_config_list, _ = service.GetDictConfigList(org.Id)
230
+			configList, _ = service.GetConfigList(org.Id)
231
+			FiledList, _ = service.FindFiledByOrgId(org.Id)
232
+		}
233
+		if len(FiledList) == 0 {
234
+			var err error
235
+			if org.Id > 0 {
236
+				err = service.BatchInsertFiledConfig(org.Id)
237
+				if err == nil {
238
+					FiledList, _ = service.FindFiledByOrgId(org.Id)
239
+				} else {
240
+					utils.ErrorLog("字段批量插入失败:%v", err)
241
+				}
242
+			} else {
243
+				FiledList = make([]*models.FiledConfig, 0)
244
+			}
245
+
246
+			if org.Id > 0 {
247
+				//产寻该机构是否有收缩压和舒张压
248
+				pressure, err := service.GetDefaultSystolicPressure(org.Id)
249
+				fmt.Println(err)
250
+				if len(pressure) == 0 {
251
+					err = service.BathInsertQualityControlTwo(org.Id)
252
+				} else {
253
+					utils.ErrorLog("字段批量插入失败:%v", err)
254
+				}
255
+				major, err := service.GetInspectionMajor(org.Id)
256
+				if len(major) == 0 {
257
+					QualityeList, err := service.FindQualityByOrgId(org.Id)
258
+					if len(QualityeList) == 0 {
259
+						err = service.BatchInsertQualityControl(org.Id)
260
+					} else {
261
+						utils.ErrorLog("字段批量插入失败:%v", err)
262
+					}
263
+
264
+					InspectionList, err := service.FindeInspectionByOrgId(org.Id)
265
+					if len(InspectionList) == 0 {
266
+						err = service.BatchInspectionConfiguration(org.Id)
267
+					} else {
268
+						utils.ErrorLog("字段批量插入失败:%v", err)
269
+					}
270
+				} else {
271
+					utils.ErrorLog("字段批量插入失败:%v", err)
272
+				}
273
+
274
+			}
275
+
276
+		}
277
+		this.ServeSuccessJSON(map[string]interface{}{
278
+			"admin": adminUser,
279
+			"user":  appRole,
280
+			"org":   org,
281
+			"template_info": map[string]interface{}{
282
+				"id":          templateInfo.ID,
283
+				"org_id":      templateInfo.OrgId,
284
+				"template_id": templateInfo.TemplateId,
285
+			},
286
+			"config_list":      configList,
287
+			"dict_config_list": dict_config_list,
288
+			"filed_list":       FiledList,
289
+		})
290
+	}
291
+
292
+}
293
+
294
+func (this *HomeController) CreateOrg() {
295
+
296
+	adminUserInfo := this.GetMobileAdminUserInfo()
297
+	adminUser := adminUserInfo.AdminUser
298
+
299
+	//if didCreateOrg, checkCreateOrgErr := service.DidAdminUserCreateOrg(adminUser.Id); checkCreateOrgErr != nil {
300
+	//	this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
301
+	//	this.ServeJSON()
302
+	//	return
303
+	//} else if didCreateOrg {
304
+	//	this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeRepeatCreateOrg)
305
+	//	this.ServeJSON()
306
+	//	return
307
+	//}
308
+
309
+	name := this.GetString("org_name")
310
+	shortName := name
311
+	provinceName := this.GetString("provinces_name")
312
+	cityName := this.GetString("city_name")
313
+	districtName := this.GetString("district_name")
314
+	address := this.GetString("address")
315
+	org_type := this.GetString("org_type")
316
+	contactName := this.GetString("contact_name")
317
+
318
+	openXT := true
319
+	openCDM := false
320
+	openSCRM := false
321
+	openMall := false
322
+
323
+	if len(name) == 0 || len(shortName) == 0 || len(contactName) == 0 || len(address) == 0 || len(provinceName) <= 0 || len(cityName) <= 0 || len(districtName) <= 0 || len(org_type) <= 0 {
324
+		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
325
+		this.ServeJSON()
326
+		return
327
+	}
328
+	orgPhone := this.GetString("telephone")
329
+
330
+	provinceID := 0
331
+	cityID := 0
332
+	districtID := 0
333
+
334
+	province, getProvinceErr := service.GetProvinceWithName(provinceName)
335
+	if getProvinceErr != nil {
336
+		utils.ErrorLog("查询省名失败:%v", getProvinceErr)
337
+		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
338
+		this.ServeJSON()
339
+		return
340
+	} else if province != nil {
341
+		provinceID = int(province.ID)
342
+		city, getCityErr := service.GetCityWithName(province.ID, cityName)
343
+		if getCityErr != nil {
344
+			utils.ErrorLog("查询城市名失败:%v", getCityErr)
345
+			this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
346
+			this.ServeJSON()
347
+			return
348
+		} else if city != nil {
349
+			cityID = int(city.ID)
350
+			district, getDistrictErr := service.GetDistrictWithName(city.ID, districtName)
351
+			if getDistrictErr != nil {
352
+				utils.ErrorLog("查询区县名失败:%v", getDistrictErr)
353
+				this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
354
+				this.ServeJSON()
355
+				return
356
+			} else if district != nil {
357
+				districtID = int(district.ID)
358
+			}
359
+		}
360
+	}
361
+
362
+	var orgs []*models.Org
363
+	vmAdminUser, err := service.GetHomeData(adminUser.Id)
364
+	if err != nil {
365
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
366
+		return
367
+	}
368
+	for _, item := range vmAdminUser.Org {
369
+		orgs = append(orgs, item)
370
+	}
371
+	for _, item := range vmAdminUser.VMApp_Role {
372
+		for _, subItem := range item.Org {
373
+			orgs = append(orgs, subItem)
374
+		}
375
+	}
376
+	orgs = RemoveRepeatedOrgElement(orgs)
377
+
378
+	orgType := service.GetOrgTypeByName(org_type)
379
+
380
+	org := &models.Org{
381
+		Creator:      adminUser.Id,
382
+		OrgName:      name,
383
+		OrgShortName: shortName,
384
+		Province:     int64(provinceID),
385
+		City:         int64(cityID),
386
+		District:     int64(districtID),
387
+		Address:      address,
388
+		OrgType:      orgType.ID,
389
+		Telephone:    orgPhone,
390
+		ContactName:  contactName,
391
+		Claim:        1,
392
+		Evaluate:     5,
393
+		Status:       1,
394
+		CreateTime:   time.Now().Unix(),
395
+		ModifyTime:   time.Now().Unix(),
396
+	}
397
+
398
+	createErr := service.CreateOrg(org, adminUser.Name, openXT, openCDM, openSCRM, openMall) // 创建机构以及所有类型的 app,如果有新类型的平台,则需要在这个方法里面把创建这一新类型的 app 的代码加上
399
+
400
+	if createErr != nil {
401
+		utils.ErrorLog("mobile=%v的超级管理员创建机构失败:%v", adminUser.Mobile, createErr)
402
+		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
403
+		this.ServeJSON()
404
+	} else {
405
+
406
+		//初始化病人和排班相关数据
407
+		InitPatientAndSchedule(org)
408
+		//初始化透析方案
409
+		InitSystemPrescrption(org)
410
+		//初始化医嘱模版
411
+		//InitAdviceTemplate(org)
412
+		//初始化角色和权限
413
+		InitRoleAndPurviews(org)
414
+		//初始化设备管理
415
+		InitEquitMentInformation(org)
416
+		//初始化显示配置和打印模版
417
+		InitShowConfig(org)
418
+		//初始化商品类型
419
+		InitGoodTypesConfig(org)
420
+
421
+		if len(orgs) == 0 {
422
+			ip := utils.GetIP(this.Ctx.Request)
423
+			ssoDomain := beego.AppConfig.String("sso_domain")
424
+			api := ssoDomain + "/m/login/pwd"
425
+			values := make(url.Values)
426
+			values.Set("mobile", adminUser.Mobile)
427
+			values.Set("password", adminUser.Password)
428
+			values.Set("app_type", "3")
429
+			values.Set("ip", ip)
430
+			resp, requestErr := http.PostForm(api, values)
431
+
432
+			if requestErr != nil {
433
+				utils.ErrorLog("请求SSO登录接口失败: %v", requestErr)
434
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
435
+				return
436
+			}
437
+			defer resp.Body.Close()
438
+			body, ioErr := ioutil.ReadAll(resp.Body)
439
+			if ioErr != nil {
440
+				utils.ErrorLog("SSO登录接口返回数据读取失败: %v", ioErr)
441
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
442
+				return
443
+			}
444
+			var respJSON map[string]interface{}
445
+			utils.InfoLog(string(body))
446
+			if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
447
+				utils.ErrorLog("SSO登录接口返回数据解析JSON失败: %v", err)
448
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
449
+				return
450
+			}
451
+
452
+			if respJSON["state"].(float64) != 1 {
453
+				msg := respJSON["msg"].(string)
454
+				utils.ErrorLog("SSO登录接口请求失败: %v", msg)
455
+				if int(respJSON["code"].(float64)) == 609 {
456
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAccountOrPasswordWrong)
457
+					return
458
+				}
459
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
460
+				return
461
+			} else {
462
+				utils.SuccessLog("SSO登录成功")
463
+				// 下面这几段 Map=>JSON=>Struct 的流程可能会造成速度很慢
464
+				userJSON := respJSON["data"].(map[string]interface{})["admin"].(map[string]interface{})
465
+				userJSONBytes, _ := json.Marshal(userJSON)
466
+				var adminUser models.AdminUser
467
+				if err := json.Unmarshal(userJSONBytes, &adminUser); err != nil {
468
+					utils.ErrorLog("解析管理员失败:%v", err)
469
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
470
+					return
471
+				}
472
+
473
+				var org models.Org
474
+				if respJSON["data"].(map[string]interface{})["org"] != nil {
475
+					orgJSON := respJSON["data"].(map[string]interface{})["org"].(map[string]interface{})
476
+					orgJSONBytes, _ := json.Marshal(orgJSON)
477
+					if err := json.Unmarshal(orgJSONBytes, &org); err != nil {
478
+						utils.ErrorLog("解析机构失败:%v", err)
479
+						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
480
+						return
481
+					}
482
+				}
483
+
484
+				var app models.OrgApp
485
+
486
+				if respJSON["data"].(map[string]interface{})["app"] != nil {
487
+					appJSON := respJSON["data"].(map[string]interface{})["app"].(map[string]interface{})
488
+					appJSONBytes, _ := json.Marshal(appJSON)
489
+					if err := json.Unmarshal(appJSONBytes, &app); err != nil {
490
+						utils.ErrorLog("解析应用失败:%v", err)
491
+						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
492
+						return
493
+					}
494
+				}
495
+
496
+				var appRole models.App_Role
497
+
498
+				if respJSON["data"].(map[string]interface{})["app_role"] != nil {
499
+					appRoleJSON := respJSON["data"].(map[string]interface{})["app_role"].(map[string]interface{})
500
+					appRoleJSONBytes, _ := json.Marshal(appRoleJSON)
501
+					if err := json.Unmarshal(appRoleJSONBytes, &appRole); err != nil {
502
+						utils.ErrorLog("解析AppRole失败:%v", err)
503
+						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
504
+						return
505
+					}
506
+				}
507
+
508
+				var subscibe models.ServeSubscibe
509
+				if respJSON["data"].(map[string]interface{})["subscibe"] != nil {
510
+					subscibeJSON := respJSON["data"].(map[string]interface{})["subscibe"].(map[string]interface{})
511
+					subscibeJSONBytes, _ := json.Marshal(subscibeJSON)
512
+					if err := json.Unmarshal(subscibeJSONBytes, &subscibe); err != nil {
513
+						utils.ErrorLog("解析Subscibe失败:%v", err)
514
+						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
515
+						return
516
+					}
517
+
518
+				}
519
+
520
+				//service.GetOrgSubscibeState(&subscibe)
521
+				templateInfo, _ := service.GetOrgInfoTemplate(org.Id)
522
+
523
+				mobileAdminUserInfo := &mobile_api_controllers.MobileAdminUserInfo{
524
+					AdminUser:    &adminUser,
525
+					Org:          &org,
526
+					App:          &app,
527
+					AppRole:      &appRole,
528
+					Subscibe:     &subscibe,
529
+					TemplateInfo: &templateInfo,
530
+				}
531
+				this.Ctx.SetCookie("token_cookie", "")
532
+
533
+				//设置seesion
534
+				this.SetSession("mobile_admin_user_info", mobileAdminUserInfo)
535
+
536
+				//设置cookie
537
+				mobile := adminUser.Mobile + "-" + strconv.FormatInt(org.Id, 10) + "-" + strconv.FormatInt(appRole.Id, 10)
538
+				token := utils.GenerateLoginToken(mobile)
539
+				expiration, _ := beego.AppConfig.Int64("mobile_token_expiration_second")
540
+				this.Ctx.SetCookie("token_cookie", token, expiration, "/")
541
+
542
+				var configList interface{}
543
+				var dict_config_list interface{}
544
+
545
+				var FiledList []*models.FiledConfig
546
+
547
+				if org.Id > 0 {
548
+					dict_config_list, _ = service.GetDictConfigList(org.Id)
549
+
550
+					configList, _ = service.GetConfigList(org.Id)
551
+					FiledList, _ = service.FindFiledByOrgId(org.Id)
552
+				}
553
+				if len(FiledList) == 0 {
554
+					var err error
555
+					if org.Id > 0 {
556
+						err = service.BatchInsertFiledConfig(org.Id)
557
+						if err == nil {
558
+							FiledList, _ = service.FindFiledByOrgId(org.Id)
559
+						} else {
560
+							utils.ErrorLog("字段批量插入失败:%v", err)
561
+						}
562
+					} else {
563
+						FiledList = make([]*models.FiledConfig, 0)
564
+					}
565
+				}
566
+
567
+				if org.Id > 0 {
568
+					major, requestErr := service.GetInspectionMajor(org.Id)
569
+					if len(major) == 0 {
570
+						QualityeList, err := service.FindQualityByOrgId(org.Id)
571
+						if len(QualityeList) == 0 {
572
+							err = service.BatchInsertQualityControl(org.Id)
573
+						} else {
574
+							utils.ErrorLog("字段批量插入失败:%v", err)
575
+						}
576
+
577
+						InspectionList, err := service.FindeInspectionByOrgId(org.Id)
578
+						if len(InspectionList) == 0 {
579
+							err = service.BatchInspectionConfiguration(org.Id)
580
+						} else {
581
+							utils.ErrorLog("字段批量插入失败:%v", err)
582
+						}
583
+					} else {
584
+						utils.ErrorLog("字段批量插入失败:%v", requestErr)
585
+					}
586
+
587
+				}
588
+
589
+				this.ServeSuccessJSON(map[string]interface{}{
590
+					"admin": adminUser,
591
+					"user":  appRole,
592
+					"org":   org,
593
+					"template_info": map[string]interface{}{
594
+						"id":          templateInfo.ID,
595
+						"org_id":      templateInfo.OrgId,
596
+						"template_id": templateInfo.TemplateId,
597
+					},
598
+					"config_list":      configList,
599
+					"dict_config_list": dict_config_list,
600
+
601
+					"filed_list": FiledList,
602
+					"status":     1,
603
+				})
604
+			}
605
+
606
+		} else {
607
+			this.ServeSuccessJSON(map[string]interface{}{
608
+				"org":    org,
609
+				"status": 2,
610
+			})
611
+
612
+		}
613
+
614
+	}
615
+
616
+}
617
+
618
+func (this *HomeController) ModifyPsw() {
619
+	mobile := this.GetString("mobile")
620
+	code := this.GetString("code")
621
+	password := this.GetString("password")
622
+	checkErr := this.checkParam(mobile, code, password)
623
+	if checkErr != nil {
624
+		this.ServeFailJSONWithSGJErrorCode(checkErr.Code)
625
+		return
626
+	}
627
+	adminUser, _ := service.GetValidAdminUserByMobileReturnErr(mobile)
628
+	modifyErr := service.ModifyPassword(adminUser.Id, password)
629
+	if modifyErr != nil {
630
+		utils.ErrorLog("修改mobile=%v的用户的密码时失败: %v", mobile, modifyErr)
631
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
632
+		return
633
+	} else {
634
+		// 修改成功后验证码就要使其失效
635
+		redisClient := service.RedisClient()
636
+		defer redisClient.Close()
637
+		redisClient.Del("code_msg_" + mobile)
638
+		this.ServeSuccessJSON(map[string]interface{}{
639
+			"admin": adminUser,
640
+		})
641
+		return
642
+	}
643
+}
644
+
645
+func (this *HomeController) checkParam(mobile string, code string, password string) *enums.SGJError {
646
+	if utils.CellPhoneRegexp().MatchString(mobile) == false {
647
+		return &enums.SGJError{Code: enums.ErrorCodeMobileFormat}
648
+	}
649
+	if len(code) == 0 {
650
+		return &enums.SGJError{Code: enums.ErrorCodeVerificationCodeWrong}
651
+	}
652
+	if len(password) == 0 {
653
+		return &enums.SGJError{Code: enums.ErrorCodePasswordEmpty}
654
+	}
655
+	if service.IsMobileRegister(mobile) == false {
656
+		return &enums.SGJError{Code: enums.ErrorCodeMobileNotExit}
657
+	}
658
+	redisClient := service.RedisClient()
659
+	defer redisClient.Close()
660
+	cache_code, _ := redisClient.Get("code_msg_" + mobile).Result()
661
+	if cache_code != code {
662
+		return &enums.SGJError{Code: enums.ErrorCodeVerificationCodeWrong}
663
+	}
664
+	return nil
665
+}
666
+
667
+func (this *HomeController) GetFuncPermission() {
668
+	adminUserInfo := this.GetMobileAdminUserInfo()
669
+	user_id := adminUserInfo.AdminUser.Id
670
+	app_id := adminUserInfo.App.Id
671
+	org_id := adminUserInfo.Org.Id
672
+	create_url := this.GetString("create_url")
673
+	modify_url := this.GetString("modify_url")
674
+	modify_other_url := this.GetString("modify_other_url")
675
+	del_url := this.GetString("del_url")
676
+	del_other_url := this.GetString("del_other_url")
677
+	exce_url := this.GetString("exce_url")
678
+	check_url := this.GetString("check_url")
679
+	modify_exce_url := this.GetString("modify_exce_url")
680
+	module, _ := this.GetInt64("module", 0)
681
+
682
+	app_role, _ := service.GetAppRole(org_id, app_id, user_id)
683
+	var is_has_create bool
684
+	var is_has_modify bool
685
+	var is_has_modify_other bool
686
+	var is_has_del bool
687
+	var is_has_del_other bool
688
+	var is_has_exce bool
689
+	var is_has_check bool
690
+	var is_has_modify_exce bool
691
+
692
+	if adminUserInfo.AdminUser.Id != adminUserInfo.Org.Creator {
693
+
694
+		if app_role != nil {
695
+			if len(app_role.RoleIds) > 0 {
696
+				roles := strings.Split(app_role.RoleIds, ",")
697
+				var userRolePurviews string
698
+				for _, item := range roles {
699
+					role_id, _ := strconv.ParseInt(item, 10, 64)
700
+					purviews, _ := service.GetRoleFuncPurviewIds(role_id)
701
+					if len(userRolePurviews) == 0 {
702
+						userRolePurviews = purviews
703
+					} else {
704
+						userRolePurviews = userRolePurviews + "," + purviews
705
+					}
706
+				}
707
+				userRolePurviewsArr := RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
708
+				funcPurviews, _ := service.FindAllFuncPurview(userRolePurviewsArr)
709
+				for _, item := range funcPurviews {
710
+					//for _, url := range strings.Split(item.Urlfor,","){
711
+					if strings.Split(item.Urlfor, ",")[0] == create_url {
712
+						is_has_create = true
713
+					}
714
+					if strings.Split(item.Urlfor, ",")[0] == modify_url {
715
+						is_has_modify = true
716
+					}
717
+					if strings.Split(item.Urlfor, ",")[0] == modify_other_url {
718
+						is_has_modify_other = true
719
+					}
720
+					if strings.Split(item.Urlfor, ",")[0] == del_url {
721
+						is_has_del = true
722
+					}
723
+					if strings.Split(item.Urlfor, ",")[0] == del_other_url {
724
+						is_has_del_other = true
725
+					}
726
+					if strings.Split(item.Urlfor, ",")[0] == exce_url {
727
+						is_has_exce = true
728
+					}
729
+					if strings.Split(item.Urlfor, ",")[0] == check_url {
730
+						is_has_check = true
731
+					}
732
+					if strings.Split(item.Urlfor, ",")[0] == modify_exce_url {
733
+						is_has_modify_exce = true
734
+					}
735
+
736
+				}
737
+			} else {
738
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRole)
739
+				return
740
+			}
741
+			this.ServeSuccessJSON(map[string]interface{}{
742
+				"is_has_create":       is_has_create,
743
+				"is_has_modify":       is_has_modify,
744
+				"is_has_modify_other": is_has_modify_other,
745
+				"is_has_del":          is_has_del,
746
+				"is_has_del_other":    is_has_del_other,
747
+				"is_has_exce":         is_has_exce,
748
+				"is_has_check":        is_has_check,
749
+				"is_has_modify_exce":  is_has_modify_exce,
750
+				"module":              module,
751
+			})
752
+		} else {
753
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserIsExit)
754
+			return
755
+
756
+		}
757
+
758
+	} else {
759
+		this.ServeSuccessJSON(map[string]interface{}{
760
+			"is_has_create":       true,
761
+			"is_has_modify":       true,
762
+			"is_has_modify_other": true,
763
+			"is_has_del":          true,
764
+			"is_has_del_other":    true,
765
+			"is_has_exce":         true,
766
+			"is_has_check":        true,
767
+			"is_has_modify_exce":  true,
768
+			"module":              true,
769
+		})
770
+
771
+	}
772
+
773
+}
774
+func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
775
+	newArr = make([]string, 0)
776
+	for i := 0; i < len(arr); i++ {
777
+		repeat := false
778
+		for j := i + 1; j < len(arr); j++ {
779
+			if arr[i] == arr[j] {
780
+				repeat = true
781
+				break
782
+			}
783
+		}
784
+		if !repeat {
785
+			newArr = append(newArr, arr[i])
786
+		}
787
+	}
788
+	return
789
+}
790
+
791
+func RemoveRepeatedOrgElementTwo(orgs []*models.SgjUserOrg) (newOrgs []*models.SgjUserOrg) {
792
+	newOrgs = make([]*models.SgjUserOrg, 0)
793
+	for i := 0; i < len(orgs); i++ {
794
+		repeat := false
795
+		for j := i + 1; j < len(orgs); j++ {
796
+			if orgs[i].ID == orgs[j].ID {
797
+				repeat = true
798
+				break
799
+			}
800
+		}
801
+		if !repeat {
802
+			newOrgs = append(newOrgs, orgs[i])
803
+		}
804
+	}
805
+	return
806
+}

+ 925 - 0
controllers/new_mobile_api_controllers/index_evaluation_api_controller.go View File

@@ -0,0 +1,925 @@
1
+package new_mobile_api_controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/models"
6
+	"Xcx_New/service/statistics_service"
7
+	"Xcx_New/utils"
8
+	"fmt"
9
+	"time"
10
+)
11
+
12
+type IndexEvaluationApiController struct {
13
+	NewMobileBaseAPIAuthController
14
+}
15
+
16
+func (this *IndexEvaluationApiController) GetAdminUser() {
17
+	admins, _ := statistics_service.GetAllAdminUser(this.GetMobileAdminUserInfo().Org.Id)
18
+	this.ServeSuccessJSON(map[string]interface{}{
19
+		"admin": admins,
20
+	})
21
+}
22
+
23
+//化验指标
24
+
25
+//初始化数据
26
+func (this *IndexEvaluationApiController) GetLaboratoryIndexInitData() {
27
+	adminUserInfo := this.GetMobileAdminUserInfo()
28
+	var references []*models.InspectionReference
29
+	count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.Org.Id)
30
+	if count <= 0 {
31
+		references, _ = statistics_service.FindOrgInspectionReference(0, 1)
32
+		references2, _ := statistics_service.FindOrgInspectionReference(0, 2)
33
+		references = append(references, references2...)
34
+
35
+	} else {
36
+		references, _ = statistics_service.FindOrgInspectionReference(adminUserInfo.Org.Id, 1)
37
+		references2, _ := statistics_service.FindOrgInspectionReference(adminUserInfo.Org.Id, 2)
38
+		references = append(references, references2...)
39
+
40
+	}
41
+
42
+	this.ServeSuccessJSON(map[string]interface{}{
43
+		"references": references,
44
+	})
45
+
46
+	//adminUserInfo := this.GetMobileAdminUserInfo()
47
+	//
48
+	//
49
+	//
50
+	//references, _ := statistics_service.FindOrgInspectionReference(adminUserInfo.Org.Id,1)
51
+	//references2, _ := statistics_service.FindOrgInspectionReference(adminUserInfo.Org.Id,2)
52
+	//references = append(references, references2...)
53
+	//this.ServeSuccessJSON(map[string]interface{}{
54
+	//	"references": references,
55
+	//})
56
+
57
+}
58
+
59
+//获取取值范围
60
+func (this *IndexEvaluationApiController) GetLaboratoryIndexProjectRangeValueData() {
61
+	range_type, _ := this.GetInt64("range_type")
62
+	project_id, _ := this.GetInt64("project_id")
63
+	item_id, _ := this.GetInt64("item_id")
64
+	adminUserInfo := this.GetMobileAdminUserInfo()
65
+	var range_vaule []string
66
+	var qcs models.InspectionReference
67
+
68
+	if range_type == 1 {
69
+		count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.Org.Id)
70
+
71
+		if count <= 0 {
72
+			qcs, _ = statistics_service.FindOrgConfigRangeTypeValue(0, project_id, item_id)
73
+		} else {
74
+			qcs, _ = statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.Org.Id, project_id, item_id)
75
+
76
+		}
77
+		//qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.Org.Id, project_id, item_id)
78
+		range_vaule = append(range_vaule, qcs.RangeMin)
79
+		range_vaule = append(range_vaule, qcs.RangeMax)
80
+	} else {
81
+		inspection, _ := statistics_service.FindOrgInspectionReferenceRangeTypeValue(adminUserInfo.Org.Id, project_id, item_id)
82
+		for _, item := range inspection {
83
+			range_vaule = append(range_vaule, item.InspectValue)
84
+		}
85
+	}
86
+	this.ServeSuccessJSON(map[string]interface{}{
87
+		"range_vaule": range_vaule,
88
+	})
89
+
90
+}
91
+func (this *IndexEvaluationApiController) GetInspectionChartData() {
92
+	adminUserInfo := this.GetMobileAdminUserInfo()
93
+	start_time := this.GetString("start_time")
94
+	end_time := this.GetString("end_time")
95
+	project_id, _ := this.GetInt64("project_id")
96
+	item_id, _ := this.GetInt64("item_id")
97
+	range_type, _ := this.GetInt("range_type")
98
+
99
+	timeLayout := "2006-01-02"
100
+	loc, _ := time.LoadLocation("Local")
101
+
102
+	var theStartTIme int64
103
+	if len(start_time) > 0 {
104
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
105
+		if err != nil {
106
+			utils.ErrorLog(err.Error())
107
+		}
108
+		theStartTIme = theTime.Unix()
109
+	}
110
+	var theEndtTIme int64
111
+	if len(end_time) > 0 {
112
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
113
+		if err != nil {
114
+			utils.ErrorLog(err.Error())
115
+		}
116
+		theEndtTIme = theTime.Unix()
117
+	}
118
+
119
+	var range_value string
120
+	//if range_type == 1 {
121
+	//	qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.Org.Id, project_id, item_id)
122
+	//	range_value = qcs.RangeMin + "," + qcs.RangeMax
123
+	//
124
+	//} else {
125
+	//
126
+	//	inspection, _ := statistics_service.FindOrgInspectionReferenceRangeTypeValue(adminUserInfo.Org.Id, project_id, item_id)
127
+	//	for _, item := range inspection {
128
+	//		if len(range_value) == 0 {
129
+	//			range_value = item.InspectValue
130
+	//		} else {
131
+	//			range_value = range_value + "," + item.InspectValue
132
+	//		}
133
+	//	}
134
+	//}
135
+
136
+	if range_type == 1 {
137
+		count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.Org.Id)
138
+
139
+		if count <= 0 {
140
+			qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(0, project_id, item_id)
141
+			range_value = qcs.RangeMin + "," + qcs.RangeMax
142
+
143
+		} else {
144
+			qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.Org.Id, project_id, item_id)
145
+			range_value = qcs.RangeMin + "," + qcs.RangeMax
146
+		}
147
+
148
+	} else {
149
+
150
+		inspection, _ := statistics_service.FindOrgInspectionReferenceRangeTypeValue(adminUserInfo.Org.Id, project_id, item_id)
151
+		for _, item := range inspection {
152
+			if len(range_value) == 0 {
153
+				range_value = item.InspectValue
154
+			} else {
155
+				range_value = range_value + "," + item.InspectValue
156
+			}
157
+		}
158
+
159
+	}
160
+
161
+	data, _ := statistics_service.GetInspectionChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, project_id, item_id, range_type, range_value)
162
+	this.ServeSuccessJSON(map[string]interface{}{
163
+		"data": data,
164
+	})
165
+
166
+}
167
+func (this *IndexEvaluationApiController) GetInspectionChartTableData() {
168
+	adminUserInfo := this.GetMobileAdminUserInfo()
169
+	start_time := this.GetString("start_time")
170
+	end_time := this.GetString("end_time")
171
+	patient_id, _ := this.GetInt64("patient_id")
172
+	page, _ := this.GetInt64("page")
173
+	limit, _ := this.GetInt64("limit")
174
+	project_id, _ := this.GetInt64("project_id")
175
+	item_id, _ := this.GetInt64("item_id")
176
+	range_value := this.GetString("range_value")
177
+	range_type, _ := this.GetInt("range_type")
178
+
179
+	if page == 0 {
180
+		page = 1
181
+	}
182
+	if limit == 0 {
183
+		limit = 20
184
+	}
185
+	timeLayout := "2006-01-02"
186
+	loc, _ := time.LoadLocation("Local")
187
+
188
+	var theStartTIme int64
189
+	if len(start_time) > 0 {
190
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
191
+		if err != nil {
192
+			utils.ErrorLog(err.Error())
193
+		}
194
+		theStartTIme = theTime.Unix()
195
+	}
196
+	var theEndtTIme int64
197
+	if len(end_time) > 0 {
198
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
199
+		if err != nil {
200
+			utils.ErrorLog(err.Error())
201
+		}
202
+		theEndtTIme = theTime.Unix()
203
+	}
204
+	data, total, _ := statistics_service.GetInspectionChartTableData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, project_id, item_id, patient_id, page, limit, range_type, range_value)
205
+	this.ServeSuccessJSON(map[string]interface{}{
206
+		"data":  data,
207
+		"total": total,
208
+	})
209
+
210
+}
211
+func (this *IndexEvaluationApiController) GetPatientInspectionChartData() {
212
+	adminUserInfo := this.GetMobileAdminUserInfo()
213
+	start_time := this.GetString("start_time")
214
+	end_time := this.GetString("end_time")
215
+	project_id, _ := this.GetInt64("project_id")
216
+	item_id, _ := this.GetInt64("item_id")
217
+	patient_id, _ := this.GetInt64("patient_id")
218
+
219
+	timeLayout := "2006-01-02"
220
+	loc, _ := time.LoadLocation("Local")
221
+
222
+	var theStartTIme int64
223
+	if len(start_time) > 0 {
224
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
225
+		if err != nil {
226
+			utils.ErrorLog(err.Error())
227
+		}
228
+		theStartTIme = theTime.Unix()
229
+	}
230
+	var theEndtTIme int64
231
+	if len(end_time) > 0 {
232
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
233
+		if err != nil {
234
+			utils.ErrorLog(err.Error())
235
+		}
236
+		theEndtTIme = theTime.Unix()
237
+	}
238
+
239
+	data, _ := statistics_service.GetPatientInspectionChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, project_id, item_id, patient_id)
240
+	references, _ := statistics_service.FindOrgQualityControlStandardInspectionReferenceById(adminUserInfo.Org.Id, project_id, item_id)
241
+
242
+	this.ServeSuccessJSON(map[string]interface{}{
243
+		"data":       data,
244
+		"references": references,
245
+	})
246
+
247
+}
248
+func (this *IndexEvaluationApiController) GetPatientInspectionBarChartData() {
249
+	adminUserInfo := this.GetMobileAdminUserInfo()
250
+	start_time := this.GetString("start_time")
251
+	end_time := this.GetString("end_time")
252
+	project_id, _ := this.GetInt64("project_id")
253
+	item_id, _ := this.GetInt64("item_id")
254
+	range_type, _ := this.GetInt("range_type")
255
+	patient_id, _ := this.GetInt64("patient_id")
256
+
257
+	timeLayout := "2006-01-02"
258
+	loc, _ := time.LoadLocation("Local")
259
+
260
+	var theStartTIme int64
261
+	if len(start_time) > 0 {
262
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
263
+		if err != nil {
264
+			utils.ErrorLog(err.Error())
265
+		}
266
+		theStartTIme = theTime.Unix()
267
+	}
268
+	var theEndtTIme int64
269
+	if len(end_time) > 0 {
270
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
271
+		if err != nil {
272
+			utils.ErrorLog(err.Error())
273
+		}
274
+		theEndtTIme = theTime.Unix()
275
+	}
276
+
277
+	var range_value string
278
+	if range_type == 1 {
279
+		count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.Org.Id)
280
+
281
+		if count <= 0 {
282
+			qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(0, project_id, item_id)
283
+			range_value = qcs.RangeMin + "," + qcs.RangeMax
284
+
285
+		} else {
286
+			qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.Org.Id, project_id, item_id)
287
+			range_value = qcs.RangeMin + "," + qcs.RangeMax
288
+		}
289
+
290
+	} else {
291
+
292
+		inspection, _ := statistics_service.FindOrgInspectionReferenceRangeTypeValue(adminUserInfo.Org.Id, project_id, item_id)
293
+		for _, item := range inspection {
294
+			if len(range_value) == 0 {
295
+				range_value = item.InspectValue
296
+			} else {
297
+				range_value = range_value + "," + item.InspectValue
298
+			}
299
+		}
300
+
301
+	}
302
+
303
+	data, _ := statistics_service.GetPatientInspectionBarChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, project_id, item_id, range_type, range_value, patient_id)
304
+	this.ServeSuccessJSON(map[string]interface{}{
305
+		"data": data,
306
+	})
307
+
308
+}
309
+
310
+func (this *IndexEvaluationApiController) GetDialysisProcessIndexChartData() {
311
+	adminUserInfo := this.GetMobileAdminUserInfo()
312
+	statistics_type, _ := this.GetInt("statistics_type")
313
+	fmt.Println("startisct=====================", statistics_type)
314
+	start_time := this.GetString("start_time")
315
+	end_time := this.GetString("end_time")
316
+	patient_id, _ := this.GetInt64("patient_id")
317
+	timeLayout := "2006-01-02"
318
+	loc, _ := time.LoadLocation("Local")
319
+
320
+	var theStartTIme int64
321
+	if len(start_time) > 0 {
322
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
323
+		if err != nil {
324
+			utils.ErrorLog(err.Error())
325
+		}
326
+		theStartTIme = theTime.Unix()
327
+	}
328
+	var theEndtTIme int64
329
+	if len(end_time) > 0 {
330
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
331
+		if err != nil {
332
+			utils.ErrorLog(err.Error())
333
+		}
334
+		theEndtTIme = theTime.Unix()
335
+	}
336
+
337
+	if patient_id == 0 {
338
+		patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.Org.Id)
339
+		if patientInfo == nil {
340
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
341
+			return
342
+		}
343
+		if statistics_type == 9 || statistics_type == 10 {
344
+			data, _ := statistics_service.GetDialysisProcessIndexOtherChartData(adminUserInfo.Org.Id, patientInfo.ID, theStartTIme, theEndtTIme, statistics_type)
345
+
346
+			this.ServeSuccessJSON(map[string]interface{}{
347
+				"data": data,
348
+			})
349
+		} else {
350
+
351
+			data, _ := statistics_service.GetDialysisProcessIndexChartData(adminUserInfo.Org.Id, patientInfo.ID, theStartTIme, theEndtTIme, statistics_type)
352
+
353
+			this.ServeSuccessJSON(map[string]interface{}{
354
+				"data": data,
355
+			})
356
+
357
+		}
358
+	} else {
359
+		if statistics_type == 9 || statistics_type == 10 {
360
+			data, _ := statistics_service.GetDialysisProcessIndexOtherChartData(adminUserInfo.Org.Id, patient_id, theStartTIme, theEndtTIme, statistics_type)
361
+
362
+			this.ServeSuccessJSON(map[string]interface{}{
363
+				"data": data,
364
+			})
365
+
366
+		} else {
367
+			data, _ := statistics_service.GetDialysisProcessIndexChartData(adminUserInfo.Org.Id, patient_id, theStartTIme, theEndtTIme, statistics_type)
368
+
369
+			this.ServeSuccessJSON(map[string]interface{}{
370
+				"data": data,
371
+			})
372
+
373
+		}
374
+	}
375
+
376
+}
377
+func (this *IndexEvaluationApiController) GetDialysisProcessIndexTableData() {
378
+	adminUserInfo := this.GetMobileAdminUserInfo()
379
+	start_time := this.GetString("start_time")
380
+	end_time := this.GetString("end_time")
381
+	patient_id, _ := this.GetInt64("patient_id")
382
+
383
+	page, _ := this.GetInt64("page")
384
+	limit, _ := this.GetInt64("limit")
385
+
386
+	if page == 0 {
387
+		page = 1
388
+	}
389
+	if limit == 0 {
390
+		limit = 20
391
+	}
392
+
393
+	timeLayout := "2006-01-02"
394
+	loc, _ := time.LoadLocation("Local")
395
+
396
+	var theStartTIme int64
397
+	if len(start_time) > 0 {
398
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
399
+		if err != nil {
400
+			utils.ErrorLog(err.Error())
401
+		}
402
+		theStartTIme = theTime.Unix()
403
+	}
404
+	var theEndtTIme int64
405
+	if len(end_time) > 0 {
406
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
407
+		if err != nil {
408
+			utils.ErrorLog(err.Error())
409
+		}
410
+		theEndtTIme = theTime.Unix()
411
+	}
412
+
413
+	if patient_id == 0 {
414
+		patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.Org.Id)
415
+		if patientInfo == nil {
416
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
417
+			return
418
+		}
419
+
420
+		data, total, _ := statistics_service.GetDialysisProcessIndexTableData(adminUserInfo.Org.Id, patientInfo.ID, page, limit, theStartTIme, theEndtTIme)
421
+
422
+		this.ServeSuccessJSON(map[string]interface{}{
423
+			"data":  data,
424
+			"total": total,
425
+		})
426
+
427
+	} else {
428
+		data, total, _ := statistics_service.GetDialysisProcessIndexTableData(adminUserInfo.Org.Id, patient_id, page, limit, theStartTIme, theEndtTIme)
429
+		this.ServeSuccessJSON(map[string]interface{}{
430
+			"data":  data,
431
+			"total": total,
432
+		})
433
+
434
+	}
435
+
436
+}
437
+func (this *IndexEvaluationApiController) GetDialysisWatchChartData() {
438
+	adminUserInfo := this.GetMobileAdminUserInfo()
439
+	statistics_type, _ := this.GetInt("statistics_type")
440
+	start_time := this.GetString("start_time")
441
+	end_time := this.GetString("end_time")
442
+	patient_id, _ := this.GetInt64("patient_id")
443
+	timeLayout := "2006-01-02"
444
+	loc, _ := time.LoadLocation("Local")
445
+
446
+	var theStartTIme int64
447
+	if len(start_time) > 0 {
448
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
449
+		if err != nil {
450
+			utils.ErrorLog(err.Error())
451
+		}
452
+		theStartTIme = theTime.Unix()
453
+	}
454
+	var theEndtTIme int64
455
+	if len(end_time) > 0 {
456
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
457
+		if err != nil {
458
+			utils.ErrorLog(err.Error())
459
+		}
460
+		theEndtTIme = theTime.Unix()
461
+	}
462
+
463
+	if patient_id == 0 {
464
+		patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.Org.Id)
465
+		if patientInfo == nil {
466
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
467
+			return
468
+		}
469
+		data, _ := statistics_service.GetDialysisWatchChartData(adminUserInfo.Org.Id, patientInfo.ID, theStartTIme, theEndtTIme, statistics_type)
470
+		this.ServeSuccessJSON(map[string]interface{}{
471
+			"data": data,
472
+		})
473
+	} else {
474
+		data, _ := statistics_service.GetDialysisWatchChartData(adminUserInfo.Org.Id, patient_id, theStartTIme, theEndtTIme, statistics_type)
475
+		this.ServeSuccessJSON(map[string]interface{}{
476
+			"data": data,
477
+		})
478
+	}
479
+
480
+}
481
+func (this *IndexEvaluationApiController) GetDialysisWatchTableData() {
482
+	adminUserInfo := this.GetMobileAdminUserInfo()
483
+	start_time := this.GetString("start_time")
484
+	end_time := this.GetString("end_time")
485
+	patient_id, _ := this.GetInt64("patient_id")
486
+	page, _ := this.GetInt64("page")
487
+	limit, _ := this.GetInt64("limit")
488
+
489
+	if page == 0 {
490
+		page = 1
491
+	}
492
+	if limit == 0 {
493
+		limit = 20
494
+	}
495
+	timeLayout := "2006-01-02"
496
+	loc, _ := time.LoadLocation("Local")
497
+
498
+	var theStartTIme int64
499
+	if len(start_time) > 0 {
500
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
501
+		if err != nil {
502
+			utils.ErrorLog(err.Error())
503
+		}
504
+		theStartTIme = theTime.Unix()
505
+	}
506
+	var theEndtTIme int64
507
+	if len(end_time) > 0 {
508
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
509
+		if err != nil {
510
+			utils.ErrorLog(err.Error())
511
+		}
512
+		theEndtTIme = theTime.Unix()
513
+	}
514
+
515
+	if patient_id == 0 {
516
+		patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.Org.Id)
517
+		if patientInfo == nil {
518
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
519
+			return
520
+		}
521
+
522
+		data, total, _ := statistics_service.GetDialysisWatchTableData(adminUserInfo.Org.Id, patientInfo.ID, page, limit, theStartTIme, theEndtTIme)
523
+
524
+		this.ServeSuccessJSON(map[string]interface{}{
525
+			"data":  data,
526
+			"total": total,
527
+		})
528
+
529
+	} else {
530
+
531
+		data, total, _ := statistics_service.GetDialysisWatchTableData(adminUserInfo.Org.Id, patient_id, page, limit, theStartTIme, theEndtTIme)
532
+		this.ServeSuccessJSON(map[string]interface{}{
533
+			"data":  data,
534
+			"total": total,
535
+		})
536
+
537
+	}
538
+
539
+}
540
+
541
+func (this *IndexEvaluationApiController) GetDialysisBloodPressureChartData() {
542
+	adminUserInfo := this.GetMobileAdminUserInfo()
543
+	statistics_type, _ := this.GetInt("statistics_type")
544
+	start_time := this.GetString("start_time")
545
+	end_time := this.GetString("end_time")
546
+	patient_id, _ := this.GetInt64("patient_id")
547
+
548
+	timeLayout := "2006-01-02"
549
+	loc, _ := time.LoadLocation("Local")
550
+
551
+	var theStartTIme int64
552
+	if len(start_time) > 0 {
553
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
554
+		if err != nil {
555
+			utils.ErrorLog(err.Error())
556
+		}
557
+		theStartTIme = theTime.Unix()
558
+	}
559
+	var theEndtTIme int64
560
+	if len(end_time) > 0 {
561
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
562
+		if err != nil {
563
+			utils.ErrorLog(err.Error())
564
+		}
565
+		theEndtTIme = theTime.Unix()
566
+	}
567
+
568
+	data, _ := statistics_service.GetBloodPressureChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, statistics_type, patient_id)
569
+	this.ServeSuccessJSON(map[string]interface{}{
570
+		"data": data,
571
+	})
572
+
573
+}
574
+func (this *IndexEvaluationApiController) GetDialysisBloodPressureTableData() {
575
+	adminUserInfo := this.GetMobileAdminUserInfo()
576
+	start_time := this.GetString("start_time")
577
+	end_time := this.GetString("end_time")
578
+	patient_id, _ := this.GetInt64("patient_id")
579
+	page, _ := this.GetInt64("page")
580
+	limit, _ := this.GetInt64("limit")
581
+
582
+	if page == 0 {
583
+		page = 1
584
+	}
585
+	if limit == 0 {
586
+		limit = 20
587
+	}
588
+	timeLayout := "2006-01-02"
589
+	loc, _ := time.LoadLocation("Local")
590
+
591
+	var theStartTIme int64
592
+	if len(start_time) > 0 {
593
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
594
+		if err != nil {
595
+			utils.ErrorLog(err.Error())
596
+		}
597
+		theStartTIme = theTime.Unix()
598
+	}
599
+	var theEndtTIme int64
600
+	if len(end_time) > 0 {
601
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
602
+		if err != nil {
603
+			utils.ErrorLog(err.Error())
604
+		}
605
+		theEndtTIme = theTime.Unix()
606
+	}
607
+
608
+	data, total, _ := statistics_service.GetBloodPressureTableData(adminUserInfo.Org.Id, patient_id, page, limit, theStartTIme, theEndtTIme)
609
+	this.ServeSuccessJSON(map[string]interface{}{
610
+		"data":  data,
611
+		"total": total,
612
+	})
613
+
614
+}
615
+func (this *IndexEvaluationApiController) GetDialysisPatientBloodPressureChartData() {
616
+	adminUserInfo := this.GetMobileAdminUserInfo()
617
+	statistics_type, _ := this.GetInt("statistics_type")
618
+	start_time := this.GetString("start_time")
619
+	end_time := this.GetString("end_time")
620
+	patient_id, _ := this.GetInt64("patient_id")
621
+
622
+	timeLayout := "2006-01-02"
623
+	loc, _ := time.LoadLocation("Local")
624
+
625
+	var theStartTIme int64
626
+	if len(start_time) > 0 {
627
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
628
+		if err != nil {
629
+			utils.ErrorLog(err.Error())
630
+		}
631
+		theStartTIme = theTime.Unix()
632
+	}
633
+	var theEndtTIme int64
634
+	if len(end_time) > 0 {
635
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
636
+		if err != nil {
637
+			utils.ErrorLog(err.Error())
638
+		}
639
+		theEndtTIme = theTime.Unix()
640
+	}
641
+
642
+	data, _ := statistics_service.GetPatientBloodPressureChartData(adminUserInfo.Org.Id, patient_id, theStartTIme, theEndtTIme, statistics_type)
643
+	this.ServeSuccessJSON(map[string]interface{}{
644
+		"data": data,
645
+	})
646
+
647
+}
648
+
649
+func (this *IndexEvaluationApiController) GetDialysisWeightChartData() {
650
+	adminUserInfo := this.GetMobileAdminUserInfo()
651
+	statistics_type, _ := this.GetInt("statistics_type")
652
+	start_time := this.GetString("start_time")
653
+	end_time := this.GetString("end_time")
654
+	timeLayout := "2006-01-02"
655
+	loc, _ := time.LoadLocation("Local")
656
+
657
+	var theStartTIme int64
658
+	if len(start_time) > 0 {
659
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
660
+		if err != nil {
661
+			utils.ErrorLog(err.Error())
662
+		}
663
+		theStartTIme = theTime.Unix()
664
+	}
665
+	var theEndtTIme int64
666
+	if len(end_time) > 0 {
667
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
668
+		if err != nil {
669
+			utils.ErrorLog(err.Error())
670
+		}
671
+		theEndtTIme = theTime.Unix()
672
+	}
673
+
674
+	data, _ := statistics_service.GetDialysisWeightChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, statistics_type)
675
+	this.ServeSuccessJSON(map[string]interface{}{
676
+		"data": data,
677
+	})
678
+
679
+}
680
+func (this *IndexEvaluationApiController) GetDialysisWeightTableData() {
681
+	adminUserInfo := this.GetMobileAdminUserInfo()
682
+	start_time := this.GetString("start_time")
683
+	end_time := this.GetString("end_time")
684
+	patient_id, _ := this.GetInt64("patient_id")
685
+	page, _ := this.GetInt64("page")
686
+	limit, _ := this.GetInt64("limit")
687
+
688
+	if page == 0 {
689
+		page = 1
690
+	}
691
+	if limit == 0 {
692
+		limit = 20
693
+	}
694
+	timeLayout := "2006-01-02"
695
+	loc, _ := time.LoadLocation("Local")
696
+
697
+	var theStartTIme int64
698
+	if len(start_time) > 0 {
699
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
700
+		if err != nil {
701
+			utils.ErrorLog(err.Error())
702
+		}
703
+		theStartTIme = theTime.Unix()
704
+	}
705
+	var theEndtTIme int64
706
+	if len(end_time) > 0 {
707
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
708
+		if err != nil {
709
+			utils.ErrorLog(err.Error())
710
+		}
711
+		theEndtTIme = theTime.Unix()
712
+	}
713
+
714
+	data, total, _ := statistics_service.GetDialysisWeightTableData(adminUserInfo.Org.Id, patient_id, page, limit, theStartTIme, theEndtTIme)
715
+	this.ServeSuccessJSON(map[string]interface{}{
716
+		"data":  data,
717
+		"total": total,
718
+	})
719
+}
720
+func (this *IndexEvaluationApiController) GetDialysisPatientWeightChartData() {
721
+	adminUserInfo := this.GetMobileAdminUserInfo()
722
+	statistics_type, _ := this.GetInt("statistics_type")
723
+	start_time := this.GetString("start_time")
724
+	end_time := this.GetString("end_time")
725
+	patient_id, _ := this.GetInt64("patient_id")
726
+
727
+	timeLayout := "2006-01-02"
728
+	loc, _ := time.LoadLocation("Local")
729
+
730
+	var theStartTIme int64
731
+	if len(start_time) > 0 {
732
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
733
+		if err != nil {
734
+			utils.ErrorLog(err.Error())
735
+		}
736
+		theStartTIme = theTime.Unix()
737
+	}
738
+	var theEndtTIme int64
739
+	if len(end_time) > 0 {
740
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
741
+		if err != nil {
742
+			utils.ErrorLog(err.Error())
743
+		}
744
+		theEndtTIme = theTime.Unix()
745
+	}
746
+
747
+	data, _ := statistics_service.GetPatientDialysisWeightChartData(adminUserInfo.Org.Id, patient_id, theStartTIme, theEndtTIme, statistics_type)
748
+	this.ServeSuccessJSON(map[string]interface{}{
749
+		"data": data,
750
+	})
751
+
752
+}
753
+
754
+func (this *IndexEvaluationApiController) GetDoctorWorkloadChartData() {
755
+	adminUserInfo := this.GetMobileAdminUserInfo()
756
+	statistics_type, _ := this.GetInt("statistics_type")
757
+	start_time := this.GetString("start_time")
758
+	admin_user_id, _ := this.GetInt64("admin_user_id")
759
+	end_time := this.GetString("end_time")
760
+	timeLayout := "2006-01-02"
761
+	loc, _ := time.LoadLocation("Local")
762
+
763
+	var theStartTIme int64
764
+	if len(start_time) > 0 {
765
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
766
+		if err != nil {
767
+			utils.ErrorLog(err.Error())
768
+		}
769
+		theStartTIme = theTime.Unix()
770
+	}
771
+	var theEndtTIme int64
772
+	if len(end_time) > 0 {
773
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
774
+		if err != nil {
775
+			utils.ErrorLog(err.Error())
776
+		}
777
+		theEndtTIme = theTime.Unix()
778
+	}
779
+
780
+	data, _ := statistics_service.GetDoctorWorkloadChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, statistics_type, admin_user_id)
781
+	this.ServeSuccessJSON(map[string]interface{}{
782
+		"data": data,
783
+	})
784
+
785
+}
786
+func (this *IndexEvaluationApiController) GetDoctorWorkloadTableData() {
787
+	adminUserInfo := this.GetMobileAdminUserInfo()
788
+	start_time := this.GetString("start_time")
789
+	end_time := this.GetString("end_time")
790
+	admin_user_id, _ := this.GetInt64("admin_user_id")
791
+	page, _ := this.GetInt64("page")
792
+	limit, _ := this.GetInt64("limit")
793
+
794
+	if page == 0 {
795
+		page = 1
796
+	}
797
+	if limit == 0 {
798
+		limit = 20
799
+	}
800
+	timeLayout := "2006-01-02"
801
+	loc, _ := time.LoadLocation("Local")
802
+
803
+	var theStartTIme int64
804
+	if len(start_time) > 0 {
805
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
806
+		if err != nil {
807
+			utils.ErrorLog(err.Error())
808
+		}
809
+		theStartTIme = theTime.Unix()
810
+	}
811
+	var theEndtTIme int64
812
+	if len(end_time) > 0 {
813
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
814
+		if err != nil {
815
+			utils.ErrorLog(err.Error())
816
+		}
817
+		theEndtTIme = theTime.Unix()
818
+	}
819
+	data, _ := statistics_service.GetDoctorWorkloadTableData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, admin_user_id)
820
+	this.ServeSuccessJSON(map[string]interface{}{
821
+		"data": data,
822
+	})
823
+}
824
+
825
+func (this *IndexEvaluationApiController) GetNurseWorkloadChartData() {
826
+	adminUserInfo := this.GetMobileAdminUserInfo()
827
+	statistics_type, _ := this.GetInt("statistics_type")
828
+	start_time := this.GetString("start_time")
829
+	admin_user_id, _ := this.GetInt64("admin_user_id")
830
+
831
+	end_time := this.GetString("end_time")
832
+	timeLayout := "2006-01-02"
833
+	loc, _ := time.LoadLocation("Local")
834
+
835
+	var theStartTIme int64
836
+	if len(start_time) > 0 {
837
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
838
+		if err != nil {
839
+			utils.ErrorLog(err.Error())
840
+		}
841
+		theStartTIme = theTime.Unix()
842
+	}
843
+	var theEndtTIme int64
844
+	if len(end_time) > 0 {
845
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
846
+		if err != nil {
847
+			utils.ErrorLog(err.Error())
848
+		}
849
+		theEndtTIme = theTime.Unix()
850
+	}
851
+
852
+	data, _ := statistics_service.GetNurseWorkloadChartData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, statistics_type, admin_user_id)
853
+	this.ServeSuccessJSON(map[string]interface{}{
854
+		"data": data,
855
+	})
856
+
857
+}
858
+func (this *IndexEvaluationApiController) GetNurseWorkloadTableData() {
859
+	adminUserInfo := this.GetMobileAdminUserInfo()
860
+	start_time := this.GetString("start_time")
861
+	end_time := this.GetString("end_time")
862
+	admin_user_id, _ := this.GetInt64("admin_user_id")
863
+	page, _ := this.GetInt64("page")
864
+	limit, _ := this.GetInt64("limit")
865
+
866
+	if page == 0 {
867
+		page = 1
868
+	}
869
+	if limit == 0 {
870
+		limit = 10
871
+	}
872
+	timeLayout := "2006-01-02"
873
+	loc, _ := time.LoadLocation("Local")
874
+
875
+	var theStartTIme int64
876
+	if len(start_time) > 0 {
877
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
878
+		if err != nil {
879
+			utils.ErrorLog(err.Error())
880
+		}
881
+		theStartTIme = theTime.Unix()
882
+	}
883
+	var theEndtTIme int64
884
+	if len(end_time) > 0 {
885
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
886
+		if err != nil {
887
+			utils.ErrorLog(err.Error())
888
+		}
889
+		theEndtTIme = theTime.Unix()
890
+	}
891
+	data, total, _ := statistics_service.GetNurseWorkloadTableData(adminUserInfo.Org.Id, theStartTIme, theEndtTIme, admin_user_id, page, limit)
892
+	dialysisCount, _ := statistics_service.GetOrderDialysisCount(adminUserInfo.Org.Id, theStartTIme, theEndtTIme)
893
+	this.ServeSuccessJSON(map[string]interface{}{
894
+		"data":          data,
895
+		"total":         total,
896
+		"dialysisCount": dialysisCount,
897
+	})
898
+}
899
+
900
+func (this *IndexEvaluationApiController) GetDefaultPatient() {
901
+	adminUserInfo := this.GetMobileAdminUserInfo()
902
+	patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.Org.Id)
903
+	if patientInfo == nil {
904
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
905
+		return
906
+	}
907
+
908
+	this.ServeSuccessJSON(map[string]interface{}{
909
+		"patient": patientInfo,
910
+	})
911
+
912
+}
913
+
914
+func (this *IndexEvaluationApiController) GetAllPatients() {
915
+	adminUserInfo := this.GetMobileAdminUserInfo()
916
+	patients, _ := statistics_service.GetOrgPatients(adminUserInfo.Org.Id)
917
+	if patients == nil {
918
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
919
+		return
920
+	}
921
+	this.ServeSuccessJSON(map[string]interface{}{
922
+		"patients": patients,
923
+	})
924
+
925
+}

+ 139 - 0
controllers/new_mobile_api_controllers/management_analyse_api_controller.go View File

@@ -0,0 +1,139 @@
1
+package new_mobile_api_controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/service/management_service"
6
+	service "Xcx_New/service/print_data_service/schedule_dialysis"
7
+	"Xcx_New/utils"
8
+	"time"
9
+)
10
+
11
+type ManagementAnalyseApiController struct {
12
+	NewMobileBaseAPIAuthController
13
+}
14
+
15
+func (this *ManagementAnalyseApiController) StockRecordPrintData() {
16
+	types, _ := this.GetInt("type", 0)
17
+	start_time := this.GetString("start_time")
18
+	end_time := this.GetString("end_time")
19
+	adminUserInfo := this.GetMobileAdminUserInfo()
20
+
21
+	timeLayout := "2006-01-02"
22
+	loc, _ := time.LoadLocation("Local")
23
+	var startTime int64
24
+	if len(start_time) > 0 {
25
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
26
+		if err != nil {
27
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
28
+			return
29
+		}
30
+		startTime = theTime.Unix()
31
+	}
32
+	var endTime int64
33
+	if len(end_time) > 0 {
34
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
35
+		if err != nil {
36
+			utils.ErrorLog(err.Error())
37
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
38
+			return
39
+		}
40
+		endTime = theTime.Unix()
41
+	}
42
+
43
+	list, err := service.FindPrintStockGoodInfoByType(types, startTime, endTime, adminUserInfo.Org.Id)
44
+
45
+	if err != nil {
46
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
47
+	} else {
48
+		this.ServeSuccessJSON(map[string]interface{}{
49
+			"list": list,
50
+			"type": types,
51
+		})
52
+	}
53
+}
54
+func (this *ManagementAnalyseApiController) StatisticsPatientChart() {
55
+	start_time := this.GetString("start_time")
56
+	end_time := this.GetString("end_time")
57
+	statistics_type, _ := this.GetInt("type", 0)
58
+
59
+	adminUserInfo := this.GetMobileAdminUserInfo()
60
+
61
+	timeLayout := "2006-01-02"
62
+	loc, _ := time.LoadLocation("Local")
63
+	var startTime int64
64
+	if len(start_time) > 0 {
65
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
66
+		if err != nil {
67
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
68
+			return
69
+		}
70
+		startTime = theTime.Unix()
71
+	}
72
+	var endTime int64
73
+	if len(end_time) > 0 {
74
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
75
+		if err != nil {
76
+			utils.ErrorLog(err.Error())
77
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
78
+			return
79
+		}
80
+		endTime = theTime.Unix()
81
+	}
82
+	data, total_one, _ := management_service.GetPatientChartData(adminUserInfo.Org.Id, startTime, endTime, statistics_type)
83
+	total, _ := management_service.GetLapsetoPatientTotal(adminUserInfo.Org.Id, statistics_type)
84
+
85
+	total_three, _ := management_service.GetLapsetoPatientTotal(adminUserInfo.Org.Id, 2)
86
+
87
+	this.ServeSuccessJSON(map[string]interface{}{
88
+		"chart_data":  data,
89
+		"total_one":   total_one,
90
+		"total":       total,
91
+		"total_three": total + total_three,
92
+	})
93
+
94
+}
95
+func (this *ManagementAnalyseApiController) StatisticsPatientTable() {
96
+	start_time := this.GetString("start_time")
97
+	end_time := this.GetString("end_time")
98
+	statistics_type, _ := this.GetInt("type", 0)
99
+	page, _ := this.GetInt64("page", 0)
100
+	limit, _ := this.GetInt64("limit", 0)
101
+
102
+	if page == 0 {
103
+		page = 1
104
+	}
105
+	if limit == 0 {
106
+		limit = 20
107
+	}
108
+
109
+	adminUserInfo := this.GetMobileAdminUserInfo()
110
+
111
+	timeLayout := "2006-01-02"
112
+	loc, _ := time.LoadLocation("Local")
113
+	var startTime int64
114
+	if len(start_time) > 0 {
115
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
116
+		if err != nil {
117
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
118
+			return
119
+		}
120
+		startTime = theTime.Unix()
121
+	}
122
+	var endTime int64
123
+	if len(end_time) > 0 {
124
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
125
+		if err != nil {
126
+			utils.ErrorLog(err.Error())
127
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
128
+			return
129
+		}
130
+		endTime = theTime.Unix()
131
+	}
132
+	data, total, _ := management_service.GetPatientTableData(adminUserInfo.Org.Id, page, limit, startTime, endTime, statistics_type)
133
+
134
+	this.ServeSuccessJSON(map[string]interface{}{
135
+		"data":  data,
136
+		"total": total,
137
+	})
138
+
139
+}

File diff suppressed because it is too large
+ 1084 - 0
controllers/new_mobile_api_controllers/mobile_his_api_controller.go


File diff suppressed because it is too large
+ 1280 - 0
controllers/new_mobile_api_controllers/mobile_regist_controller.go


File diff suppressed because it is too large
+ 2159 - 0
controllers/new_mobile_api_controllers/new_common_api_controller.go


+ 48 - 0
controllers/new_mobile_api_controllers/new_common_api_router.go View File

@@ -0,0 +1,48 @@
1
+package new_mobile_api_controllers
2
+
3
+import "github.com/astaxie/beego"
4
+
5
+func NewCommonApiControllersRegisterRouters() {
6
+
7
+	beego.Router("/m/api/gettotaldialysis", &NewCommonApiController{}, "Get:GetTotalDialysis")
8
+	beego.Router("/m/api/getmobiletotallapsecount", &NewCommonApiController{}, "Get:GetMobileTotalLapseCount")
9
+	beego.Router("/m/api/getmobiletotalsexcount", &NewCommonApiController{}, "Get:GetMobileTotalSexCount")
10
+	beego.Router("/m/api/getmobiletotalinfectiouscount", &NewCommonApiController{}, "Get:GetMobileTotalInfectiousCout")
11
+	beego.Router("/m/api/getmobiletotalagecount", &NewCommonApiController{}, "Get:GetMobileTotalAgeCount")
12
+	beego.Router("/m/api/getmobiletotaldialysiscount", &NewCommonApiController{}, "Get:GetMobileTotalDialysisCount")
13
+	beego.Router("/m/api/gemobilepatientlist", &NewCommonApiController{}, "Get:GetMobilePatientList")
14
+	beego.Router("/m/api/getprescriptionlist", &NewCommonApiController{}, "Get:GetPrescriptionlist")
15
+	beego.Router("/m/api/getmobilepatientdetail", &NewCommonApiController{}, "Get:GetMobilePatientDetail")
16
+	beego.Router("/m/api/tosearchpatient", &NewCommonApiController{}, "Get:ToSearchPatient")
17
+	beego.Router("/m/api/getallpatientsmode", &NewCommonApiController{}, "Get:GetAllPatientsMode")
18
+	beego.Router("/m/api/getmobileInspectionList", &NewCommonApiController{}, "Get:GetMobileInspectionList")
19
+	beego.Router("/m/api/getpatientinspectiondetail", &NewCommonApiController{}, "Get:GetPatientInspectionDetail")
20
+	beego.Router("m/api/getseachpatientdetail", &NewCommonApiController{}, "Get:GetSeachPatientDetail")
21
+	beego.Router("m/api/getmobilenormdata", &NewCommonApiController{}, "Get:GetMobileNormdata")
22
+	beego.Router("m/api/getmobileprojectlist", &NewCommonApiController{}, "Get:GetMobileProjectlsit")
23
+	beego.Router("/m/api/getmobilefirstquarter", &NewCommonApiController{}, "Get:GetMobileFirstQuarter")
24
+	beego.Router("/m/api/getmobilemonthprojectlist", &NewCommonApiController{}, "Get:GetMobileMonthProjectList")
25
+	beego.Router("/m/api/getallmobilemajorinspection", &NewCommonApiController{}, "Get:GetAllMobileMajorInspection")
26
+	beego.Router("/m/api/getmobilepatientlist", &NewCommonApiController{}, "Get:GetMobilePatient")
27
+	beego.Router("/m/api/getmobilepatientdetailcheck", &NewCommonApiController{}, "Get:GetMobilePatientDetailCheck")
28
+	beego.Router("/m/api/getmobilepatientcontrol", &NewCommonApiController{}, "Get:GetMobilePatientControl")
29
+	beego.Router("m/api/getmobilecartogramlist", &NewCommonApiController{}, "Get:GetMobileCartogramlist")
30
+	beego.Router("/m/api/getmobilequalitycontrol", &NewCommonApiController{}, "Get:GetMobileQualityControl")
31
+	beego.Router("/m/api/toseachpatientscontrol", &NewCommonApiController{}, "Get:GetSeachPatientsControl")
32
+	beego.Router("/m/api/getmobiletreatlist", &NewCommonApiController{}, "Get:GetMobileTreatlist")
33
+	beego.Router("/m/api/getlistpatientdetail", &NewCommonApiController{}, "Get:GetPatientComplianceDetail")
34
+	beego.Router("/m/api/getmobilebloodlist", &NewCommonApiController{}, "Get:GetMoblieBloodList")
35
+	beego.Router("/m/api/getbloodmonthlist", &NewCommonApiController{}, "Get:GetBloodMonthList")
36
+	beego.Router("/m/api/getquarterTargelist", &NewCommonApiController{}, "Get:GetQuarterTargeList")
37
+	beego.Router("/m/api/getmonthtarge", &NewCommonApiController{}, "Get:GetMonthTarget")
38
+	beego.Router("/m/api/getquarterbloodlist", &NewCommonApiController{}, "Get:GetQuarterBloodList")
39
+	beego.Router("/m/api/getmonthbloolist", &NewCommonApiController{}, "Get:GetMonthBLoodList")
40
+	beego.Router("/m/api/gettargetnostanddetail", &NewCommonApiController{}, "Get:GetTargetNoStandDetail")
41
+	beego.Router("/m/api/gettargestanddetail", &NewCommonApiController{}, "Get:GetTargetStandDetail")
42
+	beego.Router("/m/api/getsystolicbloodstand", &NewCommonApiController{}, "Get:GetSystolicBloodStand")
43
+	beego.Router("/m/api/getmobileidslist", &NewCommonApiController{}, "post:GetMobileIdsList")
44
+	beego.Router("/m/api/getsystolicbloodnostand", &NewCommonApiController{}, "Get:GetSystolicBloodNoStand")
45
+	beego.Router("/m/api/getmobiletreatmodelist", &NewCommonApiController{}, "Get:GetMobileTreatModeList")
46
+	beego.Router("/m/api/getmobileCountModeId", &NewCommonApiController{}, "Get:GetMobileCountModeId")
47
+	beego.Router("/m/api/getmobilerolloutcount", &NewCommonApiController{}, "Get:GetMobileRolloutCount")
48
+}

File diff suppressed because it is too large
+ 2856 - 0
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go


+ 589 - 0
controllers/new_mobile_api_controllers/new_login_api_controller.go View File

@@ -0,0 +1,589 @@
1
+package new_mobile_api_controllers
2
+
3
+import (
4
+	"Xcx_New/controllers/mobile_api_controllers"
5
+	"Xcx_New/enums"
6
+	"Xcx_New/models"
7
+	"Xcx_New/service"
8
+	"Xcx_New/utils"
9
+	"encoding/json"
10
+	"fmt"
11
+	"github.com/astaxie/beego"
12
+	"io/ioutil"
13
+	"net/http"
14
+	"net/url"
15
+	"strconv"
16
+	"strings"
17
+	"time"
18
+)
19
+
20
+type NewLoginApiController struct {
21
+	mobile_api_controllers.MobileBaseAPIController
22
+}
23
+
24
+func (this *NewLoginApiController) GetLogin() {
25
+	token_cookie := this.Ctx.GetCookie("token_cookie")
26
+	if len(token_cookie) == 0 {
27
+		this.ServeSuccessJSON(map[string]interface{}{
28
+			"isLogin": false,
29
+		})
30
+		this.ServeJSON()
31
+	} else {
32
+		//从cookie中分离出,手机号码,机构id,角色id,
33
+		cookieStr := token_cookie[24:]
34
+		cookieArr := strings.Split(cookieStr, "-")
35
+		mobile := cookieArr[0]
36
+		org_id, _ := strconv.ParseInt(cookieArr[1], 10, 64)
37
+		role_id, _ := strconv.ParseInt(cookieArr[2], 10, 64)
38
+		adminUser, getAdminErr := service.GetValidAdminUserByMobileReturnErr(mobile)
39
+		if getAdminErr != nil {
40
+			utils.ErrorLog("获取管理员失败:%v", getAdminErr)
41
+			this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
42
+			this.ServeJSON()
43
+			return
44
+		} else if adminUser == nil {
45
+			utils.ErrorLog("查找不到 mobile = %v 的用户", mobile)
46
+			this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeAccountOrPasswordWrong)
47
+			this.ServeJSON()
48
+			return
49
+		} else {
50
+			var appRole *models.App_Role
51
+			var org *models.Org
52
+			var app *models.OrgApp
53
+			var templateInfo models.GobalTemplate
54
+			var configList interface{}
55
+			var dict_configList interface{}
56
+
57
+			var FiledList []*models.FiledConfig
58
+
59
+			var getAppRoleErr error
60
+			var getOrgErr error
61
+			var getAppErr error
62
+
63
+			if role_id > 0 {
64
+				appRole, getAppRoleErr = service.GetAppRoleById(role_id)
65
+				if getAppRoleErr != nil {
66
+					utils.ErrorLog("获取 app_role 失败:%v", getAppRoleErr)
67
+					this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
68
+					this.ServeJSON()
69
+					return
70
+				}
71
+
72
+				app, getAppErr = service.GetAppById(appRole.AppId)
73
+				if getAppErr != nil {
74
+					utils.ErrorLog("获取APP失败:%v", getOrgErr)
75
+					this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
76
+					this.ServeJSON()
77
+					return
78
+				}
79
+			}
80
+
81
+			if org_id > 0 {
82
+				org, getOrgErr = service.GetOrgById(org_id)
83
+				if getOrgErr != nil {
84
+					utils.ErrorLog("获取机构失败:%v", getOrgErr)
85
+					this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
86
+					this.ServeJSON()
87
+					return
88
+				}
89
+				templateInfo, _ = service.GetOrgInfoTemplate(org.Id)
90
+				configList, _ = service.GetConfigList(org.Id)
91
+				dict_configList, _ = service.GetDictConfigList(org.Id)
92
+
93
+				FiledList, _ = service.FindFiledByOrgId(org.Id)
94
+			}
95
+
96
+			mobileAdminUserInfo := &mobile_api_controllers.MobileAdminUserInfo{
97
+				AdminUser:    adminUser,
98
+				Org:          org,
99
+				App:          app,
100
+				AppRole:      appRole,
101
+				TemplateInfo: &templateInfo,
102
+			}
103
+			fmt.Println(this.GetSession("mobile_admin_user_info"))
104
+
105
+			if this.GetSession("mobile_admin_user_info") == nil {
106
+				this.SetSession("mobile_admin_user_info", mobileAdminUserInfo)
107
+			}
108
+			fmt.Println(this.GetSession("mobile_admin_user_info"))
109
+
110
+			this.ServeSuccessJSON(map[string]interface{}{
111
+				"admin": adminUser,
112
+				"user":  appRole,
113
+				"org":   org,
114
+				"app":   app,
115
+				"template_info": map[string]interface{}{
116
+					"id":          templateInfo.ID,
117
+					"org_id":      templateInfo.OrgId,
118
+					"template_id": templateInfo.TemplateId,
119
+				},
120
+				"config_list":      configList,
121
+				"dict_config_list": dict_configList,
122
+
123
+				"filed_list": FiledList,
124
+				"isLogin":    true,
125
+			})
126
+
127
+			this.ServeJSON()
128
+		}
129
+	}
130
+
131
+}
132
+
133
+func (this *NewLoginApiController) GetCodeInit() {
134
+	redisClient := service.RedisClient()
135
+	defer redisClient.Close()
136
+	req := this.Ctx.Request
137
+	addr := utils.GetIP(req)
138
+	cur_time := time.Now().Format("2006-01-02")
139
+	_, err := redisClient.Get("ip:host_" + cur_time + "_" + addr).Result()
140
+	if err != nil {
141
+		redisClient.Set("ip:host_"+cur_time+"_"+addr, 0, time.Second*24*60*60)
142
+	}
143
+	//将客户端的ip加密传给前端,作为短信验证的密钥,来验证短信发送的IP地址
144
+	aespass := utils.AESEncrypt(addr)
145
+	//this.Data["aespass"] = aespass
146
+
147
+	this.ServeSuccessJSON(map[string]interface{}{
148
+		"aespass": aespass,
149
+	})
150
+
151
+}
152
+
153
+func (this *NewLoginApiController) LoginByCs() {
154
+	mobile := this.GetString("mobile")
155
+	code := this.GetString("code")
156
+	//pwd := this.GetString("password")
157
+	if len(mobile) == 0 || len(code) == 0 || utils.CellPhoneRegexp().MatchString(mobile) == false {
158
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
159
+		return
160
+	}
161
+	if !service.IsMobileRegister(mobile) {
162
+		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeAccountOrVerCodeWrong)
163
+		this.ServeJSON()
164
+		return
165
+	}
166
+
167
+	if code == "13535547901" {
168
+		ip := utils.GetIP(this.Ctx.Request)
169
+		ssoDomain := beego.AppConfig.String("sso_domain")
170
+		api := ssoDomain + "/m/login/code"
171
+		values := make(url.Values)
172
+		values.Set("mobile", mobile)
173
+		values.Set("app_type", "3")
174
+		values.Set("ip", ip)
175
+		resp, requestErr := http.PostForm(api, values)
176
+
177
+		if requestErr != nil {
178
+			utils.ErrorLog("请求SSO登录接口失败: %v", requestErr)
179
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
180
+			return
181
+		}
182
+		defer resp.Body.Close()
183
+		body, ioErr := ioutil.ReadAll(resp.Body)
184
+		if ioErr != nil {
185
+			utils.ErrorLog("SSO登录接口返回数据读取失败: %v", ioErr)
186
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
187
+			return
188
+		}
189
+		var respJSON map[string]interface{}
190
+		utils.InfoLog(string(body))
191
+		if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
192
+			utils.ErrorLog("SSO登录接口返回数据解析JSON失败: %v", err)
193
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
194
+			return
195
+		}
196
+
197
+		if respJSON["state"].(float64) != 1 {
198
+			msg := respJSON["msg"].(string)
199
+			utils.ErrorLog("SSO登录接口请求失败: %v", msg)
200
+			if int(respJSON["code"].(float64)) == 609 {
201
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAccountOrPasswordWrong)
202
+				return
203
+			}
204
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
205
+			return
206
+		} else {
207
+			utils.SuccessLog("SSO登录成功")
208
+			// 下面这几段 Map=>JSON=>Struct 的流程可能会造成速度很慢
209
+			userJSON := respJSON["data"].(map[string]interface{})["admin"].(map[string]interface{})
210
+			userJSONBytes, _ := json.Marshal(userJSON)
211
+			var adminUser models.AdminUser
212
+			if err := json.Unmarshal(userJSONBytes, &adminUser); err != nil {
213
+				utils.ErrorLog("解析管理员失败:%v", err)
214
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
215
+				return
216
+			}
217
+
218
+			var org models.Org
219
+			if respJSON["data"].(map[string]interface{})["org"] != nil {
220
+				orgJSON := respJSON["data"].(map[string]interface{})["org"].(map[string]interface{})
221
+				orgJSONBytes, _ := json.Marshal(orgJSON)
222
+				if err := json.Unmarshal(orgJSONBytes, &org); err != nil {
223
+					utils.ErrorLog("解析机构失败:%v", err)
224
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
225
+					return
226
+				}
227
+			}
228
+
229
+			var app models.OrgApp
230
+
231
+			if respJSON["data"].(map[string]interface{})["app"] != nil {
232
+				appJSON := respJSON["data"].(map[string]interface{})["app"].(map[string]interface{})
233
+				appJSONBytes, _ := json.Marshal(appJSON)
234
+				if err := json.Unmarshal(appJSONBytes, &app); err != nil {
235
+					utils.ErrorLog("解析应用失败:%v", err)
236
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
237
+					return
238
+				}
239
+			}
240
+
241
+			var appRole models.App_Role
242
+
243
+			if respJSON["data"].(map[string]interface{})["app_role"] != nil {
244
+				appRoleJSON := respJSON["data"].(map[string]interface{})["app_role"].(map[string]interface{})
245
+				appRoleJSONBytes, _ := json.Marshal(appRoleJSON)
246
+				if err := json.Unmarshal(appRoleJSONBytes, &appRole); err != nil {
247
+					utils.ErrorLog("解析AppRole失败:%v", err)
248
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
249
+					return
250
+				}
251
+			}
252
+
253
+			var subscibe models.ServeSubscibe
254
+			if respJSON["data"].(map[string]interface{})["subscibe"] != nil {
255
+				subscibeJSON := respJSON["data"].(map[string]interface{})["subscibe"].(map[string]interface{})
256
+				subscibeJSONBytes, _ := json.Marshal(subscibeJSON)
257
+				if err := json.Unmarshal(subscibeJSONBytes, &subscibe); err != nil {
258
+					utils.ErrorLog("解析Subscibe失败:%v", err)
259
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
260
+					return
261
+				}
262
+
263
+			}
264
+
265
+			//service.GetOrgSubscibeState(&subscibe)
266
+			templateInfo, _ := service.GetOrgInfoTemplate(org.Id)
267
+
268
+			mobileAdminUserInfo := &mobile_api_controllers.MobileAdminUserInfo{
269
+				AdminUser:    &adminUser,
270
+				Org:          &org,
271
+				App:          &app,
272
+				AppRole:      &appRole,
273
+				Subscibe:     &subscibe,
274
+				TemplateInfo: &templateInfo,
275
+			}
276
+			this.SetSession("mobile_admin_user_info", mobileAdminUserInfo)
277
+
278
+			mobile = mobile + "-" + strconv.FormatInt(org.Id, 10) + "-" + strconv.FormatInt(appRole.Id, 10)
279
+			token := utils.GenerateLoginToken(mobile)
280
+			expiration, _ := beego.AppConfig.Int64("mobile_token_expiration_second")
281
+			this.Ctx.SetCookie("token_cookie", token, expiration, "/")
282
+
283
+			var configList interface{}
284
+			var dict_configList interface{}
285
+
286
+			var FiledList []*models.FiledConfig
287
+
288
+			if org.Id > 0 {
289
+				dict_configList, _ = service.GetDictConfigList(org.Id)
290
+
291
+				configList, _ = service.GetConfigList(org.Id)
292
+				FiledList, _ = service.FindFiledByOrgId(org.Id)
293
+			}
294
+			if len(FiledList) == 0 {
295
+				var err error
296
+				if org.Id > 0 {
297
+					err = service.BatchInsertFiledConfig(org.Id)
298
+					if err == nil {
299
+						FiledList, _ = service.FindFiledByOrgId(org.Id)
300
+					} else {
301
+						utils.ErrorLog("字段批量插入失败:%v", err)
302
+					}
303
+				} else {
304
+					FiledList = make([]*models.FiledConfig, 0)
305
+				}
306
+			}
307
+
308
+			if org.Id > 0 {
309
+				//产寻该机构是否有收缩压和舒张压
310
+				pressure, err := service.GetDefaultSystolicPressure(org.Id)
311
+				fmt.Println(err)
312
+				if len(pressure) == 0 {
313
+					err = service.BathInsertQualityControlTwo(org.Id)
314
+				} else {
315
+					utils.ErrorLog("字段批量插入失败:%v", err)
316
+				}
317
+				major, requestErr := service.GetInspectionMajor(org.Id)
318
+				if len(major) == 0 {
319
+					QualityeList, err := service.FindQualityByOrgId(org.Id)
320
+					if len(QualityeList) == 0 {
321
+						err = service.BatchInsertQualityControl(org.Id)
322
+
323
+					} else {
324
+						utils.ErrorLog("字段批量插入失败0:%v", err)
325
+					}
326
+
327
+					InspectionList, err := service.FindeInspectionByOrgId(org.Id)
328
+					if len(InspectionList) == 0 {
329
+						err = service.BatchInspectionConfiguration(org.Id)
330
+					} else {
331
+						utils.ErrorLog("字段批量插入失败0:%v", err)
332
+					}
333
+				} else {
334
+					utils.ErrorLog("字段批量插入失败0:%v", requestErr)
335
+				}
336
+
337
+			}
338
+
339
+			this.ServeSuccessJSON(map[string]interface{}{
340
+				"admin": adminUser,
341
+				"user": map[string]interface{}{
342
+					"id":         appRole.Id,
343
+					"user_name":  appRole.UserName,
344
+					"avatar":     appRole.Avatar,
345
+					"intro":      appRole.Intro,
346
+					"user_type":  appRole.UserType,
347
+					"user_title": appRole.UserTitle,
348
+				},
349
+				"org": map[string]interface{}{
350
+					"id":             org.Id,
351
+					"org_name":       org.OrgName,
352
+					"org_short_name": org.OrgShortName,
353
+					"org_intro":      org.OrgIntroduction,
354
+					"org_logo":       org.OrgLogo,
355
+					"province":       org.Province,
356
+					"city":           org.City,
357
+					"district":       org.District,
358
+					"address":        org.Address,
359
+					"creator":        org.Creator,
360
+				},
361
+				"subscibe": map[string]interface{}{
362
+					"id":           subscibe.ID,
363
+					"period_start": subscibe.PeriodStart,
364
+					"period_end":   subscibe.PeriodEnd,
365
+					"state":        subscibe.State,
366
+				}, "template_info": map[string]interface{}{
367
+					"id":          templateInfo.ID,
368
+					"org_id":      templateInfo.OrgId,
369
+					"template_id": templateInfo.TemplateId,
370
+				},
371
+				"config_list":      configList,
372
+				"dict_config_list": dict_configList,
373
+
374
+				"filed_list": FiledList,
375
+			})
376
+		}
377
+	} else {
378
+
379
+		redisClient := service.RedisClient()
380
+		defer redisClient.Close()
381
+		cachedCode, err := redisClient.Get("code_msg_" + mobile).Result()
382
+
383
+		if err != nil {
384
+			this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeAccountOrVerCodeWrong)
385
+			this.ServeJSON()
386
+			return
387
+
388
+		} else {
389
+			if code != cachedCode {
390
+				this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeAccountOrVerCodeWrong)
391
+				this.ServeJSON()
392
+				return
393
+			} else {
394
+
395
+				ip := utils.GetIP(this.Ctx.Request)
396
+
397
+				ssoDomain := beego.AppConfig.String("sso_domain")
398
+				api := ssoDomain + "/m/login/code"
399
+				values := make(url.Values)
400
+				values.Set("mobile", mobile)
401
+				values.Set("app_type", "3")
402
+				values.Set("ip", ip)
403
+				resp, requestErr := http.PostForm(api, values)
404
+
405
+				if requestErr != nil {
406
+					utils.ErrorLog("请求SSO登录接口失败: %v", requestErr)
407
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
408
+					return
409
+				}
410
+				defer resp.Body.Close()
411
+				body, ioErr := ioutil.ReadAll(resp.Body)
412
+				if ioErr != nil {
413
+					utils.ErrorLog("SSO登录接口返回数据读取失败: %v", ioErr)
414
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
415
+					return
416
+				}
417
+				var respJSON map[string]interface{}
418
+				utils.InfoLog(string(body))
419
+				if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
420
+					utils.ErrorLog("SSO登录接口返回数据解析JSON失败: %v", err)
421
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
422
+					return
423
+				}
424
+
425
+				if respJSON["state"].(float64) != 1 {
426
+					msg := respJSON["msg"].(string)
427
+					utils.ErrorLog("SSO登录接口请求失败: %v", msg)
428
+					if int(respJSON["code"].(float64)) == 609 {
429
+						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAccountOrPasswordWrong)
430
+						return
431
+					}
432
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
433
+					return
434
+				} else {
435
+					utils.SuccessLog("SSO登录成功")
436
+					// 下面这几段 Map=>JSON=>Struct 的流程可能会造成速度很慢
437
+					userJSON := respJSON["data"].(map[string]interface{})["admin"].(map[string]interface{})
438
+					userJSONBytes, _ := json.Marshal(userJSON)
439
+					var adminUser models.AdminUser
440
+					if err := json.Unmarshal(userJSONBytes, &adminUser); err != nil {
441
+						utils.ErrorLog("解析管理员失败:%v", err)
442
+						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
443
+						return
444
+					}
445
+					orgJSON := respJSON["data"].(map[string]interface{})["org"].(map[string]interface{})
446
+					orgJSONBytes, _ := json.Marshal(orgJSON)
447
+					var org models.Org
448
+					if err := json.Unmarshal(orgJSONBytes, &org); err != nil {
449
+						utils.ErrorLog("解析机构失败:%v", err)
450
+						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
451
+						return
452
+					}
453
+					appJSON := respJSON["data"].(map[string]interface{})["app"].(map[string]interface{})
454
+					appJSONBytes, _ := json.Marshal(appJSON)
455
+					var app models.OrgApp
456
+					if err := json.Unmarshal(appJSONBytes, &app); err != nil {
457
+						utils.ErrorLog("解析应用失败:%v", err)
458
+						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
459
+						return
460
+					}
461
+					appRoleJSON := respJSON["data"].(map[string]interface{})["app_role"].(map[string]interface{})
462
+					appRoleJSONBytes, _ := json.Marshal(appRoleJSON)
463
+					var appRole models.App_Role
464
+					if err := json.Unmarshal(appRoleJSONBytes, &appRole); err != nil {
465
+						utils.ErrorLog("解析AppRole失败:%v", err)
466
+						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
467
+						return
468
+					}
469
+					subscibeJSON := respJSON["data"].(map[string]interface{})["subscibe"].(map[string]interface{})
470
+					subscibeJSONBytes, _ := json.Marshal(subscibeJSON)
471
+					var subscibe models.ServeSubscibe
472
+					if err := json.Unmarshal(subscibeJSONBytes, &subscibe); err != nil {
473
+						utils.ErrorLog("解析Subscibe失败:%v", err)
474
+						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
475
+						return
476
+					}
477
+					service.GetOrgSubscibeState(&subscibe)
478
+					templateInfo, _ := service.GetOrgInfoTemplate(org.Id)
479
+
480
+					mobileAdminUserInfo := &mobile_api_controllers.MobileAdminUserInfo{
481
+						AdminUser:    &adminUser,
482
+						Org:          &org,
483
+						App:          &app,
484
+						AppRole:      &appRole,
485
+						Subscibe:     &subscibe,
486
+						TemplateInfo: &templateInfo,
487
+					}
488
+					this.SetSession("mobile_admin_user_info", mobileAdminUserInfo)
489
+					redisClient.Del("code_msg_" + mobile)
490
+
491
+					mobile = mobile + "-" + strconv.FormatInt(org.Id, 10) + "-" + strconv.FormatInt(appRole.Id, 10)
492
+					token := utils.GenerateLoginToken(mobile)
493
+					expiration, _ := beego.AppConfig.Int64("mobile_token_expiration_second")
494
+					this.Ctx.SetCookie("token_cookie", token, expiration, "/")
495
+
496
+					configList, _ := service.GetConfigList(org.Id)
497
+					dict_configList, _ := service.GetDictConfigList(org.Id)
498
+
499
+					var FiledList []*models.FiledConfig
500
+					FiledList, _ = service.FindFiledByOrgId(org.Id)
501
+					if len(FiledList) == 0 {
502
+						var err error
503
+						if org.Id > 0 {
504
+							err = service.BatchInsertFiledConfig(org.Id)
505
+							if err == nil {
506
+								FiledList, _ = service.FindFiledByOrgId(org.Id)
507
+							} else {
508
+								utils.ErrorLog("字段批量插入失败:%v", err)
509
+							}
510
+						} else {
511
+							FiledList = make([]*models.FiledConfig, 0)
512
+						}
513
+					}
514
+
515
+					this.ServeSuccessJSON(map[string]interface{}{
516
+						"user": map[string]interface{}{
517
+							"id":         adminUser.Id,
518
+							"mobile":     adminUser.Mobile,
519
+							"user_name":  appRole.UserName,
520
+							"avatar":     appRole.Avatar,
521
+							"intro":      appRole.Intro,
522
+							"user_type":  appRole.UserType,
523
+							"user_title": appRole.UserTitle,
524
+						},
525
+						"org": map[string]interface{}{
526
+							"id":             org.Id,
527
+							"org_name":       org.OrgName,
528
+							"org_short_name": org.OrgShortName,
529
+							"org_intro":      org.OrgIntroduction,
530
+							"org_logo":       org.OrgLogo,
531
+							"province":       org.Province,
532
+							"city":           org.City,
533
+							"district":       org.District,
534
+							"address":        org.Address,
535
+							"creator":        org.Creator,
536
+						},
537
+						"subscibe": map[string]interface{}{
538
+							"id":           subscibe.ID,
539
+							"period_start": subscibe.PeriodStart,
540
+							"period_end":   subscibe.PeriodEnd,
541
+							"state":        subscibe.State,
542
+						}, "template_info": map[string]interface{}{
543
+							"id":          templateInfo.ID,
544
+							"org_id":      templateInfo.OrgId,
545
+							"template_id": templateInfo.TemplateId,
546
+						},
547
+						"config_list":      configList,
548
+						"dict_config_list": dict_configList,
549
+
550
+						"filed_list": FiledList,
551
+					})
552
+				}
553
+
554
+			}
555
+		}
556
+	}
557
+}
558
+
559
+func (this *NewLoginApiController) GetCode() {
560
+	mobile := this.GetString("phone")
561
+	aespass := this.GetString("aespass")
562
+	types, _ := this.GetInt("type", 0)
563
+	utils.TraceLog("mobile:%v aespass:%v", mobile, aespass)
564
+	if utils.CellPhoneRegexp().MatchString(mobile) == false {
565
+		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeMobileFormat)
566
+		this.ServeJSON()
567
+		return
568
+	}
569
+
570
+	if types == 1 {
571
+		adminUser, _ := service.GetValidAdminUserByMobileReturnErr(mobile)
572
+		if adminUser != nil {
573
+			this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeRegisterExist)
574
+			this.ServeJSON()
575
+			return
576
+		}
577
+	}
578
+
579
+	if err := service.SendVerificationCodeSMS(mobile, aespass); err != nil {
580
+		this.Data["json"] = enums.MakeFailResponseJSON(err.Error(), 600)
581
+		this.ServeJSON()
582
+	} else {
583
+		this.Data["json"] = enums.MakeSuccessResponseJSON(map[string]interface{}{
584
+			"msg": "短信发送成功,有效期为10分钟",
585
+		})
586
+		this.ServeJSON()
587
+	}
588
+
589
+}

+ 241 - 0
controllers/new_mobile_api_controllers/new_manage_api_controller.go View File

@@ -0,0 +1,241 @@
1
+package new_mobile_api_controllers
2
+
3
+import (
4
+	"Xcx_New/controllers/mobile_api_controllers"
5
+	"Xcx_New/enums"
6
+	"Xcx_New/models"
7
+	"Xcx_New/service"
8
+	"Xcx_New/utils"
9
+	"fmt"
10
+	"github.com/jinzhu/gorm"
11
+	"strconv"
12
+	"time"
13
+)
14
+
15
+type NewManageApiController struct {
16
+	mobile_api_controllers.MobileBaseAPIAuthController
17
+}
18
+
19
+func (this *NewManageApiController) GetEquitAutoInfo() {
20
+
21
+	adminUser := this.GetMobileAdminUserInfo()
22
+	orgid := adminUser.Org.Id
23
+	remander, err := service.GetRemanderData(orgid)
24
+	if err != nil {
25
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
26
+		return
27
+	}
28
+	this.ServeSuccessJSON(map[string]interface{}{
29
+		"remander": remander,
30
+	})
31
+}
32
+
33
+func (this *NewManageApiController) GetDisInfectionTime() {
34
+	adminUser := this.GetMobileAdminUserInfo()
35
+	orgid := adminUser.Org.Id
36
+	bedid, _ := this.GetInt64("bed_id")
37
+	scheduletype, _ := this.GetInt64("schedule_type")
38
+	scheduleweek, _ := this.GetInt64("schedule_week")
39
+	fmt.Println(scheduleweek)
40
+	scheduledate, _ := this.GetInt64("schedule_date")
41
+
42
+	//根据床位号获取设备型号
43
+	unitType, _ := service.GetUnitType(bedid, orgid)
44
+	//查询使用登记最后一条消毒记录
45
+	infomation, err := service.GetLaseDeviceInfomation(orgid, bedid, scheduledate, scheduletype)
46
+	fmt.Println("err", err)
47
+	if err == gorm.ErrRecordNotFound {
48
+		//查询改设备是否有消毒计划
49
+		plan, errcode := service.GetDisInfectionTime(orgid, unitType.UnitType, scheduletype, scheduleweek)
50
+		//如果没有消毒计划,去查询该设备的上次消毒时间
51
+		if errcode == gorm.ErrRecordNotFound {
52
+			infor, errco := service.GetLaseDeviceInfomationTwo(orgid, bedid, scheduletype)
53
+			if errco != nil {
54
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
55
+				return
56
+			}
57
+			this.ServeSuccessJSON(map[string]interface{}{
58
+				"plan": infor.LongTime,
59
+			})
60
+		} else if errcode == nil {
61
+			this.ServeSuccessJSON(map[string]interface{}{
62
+				"plan": plan.DisinfecTime,
63
+			})
64
+		}
65
+	} else if err == nil {
66
+		this.ServeSuccessJSON(map[string]interface{}{
67
+			"plan":       infomation.LongTime,
68
+			"infomation": infomation,
69
+		})
70
+	}
71
+	//查询改设备是否有消毒计划
72
+	//plan, err := service.GetDisInfectionTime(orgid, bedid, scheduletype, scheduleweek)
73
+	//if err == gorm.ErrRecordNotFound {
74
+	//	//去查询使用登记最后一条数据
75
+	//	infomation, err := service.GetLaseDeviceInfomation(orgid, bedid)
76
+	//	if err != nil {
77
+	//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
78
+	//		return
79
+	//	}
80
+	//	this.ServeSuccessJSON(map[string]interface{}{
81
+	//		"plan": infomation.LongTime,
82
+	//	})
83
+	//} else if err == nil {
84
+	//	if err != nil {
85
+	//		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
86
+	//		return
87
+	//	}
88
+	//	this.ServeSuccessJSON(map[string]interface{}{
89
+	//		"plan": plan.DisinfecTime,
90
+	//	})
91
+	//} else {
92
+	//
93
+	//}
94
+
95
+}
96
+
97
+func (this *NewManageApiController) SaveDisInfectionInfo() {
98
+	adminUser := this.GetMobileAdminUserInfo()
99
+	orgid := adminUser.Org.Id
100
+	bedid, _ := this.GetInt64("bed_id")
101
+	start_time := this.GetString("start_time")
102
+	startdate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", start_time)
103
+	startdateunix := startdate.Unix()
104
+	disinfectime, _ := this.GetInt64("disinfec_time")
105
+	endtime := this.GetString("end_time")
106
+	enddate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", endtime)
107
+	enddateunix := enddate.Unix()
108
+	scheduledate, _ := this.GetInt64("schedule_date")
109
+	zoneid, _ := this.GetInt64("zone_id")
110
+	patientid, _ := this.GetInt64("patient_id")
111
+	modeid, _ := this.GetInt64("mode_id")
112
+	scheduletype, _ := this.GetInt64("schedule_type")
113
+
114
+	//查询病人信息
115
+	patients, _ := service.GetPatientInfoMation(patientid)
116
+	var con = ""
117
+	if patients.IsInfectious == 0 {
118
+		con = ""
119
+	}
120
+	if patients.IsInfectious == 1 {
121
+		con = "无"
122
+	}
123
+	if patients.IsInfectious == 2 {
124
+		con = "有"
125
+	}
126
+	//查询病人上机信息
127
+	order, _ := service.GetPatientOrderInfo(scheduledate, patientid, orgid)
128
+	//查询病人今日透后评估数据
129
+	dislysis, _ := service.GetAssessmentAfterDissDataTwo(patientid, orgid, scheduledate)
130
+	fmt.Println("透析减少", dislysis.WeightLoss)
131
+	//			//根据床位号获取设备id
132
+	addmacher, _ := service.GetEquimentIDTwo(bedid, orgid)
133
+	//unitype, _ := strconv.ParseInt(addmacher.UnitType, 10, 64)
134
+	//fmt.Println(unitype)
135
+	plan, errplan := service.GetDisinfectionTwo(addmacher.UnitType, scheduletype, orgid)
136
+	//counts, errplan := service.GetUserTotalCount(orgid, bedid)
137
+	//var usertoal  int64
138
+	//fmt.Println(usertoal)
139
+	//for index, count := range counts {
140
+	//   if(index == 0){
141
+	//      usertoal = count.Total
142
+	//   }
143
+	//}
144
+	//usertotalint, errplan := strconv.ParseInt(addmacher.UserTotal, 10, 64)
145
+	//var total = usertoal + usertotalint
146
+	//totals := strconv.FormatInt(total, 10)
147
+	if errplan == gorm.ErrRecordNotFound {
148
+		returnData := make(map[string]interface{}, 0)
149
+		returnData["msstatus"] = "2"
150
+		this.ServeSuccessJSON(returnData)
151
+		return
152
+	} else {
153
+		_, errcode := service.GetInforTwo(patientid, scheduledate, orgid, scheduletype)
154
+		if errcode == gorm.ErrRecordNotFound {
155
+			information := models.DeviceInformation{
156
+				Date:                  scheduledate,
157
+				Zone:                  zoneid,
158
+				Class:                 scheduletype,
159
+				BedNumber:             bedid,
160
+				PatientId:             patientid,
161
+				DialysisMode:          modeid,
162
+				LongTime:              strconv.FormatInt(disinfectime, 10),
163
+				Disinfection:          1,
164
+				DialysisConcentration: 1,
165
+				DisinfectionStatus:    1,
166
+				Move:                  1,
167
+				UserOrgId:             orgid,
168
+				DisinfectType:         plan.Way,
169
+				DisinfectantType:      plan.MachineDisinfectant,
170
+				FluidPath:             plan.DisinfectanWay, //液路消毒方式
171
+				Disinfectant:          plan.Disinfectant,
172
+				Ctime:                 time.Now().Unix(),
173
+				Status:                1,
174
+				SignName:              order.FinishNurse,
175
+				EquimentId:            addmacher.ID,
176
+				DisinfectionResidue:   2,
177
+				Bed:                   addmacher.BedNumber,
178
+				StartTime:             order.StartTime,
179
+				EndTime:               order.EndTime,
180
+				Contagion:             con,
181
+				WeightLoss:            dislysis.WeightLoss,
182
+				Hyperfiltratio:        dislysis.ActualUltrafiltration,
183
+				DialysisHour:          strconv.FormatInt(dislysis.ActualTreatmentHour, 10),
184
+				MachineRun:            1,
185
+				DisinfecStartime:      startdateunix,
186
+				DisinfecEndtime:       enddateunix,
187
+			}
188
+			err := service.CreateInformationTwo(&information)
189
+			fmt.Println("报错", err)
190
+			if err != nil {
191
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
192
+				return
193
+			}
194
+			this.ServeSuccessJSON(map[string]interface{}{
195
+				"information": information,
196
+			})
197
+		} else if errcode == nil {
198
+			information := models.DeviceInformation{
199
+				DisinfecStartime: startdateunix,
200
+				DisinfecEndtime:  enddateunix,
201
+				LongTime:         strconv.FormatInt(disinfectime, 10),
202
+			}
203
+
204
+			errcode := service.UpdateInformation(&information, scheduledate, bedid, scheduletype)
205
+			if errcode != nil {
206
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
207
+				return
208
+			}
209
+			this.ServeSuccessJSON(map[string]interface{}{
210
+				"information": information,
211
+			})
212
+		} else {
213
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
214
+			return
215
+		}
216
+	}
217
+}
218
+
219
+func (this *NewManageApiController) GetDeviceInformation() {
220
+
221
+	adminUser := this.GetMobileAdminUserInfo()
222
+	orgid := adminUser.Org.Id
223
+
224
+	scheduleDate := this.GetString("schedule_date")
225
+	recordDate, parseErr := utils.ParseTimeStringToTime("2006-01-02", scheduleDate)
226
+	if parseErr != nil {
227
+		this.ErrorLog("时间解析失败:%v", parseErr)
228
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
229
+		return
230
+	}
231
+	fmt.Println("recordDate2222222", recordDate.Unix())
232
+	//查询今日所有设备使用登记
233
+	information, err := service.GetDeviceInfomation(orgid, recordDate.Unix())
234
+	if err != nil {
235
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
236
+		return
237
+	}
238
+	this.ServeSuccessJSON(map[string]interface{}{
239
+		"information": information,
240
+	})
241
+}

+ 11 - 0
controllers/new_mobile_api_controllers/new_manage_api_router.go View File

@@ -0,0 +1,11 @@
1
+package new_mobile_api_controllers
2
+
3
+import "github.com/astaxie/beego"
4
+
5
+func NewManageApiControllersRegisterRouters() {
6
+
7
+	beego.Router("m/api/getequitautoinfo", &NewManageApiController{}, "Get:GetEquitAutoInfo")
8
+	beego.Router("m/api/getdisinfection", &NewManageApiController{}, "Get:GetDisInfectionTime")
9
+	beego.Router("/m/api/savedisinfectioninfo", &NewManageApiController{}, "Get:SaveDisInfectionInfo")
10
+	beego.Router("/m/api/getdeviceinformation", &NewManageApiController{}, "Get:GetDeviceInformation")
11
+}

+ 13 - 0
controllers/new_mobile_api_controllers/new_mobile_api_base_controller.go View File

@@ -0,0 +1,13 @@
1
+package new_mobile_api_controllers
2
+
3
+import (
4
+	"Xcx_New/controllers/mobile_api_controllers"
5
+)
6
+
7
+type NewMobileBaseAPIAuthController struct {
8
+	mobile_api_controllers.MobileBaseAPIAuthController
9
+}
10
+
11
+func (this *NewMobileBaseAPIAuthController) Prepare() {
12
+	this.MobileBaseAPIAuthController.Prepare()
13
+}

+ 181 - 0
controllers/new_mobile_api_controllers/new_mobile_api_router_register.go View File

@@ -0,0 +1,181 @@
1
+package new_mobile_api_controllers
2
+
3
+import "github.com/astaxie/beego"
4
+
5
+// 平板端路由,以 /m/api 为前缀
6
+func NewMobileAPIControllersRegisterRouters() {
7
+
8
+	beego.Router("m/api/patient/getillnesslist", &NewDialysisApiController{}, "Get:GetIllnesslist")
9
+	beego.Router("/m/api/patients/generatedialysisnotwo", &NewDialysisApiController{}, "Get:GetGeneratedialysisno")
10
+	beego.Router("/m/api/patient/getbloodDialysisPatient", &NewDialysisApiController{}, "Get:GetPatient")
11
+
12
+	beego.Router("/m/api/islogin", &NewLoginApiController{}, "Get:GetLogin")
13
+
14
+	//验证码相关
15
+	beego.Router("/m/api/code", &NewLoginApiController{}, "Get:GetCodeInit")
16
+	beego.Router("/m/api/getcode", &NewLoginApiController{}, "Get:GetCode")
17
+
18
+	//免密码登录
19
+	beego.Router("/m/api/login/cs", &NewLoginApiController{}, "post:LoginByCs")
20
+
21
+	//忘记密码
22
+	beego.Router("/m/api/password/commit", &ForgetPwdController{}, "post:ModifyPassword")
23
+
24
+	//注册
25
+	beego.Router("/m/api/register/commit", &MobileRegistController{}, "post:RegistSubmit")
26
+	beego.Router("/m/api/register/setname", &MobileRegistController{}, "post:ModifyName")
27
+
28
+	beego.Router("/m/api/register/login", &MobileRegistController{}, "post:Login")
29
+
30
+	beego.Router("/m/api/org/create", &MobileRegistController{}, "post:CreateOrg")
31
+
32
+	beego.Router("/m/api/home", &HomeController{}, "get:GetHomeData")
33
+	beego.Router("/m/api/changeorg", &HomeController{}, "post:ChangeOrg")
34
+	beego.Router("/m/api/createOrg", &HomeController{}, "post:CreateOrg")
35
+
36
+	beego.Router("/m/api/modifypsw", &HomeController{}, "post:ModifyPsw")
37
+
38
+	beego.Router("/m/api/staff", &NewRoleApiController{}, "get:GetAllOrgUser")
39
+
40
+	beego.Router("/m/api/staff/edit", &NewRoleApiController{}, "post:EditAdmin")
41
+	beego.Router("/m/api/staff/init", &NewRoleApiController{}, "get:GetEditAdminInitData")
42
+	beego.Router("/m/api/staff/get", &NewRoleApiController{}, "get:GetAdminUserInfo")
43
+	beego.Router("/m/api/staff/stop", &NewRoleApiController{}, "post:StopAdminUser")
44
+	beego.Router("/m/api/staff/create", &NewRoleApiController{}, "post:CreateAdminUser")
45
+
46
+	beego.Router("/m/api/role/addStaff", &NewRoleApiController{}, "post:AddRoleStaff")
47
+
48
+	beego.Router("/m/api/role", &NewRoleApiController{}, "get:GetAllOrgRole")
49
+	beego.Router("/m/api/role/edit", &NewRoleApiController{}, "post:EditRole")
50
+	beego.Router("/m/api/role/get", &NewRoleApiController{}, "get:GetOrgRoleInfo")
51
+	beego.Router("/m/api/role/del", &NewRoleApiController{}, "post:DeleteOrgRole")
52
+	beego.Router("/m/api/role/create", &NewRoleApiController{}, "post:CreateRole")
53
+
54
+	beego.Router("/m/api/permission/post", &NewRoleApiController{}, "post:EditRolePermission")
55
+	beego.Router("/m/api/functionpermission/post", &NewRoleApiController{}, "post:EditFunctionPermission")
56
+
57
+	beego.Router("/m/api/permission", &NewRoleApiController{}, "get:GetAllPermission")
58
+
59
+	beego.Router("/m/api/newpermission", &NewRoleApiController{}, "get:GetAllNewPermission")
60
+
61
+	beego.Router("/m/api/rolepurview", &NewRoleApiController{}, "get:GetRolePurviews")
62
+	beego.Router("/m/api/role/funtionpurview", &NewRoleApiController{}, "get:GetFuntionPurviews")
63
+
64
+	beego.Router("/m/api/func_role/get", &NewRoleApiController{}, "get:GetFuncRolePurviews")
65
+
66
+	beego.Router("/m/api/permission/get", &HomeController{}, "get:GetFuncPermission")
67
+
68
+	beego.Router("/m/api/patient/getbloodpatientinfo", &NewDialysisApiController{}, "Get:GetBloodPatientInfo")
69
+	beego.Router("/m/api/patient/getslowpatientinfo", &NewDialysisApiController{}, "Get:GetSlowPatientInfo")
70
+	beego.Router("/m/api/patient/getmemberpatientinfo", &NewDialysisApiController{}, "Get:GetMemberpatientInfo")
71
+	beego.Router("/m/api/patient/savepatient", &NewDialysisApiController{}, "Post:SavePatient")
72
+	beego.Router("/m/api/patient/getpatientdetail", &NewDialysisApiController{}, "Get:GetPatientDetail")
73
+	beego.Router("/m/api/patient/getdoctoradvices", &NewDialysisApiController{}, "Get:GetDoctorAdvices")
74
+	beego.Router("/m/api/paitent/getdryweight", &NewDialysisApiController{}, "Get:GetDryWeight")
75
+	beego.Router("m/api/patient/getbloodDialysisPatientwo", &NewDialysisApiController{}, "Get:GetAllPatient")
76
+	beego.Router("m/api/patient/tosearch", &NewDialysisApiController{}, "Get:ToSearch")
77
+	beego.Router("/m/api/patient/getcoursemanagement", &NewDialysisApiController{}, "Get:GetCourseManagement")
78
+	beego.Router("/m/api/patient/delelecousemanage", &NewDialysisApiController{}, "Delete:DeleteCourseManagement")
79
+	beego.Router("/m/api/patient/getcousemanagementdetail", &NewDialysisApiController{}, "Get:GetCouseManagentDetail")
80
+	beego.Router("/m/api/patient/getallblooddialysispatient", &NewDialysisApiController{}, "Get:GetAllBloodDialysisPatient")
81
+	beego.Router("/m/api/patient/getallslowpatient", &NewDialysisApiController{}, "Get:GetAllSlowPatent")
82
+	beego.Router("/m/api/patient/getallmemberpatient", &NewDialysisApiController{}, "Get:GetAllMemberPatient")
83
+	beego.Router("/m/api/patient/deletedryweight", &NewDialysisApiController{}, "Delete:DeleteDryWeight")
84
+	beego.Router("/m/api/patient/getdryweightdetail", &NewDialysisApiController{}, "Get:GetDryWeightDetail")
85
+	beego.Router("/m/api/patient/getlongdialysisrecord", &NewDialysisApiController{}, "Get:GetlongDialysisrecord")
86
+	beego.Router("/m/api/patient/getrescuerecord", &NewDialysisApiController{}, "Get:GetRescuerecord")
87
+	beego.Router("/m/api/patient/getscheduling", &NewDialysisApiController{}, "Get:GetScheduling")
88
+	beego.Router("/m/api/patient/geteducation", &NewDialysisApiController{}, "Get:GetEducation")
89
+	beego.Router("/m/api/patient/getschedulingdetail", &NewDialysisApiController{}, "Get:GetSchedulingDetail")
90
+	beego.Router("/m/api/patient/deletescheduling", &NewDialysisApiController{}, "Delete:DeleteScheduling")
91
+	beego.Router("/m/api/patient/geteducationdetail", &NewDialysisApiController{}, "Get:GetEducationDetail")
92
+	beego.Router("/m/api/patient/deleteeductionone", &NewDialysisApiController{}, "Delete:DeleteEducation")
93
+	beego.Router("/m/api/patient/getrescuerecorddetail", &NewDialysisApiController{}, "GET:GetRescueRecordDetail")
94
+	beego.Router("/m/api/patient/deleterescuerecord", &NewDialysisApiController{}, "Delete:DeleteRescueRecord")
95
+	beego.Router("/m/api/patient/tosearchepatient", &NewDialysisApiController{}, "Get:ToSearchePatient")
96
+	beego.Router("/m/api/patient/searchallpatient", &NewDialysisApiController{}, "Get:SearchallPatient")
97
+	beego.Router("/m/api/patient/searchallblood", &NewDialysisApiController{}, "Get:GetSearchallBlood")
98
+	beego.Router("/m/api/patient/getslowsearchepatient", &NewDialysisApiController{}, "Get:GetSlowSearchePatient")
99
+	beego.Router("/m/api/patient/getmembersearchpatient", &NewDialysisApiController{}, "Get:GetMemberSearchPatent")
100
+	beego.Router("/m/api/patient/getlongdialysisdetail", &NewDialysisApiController{}, "Get:GetLongDialysisDetail")
101
+	beego.Router("/m/api/patient/deletelongdialysis", &NewDialysisApiController{}, "Delete:DeleteLongDialysis")
102
+	beego.Router("/m/api/patient/getdialysisrecord", &NewDialysisApiController{}, "Get:GetDialysisrecord")
103
+	beego.Router("/m/api/patient/getdoctoradvicedetail", &NewDialysisApiController{}, "Get:GetDoctorAdviceDetail")
104
+	beego.Router("/m/api/patient/deletemanagement", &NewDialysisApiController{}, "Delete:DeleteManagement")
105
+	beego.Router("/m/api/patient/updatedpatient", &NewDialysisApiController{}, "Post:UpdatedPatient")
106
+	beego.Router("/m/api/patient/getalldoctor", &NewDialysisApiController{}, "Get:GetAllDoctor")
107
+	beego.Router("/m/api/patient/getallprojectname", &NewDialysisApiController{}, "Get:GetAllProjectName")
108
+	beego.Router("/m/api/patient/getallinspection", &NewDialysisApiController{}, "Get:GetAllInspection")
109
+	beego.Router("/m/api/patient/getinspection", &NewDialysisApiController{}, "Get:GetInspection")
110
+	beego.Router("/m/api/patient/getmyinformation", &NewDialysisApiController{}, "Get:GetMyInformation")
111
+	beego.Router("/m/api/patient/getmyinformationThree", &NewDialysisApiController{}, "Get:GetMyInformationThree")
112
+	beego.Router("/m/api/patient/getpatientname", &NewDialysisApiController{}, "Get:GetPatientName")
113
+	beego.Router("/m/api/patient/getinspectiondetail", &NewDialysisApiController{}, "Get:GetInspectionDetail")
114
+	beego.Router("/m/api/patient/savefeed", &NewDialysisApiController{}, "Get:SaveFeed")
115
+	beego.Router("/m/api/patient/deletechild", &NewDialysisApiController{}, "Delete:DeleteChild")
116
+	beego.Router("/m/api/patient/deletePatient", &NewDialysisApiController{}, "Delete:DeletePatient")
117
+	beego.Router("/m/api/patient/deleteinspection", &NewDialysisApiController{}, "Delete:DeleteInspection")
118
+	beego.Router("/m/api/patient/deletechildinspection", &NewDialysisApiController{}, "Delete:DeleteChildInspection")
119
+	beego.Router("/m/api/patient/savemessage", &NewDialysisApiController{}, "Get:SaveMessage")
120
+	beego.Router("/m/api/patient/savesex", &NewDialysisApiController{}, "Get:SaveSex")
121
+	beego.Router("/m/api/patient/savebirthday", &NewDialysisApiController{}, "Post:SaveBirthday")
122
+	beego.Router("/m/api/patient/getorgname", &NewDialysisApiController{}, "Get:GetOrgName")
123
+	beego.Router("/m/api/patient/getrolename", &NewDialysisApiController{}, "Get:GetRoleName")
124
+	beego.Router("/m/api/patient/savepartition", &NewDialysisApiController{}, "Get:SavePartition")
125
+	beego.Router("/m/api/patient/getallzone", &NewDialysisApiController{}, "Get:GetAllZone")
126
+	beego.Router("/m/api/patient/deletezone", &NewDialysisApiController{}, "Delete:DeleteZone")
127
+	beego.Router("/m/api/patient/savegroup", &NewDialysisApiController{}, "Get:SaveGroup")
128
+	beego.Router("/m/api/patient/getallgroup", &NewDialysisApiController{}, "Get:GetAllGroup")
129
+	beego.Router("/m/api/patient/deletegroup", &NewDialysisApiController{}, "Delete:DeleteGroup")
130
+	beego.Router("m/api/patient/getallgroupone", &NewDialysisApiController{}, "Get:GetAllGroupOne")
131
+	beego.Router("/m/api/patient/savebed", &NewDialysisApiController{}, "Get:SaveBed")
132
+	beego.Router("/m/api/patient/getallnumber", &NewDialysisApiController{}, "Get:GetAllNumber")
133
+	beego.Router("/m/api/patient/deletebed", &NewDialysisApiController{}, "Delete:DeleteBed")
134
+	beego.Router("/m/api/patient/loginout", &NewDialysisApiController{}, "Get:LoginOut")
135
+	beego.Router("/m/api/patient/getmemberpatient", &NewDialysisApiController{}, "Get:GetMemberPatient")
136
+	beego.Router("/m/api/patient/getslowpatient", &NewDialysisApiController{}, "Get:GetSlowPatient")
137
+	beego.Router("/m/api/patient/getbloodpatient", &NewDialysisApiController{}, "Get:GetBloodPatient")
138
+	beego.Router("/m/api/patient/savename", &NewDialysisApiController{}, "Get:SaveName")
139
+	beego.Router("/m/api/patient/getallorganization", &NewDialysisApiController{}, "Get:GetAllOrganization")
140
+	beego.Router("/m/api/patient/getmyorganazition", &NewDialysisApiController{}, "Get:GetMyOrganazition")
141
+	beego.Router("/m/api/org/getorginformation", &NewDialysisApiController{}, "Get:GetOrgInformation")
142
+	beego.Router("/m/api/patient/getallorgtype", &NewDialysisApiController{}, "Get:GetAllOrgType")
143
+	beego.Router("/m/api/patient/editorg", &NewDialysisApiController{}, "Get:EditOrg")
144
+	beego.Router("/m/api/patient/getmyinforname", &NewDialysisApiController{}, "Get:GetMyInforName")
145
+	beego.Router("/m/api/patient/getpartiondetail", &NewDialysisApiController{}, "Get:GetPartionDetail")
146
+	beego.Router("/m/api/patient/updatepartition", &NewDialysisApiController{}, "Get:UpdatePartition")
147
+	beego.Router("/m/api/patient/getgroupdetail", &NewDialysisApiController{}, "Get:GetGroupDetail")
148
+	beego.Router("/m/api/patient/updategroup", &NewDialysisApiController{}, "Get:UpdateGroup")
149
+	beego.Router("/m/api/patient/getbeddetail", &NewDialysisApiController{}, "Get:GetBedDetail")
150
+	beego.Router("/m/api/patient/updatebed", &NewDialysisApiController{}, "Get:UpdatedBed")
151
+	beego.Router("/m/api/patient/getmyorginformation", &NewDialysisApiController{}, "Get:GetMyOrgInformation")
152
+	beego.Router("/m/api/patient/savenametwo", &NewDialysisApiController{}, "Get:SaveNameTwo")
153
+	beego.Router("/m/api/patient/getcurrentorg", &NewDialysisApiController{}, "Get:GetCurrentOrg")
154
+	beego.Router("/m/api/patient/getmyinformationfour", &NewDialysisApiController{}, "Get:GetMyInformationFour")
155
+	beego.Router("/m/api/org/getMyMobile", &NewDialysisApiController{}, "Get:GetMyMobile")
156
+	beego.Router("/m/api/patient/sumitform", &NewDialysisApiController{}, "Get:SumitForm")
157
+	beego.Router("/m/api/patient/getroleposition", &NewDialysisApiController{}, "Get:GetRolePosition")
158
+	beego.Router("/m/api/patient/getmobile", &NewDialysisApiController{}, "Get:GetMobile")
159
+	beego.Router("/m/api/patient/getorgs", &NewDialysisApiController{}, "Get:GetOrgs")
160
+	beego.Router("/m/api/patient/getnewpatientid", &NewDialysisApiController{}, "Get:GetNewPatientId")
161
+	beego.Router("/m/api/patient/updateimage", &NewDialysisApiController{}, "Get:UpdateImage")
162
+	beego.Router("/m/api/patient/deletemanagementtwo", &NewDialysisApiController{}, "Delete:DeleteManageMentTwo")
163
+	beego.Router("/m/api/patient/savecouresemanagement", &NewDialysisApiController{}, "Get:SaveCourseManageMent")
164
+	beego.Router("/m/api/patient/savecoursemanagementtwo", &NewDialysisApiController{}, "Get:SaveCourseManageMentTwo")
165
+	beego.Router("/m/api/patient/getvascularaccess", &NewDialysisApiController{}, "Get:GetVascularAccess")
166
+	beego.Router("/m/api/patient/getvascularaccessdetail", &NewDialysisApiController{}, "Get:GetVascularAccessDetail")
167
+	beego.Router("/m/api/patient/getalldoctorlist", &NewDialysisApiController{}, "Get:GetAllDoctorList")
168
+	beego.Router("/m/api/patient/gettreatesummay", &NewDialysisApiController{}, "Get:GetTreateSummary")
169
+
170
+	//His相关
171
+	beego.Router("/m/api/hispatientlist/get", &MobileHisApiController{}, "Get:GetHisPatientList")
172
+	beego.Router("/m/api/prescriptionconfig/get", &MobileHisApiController{}, "Get:GetHisPrescriptionConfig")
173
+	beego.Router("/m/api/prescriptioninfo/get", &MobileHisApiController{}, "Get:GetHisPatientInfo")
174
+	beego.Router("/m/api/prescription/call", &MobileHisApiController{}, "Get:GetCallHisPrescription")
175
+	beego.Router("/m/api/lastornextprescription/get", &MobileHisApiController{}, "Get:GetLastOrNextHisPrescription")
176
+	beego.Router("/m/api/prescription/delete", &MobileHisApiController{}, "Post:DeletePrescription")
177
+	beego.Router("/m/api/hisdoctoradvice/delete", &MobileHisApiController{}, "Post:DeleteDoctorAdvice")
178
+	beego.Router("/m/api/hisproject/delete", &MobileHisApiController{}, "Post:DeleteProject")
179
+	beego.Router("/m/api/prescription/create", &MobileHisApiController{}, "Post:CreateHisPrescription")
180
+
181
+}

+ 747 - 0
controllers/new_mobile_api_controllers/new_role_api_controller.go View File

@@ -0,0 +1,747 @@
1
+package new_mobile_api_controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/models"
6
+	"Xcx_New/service"
7
+	"fmt"
8
+	"strconv"
9
+	"strings"
10
+	"time"
11
+)
12
+
13
+type NewRoleApiController struct {
14
+	NewMobileBaseAPIAuthController
15
+}
16
+
17
+func (this *NewRoleApiController) GetAllOrgUser() {
18
+	adminUserInfo := this.GetMobileAdminUserInfo()
19
+	var isSubSuperAdmin bool = false
20
+	app_role, _ := service.GetAppRoleById(adminUserInfo.AppRole.Id)
21
+	role_ids := strings.Split(app_role.RoleIds, ",")
22
+
23
+	if len(role_ids) > 0 {
24
+		if adminUserInfo.AdminUser.Id != adminUserInfo.Org.Creator {
25
+			for _, item := range role_ids {
26
+				id, _ := strconv.ParseInt(item, 10, 64)
27
+				if id != 0 {
28
+					role, _ := service.GetRoleByRoleID(id)
29
+					if role != nil {
30
+						if role.IsSystem == 1 && role.RoleName == "子管理员" {
31
+							isSubSuperAdmin = true
32
+						}
33
+					}
34
+				}
35
+
36
+			}
37
+		}
38
+	}
39
+	viewModels, _, _ := service.GetAllAdminUsersAndRole(adminUserInfo.Org.Id, adminUserInfo.App.Id, 1, 100)
40
+	this.ServeSuccessJSON(map[string]interface{}{
41
+		"admins":          viewModels,
42
+		"isSubSuperAdmin": isSubSuperAdmin,
43
+		"org_creator":     adminUserInfo.Org.Creator,
44
+	})
45
+}
46
+
47
+func (this *NewRoleApiController) EditAdmin() {
48
+	adminUserInfo := this.GetMobileAdminUserInfo()
49
+	adminUserId, _ := this.GetInt64("uid")
50
+	name := this.GetString("name")
51
+	userTitle := this.GetString("title")
52
+	roleIds := this.GetString("role_ids")
53
+	user_type, _ := this.GetInt64("user_type", 0)
54
+	user_title, _ := this.GetInt64("user_title", 0)
55
+
56
+	department_name := this.GetString("department_name")
57
+	department_id, _ := this.GetInt64("department_id", 0)
58
+
59
+	//roleIds := this.GetString("role_ids")
60
+
61
+	if adminUserId <= 0 || len(name) == 0 || len(roleIds) <= 0 {
62
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
63
+		return
64
+	}
65
+	appRole, getAppRoleErr := service.GetAppRole(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserId)
66
+	if getAppRoleErr != nil {
67
+		//beego.Error("查询管理员信息时失败:", getAppRoleErr)
68
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
69
+		return
70
+	}
71
+	if appRole == nil {
72
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserNotExist)
73
+		return
74
+	}
75
+	appRole.UserName = name
76
+	appRole.UserTitleName = userTitle
77
+	appRole.RoleIds = roleIds
78
+	appRole.ModifyTime = time.Now().Unix()
79
+	appRole.UserType = int8(user_type)
80
+	appRole.UserTitle = int8(user_title)
81
+	appRole.Department = department_name
82
+	appRole.DepartmentId = department_id
83
+	saveErr := service.SaveAppRole(appRole)
84
+
85
+	if saveErr != nil {
86
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
87
+	} else {
88
+		this.ServeSuccessJSON(nil)
89
+	}
90
+}
91
+
92
+func (this *NewRoleApiController) GetEditAdminInitData() {
93
+	adminUserInfo := this.GetMobileAdminUserInfo()
94
+
95
+	roles, _ := service.GetNewAllOrgValidRoles(adminUserInfo.Org.Id)
96
+	this.ServeSuccessJSON(map[string]interface{}{
97
+		"roles": roles,
98
+	})
99
+}
100
+
101
+func (this *NewRoleApiController) GetAdminUserInfo() {
102
+	adminUserInfo := this.GetMobileAdminUserInfo()
103
+	adminUserId, _ := this.GetInt64("uid")
104
+	var isSubSuperAdmin bool = false
105
+	app_role, _ := service.GetAppRoleById(adminUserInfo.AppRole.Id)
106
+	role_ids := strings.Split(app_role.RoleIds, ",")
107
+	if len(role_ids) > 0 {
108
+		if adminUserInfo.AdminUser.Id != adminUserInfo.Org.Creator {
109
+			for _, item := range role_ids {
110
+				id, _ := strconv.ParseInt(item, 10, 64)
111
+				if id != 0 {
112
+					role, _ := service.GetRoleByRoleID(id)
113
+					if role != nil {
114
+
115
+						if role.IsSystem == 1 && role.RoleName == "子管理员" {
116
+							isSubSuperAdmin = true
117
+						}
118
+					}
119
+				}
120
+			}
121
+		}
122
+	}
123
+
124
+	appRole, getAppRoleErr := service.GetAppRole(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserId)
125
+	if getAppRoleErr != nil {
126
+		//beego.Error("查询管理员信息时失败:", getAppRoleErr)
127
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
128
+		return
129
+	}
130
+	if appRole == nil {
131
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserNotExist)
132
+		return
133
+	}
134
+
135
+	this.ServeSuccessJSON(map[string]interface{}{
136
+		"user_info":       appRole,
137
+		"isSubSuperAdmin": isSubSuperAdmin,
138
+	})
139
+
140
+}
141
+
142
+func (this *NewRoleApiController) StopAdminUser() {
143
+	adminUserInfo := this.GetMobileAdminUserInfo()
144
+	adminUserId, _ := this.GetInt64("uid")
145
+	appRole, getAppRoleErr := service.GetAppRole(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserId)
146
+	if getAppRoleErr != nil {
147
+		//beego.Error("查询管理员信息时失败:", getAppRoleErr)
148
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
149
+		return
150
+	}
151
+	if appRole == nil {
152
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserNotExist)
153
+		return
154
+	}
155
+
156
+	enable, _ := this.GetBool("enable")
157
+
158
+	if enable {
159
+		appRole.Status = 1
160
+	} else {
161
+		appRole.Status = 0
162
+	}
163
+	appRole.ModifyTime = time.Now().Unix()
164
+	saveErr := service.SaveAppRole(appRole)
165
+	if saveErr != nil {
166
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
167
+	} else {
168
+		this.ServeSuccessJSON(nil)
169
+	}
170
+
171
+}
172
+
173
+func (this *NewRoleApiController) CreateAdminUser() {
174
+	adminUserInfo := this.GetMobileAdminUserInfo()
175
+	mobile := this.GetString("mobile")
176
+	name := this.GetString("name")
177
+	role_ids := this.GetString("role_ids")
178
+	userTitle := this.GetString("title")
179
+	department_name := this.GetString("department_name")
180
+	department_id, _ := this.GetInt64("department_id")
181
+
182
+	user_type, _ := this.GetInt("user_type", 0)
183
+	user_title, _ := this.GetInt("user_title", 0)
184
+	if len(mobile) == 0 || len(name) == 0 || len(role_ids) <= 0 {
185
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
186
+		return
187
+	}
188
+
189
+	// 判断是否已存在该手机号
190
+	if adminUser, err := service.GetValidAdminUserByMobileReturnErr(mobile); err != nil {
191
+		//beego.Error("查询用户是否已被添加为管理员时失败:", err)
192
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
193
+		return
194
+	} else {
195
+		if adminUser == nil { //新增账号和用户
196
+
197
+			_, password, createErr := service.CreateGeneralAdminUser(adminUserInfo.Org.Id, adminUserInfo.App.Id, mobile, name, userTitle, role_ids, user_type, user_title, department_id, department_name)
198
+			if createErr != nil {
199
+				//beego.Error("创建管理员失败:", createErr)
200
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
201
+				return
202
+
203
+			} else {
204
+				sendSMSErr := service.SMSSendInviteMobileToJoinOrgAdmin(name, mobile, password)
205
+				if sendSMSErr != nil {
206
+				}
207
+
208
+				this.ServeSuccessJSON(nil)
209
+				return
210
+			}
211
+		} else {
212
+
213
+			total, _ := service.FindAdminUserByID(adminUser.Id, adminUserInfo.Org.Id)
214
+
215
+			if total <= 0 {
216
+				//新增用户
217
+				app_role := &models.App_Role{
218
+					AdminUserId:   adminUser.Id,
219
+					OrgId:         adminUserInfo.Org.Id,
220
+					AppId:         adminUserInfo.App.Id,
221
+					Avatar:        "",
222
+					UserName:      name,
223
+					UserTitleName: userTitle,
224
+					UserTitle:     int8(user_title),
225
+					UserType:      int8(user_type),
226
+					Status:        1,
227
+					CreateTime:    time.Now().Unix(),
228
+					ModifyTime:    time.Now().Unix(),
229
+					RoleIds:       role_ids,
230
+					IsSort:        1,
231
+				}
232
+				err := service.CreateUserRole(app_role)
233
+				if err != nil {
234
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
235
+					return
236
+				}
237
+				this.ServeSuccessJSON(nil)
238
+			} else {
239
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRepeatCreateStaffException)
240
+				return
241
+			}
242
+
243
+			return
244
+		}
245
+	}
246
+
247
+}
248
+
249
+func (this *NewRoleApiController) GetAllOrgRole() {
250
+	adminUserInfo := this.GetMobileAdminUserInfo()
251
+
252
+	var isSubSuperAdmin bool = false
253
+
254
+	app_role, _ := service.GetAppRoleById(adminUserInfo.AppRole.Id)
255
+	role_ids := strings.Split(app_role.RoleIds, ",")
256
+	if len(role_ids) > 0 {
257
+
258
+		if adminUserInfo.AdminUser.Id != adminUserInfo.Org.Creator {
259
+			for _, item := range role_ids {
260
+				id, _ := strconv.ParseInt(item, 10, 64)
261
+				if id != 0 {
262
+					role, _ := service.GetRoleByRoleID(id)
263
+					if role != nil {
264
+						if role.IsSystem == 1 && role.RoleName == "子管理员" {
265
+							isSubSuperAdmin = true
266
+						}
267
+					}
268
+				}
269
+			}
270
+		}
271
+	}
272
+	fmt.Println(isSubSuperAdmin)
273
+
274
+	roles, err := service.GetAllOrgValidRoles(adminUserInfo.Org.Id, isSubSuperAdmin)
275
+	if err != nil {
276
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
277
+		return
278
+	} else {
279
+		this.ServeSuccessJSON(map[string]interface{}{
280
+			"roles": roles,
281
+		})
282
+	}
283
+
284
+}
285
+
286
+func (this *NewRoleApiController) EditRole() {
287
+	role_id, _ := this.GetInt64("id", 0)
288
+	desc := this.GetString("desc")
289
+
290
+	role, _ := service.GetRoleByRoleID(role_id)
291
+
292
+	role.RoleIntro = desc
293
+	role.ModifyTime = time.Now().Unix()
294
+
295
+	err := service.SaveRole(role)
296
+	if err != nil {
297
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
298
+	}
299
+	this.ServeSuccessJSON(map[string]interface{}{
300
+		"role": role,
301
+	})
302
+	return
303
+}
304
+
305
+func (this *NewRoleApiController) GetOrgRoleInfo() {
306
+	role_id, _ := this.GetInt64("id", 0)
307
+	role, err := service.GetRoleByRoleID(role_id)
308
+	if err != nil {
309
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
310
+		return
311
+	} else {
312
+		this.ServeSuccessJSON(map[string]interface{}{
313
+			"role": role,
314
+		})
315
+	}
316
+
317
+}
318
+
319
+func (this *NewRoleApiController) CreateRole() {
320
+	adminUserInfo := this.GetMobileAdminUserInfo()
321
+	role_name := this.GetString("name")
322
+	role_desc := this.GetString("desc")
323
+
324
+	total := service.FindRoleRecordByRoleName(role_name, adminUserInfo.Org.Id)
325
+	if total > 0 {
326
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRoleNameIsExist)
327
+		return
328
+
329
+	}
330
+
331
+	role := &models.Role{
332
+		RoleName:     role_name,
333
+		RoleIntro:    role_desc,
334
+		Creator:      adminUserInfo.AdminUser.Id,
335
+		OrgId:        adminUserInfo.Org.Id,
336
+		AppId:        adminUserInfo.App.Id,
337
+		Status:       1,
338
+		IsSuperAdmin: false,
339
+		CreateTime:   time.Now().Unix(),
340
+		ModifyTime:   time.Now().Unix(),
341
+	}
342
+
343
+	err := service.CreateOrgRole(role)
344
+	if err != nil {
345
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
346
+		return
347
+	} else {
348
+		this.ServeSuccessJSON(map[string]interface{}{
349
+			"role": role,
350
+		})
351
+	}
352
+
353
+}
354
+
355
+func (this *NewRoleApiController) GetAllPermission() {
356
+	module, _ := this.GetInt64("module")
357
+	parent_id, _ := this.GetInt64("id")
358
+	purviews, _ := service.GetAllPurview(module, parent_id)
359
+	this.ServeSuccessJSON(map[string]interface{}{
360
+		"purviews": purviews,
361
+	})
362
+}
363
+
364
+func (this *NewRoleApiController) DeleteOrgRole() {
365
+	roleID, _ := this.GetInt64("role_id")
366
+	enable, _ := this.GetBool("enable")
367
+	if roleID <= 0 {
368
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
369
+		return
370
+	}
371
+
372
+	adminUserInfo := this.GetMobileAdminUserInfo()
373
+
374
+	role, getRoleErr := service.GetRoleByRoleID(roleID)
375
+	if getRoleErr != nil {
376
+		//beego.Error("获取角色失败:", getRoleErr)
377
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
378
+		return
379
+	} else if role == nil {
380
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRoleNotExist)
381
+		return
382
+	}
383
+
384
+	if enable == false {
385
+		if count, _ := service.RoleAdminUserCountTwo(adminUserInfo.Org.Id, adminUserInfo.App.Id, roleID); count != 0 {
386
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCannotRemoveRole)
387
+			return
388
+		}
389
+	}
390
+
391
+	if enable {
392
+		role.Status = 1
393
+	} else {
394
+		role.Status = 2
395
+	}
396
+	role.ModifyTime = time.Now().Unix()
397
+	saveErr := service.ModifyRole(role)
398
+	if saveErr != nil {
399
+		//beego.Error("修改角色失败:", role.Id, saveErr)
400
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
401
+	} else {
402
+		this.ServeSuccessJSON(nil)
403
+	}
404
+
405
+}
406
+
407
+func (this *NewRoleApiController) GetRolePurviews() {
408
+	adminUserInfo := this.GetMobileAdminUserInfo()
409
+	role_id, _ := this.GetInt64("id", 0)
410
+	rolePurview, _ := service.GetRoleAndPurviewById(role_id, adminUserInfo.Org.Id, adminUserInfo.App.Id)
411
+	funRolePurview, _ := service.GetRoleFuncPurview(role_id)
412
+
413
+	role, _ := service.GetRoleByRoleID(role_id)
414
+	this.ServeSuccessJSON(map[string]interface{}{
415
+		"role_purview": rolePurview,
416
+		"role":         role,
417
+		"func_purview": funRolePurview,
418
+	})
419
+}
420
+
421
+func (this *NewRoleApiController) AddRoleStaff() {
422
+	//adminUserInfo := this.GetMobileAdminUserInfo()
423
+	role_id, _ := this.GetInt64("id", 0)
424
+	staff_ids := this.GetString("ids")
425
+	ids := strings.Split(staff_ids, ",")
426
+	for _, item := range ids {
427
+		id, _ := strconv.ParseInt(item, 10, 64)
428
+		role, _ := service.FindAdminUserID(id)
429
+		role.RoleIds = role.RoleIds + "," + strconv.FormatInt(role_id, 10)
430
+		service.SaveAdminUser(&role)
431
+	}
432
+	this.ServeSuccessJSON(map[string]interface{}{
433
+		"msg": "添加成功",
434
+	})
435
+
436
+}
437
+
438
+func (this *NewRoleApiController) GetFuntionPurviews() {
439
+	pid, _ := this.GetInt64("pid")
440
+	functionPurview, _ := service.GetFunctionPurview(pid)
441
+	this.ServeSuccessJSON(map[string]interface{}{
442
+		"funtion_purview": functionPurview,
443
+	})
444
+}
445
+
446
+func RemoveRepeatedIDSElement(arr []string) (newArr []string) {
447
+	newArr = make([]string, 0)
448
+	for i := 0; i < len(arr); i++ {
449
+		repeat := false
450
+		for j := i + 1; j < len(arr); j++ {
451
+			if arr[i] == arr[j] {
452
+				repeat = true
453
+				break
454
+			}
455
+		}
456
+		if !repeat {
457
+			newArr = append(newArr, arr[i])
458
+		}
459
+	}
460
+	return
461
+}
462
+
463
+func (this *NewRoleApiController) EditRolePermission() {
464
+	adminUser := this.GetMobileAdminUserInfo()
465
+	role_id, _ := this.GetInt64("id", 0)
466
+	purview_id := this.GetString("purview_id")
467
+	is_open, _ := this.GetInt64("type", 0)
468
+
469
+	permissions, err := service.GetRolePurviewIds(role_id)
470
+	if err != nil {
471
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
472
+		return
473
+	} else {
474
+
475
+		if is_open == 1 { //打开
476
+			purview, _ := service.GetRolePurview(role_id)
477
+			if purview.Id == 0 { // 新建
478
+
479
+				purview.PurviewIds = purview_id
480
+				purview.CreateTime = time.Now().Unix()
481
+				purview.ModifyTime = time.Now().Unix()
482
+				purview.Status = 1
483
+				purview.RoleId = role_id
484
+				purview.OrgId = adminUser.Org.Id
485
+				purview.AppId = adminUser.App.Id
486
+				err := service.CreateRolePurview(&purview)
487
+				if err != nil {
488
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
489
+					return
490
+				}
491
+
492
+				this.ServeSuccessJSON(map[string]interface{}{
493
+					"is_open": 1,
494
+				})
495
+
496
+			} else { //修改
497
+				var permission_arr []string
498
+				purview, _ := service.GetRolePurview(role_id)
499
+				if len(permissions) > 0 {
500
+					permission_arr = strings.Split(permissions, ",")
501
+					if len(purview_id) > 0 {
502
+						permission_arr = append(permission_arr, strings.Split(purview_id, ",")...)
503
+					}
504
+				} else {
505
+					if len(purview_id) > 0 {
506
+						permission_arr = strings.Split(purview_id, ",")
507
+					}
508
+				}
509
+
510
+				permission_arr = RemoveRepeatedIDSElement(permission_arr)
511
+				permissions = strings.Join(permission_arr, ",")
512
+				purview.PurviewIds = permissions
513
+				err := service.SaveRolePurview(&purview)
514
+				if err != nil {
515
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
516
+					return
517
+				}
518
+
519
+				this.ServeSuccessJSON(map[string]interface{}{
520
+					"is_open": 1,
521
+				})
522
+
523
+			}
524
+
525
+		} else { //关闭
526
+			permission_arr := strings.Split(permissions, ",")
527
+			purview_arr := strings.Split(purview_id, ",")
528
+
529
+			for _, pur_id := range purview_arr {
530
+				for index, id := range permission_arr {
531
+					if id == pur_id {
532
+						permission_arr = append(permission_arr[:index], permission_arr[index+1:]...)
533
+					}
534
+				}
535
+			}
536
+			purview, _ := service.GetRolePurview(role_id)
537
+			fmt.Println(purview.CreateTime)
538
+			purview.PurviewIds = strings.Join(permission_arr, ",")
539
+
540
+			err := service.SaveRolePurview(&purview)
541
+			if err != nil {
542
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
543
+				return
544
+			}
545
+			this.ServeSuccessJSON(map[string]interface{}{
546
+				"is_open": 0,
547
+			})
548
+
549
+		}
550
+	}
551
+
552
+}
553
+
554
+func (this *NewRoleApiController) EditFunctionPermission() {
555
+	adminUser := this.GetMobileAdminUserInfo()
556
+	role_id, _ := this.GetInt64("id", 0)
557
+	purview_id := this.GetString("purview_id")
558
+	is_open, _ := this.GetInt64("type", 0)
559
+	is_all, _ := this.GetInt64("is_all", 0)
560
+	pid := this.GetString("pid")
561
+
562
+	func_permissions, err := service.GetRoleFuncPurviewIds(role_id)
563
+	permissions, _ := service.GetRolePurviewIds(role_id)
564
+
565
+	redis := service.RedisClient()
566
+	defer redis.Close()
567
+
568
+	users := service.GetAllUserRole(adminUser.Org.Id)
569
+	for _, item := range users {
570
+		key := "purviews_" + strconv.FormatInt(adminUser.Org.Id, 10) + strconv.FormatInt(item.AdminUserId, 10)
571
+		redis.Set(key, "", time.Second)
572
+	}
573
+
574
+	if err != nil {
575
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
576
+		return
577
+	} else {
578
+
579
+		if is_open == 1 { //打开
580
+			//处理功能权限涉及到的菜单权限
581
+
582
+			purview, _ := service.GetRolePurview(role_id)
583
+			if purview.Id == 0 { // 新建
584
+				purview.PurviewIds = pid
585
+				purview.CreateTime = time.Now().Unix()
586
+				purview.ModifyTime = time.Now().Unix()
587
+				purview.Status = 1
588
+				purview.RoleId = role_id
589
+				purview.OrgId = adminUser.Org.Id
590
+				purview.AppId = adminUser.App.Id
591
+				service.CreateRolePurview(&purview)
592
+
593
+			} else { //修改
594
+				var permission_arr []string
595
+				purview, _ := service.GetRolePurview(role_id)
596
+				if len(permissions) > 0 {
597
+					permission_arr = strings.Split(permissions, ",")
598
+					if len(pid) > 0 {
599
+						permission_arr = append(permission_arr, strings.Split(pid, ",")...)
600
+					}
601
+				} else {
602
+					if len(pid) > 0 {
603
+						permission_arr = strings.Split(pid, ",")
604
+					}
605
+				}
606
+				permission_arr = RemoveRepeatedIDSElement(permission_arr)
607
+				permissions = strings.Join(permission_arr, ",")
608
+				purview.PurviewIds = permissions
609
+				service.SaveRolePurview(&purview)
610
+			}
611
+
612
+			func_purview, _ := service.GetFuncRolePurview(role_id)
613
+			if func_purview.ID == 0 { // 新建
614
+
615
+				func_purview.PurviewIds = purview_id
616
+				func_purview.Ctime = time.Now().Unix()
617
+				func_purview.Mtime = time.Now().Unix()
618
+				func_purview.Status = 1
619
+				func_purview.RoleId = role_id
620
+				func_purview.OrgId = adminUser.Org.Id
621
+				func_purview.AppId = adminUser.App.Id
622
+				err := service.CreateFuncRolePurview(&func_purview)
623
+				if err != nil {
624
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
625
+					return
626
+				}
627
+
628
+				this.ServeSuccessJSON(map[string]interface{}{
629
+					"is_open": 1,
630
+				})
631
+			} else { //修改
632
+				var permission_arr []string
633
+				func_purview, _ := service.GetRoleFuncPurview(role_id)
634
+				if len(func_permissions) > 0 {
635
+					permission_arr = strings.Split(func_permissions, ",")
636
+					if len(purview_id) > 0 {
637
+						permission_arr = append(permission_arr, strings.Split(purview_id, ",")...)
638
+					}
639
+				} else {
640
+					if len(purview_id) > 0 {
641
+						permission_arr = strings.Split(purview_id, ",")
642
+					}
643
+				}
644
+				permission_arr = RemoveRepeatedIDSElement(permission_arr)
645
+				func_permissions = strings.Join(permission_arr, ",")
646
+				func_purview.PurviewIds = func_permissions
647
+
648
+				err := service.SaveRoleFuncPurview(&func_purview)
649
+				if err != nil {
650
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
651
+					return
652
+				}
653
+				this.ServeSuccessJSON(map[string]interface{}{
654
+					"is_open": 1,
655
+				})
656
+			}
657
+		} else { //关闭
658
+
659
+			//处理功能权限涉及到的菜单权限,当关闭到只剩下一个的时候,在将菜单权限对应的权限id清除
660
+			func_permission_arr := strings.Split(func_permissions, ",")
661
+			if len(func_permission_arr) == 1 {
662
+				permission_arr := strings.Split(permissions, ",")
663
+				pid_arr := strings.Split(pid, ",")
664
+				for _, pur_id := range pid_arr {
665
+					for index, id := range permission_arr {
666
+						if id == pur_id {
667
+							permission_arr = append(permission_arr[:index], permission_arr[index+1:]...)
668
+						}
669
+					}
670
+				}
671
+				purview, _ := service.GetRolePurview(role_id)
672
+				purview.PurviewIds = strings.Join(permission_arr, ",")
673
+				service.SaveRolePurview(&purview)
674
+			}
675
+
676
+			if is_all == 1 {
677
+
678
+				permission_arr := strings.Split(permissions, ",")
679
+				pid_arr := strings.Split(pid, ",")
680
+				for _, pur_id := range pid_arr {
681
+					for index, id := range permission_arr {
682
+						if id == pur_id {
683
+							permission_arr = append(permission_arr[:index], permission_arr[index+1:]...)
684
+						}
685
+					}
686
+				}
687
+				purview, _ := service.GetRolePurview(role_id)
688
+				purview.PurviewIds = strings.Join(permission_arr, ",")
689
+				service.SaveRolePurview(&purview)
690
+
691
+				func_purview, _ := service.GetRoleFuncPurview(role_id)
692
+				func_purview.PurviewIds = ""
693
+				err := service.SaveRoleFuncPurview(&func_purview)
694
+				if err != nil {
695
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
696
+					return
697
+				}
698
+				this.ServeSuccessJSON(map[string]interface{}{
699
+					"is_open": 0,
700
+				})
701
+
702
+			} else {
703
+				permission_arr := strings.Split(func_permissions, ",")
704
+				purview_arr := strings.Split(purview_id, ",")
705
+				fmt.Println(permission_arr)
706
+				fmt.Println(purview_arr)
707
+				for index, id := range permission_arr {
708
+					for _, pur_id := range purview_arr {
709
+						if id == pur_id {
710
+							permission_arr = append(permission_arr[:index], permission_arr[index+1:]...)
711
+						}
712
+					}
713
+				}
714
+				func_purview, _ := service.GetRoleFuncPurview(role_id)
715
+				func_purview.PurviewIds = strings.Join(permission_arr, ",")
716
+
717
+				err := service.SaveRoleFuncPurview(&func_purview)
718
+				if err != nil {
719
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
720
+					return
721
+				}
722
+				this.ServeSuccessJSON(map[string]interface{}{
723
+					"is_open": 0,
724
+				})
725
+			}
726
+
727
+		}
728
+	}
729
+
730
+}
731
+
732
+func (this *NewRoleApiController) GetFuncRolePurviews() {
733
+	//adminUserInfo := this.GetMobileAdminUserInfo()
734
+	role_id, _ := this.GetInt64("id", 0)
735
+	purview, _ := service.GetRoleFuncPurview(role_id)
736
+	this.ServeSuccessJSON(map[string]interface{}{
737
+		"role_purview": purview,
738
+	})
739
+}
740
+
741
+func (this *NewRoleApiController) GetAllNewPermission() {
742
+	url := this.GetString("url")
743
+	purviews, _ := service.GetNewAllPurview(url)
744
+	this.ServeSuccessJSON(map[string]interface{}{
745
+		"purviews": purviews,
746
+	})
747
+}

+ 50 - 0
controllers/new_mobile_api_controllers/new_self_drug_api_controller.go View File

@@ -0,0 +1,50 @@
1
+package new_mobile_api_controllers
2
+
3
+import (
4
+	"Xcx_New/controllers/mobile_api_controllers"
5
+	"Xcx_New/enums"
6
+	"Xcx_New/service"
7
+	"fmt"
8
+)
9
+
10
+type NewDrugApiController struct {
11
+	mobile_api_controllers.MobileBaseAPIAuthController
12
+}
13
+
14
+func (this *NewDrugApiController) GetSelfMedicalList() {
15
+
16
+	patient_id, _ := this.GetInt64("patient_id")
17
+	fmt.Println("222222222", patient_id)
18
+	adminUserInfo := this.GetMobileAdminUserInfo()
19
+	orgId := adminUserInfo.Org.Id
20
+	medical, _ := service.GetSetSelfMedical(orgId)
21
+	//开启
22
+	if medical.DrugStart == 1 {
23
+		list, err := service.GetSelfMedicalList(patient_id)
24
+		if err != nil {
25
+			this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取自备药失败")
26
+			return
27
+		}
28
+		this.ServeSuccessJSON(map[string]interface{}{
29
+			"medicalList": list,
30
+		})
31
+	}
32
+}
33
+
34
+func (this *NewDrugApiController) GetDrugDescByDrugName() {
35
+
36
+	drug_name := this.GetString("drug_name")
37
+	fmt.Println("drug_name", drug_name)
38
+	patient_id, _ := this.GetInt64("patient_id")
39
+	fmt.Println("patient_id", patient_id)
40
+	adminUserInfo := this.GetMobileAdminUserInfo()
41
+	orgId := adminUserInfo.Org.Id
42
+	drugspec, err := service.GetDrugDescByDrugName(drug_name, patient_id, orgId)
43
+	if err != nil {
44
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
45
+		return
46
+	}
47
+	this.ServeSuccessJSON(map[string]interface{}{
48
+		"drugspec": drugspec,
49
+	})
50
+}

+ 170 - 0
controllers/new_mobile_api_controllers/patient.json View File

@@ -0,0 +1,170 @@
1
+{
2
+  "patients": [
3
+    {
4
+      "avatar": "https://images.shengws.com/201809182128111.png",
5
+      "patient_type": 1,
6
+      "dialysis_no": "001",
7
+      "admission_number": "",
8
+      "source": 1,
9
+      "lapseto": 1,
10
+      "partition_id": 0,
11
+      "bed_id": 0,
12
+      "name": "演示患者一",
13
+      "alias": "",
14
+      "gender": 1,
15
+      "nation": "汉",
16
+      "native_place": "广东深圳",
17
+      "marital_status": 1,
18
+      "id_card_no": "999999190001019999",
19
+      "birthday": -312537600,
20
+      "reimbursement_way_id": 7,
21
+      "health_care_type": 0,
22
+      "health_care_no": "604324517",
23
+      "health_care_due_date": 0,
24
+      "height": 158,
25
+      "blood_type": 0,
26
+      "rh": 0,
27
+      "health_care_due_alert_date": 0,
28
+      "education_level": 5,
29
+      "profession": 10,
30
+      "phone": "13800000001",
31
+      "home_telephone": "",
32
+      "relative_phone": "",
33
+      "relative_relations": "",
34
+      "home_address": "深圳市罗湖区鸿翔花园",
35
+      "work_unit": "无",
36
+      "unit_address": "无",
37
+      "children": 2,
38
+      "receiving_date": 0,
39
+      "is_hospital_first_dialysis": 1,
40
+      "first_dialysis_date": 1110816000,
41
+      "first_dialysis_hospital": "深圳市人民医院",
42
+      "predialysis_condition": "",
43
+      "pre_hospital_dialysis_frequency": "每周3次",
44
+      "pre_hospital_dialysis_times": 1820,
45
+      "hospital_first_dialysis_date": 1511366400,
46
+      "induction_period": 0,
47
+      "initial_dialysis": 0,
48
+      "total_dialysis": 0,
49
+      "attending_doctor_id": 0,
50
+      "head_nurse_id": 0,
51
+      "evaluate": "",
52
+      "diagnose": "慢病肾功能不全(尿毒症期)",
53
+      "remark": "慢病肾功能不全(尿毒症期)肾性贫血,肾性高血压,多囊肾,多囊肝,支气管炎;",
54
+      "registrars_id": 185,
55
+      "registrars": "",
56
+      "qr_code": "",
57
+      "binding_state": 2,
58
+      "patient_complains": "慢病肾功能不全(尿毒症期)",
59
+      "present_history": "慢病肾功能不全(尿毒症期)肾性贫血,肾性高血压,多囊肾,多囊肝,支气管炎;",
60
+      "past_history": "慢病肾功能不全(尿毒症期)肾性贫血,肾性高血压,多囊肾,多囊肝,支气管炎;",
61
+      "temperature": 39,
62
+      "pulse": 60,
63
+      "respiratory": 100,
64
+      "sbp": 0,
65
+      "dbp": 0,
66
+      "status": 1,
67
+      "created_time": 1537347970,
68
+      "updated_time": 1584343696,
69
+      "solutions": null,
70
+      "age": 60,
71
+      "schedules": null,
72
+      "contagions": null,
73
+      "diseases": null,
74
+      "response_result": "",
75
+      "is_open_remind": 1,
76
+      "dialysis_age": 0,
77
+      "expense_kind": 3,
78
+      "tell_phone": "21212",
79
+      "first_treatment_date": 1582560000,
80
+      "contact_name": "21221",
81
+      "is_infectious":1,
82
+      "contagion_ids": ""
83
+
84
+
85
+    },
86
+    {
87
+      "avatar": "https://images.shengws.com/201809182128111.png",
88
+      "patient_type": 1,
89
+      "dialysis_no": "002",
90
+      "admission_number": "",
91
+      "source": 1,
92
+      "lapseto": 1,
93
+      "partition_id": 0,
94
+      "bed_id": 0,
95
+      "name": "演示患者二",
96
+      "alias": "",
97
+      "gender": 2,
98
+      "nation": "汉",
99
+      "native_place": "广东深圳",
100
+      "marital_status": 1,
101
+      "id_card_no": "999999190001018888",
102
+      "birthday": -312537600,
103
+      "reimbursement_way_id": 7,
104
+      "health_care_type": 0,
105
+      "health_care_no": "604324517",
106
+      "health_care_due_date": 0,
107
+      "height": 158,
108
+      "blood_type": 0,
109
+      "rh": 0,
110
+      "health_care_due_alert_date": 0,
111
+      "education_level": 5,
112
+      "profession": 10,
113
+      "phone": "13800000001",
114
+      "home_telephone": "",
115
+      "relative_phone": "",
116
+      "relative_relations": "哥哥",
117
+      "home_address": "深圳市罗湖区鸿翔花园",
118
+      "work_unit": "无",
119
+      "unit_address": "无",
120
+      "children": 2,
121
+      "receiving_date": 0,
122
+      "is_hospital_first_dialysis": 1,
123
+      "first_dialysis_date": 1110816000,
124
+      "first_dialysis_hospital": "深圳市人民医院",
125
+      "predialysis_condition": "",
126
+      "pre_hospital_dialysis_frequency": "每周3次",
127
+      "pre_hospital_dialysis_times": 1820,
128
+      "hospital_first_dialysis_date": 1511366400,
129
+      "induction_period": 0,
130
+      "initial_dialysis": 0,
131
+      "total_dialysis": 0,
132
+      "attending_doctor_id": 0,
133
+      "head_nurse_id": 0,
134
+      "evaluate": "",
135
+      "diagnose": "慢病肾功能不全(尿毒症期)",
136
+      "remark": "慢病肾功能不全(尿毒症期)肾性贫血,肾性高血压,多囊肾,多囊肝,支气管炎;",
137
+      "registrars_id": 185,
138
+      "registrars": "",
139
+      "qr_code": "",
140
+      "binding_state": 2,
141
+      "patient_complains": "慢病肾功能不全(尿毒症期)",
142
+      "present_history": "慢病肾功能不全(尿毒症期)肾性贫血,肾性高血压,多囊肾,多囊肝,支气管炎;",
143
+      "past_history": "慢病肾功能不全(尿毒症期)肾性贫血,肾性高血压,多囊肾,多囊肝,支气管炎;",
144
+      "temperature": 39,
145
+      "pulse": 60,
146
+      "respiratory": 100,
147
+      "sbp": 0,
148
+      "dbp": 0,
149
+      "status": 1,
150
+      "created_time": 1537347970,
151
+      "updated_time": 1584343696,
152
+      "solutions": null,
153
+      "age": 60,
154
+      "schedules": null,
155
+      "contagions": null,
156
+      "diseases": null,
157
+      "response_result": "",
158
+      "is_open_remind": 1,
159
+      "dialysis_age": 0,
160
+      "expense_kind": 3,
161
+      "tell_phone": "21212",
162
+      "first_treatment_date": 1582560000,
163
+      "contact_name": "21221",
164
+      "is_infectious":2,
165
+      "contagion_ids": "2"
166
+
167
+    }
168
+  ]
169
+}
170
+

+ 73 - 0
controllers/new_mobile_api_controllers/role.json View File

@@ -0,0 +1,73 @@
1
+{
2
+  "roles": [
3
+    {
4
+      "role_name": "子管理员",
5
+      "role_introduction": "子管理员角色具备平台全部功能的使用权限,请谨慎配置",
6
+      "is_super_admin": false,
7
+      "status": 1,
8
+      "is_system": 1,
9
+      "number": 9999,
10
+      "purview_ids": "71,72,70,74,75,73,48,49,52,110,49,77,78,79,80,197,76,111,112,113,114,115,116,117,118,119,129,84,93,121,122,124,125,120,127,128,201,193,194,196,192,158,157,159,160,161,162,167,166,168,169,170,171,174,173,175,178,177,179,101,100,102,83,94",
11
+      "func_ids": "20001,20002,20003,20004,20005,20006,20007,20008,20009,20010,20011,20012,20034,20035,20036,20038,20039,20055,20056,20040,20041,20042,20043,20054,20044,20045,20046,20047,20048,20049,20050,20051,20052,20053,20013,20014,20015,20016,20017,20018,20019,20020,20021,20022,20023,20024,20025,20026,20027,20028,20029,20030"
12
+    },
13
+    {
14
+      "role_name": "医生",
15
+      "role_introduction": "医生角色能够进行建立患者档案,制定和调整患者透析治疗方案,定期评价病人的透析质量等",
16
+      "is_super_admin": false,
17
+      "status": 1,
18
+      "is_system": 2,
19
+      "number": 9998,
20
+      "purview_ids": "71,72,70,74,75,73,48,52,110,77,78,79,80,197,76,93,121,122,124,125,120,127,128,193,194,196,192,101,100,102,49",
21
+      "func_ids": "20001,20002,20003,20004,20005,20006,20007,20008,20009,20010,20011,20012,20034,20035,20036,20038,20040,20041,20043,20044,20046,20047,20049,20024,20025,20026,20027,20028,20029,20030"
22
+    },
23
+    {
24
+      "role_name": "护士",
25
+      "role_introduction": "护士角色能够进行病人透析管理,以及医院的感染控制与消毒记录等",
26
+      "is_super_admin": false,
27
+      "status": 1,
28
+      "is_system": 3,
29
+      "number": 9997,
30
+      "purview_ids": "71,72,70,74,75,73,127,128,48,49,52,110,111,112,113,114,115,116,117,118,119,129,84,77,78,79,80,197,76,83,94",
31
+      "func_ids": "20007,20008,20009,20010,20011,20051,20053,20013,20014,20016,20017,20019,20021,20022,20024,20025,20026,20027,20028,20029,20055,20056,20052,20012"
32
+    },{
33
+      "role_name": "库存",
34
+      "role_introduction": "库存角色负责透析耗材的日常管理,对耗材的入库、出库、退库的登记操作",
35
+      "is_super_admin": false,
36
+      "status": 1,
37
+      "is_system": 0,
38
+      "number": 9996,
39
+      "purview_ids": "111,112,113,114,115,116,117,118,119,129,84,83,94",
40
+      "func_ids": ""
41
+    },{
42
+      "role_name": "运营",
43
+      "role_introduction": "运营角色能够在SCRM中管理微网站、使用营销工具、做会员管理和分销商品经营的操作",
44
+      "is_super_admin": false,
45
+      "status": 1,
46
+      "is_system": 0,
47
+      "number": 9995,
48
+      "purview_ids": "48,110,158,157,159,160,161,162,167,166,168,169,170,171,174,173,175,178,177,179,201",
49
+      "func_ids": ""
50
+    },{
51
+      "role_name": "技师",
52
+      "role_introduction": "技师角色能够进行设备的管理,日常维护维修记录等",
53
+      "is_super_admin": false,
54
+      "status": 1,
55
+      "is_system": 0,
56
+      "number": 9994,
57
+      "purview_ids": "77,78,79,80,197,76",
58
+      "func_ids": ""
59
+    },
60
+    {
61
+      "role_name": "院长",
62
+      "role_introduction": "院长角色了解血透患者血液透析质量和相关的大数据,以及掌握透析中心整体运营情况",
63
+      "is_super_admin": false,
64
+      "status": 1,
65
+      "is_system": 0,
66
+      "number": 9993,
67
+      "purview_ids": "71,72,70,74,75,73,48,49,52,110,111,112,113,114,115,116,117,118,119,129,84,93,121,122,124,125,120,77,78,79,80,197,76,101,100,102,127,128,158,157,159,160,161,162,167,166,168,169,170,171,174,173,175,178,177,179,201,83,94",
68
+      "func_ids": ""
69
+
70
+
71
+    }
72
+  ]
73
+}

+ 86 - 0
controllers/new_mobile_api_controllers/schedule_template.json View File

@@ -0,0 +1,86 @@
1
+{
2
+  "item": [
3
+    {
4
+      "treat_mode": 1,
5
+      "weekday": 1,
6
+      "time_type": 1
7
+    },
8
+    {
9
+      "treat_mode": 1,
10
+      "weekday": 1,
11
+      "time_type": 2
12
+    },
13
+    {
14
+
15
+      "treat_mode": 1,
16
+      "weekday": 2,
17
+      "time_type": 1
18
+    },
19
+
20
+    {
21
+
22
+      "treat_mode": 1,
23
+      "weekday": 2,
24
+      "time_type": 2
25
+    },
26
+    {
27
+
28
+      "treat_mode": 1,
29
+      "weekday": 3,
30
+      "time_type": 1
31
+    },
32
+    {
33
+
34
+      "treat_mode": 1,
35
+      "weekday": 3,
36
+      "time_type": 2
37
+    },
38
+    {
39
+
40
+      "treat_mode": 1,
41
+      "weekday": 4,
42
+      "time_type": 1
43
+    },
44
+    {
45
+
46
+      "treat_mode": 1,
47
+      "weekday": 4,
48
+      "time_type": 2
49
+    },
50
+    {
51
+
52
+      "treat_mode": 1,
53
+      "weekday": 5,
54
+      "time_type": 1
55
+    },
56
+    {
57
+
58
+      "treat_mode": 1,
59
+      "weekday": 5,
60
+      "time_type": 2
61
+    },
62
+    {
63
+
64
+      "treat_mode": 1,
65
+      "weekday": 6,
66
+      "time_type": 1
67
+    },
68
+    {
69
+
70
+      "treat_mode": 1,
71
+      "weekday": 6,
72
+      "time_type": 2
73
+    },
74
+    {
75
+
76
+      "treat_mode": 1,
77
+      "weekday": 7,
78
+      "time_type": 1
79
+    },
80
+    {
81
+      "treat_mode": 1,
82
+      "weekday": 7,
83
+      "time_type": 2
84
+    }
85
+  ]
86
+}

+ 354 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go View File

@@ -0,0 +1,354 @@
1
+package new_mobile_api_controllers
2
+
3
+import (
4
+	"Xcx_New/controllers/mobile_api_controllers"
5
+	"Xcx_New/enums"
6
+	"Xcx_New/models"
7
+	"Xcx_New/service"
8
+	"fmt"
9
+	"strings"
10
+	"time"
11
+)
12
+
13
+type StaffScheduleApiController struct {
14
+	mobile_api_controllers.MobileBaseAPIAuthController
15
+}
16
+
17
+func (this *StaffScheduleApiController) GetMobileDoctorList() {
18
+
19
+	orgId := this.GetMobileAdminUserInfo().Org.Id
20
+	appId := this.GetMobileAdminUserInfo().App.Id
21
+	staffList, err := service.GetDoctorList(orgId, appId)
22
+	//获取所有的医生
23
+	doctorList, err := service.GetAllDoctorList(orgId, appId)
24
+
25
+	//获取所有的护士
26
+	nurseList, err := service.GetAllNurseList(orgId, appId)
27
+	if err != nil {
28
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
29
+		return
30
+	}
31
+
32
+	if err != nil {
33
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
34
+		return
35
+	}
36
+
37
+	this.ServeSuccessJSON(map[string]interface{}{
38
+		"staffList":  staffList,
39
+		"doctorList": doctorList,
40
+		"nurseList":  nurseList,
41
+	})
42
+}
43
+
44
+func (this *StaffScheduleApiController) GetMobileStaffScheduleList() {
45
+
46
+	orgId := this.GetMobileAdminUserInfo().Org.Id
47
+	start_time, _ := this.GetInt64("start_time")
48
+	fmt.Println("staft_time", start_time)
49
+	end_time, _ := this.GetInt64("end_time")
50
+	staffList, err := service.GetStaffScheduleList(orgId, start_time, end_time)
51
+	if err != nil {
52
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
53
+		return
54
+	}
55
+
56
+	this.ServeSuccessJSON(map[string]interface{}{
57
+		"staffList": staffList,
58
+	})
59
+}
60
+
61
+func (this *StaffScheduleApiController) GetMobileNextWeekScheduleLIst() {
62
+
63
+	orgId := this.GetMobileAdminUserInfo().Org.Id
64
+	start_time, _ := this.GetInt64("start_time")
65
+	end_time, _ := this.GetInt64("end_time")
66
+
67
+	staffList, err := service.GetStaffScheduleList(orgId, start_time, end_time)
68
+	if err != nil {
69
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
70
+		return
71
+	}
72
+
73
+	this.ServeSuccessJSON(map[string]interface{}{
74
+		"staffList": staffList,
75
+	})
76
+}
77
+
78
+func (this *StaffScheduleApiController) GetScheduleByUserType() {
79
+	doctor_id, _ := this.GetInt64("doctor_id")
80
+	start_time, _ := this.GetInt64("start_time")
81
+	end_time, _ := this.GetInt64("end_time")
82
+	orgId := this.GetMobileAdminUserInfo().Org.Id
83
+	staffList, err := service.GetScheduleByDoctorId(doctor_id, start_time, end_time, orgId)
84
+	if err != nil {
85
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
86
+		return
87
+	}
88
+
89
+	this.ServeSuccessJSON(map[string]interface{}{
90
+		"staffList": staffList,
91
+	})
92
+}
93
+
94
+func (this *StaffScheduleApiController) GetSearchPatientByDoctorId() {
95
+
96
+	orgId := this.GetMobileAdminUserInfo().Org.Id
97
+	user_name := this.GetString("user_name")
98
+	start_time, _ := this.GetInt64("start_time")
99
+	end_time, _ := this.GetInt64("end_time")
100
+	staffList, err := service.ToSearchSeacheduleList(user_name, start_time, end_time, orgId)
101
+	if err != nil {
102
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
103
+		return
104
+	}
105
+
106
+	this.ServeSuccessJSON(map[string]interface{}{
107
+		"staffList": staffList,
108
+	})
109
+}
110
+
111
+func (this *StaffScheduleApiController) GetMobileSchedulelist() {
112
+
113
+	orgId := this.GetMobileAdminUserInfo().Org.Id
114
+	list, err := service.GetScheduleList(orgId)
115
+	if err != nil {
116
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
117
+		return
118
+	}
119
+
120
+	this.ServeSuccessJSON(map[string]interface{}{
121
+		"list": list,
122
+	})
123
+}
124
+
125
+func (this *StaffScheduleApiController) GetMobileScheduleListTotal() {
126
+
127
+	start_time, _ := this.GetInt64("start_time")
128
+	end_time, _ := this.GetInt64("end_time")
129
+	orgId := this.GetMobileAdminUserInfo().Org.Id
130
+
131
+	//统计班次
132
+	scheudletotal, err := service.GetScheduleListTotal(orgId, start_time, end_time)
133
+	//统计总工时
134
+	list, err := service.GetTotalMinutes(orgId, start_time, end_time)
135
+	//统计出勤天数
136
+	workDay, err := service.GetTotalWorkDay(orgId, start_time, end_time)
137
+	//统计缺勤天数
138
+	noWorkDay, err := service.GetTotalNoWorkDay(orgId, start_time, end_time)
139
+	if err != nil {
140
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
141
+		return
142
+	}
143
+	this.ServeSuccessJSON(map[string]interface{}{
144
+		"scheudletotal": scheudletotal,
145
+		"list":          list,
146
+		"workDay":       workDay,
147
+		"noWorkDay":     noWorkDay,
148
+	})
149
+}
150
+
151
+func (this *StaffScheduleApiController) GetMySchedule() {
152
+	start_time, _ := this.GetInt64("start_time")
153
+	end_time, _ := this.GetInt64("end_time")
154
+	orgId := this.GetMobileAdminUserInfo().Org.Id
155
+	creator, _ := this.GetInt64("creator")
156
+	schedule, err := service.GetMySchedule(start_time, end_time, orgId, creator)
157
+	if err != nil {
158
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
159
+		return
160
+	}
161
+	this.ServeSuccessJSON(map[string]interface{}{
162
+		"schedule": schedule,
163
+	})
164
+}
165
+
166
+func (this *StaffScheduleApiController) GetMobileChartList() {
167
+
168
+	start_time, _ := this.GetInt64("start_time")
169
+	end_time, _ := this.GetInt64("end_time")
170
+	orgId := this.GetMobileAdminUserInfo().Org.Id
171
+	//统计总工时
172
+	list, err := service.GetTotalMinutesOne(orgId, start_time, end_time)
173
+	//统计出勤的总工时
174
+	workDaylist, err := service.GetTotalMinutesTwo(orgId, start_time, end_time)
175
+	if err != nil {
176
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
177
+		return
178
+	}
179
+	this.ServeSuccessJSON(map[string]interface{}{
180
+		"list":        list,
181
+		"workDaylist": workDaylist,
182
+	})
183
+}
184
+
185
+func (this *StaffScheduleApiController) ToSearchMobileTotal() {
186
+
187
+	start_time, _ := this.GetInt64("start_time")
188
+	end_time, _ := this.GetInt64("end_time")
189
+	orgId := this.GetMobileAdminUserInfo().Org.Id
190
+	keyword := this.GetString("keyword")
191
+	//统计表
192
+	scheduletotal, err := service.GetSearchScheduleListTotal(orgId, start_time, end_time, keyword)
193
+	list, err := service.GeSearchtTotalMinutes(orgId, start_time, end_time, keyword)
194
+	workDay, err := service.GetSearchWorkDay(orgId, start_time, end_time, keyword)
195
+	noWorkDay, err := service.GetSearchWorkNoDay(orgId, start_time, end_time, keyword)
196
+
197
+	//统计图
198
+	chartTotalMinute, err := service.GetChartTotalMinutesOne(orgId, start_time, end_time, keyword)
199
+	chartWorkDayMinute, err := service.GetChartTotalMinutesTwo(orgId, start_time, end_time, keyword)
200
+	if err != nil {
201
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
202
+		return
203
+	}
204
+	this.ServeSuccessJSON(map[string]interface{}{
205
+		"scheduletotal":      scheduletotal,
206
+		"list":               list,
207
+		"workDay":            workDay,
208
+		"noWorkDay":          noWorkDay,
209
+		"chartTotalMinute":   chartTotalMinute,
210
+		"chartWorkDayMinute": chartWorkDayMinute,
211
+	})
212
+}
213
+
214
+func (this *StaffScheduleApiController) ChangeMobileOption() {
215
+
216
+	start_time, _ := this.GetInt64("start_time")
217
+	end_time, _ := this.GetInt64("end_time")
218
+	orgId := this.GetMobileAdminUserInfo().Org.Id
219
+	doctor_type, _ := this.GetInt64("doctor_type")
220
+	//统计图
221
+	scheduletotal, err := service.ChagneScheduleListTotal(orgId, start_time, end_time, doctor_type)
222
+	list, err := service.ChangeScheduleMinute(orgId, start_time, end_time, doctor_type)
223
+	workday, err := service.ChangeWorkDay(orgId, start_time, end_time, doctor_type)
224
+	worknoday, err := service.ChangeNoWorkDay(orgId, start_time, end_time, doctor_type)
225
+
226
+	//统计表
227
+	chartotalminute, err := service.ChartTotalMinute(orgId, start_time, end_time, doctor_type)
228
+	chartworkdayminute, err := service.ChartWorkDayMinute(orgId, start_time, end_time, doctor_type)
229
+	if err != nil {
230
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
231
+		return
232
+	}
233
+	this.ServeSuccessJSON(map[string]interface{}{
234
+		"scheduletotal":      scheduletotal,
235
+		"list":               list,
236
+		"workday":            workday,
237
+		"worknoday":          worknoday,
238
+		"chartotalminute":    chartotalminute,
239
+		"chartworkdayminute": chartworkdayminute,
240
+	})
241
+}
242
+
243
+func (this *StaffScheduleApiController) GetAllZone() {
244
+
245
+	id := this.GetMobileAdminUserInfo().Org.Id
246
+	zone, err := service.GetAllMobileZone(id)
247
+	if err != nil {
248
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
249
+		return
250
+	}
251
+	this.ServeSuccessJSON(map[string]interface{}{
252
+		"zone": zone,
253
+	})
254
+}
255
+
256
+func (this *StaffScheduleApiController) GetPatientScheduleList() {
257
+	orgid := this.GetMobileAdminUserInfo().Org.Id
258
+	fmt.Println("orgid", orgid)
259
+	timeLayout := "2006-01-02"
260
+	loc, _ := time.LoadLocation("Local")
261
+	start_time := this.GetString("start_time")
262
+	var startTime int64
263
+	if len(start_time) > 0 {
264
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
265
+		if err != nil {
266
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
267
+			return
268
+		}
269
+		startTime = theTime.Unix()
270
+	}
271
+	fmt.Println("时间搓", startTime)
272
+	zoneid, _ := this.GetInt64("zoneid")
273
+	fmt.Println(zoneid)
274
+	classtype, _ := this.GetInt64("classtype")
275
+	fmt.Println("classtype", classtype)
276
+
277
+	//获取当天排班的病人情况
278
+	schedule, err := service.GetPatientSchedule(startTime, zoneid, classtype, orgid)
279
+
280
+	if err != nil {
281
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
282
+		return
283
+	}
284
+	this.ServeSuccessJSON(map[string]interface{}{
285
+		"schedule": schedule,
286
+	})
287
+}
288
+
289
+func (this *StaffScheduleApiController) DeleteSchedule() {
290
+	id, _ := this.GetInt64("id")
291
+	fmt.Println("id", id)
292
+	err := service.DeleteSchedule(id)
293
+	fmt.Println(err)
294
+	returnData := make(map[string]interface{}, 0)
295
+	returnData["msg"] = "ok"
296
+	this.ServeSuccessJSON(returnData)
297
+	return
298
+}
299
+
300
+func (this *StaffScheduleApiController) SearchPatient() {
301
+	timeLayout := "2006-01-02"
302
+	loc, _ := time.LoadLocation("Local")
303
+	keyword := this.GetString("keyword")
304
+	fmt.Println(keyword)
305
+	orgId := this.GetMobileAdminUserInfo().Org.Id
306
+	start_time := this.GetString("start_time")
307
+	var startTime int64
308
+	if len(start_time) > 0 {
309
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
310
+		if err != nil {
311
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
312
+			return
313
+		}
314
+		startTime = theTime.Unix()
315
+	}
316
+	schedule, err := service.GetSearchPatient(keyword, orgId, startTime)
317
+
318
+	if err != nil {
319
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
320
+		return
321
+	}
322
+	this.ServeSuccessJSON(map[string]interface{}{
323
+		"schedule": schedule,
324
+	})
325
+}
326
+
327
+func (this *StaffScheduleApiController) UpdatePatientScheduleById() {
328
+
329
+	ids := this.GetString("ids")
330
+	idSplit := strings.Split(ids, ",")
331
+	var err error
332
+	//查询患者信息
333
+	list, _ := service.GetStaffScheduleById(idSplit)
334
+	if len(list) > 0 {
335
+		for index, _ := range list {
336
+			fmt.Println("index2322332", index)
337
+			schedule := models.XtSchedule{
338
+				PatientId: list[0].PatientId,
339
+				ModeId:    list[0].ModeId,
340
+			}
341
+			xtSchedule := models.WeekSchedule{
342
+				PatientId: list[1].PatientId,
343
+				ModeId:    list[1].ModeId,
344
+			}
345
+			err = service.UpdateStaffSchedule(list[1].ID, schedule)
346
+			fmt.Println("errrrrrrr2323323232323", err)
347
+			service.UpdateStaffScheduleOne(list[0].ID, xtSchedule)
348
+		}
349
+	}
350
+	fmt.Println(err)
351
+	this.ServeSuccessJSON(map[string]interface{}{
352
+		"msg": "切换成功",
353
+	})
354
+}

+ 23 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_router.go View File

@@ -0,0 +1,23 @@
1
+package new_mobile_api_controllers
2
+
3
+import "github.com/astaxie/beego"
4
+
5
+func StaffScheduleApiControllersRegisterRouters() {
6
+
7
+	beego.Router("/m/api/getmobiledoctorlist", &StaffScheduleApiController{}, "Get:GetMobileDoctorList")
8
+	beego.Router("/m/api/getmobilestaffschedulelist", &StaffScheduleApiController{}, "Get:GetMobileStaffScheduleList")
9
+	beego.Router("/m/api/getmobilenextweekschedulelist", &StaffScheduleApiController{}, "Get:GetMobileNextWeekScheduleLIst")
10
+	beego.Router("/m/api/getschedulebyusertype", &StaffScheduleApiController{}, "Get:GetScheduleByUserType")
11
+	beego.Router("/m/api/getsearchpatientbydoctorid", &StaffScheduleApiController{}, "Get:GetSearchPatientByDoctorId")
12
+	beego.Router("/m/api/getmobileschedulelist", &StaffScheduleApiController{}, "Get:GetMobileSchedulelist")
13
+	beego.Router("/m/api/getmobileschedulelisttoal", &StaffScheduleApiController{}, "Get:GetMobileScheduleListTotal")
14
+	beego.Router("m/api/getmyschedule", &StaffScheduleApiController{}, "Get:GetMySchedule")
15
+	beego.Router("/m/api/getmobilechartlist", &StaffScheduleApiController{}, "Get:GetMobileChartList")
16
+	beego.Router("/m/api/tosearchmobiletotal", &StaffScheduleApiController{}, "Get:ToSearchMobileTotal")
17
+	beego.Router("/m/api/changemobileoption", &StaffScheduleApiController{}, "Get:ChangeMobileOption")
18
+	beego.Router("/m/api/getallzone", &StaffScheduleApiController{}, "Get:GetAllZone")
19
+	beego.Router("/m/api/getpatientschedulelist", &StaffScheduleApiController{}, "Get:GetPatientScheduleList")
20
+	beego.Router("/m/api/deleteSchedule", &StaffScheduleApiController{}, "Get:DeleteSchedule")
21
+	beego.Router("/m/api/ssearchpatient", &StaffScheduleApiController{}, "Get:SearchPatient")
22
+	beego.Router("/m/api/updatepatientschedule", &StaffScheduleApiController{}, "Get:UpdatePatientScheduleById")
23
+}

+ 44 - 0
controllers/new_mobile_api_controllers/statistics_api_controllers.go View File

@@ -0,0 +1,44 @@
1
+package new_mobile_api_controllers
2
+
3
+import "github.com/astaxie/beego"
4
+
5
+func StatisticsAPIControllersRegisterRouters() {
6
+
7
+	//化验指标
8
+	beego.Router("/m/api/inspectionindex/init", &IndexEvaluationApiController{}, "Get:GetLaboratoryIndexInitData")
9
+	beego.Router("/m/api/rangevalue/get", &IndexEvaluationApiController{}, "Get:GetLaboratoryIndexProjectRangeValueData")
10
+	beego.Router("/m/api/inspectionindex/chart", &IndexEvaluationApiController{}, "Get:GetInspectionChartData")
11
+	beego.Router("/m/api/inspectionindex/table", &IndexEvaluationApiController{}, "Get:GetInspectionChartTableData")
12
+	beego.Router("/m/api/patientinspectionindex/chart", &IndexEvaluationApiController{}, "Get:GetPatientInspectionChartData")
13
+	beego.Router("/m/api/patientinspectionindex/barchart", &IndexEvaluationApiController{}, "Get:GetPatientInspectionBarChartData")
14
+
15
+	beego.Router("/m/api/dialysisprocessindex/chart", &IndexEvaluationApiController{}, "Get:GetDialysisProcessIndexChartData")
16
+	beego.Router("/m/api/dialysisprocessindex/table", &IndexEvaluationApiController{}, "Get:GetDialysisProcessIndexTableData")
17
+
18
+	beego.Router("/m/api/dialysiswatch/chart", &IndexEvaluationApiController{}, "Get:GetDialysisWatchChartData")
19
+	beego.Router("/m/api/dialysiswatch/table", &IndexEvaluationApiController{}, "Get:GetDialysisWatchTableData")
20
+
21
+	beego.Router("/m/api/dialysisbloodpressure/chart", &IndexEvaluationApiController{}, "Get:GetDialysisBloodPressureChartData")
22
+	beego.Router("/m/api/dialysisbloodpressure/table", &IndexEvaluationApiController{}, "Get:GetDialysisBloodPressureTableData")
23
+	beego.Router("/m/api/patientdialysisbloodpressure/chart", &IndexEvaluationApiController{}, "Get:GetDialysisPatientBloodPressureChartData")
24
+
25
+	beego.Router("/m/api/dialysisweight/chart", &IndexEvaluationApiController{}, "Get:GetDialysisWeightChartData")
26
+	beego.Router("/m/api/dialysisweight/table", &IndexEvaluationApiController{}, "Get:GetDialysisWeightTableData")
27
+	beego.Router("/m/api/patientdialysisweight/chart", &IndexEvaluationApiController{}, "Get:GetDialysisPatientWeightChartData")
28
+
29
+	beego.Router("/m/api/doctorworkload/chart", &IndexEvaluationApiController{}, "Get:GetDoctorWorkloadChartData")
30
+	beego.Router("/m/api/doctorworkload/table", &IndexEvaluationApiController{}, "Get:GetDoctorWorkloadTableData")
31
+
32
+	beego.Router("/m/api/nurseworkload/chart", &IndexEvaluationApiController{}, "Get:GetNurseWorkloadChartData")
33
+	beego.Router("/m/api/nurseworkload/table", &IndexEvaluationApiController{}, "Get:GetNurseWorkloadTableData")
34
+
35
+	beego.Router("/m/api/adminuser/all", &IndexEvaluationApiController{}, "Get:GetAdminUser")
36
+	beego.Router("/m/api/defalutpatient/get", &IndexEvaluationApiController{}, "Get:GetDefaultPatient")
37
+
38
+	beego.Router("/m/api/patients/get", &IndexEvaluationApiController{}, "Get:GetAllPatients")
39
+
40
+	beego.Router("/m/api/stock/get", &ManagementAnalyseApiController{}, "Get:StockRecordPrintData")
41
+	beego.Router("/m/api/patientlapseto/chart", &ManagementAnalyseApiController{}, "Get:StatisticsPatientChart")
42
+	beego.Router("/m/api/patientlapseto/table", &ManagementAnalyseApiController{}, "Get:StatisticsPatientTable")
43
+
44
+}

+ 57 - 0
controllers/new_mobile_api_controllers/system_dialysis_prescription.json View File

@@ -0,0 +1,57 @@
1
+{
2
+  "prescription": [
3
+    {
4
+      "anticoagulant": 3,
5
+      "anticoagulant_shouji": 4000,
6
+      "anticoagulant_weichi": 0,
7
+      "anticoagulant_zongliang": 4000,
8
+      "mode_id": 1,
9
+      "blood_flow_volume": 250,
10
+      "kalium": 2,
11
+      "sodium": 135,
12
+      "calcium": 1.5,
13
+      "status": 1,
14
+      "dialysis_duration_hour": 4,
15
+      "dialysis_duration_minute": 0
16
+    },{
17
+      "anticoagulant": 3,
18
+      "anticoagulant_shouji": 4000,
19
+      "anticoagulant_weichi": 0,
20
+      "anticoagulant_zongliang": 4000,
21
+      "mode_id": 2,
22
+      "blood_flow_volume": 250,
23
+      "kalium": 2,
24
+      "sodium": 135,
25
+      "calcium": 1.5,
26
+      "status": 1,
27
+      "dialysis_duration_hour": 4,
28
+      "dialysis_duration_minute": 0
29
+    },{
30
+      "anticoagulant": 3,
31
+      "anticoagulant_shouji": 4000,
32
+      "anticoagulant_weichi": 0,
33
+      "anticoagulant_zongliang": 4000,
34
+      "mode_id": 3,
35
+      "blood_flow_volume": 200,
36
+      "kalium": 2,
37
+      "sodium": 135,
38
+      "calcium": 1.5,
39
+      "status": 1,
40
+      "dialysis_duration_hour": 4,
41
+      "dialysis_duration_minute": 0
42
+    },{
43
+      "anticoagulant": 3,
44
+      "anticoagulant_shouji": 4000,
45
+      "anticoagulant_weichi": 0,
46
+      "anticoagulant_zongliang": 4000,
47
+      "mode_id": 12,
48
+      "blood_flow_volume": 200,
49
+      "kalium": 2,
50
+      "sodium": 135,
51
+      "calcium": 1.5,
52
+      "status": 1,
53
+      "dialysis_duration_hour": 4,
54
+      "dialysis_duration_minute": 0
55
+    }
56
+  ]
57
+}

+ 296 - 0
controllers/orginfo_api_controller.go View File

@@ -0,0 +1,296 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/models"
6
+	"Xcx_New/service"
7
+	"Xcx_New/utils"
8
+	"encoding/json"
9
+	"reflect"
10
+	"time"
11
+
12
+	"github.com/astaxie/beego"
13
+)
14
+
15
+type OrgInfoApiController struct {
16
+	BaseAuthAPIController
17
+}
18
+
19
+func OrgInfoApiRegistRouters() {
20
+	beego.Router("/api/orginfo/getinfo", &OrgInfoApiController{}, "get:GetOrgInfo")
21
+	beego.Router("/api/orginfo/savegallery", &OrgInfoApiController{}, "post:SaveOrgGallery")
22
+	beego.Router("/api/orginfo/deletegallery", &OrgInfoApiController{}, "delete:DeleteOrgGallery")
23
+	beego.Router("/api/orginfo/edit", &OrgInfoApiController{}, "post:EditOrgInfo")
24
+
25
+}
26
+
27
+func (c *OrgInfoApiController) GetOrgInfo() {
28
+
29
+	adminUserInfo := c.GetAdminUserInfo()
30
+
31
+	orgInfo := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
32
+	provinces, _ := service.GetDistrictsByUpid(0)
33
+	var citys []*models.District
34
+	var districts []*models.District
35
+	if orgInfo.Province > 0 {
36
+		citys, _ = service.GetDistrictsByUpid(orgInfo.Province)
37
+	}
38
+	if orgInfo.City > 0 {
39
+		districts, _ = service.GetDistrictsByUpid(orgInfo.City)
40
+	}
41
+
42
+	orgtypes, _ := service.GetOrgTypes()
43
+
44
+	illness, _ := service.GetIllnessList()
45
+
46
+	c.ServeSuccessJSON(map[string]interface{}{
47
+		"orginfo":   orgInfo,
48
+		"provinces": provinces,
49
+		"citys":     citys,
50
+		"districts": districts,
51
+		"orgtypes":  orgtypes,
52
+		"illness":   illness,
53
+	})
54
+	return
55
+}
56
+
57
+func (c *OrgInfoApiController) EditOrgInfo() {
58
+	adminUserInfo := c.GetAdminUserInfo()
59
+
60
+	tempOrg, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
61
+
62
+	if tempOrg != nil && adminUserInfo.AdminUser.Id != tempOrg.Creator {
63
+		c.ServeFailJsonSend(enums.ErrorCodePermissionDenied, "权限不足")
64
+		return
65
+	}
66
+
67
+	dataBody := make(map[string]interface{}, 0)
68
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
69
+	if err != nil {
70
+		utils.ErrorLog(err.Error())
71
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
72
+		return
73
+	}
74
+
75
+	orgInfo := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
76
+	org := *orgInfo
77
+
78
+	if dataBody["org_name"] == nil || reflect.TypeOf(dataBody["org_name"]).String() != "string" {
79
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:机构名称")
80
+		return
81
+	}
82
+	orgName, _ := dataBody["org_name"].(string)
83
+	if len(orgName) == 0 {
84
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "机构名称不能为空")
85
+		return
86
+	}
87
+
88
+	org.OrgName = orgName
89
+
90
+	if dataBody["contact_name"] == nil || reflect.TypeOf(dataBody["contact_name"]).String() != "string" {
91
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:联系人姓名")
92
+		return
93
+	}
94
+	contactName, _ := dataBody["contact_name"].(string)
95
+	if len(contactName) == 0 {
96
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "联系人姓名不能为空")
97
+		return
98
+	}
99
+	org.ContactName = contactName
100
+
101
+	// if dataBody["org_short_name"] == nil || reflect.TypeOf(dataBody["org_short_name"]).String() != "string" {
102
+	// 	c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:商家简称")
103
+	// 	return
104
+	// }
105
+	// orgShortName, _ := dataBody["org_short_name"].(string)
106
+	// if len(orgShortName) == 0 {
107
+	// 	c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "商家简称不能为空")
108
+	// 	return
109
+	// }
110
+	org.OrgShortName = orgName
111
+
112
+	if dataBody["org_introduction"] == nil || reflect.TypeOf(dataBody["org_introduction"]).String() != "string" {
113
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:机构介绍")
114
+		return
115
+	}
116
+	orgIntroduction, _ := dataBody["org_introduction"].(string)
117
+	if len(orgIntroduction) == 0 {
118
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "机构介绍不能为空")
119
+		return
120
+	}
121
+	org.OrgIntroduction = orgIntroduction
122
+
123
+	if dataBody["org_logo"] == nil || reflect.TypeOf(dataBody["org_logo"]).String() != "string" {
124
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:机构头像")
125
+		return
126
+	}
127
+	orgLogo, _ := dataBody["org_logo"].(string)
128
+	if len(orgLogo) == 0 {
129
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "机构头像不能为空")
130
+		return
131
+	}
132
+	org.OrgLogo = orgLogo
133
+
134
+	if dataBody["province"] != nil || reflect.TypeOf(dataBody["province"]).String() == "float64" {
135
+		province := int64(dataBody["province"].(float64))
136
+		org.Province = province
137
+	}
138
+
139
+	if dataBody["city"] != nil || reflect.TypeOf(dataBody["city"]).String() == "float64" {
140
+		city := int64(dataBody["city"].(float64))
141
+		org.City = city
142
+	}
143
+
144
+	if dataBody["district"] != nil || reflect.TypeOf(dataBody["district"]).String() == "float64" {
145
+		district := int64(dataBody["district"].(float64))
146
+		org.District = district
147
+	}
148
+
149
+	if dataBody["address"] != nil || reflect.TypeOf(dataBody["address"]).String() == "string" {
150
+		address, _ := dataBody["address"].(string)
151
+		org.Address = address
152
+	}
153
+
154
+	if dataBody["org_type"] != nil || reflect.TypeOf(dataBody["org_type"]).String() == "float64" {
155
+		orgType := int64(dataBody["org_type"].(float64))
156
+		org.OrgType = orgType
157
+	}
158
+
159
+	if dataBody["telephone"] != nil || reflect.TypeOf(dataBody["telephone"]).String() == "string" {
160
+		telephone, _ := dataBody["telephone"].(string)
161
+		org.Telephone = telephone
162
+	}
163
+
164
+	if dataBody["operating_state"] != nil || reflect.TypeOf(dataBody["operating_state"]).String() == "float64" {
165
+		operatingState := int64(dataBody["operating_state"].(float64))
166
+		org.OperatingState = operatingState
167
+	}
168
+
169
+	if dataBody["business_week"] != nil || reflect.TypeOf(dataBody["business_week"]).String() == "string" {
170
+		businessWeek, _ := dataBody["business_week"].(string)
171
+		org.BusinessWeek = businessWeek
172
+	}
173
+
174
+	if dataBody["business_time"] != nil || reflect.TypeOf(dataBody["business_time"]).String() == "string" {
175
+		businessTime, _ := dataBody["business_time"].(string)
176
+		org.BusinessTime = businessTime
177
+	}
178
+	if dataBody["illness"] != nil || reflect.TypeOf(dataBody["illness"]).String() == "string" {
179
+		illness, _ := dataBody["illness"].(string)
180
+		org.Illness = illness
181
+	}
182
+
183
+	timeNow := time.Now().Unix()
184
+	org.ModifyTime = timeNow
185
+	org.OrgGallery = nil
186
+	err = service.UpdateOrgInfo(&org)
187
+	if err != nil {
188
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
189
+		return
190
+	}
191
+
192
+	orgInfo.OrgName = orgName
193
+	orgInfo.OrgShortName = orgName
194
+	orgInfo.OrgIntroduction = orgIntroduction
195
+	orgInfo.OrgLogo = orgLogo
196
+	orgInfo.Province = org.Province
197
+	orgInfo.District = org.District
198
+	orgInfo.City = org.City
199
+	orgInfo.OrgType = org.OrgType
200
+	orgInfo.Telephone = org.Telephone
201
+	orgInfo.OperatingState = org.OperatingState
202
+	orgInfo.BusinessWeek = org.BusinessWeek
203
+	orgInfo.BusinessTime = org.BusinessTime
204
+	orgInfo.Illness = org.Illness
205
+	orgInfo.ContactName = org.ContactName
206
+
207
+	c.ServeSuccessJSON(map[string]interface{}{
208
+		"msg": "ok",
209
+	})
210
+	return
211
+}
212
+
213
+func (c *OrgInfoApiController) SaveOrgGallery() {
214
+	adminUserInfo := c.GetAdminUserInfo()
215
+
216
+	dataBody := make(map[string]interface{}, 0)
217
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
218
+	if err != nil {
219
+		utils.ErrorLog(err.Error())
220
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
221
+		return
222
+	}
223
+
224
+	if dataBody["type"] == nil || reflect.TypeOf(dataBody["type"]).String() != "float64" {
225
+		utils.ErrorLog("type")
226
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
227
+		return
228
+	}
229
+	galleryType := int64(dataBody["type"].(float64))
230
+	if galleryType != 1 && galleryType != 2 {
231
+		utils.ErrorLog("galleryType != 1&&2")
232
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
233
+		return
234
+	}
235
+
236
+	if dataBody["url"] == nil || reflect.TypeOf(dataBody["url"]).String() != "string" {
237
+		utils.ErrorLog("url")
238
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
239
+		return
240
+	}
241
+	url, _ := dataBody["url"].(string)
242
+	if len(url) == 0 {
243
+		utils.ErrorLog("len(url) == 0")
244
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
245
+		return
246
+	}
247
+
248
+	timeNow := time.Now().Unix()
249
+	var gallery models.OrgGallery
250
+	gallery.Type = galleryType
251
+	gallery.Url = url
252
+	gallery.OrgId = adminUserInfo.CurrentOrgId
253
+	gallery.Status = 1
254
+	gallery.Ctime = timeNow
255
+	gallery.Mtime = timeNow
256
+	err = service.CreateOrgGalleryItem(&gallery)
257
+	if err != nil {
258
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
259
+		return
260
+	}
261
+
262
+	orgInfo := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
263
+	orgInfo.OrgGallery = append(orgInfo.OrgGallery, &gallery)
264
+	c.ServeSuccessJSON(map[string]interface{}{
265
+		"msg": "ok",
266
+	})
267
+	return
268
+
269
+}
270
+
271
+func (c *OrgInfoApiController) DeleteOrgGallery() {
272
+	adminUserInfo := c.GetAdminUserInfo()
273
+	id, _ := c.GetInt64("id", 0)
274
+	if id <= 0 {
275
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
276
+		return
277
+	}
278
+
279
+	err := service.DeleteOrgGalleryItem(id)
280
+	if err != nil {
281
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
282
+		return
283
+	}
284
+
285
+	orgInfo := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
286
+	for index, item := range orgInfo.OrgGallery {
287
+		if item.ID == id {
288
+			orgInfo.OrgGallery = append(orgInfo.OrgGallery[:index], orgInfo.OrgGallery[index+1:]...)
289
+		}
290
+	}
291
+	c.ServeSuccessJSON(map[string]interface{}{
292
+		"msg": "ok",
293
+	})
294
+	return
295
+
296
+}

File diff suppressed because it is too large
+ 4515 - 0
controllers/patient_api_controller.go


+ 371 - 0
controllers/patient_dataconfig_api_controller.go View File

@@ -0,0 +1,371 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/models"
6
+	"Xcx_New/service"
7
+	"Xcx_New/utils"
8
+	"fmt"
9
+	"strconv"
10
+	"strings"
11
+	"time"
12
+
13
+	"github.com/astaxie/beego"
14
+)
15
+
16
+func PatientDataConfigAPIControllerRegistRouters() {
17
+	beego.Router("/api/patient/courses", &PatientDataConfigAPIController{}, "get:Courses")
18
+	beego.Router("/api/patient/course/create", &PatientDataConfigAPIController{}, "get:CreateCourse")
19
+	beego.Router("/api/patient/course/delete", &PatientDataConfigAPIController{}, "post:DeleteCourse")
20
+	beego.Router("/api/patient/course/modify", &PatientDataConfigAPIController{}, "get:ModifyCourse")
21
+
22
+	beego.Router("/api/patient/rescues", &PatientDataConfigAPIController{}, "get:Rescues")
23
+	beego.Router("/api/patient/rescue/create", &PatientDataConfigAPIController{}, "post:CreateRescue")
24
+	beego.Router("/api/patient/rescue/delete", &PatientDataConfigAPIController{}, "post:DeleteRescue")
25
+}
26
+
27
+type PatientDataConfigAPIController struct {
28
+	BaseAuthAPIController
29
+}
30
+
31
+// /api/patient/courses [get]
32
+// @param patient_id:int
33
+// @param start_time:string (yyyy-MM-dd)
34
+// @param end_time:string (yyyy-MM-dd)
35
+func (this *PatientDataConfigAPIController) Courses() {
36
+	patientID, _ := this.GetInt64("patient_id")
37
+	startTimeYMDStr := this.GetString("start_time")
38
+	endTimeYMDStr := this.GetString("end_time")
39
+	if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 {
40
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
41
+		return
42
+	}
43
+	endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59"
44
+	startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr)
45
+	endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
46
+	if parseStartTimeErr != nil || parseEndTimeErr != nil {
47
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
48
+		return
49
+	}
50
+
51
+	adminUserInfo := this.GetAdminUserInfo()
52
+	patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
53
+	if getPatientErr != nil {
54
+		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
55
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
56
+		return
57
+	} else if patient == nil {
58
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
59
+		return
60
+	}
61
+
62
+	records, getRecordsErr := service.GetPatientCourseOfDisease(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix())
63
+	if getRecordsErr != nil {
64
+		this.ErrorLog("获取患者病程记录失败:%v", getRecordsErr)
65
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
66
+		return
67
+	}
68
+
69
+	admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
70
+	if getAllAdminsErr != nil {
71
+		this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
72
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
73
+		return
74
+	}
75
+
76
+	this.ServeSuccessJSON(map[string]interface{}{
77
+		"records": records,
78
+		"doctors": admins,
79
+	})
80
+}
81
+
82
+// /api/patient/course/create [post]
83
+// @param patient_id:int
84
+// @param content:string
85
+func (this *PatientDataConfigAPIController) CreateCourse() {
86
+	patientID, _ := this.GetInt64("patient_id")
87
+	fmt.Println(patientID)
88
+	content := this.GetString("content")
89
+	fmt.Println("content22222222222222222222", content)
90
+	record_time_str := this.GetString("record_time")
91
+	title := this.GetString("title")
92
+
93
+	if patientID <= 0 || len(content) == 0 {
94
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
95
+		return
96
+	}
97
+
98
+	if len(record_time_str) == 0 {
99
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
100
+		return
101
+	}
102
+
103
+	checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", record_time_str)
104
+
105
+	adminUserInfo := this.GetAdminUserInfo()
106
+	patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
107
+	if getPatientErr != nil {
108
+		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
109
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
110
+		return
111
+	} else if patient == nil {
112
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
113
+		return
114
+	}
115
+
116
+	now := time.Now().Unix()
117
+	record := models.PatientDiseaseCourse{
118
+		OrgID:      adminUserInfo.CurrentOrgId,
119
+		PatientID:  patientID,
120
+		Recorder:   adminUserInfo.AdminUser.Id,
121
+		RecordTime: checkDate.Unix(),
122
+		Content:    content,
123
+		Status:     1,
124
+		CreateTime: now,
125
+		ModifyTime: now,
126
+		Title:      title,
127
+	}
128
+
129
+	createErr := service.CreatePatientCourseOfDisease(&record)
130
+	if createErr != nil {
131
+		this.ErrorLog("创建患者病程记录失败:%v", createErr)
132
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
133
+		return
134
+	}
135
+
136
+	this.ServeSuccessJSON(map[string]interface{}{
137
+		"record": record,
138
+	})
139
+}
140
+
141
+// /api/patient/course/delete
142
+// @param patient_id:int
143
+// @param ids:string 一个或多个record_id以逗号相隔 ("1,3,7")
144
+func (this *PatientDataConfigAPIController) DeleteCourse() {
145
+	patientID, _ := this.GetInt64("patient_id")
146
+	idsStr := this.GetString("ids")
147
+	if patientID <= 0 || len(idsStr) == 0 {
148
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
149
+		return
150
+	}
151
+
152
+	adminUserInfo := this.GetAdminUserInfo()
153
+	patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
154
+	if getPatientErr != nil {
155
+		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
156
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
157
+		return
158
+	} else if patient == nil {
159
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
160
+		return
161
+	}
162
+
163
+	recordIDStrs := strings.Split(idsStr, ",")
164
+	recordIDs := make([]int64, 0, len(recordIDStrs))
165
+	for _, idStr := range recordIDStrs {
166
+		id, parseErr := strconv.Atoi(idStr)
167
+		if parseErr != nil {
168
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
169
+			return
170
+		}
171
+		recordIDs = append(recordIDs, int64(id))
172
+	}
173
+
174
+	deleteErr := service.DeletePatientCoursesInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
175
+	if deleteErr != nil {
176
+		this.ErrorLog("删除患者病程记录失败:%v", deleteErr)
177
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
178
+		return
179
+	}
180
+	this.ServeSuccessJSON(nil)
181
+}
182
+
183
+// /api/patient/rescues [get]
184
+// @param patient_id:int
185
+// @param start_time:string (yyyy-MM-dd)
186
+// @param end_time:string (yyyy-MM-dd)
187
+func (this *PatientDataConfigAPIController) Rescues() {
188
+	patientID, _ := this.GetInt64("patient_id")
189
+	startTimeYMDStr := this.GetString("start_time")
190
+	endTimeYMDStr := this.GetString("end_time")
191
+	if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 {
192
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
193
+		return
194
+	}
195
+	endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59"
196
+	startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr)
197
+	endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
198
+	if parseStartTimeErr != nil || parseEndTimeErr != nil {
199
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
200
+		return
201
+	}
202
+
203
+	adminUserInfo := this.GetAdminUserInfo()
204
+	patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
205
+	if getPatientErr != nil {
206
+		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
207
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
208
+		return
209
+	} else if patient == nil {
210
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
211
+		return
212
+	}
213
+
214
+	records, getRecordsErr := service.GetPatientRescueRecords(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix())
215
+	if getRecordsErr != nil {
216
+		this.ErrorLog("获取患者抢救记录失败:%v", getRecordsErr)
217
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
218
+		return
219
+	}
220
+
221
+	admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
222
+	if getAllAdminsErr != nil {
223
+		this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
224
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
225
+		return
226
+	}
227
+
228
+	this.ServeSuccessJSON(map[string]interface{}{
229
+		"records": records,
230
+		"doctors": admins,
231
+	})
232
+}
233
+
234
+// /api/patient/rescue/create [post]
235
+// @param patient_id:int
236
+// @param content:string
237
+func (this *PatientDataConfigAPIController) CreateRescue() {
238
+	patientID, _ := this.GetInt64("patient_id")
239
+	content := this.GetString("content")
240
+	if patientID <= 0 || len(content) == 0 {
241
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
242
+		return
243
+	}
244
+
245
+	adminUserInfo := this.GetAdminUserInfo()
246
+	patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
247
+	if getPatientErr != nil {
248
+		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
249
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
250
+		return
251
+	} else if patient == nil {
252
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
253
+		return
254
+	}
255
+
256
+	now := time.Now().Unix()
257
+	record := models.PatientRescueRecord{
258
+		OrgID:      adminUserInfo.CurrentOrgId,
259
+		PatientID:  patientID,
260
+		Recorder:   adminUserInfo.AdminUser.Id,
261
+		RecordTime: now,
262
+		Content:    content,
263
+		Status:     1,
264
+		CreateTime: now,
265
+		ModifyTime: now,
266
+	}
267
+
268
+	createErr := service.CreatePatientRescueRecord(&record)
269
+	if createErr != nil {
270
+		this.ErrorLog("创建患者抢救记录失败:%v", createErr)
271
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
272
+		return
273
+	}
274
+
275
+	this.ServeSuccessJSON(map[string]interface{}{
276
+		"record": record,
277
+	})
278
+}
279
+
280
+// /api/patient/rescue/delete
281
+// @param patient_id:int
282
+// @param ids:string 一个或多个record_id以逗号相隔 ("1,3,7")
283
+func (this *PatientDataConfigAPIController) DeleteRescue() {
284
+	patientID, _ := this.GetInt64("patient_id")
285
+	idsStr := this.GetString("ids")
286
+	if patientID <= 0 || len(idsStr) == 0 {
287
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
288
+		return
289
+	}
290
+
291
+	adminUserInfo := this.GetAdminUserInfo()
292
+	patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
293
+	if getPatientErr != nil {
294
+		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
295
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
296
+		return
297
+	} else if patient == nil {
298
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
299
+		return
300
+	}
301
+
302
+	recordIDStrs := strings.Split(idsStr, ",")
303
+	recordIDs := make([]int64, 0, len(recordIDStrs))
304
+	for _, idStr := range recordIDStrs {
305
+		id, parseErr := strconv.Atoi(idStr)
306
+		if parseErr != nil {
307
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
308
+			return
309
+		}
310
+		recordIDs = append(recordIDs, int64(id))
311
+	}
312
+
313
+	deleteErr := service.DeletePatientResuceRecordsInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
314
+	if deleteErr != nil {
315
+		this.ErrorLog("删除患者抢救记录失败:%v", deleteErr)
316
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
317
+		return
318
+	}
319
+	this.ServeSuccessJSON(nil)
320
+}
321
+
322
+func (this *PatientDataConfigAPIController) ModifyCourse() {
323
+	patientID, _ := this.GetInt64("patient_id")
324
+	content := this.GetString("content")
325
+	id, _ := this.GetInt64("id", 0)
326
+	record_time_str := this.GetString("record_time")
327
+	title := this.GetString("title")
328
+
329
+	if patientID <= 0 || len(content) == 0 || id == 0 || len(record_time_str) == 0 {
330
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
331
+		return
332
+	}
333
+	checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", record_time_str)
334
+
335
+	adminUserInfo := this.GetAdminUserInfo()
336
+	patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
337
+	if getPatientErr != nil {
338
+		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
339
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
340
+		return
341
+	} else if patient == nil {
342
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
343
+		return
344
+	}
345
+
346
+	now := time.Now().Unix()
347
+
348
+	record := models.PatientDiseaseCourse{
349
+		ID:         id,
350
+		OrgID:      adminUserInfo.CurrentOrgId,
351
+		PatientID:  patientID,
352
+		Recorder:   adminUserInfo.AdminUser.Id,
353
+		Content:    content,
354
+		Status:     1,
355
+		CreateTime: now,
356
+		ModifyTime: now,
357
+		Title:      title,
358
+		RecordTime: checkDate.Unix(),
359
+	}
360
+
361
+	createErr := service.ModifyPatientCourses(&record)
362
+	if createErr != nil {
363
+		this.ErrorLog("创建患者抢救记录失败:%v", createErr)
364
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
365
+		return
366
+	}
367
+
368
+	this.ServeSuccessJSON(map[string]interface{}{
369
+		"record": record,
370
+	})
371
+}

+ 620 - 0
controllers/pay_api_controller.go View File

@@ -0,0 +1,620 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/models"
6
+	"Xcx_New/service"
7
+	"bytes"
8
+	"crypto/md5"
9
+	"encoding/hex"
10
+	"encoding/json"
11
+	"encoding/xml"
12
+	"errors"
13
+	"fmt"
14
+	"github.com/astaxie/beego"
15
+	"io/ioutil"
16
+	"math/rand"
17
+	"net/http"
18
+	"regexp"
19
+	"sort"
20
+	"strconv"
21
+	"strings"
22
+	"time"
23
+)
24
+
25
+const (
26
+	pay_url = "https://api.mch.weixin.qq.com/pay/unifiedorder"
27
+)
28
+
29
+type PayApiController struct {
30
+	BaseServeAPIController
31
+	parameters       map[string]string
32
+	resultParameters map[string]string
33
+	payUrl           string
34
+}
35
+
36
+type PayApiController2 struct {
37
+	beego.Controller
38
+	parameters       map[string]string
39
+	resultParameters map[string]string
40
+	payUrl           string
41
+}
42
+
43
+func PayApiRegistRouters() {
44
+	beego.Router("/api/my/service", &PayApiController{}, "Get:GetMyService")
45
+	beego.Router("/api/product", &PayApiController{}, "Get:GetProduct")
46
+	beego.Router("/api/pay", &PayApiController{}, "Get:GetPayUrl")
47
+	beego.Router("/api/pay/transfer", &PayApiController{}, "Post:PostTransferStatus")
48
+	beego.Router("/api/order", &PayApiController{}, "Post:PostOrderInfo")
49
+	beego.Router("/api/order/get", &PayApiController{}, "Get:GetOrderInfo")
50
+	beego.Router("/api/pay/notify", &PayApiController2{}, "Post:WxPaySuccessNotify")
51
+	beego.Router("/api/order/cancel", &PayApiController{}, "Post:CancelOrder")
52
+	beego.Router("/api/order/list", &PayApiController{}, "Get:GetOrderList")
53
+	beego.Router("/api/order/hetong", &PayApiController{}, "Get:GetHeTong")
54
+	beego.Router("/api/order/hetong", &PayApiController{}, "Post:CreateHeTong")
55
+
56
+}
57
+func (c *PayApiController) GetOrderList() {
58
+	adminUserInfo := c.GetAdminUserInfo()
59
+	serviceOrderList, err := service.GetOrderList(adminUserInfo.CurrentOrgId)
60
+	if err == nil {
61
+		c.ServeSuccessJSON(map[string]interface{}{
62
+			"list": serviceOrderList,
63
+		})
64
+	} else {
65
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
66
+	}
67
+
68
+}
69
+
70
+func (c *PayApiController) CancelOrder() {
71
+	adminUserInfo := c.GetAdminUserInfo()
72
+	orderId, _ := c.GetInt64("id", 0)
73
+	if orderId == 0 {
74
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
75
+		return
76
+	}
77
+	order, err := service.FindServeOrderByID(adminUserInfo.CurrentOrgId, orderId)
78
+	if err != nil {
79
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
80
+		return
81
+	}
82
+	if order == nil {
83
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
84
+		return
85
+	}
86
+
87
+	errs := service.UpdateOrderStatus(adminUserInfo.CurrentOrgId, orderId)
88
+	if errs == nil {
89
+		c.ServeSuccessJSON(map[string]interface{}{
90
+			"msg": "取消成功",
91
+		})
92
+	} else {
93
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
94
+	}
95
+}
96
+
97
+func (c *PayApiController) PostTransferStatus() {
98
+	adminUserInfo := c.GetAdminUserInfo()
99
+	orderId, _ := c.GetInt64("id", 0)
100
+	if orderId == 0 {
101
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
102
+		return
103
+	}
104
+	order, err := service.FindServeOrderByID(adminUserInfo.CurrentOrgId, orderId)
105
+	if err != nil {
106
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
107
+		return
108
+	}
109
+	if order == nil {
110
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
111
+		return
112
+	}
113
+
114
+	errs := service.UpdateOrderPayType(adminUserInfo.CurrentOrgId, orderId)
115
+
116
+	if errs == nil {
117
+		c.ServeSuccessJSON(map[string]interface{}{
118
+			"msg": "确认成功",
119
+		})
120
+	} else {
121
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
122
+	}
123
+}
124
+
125
+func (c *PayApiController) GetOrderInfo() {
126
+	adminUserInfo := c.GetAdminUserInfo()
127
+	orderId, _ := c.GetInt64("id", 0)
128
+	order, err := service.FindServeOrderByID(adminUserInfo.CurrentOrgId, orderId)
129
+	if err != nil {
130
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
131
+		return
132
+	}
133
+	if order == nil {
134
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
135
+		return
136
+	}
137
+
138
+	orderInfo, err := service.FindOrderInfomationByID(order.OrderNumber, adminUserInfo.CurrentOrgId)
139
+	if err != nil {
140
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
141
+		return
142
+	}
143
+	if orderInfo == nil {
144
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
145
+		return
146
+	}
147
+	c.ServeSuccessJSON(map[string]interface{}{
148
+		"total":       order.PaymentAmount,
149
+		"orderNumber": order.OrderNumber,
150
+		"OrgName":     adminUserInfo.Orgs[adminUserInfo.CurrentOrgId].OrgName,
151
+		"order":       order,
152
+		"orderInfo":   orderInfo,
153
+	})
154
+}
155
+
156
+func (c *PayApiController) PostOrderInfo() {
157
+	adminUserInfo := c.GetAdminUserInfo()
158
+	amount, _ := c.GetInt64("amount", 0)
159
+	productId, _ := c.GetInt64("id", 0)
160
+
161
+	product, err := service.FindProductByID(productId)
162
+	if err != nil {
163
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
164
+		return
165
+	}
166
+	if product == nil {
167
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeProductError)
168
+		return
169
+	}
170
+	timestamp := c.GetTimestamp()
171
+	//自定义订单号
172
+	bill_no := "S" + strconv.FormatInt(timestamp, 10) + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
173
+
174
+	order := models.ServeOrder{
175
+		OrgId:           adminUserInfo.CurrentOrgId,
176
+		Period:          amount * 12,
177
+		Status:          1,
178
+		CreatedTime:     time.Now().Unix(),
179
+		UpdatedTime:     time.Now().Unix(),
180
+		OrderNumber:     bill_no,
181
+		OrderStatus:     1,
182
+		PayableAmount:   float64(amount) * product.Price,
183
+		PaymentAmount:   float64(amount) * product.Price,
184
+		ServeName:       product.ServeName,
185
+		ServeDesc:       product.ServeDesc,
186
+		OrderExpireTime: time.Now().Unix() + (7 * 24 * 3600),
187
+		Quantity:        amount,
188
+		Price:           product.Price,
189
+		ServeId:         productId,
190
+	}
191
+	infomation := models.ServeOrderInfomation{
192
+		OrgId:       adminUserInfo.CurrentOrgId,
193
+		OrderNumber: bill_no,
194
+		Status:      1,
195
+		ProductId:   product.ID,
196
+		ProductName: product.ServeName,
197
+		ProductDesc: product.ServeDesc,
198
+		Price:       product.Price,
199
+		Quantity:    amount,
200
+		MarketPrice: product.OriginalPrice,
201
+	}
202
+
203
+	service.CreateOrderRecord(&order)
204
+	service.CreateOrderInfomation(&infomation)
205
+	c.ServeSuccessJSON(map[string]interface{}{
206
+		"order": order,
207
+		"msg":   "提交订单成功",
208
+	})
209
+}
210
+
211
+func (c *PayApiController) GetProduct() {
212
+	adminUserInfo := c.GetAdminUserInfo()
213
+	products, err := service.FindAllProduct()
214
+	subscibe, _ := service.FindServiceSubscibeByOrgId(adminUserInfo.CurrentOrgId)
215
+
216
+	if err == nil {
217
+		c.ServeSuccessJSON(map[string]interface{}{
218
+			"products":    products,
219
+			"subscibe":    subscibe,
220
+			"serviceTime": time.Now().Unix(),
221
+			//"OrgName":  adminUserInfo.Orgs[adminUserInfo.CurrentOrgId].OrgName,
222
+		})
223
+	} else {
224
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
225
+	}
226
+}
227
+
228
+func (c *PayApiController) GetMyService() {
229
+	adminUserInfo := c.GetAdminUserInfo()
230
+	subscibe, err := service.FindServiceSubscibeByOrgId(adminUserInfo.CurrentOrgId)
231
+	if err == nil {
232
+		c.ServeSuccessJSON(map[string]interface{}{
233
+			"subscibe":    subscibe,
234
+			"serviceTime": time.Now().Unix(),
235
+		})
236
+	} else {
237
+
238
+	}
239
+
240
+}
241
+
242
+func (c *PayApiController) GetPayUrl() {
243
+	adminUserInfo := c.GetAdminUserInfo()
244
+	orderId, _ := c.GetInt64("id", 0)
245
+	if orderId == 0 {
246
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
247
+		return
248
+	}
249
+	order, err := service.FindServeOrderByID(adminUserInfo.CurrentOrgId, orderId)
250
+	if err != nil {
251
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
252
+		return
253
+	}
254
+	if order == nil {
255
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
256
+		return
257
+	}
258
+
259
+	orderInfo, err := service.FindOrderInfomationByID(order.OrderNumber, adminUserInfo.CurrentOrgId)
260
+	if err != nil {
261
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
262
+		return
263
+	}
264
+	if orderInfo == nil {
265
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
266
+		return
267
+	}
268
+
269
+	totalPrice := orderInfo.Price * float64(orderInfo.Quantity)
270
+	totalFee := fmt.Sprintf("%.0f", totalPrice*100)
271
+	c.SetParameter("out_trade_no", orderInfo.OrderNumber)
272
+	c.SetParameter("total_fee", totalFee)
273
+	c.SetParameter("trade_type", "NATIVE")
274
+	c.SetParameter("body", order.ServeName)
275
+	notify_url := beego.AppConfig.String("httpdomain") + "/api/pay/notify"
276
+	c.SetParameter("product_id", orderInfo.OrderNumber)
277
+	c.SetParameter("notify_url", notify_url)
278
+	c.SetParameter("spbill_create_ip", c.GetClientIp())
279
+	fmt.Println(c.GetClientIp())
280
+	url, err := c.GetPayCodeUrl()
281
+	fmt.Println(err)
282
+	if err == nil {
283
+		c.SetPayUrl(url)
284
+		c.ServeSuccessJSON(map[string]interface{}{
285
+			"payUrl": url,
286
+			"price":  order.PayableAmount,
287
+			//":  adminUserInfo.Orgs[adminUserInfo.CurrentOrgId].OrgName,
288
+		})
289
+	} else {
290
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
291
+		// utils.LogError(err)
292
+	}
293
+
294
+}
295
+
296
+func (this *PayApiController2) WxPaySuccessNotify() {
297
+
298
+	type PaySuccessXmlResp struct {
299
+		ReturnCode    string `xml:"return_code"`
300
+		Appid         string `xml:"appid"`
301
+		BankType      string `xml:"bank_type"`
302
+		CashFee       int64  `xml:"cash_fee"`
303
+		FeeType       string `xml:"fee_type"`
304
+		IsSubscribe   string `xml:"is_subscribe"`
305
+		MchId         string `xml:"mch_id"`
306
+		NonceStr      string `xml:"nonce_str"`
307
+		OpenId        string `xml:"openid"`
308
+		OutTradeNo    string `xml:"out_trade_no"`
309
+		ResultCode    string `xml:"result_code"`
310
+		Sign          string `xml:"sign"`
311
+		TimeEnd       string `xml:"time_end"`
312
+		TotalFee      string `xml:"total_fee"`
313
+		TradeType     string `xml:"trade_type"`
314
+		TransactionId string `xml:"transaction_id"`
315
+	}
316
+
317
+	defer this.Ctx.Request.Body.Close()
318
+	result, _ := ioutil.ReadAll(this.Ctx.Request.Body)
319
+
320
+	res := new(PaySuccessXmlResp)
321
+	xmlErr := xml.Unmarshal(result, &res)
322
+	if xmlErr != nil {
323
+
324
+	}
325
+
326
+	order, _ := service.FindServeOrderByOrderNumber(res.OutTradeNo)
327
+	service.UpdateOrder(order.OrderNumber, order.Quantity, order.OrgId, res.TransactionId, order.PeriodEnd, order.PeriodStart)
328
+
329
+	this.SetResultParameter("return_code", res.ReturnCode)
330
+	results := this.ParamsToXml2(this.resultParameters)
331
+	this.Ctx.WriteString(results)
332
+	this.ServeXML()
333
+
334
+}
335
+
336
+func (this *PayApiController) GetTimestamp() int64 {
337
+	return time.Now().UnixNano() / 1000000 //毫秒
338
+}
339
+
340
+func (this *PayApiController) GetClientIp() string {
341
+	ip := this.Ctx.Request.Header.Get("Remote_addr")
342
+	if ip == "" {
343
+		ip = this.Ctx.Request.RemoteAddr
344
+	}
345
+	if strings.Contains(ip, ":") {
346
+		ip = this.Substr(ip, 0, strings.Index(ip, ":"))
347
+	}
348
+	return ip
349
+}
350
+
351
+//截取字符串 start 起点下标 end 终点下标(不包括)
352
+func (this *PayApiController) Substr(str string, start int, end int) string {
353
+	rs := []rune(str)
354
+	length := len(rs)
355
+
356
+	if start < 0 || start > length {
357
+		return ""
358
+	}
359
+	if end < 0 || end > length {
360
+		return ""
361
+	}
362
+	return string(rs[start:end])
363
+}
364
+
365
+//设置请求参数
366
+func (this *PayApiController) SetParameter(key string, value string) {
367
+	if this.parameters == nil {
368
+		this.parameters = make(map[string]string)
369
+	}
370
+	this.parameters[key] = value
371
+}
372
+
373
+//设置请求参数
374
+func (this *PayApiController2) SetResultParameter(key string, value string) {
375
+	if this.resultParameters == nil {
376
+		this.resultParameters = make(map[string]string)
377
+	}
378
+	this.resultParameters[key] = value
379
+}
380
+
381
+//设置prepay_id
382
+func (this *PayApiController) SetPayUrl(payUrl string) {
383
+	this.payUrl = payUrl
384
+}
385
+
386
+type XmlResp struct {
387
+	Return_code  string `xml:"return_code"`
388
+	Return_msg   string `xml:"return_msg"`
389
+	Result_code  string `xml:"result_code"`
390
+	Err_code     string `xml:"err_code"`
391
+	Err_code_des string `xml:"err_code_des"`
392
+	Prepay_id    string `xml:"prepay_id"`
393
+	Code_url     string `xml:"code_url"`
394
+}
395
+
396
+func (this *PayApiController) GetPayCodeUrl() (string, error) {
397
+	strXml, err := this.CreateXml()
398
+	if err != nil {
399
+		return "", this.Error("get pay_code_url error", err)
400
+	}
401
+	result, err := this.http_post(pay_url, strXml)
402
+	if err != nil {
403
+		return "", this.Error("get pay_code_url error", err)
404
+	}
405
+
406
+	res := new(XmlResp)
407
+	xmlErr := xml.Unmarshal(result, &res)
408
+	if xmlErr != nil {
409
+		return "", this.Error("get pay_code_url xml error", xmlErr)
410
+	}
411
+	if res.Return_code != "SUCCESS" {
412
+		return "", this.Error("get pay_code_url result error: "+res.Return_msg, nil)
413
+	}
414
+
415
+	if res.Result_code != "SUCCESS" {
416
+		return "", this.Error("get pay_code_url result error: "+res.Err_code+"-"+res.Err_code_des, nil)
417
+	}
418
+	if res.Code_url == "" {
419
+		return "", this.Error("get pay_code_url result error: not get pay_code_url", nil)
420
+	}
421
+	return res.Code_url, nil
422
+}
423
+
424
+func (this *PayApiController) http_post(url string, xml string) ([]byte, error) {
425
+	bc := &http.Client{
426
+		Timeout: 30 * time.Second, //设置超时时间30s
427
+	}
428
+	res, err := bc.Post(url, "text/xml:charset=UTF-8", strings.NewReader(xml))
429
+	if err != nil {
430
+		return nil, this.Error("post", err)
431
+	}
432
+	result, err := ioutil.ReadAll(res.Body)
433
+	res.Body.Close()
434
+	if err != nil {
435
+		return nil, this.Error("post result err", err)
436
+	}
437
+	return result, nil
438
+}
439
+
440
+func (this *PayApiController) CreateXml() (string, error) {
441
+	//检测必填参数
442
+	if this.parameters["out_trade_no"] == "" {
443
+		return "", this.Error("缺少统一支付接口必填参数out_trade_no(商户订单号)!", nil)
444
+	} else if this.parameters["body"] == "" {
445
+		return "", this.Error("缺少统一支付接口必填参数body(商品描述)!", nil)
446
+	} else if this.parameters["total_fee"] == "" {
447
+		return "", this.Error("缺少统一支付接口必填参数total_fee(交易金额)!", nil)
448
+	} else if this.parameters["notify_url"] == "" {
449
+		return "", this.Error("缺少统一支付接口必填参数notify_url(异步接收微信支付结果通知的回调地址)!", nil)
450
+	} else if this.parameters["trade_type"] == "" {
451
+		return "", this.Error("缺少统一支付接口必填参数trade_type(交易类型)!", nil)
452
+	} else if this.parameters["spbill_create_ip"] == "" {
453
+		return "", this.Error("缺少统一支付接口必填参数spbill_create_ip(终端ip)", nil)
454
+	} else if this.parameters["trade_type"] == "NATIVE" && this.parameters["product_id"] == "" {
455
+		return "", this.Error("统一支付接口中,缺少必填参数product_id!trade_type为NATIVE时,product_id为必填参数!", nil)
456
+	}
457
+	this.parameters["appid"] = beego.AppConfig.String("appid")                             //公众账号ID
458
+	this.parameters["mch_id"] = beego.AppConfig.String("mchid")                            //商户号
459
+	this.parameters["nonce_str"] = this.CreateNoncestr(32)                                 //随机字符串
460
+	this.parameters["sign"] = this.GetSign(this.parameters, beego.AppConfig.String("key")) //签名
461
+	return this.ParamsToXml(this.parameters), nil
462
+}
463
+
464
+//产生随机字符串,不长于32位
465
+func (this *PayApiController) CreateNoncestr(length int) (nonceStr string) {
466
+	chars := "abcdefghijklmnopqrstuvwxyz0123456789"
467
+	for i := 0; i < length; i++ {
468
+		idx := rand.Intn(len(chars) - 1)
469
+		nonceStr += chars[idx : idx+1]
470
+	}
471
+	return
472
+}
473
+
474
+func (this *PayApiController) Error(strMsg string, err error) error {
475
+	if err == nil {
476
+		return errors.New(strMsg)
477
+	} else {
478
+		return errors.New(strMsg + ": " + err.Error())
479
+	}
480
+}
481
+
482
+//格式化参数,签名过程需要使用
483
+func (this *PayApiController) FormatParams(paramsMap map[string]string) string {
484
+	//STEP 1, 对key进行升序排序.
485
+	var sorted_keys []string
486
+	for k, _ := range paramsMap {
487
+		sorted_keys = append(sorted_keys, k)
488
+	}
489
+	sort.Strings(sorted_keys)
490
+
491
+	//STEP2, 对key=value的键值对用&连接起来,略过空值
492
+	var paramsStr []string
493
+	for _, k := range sorted_keys {
494
+		v := fmt.Sprintf("%v", strings.TrimSpace(paramsMap[k]))
495
+		if v != "" {
496
+			paramsStr = append(paramsStr, fmt.Sprintf("%s=%s", k, v))
497
+		}
498
+	}
499
+	return strings.Join(paramsStr, "&")
500
+}
501
+
502
+//生成签名
503
+func (this *PayApiController) GetSign(paramsMap map[string]string, wxKey string) string {
504
+	//STEP 1:按字典序排序参数
505
+	paramsStr := this.FormatParams(paramsMap)
506
+	//STEP 2:在string后加入KEY
507
+	signStr := paramsStr + "&key=" + wxKey
508
+	//STEP 3:MD5加密
509
+	sign := md5.New()
510
+	sign.Write([]byte(signStr))
511
+	//STEP 3:所有字符转为大写
512
+	return strings.ToUpper(hex.EncodeToString(sign.Sum(nil)))
513
+}
514
+
515
+//xml结构
516
+func (this *PayApiController) ParamsToXml(data map[string]string) string {
517
+	fmt.Println(data)
518
+	buf := bytes.NewBufferString("<xml>")
519
+	for k, v := range data {
520
+		str := "<![CDATA[%s]]>"
521
+		flag, _ := regexp.MatchString("^\\d+\\.?\\d*$", v)
522
+		if flag {
523
+			str = "%s"
524
+		}
525
+		buf.WriteString(fmt.Sprintf("<%s>"+str+"</%s>", k, v, k))
526
+	}
527
+	buf.WriteString("</xml>")
528
+	return buf.String()
529
+}
530
+
531
+//xml结构
532
+func (this *PayApiController2) ParamsToXml2(data map[string]string) string {
533
+	fmt.Println(data)
534
+	buf := bytes.NewBufferString("<xml>")
535
+	for k, v := range data {
536
+		str := "<![CDATA[%s]]>"
537
+		flag, _ := regexp.MatchString("^\\d+\\.?\\d*$", v)
538
+		if flag {
539
+			str = "%s"
540
+		}
541
+		buf.WriteString(fmt.Sprintf("<%s>"+str+"</%s>", k, v, k))
542
+	}
543
+	buf.WriteString("</xml>")
544
+	return buf.String()
545
+}
546
+
547
+func (this *PayApiController) SetUrl(payUrl string) {
548
+	this.payUrl = payUrl
549
+}
550
+
551
+func (c *PayApiController) GetHeTong() {
552
+	order_id, _ := c.GetInt64("order_id", 0)
553
+	if order_id <= 0 {
554
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
555
+		return
556
+	}
557
+
558
+	admin := c.GetAdminUserInfo()
559
+	ht, err := service.GetHetong(admin.CurrentOrgId, order_id)
560
+	if err != nil {
561
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
562
+		return
563
+	}
564
+
565
+	c.ServeSuccessJSON(map[string]interface{}{
566
+		"ht": ht,
567
+	})
568
+}
569
+
570
+func (c *PayApiController) CreateHeTong() {
571
+	orderId, _ := c.GetInt64("order_id", 0)
572
+	if orderId <= 0 {
573
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
574
+		return
575
+	}
576
+	admin := c.GetAdminUserInfo()
577
+	order, err := service.FindServeOrderByID(admin.CurrentOrgId, orderId)
578
+	if err != nil {
579
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
580
+		return
581
+	}
582
+	if order == nil {
583
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
584
+		return
585
+	}
586
+	ht, err := service.GetHetong(admin.CurrentOrgId, orderId)
587
+	if err != nil {
588
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
589
+		return
590
+	}
591
+	if ht != nil {
592
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHetongHad)
593
+		return
594
+	}
595
+
596
+	var hetong models.ServeOrderContract
597
+	err = json.Unmarshal(c.Ctx.Input.RequestBody, &hetong)
598
+	if err != nil {
599
+		fmt.Println(err)
600
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
601
+		return
602
+	}
603
+
604
+	hetong.OrderId = orderId
605
+	hetong.OrderNumber = order.OrderNumber
606
+	hetong.CreatedTime = time.Now().Unix()
607
+	hetong.UpdatedTime = time.Now().Unix()
608
+	hetong.Status = 1
609
+	hetong.OrgId = admin.CurrentOrgId
610
+
611
+	err = service.CreateHetong(&hetong)
612
+	if err != nil {
613
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateHetongFail)
614
+		return
615
+	}
616
+
617
+	c.ServeSuccessJSON(map[string]interface{}{
618
+		"ht": hetong,
619
+	})
620
+}

+ 922 - 0
controllers/pc_index_evaluation_api_controller.go View File

@@ -0,0 +1,922 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/models"
6
+	"Xcx_New/service/statistics_service"
7
+	"Xcx_New/utils"
8
+	"github.com/astaxie/beego"
9
+	"time"
10
+)
11
+
12
+func PCIndexEvaluationApiControllersRegisterRouters() {
13
+
14
+	beego.Router("/api/inspectionindex/init", &PCIndexEvaluationApiController{}, "Get:GetLaboratoryIndexInitData")
15
+	beego.Router("/api/rangevalue/get", &PCIndexEvaluationApiController{}, "Get:GetLaboratoryIndexProjectRangeValueData")
16
+	beego.Router("/api/inspectionindex/chart", &PCIndexEvaluationApiController{}, "Get:GetInspectionChartData")
17
+	beego.Router("/api/inspectionindex/table", &PCIndexEvaluationApiController{}, "Get:GetInspectionChartTableData")
18
+	beego.Router("/api/patientinspectionindex/chart", &PCIndexEvaluationApiController{}, "Get:GetPatientInspectionChartData")
19
+	beego.Router("/api/patientinspectionindex/barchart", &PCIndexEvaluationApiController{}, "Get:GetPatientInspectionBarChartData")
20
+
21
+	beego.Router("/api/dialysisprocessindex/chart", &PCIndexEvaluationApiController{}, "Get:GetDialysisProcessIndexChartData")
22
+	beego.Router("/api/dialysisprocessindex/table", &PCIndexEvaluationApiController{}, "Get:GetDialysisProcessIndexTableData")
23
+
24
+	beego.Router("/api/dialysiswatch/chart", &PCIndexEvaluationApiController{}, "Get:GetDialysisWatchChartData")
25
+	beego.Router("/api/dialysiswatch/table", &PCIndexEvaluationApiController{}, "Get:GetDialysisWatchTableData")
26
+
27
+	beego.Router("/api/dialysisbloodpressure/chart", &PCIndexEvaluationApiController{}, "Get:GetDialysisBloodPressureChartData")
28
+	beego.Router("/api/dialysisbloodpressure/table", &PCIndexEvaluationApiController{}, "Get:GetDialysisBloodPressureTableData")
29
+	beego.Router("/api/patientdialysisbloodpressure/chart", &PCIndexEvaluationApiController{}, "Get:GetDialysisPatientBloodPressureChartData")
30
+
31
+	beego.Router("/api/dialysisweight/chart", &PCIndexEvaluationApiController{}, "Get:GetDialysisWeightChartData")
32
+	beego.Router("/api/dialysisweight/table", &PCIndexEvaluationApiController{}, "Get:GetDialysisWeightTableData")
33
+	beego.Router("/api/patientdialysisweight/chart", &PCIndexEvaluationApiController{}, "Get:GetDialysisPatientWeightChartData")
34
+
35
+	beego.Router("/api/doctorworkload/chart", &PCIndexEvaluationApiController{}, "Get:GetDoctorWorkloadChartData")
36
+	beego.Router("/api/doctorworkload/table", &PCIndexEvaluationApiController{}, "Get:GetDoctorWorkloadTableData")
37
+
38
+	beego.Router("/api/nurseworkload/chart", &PCIndexEvaluationApiController{}, "Get:GetNurseWorkloadChartData")
39
+	beego.Router("/api/nurseworkload/table", &PCIndexEvaluationApiController{}, "Get:GetNurseWorkloadTableData")
40
+
41
+	beego.Router("/api/adminuser/all", &PCIndexEvaluationApiController{}, "Get:GetAdminUser")
42
+	beego.Router("/api/defalutpatient/get", &PCIndexEvaluationApiController{}, "Get:GetDefaultPatient")
43
+
44
+}
45
+
46
+type PCIndexEvaluationApiController struct {
47
+	BaseAuthAPIController
48
+}
49
+
50
+//化验指标
51
+
52
+//初始化数据
53
+func (this *PCIndexEvaluationApiController) GetLaboratoryIndexInitData() {
54
+	adminUserInfo := this.GetAdminUserInfo()
55
+
56
+	var references []*models.InspectionReference
57
+	count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.CurrentOrgId)
58
+	if count <= 0 {
59
+		references, _ = statistics_service.FindOrgInspectionReference(0, 1)
60
+		references2, _ := statistics_service.FindOrgInspectionReference(0, 2)
61
+		references = append(references, references2...)
62
+
63
+	} else {
64
+		references, _ = statistics_service.FindOrgInspectionReference(adminUserInfo.CurrentOrgId, 1)
65
+		references2, _ := statistics_service.FindOrgInspectionReference(adminUserInfo.CurrentOrgId, 2)
66
+		references = append(references, references2...)
67
+
68
+	}
69
+	this.ServeSuccessJSON(map[string]interface{}{
70
+		"references": references,
71
+	})
72
+}
73
+
74
+//获取取值范围
75
+func (this *PCIndexEvaluationApiController) GetLaboratoryIndexProjectRangeValueData() {
76
+	range_type, _ := this.GetInt64("range_type")
77
+	project_id, _ := this.GetInt64("project_id")
78
+	item_id, _ := this.GetInt64("item_id")
79
+	adminUserInfo := this.GetAdminUserInfo()
80
+	var range_vaule []string
81
+	var qcs models.InspectionReference
82
+	if range_type == 1 {
83
+		count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.CurrentOrgId)
84
+
85
+		if count <= 0 {
86
+			qcs, _ = statistics_service.FindOrgConfigRangeTypeValue(0, project_id, item_id)
87
+		} else {
88
+			qcs, _ = statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
89
+
90
+		}
91
+
92
+		range_vaule = append(range_vaule, qcs.RangeMin)
93
+		range_vaule = append(range_vaule, qcs.RangeMax)
94
+
95
+	} else {
96
+
97
+		inspection, _ := statistics_service.FindOrgInspectionReferenceRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
98
+		for _, item := range inspection {
99
+			range_vaule = append(range_vaule, item.InspectValue)
100
+		}
101
+
102
+	}
103
+	this.ServeSuccessJSON(map[string]interface{}{
104
+		"range_vaule": range_vaule,
105
+	})
106
+
107
+}
108
+func (this *PCIndexEvaluationApiController) GetInspectionChartData() {
109
+	adminUserInfo := this.GetAdminUserInfo()
110
+	start_time := this.GetString("start_time")
111
+	end_time := this.GetString("end_time")
112
+	project_id, _ := this.GetInt64("project_id")
113
+	item_id, _ := this.GetInt64("item_id")
114
+	range_type, _ := this.GetInt("range_type")
115
+
116
+	timeLayout := "2006-01-02"
117
+	loc, _ := time.LoadLocation("Local")
118
+
119
+	var theStartTIme int64
120
+	if len(start_time) > 0 {
121
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
122
+		if err != nil {
123
+			utils.ErrorLog(err.Error())
124
+		}
125
+		theStartTIme = theTime.Unix()
126
+	}
127
+	var theEndtTIme int64
128
+	if len(end_time) > 0 {
129
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
130
+		if err != nil {
131
+			utils.ErrorLog(err.Error())
132
+		}
133
+		theEndtTIme = theTime.Unix()
134
+	}
135
+
136
+	var range_value string
137
+
138
+	if range_type == 1 {
139
+		count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.CurrentOrgId)
140
+
141
+		if count <= 0 {
142
+			qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(0, project_id, item_id)
143
+			range_value = qcs.RangeMin + "," + qcs.RangeMax
144
+
145
+		} else {
146
+			qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
147
+			range_value = qcs.RangeMin + "," + qcs.RangeMax
148
+		}
149
+
150
+	} else {
151
+
152
+		inspection, _ := statistics_service.FindOrgInspectionReferenceRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
153
+		for _, item := range inspection {
154
+			if len(range_value) == 0 {
155
+				range_value = item.InspectValue
156
+			} else {
157
+				range_value = range_value + "," + item.InspectValue
158
+			}
159
+		}
160
+
161
+	}
162
+
163
+	data, _ := statistics_service.GetInspectionChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, project_id, item_id, range_type, range_value)
164
+	this.ServeSuccessJSON(map[string]interface{}{
165
+		"data": data,
166
+	})
167
+
168
+}
169
+func (this *PCIndexEvaluationApiController) GetInspectionChartTableData() {
170
+	adminUserInfo := this.GetAdminUserInfo()
171
+	start_time := this.GetString("start_time")
172
+	end_time := this.GetString("end_time")
173
+	patient_id, _ := this.GetInt64("patient_id")
174
+	page, _ := this.GetInt64("page")
175
+	limit, _ := this.GetInt64("limit")
176
+	project_id, _ := this.GetInt64("project_id")
177
+	item_id, _ := this.GetInt64("item_id")
178
+	range_value := this.GetString("range_value")
179
+	range_type, _ := this.GetInt("range_type")
180
+
181
+	if page == 0 {
182
+		page = 1
183
+	}
184
+	if limit == 0 {
185
+		limit = 20
186
+	}
187
+	timeLayout := "2006-01-02"
188
+	loc, _ := time.LoadLocation("Local")
189
+
190
+	var theStartTIme int64
191
+	if len(start_time) > 0 {
192
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
193
+		if err != nil {
194
+			utils.ErrorLog(err.Error())
195
+		}
196
+		theStartTIme = theTime.Unix()
197
+	}
198
+	var theEndtTIme int64
199
+	if len(end_time) > 0 {
200
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
201
+		if err != nil {
202
+			utils.ErrorLog(err.Error())
203
+		}
204
+		theEndtTIme = theTime.Unix()
205
+	}
206
+	data, total, _ := statistics_service.GetInspectionChartTableData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, project_id, item_id, patient_id, page, limit, range_type, range_value)
207
+	this.ServeSuccessJSON(map[string]interface{}{
208
+		"data":  data,
209
+		"total": total,
210
+	})
211
+
212
+}
213
+func (this *PCIndexEvaluationApiController) GetPatientInspectionChartData() {
214
+	adminUserInfo := this.GetAdminUserInfo()
215
+	start_time := this.GetString("start_time")
216
+	end_time := this.GetString("end_time")
217
+	project_id, _ := this.GetInt64("project_id")
218
+	item_id, _ := this.GetInt64("item_id")
219
+	patient_id, _ := this.GetInt64("patient_id")
220
+
221
+	timeLayout := "2006-01-02"
222
+	loc, _ := time.LoadLocation("Local")
223
+
224
+	var theStartTIme int64
225
+	if len(start_time) > 0 {
226
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
227
+		if err != nil {
228
+			utils.ErrorLog(err.Error())
229
+		}
230
+		theStartTIme = theTime.Unix()
231
+	}
232
+	var theEndtTIme int64
233
+	if len(end_time) > 0 {
234
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
235
+		if err != nil {
236
+			utils.ErrorLog(err.Error())
237
+		}
238
+		theEndtTIme = theTime.Unix()
239
+	}
240
+
241
+	data, _ := statistics_service.GetPatientInspectionChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, project_id, item_id, patient_id)
242
+	references, _ := statistics_service.FindOrgQualityControlStandardInspectionReferenceById(adminUserInfo.CurrentOrgId, project_id, item_id)
243
+
244
+	this.ServeSuccessJSON(map[string]interface{}{
245
+		"data":       data,
246
+		"references": references,
247
+	})
248
+
249
+}
250
+func (this *PCIndexEvaluationApiController) GetPatientInspectionBarChartData() {
251
+	adminUserInfo := this.GetAdminUserInfo()
252
+	start_time := this.GetString("start_time")
253
+	end_time := this.GetString("end_time")
254
+	project_id, _ := this.GetInt64("project_id")
255
+	item_id, _ := this.GetInt64("item_id")
256
+	range_type, _ := this.GetInt("range_type")
257
+	patient_id, _ := this.GetInt64("patient_id")
258
+
259
+	timeLayout := "2006-01-02"
260
+	loc, _ := time.LoadLocation("Local")
261
+
262
+	var theStartTIme int64
263
+	if len(start_time) > 0 {
264
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
265
+		if err != nil {
266
+			utils.ErrorLog(err.Error())
267
+		}
268
+		theStartTIme = theTime.Unix()
269
+	}
270
+	var theEndtTIme int64
271
+	if len(end_time) > 0 {
272
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
273
+		if err != nil {
274
+			utils.ErrorLog(err.Error())
275
+		}
276
+		theEndtTIme = theTime.Unix()
277
+	}
278
+
279
+	var range_value string
280
+	if range_type == 1 {
281
+		count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.CurrentOrgId)
282
+
283
+		if count <= 0 {
284
+			qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(0, project_id, item_id)
285
+			range_value = qcs.RangeMin + "," + qcs.RangeMax
286
+
287
+		} else {
288
+			qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
289
+			range_value = qcs.RangeMin + "," + qcs.RangeMax
290
+		}
291
+
292
+	} else {
293
+
294
+		inspection, _ := statistics_service.FindOrgInspectionReferenceRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
295
+		for _, item := range inspection {
296
+			if len(range_value) == 0 {
297
+				range_value = item.InspectValue
298
+			} else {
299
+				range_value = range_value + "," + item.InspectValue
300
+			}
301
+		}
302
+
303
+	}
304
+	data, _ := statistics_service.GetPatientInspectionBarChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, project_id, item_id, range_type, range_value, patient_id)
305
+	this.ServeSuccessJSON(map[string]interface{}{
306
+		"data": data,
307
+	})
308
+
309
+}
310
+
311
+func (this *PCIndexEvaluationApiController) GetAdminUser() {
312
+	admins, _ := statistics_service.GetAllAdminUser(this.GetAdminUserInfo().CurrentOrgId)
313
+	this.ServeSuccessJSON(map[string]interface{}{
314
+		"admin": admins,
315
+	})
316
+}
317
+
318
+func (this *PCIndexEvaluationApiController) GetDialysisProcessIndexChartData() {
319
+	adminUserInfo := this.GetAdminUserInfo()
320
+	statistics_type, _ := this.GetInt("statistics_type")
321
+	start_time := this.GetString("start_time")
322
+	end_time := this.GetString("end_time")
323
+	patient_id, _ := this.GetInt64("patient_id")
324
+	timeLayout := "2006-01-02"
325
+	loc, _ := time.LoadLocation("Local")
326
+
327
+	var theStartTIme int64
328
+	if len(start_time) > 0 {
329
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
330
+		if err != nil {
331
+			utils.ErrorLog(err.Error())
332
+		}
333
+		theStartTIme = theTime.Unix()
334
+	}
335
+	var theEndtTIme int64
336
+	if len(end_time) > 0 {
337
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
338
+		if err != nil {
339
+			utils.ErrorLog(err.Error())
340
+		}
341
+		theEndtTIme = theTime.Unix()
342
+	}
343
+
344
+	if patient_id == 0 {
345
+		patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.CurrentOrgId)
346
+		if patientInfo == nil {
347
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
348
+			return
349
+		}
350
+		if statistics_type == 9 || statistics_type == 10 {
351
+			data, _ := statistics_service.GetDialysisProcessIndexOtherChartData(adminUserInfo.CurrentOrgId, patientInfo.ID, theStartTIme, theEndtTIme, statistics_type)
352
+
353
+			this.ServeSuccessJSON(map[string]interface{}{
354
+				"data": data,
355
+			})
356
+		} else {
357
+
358
+			data, _ := statistics_service.GetDialysisProcessIndexChartData(adminUserInfo.CurrentOrgId, patientInfo.ID, theStartTIme, theEndtTIme, statistics_type)
359
+
360
+			this.ServeSuccessJSON(map[string]interface{}{
361
+				"data": data,
362
+			})
363
+
364
+		}
365
+	} else {
366
+		if statistics_type == 9 || statistics_type == 10 {
367
+			data, _ := statistics_service.GetDialysisProcessIndexOtherChartData(adminUserInfo.CurrentOrgId, patient_id, theStartTIme, theEndtTIme, statistics_type)
368
+
369
+			this.ServeSuccessJSON(map[string]interface{}{
370
+				"data": data,
371
+			})
372
+
373
+		} else {
374
+			data, _ := statistics_service.GetDialysisProcessIndexChartData(adminUserInfo.CurrentOrgId, patient_id, theStartTIme, theEndtTIme, statistics_type)
375
+
376
+			this.ServeSuccessJSON(map[string]interface{}{
377
+				"data": data,
378
+			})
379
+
380
+		}
381
+	}
382
+
383
+}
384
+func (this *PCIndexEvaluationApiController) GetDialysisProcessIndexTableData() {
385
+	adminUserInfo := this.GetAdminUserInfo()
386
+	start_time := this.GetString("start_time")
387
+	end_time := this.GetString("end_time")
388
+	patient_id, _ := this.GetInt64("patient_id")
389
+
390
+	page, _ := this.GetInt64("page")
391
+	limit, _ := this.GetInt64("limit")
392
+
393
+	if page == 0 {
394
+		page = 1
395
+	}
396
+	if limit == 0 {
397
+		limit = 20
398
+	}
399
+
400
+	timeLayout := "2006-01-02"
401
+	loc, _ := time.LoadLocation("Local")
402
+
403
+	var theStartTIme int64
404
+	if len(start_time) > 0 {
405
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
406
+		if err != nil {
407
+			utils.ErrorLog(err.Error())
408
+		}
409
+		theStartTIme = theTime.Unix()
410
+	}
411
+	var theEndtTIme int64
412
+	if len(end_time) > 0 {
413
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
414
+		if err != nil {
415
+			utils.ErrorLog(err.Error())
416
+		}
417
+		theEndtTIme = theTime.Unix()
418
+	}
419
+
420
+	if patient_id == 0 {
421
+		patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.CurrentOrgId)
422
+		if patientInfo == nil {
423
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
424
+			return
425
+		}
426
+
427
+		data, total, _ := statistics_service.GetDialysisProcessIndexTableData(adminUserInfo.CurrentOrgId, patientInfo.ID, page, limit, theStartTIme, theEndtTIme)
428
+
429
+		this.ServeSuccessJSON(map[string]interface{}{
430
+			"data":  data,
431
+			"total": total,
432
+		})
433
+
434
+	} else {
435
+		data, total, _ := statistics_service.GetDialysisProcessIndexTableData(adminUserInfo.CurrentOrgId, patient_id, page, limit, theStartTIme, theEndtTIme)
436
+		this.ServeSuccessJSON(map[string]interface{}{
437
+			"data":  data,
438
+			"total": total,
439
+		})
440
+
441
+	}
442
+
443
+}
444
+
445
+func (this *PCIndexEvaluationApiController) GetDialysisWatchChartData() {
446
+	adminUserInfo := this.GetAdminUserInfo()
447
+	statistics_type, _ := this.GetInt("statistics_type")
448
+	start_time := this.GetString("start_time")
449
+	end_time := this.GetString("end_time")
450
+	patient_id, _ := this.GetInt64("patient_id")
451
+	timeLayout := "2006-01-02"
452
+	loc, _ := time.LoadLocation("Local")
453
+
454
+	var theStartTIme int64
455
+	if len(start_time) > 0 {
456
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
457
+		if err != nil {
458
+			utils.ErrorLog(err.Error())
459
+		}
460
+		theStartTIme = theTime.Unix()
461
+	}
462
+	var theEndtTIme int64
463
+	if len(end_time) > 0 {
464
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
465
+		if err != nil {
466
+			utils.ErrorLog(err.Error())
467
+		}
468
+		theEndtTIme = theTime.Unix()
469
+	}
470
+
471
+	if patient_id == 0 {
472
+		patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.CurrentOrgId)
473
+		if patientInfo == nil {
474
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
475
+			return
476
+		}
477
+		data, _ := statistics_service.GetDialysisWatchChartData(adminUserInfo.CurrentOrgId, patientInfo.ID, theStartTIme, theEndtTIme, statistics_type)
478
+		this.ServeSuccessJSON(map[string]interface{}{
479
+			"data": data,
480
+		})
481
+	} else {
482
+		data, _ := statistics_service.GetDialysisWatchChartData(adminUserInfo.CurrentOrgId, patient_id, theStartTIme, theEndtTIme, statistics_type)
483
+		this.ServeSuccessJSON(map[string]interface{}{
484
+			"data": data,
485
+		})
486
+	}
487
+
488
+}
489
+func (this *PCIndexEvaluationApiController) GetDialysisWatchTableData() {
490
+	adminUserInfo := this.GetAdminUserInfo()
491
+	start_time := this.GetString("start_time")
492
+	end_time := this.GetString("end_time")
493
+	patient_id, _ := this.GetInt64("patient_id")
494
+	page, _ := this.GetInt64("page")
495
+	limit, _ := this.GetInt64("limit")
496
+
497
+	if page == 0 {
498
+		page = 1
499
+	}
500
+	if limit == 0 {
501
+		limit = 20
502
+	}
503
+	timeLayout := "2006-01-02"
504
+	loc, _ := time.LoadLocation("Local")
505
+
506
+	var theStartTIme int64
507
+	if len(start_time) > 0 {
508
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
509
+		if err != nil {
510
+			utils.ErrorLog(err.Error())
511
+		}
512
+		theStartTIme = theTime.Unix()
513
+	}
514
+	var theEndtTIme int64
515
+	if len(end_time) > 0 {
516
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
517
+		if err != nil {
518
+			utils.ErrorLog(err.Error())
519
+		}
520
+		theEndtTIme = theTime.Unix()
521
+	}
522
+
523
+	if patient_id == 0 {
524
+		patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.CurrentOrgId)
525
+		if patientInfo == nil {
526
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
527
+			return
528
+		}
529
+
530
+		data, total, _ := statistics_service.GetDialysisWatchTableData(adminUserInfo.CurrentOrgId, patientInfo.ID, page, limit, theStartTIme, theEndtTIme)
531
+
532
+		this.ServeSuccessJSON(map[string]interface{}{
533
+			"data":  data,
534
+			"total": total,
535
+		})
536
+
537
+	} else {
538
+
539
+		data, total, _ := statistics_service.GetDialysisWatchTableData(adminUserInfo.CurrentOrgId, patient_id, page, limit, theStartTIme, theEndtTIme)
540
+		this.ServeSuccessJSON(map[string]interface{}{
541
+			"data":  data,
542
+			"total": total,
543
+		})
544
+
545
+	}
546
+
547
+}
548
+
549
+func (this *PCIndexEvaluationApiController) GetDialysisBloodPressureChartData() {
550
+	adminUserInfo := this.GetAdminUserInfo()
551
+	statistics_type, _ := this.GetInt("statistics_type")
552
+	start_time := this.GetString("start_time")
553
+	end_time := this.GetString("end_time")
554
+	patient_id, _ := this.GetInt64("patient_id")
555
+
556
+	timeLayout := "2006-01-02"
557
+	loc, _ := time.LoadLocation("Local")
558
+
559
+	var theStartTIme int64
560
+	if len(start_time) > 0 {
561
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
562
+		if err != nil {
563
+			utils.ErrorLog(err.Error())
564
+		}
565
+		theStartTIme = theTime.Unix()
566
+	}
567
+	var theEndtTIme int64
568
+	if len(end_time) > 0 {
569
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
570
+		if err != nil {
571
+			utils.ErrorLog(err.Error())
572
+		}
573
+		theEndtTIme = theTime.Unix()
574
+	}
575
+
576
+	data, _ := statistics_service.GetBloodPressureChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, statistics_type, patient_id)
577
+	this.ServeSuccessJSON(map[string]interface{}{
578
+		"data": data,
579
+	})
580
+
581
+}
582
+func (this *PCIndexEvaluationApiController) GetDialysisBloodPressureTableData() {
583
+	adminUserInfo := this.GetAdminUserInfo()
584
+	start_time := this.GetString("start_time")
585
+	end_time := this.GetString("end_time")
586
+	patient_id, _ := this.GetInt64("patient_id")
587
+	page, _ := this.GetInt64("page")
588
+	limit, _ := this.GetInt64("limit")
589
+
590
+	if page == 0 {
591
+		page = 1
592
+	}
593
+	if limit == 0 {
594
+		limit = 20
595
+	}
596
+	timeLayout := "2006-01-02"
597
+	loc, _ := time.LoadLocation("Local")
598
+
599
+	var theStartTIme int64
600
+	if len(start_time) > 0 {
601
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
602
+		if err != nil {
603
+			utils.ErrorLog(err.Error())
604
+		}
605
+		theStartTIme = theTime.Unix()
606
+	}
607
+	var theEndtTIme int64
608
+	if len(end_time) > 0 {
609
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
610
+		if err != nil {
611
+			utils.ErrorLog(err.Error())
612
+		}
613
+		theEndtTIme = theTime.Unix()
614
+	}
615
+
616
+	data, total, _ := statistics_service.GetBloodPressureTableData(adminUserInfo.CurrentOrgId, patient_id, page, limit, theStartTIme, theEndtTIme)
617
+	this.ServeSuccessJSON(map[string]interface{}{
618
+		"data":  data,
619
+		"total": total,
620
+	})
621
+
622
+}
623
+func (this *PCIndexEvaluationApiController) GetDialysisPatientBloodPressureChartData() {
624
+	adminUserInfo := this.GetAdminUserInfo()
625
+	statistics_type, _ := this.GetInt("statistics_type")
626
+	start_time := this.GetString("start_time")
627
+	end_time := this.GetString("end_time")
628
+	patient_id, _ := this.GetInt64("patient_id")
629
+
630
+	timeLayout := "2006-01-02"
631
+	loc, _ := time.LoadLocation("Local")
632
+
633
+	var theStartTIme int64
634
+	if len(start_time) > 0 {
635
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
636
+		if err != nil {
637
+			utils.ErrorLog(err.Error())
638
+		}
639
+		theStartTIme = theTime.Unix()
640
+	}
641
+	var theEndtTIme int64
642
+	if len(end_time) > 0 {
643
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
644
+		if err != nil {
645
+			utils.ErrorLog(err.Error())
646
+		}
647
+		theEndtTIme = theTime.Unix()
648
+	}
649
+
650
+	data, _ := statistics_service.GetPatientBloodPressureChartData(adminUserInfo.CurrentOrgId, patient_id, theStartTIme, theEndtTIme, statistics_type)
651
+	this.ServeSuccessJSON(map[string]interface{}{
652
+		"data": data,
653
+	})
654
+
655
+}
656
+
657
+func (this *PCIndexEvaluationApiController) GetDialysisWeightChartData() {
658
+	adminUserInfo := this.GetAdminUserInfo()
659
+	statistics_type, _ := this.GetInt("statistics_type")
660
+	start_time := this.GetString("start_time")
661
+	end_time := this.GetString("end_time")
662
+	timeLayout := "2006-01-02"
663
+	loc, _ := time.LoadLocation("Local")
664
+
665
+	var theStartTIme int64
666
+	if len(start_time) > 0 {
667
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
668
+		if err != nil {
669
+			utils.ErrorLog(err.Error())
670
+		}
671
+		theStartTIme = theTime.Unix()
672
+	}
673
+	var theEndtTIme int64
674
+	if len(end_time) > 0 {
675
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
676
+		if err != nil {
677
+			utils.ErrorLog(err.Error())
678
+		}
679
+		theEndtTIme = theTime.Unix()
680
+	}
681
+
682
+	data, _ := statistics_service.GetDialysisWeightChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, statistics_type)
683
+	this.ServeSuccessJSON(map[string]interface{}{
684
+		"data": data,
685
+	})
686
+
687
+}
688
+func (this *PCIndexEvaluationApiController) GetDialysisWeightTableData() {
689
+	adminUserInfo := this.GetAdminUserInfo()
690
+	start_time := this.GetString("start_time")
691
+	end_time := this.GetString("end_time")
692
+	patient_id, _ := this.GetInt64("patient_id")
693
+	page, _ := this.GetInt64("page")
694
+	limit, _ := this.GetInt64("limit")
695
+
696
+	if page == 0 {
697
+		page = 1
698
+	}
699
+	if limit == 0 {
700
+		limit = 20
701
+	}
702
+	timeLayout := "2006-01-02"
703
+	loc, _ := time.LoadLocation("Local")
704
+
705
+	var theStartTIme int64
706
+	if len(start_time) > 0 {
707
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
708
+		if err != nil {
709
+			utils.ErrorLog(err.Error())
710
+		}
711
+		theStartTIme = theTime.Unix()
712
+	}
713
+	var theEndtTIme int64
714
+	if len(end_time) > 0 {
715
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
716
+		if err != nil {
717
+			utils.ErrorLog(err.Error())
718
+		}
719
+		theEndtTIme = theTime.Unix()
720
+	}
721
+
722
+	data, total, _ := statistics_service.GetDialysisWeightTableData(adminUserInfo.CurrentOrgId, patient_id, page, limit, theStartTIme, theEndtTIme)
723
+	this.ServeSuccessJSON(map[string]interface{}{
724
+		"data":  data,
725
+		"total": total,
726
+	})
727
+}
728
+func (this *PCIndexEvaluationApiController) GetDialysisPatientWeightChartData() {
729
+	adminUserInfo := this.GetAdminUserInfo()
730
+	statistics_type, _ := this.GetInt("statistics_type")
731
+	start_time := this.GetString("start_time")
732
+	end_time := this.GetString("end_time")
733
+	patient_id, _ := this.GetInt64("patient_id")
734
+
735
+	timeLayout := "2006-01-02"
736
+	loc, _ := time.LoadLocation("Local")
737
+
738
+	var theStartTIme int64
739
+	if len(start_time) > 0 {
740
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
741
+		if err != nil {
742
+			utils.ErrorLog(err.Error())
743
+		}
744
+		theStartTIme = theTime.Unix()
745
+	}
746
+	var theEndtTIme int64
747
+	if len(end_time) > 0 {
748
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
749
+		if err != nil {
750
+			utils.ErrorLog(err.Error())
751
+		}
752
+		theEndtTIme = theTime.Unix()
753
+	}
754
+
755
+	data, _ := statistics_service.GetPatientDialysisWeightChartData(adminUserInfo.CurrentOrgId, patient_id, theStartTIme, theEndtTIme, statistics_type)
756
+	this.ServeSuccessJSON(map[string]interface{}{
757
+		"data": data,
758
+	})
759
+
760
+}
761
+
762
+func (this *PCIndexEvaluationApiController) GetDoctorWorkloadChartData() {
763
+	adminUserInfo := this.GetAdminUserInfo()
764
+	statistics_type, _ := this.GetInt("statistics_type")
765
+	start_time := this.GetString("start_time")
766
+	admin_user_id, _ := this.GetInt64("admin_user_id")
767
+
768
+	end_time := this.GetString("end_time")
769
+	timeLayout := "2006-01-02"
770
+	loc, _ := time.LoadLocation("Local")
771
+
772
+	var theStartTIme int64
773
+	if len(start_time) > 0 {
774
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
775
+		if err != nil {
776
+			utils.ErrorLog(err.Error())
777
+		}
778
+		theStartTIme = theTime.Unix()
779
+	}
780
+	var theEndtTIme int64
781
+	if len(end_time) > 0 {
782
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
783
+		if err != nil {
784
+			utils.ErrorLog(err.Error())
785
+		}
786
+		theEndtTIme = theTime.Unix()
787
+	}
788
+
789
+	data, _ := statistics_service.GetDoctorWorkloadChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, statistics_type, admin_user_id)
790
+	this.ServeSuccessJSON(map[string]interface{}{
791
+		"data": data,
792
+	})
793
+
794
+}
795
+func (this *PCIndexEvaluationApiController) GetDoctorWorkloadTableData() {
796
+	adminUserInfo := this.GetAdminUserInfo()
797
+	start_time := this.GetString("start_time")
798
+	end_time := this.GetString("end_time")
799
+	admin_user_id, _ := this.GetInt64("admin_user_id")
800
+	page, _ := this.GetInt64("page")
801
+	limit, _ := this.GetInt64("limit")
802
+
803
+	if page == 0 {
804
+		page = 1
805
+	}
806
+	if limit == 0 {
807
+		limit = 20
808
+	}
809
+	timeLayout := "2006-01-02"
810
+	loc, _ := time.LoadLocation("Local")
811
+
812
+	var theStartTIme int64
813
+	if len(start_time) > 0 {
814
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
815
+		if err != nil {
816
+			utils.ErrorLog(err.Error())
817
+		}
818
+		theStartTIme = theTime.Unix()
819
+	}
820
+	var theEndtTIme int64
821
+	if len(end_time) > 0 {
822
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
823
+		if err != nil {
824
+			utils.ErrorLog(err.Error())
825
+		}
826
+		theEndtTIme = theTime.Unix()
827
+	}
828
+	data, _ := statistics_service.GetDoctorWorkloadTableData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, admin_user_id)
829
+	this.ServeSuccessJSON(map[string]interface{}{
830
+		"data": data,
831
+	})
832
+}
833
+
834
+func (this *PCIndexEvaluationApiController) GetNurseWorkloadChartData() {
835
+	adminUserInfo := this.GetAdminUserInfo()
836
+	statistics_type, _ := this.GetInt("statistics_type")
837
+	start_time := this.GetString("start_time")
838
+	end_time := this.GetString("end_time")
839
+	admin_user_id, _ := this.GetInt64("admin_user_id")
840
+
841
+	timeLayout := "2006-01-02"
842
+	loc, _ := time.LoadLocation("Local")
843
+
844
+	var theStartTIme int64
845
+	if len(start_time) > 0 {
846
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
847
+		if err != nil {
848
+			utils.ErrorLog(err.Error())
849
+		}
850
+		theStartTIme = theTime.Unix()
851
+	}
852
+	var theEndtTIme int64
853
+	if len(end_time) > 0 {
854
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
855
+		if err != nil {
856
+			utils.ErrorLog(err.Error())
857
+		}
858
+		theEndtTIme = theTime.Unix()
859
+	}
860
+
861
+	data, _ := statistics_service.GetNurseWorkloadChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, statistics_type, admin_user_id)
862
+
863
+	this.ServeSuccessJSON(map[string]interface{}{
864
+		"data": data,
865
+	})
866
+
867
+}
868
+func (this *PCIndexEvaluationApiController) GetNurseWorkloadTableData() {
869
+	adminUserInfo := this.GetAdminUserInfo()
870
+	start_time := this.GetString("start_time")
871
+	end_time := this.GetString("end_time")
872
+	admin_user_id, _ := this.GetInt64("admin_user_id")
873
+	page, _ := this.GetInt64("page")
874
+	limit, _ := this.GetInt64("limit")
875
+
876
+	if page == 0 {
877
+		page = 1
878
+	}
879
+	if limit == 0 {
880
+		limit = 5
881
+	}
882
+	timeLayout := "2006-01-02"
883
+	loc, _ := time.LoadLocation("Local")
884
+
885
+	var theStartTIme int64
886
+	if len(start_time) > 0 {
887
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
888
+		if err != nil {
889
+			utils.ErrorLog(err.Error())
890
+		}
891
+		theStartTIme = theTime.Unix()
892
+	}
893
+	var theEndtTIme int64
894
+	if len(end_time) > 0 {
895
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
896
+		if err != nil {
897
+			utils.ErrorLog(err.Error())
898
+		}
899
+		theEndtTIme = theTime.Unix()
900
+	}
901
+	data, total, _ := statistics_service.GetNurseWorkloadTableData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, admin_user_id, page, limit)
902
+	dialysisCount, _ := statistics_service.GetOrderDialysisCount(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme)
903
+	this.ServeSuccessJSON(map[string]interface{}{
904
+		"data":          data,
905
+		"total":         total,
906
+		"dialysisCount": dialysisCount,
907
+	})
908
+}
909
+
910
+func (this *PCIndexEvaluationApiController) GetDefaultPatient() {
911
+	adminUserInfo := this.GetAdminUserInfo()
912
+	patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.CurrentOrgId)
913
+	if patientInfo == nil {
914
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
915
+		return
916
+	}
917
+
918
+	this.ServeSuccessJSON(map[string]interface{}{
919
+		"patient": patientInfo,
920
+	})
921
+
922
+}

+ 222 - 0
controllers/print_data_api_controller.go View File

@@ -0,0 +1,222 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	service "Xcx_New/service/print_data_service/schedule_dialysis"
6
+	"Xcx_New/utils"
7
+	"fmt"
8
+	"strings"
9
+	"time"
10
+
11
+	"github.com/astaxie/beego"
12
+)
13
+
14
+func PrintDataAPIControllerRegistRouters() {
15
+	beego.Router("/api/print/schedule/dialysis", &PrintDataAPIController{}, "get:ScheduleDialysisRecordPrintData")
16
+	beego.Router("/api/print/stock", &PrintDataAPIController{}, "get:StockRecordPrintData")
17
+	beego.Router("/api/print/course", &PrintDataAPIController{}, "get:CourseRecordPrintData")
18
+	beego.Router("/api/print/getlastafterweight", &PrintDataAPIController{}, "get:GetLastAfterWeight")
19
+	beego.Router("/api/stock/getgooddetailprintlist", &PrintDataAPIController{}, "get:GetGoodDetailPrintList")
20
+
21
+}
22
+
23
+type PrintDataAPIController struct {
24
+	BaseAuthAPIController
25
+}
26
+
27
+// /api/print/schedule/dialysis [get]
28
+// @param ids:string 排班 id,以逗号隔开 ("1,2,3")
29
+func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
30
+	schIDStr := this.GetString("ids")
31
+
32
+	if len(schIDStr) == 0 {
33
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
34
+		return
35
+	}
36
+
37
+	idStrs := strings.Split(schIDStr, ",")
38
+	adminUserInfo := this.GetAdminUserInfo()
39
+	schedules, getScheduleErr := service.GetSchedules(adminUserInfo.CurrentOrgId, idStrs)
40
+
41
+	if getScheduleErr != nil {
42
+		this.ErrorLog("获取打印透析记录失败:%v", getScheduleErr)
43
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
44
+		return
45
+	}
46
+
47
+	medicalStaffs, getMedicalStaffErr := service.GetMedicalStaffs(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
48
+	if getMedicalStaffErr != nil {
49
+		this.ErrorLog("获取医护人员失败:%v", getMedicalStaffErr)
50
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
51
+		return
52
+	}
53
+
54
+	adminUser, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
55
+	name, getScheduleErr := service.GetAllName(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
56
+	templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
57
+
58
+	this.ServeSuccessJSON(map[string]interface{}{
59
+		"schedules":      schedules,
60
+		"medical_staffs": medicalStaffs,
61
+		"users":          adminUser,
62
+		"templateInfo":   templateInfo,
63
+		"name":           name,
64
+	})
65
+}
66
+
67
+func (this *PrintDataAPIController) StockRecordPrintData() {
68
+	types, _ := this.GetInt("type", 0)
69
+	start_time := this.GetString("start_time")
70
+	end_time := this.GetString("end_time")
71
+	adminUserInfo := this.GetAdminUserInfo()
72
+
73
+	timeLayout := "2006-01-02"
74
+	loc, _ := time.LoadLocation("Local")
75
+	var startTime int64
76
+	if len(start_time) > 0 {
77
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
78
+		if err != nil {
79
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
80
+			return
81
+		}
82
+		startTime = theTime.Unix()
83
+	}
84
+	var endTime int64
85
+	if len(end_time) > 0 {
86
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
87
+		if err != nil {
88
+			utils.ErrorLog(err.Error())
89
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
90
+			return
91
+		}
92
+		endTime = theTime.Unix()
93
+	}
94
+
95
+	list, err := service.FindPrintStockGoodInfoByType(types, startTime, endTime, adminUserInfo.CurrentOrgId)
96
+	stockTotal, err := service.GetOutStockTotalCountTwo(startTime, endTime, adminUserInfo.CurrentOrgId)
97
+
98
+	info, err := service.GetCoutWareseOutInfo(startTime, endTime, adminUserInfo.CurrentOrgId)
99
+
100
+	infomationList, err := service.GetGoodInfomationList(adminUserInfo.CurrentOrgId)
101
+	if err != nil {
102
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
103
+	} else {
104
+		this.ServeSuccessJSON(map[string]interface{}{
105
+			"list":           list,
106
+			"type":           types,
107
+			"stockTotal":     stockTotal,
108
+			"info":           info,
109
+			"orgid":          adminUserInfo.CurrentOrgId,
110
+			"infomationList": infomationList,
111
+		})
112
+	}
113
+}
114
+
115
+func (this *PrintDataAPIController) CourseRecordPrintData() {
116
+	id, _ := this.GetInt64("id", 0)
117
+	adminUserInfo := this.GetAdminUserInfo()
118
+
119
+	if id == 0 {
120
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
121
+		return
122
+	}
123
+	timeLayout := "2006-01-02 15:04:05"
124
+	record, err := service.GetPatientCoursesRecords(adminUserInfo.CurrentOrgId, id)
125
+	dataTimeStr := time.Unix(record.RecordTime, 0).Format(timeLayout) //设置时间戳 使用模板格式化为日期字符串
126
+	tempTime := strings.Split(dataTimeStr, " ")
127
+
128
+	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", tempTime[0])
129
+	if parseDateErr != nil {
130
+		this.ErrorLog("日期(%v)解析错误:%v", tempTime[0], parseDateErr)
131
+		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
132
+		//return
133
+	}
134
+
135
+	patient, _ := service.FindPatientWithDeviceById(adminUserInfo.CurrentOrgId, record.PatientID, recordDate.Unix())
136
+	if err != nil {
137
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
138
+		return
139
+	} else {
140
+		this.ServeSuccessJSON(map[string]interface{}{
141
+			"record":  record,
142
+			"patient": patient,
143
+		})
144
+	}
145
+}
146
+
147
+func (this *PrintDataAPIController) GetLastAfterWeight() {
148
+	id, _ := this.GetInt64("id")
149
+	fmt.Print("id", id)
150
+	assmentdate, _ := this.GetInt64("assmentdate")
151
+
152
+	adminUserInfo := this.GetAdminUserInfo()
153
+	org_id := adminUserInfo.CurrentOrgId
154
+	weight, err := service.GetLastAfterWeight(org_id, id, assmentdate)
155
+	//fmt.Print("errr-------------",err)
156
+	if err != nil {
157
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
158
+		return
159
+	}
160
+	this.ServeSuccessJSON(map[string]interface{}{
161
+		"weight": weight,
162
+	})
163
+}
164
+
165
+func (this *PrintDataAPIController) GetGoodDetailPrintList() {
166
+
167
+	types, _ := this.GetInt("type", 0)
168
+	start_time := this.GetString("start_time")
169
+	end_time := this.GetString("end_time")
170
+	adminUserInfo := this.GetAdminUserInfo()
171
+
172
+	timeLayout := "2006-01-02"
173
+	loc, _ := time.LoadLocation("Local")
174
+	var startTime int64
175
+	if len(start_time) > 0 {
176
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
177
+		if err != nil {
178
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
179
+			return
180
+		}
181
+		startTime = theTime.Unix()
182
+	}
183
+	var endTime int64
184
+	if len(end_time) > 0 {
185
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
186
+		if err != nil {
187
+			utils.ErrorLog(err.Error())
188
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
189
+			return
190
+		}
191
+		endTime = theTime.Unix()
192
+	}
193
+	limit, _ := this.GetInt64("limit")
194
+	page, _ := this.GetInt64("page")
195
+
196
+	//入库详情
197
+	if types == 1 {
198
+		list, err := service.GetWarehouseInfoGoodDetailPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, limit, page)
199
+		if err != nil {
200
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
201
+			return
202
+		}
203
+		this.ServeSuccessJSON(map[string]interface{}{
204
+			"list": list,
205
+		})
206
+	}
207
+
208
+	//出库详情
209
+	if types == 2 {
210
+		list, err := service.GetWarehouseOutInfoGoodDetailPrintList(adminUserInfo.CurrentOrgId, startTime, endTime, limit, page)
211
+		stockTotal, err := service.GetOutStockTotalCountTwo(startTime, endTime, adminUserInfo.CurrentOrgId)
212
+		if err != nil {
213
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
214
+			return
215
+		}
216
+		this.ServeSuccessJSON(map[string]interface{}{
217
+			"list":       list,
218
+			"stockTotal": stockTotal,
219
+		})
220
+	}
221
+
222
+}

File diff suppressed because it is too large
+ 1745 - 0
controllers/public_api_controller.go


+ 864 - 0
controllers/qcd_api_controller.go View File

@@ -0,0 +1,864 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/service"
6
+	"Xcx_New/utils"
7
+	"time"
8
+
9
+	"github.com/astaxie/beego"
10
+)
11
+
12
+type QcdApiController struct {
13
+	BaseAuthAPIController
14
+}
15
+
16
+func QcdApiRegistRouters() {
17
+	beego.Router("/api/qcd/dialysistotaldata", &QcdApiController{}, "get:GetDialysisTotalData")
18
+	beego.Router("/api/qcd/processindicatorsdata", &QcdApiController{}, "get:GetProcessIndicatorsData")
19
+	beego.Router("/api/qcd/oicdata", &QcdApiController{}, "get:GetOICData")
20
+	beego.Router("/api/qcd/oiqdata", &QcdApiController{}, "get:GetOIQData")
21
+	beego.Router("/api/qcd/patotaldata", &QcdApiController{}, "get:GetPATotalData")
22
+	beego.Router("/api/qcd/padialysisagedata", &QcdApiController{}, "get:GetPADialysisAgeData")
23
+	beego.Router("/api/qcd/paweightdata", &QcdApiController{}, "get:GetPAWeightData")
24
+	beego.Router("/api/qcd/pabloodpressuredata", &QcdApiController{}, "get:GetPABloodPressureData")
25
+	beego.Router("/api/qcd/pacomplicationdata", &QcdApiController{}, "get:GetPAComplicationData")
26
+	beego.Router("/api/qcd/painfectiousdiseasesdata", &QcdApiController{}, "get:GetPAInfectiousDiseasesData")
27
+	beego.Router("/api/qcd/papersonlapsetdata", &QcdApiController{}, "get:GetPersonLapsetoData")
28
+	beego.Router("/api/qcd/papersonweightdata", &QcdApiController{}, "get:GetPersonWeightData")
29
+	beego.Router("/api/qcd/papersonbloodpressuredata", &QcdApiController{}, "get:GetPersonBloodPressureData")
30
+	beego.Router("/api/qcd/papersonicdata", &QcdApiController{}, "get:GetPersonICData")
31
+	beego.Router("/api/qcd/papersonadvicedata", &QcdApiController{}, "get:GetPersonAdviceData")
32
+}
33
+
34
+func (c *QcdApiController) GetDialysisTotalData() {
35
+	page, _ := c.GetInt64("page", 1)
36
+	limit, _ := c.GetInt64("limit", 10)
37
+	lapseto, _ := c.GetInt64("lapseto", 0)
38
+	statisticalMethod, _ := c.GetInt64("statistical_method", 0)
39
+	modeID, _ := c.GetInt64("mode_id", 0)
40
+	startTime := c.GetString("start_time", "")
41
+	endTime := c.GetString("end_time", "")
42
+
43
+	if page <= 0 {
44
+		page = 1
45
+	}
46
+	if limit <= 0 {
47
+		limit = 10
48
+	}
49
+
50
+	adminUserInfo := c.GetAdminUserInfo()
51
+
52
+	timeLayout := "2006-01-02"
53
+	loc, _ := time.LoadLocation("Local")
54
+
55
+	var isStartTime bool
56
+	var theStartTIme int64
57
+	if len(startTime) > 0 {
58
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
59
+		if err != nil {
60
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
61
+			return
62
+		}
63
+		isStartTime = true
64
+		theStartTIme = theTime.Unix()
65
+	}
66
+	var isEndTime bool
67
+	var theEndtTIme int64
68
+	if len(endTime) > 0 {
69
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
70
+		if err != nil {
71
+			utils.ErrorLog(err.Error())
72
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
73
+			return
74
+		}
75
+		isEndTime = true
76
+		theEndtTIme = theTime.Unix()
77
+	}
78
+
79
+	data, ttd, total, _ := service.GetDialysisTotalData(adminUserInfo.CurrentOrgId, page, limit, lapseto, statisticalMethod, modeID, theStartTIme, theEndtTIme, isStartTime, isEndTime)
80
+
81
+	c.ServeSuccessJSON(map[string]interface{}{
82
+		"dtd":   data,
83
+		"ttd":   ttd,
84
+		"total": total,
85
+	})
86
+	return
87
+}
88
+
89
+func (c *QcdApiController) GetProcessIndicatorsData() {
90
+	page, _ := c.GetInt64("page", 1)
91
+	limit, _ := c.GetInt64("limit", 10)
92
+	lapseto, _ := c.GetInt64("lapseto", 0)
93
+	dialysisAge, _ := c.GetInt64("dialysis_age", 0)
94
+	projectID, _ := c.GetInt64("project_id", 0)
95
+	startTime := c.GetString("start_time", "")
96
+	endTime := c.GetString("end_time", "")
97
+
98
+	if page <= 0 {
99
+		page = 1
100
+	}
101
+	if limit <= 0 {
102
+		limit = 10
103
+	}
104
+
105
+	adminUserInfo := c.GetAdminUserInfo()
106
+
107
+	timeLayout := "2006-01-02"
108
+	loc, _ := time.LoadLocation("Local")
109
+
110
+	var isStartTime bool
111
+	var theStartTIme int64
112
+	if len(startTime) > 0 {
113
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
114
+		if err != nil {
115
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
116
+			return
117
+		}
118
+		isStartTime = true
119
+		theStartTIme = theTime.Unix()
120
+	}
121
+	var isEndTime bool
122
+	var theEndtTIme int64
123
+	if len(endTime) > 0 {
124
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
125
+		if err != nil {
126
+			utils.ErrorLog(err.Error())
127
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
128
+			return
129
+		}
130
+		isEndTime = true
131
+		theEndtTIme = theTime.Unix()
132
+	}
133
+
134
+	inspections, references, patients, counts, total, err := service.GetProcessIndicatorsData(adminUserInfo.CurrentOrgId, page, limit, lapseto, dialysisAge, projectID, theStartTIme, theEndtTIme, isStartTime, isEndTime)
135
+	if err != nil {
136
+		utils.ErrorLog(err.Error())
137
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
138
+		return
139
+	}
140
+	c.ServeSuccessJSON(map[string]interface{}{
141
+		"inspections":     inspections,
142
+		"references":      references,
143
+		"patients":        patients,
144
+		"unfinishedcount": counts[0].Count,
145
+		"total":           total,
146
+	})
147
+	return
148
+}
149
+
150
+func (c *QcdApiController) GetOICData() {
151
+	page, _ := c.GetInt64("page", 1)
152
+	limit, _ := c.GetInt64("limit", 10)
153
+	lapseto, _ := c.GetInt64("lapseto", 0)
154
+	dialysisAge, _ := c.GetInt64("dialysis_age", 0)
155
+	projectID, _ := c.GetInt64("project_id", 0)
156
+	itemID, _ := c.GetInt64("item_id", 0)
157
+	startTime := c.GetString("start_time", "")
158
+	endTime := c.GetString("end_time", "")
159
+
160
+	if page <= 0 {
161
+		page = 1
162
+	}
163
+	if limit <= 0 {
164
+		limit = 10
165
+	}
166
+
167
+	adminUserInfo := c.GetAdminUserInfo()
168
+
169
+	timeLayout := "2006-01-02"
170
+	loc, _ := time.LoadLocation("Local")
171
+
172
+	var isStartTime bool
173
+	var theStartTIme int64
174
+	if len(startTime) > 0 {
175
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
176
+		if err != nil {
177
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
178
+			return
179
+		}
180
+		isStartTime = true
181
+		theStartTIme = theTime.Unix()
182
+	}
183
+	var isEndTime bool
184
+	var theEndtTIme int64
185
+	if len(endTime) > 0 {
186
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
187
+		if err != nil {
188
+			utils.ErrorLog(err.Error())
189
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
190
+			return
191
+		}
192
+		isEndTime = true
193
+		theEndtTIme = theTime.Unix()
194
+	}
195
+
196
+	inspections, references, patients, counts, total, err := service.GetOICData(adminUserInfo.CurrentOrgId, page, limit, lapseto, dialysisAge, projectID, itemID, theStartTIme, theEndtTIme, isStartTime, isEndTime)
197
+	if err != nil {
198
+		utils.ErrorLog(err.Error())
199
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
200
+		return
201
+	}
202
+	c.ServeSuccessJSON(map[string]interface{}{
203
+		"inspections":     inspections,
204
+		"references":      references,
205
+		"patients":        patients,
206
+		"unfinishedcount": counts[0].Count,
207
+		"total":           total,
208
+	})
209
+	return
210
+}
211
+
212
+func (c *QcdApiController) GetOIQData() {
213
+	page, _ := c.GetInt64("page", 1)
214
+	limit, _ := c.GetInt64("limit", 10)
215
+	projectID, _ := c.GetInt64("project_id", 0)
216
+	startTime := c.GetString("start_time", "")
217
+	endTime := c.GetString("end_time", "")
218
+	searchKey := c.GetString("search", "")
219
+
220
+	if page <= 0 {
221
+		page = 1
222
+	}
223
+	if limit <= 0 {
224
+		limit = 10
225
+	}
226
+
227
+	adminUserInfo := c.GetAdminUserInfo()
228
+
229
+	timeLayout := "2006-01-02"
230
+	loc, _ := time.LoadLocation("Local")
231
+
232
+	var isStartTime bool
233
+	var theStartTIme int64
234
+	if len(startTime) > 0 {
235
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
236
+		if err != nil {
237
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
238
+			return
239
+		}
240
+		isStartTime = true
241
+		theStartTIme = theTime.Unix()
242
+	}
243
+	var isEndTime bool
244
+	var theEndtTIme int64
245
+	if len(endTime) > 0 {
246
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
247
+		if err != nil {
248
+			utils.ErrorLog(err.Error())
249
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
250
+			return
251
+		}
252
+		isEndTime = true
253
+		theEndtTIme = theTime.Unix()
254
+	}
255
+
256
+	inspections, references, patients, total, err := service.GetOIQData(adminUserInfo.CurrentOrgId, page, limit, projectID, theStartTIme, theEndtTIme, isStartTime, isEndTime, searchKey)
257
+	if err != nil {
258
+		utils.ErrorLog(err.Error())
259
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
260
+		return
261
+	}
262
+	c.ServeSuccessJSON(map[string]interface{}{
263
+		"inspections": inspections,
264
+		"references":  references,
265
+		"patients":    patients,
266
+		"total":       total,
267
+	})
268
+	return
269
+}
270
+
271
+func (c *QcdApiController) GetPATotalData() {
272
+	page, _ := c.GetInt64("page", 1)
273
+	limit, _ := c.GetInt64("limit", 10)
274
+	startTime := c.GetString("start_time", "")
275
+	endTime := c.GetString("end_time", "")
276
+	searchKey := c.GetString("search", "")
277
+	age, _ := c.GetInt64("age", 0)
278
+	lapseto, _ := c.GetInt64("lapseto", 0)
279
+	source, _ := c.GetInt64("source", 0)
280
+
281
+	if page <= 0 {
282
+		page = 1
283
+	}
284
+	if limit <= 0 {
285
+		limit = 10
286
+	}
287
+
288
+	adminUserInfo := c.GetAdminUserInfo()
289
+
290
+	timeLayout := "2006-01-02"
291
+	loc, _ := time.LoadLocation("Local")
292
+
293
+	var isStartTime bool
294
+	var theStartTIme int64
295
+	if len(startTime) > 0 {
296
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
297
+		if err != nil {
298
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
299
+			return
300
+		}
301
+		isStartTime = true
302
+		theStartTIme = theTime.Unix()
303
+	}
304
+	var isEndTime bool
305
+	var theEndtTIme int64
306
+	if len(endTime) > 0 {
307
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
308
+		if err != nil {
309
+			utils.ErrorLog(err.Error())
310
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
311
+			return
312
+		}
313
+		isEndTime = true
314
+		theEndtTIme = theTime.Unix()
315
+	}
316
+
317
+	patients, lapsetoOut, lapsetoIn, total, err := service.GetPATotalData(adminUserInfo.CurrentOrgId, page, limit, lapseto, source, age, theStartTIme, theEndtTIme, isStartTime, isEndTime, searchKey)
318
+	if err != nil {
319
+		utils.ErrorLog(err.Error())
320
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
321
+		return
322
+	}
323
+	c.ServeSuccessJSON(map[string]interface{}{
324
+		"patients":   patients,
325
+		"total":      total,
326
+		"lapsetoOut": lapsetoOut,
327
+		"lapsetoIn":  lapsetoIn,
328
+	})
329
+	return
330
+}
331
+
332
+func (c *QcdApiController) GetPADialysisAgeData() {
333
+	page, _ := c.GetInt64("page", 1)
334
+	limit, _ := c.GetInt64("limit", 10)
335
+	startTime := c.GetString("start_time", "")
336
+	endTime := c.GetString("end_time", "")
337
+	age, _ := c.GetInt64("age", 0)
338
+	dialysisAge, _ := c.GetInt64("dialysis_age", 0)
339
+	lapseto, _ := c.GetInt64("lapseto", 0)
340
+
341
+	if page <= 0 {
342
+		page = 1
343
+	}
344
+	if limit <= 0 {
345
+		limit = 10
346
+	}
347
+
348
+	adminUserInfo := c.GetAdminUserInfo()
349
+
350
+	timeLayout := "2006-01-02"
351
+	loc, _ := time.LoadLocation("Local")
352
+
353
+	var isStartTime bool
354
+	var theStartTIme int64
355
+	if len(startTime) > 0 {
356
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
357
+		if err != nil {
358
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
359
+			return
360
+		}
361
+		isStartTime = true
362
+		theStartTIme = theTime.Unix()
363
+	}
364
+	var isEndTime bool
365
+	var theEndtTIme int64
366
+	if len(endTime) > 0 {
367
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
368
+		if err != nil {
369
+			utils.ErrorLog(err.Error())
370
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
371
+			return
372
+		}
373
+		isEndTime = true
374
+		theEndtTIme = theTime.Unix()
375
+	}
376
+
377
+	patients, counts, total, err := service.GetPADialysisAgeData(adminUserInfo.CurrentOrgId, page, limit, lapseto, age, dialysisAge, theStartTIme, theEndtTIme, isStartTime, isEndTime)
378
+	if err != nil {
379
+		utils.ErrorLog(err.Error())
380
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
381
+		return
382
+	}
383
+	c.ServeSuccessJSON(map[string]interface{}{
384
+		"patients": patients,
385
+		"counts":   counts,
386
+		"total":    total,
387
+	})
388
+	return
389
+}
390
+
391
+func (c *QcdApiController) GetPAWeightData() {
392
+	page, _ := c.GetInt64("page", 1)
393
+	limit, _ := c.GetInt64("limit", 10)
394
+	startTime := c.GetString("start_time", "")
395
+	endTime := c.GetString("end_time", "")
396
+	age, _ := c.GetInt64("age", 0)
397
+	lapseto, _ := c.GetInt64("lapseto", 0)
398
+
399
+	if page <= 0 {
400
+		page = 1
401
+	}
402
+	if limit <= 0 {
403
+		limit = 10
404
+	}
405
+
406
+	adminUserInfo := c.GetAdminUserInfo()
407
+
408
+	timeLayout := "2006-01-02"
409
+	loc, _ := time.LoadLocation("Local")
410
+
411
+	var isStartTime bool
412
+	var theStartTIme int64
413
+	if len(startTime) > 0 {
414
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
415
+		if err != nil {
416
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
417
+			return
418
+		}
419
+		isStartTime = true
420
+		theStartTIme = theTime.Unix()
421
+	}
422
+	var isEndTime bool
423
+	var theEndtTIme int64
424
+	if len(endTime) > 0 {
425
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
426
+		if err != nil {
427
+			utils.ErrorLog(err.Error())
428
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
429
+			return
430
+		}
431
+		isEndTime = true
432
+		theEndtTIme = theTime.Unix()
433
+	}
434
+
435
+	weights, dryweight, weightincrease, afterweight, total, err := service.GetPAWeightData(adminUserInfo.CurrentOrgId, page, limit, lapseto, age, theStartTIme, theEndtTIme, isStartTime, isEndTime)
436
+	if err != nil {
437
+		utils.ErrorLog(err.Error())
438
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
439
+		return
440
+	}
441
+	c.ServeSuccessJSON(map[string]interface{}{
442
+		"weights":        weights,
443
+		"dryweight":      dryweight,
444
+		"weightincrease": weightincrease,
445
+		"afterweight":    afterweight,
446
+		"total":          total,
447
+	})
448
+	return
449
+}
450
+
451
+func (c *QcdApiController) GetPABloodPressureData() {
452
+	page, _ := c.GetInt64("page", 1)
453
+	limit, _ := c.GetInt64("limit", 10)
454
+	startTime := c.GetString("start_time", "")
455
+	endTime := c.GetString("end_time", "")
456
+	lapseto, _ := c.GetInt64("lapseto", 0)
457
+	dialysisStage, _ := c.GetInt64("dialysis_stage", 0)
458
+
459
+	if page <= 0 {
460
+		page = 1
461
+	}
462
+	if limit <= 0 {
463
+		limit = 10
464
+	}
465
+
466
+	adminUserInfo := c.GetAdminUserInfo()
467
+
468
+	timeLayout := "2006-01-02"
469
+	loc, _ := time.LoadLocation("Local")
470
+
471
+	var isStartTime bool
472
+	var theStartTIme int64
473
+	if len(startTime) > 0 {
474
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
475
+		if err != nil {
476
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
477
+			return
478
+		}
479
+		isStartTime = true
480
+		theStartTIme = theTime.Unix()
481
+	}
482
+	var isEndTime bool
483
+	var theEndtTIme int64
484
+	if len(endTime) > 0 {
485
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
486
+		if err != nil {
487
+			utils.ErrorLog(err.Error())
488
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
489
+			return
490
+		}
491
+		isEndTime = true
492
+		theEndtTIme = theTime.Unix()
493
+	}
494
+
495
+	bloodPressures, bps, total, err := service.GetPABloodPressureData(adminUserInfo.CurrentOrgId, page, limit, lapseto, dialysisStage, theStartTIme, theEndtTIme, isStartTime, isEndTime)
496
+	if err != nil {
497
+		utils.ErrorLog(err.Error())
498
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
499
+		return
500
+	}
501
+	c.ServeSuccessJSON(map[string]interface{}{
502
+		"blood_pressures": bloodPressures,
503
+		"bps":             bps,
504
+		"total":           total,
505
+	})
506
+	return
507
+}
508
+
509
+func (c *QcdApiController) GetPAComplicationData() {
510
+	page, _ := c.GetInt64("page", 1)
511
+	limit, _ := c.GetInt64("limit", 10)
512
+	startTime := c.GetString("start_time", "")
513
+	endTime := c.GetString("end_time", "")
514
+	age, _ := c.GetInt64("age", 0)
515
+	statisticalState, _ := c.GetInt64("statistical_state", 0)
516
+
517
+	if page <= 0 {
518
+		page = 1
519
+	}
520
+	if limit <= 0 {
521
+		limit = 10
522
+	}
523
+
524
+	adminUserInfo := c.GetAdminUserInfo()
525
+
526
+	timeLayout := "2006-01-02"
527
+	loc, _ := time.LoadLocation("Local")
528
+
529
+	var isStartTime bool
530
+	var theStartTIme int64
531
+	if len(startTime) > 0 {
532
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
533
+		if err != nil {
534
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
535
+			return
536
+		}
537
+		isStartTime = true
538
+		theStartTIme = theTime.Unix()
539
+	}
540
+	var isEndTime bool
541
+	var theEndtTIme int64
542
+	if len(endTime) > 0 {
543
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
544
+		if err != nil {
545
+			utils.ErrorLog(err.Error())
546
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
547
+			return
548
+		}
549
+		isEndTime = true
550
+		theEndtTIme = theTime.Unix()
551
+	}
552
+
553
+	complications, pcps, total, err := service.GetPAComplicationData(adminUserInfo.CurrentOrgId, page, limit, age, statisticalState, theStartTIme, theEndtTIme, isStartTime, isEndTime)
554
+	if err != nil {
555
+		utils.ErrorLog(err.Error())
556
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
557
+		return
558
+	}
559
+	c.ServeSuccessJSON(map[string]interface{}{
560
+		"complications": complications,
561
+		"pcps":          pcps,
562
+		"total":         total,
563
+	})
564
+	return
565
+}
566
+
567
+func (c *QcdApiController) GetPAInfectiousDiseasesData() {
568
+	page, _ := c.GetInt64("page", 1)
569
+	limit, _ := c.GetInt64("limit", 10)
570
+	startTime := c.GetString("start_time", "")
571
+	endTime := c.GetString("end_time", "")
572
+	age, _ := c.GetInt64("age", 0)
573
+	contagionType, _ := c.GetInt64("contagion_type", 0)
574
+	lapseto, _ := c.GetInt64("lapseto", 0)
575
+
576
+	if page <= 0 {
577
+		page = 1
578
+	}
579
+	if limit <= 0 {
580
+		limit = 10
581
+	}
582
+
583
+	adminUserInfo := c.GetAdminUserInfo()
584
+
585
+	timeLayout := "2006-01-02"
586
+	loc, _ := time.LoadLocation("Local")
587
+
588
+	var isStartTime bool
589
+	var theStartTIme int64
590
+	if len(startTime) > 0 {
591
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
592
+		if err != nil {
593
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
594
+			return
595
+		}
596
+		isStartTime = true
597
+		theStartTIme = theTime.Unix()
598
+	}
599
+	var isEndTime bool
600
+	var theEndtTIme int64
601
+	if len(endTime) > 0 {
602
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
603
+		if err != nil {
604
+			utils.ErrorLog(err.Error())
605
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
606
+			return
607
+		}
608
+		isEndTime = true
609
+		theEndtTIme = theTime.Unix()
610
+	}
611
+
612
+	patients, dsp, total, err := service.GetPAInfectiousDiseasesData(adminUserInfo.CurrentOrgId, page, limit, lapseto, age, contagionType, theStartTIme, theEndtTIme, isStartTime, isEndTime)
613
+	if err != nil {
614
+		utils.ErrorLog(err.Error())
615
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
616
+		return
617
+	}
618
+	c.ServeSuccessJSON(map[string]interface{}{
619
+		"patients": patients,
620
+		"dsp":      dsp,
621
+		"total":    total,
622
+	})
623
+	return
624
+}
625
+
626
+func (c *QcdApiController) GetPersonLapsetoData() {
627
+	page, _ := c.GetInt64("page", 1)
628
+	limit, _ := c.GetInt64("limit", 10)
629
+	patientId, _ := c.GetInt64("patient_id", 0)
630
+
631
+	if page <= 0 {
632
+		page = 1
633
+	}
634
+	if limit <= 0 {
635
+		limit = 10
636
+	}
637
+
638
+	adminUserInfo := c.GetAdminUserInfo()
639
+
640
+	patient, lapsetos, total, err := service.GetPersonLapsetoData(adminUserInfo.CurrentOrgId, patientId, page, limit)
641
+	if err != nil {
642
+		utils.ErrorLog(err.Error())
643
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
644
+		return
645
+	}
646
+	c.ServeSuccessJSON(map[string]interface{}{
647
+		"patient":  patient,
648
+		"lapsetos": lapsetos,
649
+		"total":    total,
650
+	})
651
+	return
652
+}
653
+
654
+func (c *QcdApiController) GetPersonWeightData() {
655
+	page, _ := c.GetInt64("page", 1)
656
+	limit, _ := c.GetInt64("limit", 10)
657
+	patientId, _ := c.GetInt64("patient_id", 0)
658
+	startTime := c.GetString("start_time", "")
659
+	endTime := c.GetString("end_time", "")
660
+
661
+	if page <= 0 {
662
+		page = 1
663
+	}
664
+	if limit <= 0 {
665
+		limit = 10
666
+	}
667
+	var isStartTime bool
668
+	var theStartTIme int64
669
+
670
+	timeLayout := "2006-01-02"
671
+	loc, _ := time.LoadLocation("Local")
672
+
673
+	if len(startTime) > 0 {
674
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
675
+		if err != nil {
676
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
677
+			return
678
+		}
679
+		isStartTime = true
680
+		theStartTIme = theTime.Unix()
681
+	}
682
+	var isEndTime bool
683
+	var theEndtTIme int64
684
+	if len(endTime) > 0 {
685
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
686
+		if err != nil {
687
+			utils.ErrorLog(err.Error())
688
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
689
+			return
690
+		}
691
+		isEndTime = true
692
+		theEndtTIme = theTime.Unix()
693
+	}
694
+
695
+	adminUserInfo := c.GetAdminUserInfo()
696
+
697
+	patient, weight, pie, total, err := service.GetPersonWeightData(adminUserInfo.CurrentOrgId, patientId, page, limit, theStartTIme, theEndtTIme, isStartTime, isEndTime)
698
+	if err != nil {
699
+		utils.ErrorLog(err.Error())
700
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
701
+		return
702
+	}
703
+	c.ServeSuccessJSON(map[string]interface{}{
704
+		"patient": patient,
705
+		"weight":  weight,
706
+		"pie":     pie,
707
+		"total":   total,
708
+	})
709
+	return
710
+}
711
+
712
+func (c *QcdApiController) GetPersonBloodPressureData() {
713
+	page, _ := c.GetInt64("page", 1)
714
+	limit, _ := c.GetInt64("limit", 10)
715
+	patientId, _ := c.GetInt64("patient_id", 0)
716
+	startTime := c.GetString("start_time", "")
717
+	endTime := c.GetString("end_time", "")
718
+
719
+	if page <= 0 {
720
+		page = 1
721
+	}
722
+	if limit <= 0 {
723
+		limit = 10
724
+	}
725
+	var isStartTime bool
726
+	var theStartTIme int64
727
+
728
+	timeLayout := "2006-01-02"
729
+	loc, _ := time.LoadLocation("Local")
730
+
731
+	if len(startTime) > 0 {
732
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
733
+		if err != nil {
734
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
735
+			return
736
+		}
737
+		isStartTime = true
738
+		theStartTIme = theTime.Unix()
739
+	}
740
+	var isEndTime bool
741
+	var theEndtTIme int64
742
+	if len(endTime) > 0 {
743
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
744
+		if err != nil {
745
+			utils.ErrorLog(err.Error())
746
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
747
+			return
748
+		}
749
+		isEndTime = true
750
+		theEndtTIme = theTime.Unix()
751
+	}
752
+
753
+	adminUserInfo := c.GetAdminUserInfo()
754
+
755
+	patient, bps, lines, total, err := service.GetPersonBloodPressureData(adminUserInfo.CurrentOrgId, patientId, page, limit, theStartTIme, theEndtTIme, isStartTime, isEndTime)
756
+	if err != nil {
757
+		utils.ErrorLog(err.Error())
758
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
759
+		return
760
+	}
761
+	c.ServeSuccessJSON(map[string]interface{}{
762
+		"patient": patient,
763
+		"bps":     bps,
764
+		"lines":   lines,
765
+		"total":   total,
766
+	})
767
+	return
768
+}
769
+
770
+func (c *QcdApiController) GetPersonICData() {
771
+	page, _ := c.GetInt64("page", 1)
772
+	limit, _ := c.GetInt64("limit", 10)
773
+	patientId, _ := c.GetInt64("patient_id", 0)
774
+
775
+	if page <= 0 {
776
+		page = 1
777
+	}
778
+	if limit <= 0 {
779
+		limit = 10
780
+	}
781
+	adminUserInfo := c.GetAdminUserInfo()
782
+
783
+	patient, inspections, references, total, err := service.GetPersonICData(adminUserInfo.CurrentOrgId, patientId, page, limit)
784
+	if err != nil {
785
+		utils.ErrorLog(err.Error())
786
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
787
+		return
788
+	}
789
+	c.ServeSuccessJSON(map[string]interface{}{
790
+		"patient":     patient,
791
+		"inspections": inspections,
792
+		"references":  references,
793
+		"total":       total,
794
+	})
795
+	return
796
+}
797
+
798
+func (c *QcdApiController) GetPersonAdviceData() {
799
+	page, _ := c.GetInt64("page", 1)
800
+	limit, _ := c.GetInt64("limit", 10)
801
+	patientId, _ := c.GetInt64("patient_id", 0)
802
+	adviceType, _ := c.GetInt64("advice_type", 0)
803
+	medicalType, _ := c.GetInt64("medical_type", 0)
804
+	startTime := c.GetString("start_time", "")
805
+	endTime := c.GetString("end_time", "")
806
+
807
+	if page <= 0 {
808
+		page = 1
809
+	}
810
+	if limit <= 0 {
811
+		limit = 10
812
+	}
813
+	var isStartTime bool
814
+	var theStartTIme int64
815
+
816
+	timeLayout := "2006-01-02"
817
+	loc, _ := time.LoadLocation("Local")
818
+
819
+	if len(startTime) > 0 {
820
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
821
+		if err != nil {
822
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
823
+			return
824
+		}
825
+		isStartTime = true
826
+		theStartTIme = theTime.Unix()
827
+	}
828
+	var isEndTime bool
829
+	var theEndtTIme int64
830
+	if len(endTime) > 0 {
831
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
832
+		if err != nil {
833
+			utils.ErrorLog(err.Error())
834
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
835
+			return
836
+		}
837
+		isEndTime = true
838
+		theEndtTIme = theTime.Unix()
839
+	}
840
+
841
+	adminUserInfo := c.GetAdminUserInfo()
842
+
843
+	patient, advices, total, err := service.GetPersonAdviceData(adminUserInfo.CurrentOrgId, patientId, page, limit, adviceType, medicalType, theStartTIme, theEndtTIme, isStartTime, isEndTime)
844
+	if err != nil {
845
+		utils.ErrorLog(err.Error())
846
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
847
+		return
848
+	}
849
+
850
+	users, err := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
851
+	if err != nil {
852
+		utils.ErrorLog(err.Error())
853
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
854
+		return
855
+	}
856
+
857
+	c.ServeSuccessJSON(map[string]interface{}{
858
+		"patient": patient,
859
+		"advices": advices,
860
+		"users":   users,
861
+		"total":   total,
862
+	})
863
+	return
864
+}

+ 36 - 0
controllers/qiniiu_api_controller.go View File

@@ -0,0 +1,36 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/service"
6
+	"fmt"
7
+
8
+	"github.com/astaxie/beego"
9
+)
10
+
11
+type QiNiuApiController struct {
12
+	BaseAPIController
13
+	// beego.Controller
14
+}
15
+
16
+func QiniuApiRegistRouters() {
17
+	beego.Router("/api/qiniu/uptoken", &QiNiuApiController{}, "get:GetQNUpToken")
18
+}
19
+
20
+func (c *QiNiuApiController) GetQNUpToken() {
21
+	redisClient := service.RedisClient()
22
+	defer redisClient.Close()
23
+
24
+	token, err := redisClient.Get("qn_token").Result()
25
+	fmt.Print("token------------------------------------", token)
26
+	if err != nil {
27
+		defer fmt.Println(err)
28
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGetQiniuUpToken)
29
+		return
30
+	}
31
+
32
+	c.ServeSuccessJSON(map[string]interface{}{
33
+		"uptoken": token,
34
+	})
35
+	return
36
+}

+ 71 - 0
controllers/role.json View File

@@ -0,0 +1,71 @@
1
+{
2
+  "roles": [
3
+    {
4
+      "role_name": "子管理员",
5
+      "role_introduction": "子管理员角色具备平台全部功能的使用权限,请谨慎配置",
6
+      "is_super_admin": false,
7
+      "status": 1,
8
+      "is_system": 1,
9
+      "number": 9999,
10
+      "purview_ids": "71,72,70,74,75,73,48,49,52,110,49,77,78,79,80,197,76,111,112,113,114,115,116,117,118,119,129,84,93,121,122,124,125,120,127,128,201,193,194,196,192,158,157,159,160,161,162,167,166,168,169,170,171,174,173,175,178,177,179,101,100,102,83,94",
11
+      "func_ids": "20001,20002,20003,20004,20005,20006,20007,20008,20009,20010,20011,20012,20034,20035,20036,20038,20039,20055,20056,20040,20041,20042,20043,20054,20044,20045,20046,20047,20048,20049,20050,20051,20052,20053,20013,20014,20015,20016,20017,20018,20019,20020,20021,20022,20023,20024,20025,20026,20027,20028,20029,20030"
12
+    },
13
+    {
14
+      "role_name": "医生",
15
+      "role_introduction": "医生角色能够进行建立患者档案,制定和调整患者透析治疗方案,定期评价病人的透析质量等",
16
+      "is_super_admin": false,
17
+      "status": 1,
18
+      "is_system": 2,
19
+      "number": 9998,
20
+      "purview_ids": "71,72,70,74,75,73,48,52,110,77,78,79,80,197,76,93,121,122,124,125,120,127,128,193,194,196,192,101,100,102,49",
21
+      "func_ids": "20001,20002,20003,20004,20005,20006,20007,20008,20009,20010,20011,20012,20034,20035,20036,20038,20040,20041,20043,20044,20046,20047,20049,20024,20025,20026,20027,20028,20029,20030"
22
+    },
23
+    {
24
+      "role_name": "护士",
25
+      "role_introduction": "护士角色能够进行病人透析管理,以及医院的感染控制与消毒记录等",
26
+      "is_super_admin": false,
27
+      "status": 1,
28
+      "is_system": 3,
29
+      "number": 9997,
30
+      "purview_ids": "71,72,70,74,75,73,127,128,48,49,52,110,111,112,113,114,115,116,117,118,119,129,84,77,78,79,80,197,76,83,94",
31
+      "func_ids": "20007,20008,20009,20010,20011,20051,20053,20013,20014,20016,20017,20019,20021,20022,20024,20025,20026,20027,20028,20029,20055,20056,20052,20012"
32
+    },{
33
+      "role_name": "库存",
34
+      "role_introduction": "库存角色负责透析耗材的日常管理,对耗材的入库、出库、退库的登记操作",
35
+      "is_super_admin": false,
36
+      "status": 1,
37
+      "is_system": 0,
38
+      "number": 9996,
39
+      "purview_ids": "111,112,113,114,115,116,117,118,119,129,84,94",
40
+      "func_ids": ""
41
+    },{
42
+      "role_name": "运营",
43
+      "role_introduction": "运营角色能够在SCRM中管理微网站、使用营销工具、做会员管理和分销商品经营的操作",
44
+      "is_super_admin": false,
45
+      "status": 1,
46
+      "is_system": 0,
47
+      "number": 9995,
48
+      "purview_ids": "48,110,158,157,159,160,161,162,167,166,168,169,170,171,174,173,175,178,177,179,201",
49
+      "func_ids": ""
50
+    },{
51
+      "role_name": "技师",
52
+      "role_introduction": "技师角色能够进行设备的管理,日常维护维修记录等",
53
+      "is_super_admin": false,
54
+      "status": 1,
55
+      "is_system": 0,
56
+      "number": 9994,
57
+      "purview_ids": "77,78,79,80,197,76",
58
+      "func_ids": ""
59
+    },
60
+    {
61
+      "role_name": "院长",
62
+      "role_introduction": "院长角色了解血透患者血液透析质量和相关的大数据,以及掌握透析中心整体运营情况",
63
+      "is_super_admin": false,
64
+      "status": 1,
65
+      "is_system": 0,
66
+      "number": 9993,
67
+      "purview_ids": "71,72,70,74,75,73,48,49,52,110,111,112,113,114,115,116,117,118,119,129,84,93,121,122,124,125,120,77,78,79,80,197,76,101,100,102,127,128,158,157,159,160,161,162,167,166,168,169,170,171,174,173,175,178,177,179,201,94",
68
+      "func_ids": ""
69
+    }
70
+  ]
71
+}

File diff suppressed because it is too large
+ 1559 - 0
controllers/role_controller.go


File diff suppressed because it is too large
+ 2673 - 0
controllers/schedule_api_controller.go


+ 398 - 0
controllers/schedule_template_api_controller.go View File

@@ -0,0 +1,398 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/models"
6
+	"Xcx_New/service"
7
+	"Xcx_New/utils"
8
+	"encoding/json"
9
+	"time"
10
+
11
+	"github.com/astaxie/beego"
12
+)
13
+
14
+func PatientScheduleTemplateAPIControllerRegistRouters() {
15
+	beego.Router("/api/schtemp/p/initdata", &PatientScheduleTemplateAPIController{}, "get:InitData")
16
+	beego.Router("/api/schtemp/p/setmode", &PatientScheduleTemplateAPIController{}, "post:SetMode")
17
+	beego.Router("/api/schtemp/p/update_sch", &PatientScheduleTemplateAPIController{}, "post:UpdateSchedules")
18
+
19
+	// beego.Router("/api/test", &TestCtr{}, "get:Test")
20
+}
21
+
22
+// type TestCtr struct {
23
+// 	BaseAPIController
24
+// }
25
+
26
+// func (this *TestCtr) Test() {
27
+// 	now := time.Now().AddDate(0, 0, 7)
28
+
29
+// 	weekday := int(now.Weekday())
30
+// 	if weekday == 0 {
31
+// 		weekday = 7
32
+// 	}
33
+
34
+// 	monday := now.AddDate(0, 0, 1-weekday)
35
+// 	sunday := now.AddDate(0, 0, 7-weekday)
36
+
37
+// 	// this.TraceLog("%v", weekday)
38
+// 	this.ServeSuccessJSON(map[string]interface{}{
39
+// 		"weekday": weekday,
40
+// 		"monday":  monday.Format("2006-01-02"),
41
+// 		"sunday":  sunday.Format("2006-01-02"),
42
+// 	})
43
+// }
44
+
45
+// ------- 患者排班模板 --------
46
+type PatientScheduleTemplateAPIController struct {
47
+	BaseAuthAPIController
48
+}
49
+
50
+// /api/schtemp/p/initdata [get]
51
+func (this *PatientScheduleTemplateAPIController) InitData() {
52
+	adminUserInfo := this.GetAdminUserInfo()
53
+
54
+	mode, getModeErr := service.GetOrgPatientScheduleTemplateMode(adminUserInfo.CurrentOrgId)
55
+	if getModeErr != nil {
56
+		this.ErrorLog("获取排班模板启用模式失败:%v", getModeErr)
57
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
58
+		return
59
+	}
60
+	now := time.Now()
61
+	if mode == nil {
62
+		mode = &models.PatientScheduleTemplateMode{
63
+			OrgID:        adminUserInfo.CurrentOrgId,
64
+			Mode:         0,
65
+			ExecuteTimes: 0,
66
+			Status:       1,
67
+			CreateTime:   now.Unix(),
68
+			ModifyTime:   now.Unix(),
69
+		}
70
+		createModeErr := service.SavePatientScheduleTemplateMode(mode)
71
+		if createModeErr != nil {
72
+			this.ErrorLog("创建排班模板启用模式失败:%v", createModeErr)
73
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
74
+			return
75
+		}
76
+	}
77
+
78
+	deviceNumbers, getDeviceNumbersErr := service.GetScheduleValidDeviceNumbers(adminUserInfo.CurrentOrgId)
79
+	if getDeviceNumbersErr != nil {
80
+		this.ErrorLog("获取床位号失败:%v", getDeviceNumbersErr)
81
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
82
+		return
83
+	}
84
+
85
+	templates, getTemplatesErr := service.GetOrgPatientScheduleTemplateItems(adminUserInfo.CurrentOrgId)
86
+	if getTemplatesErr != nil {
87
+		this.ErrorLog("获取排班模板及其排班列表失败:%v", getTemplatesErr)
88
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
89
+		return
90
+	}
91
+	if len(templates) == 0 {
92
+		firstTemp, secondTemp, createTempErr := service.CreateTwoPatientScheduleTemplates(adminUserInfo.CurrentOrgId)
93
+		if createTempErr != nil {
94
+			this.ErrorLog("创建两个排班模板失败:%v", createTempErr)
95
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
96
+			return
97
+		}
98
+		templates = append(templates, firstTemp, secondTemp)
99
+
100
+	} else if len(templates) == 1 {
101
+		temp, createTempErr := service.CreatePatientScheduleTemplate(adminUserInfo.CurrentOrgId)
102
+		if createTempErr != nil {
103
+			this.ErrorLog("创建两个排班模板失败:%v", createTempErr)
104
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
105
+			return
106
+		}
107
+		templates = append(templates, temp)
108
+	}
109
+
110
+	patients, getPatientsErr := service.PatientScheduleTemplateGetAllValidPatient(adminUserInfo.CurrentOrgId)
111
+	if getPatientsErr != nil {
112
+		this.ErrorLog("获取患者列表失败失败:%v", getPatientsErr)
113
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
114
+		return
115
+	}
116
+
117
+	// 获取本周的排班
118
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
119
+	schedules, getScheduleErr := service.GetWeekSchedule(adminUserInfo.CurrentOrgId, monday.Unix(), sunday.Unix())
120
+	if getScheduleErr != nil {
121
+		this.ErrorLog("获取本周排班失败:%v", getScheduleErr)
122
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
123
+		return
124
+	}
125
+
126
+	this.ServeSuccessJSON(map[string]interface{}{
127
+		"template_mode":  mode,
128
+		"device_numbers": deviceNumbers,
129
+		"templates":      templates,
130
+		"patients":       patients,
131
+		"schedules":      schedules,
132
+	})
133
+}
134
+
135
+// /api/schtemp/p/setmode [post]
136
+// @param mode:int 0.不启用模板 1.单周模板 2.双周模板
137
+func (this *PatientScheduleTemplateAPIController) SetMode() {
138
+	mode, _ := this.GetInt8("mode")
139
+	if mode != 1 && mode != 2 && mode != 0 && mode != 3 && mode != 4 {
140
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
141
+		return
142
+	}
143
+
144
+	adminUserInfo := this.GetAdminUserInfo()
145
+
146
+	templateMode, getTemplateModeErr := service.GetOrgPatientScheduleTemplateMode(adminUserInfo.CurrentOrgId)
147
+	if getTemplateModeErr != nil {
148
+		this.ErrorLog("获取排班模板启用模式失败:%v", getTemplateModeErr)
149
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
150
+		return
151
+	} else if templateMode == nil {
152
+		this.ErrorLog("获取不到排班模板启用模式")
153
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
154
+		return
155
+	}
156
+
157
+	if mode != templateMode.Mode {
158
+		if templateMode.Mode == 0 { // 0 -> 1 或 0 -> 2 则直接清除下两周的排班
159
+			templateMode.Mode = mode
160
+			templateMode.ExecuteTimes = 0
161
+			templateMode.ModifyTime = time.Now().Unix()
162
+			updateErr := service.SavePatientScheduleTemplateModeAndClearNextTwoWeekSchedules(templateMode)
163
+			if updateErr != nil {
164
+				this.ErrorLog("更新排班模板启用方式(0 -> 1 或 0 -> 2)时失败:%v", updateErr)
165
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
166
+				return
167
+			}
168
+
169
+		} else if mode == 0 { // 1 -> 0 或 2 -> 0 则不处理排班,但清除所有模板item
170
+			templateMode.Mode = mode
171
+			templateMode.ExecuteTimes = 0
172
+			templateMode.ModifyTime = time.Now().Unix()
173
+			updateErr := service.SavePatientScheduleTemplateModeAndClearAllTemplateItems(templateMode)
174
+			if updateErr != nil {
175
+				this.ErrorLog("更新排班模板启用方式(1 -> 0 或 2 -> 0)时失败:%v", updateErr)
176
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
177
+				return
178
+			}
179
+
180
+		} else if templateMode.Mode == 1 && mode == 2 { // 1 -> 2 清除第二周排班
181
+			templateMode.Mode = mode
182
+			templateMode.ExecuteTimes = 0
183
+			templateMode.ModifyTime = time.Now().Unix()
184
+			updateErr := service.SavePatientScheduleTemplateModeAndClearNextSecondWeekSchedules(templateMode)
185
+			if updateErr != nil {
186
+				this.ErrorLog("更新排班模板启用方式(1 -> 2)时失败:%v", updateErr)
187
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
188
+				return
189
+			}
190
+
191
+		} else if templateMode.Mode == 2 && mode == 1 { // 2 -> 1 清除第二周模板item,清除第二周排班,将第一周的排班重复到第二周
192
+			templateIDs, getTemplateIDsErr := service.GetOrgPatientScheduleTemplateIDs(adminUserInfo.CurrentOrgId)
193
+			if getTemplateIDsErr != nil {
194
+				this.ErrorLog("获取排班模板失败:%v", getTemplateIDsErr)
195
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
196
+				return
197
+			}
198
+
199
+			firstWeekItems, getFirstWeekItemsErr := service.GetOrgPatientScheduleTemplateItemsWithoutPatientByTemplateID(adminUserInfo.CurrentOrgId, templateIDs[0].ID)
200
+			if getFirstWeekItemsErr != nil {
201
+				this.ErrorLog("获取排班模板排班失败:%v", getFirstWeekItemsErr)
202
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
203
+				return
204
+			}
205
+
206
+			templateMode.Mode = mode
207
+			templateMode.ExecuteTimes = 0
208
+			templateMode.ModifyTime = time.Now().Unix()
209
+			updateErr := service.SavePatientScheduleTemplateMode2To1(templateMode, templateIDs[1].ID, firstWeekItems)
210
+			if updateErr != nil {
211
+				this.ErrorLog("更新排班模板启用方式(1 -> 2)时失败:%v", updateErr)
212
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
213
+				return
214
+			}
215
+		}
216
+	}
217
+	this.ServeSuccessJSON(nil)
218
+}
219
+
220
+// /api/schtemp/p/update_sch [post]
221
+// @param template_id:int
222
+// @param add_schs:array'json ([ {device_number_id, patient_id, mode(treat_mode), weekday, time_type} ])
223
+// @param del_schs:array'json ([ {device_number_id, weekday, time_type} ])
224
+// @param change_schs:array'json ([ {device_number_id, patient_id, mode(treat_mode), weekday, time_type} ])
225
+func (this *PatientScheduleTemplateAPIController) UpdateSchedules() {
226
+	templateID, _ := this.GetInt64("template_id")
227
+	addSchedulesJSON := this.GetString("add_schs")
228
+	delSchedulesJSON := this.GetString("del_schs")
229
+	changeSchedulesJSON := this.GetString("change_schs")
230
+	if templateID <= 0 || len(addSchedulesJSON) == 0 || len(delSchedulesJSON) == 0 || len(changeSchedulesJSON) == 0 {
231
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
232
+		return
233
+	}
234
+
235
+	var addSchedules []*ParamModelSchedule
236
+	var delSchedules []*ParamModelSchedule
237
+	var changeSchedules []*ParamModelSchedule
238
+	parseErr := json.Unmarshal([]byte(addSchedulesJSON), &addSchedules)
239
+	if parseErr != nil {
240
+		this.ErrorLog("解析增加排班的数组参数失败:%v", parseErr)
241
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
242
+		return
243
+	}
244
+	parseErr = json.Unmarshal([]byte(delSchedulesJSON), &delSchedules)
245
+	if parseErr != nil {
246
+		this.ErrorLog("解析删除排班的数组参数失败:%v", parseErr)
247
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
248
+		return
249
+	}
250
+	parseErr = json.Unmarshal([]byte(changeSchedulesJSON), &changeSchedules)
251
+	if parseErr != nil {
252
+		this.ErrorLog("解析修改排班的数组参数失败:%v", parseErr)
253
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
254
+		return
255
+	}
256
+
257
+	adminUserInfo := this.GetAdminUserInfo()
258
+	templateIDs, getTemplateIDsErr := service.GetOrgPatientScheduleTemplateIDs(adminUserInfo.CurrentOrgId)
259
+	if getTemplateIDsErr != nil {
260
+		this.ErrorLog("获取排班模板失败:%v", getTemplateIDsErr)
261
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
262
+		return
263
+	} else {
264
+		isTemplateIDExist := false
265
+		for _, templateIDObject := range templateIDs {
266
+			if templateIDObject.ID == templateID {
267
+				isTemplateIDExist = true
268
+				break
269
+			}
270
+		}
271
+		if isTemplateIDExist == false {
272
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeScheduleTemplateNotExist)
273
+			return
274
+		}
275
+	}
276
+
277
+	addTemplateItems := make([]*models.PatientScheduleTemplateItem, 0, len(addSchedules))
278
+	delTemplateItems := make([]*models.PatientScheduleTemplateItem, 0, len(delSchedules))
279
+	changeTemplateItems := make([]*models.PatientScheduleTemplateItem, 0, len(changeSchedules))
280
+	for _, sch := range addSchedules {
281
+		if sch.DeviceNumberID <= 0 || sch.PatientID <= 0 || sch.Weekday < 1 || sch.Weekday > 7 || sch.TimeType < 1 || sch.TimeType > 3 {
282
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
283
+			return
284
+		}
285
+		addTemplateItems = append(addTemplateItems, &models.PatientScheduleTemplateItem{
286
+			DeviceNumberID: sch.DeviceNumberID,
287
+			PatientID:      sch.PatientID,
288
+			TreatMode:      sch.Mode,
289
+			Weekday:        sch.Weekday,
290
+			TimeType:       sch.TimeType,
291
+		})
292
+	}
293
+	for _, sch := range delSchedules {
294
+		if sch.DeviceNumberID <= 0 || sch.Weekday < 1 || sch.Weekday > 7 || sch.TimeType < 1 || sch.TimeType > 3 {
295
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
296
+			return
297
+		}
298
+		delTemplateItems = append(delTemplateItems, &models.PatientScheduleTemplateItem{
299
+			DeviceNumberID: sch.DeviceNumberID,
300
+			Weekday:        sch.Weekday,
301
+			TimeType:       sch.TimeType,
302
+		})
303
+	}
304
+	for _, sch := range changeSchedules {
305
+		if sch.DeviceNumberID <= 0 || sch.PatientID <= 0 || sch.Weekday < 1 || sch.Weekday > 7 || sch.TimeType < 1 || sch.TimeType > 3 {
306
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
307
+			return
308
+		}
309
+		changeTemplateItems = append(changeTemplateItems, &models.PatientScheduleTemplateItem{
310
+			DeviceNumberID: sch.DeviceNumberID,
311
+			PatientID:      sch.PatientID,
312
+			TreatMode:      sch.Mode,
313
+			Weekday:        sch.Weekday,
314
+			TimeType:       sch.TimeType,
315
+		})
316
+	}
317
+
318
+	templateMode, getTemplateModeErr := service.GetOrgPatientScheduleTemplateMode(adminUserInfo.CurrentOrgId)
319
+	if getTemplateModeErr != nil {
320
+		this.ErrorLog("获取排班模板启用模式失败:%v", getTemplateModeErr)
321
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
322
+		return
323
+	} else if templateMode == nil {
324
+		this.ErrorLog("获取不到排班模板启用模式")
325
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
326
+		return
327
+	}
328
+
329
+	shouldUpdateNextWeekSchedules := false
330
+	shouldUpdateNextSecondWeekSchedules := false
331
+	if templateMode.Mode == 0 {
332
+		this.ErrorLog("当前未开启排班模板,所以更新模板的操作将被无视")
333
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
334
+		return
335
+	}
336
+	templateIDIndex := 1
337
+	for index, templateIDObject := range templateIDs {
338
+		if templateIDObject.ID == templateID {
339
+			templateIDIndex = index + 1
340
+		}
341
+	}
342
+	if templateMode.Mode == 1 {
343
+		if templateIDIndex == 1 {
344
+			shouldUpdateNextWeekSchedules = true
345
+			shouldUpdateNextSecondWeekSchedules = true
346
+		} else {
347
+			this.ErrorLog("当前开启的是单周模板,所以不会更新第二个模板")
348
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
349
+			return
350
+		}
351
+
352
+	} else { // mode == 2 => 开启双周模板时,只需更新一周排班
353
+		if templateIDIndex == 1 {
354
+			if templateMode.ExecuteTimes%2 == 0 {
355
+				shouldUpdateNextWeekSchedules = true
356
+				shouldUpdateNextSecondWeekSchedules = false
357
+			} else {
358
+				shouldUpdateNextWeekSchedules = false
359
+				shouldUpdateNextSecondWeekSchedules = true
360
+			}
361
+
362
+		} else {
363
+			if templateMode.ExecuteTimes%2 == 0 {
364
+				shouldUpdateNextWeekSchedules = false
365
+				shouldUpdateNextSecondWeekSchedules = true
366
+			} else {
367
+				shouldUpdateNextWeekSchedules = true
368
+				shouldUpdateNextSecondWeekSchedules = false
369
+			}
370
+
371
+		}
372
+	}
373
+
374
+	updateErr := service.UpdateScheduleTemplate(adminUserInfo.CurrentOrgId, templateID, addTemplateItems, delTemplateItems, changeTemplateItems, shouldUpdateNextWeekSchedules, shouldUpdateNextSecondWeekSchedules)
375
+	if updateErr != nil {
376
+		this.ErrorLog("更新排班模板排班失败:%v", updateErr)
377
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
378
+		return
379
+	}
380
+
381
+	newItems, getTemplateItemsErr := service.GetOrgPatientScheduleTemplateItemsByTemplateID(adminUserInfo.CurrentOrgId, templateID)
382
+	if getTemplateItemsErr != nil {
383
+		this.ErrorLog("获取排班模板排班失败:%v", getTemplateItemsErr)
384
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
385
+		return
386
+	}
387
+	this.ServeSuccessJSON(map[string]interface{}{
388
+		"items": newItems,
389
+	})
390
+}
391
+
392
+type ParamModelSchedule struct {
393
+	DeviceNumberID int64 `json:"device_number_id"`
394
+	PatientID      int64 `json:"patient_id"`
395
+	Mode           int64 `json:"mode"`
396
+	Weekday        int8  `json:"weekday"`
397
+	TimeType       int8  `json:"time_type"`
398
+}

File diff suppressed because it is too large
+ 2157 - 0
controllers/self_drug_api_congtroller.go


+ 599 - 0
controllers/sign_weigh_api_controller.go View File

@@ -0,0 +1,599 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/models"
6
+	"Xcx_New/service"
7
+	"encoding/json"
8
+	"fmt"
9
+	"github.com/astaxie/beego"
10
+	"github.com/jinzhu/gorm"
11
+	"reflect"
12
+	"strconv"
13
+	"time"
14
+)
15
+
16
+func SignWeighAPIControllerRegistRouters() {
17
+	beego.Router("/api/sign/patients", &SignWeighAPIController{}, "Get:GetPatients")
18
+	beego.Router("/api/sign/patientsign", &SignWeighAPIController{}, "Get:GetPatientSign")
19
+
20
+	beego.Router("/api/signweign", &SignWeighAPIController{}, "Post:EditPatientSign")
21
+
22
+	beego.Router("/api/sign/getDialysisInforInfomation", &SignWeighAPIController{}, "Get:GetPatientList")
23
+
24
+	beego.Router("/api/sign/getDialysisAfterInfomation", &SignWeighAPIController{}, "Get:GetInforByPatientId")
25
+
26
+	beego.Router("/api/sign/savaData", &SignWeighAPIController{}, "Post:SaveData")
27
+
28
+	beego.Router("/api/sign/editdata", &SignWeighAPIController{}, "Post:EditData")
29
+
30
+	beego.Router("/api/sigh/sighdata", &SignWeighAPIController{}, "Post:Sighdata")
31
+
32
+	beego.Router("/api/sign/updateSignweight", &SignWeighAPIController{}, "Post:UpdateSignweight")
33
+
34
+}
35
+
36
+type SignWeighAPIController struct {
37
+	BaseAuthAPIController
38
+}
39
+
40
+// /api/sign/patients [get]
41
+func (c *SignWeighAPIController) GetPatients() {
42
+	keywrods := c.GetString("keywords")
43
+	fmt.Println("关键字" + keywrods)
44
+	scheduleType, _ := c.GetInt64("schedule_type", 0)
45
+	needScheduleType, _ := c.GetInt64("need_schedule_type", 0)
46
+	nowDateTime := time.Now()
47
+	nowDate := nowDateTime.Format("2006-01-02")
48
+	today := nowDate
49
+	nowDate += " 00:00:00"
50
+
51
+	//认为没有选择{0:'全部',1:'上午',2:'下午'3:'晚上' }中的一个
52
+	if scheduleType < 0 || scheduleType > 3 {
53
+		nowH := nowDateTime.Hour()
54
+
55
+		if nowH < 12 {
56
+			scheduleType = 1
57
+		} else if nowH < 18 {
58
+			scheduleType = 2
59
+		} else {
60
+			scheduleType = 3
61
+		}
62
+	}
63
+
64
+	timeLayout := "2006-01-02"
65
+	loc, _ := time.LoadLocation("Local")
66
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
67
+	if err != nil {
68
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
69
+		return
70
+	}
71
+	dateTime := theTime.Unix()
72
+	fmt.Println("dataTime是多少", dateTime)
73
+	adminUserInfo := c.GetAdminUserInfo()
74
+
75
+	patients, err := service.GetSignPatients(adminUserInfo.CurrentOrgId, keywrods, dateTime, scheduleType)
76
+
77
+	fmt.Println("病人信息", patients)
78
+	if err != nil {
79
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
80
+		return
81
+	}
82
+
83
+	panel := make(map[int64]map[string]int64, 0)
84
+	if needScheduleType == 1 {
85
+		panel, _ = service.GetSignPanels(adminUserInfo.CurrentOrgId, dateTime)
86
+		fmt.Println("panel是什么", panel)
87
+	}
88
+
89
+	c.ServeSuccessJSON(map[string]interface{}{
90
+		"patients":      patients,
91
+		"today":         today,
92
+		"schedule_type": scheduleType,
93
+		"panel":         panel,
94
+	})
95
+	return
96
+}
97
+
98
+func (c *SignWeighAPIController) GetPatientSign() {
99
+	patientID, _ := c.GetInt64("patient_id", 0)
100
+	dateTime := c.GetString("date_time")
101
+	timeLayout := "2006-01-02"
102
+	loc, _ := time.LoadLocation("Local")
103
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", dateTime+" 00:00:00", loc)
104
+	if err != nil {
105
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
106
+		return
107
+	}
108
+	dateTimeStam := theTime.Unix()
109
+
110
+	adminUserInfo := c.GetAdminUserInfo()
111
+
112
+	sign, err := service.GetPatientDateSign(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
113
+
114
+	if err != nil {
115
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
116
+		return
117
+	}
118
+
119
+	c.ServeSuccessJSON(map[string]interface{}{
120
+		"sign": sign,
121
+	})
122
+	return
123
+}
124
+
125
+func (c *SignWeighAPIController) EditPatientSign() {
126
+	patientID, _ := c.GetInt64("patient_id", 0)
127
+	dateTime := c.GetString("date_time")
128
+
129
+	timeLayout := "2006-01-02"
130
+	loc, _ := time.LoadLocation("Local")
131
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", dateTime+" 00:00:00", loc)
132
+	if err != nil {
133
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
134
+		return
135
+	}
136
+	dateTimeStam := theTime.Unix()
137
+
138
+	adminUserInfo := c.GetAdminUserInfo()
139
+
140
+	sign, err := service.GetPatientDateSign(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
141
+
142
+	if err != nil {
143
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
144
+		return
145
+	}
146
+
147
+	var signForm models.SigninAndWeigh
148
+	if sign != nil {
149
+		signForm = *sign
150
+		signForm.UpdatedTime = time.Now().Unix()
151
+
152
+	} else {
153
+		signForm.PatientId = patientID
154
+		signForm.RecordDate = dateTimeStam
155
+		signForm.UserOrgId = adminUserInfo.CurrentOrgId
156
+		signForm.SignTime = time.Now().Unix()
157
+		signForm.Status = 1
158
+		signForm.CreatedTime = time.Now().Unix()
159
+		signForm.UpdatedTime = time.Now().Unix()
160
+	}
161
+
162
+	signData := make(map[string]interface{}, 0)
163
+	err = json.Unmarshal(c.Ctx.Input.RequestBody, &signData)
164
+	if err != nil {
165
+		//utils.ErrorLog(err.Error())
166
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
167
+	}
168
+
169
+	if signData["dry_weight"] == nil || reflect.TypeOf(signData["dry_weight"]).String() != "string" {
170
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
171
+		return
172
+	}
173
+	dryWeight, _ := strconv.ParseFloat(signData["dry_weight"].(string), 64)
174
+	signForm.DryWeight = dryWeight
175
+
176
+	if signData["clothes_weight"] == nil || reflect.TypeOf(signData["clothes_weight"]).String() != "string" {
177
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
178
+		return
179
+	}
180
+	clothesWeight, _ := strconv.ParseFloat(signData["clothes_weight"].(string), 64)
181
+	signForm.ClothingWeight = clothesWeight
182
+
183
+	if signData["weigh_before"] == nil || reflect.TypeOf(signData["weigh_before"]).String() != "string" {
184
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
185
+		return
186
+	}
187
+	weighBefore, _ := strconv.ParseFloat(signData["weigh_before"].(string), 64)
188
+	signForm.WeighingBefore = weighBefore
189
+
190
+	if signData["dehydrated_weight"] == nil || reflect.TypeOf(signData["dehydrated_weight"]).String() != "string" {
191
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
192
+		return
193
+	}
194
+	dehydratedWeight, _ := strconv.ParseFloat(signData["dehydrated_weight"].(string), 64)
195
+	signForm.TargetDewatering = dehydratedWeight
196
+
197
+	if signData["weight_before"] == nil || reflect.TypeOf(signData["weight_before"]).String() != "string" {
198
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
199
+		return
200
+	}
201
+	weightBefore, _ := strconv.ParseFloat(signData["weight_before"].(string), 64)
202
+	signForm.WeightBefore = weightBefore
203
+
204
+	if signData["temperature_before"] == nil || reflect.TypeOf(signData["temperature_before"]).String() != "string" {
205
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
206
+		return
207
+	}
208
+	temperatureBefore, _ := strconv.ParseFloat(signData["temperature_before"].(string), 64)
209
+	signForm.TemperatureBefore = temperatureBefore
210
+
211
+	if signData["pulse_rate_before"] == nil || reflect.TypeOf(signData["pulse_rate_before"]).String() != "string" {
212
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
213
+		return
214
+	}
215
+	pulseRateBefore, _ := strconv.ParseFloat(signData["pulse_rate_before"].(string), 64)
216
+	signForm.PulseFrequencyBefore = pulseRateBefore
217
+
218
+	if signData["respiratory_rate_before"] == nil || reflect.TypeOf(signData["respiratory_rate_before"]).String() != "string" {
219
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
220
+		return
221
+	}
222
+	respiratoryRateBefore, _ := strconv.ParseFloat(signData["respiratory_rate_before"].(string), 64)
223
+	signForm.BreathingRateBefore = respiratoryRateBefore
224
+
225
+	if signData["DBP_before"] == nil || reflect.TypeOf(signData["DBP_before"]).String() != "string" {
226
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
227
+		return
228
+	}
229
+	DBPBefore, _ := strconv.ParseFloat(signData["DBP_before"].(string), 64)
230
+	signForm.DiastolicBloodPressureBefore = DBPBefore
231
+
232
+	if signData["SBP_before"] == nil || reflect.TypeOf(signData["SBP_before"]).String() != "string" {
233
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
234
+		return
235
+	}
236
+	SBPBefore, _ := strconv.ParseFloat(signData["SBP_before"].(string), 64)
237
+	signForm.SystolicBloodPressureBefore = SBPBefore
238
+
239
+	if signData["weigh_after"] == nil || reflect.TypeOf(signData["weigh_after"]).String() != "string" {
240
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
241
+		return
242
+	}
243
+	weighAfter, _ := strconv.ParseFloat(signData["weigh_after"].(string), 64)
244
+	signForm.WeighingAfter = weighAfter
245
+
246
+	if signData["weight_reduce_after"] == nil || reflect.TypeOf(signData["weight_reduce_after"]).String() != "string" {
247
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
248
+		return
249
+	}
250
+	weightReduceAfter, _ := strconv.ParseFloat(signData["weight_reduce_after"].(string), 64)
251
+	signForm.WeightLoss = weightReduceAfter
252
+
253
+	if signData["weight_after"] == nil || reflect.TypeOf(signData["weight_after"]).String() != "string" {
254
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
255
+		return
256
+	}
257
+	weightAfter, _ := strconv.ParseFloat(signData["weight_after"].(string), 64)
258
+	signForm.WeightAfter = weightAfter
259
+
260
+	if signData["temperature_after"] == nil || reflect.TypeOf(signData["temperature_after"]).String() != "string" {
261
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
262
+		return
263
+	}
264
+	temperatureAfter, _ := strconv.ParseFloat(signData["temperature_after"].(string), 64)
265
+	signForm.TemperatureAfter = temperatureAfter
266
+
267
+	if signData["pulse_rate_after"] == nil || reflect.TypeOf(signData["pulse_rate_after"]).String() != "string" {
268
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
269
+		return
270
+	}
271
+	pulseRateAfter, _ := strconv.ParseFloat(signData["pulse_rate_after"].(string), 64)
272
+	signForm.PulseFrequencyAfter = pulseRateAfter
273
+
274
+	if signData["respiratory_rate_after"] == nil || reflect.TypeOf(signData["respiratory_rate_after"]).String() != "string" {
275
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
276
+		return
277
+	}
278
+	respiratoryRateAfter, _ := strconv.ParseFloat(signData["respiratory_rate_after"].(string), 64)
279
+	signForm.BreathingRateAfter = respiratoryRateAfter
280
+
281
+	if signData["DBP_after"] == nil || reflect.TypeOf(signData["DBP_after"]).String() != "string" {
282
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
283
+		return
284
+	}
285
+	DBPAfter, _ := strconv.ParseFloat(signData["DBP_after"].(string), 64)
286
+	signForm.DiastolicBloodPressureAfter = DBPAfter
287
+
288
+	if signData["SBP_after"] == nil || reflect.TypeOf(signData["SBP_after"]).String() != "string" {
289
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
290
+		return
291
+	}
292
+	SBPAfter, _ := strconv.ParseFloat(signData["SBP_after"].(string), 64)
293
+	signForm.SystolicBloodPressureAfter = SBPAfter
294
+
295
+	if signForm.WeighingAfter > 0 {
296
+		signForm.WeighTime = time.Now().Unix()
297
+	}
298
+	if signForm.WeighingBefore > 0 {
299
+		signForm.WeighBeforeTime = time.Now().Unix()
300
+	}
301
+
302
+	err = service.EditPatientSign(&signForm)
303
+
304
+	if err != nil {
305
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
306
+		return
307
+	}
308
+
309
+	c.ServeSuccessJSON(map[string]interface{}{
310
+		"sign": signForm,
311
+	})
312
+	return
313
+}
314
+
315
+func (c *SignWeighAPIController) GetPatientList() {
316
+	patientID, _ := c.GetInt64("patient_id", 0)
317
+	fmt.Println("patientID是设么", patientID)
318
+	adminUserInfo := c.GetAdminUserInfo()
319
+	nowDateTime := time.Now()
320
+	nowDate := nowDateTime.Format("2006-01-02")
321
+	nowDate += " 00:00:00"
322
+	timeLayout := "2006-01-02"
323
+	loc, _ := time.LoadLocation("Local")
324
+	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
325
+	datetime := theTime.Unix()
326
+
327
+	list := service.GetPatientInformationList(adminUserInfo.CurrentOrgId, patientID, datetime)
328
+	c.ServeSuccessJSON(map[string]interface{}{
329
+		"patientlist": list,
330
+	})
331
+	return
332
+}
333
+
334
+func (c *SignWeighAPIController) GetInforByPatientId() {
335
+	patientID, _ := c.GetInt64("patient_id", 0)
336
+	adminUserInfo := c.GetAdminUserInfo()
337
+	nowDateTime := time.Now()
338
+	nowDate := nowDateTime.Format("2006-01-02")
339
+	nowDate += " 00:00:00"
340
+	timeLayout := "2006-01-02"
341
+	loc, _ := time.LoadLocation("Local")
342
+	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
343
+	datetime := theTime.Unix()
344
+	patient := service.GetInforByPatient(adminUserInfo.CurrentOrgId, patientID, datetime)
345
+	fmt.Println("patient是什么", patient)
346
+	c.ServeSuccessJSON(map[string]interface{}{
347
+		"patientinfor": patient,
348
+	})
349
+}
350
+
351
+func (c *SignWeighAPIController) SaveData() {
352
+	adminUserInfo := c.GetAdminUserInfo()
353
+	orgId := adminUserInfo.CurrentOrgId
354
+	patient_id, _ := c.GetInt64("patient_id", 0)
355
+	weight_before, _ := c.GetFloat("weight_before", 0)
356
+	dry_weight, _ := c.GetFloat("dry_weight", 0)
357
+	temperature, _ := c.GetFloat("temperature", 0)
358
+	pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
359
+	breathing_rate, _ := c.GetFloat("breathing_rate", 0)
360
+	systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
361
+	diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
362
+
363
+	predialysisevaluation := &models.PredialysisEvaluation{
364
+		WeightBefore:           weight_before,
365
+		DryWeight:              dry_weight,
366
+		Temperature:            temperature,
367
+		PulseFrequency:         pulse_frequency,
368
+		BreathingRate:          breathing_rate,
369
+		SystolicBloodPressure:  systolic_blood_pressure,
370
+		DiastolicBloodPressure: diastolic_blood_pressure,
371
+	}
372
+	data := service.SaveData(predialysisevaluation, patient_id, orgId)
373
+	c.ServeSuccessJSON(map[string]interface{}{
374
+		"params": data,
375
+	})
376
+}
377
+
378
+func (c *SignWeighAPIController) EditData() {
379
+	adminUserInfo := c.GetAdminUserInfo()
380
+	orgId := adminUserInfo.CurrentOrgId
381
+	patient_id, _ := c.GetInt64("patient_id", 0)
382
+	weight_after, _ := c.GetFloat("weight_after", 0)
383
+	dry_weight, _ := c.GetFloat("dry_weight", 0)
384
+	temperature, _ := c.GetFloat("temperature", 0)
385
+	pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
386
+	breathing_rate, _ := c.GetFloat("breathing_rate", 0)
387
+	systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
388
+	diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
389
+
390
+	assessmentafterdislysis := &models.AssessmentAfterDislysis{
391
+		WeightAfter:            weight_after,
392
+		DryWeight:              dry_weight,
393
+		Temperature:            temperature,
394
+		PulseFrequency:         pulse_frequency,
395
+		BreathingRate:          breathing_rate,
396
+		SystolicBloodPressure:  systolic_blood_pressure,
397
+		DiastolicBloodPressure: diastolic_blood_pressure,
398
+	}
399
+	editdata := service.Editdata(assessmentafterdislysis, patient_id, orgId)
400
+	c.ServeSuccessJSON(map[string]interface{}{
401
+		"params": editdata,
402
+	})
403
+}
404
+
405
+func (c *SignWeighAPIController) Sighdata() {
406
+
407
+	patientID, _ := c.GetInt64("patient_id", 0)
408
+	fmt.Println("patientID", patientID)
409
+	dateTime := c.GetString("date_time")
410
+	fmt.Println(patientID, dateTime)
411
+
412
+	timeLayout := "2006-01-02"
413
+	loc, _ := time.LoadLocation("Local")
414
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", dateTime+" 00:00:00", loc)
415
+	if err != nil {
416
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
417
+		return
418
+	}
419
+	dateTimeStam := theTime.Unix()
420
+	adminUserInfo := c.GetAdminUserInfo()
421
+	sign, errord := service.GetSign(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
422
+	fmt.Println("sign", sign)
423
+	fmt.Println(err)
424
+	weighbefore, _ := c.GetFloat("weight_before", 0)
425
+	dryweightbefore, _ := c.GetFloat("dry_weight", 0)
426
+	temperaturebefore, _ := c.GetFloat("temperature", 0)
427
+	pulsefrequencybefore, _ := c.GetFloat("pulse_frequency", 0)
428
+	breathinratebefore, _ := c.GetFloat("breathing_rate", 0)
429
+	systolicbloodpressurebefore, _ := c.GetFloat("systolic_blood_pressure", 0)
430
+	diastorlicbloodpressurebefore, _ := c.GetFloat("diastolic_blood_pressure", 0)
431
+	weightafter, _ := c.GetFloat("weight_after", 0)
432
+	temperatureafter, _ := c.GetFloat("temperatureafter", 0)
433
+	pulsefrequencyafter, _ := c.GetFloat("pulse_frequencyafter", 0)
434
+	breathingrateafter, _ := c.GetFloat("breathing_rateafter", 0)
435
+	systolicbloodpressureafter, _ := c.GetFloat("systolic_blood_pressureafter", 0)
436
+	diastolicbloodpressureafter, _ := c.GetFloat("diastolic_blood_pressureafter", 0)
437
+
438
+	var sighForm models.SignWeight
439
+
440
+	sighForm.WeightBefore = weighbefore
441
+	sighForm.DryWeightBefore = dryweightbefore
442
+	sighForm.TemperatureBefore = temperaturebefore
443
+	sighForm.PulseFrequencyBefore = pulsefrequencybefore
444
+	sighForm.BreathingRateBefore = breathinratebefore
445
+	sighForm.SystolicBloodPressureBefore = systolicbloodpressurebefore
446
+	sighForm.DiastolicBloodPressureBefore = diastorlicbloodpressurebefore
447
+	sighForm.WeightAfter = weightafter
448
+	sighForm.TemperatureAfter = temperatureafter
449
+	sighForm.PulseFrequencyAfter = pulsefrequencyafter
450
+	sighForm.BreathingRateAfter = breathingrateafter
451
+	sighForm.SystolicBloodPressureAfter = systolicbloodpressureafter
452
+	sighForm.DiastolicBloodPressureAfter = diastolicbloodpressureafter
453
+	sighForm.PatientId = patientID
454
+	sighForm.RecordDate = dateTimeStam
455
+	sighForm.UserOrgId = adminUserInfo.CurrentOrgId
456
+	sighForm.SignTime = time.Now().Unix()
457
+	sighForm.Status = 1
458
+	sighForm.CreatedTime = time.Now().Unix()
459
+
460
+	if sighForm.WeightBefore > 0 {
461
+		sighForm.WeighBeforeTime = time.Now().Unix()
462
+	}
463
+
464
+	if sighForm.WeightAfter > 0 {
465
+		sighForm.WeighTime = time.Now().Unix()
466
+	}
467
+
468
+	if errord == gorm.ErrRecordNotFound {
469
+
470
+		savesignweigh := service.Savesignweigh(&sighForm)
471
+		fmt.Println("savesignweight", savesignweigh)
472
+		c.ServeSuccessJSON(map[string]interface{}{
473
+			"signs": sighForm,
474
+		})
475
+
476
+	} else if errord == nil {
477
+		service.Updatesignweigh(&sighForm, patientID, adminUserInfo.CurrentOrgId)
478
+	} else {
479
+
480
+		service.Updatesignweigh(&sighForm, patientID, adminUserInfo.CurrentOrgId)
481
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
482
+	}
483
+	return
484
+}
485
+
486
+func (c *SignWeighAPIController) UpdateSignweight() {
487
+	patientID, _ := c.GetInt64("patient_id", 0)
488
+	dateTime := c.GetString("date_time")
489
+	fmt.Println("病人ID", patientID, dateTime)
490
+	timeLayout := "2006-01-02"
491
+	loc, _ := time.LoadLocation("Local")
492
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", dateTime+" 00:00:00", loc)
493
+	if err != nil {
494
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
495
+		return
496
+	}
497
+	dateTimeStam := theTime.Unix()
498
+	fmt.Println("datatimestam是什么", dateTimeStam)
499
+	adminUserInfo := c.GetAdminUserInfo()
500
+	fmt.Println(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
501
+	//透前
502
+	weight_before, _ := c.GetFloat("weight_before", 0)
503
+	dry_weight, _ := c.GetFloat("dry_weight", 0)
504
+	temperature, _ := c.GetFloat("temperature", 0)
505
+	fmt.Println("温度", temperature)
506
+	pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
507
+	systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
508
+	diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
509
+	fmt.Println("dry_weight", dry_weight)
510
+	var predialysisevaluation models.PredialysisEvaluation
511
+	predialysisevaluation.PatientId = patientID
512
+	predialysisevaluation.UserOrgId = adminUserInfo.CurrentOrgId
513
+	predialysisevaluation.AssessmentDate = dateTimeStam
514
+	predialysisevaluation.WeightBefore = weight_before
515
+	predialysisevaluation.DryWeight = dry_weight
516
+	predialysisevaluation.Temperature = temperature
517
+	predialysisevaluation.PulseFrequency = pulse_frequency
518
+	predialysisevaluation.SystolicBloodPressure = systolic_blood_pressure
519
+	predialysisevaluation.DiastolicBloodPressure = diastolic_blood_pressure
520
+	predialysisevaluation.CreatedTime = time.Now().Unix()
521
+	predialysisevaluation.Status = 1
522
+
523
+	predialysis, errcode := service.GetDislysisBerfore(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
524
+	fmt.Println("sigh", predialysis)
525
+	fmt.Println("错误:", errcode)
526
+	if errcode == gorm.ErrRecordNotFound {
527
+		service.SaveDislysisiBefore(&predialysisevaluation)
528
+	} else if errcode == nil {
529
+
530
+		service.UpdataDislysisiBefore(&predialysisevaluation, patientID, adminUserInfo.CurrentOrgId, dateTimeStam)
531
+	} else {
532
+		service.UpdataDislysisiBefore(&predialysisevaluation, patientID, adminUserInfo.CurrentOrgId, dateTimeStam)
533
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
534
+	}
535
+
536
+	//透后
537
+	weight_after, _ := c.GetFloat("weight_after", 0)
538
+	temperatureafter, _ := c.GetFloat("temperatureafter", 0)
539
+	pulsefrequencyafter, _ := c.GetFloat("pulse_frequencyafter", 0)
540
+	systolicbloodpressureafter, _ := c.GetFloat("systolic_blood_pressureafter", 0)
541
+	diastolicbloodpressureafter, _ := c.GetFloat("diastolic_blood_pressureafter", 0)
542
+
543
+	var assessmentafterdislysis models.AssessmentAfterDislysis
544
+	assessmentafterdislysis.PatientId = patientID
545
+	assessmentafterdislysis.UserOrgId = adminUserInfo.CurrentOrgId
546
+	assessmentafterdislysis.AssessmentDate = dateTimeStam
547
+	assessmentafterdislysis.WeightAfter = weight_after
548
+	assessmentafterdislysis.Temperature = temperatureafter
549
+	assessmentafterdislysis.PulseFrequency = pulsefrequencyafter
550
+	assessmentafterdislysis.SystolicBloodPressure = systolicbloodpressureafter
551
+	assessmentafterdislysis.DiastolicBloodPressure = diastolicbloodpressureafter
552
+	assessmentafterdislysis.CreatedTime = time.Now().Unix()
553
+	assessmentafterdislysis.Status = 1
554
+	dislysis, errcoder := service.GetAssessmentaafterdislysis(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
555
+	fmt.Println("sigh", dislysis)
556
+	fmt.Println("错误装太:", errcoder)
557
+
558
+	if errcoder == gorm.ErrRecordNotFound {
559
+		service.SaveAssessmentafter(&assessmentafterdislysis)
560
+		c.ServeSuccessJSON(map[string]interface{}{
561
+			"signs": predialysisevaluation,
562
+		})
563
+	} else if errcoder == nil {
564
+		service.UpdataAssessment(&assessmentafterdislysis, patientID, adminUserInfo.CurrentOrgId, dateTimeStam)
565
+		c.ServeSuccessJSON(map[string]interface{}{
566
+			"signs": predialysisevaluation,
567
+		})
568
+	} else {
569
+		service.UpdataAssessment(&assessmentafterdislysis, patientID, adminUserInfo.CurrentOrgId, dateTimeStam)
570
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
571
+	}
572
+}
573
+
574
+//func (c *SignWeighAPIController) GetForenoonData()  {
575
+//	nowDateTime := time.Now()
576
+//	nowDate := nowDateTime.Format("2006-01-02")
577
+//	nowDate += " 00:00:00"
578
+//	timeLayout := "2006-01-02"
579
+//	loc, _ := time.LoadLocation("Local")
580
+//	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
581
+//	datetime := theTime.Unix()
582
+//	fmt.Println("hhhhhhhhhhhhhhhhhhh")
583
+//	fmt.Println("datetime",datetime)
584
+//	adminUserInfo := c.GetAdminUserInfo()
585
+//	orgId := adminUserInfo.CurrentOrgId
586
+//	fmt.Println("orgid是什么",orgId)
587
+//	total, schedule, err := service.GetForenoonData(datetime, orgId, 1)
588
+//	fmt.Println("total",total)
589
+//	fmt.Println("schedule",schedule)
590
+//	if err != nil {
591
+//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
592
+//		return
593
+//	}
594
+//
595
+//	c.ServeSuccessJSON(map[string]interface{}{
596
+//		"total": total,
597
+//	})
598
+//
599
+//}

+ 69 - 0
controllers/statistics_api_controller.go View File

@@ -0,0 +1,69 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/service"
5
+	"github.com/astaxie/beego"
6
+	"time"
7
+)
8
+
9
+type StatisticsApiController struct {
10
+	BaseAuthAPIController
11
+}
12
+
13
+func StatisticsApiRegistRouters() {
14
+
15
+	beego.Router("/api/statistisc/index", &StatisticsApiController{}, "get:GetStatistics")
16
+
17
+}
18
+
19
+func (c *StatisticsApiController) GetStatistics() {
20
+	adminUserInfo := c.GetAdminUserInfo()
21
+
22
+	// thisTime := time.Now()
23
+	year, month, day := time.Now().Date()
24
+	todayTime := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
25
+	startYearTime := time.Date(year, 1, 1, 0, 0, 0, 0, time.Local)
26
+	endYearTime := time.Date(year+1, 1, 1, 0, 0, 0, 0, time.Local)
27
+
28
+	todayWeek := int(todayTime.Weekday())
29
+	if todayWeek == 0 {
30
+		todayWeek = 7
31
+	}
32
+
33
+	weekEnd := 7 - todayWeek
34
+	weekStart := weekEnd - 6
35
+	// endDay := todayTime.AddDate(0, 0, weekEnd)
36
+	startDay := todayTime.AddDate(0, 0, weekStart)
37
+
38
+	//患者总数
39
+	patientCount := service.GetPatientCount(adminUserInfo.CurrentOrgId)
40
+
41
+	//今日透析
42
+	todayDialysisCount := service.GetDayDialysisCount(adminUserInfo.CurrentOrgId, todayTime.Unix())
43
+
44
+	//本周透析
45
+	weekDaylysisCount := service.GetTimebetweenDialysisCount(adminUserInfo.CurrentOrgId, startDay.Unix(), todayTime.Unix())
46
+
47
+	//传染病
48
+	diseaseCounts := service.GetPatientContagionCounts(adminUserInfo.CurrentOrgId)
49
+
50
+	//性别分布
51
+	genderCounts := service.GetPatientGenderCounts(adminUserInfo.CurrentOrgId)
52
+
53
+	//年龄分布
54
+	ageCounts := service.GetPatiendAgeBetweenCount(adminUserInfo.CurrentOrgId)
55
+
56
+	//透析模式
57
+	modeCounts := service.GetPatientDialysisModeBetweenCount(adminUserInfo.CurrentOrgId, startYearTime.Unix(), endYearTime.Unix())
58
+
59
+	c.ServeSuccessJSON(map[string]interface{}{
60
+		"patient_count":        patientCount,
61
+		"today_dialysis_count": todayDialysisCount,
62
+		"week_daylysis_count":  weekDaylysisCount,
63
+		"disease_counts":       diseaseCounts,
64
+		"gender_counts":        genderCounts,
65
+		"age_counts":           ageCounts,
66
+		"mode_counts":          modeCounts,
67
+	})
68
+
69
+}

+ 379 - 0
controllers/stock_api_controller.go View File

@@ -0,0 +1,379 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/models"
6
+	"Xcx_New/service"
7
+	"Xcx_New/utils"
8
+	"github.com/astaxie/beego"
9
+	"github.com/jinzhu/gorm"
10
+	"strconv"
11
+	"time"
12
+)
13
+
14
+type StockApiController struct {
15
+	BaseAuthAPIController
16
+}
17
+
18
+func StockApiRegistRouters() {
19
+	beego.Router("/api/stock/dealer/create", &StockApiController{}, "post:CreateDealer")
20
+	beego.Router("/api/stock/dealer/modify", &StockApiController{}, "post:ModifyDealer")
21
+	beego.Router("/api/stock/dealer/list", &StockApiController{}, "get:GetDealersList")
22
+	beego.Router("/api/stock/dealer/delete", &StockApiController{}, "post:DeleteDealer")
23
+	beego.Router("/api/stock/dealer/get", &StockApiController{}, "get:GetDealer")
24
+
25
+	beego.Router("/api/stock/manufacturer/create", &StockApiController{}, "post:CreateManufacturer")
26
+	beego.Router("/api/stock/manufacturer/modify", &StockApiController{}, "post:ModifyManufacturer")
27
+	beego.Router("/api/stock/manufacturer/list", &StockApiController{}, "get:GetManufacturerList")
28
+	beego.Router("/api/stock/manufacturer/delete", &StockApiController{}, "post:DeleteManufacturer")
29
+	beego.Router("/api/stock/manufacturer/get", &StockApiController{}, "get:GetManufacturer")
30
+
31
+	beego.Router("/api/stock/dealer/all", &StockApiController{}, "get:GetAllDealer")
32
+	beego.Router("/api/stock/manufacturer/all", &StockApiController{}, "get:GetAllManufacturer")
33
+
34
+}
35
+
36
+func (c *StockApiController) CreateDealer() {
37
+	dealer_name := c.GetString("dealer_name")
38
+	contact := c.GetString("contact")
39
+	contact_phone := c.GetString("contact_phone")
40
+	platform_number := c.GetString("platform_number")
41
+	email := c.GetString("email")
42
+	contact_address := c.GetString("contact_address")
43
+	remark := c.GetString("remark")
44
+	wubi := c.GetString("wubi")
45
+	pinyin := c.GetString("pinyin")
46
+
47
+	if len(dealer_name) <= 0 {
48
+		utils.ErrorLog("len(dealer_name) == 0")
49
+
50
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
51
+		return
52
+	}
53
+
54
+	adminUserInfo := c.GetAdminUserInfo()
55
+
56
+	total := service.FindAllDealerTotal(adminUserInfo.CurrentOrgId)
57
+	totalStr := strconv.FormatInt(total+1, 10)
58
+	code := "1000" + totalStr
59
+	dealer := models.Dealer{
60
+		DealerName:     dealer_name,
61
+		Contact:        contact,
62
+		ContactPhone:   contact_phone,
63
+		ContactAddress: contact_address,
64
+		DealerCode:     code,
65
+		Ctime:          time.Now().Unix(),
66
+		Mtime:          time.Now().Unix(),
67
+		Remark:         remark,
68
+		Creater:        adminUserInfo.AdminUser.Id,
69
+		Email:          email,
70
+		PlatformNumber: platform_number,
71
+		OrgId:          adminUserInfo.CurrentOrgId,
72
+		Status:         1,
73
+		WuBi:           wubi,
74
+		PinYin:         pinyin,
75
+	}
76
+
77
+	err, dealers := service.AddSigleDealer(&dealer)
78
+	if err == nil {
79
+		c.ServeSuccessJSON(map[string]interface{}{
80
+			"dealer": dealers,
81
+		})
82
+
83
+	} else {
84
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
85
+
86
+	}
87
+
88
+}
89
+func (c *StockApiController) ModifyDealer() {
90
+	id, _ := c.GetInt64("id", 0)
91
+	dealer_name := c.GetString("dealer_name")
92
+	contact := c.GetString("contact")
93
+	contact_phone := c.GetString("contact_phone")
94
+	platform_number := c.GetString("platform_number")
95
+	dealer_code := c.GetString("dealer_code")
96
+	email := c.GetString("email")
97
+	contact_address := c.GetString("contact_address")
98
+	remark := c.GetString("remark")
99
+	wubi := c.GetString("wubi")
100
+	pinyin := c.GetString("pinyin")
101
+
102
+	if id <= 0 {
103
+		utils.ErrorLog("id == 0")
104
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
105
+		return
106
+	}
107
+
108
+	if len(dealer_name) <= 0 {
109
+		utils.ErrorLog("len(dealer_name) == 0")
110
+
111
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
112
+		return
113
+	}
114
+
115
+	adminUserInfo := c.GetAdminUserInfo()
116
+	dealer := models.Dealer{
117
+		ID:             id,
118
+		DealerName:     dealer_name,
119
+		Contact:        contact,
120
+		ContactPhone:   contact_phone,
121
+		ContactAddress: contact_address,
122
+		Mtime:          time.Now().Unix(),
123
+		DealerCode:     dealer_code,
124
+		Remark:         remark,
125
+		Creater:        adminUserInfo.AdminUser.Id,
126
+		Email:          email,
127
+		PlatformNumber: platform_number,
128
+		Modifier:       adminUserInfo.AdminUser.Id,
129
+		OrgId:          adminUserInfo.CurrentOrgId,
130
+		Status:         1,
131
+		WuBi:           wubi,
132
+		PinYin:         pinyin,
133
+	}
134
+
135
+	err := service.ModifyDealer(&dealer)
136
+
137
+	if err == nil {
138
+		c.ServeSuccessJSON(map[string]interface{}{
139
+			"dealer": dealer,
140
+		})
141
+	} else {
142
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
143
+	}
144
+}
145
+func (c *StockApiController) GetDealersList() {
146
+	page, _ := c.GetInt64("page", 1)
147
+	limit, _ := c.GetInt64("limit", 7)
148
+	adminUserInfo := c.GetAdminUserInfo()
149
+	deales, total, err := service.FindAllDealerList(adminUserInfo.CurrentOrgId, page, limit)
150
+	if err == nil {
151
+		c.ServeSuccessJSON(map[string]interface{}{
152
+			"dealer": deales,
153
+			"total":  total,
154
+		})
155
+	} else {
156
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
157
+	}
158
+}
159
+func (c *StockApiController) DeleteDealer() {
160
+	id, _ := c.GetInt64("id", 0)
161
+	total, _ := service.FindStockInByDealerId(id)
162
+	if total > 0 {
163
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteDealerWrong)
164
+		return
165
+	}
166
+	err := service.DeleteDealerById(id)
167
+	if err == nil {
168
+		c.ServeSuccessJSON(map[string]interface{}{
169
+			"msg": "删除成功",
170
+		})
171
+	} else {
172
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
173
+	}
174
+}
175
+
176
+func (c *StockApiController) GetDealer() {
177
+	id, _ := c.GetInt64("id", 0)
178
+	dealer, err := service.FindDealerById(id)
179
+	if err == nil {
180
+		c.ServeSuccessJSON(map[string]interface{}{
181
+			"dealer": dealer,
182
+		})
183
+	} else {
184
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
185
+	}
186
+}
187
+
188
+func (c *StockApiController) CreateManufacturer() {
189
+	manufacturer_name := c.GetString("manufacturer_name")
190
+	contact := c.GetString("contact")
191
+	contact_phone := c.GetString("contact_phone")
192
+	platform_number := c.GetString("platform_number")
193
+	email := c.GetString("email")
194
+	contact_address := c.GetString("contact_address")
195
+	remark := c.GetString("remark")
196
+	wubi := c.GetString("wubi")
197
+	pinyin := c.GetString("pinyin")
198
+
199
+	if len(manufacturer_name) <= 0 {
200
+		utils.ErrorLog("len(manufacturer_name) == 0")
201
+
202
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
203
+		return
204
+	}
205
+
206
+	adminUserInfo := c.GetAdminUserInfo()
207
+	total := service.FindManufacturerTotal(adminUserInfo.CurrentOrgId)
208
+	totalStr := strconv.FormatInt(total+1, 10)
209
+	code := "2000" + totalStr
210
+	manufacturer := models.Manufacturer{
211
+		ManufacturerName: manufacturer_name,
212
+		Contact:          contact,
213
+		ContactPhone:     contact_phone,
214
+		ContactAddress:   contact_address,
215
+		Ctime:            time.Now().Unix(),
216
+		Mtime:            time.Now().Unix(),
217
+		Remark:           remark,
218
+		Creater:          adminUserInfo.AdminUser.Id,
219
+		Email:            email,
220
+		PlatformNumber:   platform_number,
221
+		OrgId:            adminUserInfo.CurrentOrgId,
222
+		Status:           1,
223
+		ManufacturerCode: code,
224
+		WuBi:             wubi,
225
+		PinYin:           pinyin,
226
+	}
227
+
228
+	_, errcode := service.GetManufacturerName(adminUserInfo.CurrentOrgId, manufacturer_name)
229
+	if errcode == gorm.ErrRecordNotFound {
230
+		err, manufacturers := service.AddSigleManufacturer(&manufacturer)
231
+		if err == nil {
232
+			c.ServeSuccessJSON(map[string]interface{}{
233
+				"manufacturer": manufacturers,
234
+			})
235
+
236
+		} else {
237
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
238
+		}
239
+	} else if errcode == nil {
240
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
241
+	}
242
+
243
+}
244
+func (c *StockApiController) ModifyManufacturer() {
245
+
246
+	id, _ := c.GetInt64("id", 0)
247
+	manufacturer_name := c.GetString("manufacturer_name")
248
+	contact := c.GetString("contact")
249
+	contact_phone := c.GetString("contact_phone")
250
+	platform_number := c.GetString("platform_number")
251
+	email := c.GetString("email")
252
+	contact_address := c.GetString("contact_address")
253
+	remark := c.GetString("remark")
254
+	manufacturer_code := c.GetString("manufacturer_code")
255
+	wubi := c.GetString("wubi")
256
+	pinyin := c.GetString("pinyin")
257
+
258
+	if id <= 0 {
259
+		utils.ErrorLog("id == 0")
260
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
261
+		return
262
+	}
263
+
264
+	if len(manufacturer_name) <= 0 {
265
+		utils.ErrorLog("len(manufacturer_name) == 0")
266
+
267
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
268
+		return
269
+	}
270
+
271
+	adminUserInfo := c.GetAdminUserInfo()
272
+	manufacturer := models.Manufacturer{
273
+		ID:               id,
274
+		ManufacturerName: manufacturer_name,
275
+		Contact:          contact,
276
+		ContactPhone:     contact_phone,
277
+		ContactAddress:   contact_address,
278
+		Mtime:            time.Now().Unix(),
279
+		Remark:           remark,
280
+		Creater:          adminUserInfo.AdminUser.Id,
281
+		Email:            email,
282
+		PlatformNumber:   platform_number,
283
+		Modifier:         adminUserInfo.AdminUser.Id,
284
+		OrgId:            adminUserInfo.CurrentOrgId,
285
+		ManufacturerCode: manufacturer_code,
286
+		Status:           1,
287
+		WuBi:             wubi,
288
+		PinYin:           pinyin,
289
+	}
290
+
291
+	_, errrcode := service.GetManufacturerName(adminUserInfo.CurrentOrgId, manufacturer_name)
292
+
293
+	if errrcode == nil {
294
+
295
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIdCardNoExist)
296
+
297
+		return
298
+	}
299
+
300
+	err := service.ModifyManufacturer(&manufacturer)
301
+
302
+	if err == nil {
303
+		c.ServeSuccessJSON(map[string]interface{}{
304
+			"manufacturer": manufacturer,
305
+		})
306
+	} else {
307
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
308
+	}
309
+
310
+}
311
+func (c *StockApiController) GetManufacturerList() {
312
+	page, _ := c.GetInt64("page", 1)
313
+	limit, _ := c.GetInt64("limit", 10)
314
+	adminUserInfo := c.GetAdminUserInfo()
315
+	manufacturer, total, err := service.FindAllManufacturerList(adminUserInfo.CurrentOrgId, page, limit)
316
+	if err == nil {
317
+		c.ServeSuccessJSON(map[string]interface{}{
318
+			"manufacturer": manufacturer,
319
+			"total":        total,
320
+		})
321
+	} else {
322
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
323
+	}
324
+}
325
+func (c *StockApiController) DeleteManufacturer() {
326
+	id, _ := c.GetInt64("id", 0)
327
+	total, _ := service.FindStockInByManufacturerId(id)
328
+	if total > 0 {
329
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteManufacturerWrong)
330
+		return
331
+	}
332
+
333
+	err := service.DeleteManufacturerById(id)
334
+	if err == nil {
335
+		c.ServeSuccessJSON(map[string]interface{}{
336
+			"msg": "删除成功",
337
+		})
338
+	} else {
339
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
340
+	}
341
+}
342
+func (c *StockApiController) GetManufacturer() {
343
+	id, _ := c.GetInt64("id", 0)
344
+	manufacturer, err := service.FindManufacturerById(id)
345
+	if err == nil {
346
+		c.ServeSuccessJSON(map[string]interface{}{
347
+			"manufacturer": manufacturer,
348
+		})
349
+	} else {
350
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
351
+	}
352
+
353
+}
354
+
355
+func (c *StockApiController) GetAllDealer() {
356
+	adminUserInfo := c.GetAdminUserInfo()
357
+	dealer, err := service.FindAllDealer(adminUserInfo.CurrentOrgId)
358
+	if err == nil {
359
+		c.ServeSuccessJSON(map[string]interface{}{
360
+			"dealer": dealer,
361
+		})
362
+	} else {
363
+
364
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
365
+	}
366
+}
367
+
368
+func (c *StockApiController) GetAllManufacturer() {
369
+	adminUserInfo := c.GetAdminUserInfo()
370
+	manufacturer, err := service.FindAllManufacturer(adminUserInfo.CurrentOrgId)
371
+	if err == nil {
372
+		c.ServeSuccessJSON(map[string]interface{}{
373
+			"manufacturer": manufacturer,
374
+		})
375
+	} else {
376
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
377
+	}
378
+
379
+}

+ 228 - 0
controllers/stock_good_api_controller.go View File

@@ -0,0 +1,228 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/models"
6
+	"Xcx_New/service"
7
+	"fmt"
8
+	"github.com/astaxie/beego"
9
+	"strconv"
10
+	"time"
11
+)
12
+
13
+type StockGoodApiController struct {
14
+	BaseAuthAPIController
15
+}
16
+
17
+func StockGoodApiRegistRouters() {
18
+	beego.Router("/api/stock/good/type/create", &StockGoodApiController{}, "post:CreateGoodType")
19
+	beego.Router("/api/stock/good/type/modify", &StockGoodApiController{}, "post:ModifyGoodType")
20
+	beego.Router("/api/stock/good/type/list", &StockGoodApiController{}, "get:GetGoodTypeList")
21
+	beego.Router("/api/type/delete", &StockGoodApiController{}, "post:DeleteGoodType")
22
+	beego.Router("/api/stock/good/type/get", &StockGoodApiController{}, "get:GetGoodType")
23
+	//
24
+	//beego.Router("/api/stock/good/info/create", &StockGoodApiController{}, "post:CreateGoodInfo")
25
+	//beego.Router("/api/stock/good/info/modify", &StockGoodApiController{}, "post:ModifyGoodInfo")
26
+	//beego.Router("/api/stock/good/info/list", &StockGoodApiController{}, "get:GetGoodInfoList")
27
+	//beego.Router("/api/info/delete", &StockGoodApiController{}, "post:DeleteGoodInfo")
28
+	//beego.Router("/api/stock/good/info/get", &StockGoodApiController{}, "get:GetGoodInfoByGoodId")
29
+	//beego.Router("/api/stock/good/info", &StockGoodApiController{}, "get:GetGoodInfoById")
30
+
31
+	beego.Router("/api/stock/good/type/all", &StockGoodApiController{}, "get:GetAllGoodType")
32
+	beego.Router("/api/stock/good/info/all", &StockGoodApiController{}, "get:GetAllGoodInfo")
33
+	beego.Router("/api/good/get", &StockGoodApiController{}, "get:GetAllGood")
34
+
35
+}
36
+
37
+func (c *StockGoodApiController) CreateGoodType() {
38
+	type_name := c.GetString("type_name")
39
+	remark := c.GetString("remark")
40
+	out_stock := c.GetString("out_stock")
41
+	outStockInt, _ := strconv.ParseInt(out_stock, 10, 64)
42
+	stock_attribute := c.GetString("stock_attribute")
43
+	stockAttribute, _ := strconv.ParseInt(stock_attribute, 10, 64)
44
+	adminUserInfo := c.GetAdminUserInfo()
45
+	totals := service.FindGoodTypeByName(type_name, adminUserInfo.CurrentOrgId)
46
+	if totals > 0 {
47
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodTypeNameExistError)
48
+		return
49
+	}
50
+
51
+	total := service.FindAllGoodTypeTotal(adminUserInfo.CurrentOrgId)
52
+	code := strconv.FormatInt(total+1, 10)
53
+	code = "34000000" + code
54
+
55
+	goodType := models.GoodsType{
56
+		TypeCode:       code,
57
+		TypeName:       type_name,
58
+		Remark:         remark,
59
+		Ctime:          time.Now().Unix(),
60
+		Mtime:          time.Now().Unix(),
61
+		OrgId:          adminUserInfo.CurrentOrgId,
62
+		Creater:        adminUserInfo.AdminUser.Id,
63
+		Status:         1,
64
+		OutStock:       outStockInt,
65
+		StockAttribute: stockAttribute,
66
+	}
67
+	err, types := service.AddSigleGoodType(&goodType)
68
+	if err == nil {
69
+		c.ServeSuccessJSON(map[string]interface{}{
70
+			"goodTypes": types,
71
+		})
72
+	} else {
73
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
74
+	}
75
+}
76
+
77
+func (c *StockGoodApiController) ModifyGoodType() {
78
+	id, _ := c.GetInt64("id", 0)
79
+	type_name := c.GetString("type_name")
80
+	remark := c.GetString("remark")
81
+	good_type_code := c.GetString("type_code")
82
+	out_stock := c.GetString("out_stock")
83
+	outStockInt, _ := strconv.ParseInt(out_stock, 10, 64)
84
+	adminUserInfo := c.GetAdminUserInfo()
85
+	stock_attribute := c.GetString("stock_attribute")
86
+	stockAttribute, _ := strconv.ParseInt(stock_attribute, 10, 64)
87
+	//totals := service.FindGoodTypeByName(type_name, adminUserInfo.CurrentOrgId)
88
+	//if totals > 0 {
89
+	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodTypeNameExistError)
90
+	//	return
91
+	//}
92
+
93
+	goodType := models.GoodsType{
94
+		ID:             id,
95
+		TypeCode:       good_type_code,
96
+		TypeName:       type_name,
97
+		Remark:         remark,
98
+		Ctime:          time.Now().Unix(),
99
+		Mtime:          time.Now().Unix(),
100
+		OrgId:          adminUserInfo.CurrentOrgId,
101
+		Modifier:       adminUserInfo.AdminUser.Id,
102
+		Status:         1,
103
+		OutStock:       outStockInt,
104
+		StockAttribute: stockAttribute,
105
+	}
106
+	err, types := service.ModifyGoodType(&goodType)
107
+	if err == nil {
108
+		c.ServeSuccessJSON(map[string]interface{}{
109
+			"goodTypes": types,
110
+		})
111
+	} else {
112
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
113
+	}
114
+
115
+}
116
+
117
+func (c *StockGoodApiController) GetGoodTypeList() {
118
+	page, _ := c.GetInt64("page", 1)
119
+	limit, _ := c.GetInt64("limit", 7)
120
+	keyword := c.GetString("keyword")
121
+
122
+	adminUserInfo := c.GetAdminUserInfo()
123
+	goodTypes, total, err := service.FindAllGoodTypeList(adminUserInfo.CurrentOrgId, page, limit, keyword)
124
+
125
+	if err == nil {
126
+		c.ServeSuccessJSON(map[string]interface{}{
127
+			"list":  goodTypes,
128
+			"total": total,
129
+		})
130
+	} else {
131
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
132
+	}
133
+}
134
+
135
+func (c *StockGoodApiController) DeleteGoodType() {
136
+	id, _ := c.GetInt64("id", 0)
137
+	adminUserInfo := c.GetAdminUserInfo()
138
+	goodInfo, _ := service.FindGoodInfoByGoodId(id)
139
+	autoDetail, _ := service.FindStockOutDetailGoodInfoByGoodId(id)
140
+
141
+	if len(goodInfo) > 0 {
142
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteGoodTypeFail)
143
+		return
144
+	}
145
+
146
+	if len(autoDetail) > 0 {
147
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteGoodInfoFail)
148
+		return
149
+	}
150
+
151
+	err := service.DeleteGoodTypeById(id, adminUserInfo.AdminUser.Id)
152
+	if err == nil {
153
+		c.ServeSuccessJSON(map[string]interface{}{
154
+			"msg": "删除成功",
155
+		})
156
+	} else {
157
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
158
+	}
159
+
160
+}
161
+func (c *StockGoodApiController) GetGoodType() {
162
+	id, _ := c.GetInt64("id", 0)
163
+	goodType, err := service.FindGoodTypeById(id)
164
+	if err == nil {
165
+		c.ServeSuccessJSON(map[string]interface{}{
166
+			"goodType": goodType,
167
+		})
168
+	} else {
169
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
170
+	}
171
+
172
+}
173
+
174
+func (c *StockGoodApiController) GetAllGoodType() {
175
+	adminUserInfo := c.GetAdminUserInfo()
176
+	goodTypes, err := service.FindAllGoodType(adminUserInfo.CurrentOrgId)
177
+	if err == nil {
178
+		c.ServeSuccessJSON(map[string]interface{}{
179
+			"goodType": goodTypes,
180
+		})
181
+	} else {
182
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
183
+	}
184
+}
185
+
186
+func (c *StockGoodApiController) GetAllGoodInfo() {
187
+	adminUserInfo := c.GetAdminUserInfo()
188
+	goodInfo, err := service.FindAllGoodInfo(adminUserInfo.CurrentOrgId)
189
+	if err == nil {
190
+		c.ServeSuccessJSON(map[string]interface{}{
191
+			"goodInfo": goodInfo,
192
+		})
193
+	} else {
194
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
195
+	}
196
+}
197
+
198
+func (c *StockGoodApiController) GetAllGood() {
199
+	adminUserInfo := c.GetAdminUserInfo()
200
+	manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
201
+	dealer_id, _ := c.GetInt64("dealer_id", 0)
202
+	fmt.Println(manufacturer_id)
203
+	fmt.Println(dealer_id)
204
+
205
+	goodInfo, err := service.FindAllGoodByManufactureId(manufacturer_id, dealer_id, adminUserInfo.CurrentOrgId)
206
+	if err == nil {
207
+		c.ServeSuccessJSON(map[string]interface{}{
208
+			"goodInfo": goodInfo,
209
+		})
210
+	} else {
211
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
212
+	}
213
+}
214
+
215
+func (c *StockGoodApiController) GetWarehouseGoodInfo() {
216
+	adminUserInfo := c.GetAdminUserInfo()
217
+	manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
218
+	dealer_id, _ := c.GetInt64("dealer_id", 0)
219
+
220
+	goodInfo, err := service.FindAllGoodByManufactureId(manufacturer_id, dealer_id, adminUserInfo.CurrentOrgId)
221
+	if err == nil {
222
+		c.ServeSuccessJSON(map[string]interface{}{
223
+			"goodInfo": goodInfo,
224
+		})
225
+	} else {
226
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
227
+	}
228
+}

File diff suppressed because it is too large
+ 6137 - 0
controllers/stock_in_api_controller.go


+ 5 - 0
controllers/stock_warrhouse_contorller.go View File

@@ -0,0 +1,5 @@
1
+package controllers
2
+
3
+func main() {
4
+
5
+}

+ 0 - 325
controllers/sync.go View File

@@ -1,325 +0,0 @@
1
-package controllers
2
-
3
-import (
4
-	"Data_Upload_Api/enums"
5
-	"Data_Upload_Api/models/sz"
6
-	"Data_Upload_Api/service"
7
-	"Data_Upload_Api/service/city"
8
-	"Data_Upload_Api/utils"
9
-	"fmt"
10
-	_ "fmt"
11
-	"github.com/astaxie/beego"
12
-	_ "github.com/jinzhu/gorm"
13
-	_ "math"
14
-	_ "strconv"
15
-	_ "strings"
16
-	_ "time"
17
-)
18
-
19
-type SyncController struct {
20
-	BaseAPIController
21
-}
22
-
23
-func SyncAPIRegisterRouters() {
24
-	beego.Router("/sync/upload/hqyy", &SyncController{}, "get:SyncToHqyy")
25
-	beego.Router("/sync/upload/lg2h", &SyncController{}, "get:SyncToLg2h")
26
-	beego.Router("/sync/upload/smzy", &SyncController{}, "get:SyncToSmzy")
27
-	beego.Router("/sync/upload/smyy", &SyncController{}, "get:SyncToTesgt")
28
-
29
-}
30
-
31
-func (c *SyncController) SyncToLg2h() {
32
-	// 第一步:到上报配置表中找到深圳需要上报的机构
33
-	// sz_province, _ := beego.AppConfig.Int64("sz_province")
34
-	// sz_city, _ := beego.AppConfig.Int64("sz_city")
35
-	// configs, _ := service.FindAllDataUploadConfigOrgInfo(sz_province, sz_city, 3)
36
-
37
-	org := &sz.DataUploadConfig{
38
-		OrgId:          9598,
39
-		ProvinceId:     19,
40
-		CityId:         291,
41
-		DepartmentName: "深圳市龙岗区第二人民医院",
42
-		HospitalId:     "455835506",
43
-		InstType:       1,
44
-		DbHost:         "183.62.158.36",
45
-		DbPort:         "61433",
46
-		DbPass:         "LG2H+9897",
47
-		DbUser:         "sa",
48
-		DbName:         "xtzk",
49
-	}
50
-
51
-	// for _, org := range configs {
52
-	// 第二步:跟进配置,创建数据库连接
53
-	if len(org.DbHost) > 0 && len(org.DbUser) > 0 && len(org.DbPort) > 0 && len(org.DbPass) > 0 && len(org.DbName) > 0 {
54
-		orgDb, err := service.CreateSqlServiceDB(org.DbHost, org.DbPort, org.DbUser, org.DbPass, org.DbName)
55
-		if err != nil {
56
-			utils.ErrorLog("创建数据库连接失败:%v", err)
57
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
58
-			return
59
-		}
60
-		fmt.Println("触发了没有22222222")
61
-		// 第三步:开始同步数据
62
-		// 同步医院信息  t_hd_hospital
63
-		// city.SyncHospital(orgDb, org.OrgId, org.HospitalId, org.InstType, org.DepartmentName)
64
-		// // 同步水处理器  t_hd_wm
65
-		// city.SyncWMS(orgDb, org.OrgId, org.HospitalId)
66
-		// // // 同步员工 t_hd_staff
67
-		// city.SyncStaff(orgDb, org.OrgId, org.HospitalId)
68
-		// // // 同步病人 t_hd_patient
69
-		// city.SyncPatient(orgDb, org.OrgId, org.HospitalId)
70
-		// // // 同步排班  t_hd_shift
71
-		// city.SyncShift(orgDb, org.OrgId, org.HospitalId)
72
-		// // 同步处方 t_hd_ps
73
-		// city.SyncPs(orgDb, org.OrgId, org.HospitalId)
74
-		// // 同步处方药品 t_hd_ps
75
-		// city.SyncPsMedicine(orgDb, org.OrgId, org.HospitalId)
76
-		// // // 同步转院信息 t_hd_patient_out
77
-		// city.SyncPatientOut(orgDb, org.OrgId, org.HospitalId)
78
-		// // 同步处方信息 t_hd_doctors_advice
79
-		// city.SyncDoctorAdvice(orgDb, org.OrgId, org.HospitalId)
80
-		// // 同步透中信息 t_hd_middle
81
-		// city.SyncMiddle(orgDb, org.OrgId, org.HospitalId)
82
-		// // // 同步设备 t_hd_other_machine
83
-		// city.SyncOtherMachine(orgDb, org.OrgId, org.HospitalId)
84
-		// // // 同步维修 t_hd_maintain
85
-		// city.SyncMachineRepair(orgDb, org.OrgId, org.HospitalId)
86
-		// // // 同步设备 t_hd_dm
87
-		// city.SyncDM(orgDb, org.OrgId, org.HospitalId)
88
-		// // // 同步患者透析记录 t_hd_dialysis
89
-		// city.SyncDialysis(orgDb, org.OrgId, org.HospitalId)
90
-		// // 同步透析床位分区 t_hd_division
91
-		// city.SyncDivision(orgDb, org.OrgId, org.HospitalId)
92
-		// // 患者通路信息表(T_HD_ACCESS)
93
-		// city.SyncAccess(orgDb, org.OrgId, org.HospitalId)
94
-		// // 透析床位表(T_HD_SICKBED)
95
-		// city.SyncSickbed(orgDb, org.OrgId, org.HospitalId)
96
-		// // 患者诊断信息表(T_HD_DIAGNOSIS)
97
-		// city.SyncDiagnosis(orgDb, org.OrgId, org.HospitalId)
98
-		//  患者传染病检查记录表(T_HD_INFECTION
99
-		//city.SyncInfection(orgDb, org.OrgId, org.HospitalId)
100
-		// //  透析并发症记录表(T_HD_COMPLICATION)
101
-		// city.SyncComplication(orgDb, org.OrgId, org.HospitalId)
102
-		// //  血透患者检测结果表(T_HD_LIS_REPORT)
103
-		// city.SyncLisReport(orgDb, org.OrgId, org.HospitalId)
104
-		// //  血透患者检验结果指标表(T_HD_LIS_INDICATORS)
105
-		// city.SyncLisIndicators(orgDb, org.OrgId, org.HospitalId)
106
-
107
-		// 透析机透析液细菌培养检测记录表(t_hd_dm_dialysate_bc)
108
-		// city.SyncLisCulture(orgDb,org.OrgId,org.HospitalId)
109
-		//透析机透析液内毒素检测记录表(T_HD_DM_DIALYSATE_BC)
110
-		// city.SyncDialysate(orgDb,org.OrgId,org.HospitalId)
111
-
112
-		//物表消毒记录表(T_HD_SURFACE_DISINFECT)
113
-		// city.SyncLisBodyDetection(orgDb,org.OrgId,org.HospitalId)
114
-		// 第四步:关闭数据库连接
115
-
116
-		//透析用水游离氯检测表(T_HD_WATER_FC)
117
-		// city.SyncLisWaterFc(orgDb,org.OrgId,org.HospitalId)
118
-
119
-		//透析用水有毒化学物检测表(T_HD_WATER_NC)
120
-		// city.SynLisWaterNc(orgDb,org.OrgId,org.HospitalId)
121
-
122
-		//透析用水PH值检测表(T_HD_WATER_PH)
123
-		// city.SynLisWaterPh(orgDb,org.OrgId,org.HospitalId)
124
-
125
-		//透析用水水硬度检测表(T_HD_WATER_WH)
126
-		// city.SynListHadWater(orgDb,org.OrgId,org.HospitalId)
127
-
128
-		//导管感染记录表(T_HD_CI)
129
-		// city.SynListHdCi(orgDb,org.OrgId,org.HospitalId)
130
-
131
-		//导管感染转归记录表(T_HD_CI_OUTCOME)
132
-		// city.SynLisHdCiOutCome(orgDb,org.OrgId,org.HospitalId)
133
-
134
-		//透析室空气消毒记录表(T_HD_AIR_DISINFECT)
135
-		// city.SyncLisAirDetection(orgDb,org.OrgId,org.HospitalId)
136
-
137
-		//透析用水细菌培养检测表(T_HD_WATER_BC)
138
-		// city.SyncLisWaterBc(orgDb,org.OrgId,org.HospitalId)
139
-
140
-		//透析用水内毒素检测表(T_HD_WATER_EN)
141
-		// city.SyncLisWaterEn(orgDb,org.OrgId,org.HospitalId)
142
-		// 第四步:关闭数据库连接
143
-		service.CloseDB(orgDb)
144
-	}
145
-	// }
146
-	c.ServeSuccessJSON(map[string]interface{}{
147
-		"resultList": "12345",
148
-	})
149
-	return
150
-}
151
-
152
-func (c *SyncController) SyncToHqyy() {
153
-	// 第一步:到上报配置表中找到深圳需要上报的机构
154
-	// sz_province, _ := beego.AppConfig.Int64("sz_province")
155
-	// sz_city, _ := beego.AppConfig.Int64("sz_city")
156
-	// configs, _ := service.FindAllDataUploadConfigOrgInfo(sz_province, sz_city, 3)
157
-
158
-	org := &sz.DataUploadConfig{
159
-		OrgId:          9442,
160
-		ProvinceId:     19,
161
-		CityId:         291,
162
-		DepartmentName: "暨南大学附属深圳华侨医院",
163
-		HospitalId:     "73307826X",
164
-		InstType:       1,
165
-		DbHost:         "183.11.232.26",
166
-		DbPort:         "3306",
167
-		DbPass:         "1Q2W3e4r!@#$",
168
-		DbUser:         "sa",
169
-		DbName:         "xtzk",
170
-	}
171
-
172
-	// for _, org := range configs {
173
-	// 第二步:跟进配置,创建数据库连接
174
-	if len(org.DbHost) > 0 && len(org.DbUser) > 0 && len(org.DbPort) > 0 && len(org.DbPass) > 0 && len(org.DbName) > 0 {
175
-		orgDb, err := service.CreateSqlServiceDB(org.DbHost, org.DbPort, org.DbUser, org.DbPass, org.DbName)
176
-		if err != nil {
177
-			utils.ErrorLog("创建数据库连接失败:%v", err)
178
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
179
-			return
180
-		}
181
-		// 第三步:开始同步数据
182
-		// 同步医院信息  t_hd_hospital
183
-		city.SyncHospital(orgDb, org.OrgId, org.HospitalId, org.InstType, org.DepartmentName)
184
-		// 同步水处理器  t_hd_wm
185
-		city.SyncWMS(orgDb, org.OrgId, org.HospitalId)
186
-		// // 同步员工 t_hd_staff
187
-		city.SyncStaff(orgDb, org.OrgId, org.HospitalId)
188
-		// // 同步病人 t_hd_patient
189
-		city.SyncPatient(orgDb, org.OrgId, org.HospitalId)
190
-		// // 同步排班  t_hd_shift
191
-		city.SyncShift(orgDb, org.OrgId, org.HospitalId)
192
-		// 同步处方 t_hd_ps
193
-		city.SyncPs(orgDb, org.OrgId, org.HospitalId)
194
-		// 同步处方药品 t_hd_ps
195
-		city.SyncPsMedicine(orgDb, org.OrgId, org.HospitalId)
196
-		// // 同步转院信息 t_hd_patient_out
197
-		city.SyncPatientOut(orgDb, org.OrgId, org.HospitalId)
198
-		// 同步处方信息 t_hd_doctors_advice
199
-		city.SyncDoctorAdvice(orgDb, org.OrgId, org.HospitalId)
200
-		// 同步透中信息 t_hd_middle
201
-		city.SyncMiddle(orgDb, org.OrgId, org.HospitalId)
202
-		// // 同步设备 t_hd_other_machine
203
-		city.SyncOtherMachine(orgDb, org.OrgId, org.HospitalId)
204
-		// // 同步维修 t_hd_maintain
205
-		city.SyncMachineRepair(orgDb, org.OrgId, org.HospitalId)
206
-		// // 同步设备 t_hd_dm
207
-		city.SyncDM(orgDb, org.OrgId, org.HospitalId)
208
-		// // 同步患者透析记录 t_hd_dialysis
209
-		city.SyncDialysis(orgDb, org.OrgId, org.HospitalId)
210
-		// 同步透析床位分区 t_hd_division
211
-		city.SyncDivision(orgDb, org.OrgId, org.HospitalId)
212
-		// 患者通路信息表(T_HD_ACCESS)
213
-		city.SyncAccess(orgDb, org.OrgId, org.HospitalId)
214
-		// 透析床位表(T_HD_SICKBED)
215
-		city.SyncSickbed(orgDb, org.OrgId, org.HospitalId)
216
-		// 患者诊断信息表(T_HD_DIAGNOSIS)
217
-		city.SyncDiagnosis(orgDb, org.OrgId, org.HospitalId)
218
-		//  患者传染病检查记录表(T_HD_INFECTION
219
-		city.SyncInfection(orgDb, org.OrgId, org.HospitalId)
220
-		//  透析并发症记录表(T_HD_COMPLICATION)
221
-		city.SyncComplication(orgDb, org.OrgId, org.HospitalId)
222
-		//  血透患者检测结果表(T_HD_LIS_REPORT)
223
-		city.SyncLisReport(orgDb, org.OrgId, org.HospitalId)
224
-		//  血透患者检验结果指标表(T_HD_LIS_INDICATORS)
225
-		city.SyncLisIndicators(orgDb, org.OrgId, org.HospitalId)
226
-
227
-		// 第四步:关闭数据库连接
228
-		service.CloseDB(orgDb)
229
-	}
230
-	// }
231
-	c.ServeSuccessJSON(map[string]interface{}{
232
-		"resultList": "12345",
233
-	})
234
-	return
235
-}
236
-
237
-func (c *SyncController) SyncToSmzy() {
238
-	// 第一步:到上报配置表中找到深圳需要上报的机构
239
-	// sz_province, _ := beego.AppConfig.Int64("sz_province")
240
-	// sz_city, _ := beego.AppConfig.Int64("sz_city")
241
-	// configs, _ := service.FindAllDataUploadConfigOrgInfo(sz_province, sz_city, 3)
242
-
243
-	org := &sz.DataUploadConfig{
244
-		OrgId:          9504,
245
-		ProvinceId:     19,
246
-		CityId:         291,
247
-		DepartmentName: "深圳生命之源血液透析中心",
248
-		HospitalId:     "MA5EU4PC0",
249
-		InstType:       1,
250
-		DbHost:         "localhost",
251
-		DbPort:         "1433",
252
-		DbPass:         "1Q2W3e4r!@#$",
253
-		DbUser:         "sa",
254
-		DbName:         "xtzk",
255
-	}
256
-
257
-	// for _, org := range configs {
258
-	// 第二步:跟进配置,创建数据库连接
259
-	if len(org.DbHost) > 0 && len(org.DbUser) > 0 && len(org.DbPort) > 0 && len(org.DbPass) > 0 && len(org.DbName) > 0 {
260
-		orgDb, err := service.CreateSqlServiceDB(org.DbHost, org.DbPort, org.DbUser, org.DbPass, org.DbName)
261
-		if err != nil {
262
-			utils.ErrorLog("创建数据库连接失败:%v", err)
263
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
264
-			return
265
-		}
266
-		// 第三步:开始同步数据
267
-		// 同步医院信息  t_hd_hospital
268
-		city.SyncHospital(orgDb, org.OrgId, org.HospitalId, org.InstType, org.DepartmentName)
269
-		// 同步水处理器  t_hd_wm
270
-		city.SyncWMS(orgDb, org.OrgId, org.HospitalId)
271
-		// // 同步员工 t_hd_staff
272
-		city.SyncStaff(orgDb, org.OrgId, org.HospitalId)
273
-		// // 同步病人 t_hd_patient
274
-		city.SyncPatient(orgDb, org.OrgId, org.HospitalId)
275
-		// // 同步排班  t_hd_shift
276
-		city.SyncShift(orgDb, org.OrgId, org.HospitalId)
277
-		// 同步处方 t_hd_ps
278
-		city.SyncPs(orgDb, org.OrgId, org.HospitalId)
279
-		// 同步处方药品 t_hd_ps
280
-		city.SyncPsMedicine(orgDb, org.OrgId, org.HospitalId)
281
-		// // 同步转院信息 t_hd_patient_out
282
-		city.SyncPatientOut(orgDb, org.OrgId, org.HospitalId)
283
-		// 同步处方信息 t_hd_doctors_advice
284
-		city.SyncDoctorAdvice(orgDb, org.OrgId, org.HospitalId)
285
-		// 同步透中信息 t_hd_middle
286
-		city.SyncMiddle(orgDb, org.OrgId, org.HospitalId)
287
-		// // 同步设备 t_hd_other_machine
288
-		city.SyncOtherMachine(orgDb, org.OrgId, org.HospitalId)
289
-		// // 同步维修 t_hd_maintain
290
-		city.SyncMachineRepair(orgDb, org.OrgId, org.HospitalId)
291
-		// // 同步设备 t_hd_dm
292
-		city.SyncDM(orgDb, org.OrgId, org.HospitalId)
293
-		// // 同步患者透析记录 t_hd_dialysis
294
-		city.SyncDialysis(orgDb, org.OrgId, org.HospitalId)
295
-		// 同步透析床位分区 t_hd_division
296
-		city.SyncDivision(orgDb, org.OrgId, org.HospitalId)
297
-		// 患者通路信息表(T_HD_ACCESS)
298
-		city.SyncAccess(orgDb, org.OrgId, org.HospitalId)
299
-		// 透析床位表(T_HD_SICKBED)
300
-		city.SyncSickbed(orgDb, org.OrgId, org.HospitalId)
301
-		// 患者诊断信息表(T_HD_DIAGNOSIS)
302
-		city.SyncDiagnosis(orgDb, org.OrgId, org.HospitalId)
303
-		//  患者传染病检查记录表(T_HD_INFECTION
304
-		city.SyncInfection(orgDb, org.OrgId, org.HospitalId)
305
-		//  透析并发症记录表(T_HD_COMPLICATION)
306
-		city.SyncComplication(orgDb, org.OrgId, org.HospitalId)
307
-		//  血透患者检测结果表(T_HD_LIS_REPORT)
308
-		city.SyncLisReport(orgDb, org.OrgId, org.HospitalId)
309
-		//  血透患者检验结果指标表(T_HD_LIS_INDICATORS)
310
-		city.SyncLisIndicators(orgDb, org.OrgId, org.HospitalId)
311
-
312
-		// 第四步:关闭数据库连接
313
-		service.CloseDB(orgDb)
314
-	}
315
-	// }
316
-	c.ServeSuccessJSON(map[string]interface{}{
317
-		"resultList": "12345",
318
-	})
319
-	return
320
-}
321
-
322
-func (c *SyncController) SyncToTesgt() {
323
-	fmt.Println("c出发飞阿道夫阿道夫阿方阿方")
324
-	//city.GetInspectionData(10028)
325
-}

+ 441 - 0
controllers/verify_login_controller.go View File

@@ -0,0 +1,441 @@
1
+package controllers
2
+
3
+import (
4
+	"Xcx_New/enums"
5
+	"Xcx_New/models"
6
+	"Xcx_New/service"
7
+	"Xcx_New/utils"
8
+	"fmt"
9
+	"github.com/astaxie/beego"
10
+	"github.com/jinzhu/gorm"
11
+	"net/url"
12
+	"regexp"
13
+	"strconv"
14
+	"strings"
15
+	"time"
16
+)
17
+
18
+func VerifyUserLoginControllerRegistRouters() {
19
+	beego.Router("/login", &VerifyUserLoginController{}, "get:Login")
20
+	beego.Router("/logout", &VerifyUserLoginController{}, "get,post:Logout")
21
+	beego.Router("/handle_error", &VerifyUserLoginController{}, "get:HandleError")
22
+
23
+	beego.Router("/api/token/verify", &VerifyUserLoginAPIController{}, "post:VerifyToken")
24
+	beego.Router("/api/admin/edit_info", &VerifyUserLoginAPIController{}, "post:EditAdminUserInfo")
25
+
26
+	beego.Router("/api/password/code", &PersonAPIController{}, "post:CodeOfModifyPwd")
27
+	beego.Router("/api/password/modify", &PersonAPIController{}, "post:ModifyPwd")
28
+}
29
+
30
+type VerifyUserLoginController struct {
31
+	BaseViewController
32
+}
33
+
34
+// /login [get]
35
+// @param token?:string
36
+// @param relogin?:bool
37
+func (this *VerifyUserLoginController) Login() {
38
+	token := this.Ctx.Input.Query("token")
39
+	if len(token) > 0 { // 带 token 参数的一般是从 SSO 回调回来的
40
+		utils.TraceLog("SSO Login 回调: token=%v", token)
41
+		xtFrontEndDomain := beego.AppConfig.String("front_end_domain") + "?lt=" + token
42
+		this.Redirect302(xtFrontEndDomain)
43
+
44
+	} else {
45
+		relogin, _ := this.GetBool("relogin", false)
46
+		returnURL := url.QueryEscape(fmt.Sprintf("%v%v", beego.AppConfig.String("httpdomain"), this.Ctx.Request.RequestURI))
47
+		ssoDomain := beego.AppConfig.String("sso_domain")
48
+		ssoLoginURL := fmt.Sprintf("%v/login?returnurl=%v&app_type=3&relogin=%v", ssoDomain, returnURL, relogin)
49
+		this.Redirect302(ssoLoginURL)
50
+	}
51
+}
52
+
53
+// /logout [get/post]
54
+func (this *VerifyUserLoginController) Logout() {
55
+	if this.Ctx.Request.Method == "GET" {
56
+		this.DelSession("admin_user_info")
57
+		this.Redirect302(fmt.Sprintf("%v/logout", beego.AppConfig.String("sso_domain")))
58
+	} else if this.Ctx.Request.Method == "POST" {
59
+		this.DelSession("admin_user_info")
60
+	}
61
+}
62
+
63
+// /handle_error [get]
64
+// @param code:int
65
+func (this *VerifyUserLoginController) HandleError() {
66
+	code, _ := this.GetInt("code")
67
+	if code == enums.ErrorCodeNeverCreateTypeApp {
68
+		ssoDomain := beego.AppConfig.String("sso_domain")
69
+		createAppURL := fmt.Sprintf("%v/org/app/create", ssoDomain)
70
+		this.Redirect302(createAppURL)
71
+
72
+	} else if code == enums.ErrorCodeContactSuperAdminCreateTypeApp {
73
+		ssoDomain := beego.AppConfig.String("sso_domain")
74
+		hitURL := fmt.Sprintf("%v/create_app_hint", ssoDomain)
75
+		this.Redirect302(hitURL)
76
+
77
+	} else {
78
+		this.Abort404()
79
+	}
80
+}
81
+
82
+type VerifyUserLoginAPIController struct {
83
+	BaseAPIController
84
+}
85
+
86
+// /api/token/verify [post]
87
+// @param token:string
88
+func (this *VerifyUserLoginAPIController) VerifyToken() {
89
+	if this.Ctx.Request.Method == "OPTIONS" {
90
+		this.Abort("200")
91
+
92
+	} else {
93
+		token := this.GetString("token")
94
+		if len(token) == 0 {
95
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
96
+			return
97
+		}
98
+
99
+		ip := utils.GetIP(this.Ctx.Request)
100
+		sessionID := this.Ctx.GetCookie("s")
101
+		adminUserInfo, err, errCode := service.VerifyToken(token, ip, sessionID)
102
+		if err != nil {
103
+			if errCode == 903 { // 未创建应用
104
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNeverCreateTypeApp)
105
+
106
+			} else if errCode == 904 { // 联系超管来开通
107
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeContactSuperAdminCreateTypeApp)
108
+
109
+			} else {
110
+				utils.ErrorLog("令牌验证失败:%v", err)
111
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInvalidToken)
112
+			}
113
+			return
114
+
115
+		} else {
116
+			adminUser := adminUserInfo.AdminUser
117
+			appRole := adminUserInfo.AppRoles[adminUserInfo.CurrentAppId]
118
+			userInfo := map[string]interface{}{
119
+				"id":         adminUser.Id,
120
+				"mobile":     adminUser.Mobile,
121
+				"user_name":  appRole.UserName,
122
+				"avatar":     appRole.Avatar,
123
+				"intro":      appRole.Intro,
124
+				"user_type":  appRole.UserType,
125
+				"user_title": appRole.UserTitle,
126
+			}
127
+			curOrg := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
128
+			org := map[string]interface{}{
129
+				"id":             curOrg.Id,
130
+				"org_name":       curOrg.OrgName,
131
+				"org_short_name": curOrg.OrgShortName,
132
+				"org_intro":      curOrg.OrgIntroduction,
133
+				"org_logo":       curOrg.OrgLogo,
134
+				"province":       curOrg.Province,
135
+				"city":           curOrg.City,
136
+				"district":       curOrg.District,
137
+				"address":        curOrg.Address,
138
+			}
139
+
140
+			var didRegistedForSCRM bool = false
141
+			var didRegistedForCDM bool = false
142
+			var didRegistedForMall bool = false
143
+
144
+			tempInfo, _ := service.GetOrgInfoTemplate(curOrg.Id)
145
+			template_info := map[string]interface{}{
146
+				"id":          tempInfo.ID,
147
+				"org_id":      tempInfo.OrgId,
148
+				"template_id": tempInfo.TemplateId,
149
+			}
150
+			var FiledList []*models.FiledConfig
151
+
152
+			FiledList, _ = service.FindFiledByOrgId(curOrg.Id)
153
+			if len(FiledList) == 0 {
154
+				err := service.BatchInsertFiledConfig(curOrg.Id)
155
+				if err == nil {
156
+					FiledList, _ = service.FindFiledByOrgId(curOrg.Id)
157
+
158
+				} else {
159
+					utils.ErrorLog("字段批量插入失败:%v", err)
160
+				}
161
+			}
162
+			//产寻该机构是否有收缩压和舒张压
163
+			pressure, err := service.GetDefaultSystolicPressure(curOrg.Id)
164
+			fmt.Println(err)
165
+			if len(pressure) == 0 {
166
+				err = service.BathInsertQualityControlTwo(curOrg.Id)
167
+			} else {
168
+				utils.ErrorLog("字段批量插入失败:%v", err)
169
+			}
170
+			major, err := service.GetInspectionMajor(curOrg.Id)
171
+			if len(major) == 0 {
172
+				QualityeList, err := service.FindQualityByOrgId(curOrg.Id)
173
+				if len(QualityeList) == 0 {
174
+					err = service.BatchInsertQualityControl(curOrg.Id)
175
+				} else {
176
+					utils.ErrorLog("字段批量插入失败:%v", err)
177
+				}
178
+
179
+				InspectionList, err := service.FindeInspectionByOrgId(curOrg.Id)
180
+				if len(InspectionList) == 0 {
181
+					err = service.BatchInspectionConfiguration(curOrg.Id)
182
+				} else {
183
+					utils.ErrorLog("字段批量插入失败:%v", err)
184
+				}
185
+			} else {
186
+				utils.ErrorLog("字段批量插入失败:%v", err)
187
+			}
188
+
189
+			//查询该机构是否存在医护排班
190
+			_, errcode := service.GetDoctorScheduleByOrgId(curOrg.Id)
191
+			fmt.Println("errcode2------------------", errcode)
192
+			//如果没有就插入
193
+			if errcode == gorm.ErrRecordNotFound {
194
+				err = service.BatchInsertDoctorSchedule(curOrg.Id)
195
+			} else {
196
+				utils.ErrorLog("医护排班默认数据插入失败:%v", err)
197
+			}
198
+
199
+			//产询该机构是否连续排班的状态值
200
+			_, errcodes := service.GetContinueScheduleByOrgId(curOrg.Id)
201
+			if errcodes == gorm.ErrRecordNotFound {
202
+				schedule := models.ContinueSchedule{
203
+					IsStatus:  1,
204
+					UserOrgId: curOrg.Id,
205
+					Status:    1,
206
+					Ctime:     time.Now().Unix(),
207
+				}
208
+				err := service.CreateContinueSchedule(&schedule)
209
+				if err == nil {
210
+					utils.ErrorLog("创建连续排班值成功:%v", err)
211
+				}
212
+			} else {
213
+				utils.ErrorLog("连续排班已存在数据:%v", err)
214
+			}
215
+
216
+			var pruviews []*models.Purview
217
+			var curAppUrlfors []string
218
+			if len(curAppUrlfors) == 0 {
219
+				if adminUser.Id == curOrg.Creator { //超级管理员
220
+					urlfors, _, _ := service.GetSuperAdminUsersPurviewTreeAndUrlfors(3)
221
+					urlforss, _, _ := service.GetSuperAdminUsersPurviewTreeAndUrlfors(8)
222
+					urlfors = append(urlfors, urlforss...)
223
+					didRegistedForSCRM = true
224
+					didRegistedForCDM = true
225
+					didRegistedForMall = true
226
+
227
+					//urlfors, _, _ := service.GetSuperAdminUsersPurviewTreeAndUrlfors(4)
228
+					//urlfors, _, _ := service.GetSuperAdminUsersPurviewTreeAndUrlfors(5)
229
+					//urlfors, _, _ := service.GetSuperAdminUsersPurviewTreeAndUrlfors(6)
230
+
231
+					curAppUrlfors = urlfors
232
+				} else {
233
+					appRole, _ := service.FindAdminUserIDA(appRole.Id)
234
+					if appRole.Id > 0 && len(appRole.RoleIds) > 0 {
235
+						role_arr := strings.Split(appRole.RoleIds, ",")
236
+						var ids string
237
+						for _, role_id := range role_arr {
238
+							id, _ := strconv.ParseInt(role_id, 10, 64)
239
+							role, _ := service.GetRoleByRoleID(id)
240
+							var system_ids = ""
241
+							if role.RoleName == "子管理员" && role.IsSystem > 0 {
242
+								purviews, _ := service.GetAllSystemPurview()
243
+								for _, purview := range purviews {
244
+									if len(system_ids) == 0 {
245
+										system_ids = strconv.FormatInt(purview.Id, 10)
246
+									} else {
247
+										system_ids = system_ids + "," + strconv.FormatInt(purview.Id, 10)
248
+									}
249
+								}
250
+							}
251
+							purview_ids, _ := service.GetRolePurviewIds(id)
252
+							if len(ids) == 0 {
253
+								ids = purview_ids
254
+							} else {
255
+								if len(purview_ids) > 0 {
256
+									ids = ids + "," + purview_ids
257
+								}
258
+							}
259
+
260
+							if len(system_ids) > 0 {
261
+								ids = ids + "," + system_ids
262
+							}
263
+						}
264
+
265
+						if len(ids) != 0 {
266
+							pruviews, _ = service.GetPurviewById(CompressStr(ids))
267
+							for _, item := range pruviews {
268
+								if item.Module == 3 && item.Parentid > 0 {
269
+									fmt.Println(item.Urlfor)
270
+									curAppUrlfors = append(curAppUrlfors, item.Urlfor)
271
+								}
272
+							}
273
+						} else {
274
+
275
+							curAppUrlfors = append(curAppUrlfors, "")
276
+						}
277
+					} else {
278
+						curAppUrlfors = append(curAppUrlfors, "")
279
+
280
+					}
281
+				}
282
+			}
283
+			curAppUrlfors = append(curAppUrlfors, "/home")
284
+			for _, item := range pruviews {
285
+				if item.Module == 6 {
286
+					didRegistedForSCRM = true
287
+				}
288
+				if item.Module == 4 {
289
+					didRegistedForCDM = true
290
+				}
291
+				if item.Module == 7 {
292
+					didRegistedForMall = true
293
+				}
294
+			}
295
+
296
+			if adminUser.Id == curOrg.Creator { //超级管理员
297
+				didRegistedForSCRM = true
298
+				didRegistedForCDM = true
299
+				didRegistedForMall = true
300
+
301
+			}
302
+
303
+			subscibe, _ := service.GetOrgSubscibe(adminUserInfo.CurrentOrgId)
304
+
305
+			this.SetSession("admin_user_info", adminUserInfo)
306
+
307
+			this.ServeSuccessJSON(map[string]interface{}{
308
+				"user":            userInfo,
309
+				"org":             org,
310
+				"urlfors":         curAppUrlfors,
311
+				"current_org_id":  adminUserInfo.CurrentOrgId,
312
+				"current_app_id":  adminUserInfo.CurrentAppId,
313
+				"subscibe":        subscibe,
314
+				"scrm_role_exist": didRegistedForSCRM,
315
+				"cdm_role_exist":  didRegistedForCDM,
316
+				"mall_role_exist": didRegistedForMall,
317
+				"template_info":   template_info,
318
+				"fileds":          FiledList,
319
+			})
320
+			return
321
+		}
322
+	}
323
+}
324
+
325
+// /api/admin/edit_info [post]
326
+// @param avatar:string
327
+// @param name:string
328
+// @param opwd?:string 没有原始密码的时候,认为不修改密码
329
+// @param npwd?:string
330
+func (this *VerifyUserLoginAPIController) EditAdminUserInfo() {
331
+	adminUserInfo := this.GetAdminUserInfo()
332
+
333
+	avatar := this.GetString("avatar")
334
+	name := this.GetString("name")
335
+	if len(name) == 0 {
336
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMissingUserName)
337
+		return
338
+	}
339
+	// oldPwd := this.GetString("opwd")
340
+	// newPwd := this.GetString("npwd")
341
+	// modifyPwd := len(oldPwd) != 0
342
+	// if modifyPwd {
343
+	// 	if len(newPwd) == 0 {
344
+	// 		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodePasswordEmpty)
345
+	// 		this.ServeJSON()
346
+	// 		return
347
+	// 	}
348
+	// 	pwdRight, err := service.IsPasswordRight(adminUserInfo.AdminUser.Id, oldPwd)
349
+	// 	if err != nil {
350
+	// 		utils.ErrorLog("判断旧密码是否错误失败:%v", err)
351
+	// 		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
352
+	// 		this.ServeJSON()
353
+	// 		return
354
+	// 	}
355
+	// 	if !pwdRight {
356
+	// 		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeOldPasswordWrong)
357
+	// 		this.ServeJSON()
358
+	// 		return
359
+	// 	}
360
+	// } else {
361
+	// 	newPwd = ""
362
+	// }
363
+	modifyErr := service.ModifyAdminUserInfo(adminUserInfo.AdminUser.Id, adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, name, avatar, "")
364
+	if modifyErr != nil {
365
+		this.ErrorLog("修改个人信息失败:%v", modifyErr)
366
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
367
+
368
+	} else {
369
+		appRole := adminUserInfo.AppRoles[adminUserInfo.CurrentAppId]
370
+		appRole.UserName = name
371
+		appRole.Avatar = avatar
372
+		this.ServeSuccessJSON(nil)
373
+	}
374
+}
375
+
376
+type PersonAPIController struct {
377
+	BaseAuthAPIController
378
+}
379
+
380
+// /api/password/code [post]
381
+func (this *PersonAPIController) CodeOfModifyPwd() {
382
+	adminUserInfo := this.GetAdminUserInfo()
383
+	mobile := adminUserInfo.AdminUser.Mobile
384
+	if err := service.SMSSendVerificationCode(mobile); err != nil {
385
+		utils.ErrorLog("修改密码发送验证码失败:%v", err)
386
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
387
+		return
388
+	} else {
389
+		this.ServeSuccessJSON(map[string]interface{}{
390
+			"msg": "短信发送成功,有效期为10分钟",
391
+		})
392
+	}
393
+}
394
+
395
+// /api/password/modify [post]
396
+// @param password:string
397
+// @param code:string
398
+func (this *PersonAPIController) ModifyPwd() {
399
+	new_pwd := this.GetString("password")
400
+	code := this.GetString("code")
401
+	if len(new_pwd) == 0 || len(code) == 0 {
402
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
403
+		return
404
+	}
405
+
406
+	adminUserInfo := this.GetAdminUserInfo()
407
+	mobile := adminUserInfo.AdminUser.Mobile
408
+
409
+	redisClient := service.RedisClient()
410
+	defer redisClient.Close()
411
+	cachedCode, err := redisClient.Get("xt_modify_pwd_" + mobile).Result()
412
+	if err != nil {
413
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAccountOrVerCodeWrong)
414
+		return
415
+	}
416
+	if code != cachedCode {
417
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAccountOrVerCodeWrong)
418
+		return
419
+	}
420
+
421
+	if modifyErr := service.ModifyPassword(adminUserInfo.AdminUser.Id, new_pwd); modifyErr != nil {
422
+		this.ErrorLog("修改密码失败:%v", modifyErr)
423
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
424
+		return
425
+	}
426
+
427
+	// 清除验证码
428
+	redisClient.Del("xt_modify_pwd_" + mobile)
429
+	this.ServeSuccessJSON(map[string]interface{}{
430
+		"msg": "密码已修改",
431
+	})
432
+}
433
+
434
+func CompressStr(str string) string {
435
+	if str == "" {
436
+		return ""
437
+	}
438
+	//匹配一个或多个空白符的正则表达式
439
+	reg := regexp.MustCompile("\\s+")
440
+	return reg.ReplaceAllString(str, "")
441
+}

BIN
db/xtdb.docx View File


+ 145 - 5
enums/error_code.go View File

@@ -1,6 +1,6 @@
1 1
 package enums
2 2
 
3
-import "Data_Upload_Api/utils"
3
+import "Xcx_New/utils"
4 4
 
5 5
 const ( // ErrorCode
6 6
 	// 登录注册错误 6000+
@@ -22,6 +22,8 @@ const ( // ErrorCode
22 22
 	ErrorCodeNeverCreateTypeApp             = 6016
23 23
 	ErrorCodeContactSuperAdminCreateTypeApp = 6017
24 24
 
25
+	ErrorCodeRepeatCreateOrg = 901
26
+
25 27
 	// 数据验证错误 7000+
26 28
 	ErrorCodeMobileFormat     = 7001
27 29
 	ErrorCodeTelphoneFormat   = 7002
@@ -87,6 +89,7 @@ const ( // ErrorCode
87 89
 	ErrorCodeDelScheduleFailByDialysis      = 1041
88 90
 	ErrorCodeNotSelectLapsetoType           = 1042
89 91
 	ErrorCodeNotSelectLapsetoTime           = 1043
92
+	ErrorCodeEquitNoExist                   = 1045
90 93
 
91 94
 	ErrorCodeInspectionDateExit    = 1201
92 95
 	ErrorCodeInspectionAddFail     = 1202
@@ -100,6 +103,7 @@ const ( // ErrorCode
100 103
 	ErrorDialysisOrderNoStart               = 1132
101 104
 	ErrorDialysisOrderNoEND                 = 1133
102 105
 	ErrorDialysisOrderRepeatStart           = 1134
106
+	ErrorDialysisOrderRepeatBed             = 1136
103 107
 	ErrorCodeDialysisPermissionDeniedModify = 1135
104 108
 
105 109
 	ErrorCodeNotSubscibe       = 4003
@@ -126,6 +130,12 @@ const ( // ErrorCode
126 130
 
127 131
 	ErrorCodeCreateStockInFail = 20001
128 132
 
133
+	ErrorCodeCreateReturnFail = 50001
134
+
135
+	ErrorCodeCreateStockOutFail = 50002
136
+
137
+	ErrorCodeCreateCancelStockFail = 50003
138
+
129 139
 	ErrorCodeScheduleTemplateNotExist = 10001
130 140
 
131 141
 	ErrorCodeSystemError  = 6666
@@ -161,7 +171,69 @@ const ( // ErrorCode
161 171
 	ErrorCodeAdvicePermissionDeniedModify = 200021
162 172
 	ErrorCodePrescriptionException        = 200022
163 173
 
164
-	ErrorCodeNameException = 200023
174
+	ErrorCodeNotDocking = 200023
175
+
176
+	ErrorCodeAdviceTypeWrong = 200024
177
+
178
+	ErrorCodeCreateAdvice = 200025
179
+
180
+	ErrorCodePatientDialysisOrder = 20026
181
+	ErrorSchedualcRepeatBed       = 20027
182
+
183
+	ErrorCodeChangeMode         = 20028
184
+	ErrorCodeChangeDeviceNumber = 20029
185
+
186
+	ErrorCodeHisIdExist = 20030
187
+
188
+	ErrorCodePreExist   = 20031
189
+	ErrorCodeOrgNoExist = 20032
190
+
191
+	ErrorCodeRegisterExist = 20033
192
+
193
+	ErrorCodeRepeatCreateStaffException = 20034
194
+
195
+	ErrorCodeForbidden       = 20035
196
+	ErrorCodeRoleNameIsExist = 20036
197
+
198
+	ErrorCodeRole = 20037
199
+
200
+	ErrorCodeAdminUserIsExit = 20038
201
+
202
+	ErrorCodePhone = 20039
203
+
204
+	ErrorCodeLogOut = 20049
205
+
206
+	ErrorCodeExportError = 20050
207
+
208
+	ErrorCodeOrgNoPatient = 20051
209
+
210
+	ErrorCodeDoctorAdviceEmpty = 20052
211
+
212
+	ErrorCodeOpenStocktWrong = 20053
213
+
214
+	ErrorCodeDrugRepeatDataException = 20054
215
+
216
+	ErrorCodeIDCartNo = 20055
217
+
218
+	ErrorCodeRegisterOneException = 20066
219
+
220
+	ErrorCodeRegisterTwoException = 20067
221
+
222
+	ErrorCodeCreateOrderException = 20068
223
+
224
+	ErrorCodeCalOrderException = 20069
225
+
226
+	ErrorCodeHisRegisterException = 300001
227
+
228
+	ErrorCodeNoBloodPatientException = 300002
229
+
230
+	ErrorCodeOrderParamWrong = 300003
231
+
232
+	ErrorCodeHisPatientParamWrong = 300004
233
+
234
+	ErrorCodeOutOfStockParamWrong = 300300
235
+
236
+	ErrorCodeOrderParamWrongTwo = 300500
165 237
 )
166 238
 
167 239
 var ErrCodeMsgs = map[int]string{
@@ -203,7 +275,7 @@ var ErrCodeMsgs = map[int]string{
203 275
 	ErrorCodeMobileDidUsedInApp:     "该手机号已在该应用中被注册为管理员",
204 276
 	ErrorCodeMissingUserName:        "缺少用户名",
205 277
 	ErrorCodeOldPasswordWrong:       "原密码不正确",
206
-	ErrorCodeCannotRemoveRole:       "存在该角色的管理员,不能删除该角色",
278
+	ErrorCodeCannotRemoveRole:       "该角色下存在用户,不能删除该角色",
207 279
 	ErrorCodeRoleMobileIsSuperAdmin: "该手机号已注册为超级管理员",
208 280
 
209 281
 	ErrorCodeGetQiniuUpToken: "获取七牛uptoken失败",
@@ -285,6 +357,7 @@ var ErrCodeMsgs = map[int]string{
285 357
 	ErrorDialysisOrderNoStart:     "尚未上机,无法执行下机操作",
286 358
 	ErrorDialysisOrderNoEND:       "已处于下机状态",
287 359
 	ErrorDialysisOrderRepeatStart: "已上机",
360
+	ErrorDialysisOrderRepeatBed:   "该床位已有患者上机,请选择其他床位",
288 361
 	//ErrorCodeScheduleTemplateNotExist: "排班模板不存在",
289 362
 
290 363
 	ErrorCodeSystemError:              "系统异常",
@@ -305,7 +378,7 @@ var ErrCodeMsgs = map[int]string{
305 378
 
306 379
 	ErrorCodeCancelStockFail:    "出库退库失败",
307 380
 	ErrorCodeDeleteGoodTypeFail: "该类型存在商品信息,无法删除",
308
-	ErrorCodeDeleteGoodInfoFail: "该商品已经入库无法删除",
381
+	ErrorCodeDeleteGoodInfoFail: "该商品已经入库或者出库无法删除",
309 382
 
310 383
 	ErrorCodeDeleteFail: "删除失败",
311 384
 
@@ -323,8 +396,68 @@ var ErrCodeMsgs = map[int]string{
323 396
 	ErrorCodePrescriptionPermissionDeniedModify: "您没有权限修改透析处方数据",
324 397
 	ErrorCodeAdvicePermissionDeniedModify:       "您没有权限添加医嘱",
325 398
 	ErrorCodePrescriptionException:              "上机失败,请先开处方",
399
+	ErrorCodeNotDocking:                         "该地区尚未对接",
326 400
 
327
-	ErrorCodeNameException: "账号已经存在",
401
+	ErrorCodeAdviceTypeWrong:      "请选择医嘱模版类型",
402
+	ErrorCodeCreateAdvice:         "你没有权限开医嘱",
403
+	ErrorCodePatientDialysisOrder: "该病人已经上机,无法临时排班",
404
+	ErrorSchedualcRepeatBed:       "该床位已经有人排班,无法临时排班",
405
+
406
+	ErrorCodeChangeMode:         "该患者今天已上机治疗,请在透析记录中进行调整透析模式",
407
+	ErrorCodeChangeDeviceNumber: "该患者今天已上机治疗,请在透析记录中进行调整机号",
408
+
409
+	ErrorCodeHisIdExist: "该his_id已被占用,请重新输入",
410
+
411
+	ErrorCodePreExist: "没有该权限",
412
+
413
+	ErrorCodeRepeatCreateOrg: "该账号已创建过机构了",
414
+
415
+	ErrorCodeOrgNoExist: "该机构不存在",
416
+
417
+	ErrorCodeRegisterExist: "该账号已经注册,请登录",
418
+
419
+	ErrorCodeRepeatCreateStaffException: "该员工已经存在无法继续添加",
420
+
421
+	ErrorCodeForbidden: "你已经被管理员禁用,无法使用该系统",
422
+
423
+	ErrorCodeRoleNameIsExist: "该角色已经不存在",
424
+
425
+	ErrorCodeRole: "尚未配置角色,无访问权限",
426
+
427
+	ErrorCodeAdminUserIsExit: "用户不存在",
428
+	ErrorCodePhone:           "请填写正确的联系电话",
429
+
430
+	ErrorCodeLogOut:      "退出",
431
+	ErrorCodeExportError: "导入出错,请下载并查看相关日志",
432
+
433
+	ErrorCodeOrgNoPatient: "暂无病人",
434
+
435
+	ErrorCodeDoctorAdviceEmpty: "没有更多了",
436
+	ErrorCodeOpenStocktWrong:   "未开启自动扣减功能,无法出库",
437
+
438
+	ErrorCodeDrugRepeatDataException: "该药已经存在,无法添加",
439
+
440
+	ErrorCodeIDCartNo: "身份证不能为空",
441
+
442
+	ErrorCodeRegisterOneException: "无参保信息",
443
+
444
+	ErrorCodeRegisterTwoException: "挂号失败",
445
+
446
+	ErrorCodeCreateOrderException: "创建预结算订单失败",
447
+
448
+	ErrorCodeCalOrderException: "结算失败",
449
+
450
+	ErrorCodeHisRegisterException: "一天只能挂一个号",
451
+
452
+	ErrorCodeNoBloodPatientException: "找不到该患者,请先在系统录入患者信息或检查患者身份证信息",
453
+
454
+	ErrorCodeOrderParamWrong: "结算记录不存在",
455
+
456
+	ErrorCodeHisPatientParamWrong: "订单正在结算、请先结算完成",
457
+
458
+	ErrorCodeOutOfStockParamWrong: "库存不足",
459
+
460
+	ErrorCodeOrderParamWrongTwo: "该就诊号存在结算记录,需要先退费后再退号",
328 461
 }
329 462
 
330 463
 type SGJError struct {
@@ -360,6 +493,13 @@ func MakeFailResponseJSON(errMsg string, errCode int) map[string]interface{} {
360 493
 	return json
361 494
 }
362 495
 
496
+func MakeDynamicFailResponseJSON(errMsg string) map[string]interface{} {
497
+	json := make(map[string]interface{})
498
+	json["msg"] = errMsg
499
+	json["state"] = 0
500
+	return json
501
+}
502
+
363 503
 func MakeFailResponseJSONWithSGJError(err *SGJError) map[string]interface{} {
364 504
 	if err == nil {
365 505
 		utils.WarningLog("MakeFailResponseJSONWithSGJError 参数err 不能为空")