Ver código fonte

11月8日库存管理

XMLWAN 3 anos atrás
pai
commit
e841cb096c

+ 99 - 41
controllers/dialysis_record_api_controller.go Ver arquivo

@@ -165,12 +165,21 @@ func (this *DialysisRecordAPIController) GetSchedules() {
165 165
 					redis.Set(key, scheduals_json, time.Second*60)
166 166
 				}
167 167
 			}
168
-			information, _ := service.GetAdminUserRoleInformation(orgID)
169 168
 
170
-			this.ServeSuccessJSON(map[string]interface{}{
171
-				"schedules":   scheduals,
172
-				"information": information,
173
-			})
169
+			_, errcodes := service.GetOrgFollowIsExist(orgID)
170
+			if errcodes == gorm.ErrRecordNotFound {
171
+				information, _ := service.GetAdminUserRoleInformation(0)
172
+				this.ServeSuccessJSON(map[string]interface{}{
173
+					"schedules":   scheduals,
174
+					"information": information,
175
+				})
176
+			} else if errcodes == nil {
177
+				information, _ := service.GetAdminUserRoleInformation(orgID)
178
+				this.ServeSuccessJSON(map[string]interface{}{
179
+					"schedules":   scheduals,
180
+					"information": information,
181
+				})
182
+			}
174 183
 
175 184
 		}
176 185
 
@@ -183,9 +192,20 @@ func (this *DialysisRecordAPIController) GetSchedules() {
183 192
 
184 193
 		}
185 194
 
186
-		this.ServeSuccessJSON(map[string]interface{}{
187
-			"schedules": dat,
188
-		})
195
+		_, errcodes := service.GetOrgFollowIsExist(orgID)
196
+		if errcodes == gorm.ErrRecordNotFound {
197
+			information, _ := service.GetAdminUserRoleInformation(0)
198
+			this.ServeSuccessJSON(map[string]interface{}{
199
+				"schedules":   dat,
200
+				"information": information,
201
+			})
202
+		} else if errcodes == nil {
203
+			information, _ := service.GetAdminUserRoleInformation(orgID)
204
+			this.ServeSuccessJSON(map[string]interface{}{
205
+				"schedules":   dat,
206
+				"information": information,
207
+			})
208
+		}
189 209
 
190 210
 	}
191 211
 
@@ -396,39 +416,77 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
396 416
 		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.CurrentOrgId, patientID, date.Unix())
397 417
 	}
398 418
 
