Browse Source

Merge branch '20200710_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20200710_xt_api_new_branch

csx 4 years ago
parent
commit
f9dee76609

+ 78 - 3
controllers/doctor_schedule_api_controller.go View File

@@ -31,6 +31,9 @@ func DoctorScheduleRouters() {
31 31
 	beego.Router("api/schedule/deletestaffschedule", &DoctorScheduleApiController{}, "Get:DeleteStaffSchedule")
32 32
 	beego.Router("/api/schedule/copystaffschedule", &DoctorScheduleApiController{}, "Get:CopyStaffSchedule")
33 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")
34 37
 }
35 38
 
36 39
 func (this *DoctorScheduleApiController) SaveDoctorSchedules() {
@@ -46,7 +49,7 @@ func (this *DoctorScheduleApiController) SaveDoctorSchedules() {
46 49
 	timetwo_end := this.GetString("timetwo_end")
47 50
 	work_time := this.GetString("work_time")
48 51
 	remarks := this.GetString("remarks")
49
-
52
+	minute, _ := this.GetInt64("minute")
50 53
 	schedules := models.DoctorSchedules{
51 54
 		ClassName:       class_name,
52 55
 		ClassAttributes: class_attributes,
@@ -61,6 +64,7 @@ func (this *DoctorScheduleApiController) SaveDoctorSchedules() {
61 64
 		UserOrgId:       orgId,
62 65
 		Status:          1,
63 66
 		Ctime:           time.Now().Unix(),
67
+		Minute:          minute,
64 68
 	}
65 69
 
66 70
 	//查询班种名称是否存在
@@ -153,7 +157,7 @@ func (this *DoctorScheduleApiController) UpdateSchedule() {
153 157
 	work_time := this.GetString("work_time")
154 158
 	remarks := this.GetString("remarks")
155 159
 	user_org_id, _ := this.GetInt64("user_org_id")
156
-
160
+	minute, _ := this.GetInt64("minute")
157 161
 	schedules := models.DoctorSchedules{
158 162
 		ClassName:       class_name,
159 163
 		ClassAttributes: class_attributes,
@@ -165,6 +169,7 @@ func (this *DoctorScheduleApiController) UpdateSchedule() {
165 169
 		TimetwoType:     timetwo_type,
166 170
 		WorkTime:        work_time,
167 171
 		Remarks:         remarks,
172
+		Minute:          minute,
168 173
 	}
169 174
 
170 175
 	if user_org_id == 0 {
@@ -222,13 +227,21 @@ func (this *DoctorScheduleApiController) GetDoctorList() {
222 227
 	appId := this.GetAdminUserInfo().CurrentAppId
223 228
 	//admin_user_id := this.GetAdminUserInfo().AdminUser.Id
224 229
 	list, err := service.GetDoctorList(orgId, appId)
230
+
231
+	//获取所有的医生
232
+	doctorList, err := service.GetAllDoctorList(orgId, appId)
233
+
234
+	//获取所有的护士
235
+	nurseList, err := service.GetAllNurseList(orgId, appId)
225 236
 	if err != nil {
226 237
 		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
227 238
 		return
228 239
 	}
229 240
 
230 241
 	this.ServeSuccessJSON(map[string]interface{}{
231
-		"list": list,
242
+		"list":       list,
243
+		"doctorlist": doctorList,
244
+		"nurselist":  nurseList,
232 245
 	})
233 246
 }
234 247
 
@@ -491,3 +504,65 @@ func (this *DoctorScheduleApiController) UpdateContinusSchedule() {
491 504
 		"schedule": schedule,
492 505
 	})
493 506
 }
507
+
508
+func (this *DoctorScheduleApiController) SaveNureSort() {
509
+
510
+	id, _ := this.GetInt64("id")
511
+	fmt.Println("id", id)
512
+	sort, _ := this.GetInt64("sort")
513
+	fmt.Println("sort", sort)
514
+	role := models.App_Role{
515
+		Sort: sort,
516
+	}
517
+	err := service.SaveNurseSort(&role, id)
518
+	if err != nil {
519
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
520
+		return
521
+	}
522
+
523
+	this.ServeSuccessJSON(map[string]interface{}{
524
+		"role": role,
525
+	})
526
+}
527
+
528
+func (this *DoctorScheduleApiController) SaveIsSchedule() {
529
+
530
+	id, _ := this.GetInt64("id")
531
+	fmt.Println("id", id)
532
+	is_sort, _ := this.GetInt64("is_sort")
533
+	fmt.Println("is_sort", is_sort)
534
+	role := models.App_Role{
535
+		IsSort: is_sort,
536
+	}
537
+	err := service.SaveIsSchedule(id, &role)
538
+	if err != nil {
539
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
540
+		return
541
+	}
542
+
543
+	this.ServeSuccessJSON(map[string]interface{}{
544
+		"role": role,
545
+	})
546
+}
547
+
548
+func (this *DoctorScheduleApiController) GetScheduleListTotal() {
549
+
550
+	start_time, _ := this.GetInt64("start_time")
551
+	fmt.Println(start_time)
552
+	end_time, _ := this.GetInt64("end_time")
553
+	fmt.Println("end_time", end_time)
554
+	adminUserInfo := this.GetAdminUserInfo()
555
+	orgId := adminUserInfo.CurrentOrgId
556
+	//统计总工时
557
+	scheudletotal, err := service.GetScheduleListTotal(orgId, start_time, end_time)
558
+	list, err := service.GetTotalMinutes(orgId, start_time, end_time)
559
+	if err != nil {
560
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
561
+		return
562
+	}
563
+
564
+	this.ServeSuccessJSON(map[string]interface{}{
565
+		"scheudletotal": scheudletotal,
566
+		"list":          list,
567
+	})
568
+}

+ 21 - 0
models/doctor_schedule_models.go View File

@@ -16,6 +16,7 @@ type DoctorSchedules struct {
16 16
 	Status          int64  `gorm:"column:status" json:"status" form:"status"`
17 17
 	Ctime           int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
18 18
 	Mtime           int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
19
+	Minute          int64  `gorm:"column:minute" json:"minute" form:"minute"`
19 20
 }
20 21
 
21 22
 func (DoctorSchedules) TableName() string {
@@ -59,6 +60,10 @@ type XtStaffSchedule struct {
59 60
 	AdminUserId     int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
60 61
 	UserType        int64  `gorm:"column:user_type" json:"user_type" form:"user_type"`
61 62
 	ClassAttributes int64  `gorm:"column:class_attributes" json:"class_attributes" form:"class_attributes"`
63
+	Sort            int64  `gorm:"column:sort" json:"sort" form:"sort"`
64
+	IsSort          int64  `gorm:"column:is_sort" json:"is_sort" form:"is_sort"`
65
+	WorkTime        string `gorm:"column:work_time" json:"work_time" form:"work_time"`
66
+	Minute          int64  `gorm:"column:minute" json:"minute" form:"minute"`
62 67
 }
63 68
 
64 69
 type XTSgjUserAdminRole struct {
@@ -66,6 +71,9 @@ type XTSgjUserAdminRole struct {
66 71
 	AdminUserId int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
67 72
 	UserName    string `gorm:"column:user_name" json:"user_name" form:"user_name"`
68 73
 	UserType    int64  `gorm:"column:user_type" json:"user_type" form:"user_type"`
74
+	UserTitle   int64  `gorm:"column:user_title" json:"user_title" form:"user_title"`
75
+	Sort        int64  `gorm:"column:sort" json:"sort" form:"sort"`
76
+	IsSort      int64  `gorm:"column:is_sort" json:"is_sort" form:"is_sort"`
69 77
 }
70 78
 
71 79
 func (XTSgjUserAdminRole) TableName() string {
@@ -84,3 +92,16 @@ type ContinueSchedule struct {
84 92
 func (ContinueSchedule) TableName() string {
85 93
 	return "xt_continue_schedule"
86 94
 }
95
+
96
+type CountStaffSchedule struct {
97
+	ID            int64  `gorm:"column:id" json:"id" form:"id"`
98
+	DoctorId      int64  `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
99
+	StartTime     int64  `gorm:"column:start_time" json:"start_time" form:"start_time"`
100
+	EndTime       int64  `gorm:"column:end_time" json:"end_time" form:"end_time"`
101
+	ScheduleDate  int64  `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
102
+	UserName      string `gorm:"column:user_name" json:"user_name" form:"user_name"`
103
+	ClassName     string `gorm:"column:class_name" json:"class_name" form:"class_name"`
104
+	Sort          int64  `gorm:"column:sort" json:"sort" form:"sort"`
105
+	Count         int64
106
+	TotalMininute int64 `gorm:"column:totalminute" json:"totalminute" form:"totalminute"`
107
+}

+ 1 - 0
models/role_models.go View File

@@ -60,6 +60,7 @@ type App_Role struct {
60 60
 	Sex             int64  `gorm:"column:sex" json:"sex" form:"sex"`
61 61
 	Birthday        int64  `gorm:"column:birthday" json:"birthday" form:"birthday"`
62 62
 	Sort            int64  `gorm:"column:sort" json:"sort" form:"sort"`
63
+	IsSort          int64  `gorm:"column:is_sort" json:"is_sort" form:"is_sort"`
63 64
 }
64 65
 
65 66
 func (App_Role) TableName() string {

+ 1 - 1
service/data.go View File

@@ -228,7 +228,7 @@ func BatchInsertFiledSystemConfig(org_id int64) (err error) {
228 228
 
229 229
 func BatchInsertDoctorSchedule(orgid int64) (err error) {
230 230
 
231
-	err = readDb.Exec("INSERT INTO sgj_xt.xt_doctor_schedules(user_org_id,class_name,class_attributes,timeone_start,timeone_type,timeone_end,timetwo_start,timetwo_type,timetwo_end,work_time,remarks,status,ctime) SELECT ?, class_name,class_attributes,timeone_start,timeone_type,timeone_end,timetwo_start,timetwo_type,timetwo_end,work_time,remarks,status,ctime FROM xt_doctor_schedules WHERE user_org_id = 0", orgid).Error
231
+	err = readDb.Exec("INSERT INTO sgj_xt.xt_doctor_schedules(user_org_id,class_name,class_attributes,timeone_start,timeone_type,timeone_end,timetwo_start,timetwo_type,timetwo_end,work_time,remarks,status,ctime,minute) SELECT ?, class_name,class_attributes,timeone_start,timeone_type,timeone_end,timetwo_start,timetwo_type,timetwo_end,work_time,remarks,status,ctime,minute FROM xt_doctor_schedules WHERE user_org_id = 0", orgid).Error
232 232
 	return
233 233
 }
234 234
 

+ 61 - 5
service/doctor_schedule_service.go View File

@@ -58,7 +58,7 @@ func GetClassNameIsExsit(classname string, orgid int64, id int64) (schedule mode
58 58
 
59 59
 func UpdateScheduleList(id int64, schedules *models.DoctorSchedules) error {
60 60
 
61
-	err := XTReadDB().Model(&schedules).Where("id=?", id).Updates(map[string]interface{}{"class_name": schedules.ClassName, "class_attributes": schedules.ClassAttributes, "timeone_start": schedules.TimeoneStart, "timeone_type": schedules.TimeoneType, "timeone_end": schedules.TimeoneEnd, "timetwo_start": schedules.TimetwoStart, "timetwo_type": schedules.TimetwoType, "timetwo_end": schedules.TimetwoEnd, "work_time": schedules.WorkTime, "remarks": schedules.Remarks, "mtime": time.Now().Unix()}).Error
61
+	err := XTReadDB().Model(&schedules).Where("id=?", id).Updates(map[string]interface{}{"class_name": schedules.ClassName, "class_attributes": schedules.ClassAttributes, "timeone_start": schedules.TimeoneStart, "timeone_type": schedules.TimeoneType, "timeone_end": schedules.TimeoneEnd, "timetwo_start": schedules.TimetwoStart, "timetwo_type": schedules.TimetwoType, "timetwo_end": schedules.TimetwoEnd, "work_time": schedules.WorkTime, "remarks": schedules.Remarks, "minute": schedules.Minute, "mtime": time.Now().Unix()}).Error
62 62
 	return err
63 63
 }
64 64
 
@@ -82,7 +82,19 @@ func DeleteScheduleById(id int64) error {
82 82
 
83 83
 func GetDoctorList(orgid int64, appid int64) (role []*models.XTSgjUserAdminRole, err error) {
84 84
 
85
-	err = UserReadDB().Model(&role).Where("org_id = ? and app_id = ? and status = 1 ", orgid, appid).Order("user_type desc").Find(&role).Error
85
+	err = UserReadDB().Model(&role).Where("org_id = ? and app_id = ? and (user_type = 2 or user_type = 3) and status = 1 and is_sort = 1", orgid, appid).Order("user_type desc").Find(&role).Error
86
+	return role, err
87
+}
88
+
89
+func GetAllDoctorList(orgid int64, appid int64) (role []*models.XTSgjUserAdminRole, err error) {
90
+
91
+	err = UserReadDB().Model(&role).Where("org_id =? and app_id = ? and user_type = 2 and status = 1", orgid, appid).Order("sort desc").Find(&role).Error
92
+	return role, err
93
+}
94
+
95
+func GetAllNurseList(orgid int64, appid int64) (role []*models.XTSgjUserAdminRole, err error) {
96
+
97
+	err = UserReadDB().Model(&role).Where("org_id = ? and app_id = ? and user_type =3 and status =1", orgid, appid).Order("sort desc").Find(&role).Error
86 98
 	return role, err
87 99
 }
88 100
 
@@ -127,7 +139,7 @@ func GetStaffScheduleList(orgid int64, startime int64, endtime int64) (schedule
127 139
 	if orgid > 0 {
128 140
 		db = db.Where("x.user_org_id = ?", orgid)
129 141
 	}
130
-	err = db.Group("x.id").Select("x.id,x.doctor_id,x.doctor_type,x.schedule_type,x.schedule_week,x.user_org_id,x.start_time,x.end_time,x.schedule_date,r.user_name,s.class_name,r.admin_user_id,r.user_type,s.class_attributes").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.doctor_id").Joins("left join xt_doctor_schedules as s on s.id = x.schedule_type").Where("r.org_id = ? and r.status = 1 and s.user_org_id = ? and s.status = 1", orgid, orgid).Scan(&schedule).Error
142
+	err = db.Group("x.id").Select("x.id,x.doctor_id,x.doctor_type,x.schedule_type,x.schedule_week,x.user_org_id,x.start_time,x.end_time,x.schedule_date,r.user_name,s.class_name,r.admin_user_id,r.user_type,s.class_attributes,r.sort,r.is_sort,s.work_time,s.minute").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.doctor_id").Joins("left join xt_doctor_schedules as s on s.id = x.schedule_type").Where("r.org_id = ? and r.status = 1 and s.user_org_id = ? and s.status = 1", orgid, orgid).Scan(&schedule).Error
131 143
 	return schedule, err
132 144
 }
133 145
 
@@ -167,7 +179,7 @@ func GetScheduleByDoctorId(doctorid int64, startime int64, endtime int64, orgid
167 179
 	if doctorid > 0 {
168 180
 		db = db.Where("x.doctor_type = ?", doctorid)
169 181
 	}
170
-	err = db.Group("x.id").Select("x.id,x.doctor_id,x.doctor_type,x.schedule_type,x.schedule_week,x.user_org_id,x.start_time,x.end_time,x.schedule_date,r.user_name,s.class_name,r.admin_user_id,s.class_attributes").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.doctor_id").Joins("left join xt_doctor_schedules as s on s.id = x.schedule_type").Where("r.org_id = ? and r.status = 1 and s.user_org_id = ?", orgid, orgid).Scan(&schedule).Error
182
+	err = db.Group("x.id").Select("x.id,x.doctor_id,x.doctor_type,x.schedule_type,x.schedule_week,x.user_org_id,x.start_time,x.end_time,x.schedule_date,r.user_name,s.class_name,r.admin_user_id,s.class_attributes,r.sort,r.is_sort").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.doctor_id").Joins("left join xt_doctor_schedules as s on s.id = x.schedule_type").Where("r.org_id = ? and r.status = 1 and s.user_org_id = ?", orgid, orgid).Scan(&schedule).Error
171 183
 	return schedule, err
172 184
 }
173 185
 
@@ -186,7 +198,7 @@ func ToSearchSeacheduleList(keywords string, startime int64, endtime int64, orgi
186 198
 	//if(doctorid >0){
187 199
 	//  db = db.Where("x.doctor_id = ?", doctorid)
188 200
 	//}
189
-	err = db.Group("x.id").Select("x.id,x.doctor_id,x.doctor_type,x.schedule_type,x.schedule_week,x.user_org_id,x.start_time,x.schedule_date,x.end_time,r.user_type,r.user_name,s.class_name,r.admin_user_id,s.class_attributes").Joins("left join sgj_users.sgj_user_admin_role AS r ON r.admin_user_id = x.doctor_id").Joins("left join xt_doctor_schedules as s on s.id = x.schedule_type and s.user_org_id = ?", orgid).Where("r.org_id = ? and r.status = 1  and r.user_name like ?", orgid, likeKey).Scan(&schedule).Error
201
+	err = db.Group("x.id").Select("x.id,x.doctor_id,x.doctor_type,x.schedule_type,x.schedule_week,x.user_org_id,x.start_time,x.schedule_date,x.end_time,r.user_type,r.user_name,s.class_name,r.admin_user_id,s.class_attributes,r.sort,r.is_sort").Joins("left join sgj_users.sgj_user_admin_role AS r ON r.admin_user_id = x.doctor_id").Joins("left join xt_doctor_schedules as s on s.id = x.schedule_type and s.user_org_id = ?", orgid).Where("r.org_id = ? and r.status = 1  and r.user_name like ?", orgid, likeKey).Scan(&schedule).Error
190 202
 	return schedule, err
191 203
 }
192 204
 
@@ -224,3 +236,47 @@ func UpdateContinusSchedule(schedule *models.ContinueSchedule, orgid int64) erro
224 236
 	err := XTWriteDB().Model(&schedule).Where("user_org_id = ? and status = 1", orgid).Updates(map[string]interface{}{"is_status": schedule.IsStatus, "mtime": time.Now().Unix()}).Error
225 237
 	return err
226 238
 }
239
+
240
+func SaveNurseSort(role *models.App_Role, id int64) error {
241
+
242
+	err := UserWriteDB().Model(&role).Where("id = ?", id).Updates(map[string]interface{}{"sort": role.Sort}).Error
243
+	return err
244
+}
245
+
246
+func SaveIsSchedule(id int64, role *models.App_Role) error {
247
+
248
+	err := UserWriteDB().Model(&role).Where("id=?", id).Updates(map[string]interface{}{"is_sort": role.IsSort}).Error
249
+	return err
250
+}
251
+
252
+func GetScheduleListTotal(orgid int64, startime int64, endtime int64) (schedule []*models.CountStaffSchedule, err error) {
253
+
254
+	db := XTReadDB().Table("xt_staff_schedule as x").Where("x.status = 1")
255
+	if startime > 0 {
256
+		db = db.Where("x.start_time >=?", startime)
257
+	}
258
+	if endtime > 0 {
259
+		db = db.Where("x.end_time <=?", endtime)
260
+	}
261
+	if orgid > 0 {
262
+		db = db.Where("x.user_org_id = ?", orgid)
263
+	}
264
+	err = db.Group("x.doctor_id,x.schedule_type").Select("x.doctor_id,x.schedule_type,x.start_time,x.end_time,x.schedule_date,r.user_name,s.class_name,r.sort,r.is_sort,count(s.class_name) as count").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.doctor_id").Joins("left join xt_doctor_schedules as s on s.id = x.schedule_type").Where("r.org_id = ? and r.status = 1 and s.user_org_id = ? and s.status = 1", orgid, orgid).Scan(&schedule).Error
265
+	return schedule, err
266
+}
267
+
268
+func GetTotalMinutes(orgid int64, startime int64, endtime int64) (schedule []*models.CountStaffSchedule, err error) {
269
+
270
+	db := XTReadDB().Table("xt_staff_schedule as x").Where("x.status = 1")
271
+	if startime > 0 {
272
+		db = db.Where("x.start_time >=?", startime)
273
+	}
274
+	if endtime > 0 {
275
+		db = db.Where("x.end_time <=?", endtime)
276
+	}
277
+	if orgid > 0 {
278
+		db = db.Where("x.user_org_id = ?", orgid)
279
+	}
280
+	err = db.Group("x.doctor_id").Select("x.doctor_id,x.schedule_type,x.start_time,x.end_time,x.schedule_date,r.user_name,s.class_name,r.sort,r.is_sort,sum(s.minute) as totalminute").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.doctor_id").Joins("left join xt_doctor_schedules as s on s.id = x.schedule_type").Where("r.org_id = ? and r.status = 1 and s.user_org_id = ? and s.status = 1", orgid, orgid).Scan(&schedule).Error
281
+	return schedule, err
282
+}

+ 1 - 0
service/role_service.go View File

@@ -345,6 +345,7 @@ func CreateGeneralAdminUser(orgID int64, appID int64, mobile string, name string
345 345
 		CreateTime:    now,
346 346
 		ModifyTime:    now,
347 347
 		RoleIds:       roleIds,
348
+		IsSort:        1,
348 349
 	}
349 350
 	if createApp_RoleErr := tx.Create(&app_role).Error; createApp_RoleErr != nil {
350 351
 		tx.Rollback()