399
-	information, _ := service.GetAdminUserRoleInformation(adminInfo.CurrentOrgId)
400
-	returnData := map[string]interface{}{
401
-		"patient":                     patient,
402
-		"schedual":                    schedual,
403
-		"prescription":                dialysisPrescribe,
404
-		"solution":                    dialysisSolution,
405
-		"receiver_treatment_access":   receiverTreatmentAccess,
406
-		"predialysis_evaluation":      predialysisEvaluation,
407
-		"doctor_advices":              doctorAdvices,
408
-		"double_check":                doubleCheck,
409
-		"assessment_after_dislysis":   assessmentAfterDislysis,
410
-		"treatment_summary":           treatmentSummary,
411
-		"monitor_records":             monitorRecords,
412
-		"dialysis_order":              dialysisOrder,
413
-		"doctors":                     admins,
414
-		"config":                      record,
415
-		"devices":                     devices,
416
-		"device_numbers":              deviceNumbers,
417
-		"lastPredialysisEvaluation":   lastPredialysisEvaluation,
418
-		"lastMonitorRecord":           lastMonitorRecord,
419
-		"lastAssessmentAfterDislysis": lastAssessmentAfterDislysis,
420
-		"lastDialysisPrescribe":       lastDialysisPrescribe,
421
-		"lastDryWeightDislysis":       lastDryWeightDislysis,
422
-		"headNurses":                  headNurses,
423
-		"system_prescribe":            systemDialysisPrescribe,
424
-		"his_advices":                 his_advices,
425
-		"is_open_config":              is_open_config,
426
-		"stockType":                   stockType,
427
-		"prepare":                     prepare,
428
-		"lastAssessment":              lastAssessment,
429
-		"information":                 information,
430
-	}
431
-	this.ServeSuccessJSON(returnData)
419
+	_, errcode := service.GetOrgFollowIsExist(adminInfo.CurrentOrgId)
420
+	if errcode == gorm.ErrRecordNotFound {
421
+		information, _ := service.GetAdminUserRoleInformation(0)
422
+		returnData := map[string]interface{}{
423
+			"patient":                     patient,
424
+			"schedual":                    schedual,
425
+			"prescription":                dialysisPrescribe,
426
+			"solution":                    dialysisSolution,
427
+			"receiver_treatment_access":   receiverTreatmentAccess,
428
+			"predialysis_evaluation":      predialysisEvaluation,
429
+			"doctor_advices":              doctorAdvices,
430
+			"double_check":                doubleCheck,
431
+			"assessment_after_dislysis":   assessmentAfterDislysis,
432
+			"treatment_summary":           treatmentSummary,
433
+			"monitor_records":             monitorRecords,
434
+			"dialysis_order":              dialysisOrder,
435
+			"doctors":                     admins,
436
+			"config":                      record,
437
+			"devices":                     devices,
438
+			"device_numbers":              deviceNumbers,
439
+			"lastPredialysisEvaluation":   lastPredialysisEvaluation,
440
+			"lastMonitorRecord":           lastMonitorRecord,
441
+			"lastAssessmentAfterDislysis": lastAssessmentAfterDislysis,
442
+			"lastDialysisPrescribe":       lastDialysisPrescribe,
443
+			"lastDryWeightDislysis":       lastDryWeightDislysis,
444
+			"headNurses":                  headNurses,
445
+			"system_prescribe":            systemDialysisPrescribe,
446
+			"his_advices":                 his_advices,
447
+			"is_open_config":              is_open_config,
448
+			"stockType":                   stockType,
449
+			"prepare":                     prepare,
450
+			"lastAssessment":              lastAssessment,
451
+			"information":                 information,
452
+		}
453
+		this.ServeSuccessJSON(returnData)
454
+
455
+	} else if errcode == nil {
456
+		information, _ := service.GetAdminUserRoleInformation(adminInfo.CurrentOrgId)
457
+		returnData := map[string]interface{}{
458
+			"patient":                     patient,
459
+			"schedual":                    schedual,
460
+			"prescription":                dialysisPrescribe,
461
+			"solution":                    dialysisSolution,
462
+			"receiver_treatment_access":   receiverTreatmentAccess,
463
+			"predialysis_evaluation":      predialysisEvaluation,
464
+			"doctor_advices":              doctorAdvices,
465
+			"double_check":                doubleCheck,
466
+			"assessment_after_dislysis":   assessmentAfterDislysis,
467
+			"treatment_summary":           treatmentSummary,
468
+			"monitor_records":             monitorRecords,
469
+			"dialysis_order":              dialysisOrder,
470
+			"doctors":                     admins,
471
+			"config":                      record,
472
+			"devices":                     devices,
473
+			"device_numbers":              deviceNumbers,
474
+			"lastPredialysisEvaluation":   lastPredialysisEvaluation,
475
+			"lastMonitorRecord":           lastMonitorRecord,
476
+			"lastAssessmentAfterDislysis": lastAssessmentAfterDislysis,
477
+			"lastDialysisPrescribe":       lastDialysisPrescribe,
478
+			"lastDryWeightDislysis":       lastDryWeightDislysis,
479
+			"headNurses":                  headNurses,
480
+			"system_prescribe":            systemDialysisPrescribe,
481
+			"his_advices":                 his_advices,
482
+			"is_open_config":              is_open_config,
483
+			"stockType":                   stockType,
484
+			"prepare":                     prepare,
485
+			"lastAssessment":              lastAssessment,
486
+			"information":                 information,
487
+		}
488
+		this.ServeSuccessJSON(returnData)
489
+	}
432 490
 
433 491
 }
434 492
 

+ 48 - 16
controllers/new_mobile_api_controllers/home_api_controller.go Ver arquivo

@@ -9,6 +9,7 @@ import (
9 9
 	"encoding/json"
10 10
 	"fmt"
11 11
 	"github.com/astaxie/beego"
12
+	"github.com/jinzhu/gorm"
12 13
 	"io/ioutil"
13 14
 	"net/http"
14 15
 	"net/url"
@@ -81,16 +82,32 @@ func (this *HomeController) GetHomeData() {
81 82
 		}
82 83
 
83 84
 		cretor := adminUserInfo.AdminUser.Id
84
-		information, err := service.GetAdminUserRoleInformation(adminUserInfo.Org.Id)
85
-		this.ServeSuccessJSON(map[string]interface{}{
86
-			"orgs":            orgs,
87
-			"apps":            apps,
88
-			"banners":         banners,
89
-			"isCreateOrg":     true,
90
-			"isSubSuperAdmin": isSubSuperAdmin,
91
-			"cretor":          cretor,
92
-			"information":     information,
93
-		})
85
+		//查询机构ID是否存在
86
+		_, errcode := service.GetOrgFollowIsExist(adminUserInfo.Org.Id)
87
+		if errcode == gorm.ErrRecordNotFound {
88
+			information, _ := service.GetAdminUserRoleInformation(0)
89
+			this.ServeSuccessJSON(map[string]interface{}{
90
+				"orgs":            orgs,
91
+				"apps":            apps,
92
+				"banners":         banners,
93
+				"isCreateOrg":     true,
94
+				"isSubSuperAdmin": isSubSuperAdmin,
95
+				"cretor":          cretor,
96
+				"information":     information,
97
+			})
98
+		} else if errcode == nil {
99
+			information, _ := service.GetAdminUserRoleInformation(adminUserInfo.Org.Id)
100
+			this.ServeSuccessJSON(map[string]interface{}{
101
+				"orgs":            orgs,
102
+				"apps":            apps,
103
+				"banners":         banners,
104
+				"isCreateOrg":     true,
105
+				"isSubSuperAdmin": isSubSuperAdmin,
106
+				"cretor":          cretor,
107
+				"information":     information,
108
+			})
109
+		}
110
+
94 111
 	} else {
95 112
 
96 113
 		apps, err := service.GetAllApp(0)
@@ -104,12 +121,27 @@ func (this *HomeController) GetHomeData() {
104 121
 			return
105 122
 		}
106 123
 
107
-		this.ServeSuccessJSON(map[string]interface{}{
108
-			"isCreateOrg":     false,
109
-			"apps":            apps,
110
-			"banners":         banners,
111
-			"isSubSuperAdmin": false,
112
-		})
124
+		_, errcode := service.GetOrgFollowIsExist(adminUserInfo.Org.Id)
125
+		if errcode == gorm.ErrRecordNotFound {
126
+			information, _ := service.GetAdminUserRoleInformation(0)
127
+			this.ServeSuccessJSON(map[string]interface{}{
128
+				"isCreateOrg":     false,
129
+				"apps":            apps,
130
+				"banners":         banners,
131
+				"isSubSuperAdmin": false,
132
+				"information":     information,
133
+			})
134
+		} else if errcode == nil {
135
+			information, _ := service.GetAdminUserRoleInformation(adminUserInfo.Org.Id)
136
+			this.ServeSuccessJSON(map[string]interface{}{
137
+				"isCreateOrg":     false,
138
+				"apps":            apps,
139
+				"banners":         banners,
140
+				"isSubSuperAdmin": false,
141
+				"information":     information,
142
+			})
143
+		}
144
+
113 145
 	}
114 146
 
115 147
 }

+ 13 - 0
models/his_models.go Ver arquivo

@@ -1657,6 +1657,19 @@ func (SgjAdmin) TableName() string {
1657 1657
 	return "sgj_admin"
1658 1658
 }
1659 1659
 
1660
+type SgjOrgFollowOne struct {
1661
+	ID          int64 `gorm:"column:id" json:"id" form:"id"`
1662
+	OrgId       int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
1663
+	AdminUserId int64 `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
1664
+	Ctime       int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
1665
+	Mtime       int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
1666
+	Status      int64 `gorm:"column:status" json:"status" form:"status"`
1667
+}
1668
+
1669
+func (SgjOrgFollowOne) TableName() string {
1670
+	return "sgj_org_follow"
1671
+}
1672
+
1660 1673
 type SgjOrgFollow struct {
1661 1674
 	ID          int64  `gorm:"column:id" json:"id" form:"id"`
1662 1675
 	OrgId       int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`