|
@@ -0,0 +1,493 @@
|
|
1
|
+package controllers
|
|
2
|
+
|
|
3
|
+import (
|
|
4
|
+ "XT_New/enums"
|
|
5
|
+ "XT_New/models"
|
|
6
|
+ "XT_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
|
+}
|
|
35
|
+
|
|
36
|
+func (this *DoctorScheduleApiController) SaveDoctorSchedules() {
|
|
37
|
+ adminUser := this.GetAdminUserInfo()
|
|
38
|
+ orgId := adminUser.CurrentOrgId
|
|
39
|
+ class_name := this.GetString("class_name")
|
|
40
|
+ class_attributes, _ := this.GetInt64("class_attributes")
|
|
41
|
+ timeone_start := this.GetString("timeone_start")
|
|
42
|
+ timeone_type, _ := this.GetInt64("timeone_type")
|
|
43
|
+ timeone_end := this.GetString("timeone_end")
|
|
44
|
+ timetwo_start := this.GetString("timetwo_start")
|
|
45
|
+ timetwo_type, _ := this.GetInt64("timetwo_type")
|
|
46
|
+ timetwo_end := this.GetString("timetwo_end")
|
|
47
|
+ work_time := this.GetString("work_time")
|
|
48
|
+ remarks := this.GetString("remarks")
|
|
49
|
+
|
|
50
|
+ schedules := models.DoctorSchedules{
|
|
51
|
+ ClassName: class_name,
|
|
52
|
+ ClassAttributes: class_attributes,
|
|
53
|
+ TimeoneStart: timeone_start,
|
|
54
|
+ TimeoneType: timeone_type,
|
|
55
|
+ TimeoneEnd: timeone_end,
|
|
56
|
+ TimetwoStart: timetwo_start,
|
|
57
|
+ TimetwoEnd: timetwo_end,
|
|
58
|
+ TimetwoType: timetwo_type,
|
|
59
|
+ WorkTime: work_time,
|
|
60
|
+ Remarks: remarks,
|
|
61
|
+ UserOrgId: orgId,
|
|
62
|
+ Status: 1,
|
|
63
|
+ Ctime: time.Now().Unix(),
|
|
64
|
+ }
|
|
65
|
+
|
|
66
|
+ //查询班种名称是否存在
|
|
67
|
+ _, errcode := service.GetClassName(orgId, class_name)
|
|
68
|
+ //如果不存在
|
|
69
|
+ if errcode == gorm.ErrRecordNotFound {
|
|
70
|
+ err := service.CreateDotorSchedule(&schedules)
|
|
71
|
+ if err != nil {
|
|
72
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
|
|
73
|
+ return
|
|
74
|
+ }
|
|
75
|
+
|
|
76
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
77
|
+ "schedules": schedules,
|
|
78
|
+ })
|
|
79
|
+ } else if errcode == nil {
|
|
80
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "班种名称已存在")
|
|
81
|
+ return
|
|
82
|
+ }
|
|
83
|
+
|
|
84
|
+}
|
|
85
|
+
|
|
86
|
+func (this *DoctorScheduleApiController) GetDoctorScheduleList() {
|
|
87
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
88
|
+ orgId := adminUserInfo.CurrentOrgId
|
|
89
|
+ page, _ := this.GetInt64("page")
|
|
90
|
+ limit, _ := this.GetInt64("limit")
|
|
91
|
+ schedules, total, err := service.GetDoctorScheduleList(orgId, page, limit)
|
|
92
|
+ if err != nil {
|
|
93
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
|
|
94
|
+ return
|
|
95
|
+ }
|
|
96
|
+
|
|
97
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
98
|
+ "schedules": schedules,
|
|
99
|
+ "total": total,
|
|
100
|
+ })
|
|
101
|
+ //查询该机构是否有班种,如果没有去读系统默认的
|
|
102
|
+ //_, errcode := service.GetDoctorScheduleByOrgId(orgId)
|
|
103
|
+ //if errcode == gorm.ErrRecordNotFound{
|
|
104
|
+ // schedules, total, err := service.GetDoctorScheduleList(0,page, limit)
|
|
105
|
+ // if err != nil {
|
|
106
|
+ // this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
|
|
107
|
+ // return
|
|
108
|
+ // }
|
|
109
|
+ //
|
|
110
|
+ // this.ServeSuccessJSON(map[string]interface{}{
|
|
111
|
+ // "schedules": schedules,
|
|
112
|
+ // "total":total,
|
|
113
|
+ // })
|
|
114
|
+ //}else if errcode == nil{
|
|
115
|
+ // schedules, total, err := service.GetDoctorScheduleList(orgId, page, limit)
|
|
116
|
+ // if err != nil {
|
|
117
|
+ // this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
|
|
118
|
+ // return
|
|
119
|
+ // }
|
|
120
|
+ //
|
|
121
|
+ // this.ServeSuccessJSON(map[string]interface{}{
|
|
122
|
+ // "schedules": schedules,
|
|
123
|
+ // "total":total,
|
|
124
|
+ // })
|
|
125
|
+ //}
|
|
126
|
+}
|
|
127
|
+
|
|
128
|
+func (this *DoctorScheduleApiController) GetScheduleDetail() {
|
|
129
|
+
|
|
130
|
+ id, _ := this.GetInt64("id")
|
|
131
|
+ scheduleDetail, err := service.GetScheduleDetail(id)
|
|
132
|
+ if err != nil {
|
|
133
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
|
|
134
|
+ return
|
|
135
|
+ }
|
|
136
|
+
|
|
137
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
138
|
+ "scheduleDetail": scheduleDetail,
|
|
139
|
+ })
|
|
140
|
+}
|
|
141
|
+
|
|
142
|
+func (this *DoctorScheduleApiController) UpdateSchedule() {
|
|
143
|
+
|
|
144
|
+ id, _ := this.GetInt64("id")
|
|
145
|
+ class_name := this.GetString("class_name")
|
|
146
|
+ class_attributes, _ := this.GetInt64("class_attributes")
|
|
147
|
+ timeone_start := this.GetString("timeone_start")
|
|
148
|
+ timeone_type, _ := this.GetInt64("timeone_type")
|
|
149
|
+ timeone_end := this.GetString("timeone_end")
|
|
150
|
+ timetwo_start := this.GetString("timetwo_start")
|
|
151
|
+ timetwo_type, _ := this.GetInt64("timetwo_type")
|
|
152
|
+ timetwo_end := this.GetString("timetwo_end")
|
|
153
|
+ work_time := this.GetString("work_time")
|
|
154
|
+ remarks := this.GetString("remarks")
|
|
155
|
+ user_org_id, _ := this.GetInt64("user_org_id")
|
|
156
|
+
|
|
157
|
+ schedules := models.DoctorSchedules{
|
|
158
|
+ ClassName: class_name,
|
|
159
|
+ ClassAttributes: class_attributes,
|
|
160
|
+ TimeoneStart: timeone_start,
|
|
161
|
+ TimeoneType: timeone_type,
|
|
162
|
+ TimeoneEnd: timeone_end,
|
|
163
|
+ TimetwoStart: timetwo_start,
|
|
164
|
+ TimetwoEnd: timetwo_end,
|
|
165
|
+ TimetwoType: timetwo_type,
|
|
166
|
+ WorkTime: work_time,
|
|
167
|
+ Remarks: remarks,
|
|
168
|
+ }
|
|
169
|
+
|
|
170
|
+ if user_org_id == 0 {
|
|
171
|
+ err := service.CreateDotorSchedule(&schedules)
|
|
172
|
+ if err != nil {
|
|
173
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
|
|
174
|
+ return
|
|
175
|
+ }
|
|
176
|
+ } else {
|
|
177
|
+ //查询是否班种名称已存在
|
|
178
|
+ scheduledata, _ := service.GetClassNameIsExsit(class_name, user_org_id, id)
|
|
179
|
+
|
|
180
|
+ if scheduledata.ID > 0 && scheduledata.ID != id {
|
|
181
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "班种名称已存在")
|
|
182
|
+ return
|
|
183
|
+ }
|
|
184
|
+
|
|
185
|
+ err := service.UpdateScheduleList(id, &schedules)
|
|
186
|
+ if err != nil {
|
|
187
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
|
|
188
|
+ return
|
|
189
|
+ }
|
|
190
|
+ }
|
|
191
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
192
|
+ "schedules": schedules,
|
|
193
|
+ })
|
|
194
|
+}
|
|
195
|
+
|
|
196
|
+func (this *DoctorScheduleApiController) DeleteSchedule() {
|
|
197
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
198
|
+ orgId := adminUserInfo.CurrentOrgId
|
|
199
|
+ id, _ := this.GetInt64("id")
|
|
200
|
+ //产寻该班种是否存在排班,如果存在不能删除
|
|
201
|
+ _, errcode := service.GetStaffScheduleByScheduleType(id, orgId)
|
|
202
|
+ if errcode == gorm.ErrRecordNotFound {
|
|
203
|
+ err := service.DeleteScheduleById(id)
|
|
204
|
+ if err != nil {
|
|
205
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
|
|
206
|
+ return
|
|
207
|
+ }
|
|
208
|
+ returnData := make(map[string]interface{}, 0)
|
|
209
|
+ returnData["msg"] = "ok"
|
|
210
|
+ this.ServeSuccessJSON(returnData)
|
|
211
|
+ return
|
|
212
|
+ } else if errcode == nil {
|
|
213
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "该班种已存在排班,不能删除")
|
|
214
|
+ return
|
|
215
|
+ }
|
|
216
|
+
|
|
217
|
+}
|
|
218
|
+
|
|
219
|
+func (this *DoctorScheduleApiController) GetDoctorList() {
|
|
220
|
+
|
|
221
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
222
|
+ appId := this.GetAdminUserInfo().CurrentAppId
|
|
223
|
+ //admin_user_id := this.GetAdminUserInfo().AdminUser.Id
|
|
224
|
+ list, err := service.GetDoctorList(orgId, appId)
|
|
225
|
+ if err != nil {
|
|
226
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
|
|
227
|
+ return
|
|
228
|
+ }
|
|
229
|
+
|
|
230
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
231
|
+ "list": list,
|
|
232
|
+ })
|
|
233
|
+}
|
|
234
|
+
|
|
235
|
+func (this *DoctorScheduleApiController) GetScheduleList() {
|
|
236
|
+
|
|
237
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
238
|
+ _, errcode := service.GetDoctorScheduleByOrgId(orgId)
|
|
239
|
+ if errcode == gorm.ErrRecordNotFound {
|
|
240
|
+ scheduleList, err := service.GetScheduleList(0)
|
|
241
|
+ if err != nil {
|
|
242
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
|
|
243
|
+ return
|
|
244
|
+ }
|
|
245
|
+
|
|
246
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
247
|
+ "scheduleList": scheduleList,
|
|
248
|
+ })
|
|
249
|
+ } else {
|
|
250
|
+ scheduleList, err := service.GetScheduleList(orgId)
|
|
251
|
+ if err != nil {
|
|
252
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
|
|
253
|
+ return
|
|
254
|
+ }
|
|
255
|
+
|
|
256
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
257
|
+ "scheduleList": scheduleList,
|
|
258
|
+ })
|
|
259
|
+ }
|
|
260
|
+}
|
|
261
|
+
|
|
262
|
+func (this *DoctorScheduleApiController) AddSchedule() {
|
|
263
|
+
|
|
264
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
265
|
+ doctor_id, _ := this.GetInt64("doctor_id")
|
|
266
|
+ fmt.Println("doctor_id", doctor_id)
|
|
267
|
+ doctor_type, _ := this.GetInt64("doctor_type")
|
|
268
|
+ fmt.Println("doctor_type", doctor_type)
|
|
269
|
+ start_time, _ := this.GetInt64("start_time")
|
|
270
|
+ fmt.Println("start_time", start_time)
|
|
271
|
+ end_time, _ := this.GetInt64("end_time")
|
|
272
|
+ fmt.Println("end_time", end_time)
|
|
273
|
+ schedule_type, _ := this.GetInt64("schedule_type")
|
|
274
|
+ fmt.Println("schedule_type", schedule_type)
|
|
275
|
+ schedule_week, _ := this.GetInt64("schedule_week")
|
|
276
|
+ fmt.Println("schedule_week", schedule_week)
|
|
277
|
+ schedule_date, _ := this.GetInt64("schedule_date")
|
|
278
|
+ schedule := models.StaffSchedule{
|
|
279
|
+ DoctorId: doctor_id,
|
|
280
|
+ DoctorType: doctor_type,
|
|
281
|
+ ScheduleType: schedule_type,
|
|
282
|
+ ScheduleWeek: schedule_week,
|
|
283
|
+ UserOrgId: orgId,
|
|
284
|
+ StartTime: start_time,
|
|
285
|
+ EndTime: end_time,
|
|
286
|
+ Status: 1,
|
|
287
|
+ Ctime: time.Now().Unix(),
|
|
288
|
+ ScheduleDate: schedule_date,
|
|
289
|
+ }
|
|
290
|
+
|
|
291
|
+ _, errcode := service.GetScheduleListDetail(doctor_id, orgId, schedule_date)
|
|
292
|
+ fmt.Println("errcode-----", errcode)
|
|
293
|
+ if errcode == gorm.ErrRecordNotFound {
|
|
294
|
+ err := service.AddSchedule(&schedule)
|
|
295
|
+ if err != nil {
|
|
296
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
|
|
297
|
+ return
|
|
298
|
+ }
|
|
299
|
+
|
|
300
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
301
|
+ "schedule": schedule,
|
|
302
|
+ })
|
|
303
|
+ } else if errcode == nil {
|
|
304
|
+ schedules, _ := service.GetScheduleListDetail(doctor_id, orgId, schedule_date)
|
|
305
|
+ err := service.UpdateStaffList(&schedule, schedules.ID)
|
|
306
|
+ if err != nil {
|
|
307
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
|
|
308
|
+ return
|
|
309
|
+ }
|
|
310
|
+
|
|
311
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
312
|
+ "schedule": schedule,
|
|
313
|
+ })
|
|
314
|
+ }
|
|
315
|
+
|
|
316
|
+}
|
|
317
|
+
|
|
318
|
+func (this *DoctorScheduleApiController) GetStaffScheduleList() {
|
|
319
|
+
|
|
320
|
+ start_time, _ := this.GetInt64("start_time")
|
|
321
|
+ fmt.Println("start_time", start_time)
|
|
322
|
+ end_time, _ := this.GetInt64("end_time")
|
|
323
|
+ fmt.Println("end_time", end_time)
|
|
324
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
325
|
+ staffList, err := service.GetStaffScheduleList(orgId, start_time, end_time)
|
|
326
|
+ if err != nil {
|
|
327
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
|
|
328
|
+ return
|
|
329
|
+ }
|
|
330
|
+
|
|
331
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
332
|
+ "staffList": staffList,
|
|
333
|
+ })
|
|
334
|
+}
|
|
335
|
+
|
|
336
|
+func (this *DoctorScheduleApiController) GetNextWeekList() {
|
|
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) GetScheduleByDoctorId() {
|
|
354
|
+
|
|
355
|
+ doctor_id, _ := this.GetInt64("doctor_id")
|
|
356
|
+ start_time, _ := this.GetInt64("start_time")
|
|
357
|
+ end_time, _ := this.GetInt64("end_time")
|
|
358
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
359
|
+ staffList, err := service.GetScheduleByDoctorId(doctor_id, start_time, end_time, orgId)
|
|
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) ToSearchScheduleList() {
|
|
371
|
+
|
|
372
|
+ //doctor_id, _ := this.GetInt64("doctor_id")
|
|
373
|
+ user_name := this.GetString("user_name")
|
|
374
|
+ start_time, _ := this.GetInt64("start_time")
|
|
375
|
+ end_time, _ := this.GetInt64("end_time")
|
|
376
|
+ orgId := this.GetAdminUserInfo().CurrentOrgId
|
|
377
|
+ staffList, err := service.ToSearchSeacheduleList(user_name, start_time, end_time, orgId)
|
|
378
|
+ if err != nil {
|
|
379
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
|
|
380
|
+ return
|
|
381
|
+ }
|
|
382
|
+
|
|
383
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
384
|
+ "staffList": staffList,
|
|
385
|
+ })
|
|
386
|
+}
|
|
387
|
+
|
|
388
|
+func (this *DoctorScheduleApiController) DeleteStaffSchedule() {
|
|
389
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
390
|
+ orgId := adminUserInfo.CurrentOrgId
|
|
391
|
+ start_time, _ := this.GetInt64("start_time")
|
|
392
|
+ fmt.Println("start_time", start_time)
|
|
393
|
+ end_time, _ := this.GetInt64("end_time")
|
|
394
|
+ err := service.DeleteStaffSchedule(orgId, start_time, end_time)
|
|
395
|
+ if err != nil {
|
|
396
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
|
|
397
|
+ return
|
|
398
|
+ }
|
|
399
|
+ returnData := make(map[string]interface{}, 0)
|
|
400
|
+ returnData["msg"] = "ok"
|
|
401
|
+ this.ServeSuccessJSON(returnData)
|
|
402
|
+ return
|
|
403
|
+}
|
|
404
|
+
|
|
405
|
+func (this *DoctorScheduleApiController) CopyStaffSchedule() {
|
|
406
|
+
|
|
407
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
408
|
+ orgId := adminUserInfo.CurrentOrgId
|
|
409
|
+ start_time, _ := this.GetInt64("start_time")
|
|
410
|
+ fmt.Println("start_time", start_time)
|
|
411
|
+ end_time, _ := this.GetInt64("end_time")
|
|
412
|
+ fmt.Println("end_time", end_time)
|
|
413
|
+ copy_startime, _ := this.GetInt64("copy_startime")
|
|
414
|
+ fmt.Println("copy_startime", copy_startime)
|
|
415
|
+ copy_endtime, _ := this.GetInt64("copy_endtime")
|
|
416
|
+ schedule, err := service.GetStaffScheduleListTwo(orgId, start_time, end_time)
|
|
417
|
+ //查询选中日期的排班是否存在
|
|
418
|
+ _, errcode := service.GetNextWeekSchedule(orgId, copy_startime, copy_endtime)
|
|
419
|
+ if errcode == gorm.ErrRecordNotFound {
|
|
420
|
+ for _, item := range schedule {
|
|
421
|
+ //fmt.Println(item.StartTime+604800)
|
|
422
|
+ //礼拜1
|
|
423
|
+ if item.ScheduleWeek == 1 {
|
|
424
|
+ item.ScheduleDate = copy_startime
|
|
425
|
+ }
|
|
426
|
+ if item.ScheduleWeek == 2 {
|
|
427
|
+ item.ScheduleDate = copy_startime + 86400
|
|
428
|
+ }
|
|
429
|
+ if item.ScheduleWeek == 3 {
|
|
430
|
+ item.ScheduleDate = copy_startime + 172800
|
|
431
|
+ }
|
|
432
|
+ if item.ScheduleWeek == 4 {
|
|
433
|
+ item.ScheduleDate = copy_startime + 259200
|
|
434
|
+ }
|
|
435
|
+ if item.ScheduleWeek == 5 {
|
|
436
|
+ item.ScheduleDate = copy_startime + 345600
|
|
437
|
+ }
|
|
438
|
+
|
|
439
|
+ if item.ScheduleWeek == 6 {
|
|
440
|
+ item.ScheduleDate = copy_startime + 432000
|
|
441
|
+ }
|
|
442
|
+ //礼拜天
|
|
443
|
+ if item.ScheduleWeek == 0 {
|
|
444
|
+ item.ScheduleDate = copy_endtime
|
|
445
|
+ }
|
|
446
|
+ staffSchedule := models.StaffSchedule{
|
|
447
|
+ DoctorId: item.DoctorId,
|
|
448
|
+ DoctorType: item.DoctorType,
|
|
449
|
+ ScheduleType: item.ScheduleType,
|
|
450
|
+ ScheduleWeek: item.ScheduleWeek,
|
|
451
|
+ UserOrgId: item.UserOrgId,
|
|
452
|
+ StartTime: copy_startime,
|
|
453
|
+ EndTime: copy_endtime,
|
|
454
|
+ Status: 1,
|
|
455
|
+ Ctime: time.Now().Unix(),
|
|
456
|
+ ScheduleDate: item.ScheduleDate,
|
|
457
|
+ }
|
|
458
|
+ service.AddSchedule(&staffSchedule)
|
|
459
|
+ }
|
|
460
|
+ if err != nil {
|
|
461
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
|
|
462
|
+ return
|
|
463
|
+ }
|
|
464
|
+ returnData := make(map[string]interface{}, 0)
|
|
465
|
+ returnData["msg"] = "ok"
|
|
466
|
+ this.ServeSuccessJSON(returnData)
|
|
467
|
+ return
|
|
468
|
+ } else if errcode == nil {
|
|
469
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "排班数据已存在")
|
|
470
|
+ fmt.Print("下周排班已存在")
|
|
471
|
+ return
|
|
472
|
+ }
|
|
473
|
+
|
|
474
|
+}
|
|
475
|
+
|
|
476
|
+func (this *DoctorScheduleApiController) UpdateContinusSchedule() {
|
|
477
|
+ adminUserInfo := this.GetAdminUserInfo()
|
|
478
|
+ orgId := adminUserInfo.CurrentOrgId
|
|
479
|
+ is_status, _ := this.GetInt64("is_status")
|
|
480
|
+ fmt.Println("is_status", is_status)
|
|
481
|
+ schedule := models.ContinueSchedule{
|
|
482
|
+ IsStatus: is_status,
|
|
483
|
+ }
|
|
484
|
+ err := service.UpdateContinusSchedule(&schedule, orgId)
|
|
485
|
+ if err != nil {
|
|
486
|
+ this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
|
|
487
|
+ return
|
|
488
|
+ }
|
|
489
|
+
|
|
490
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
491
|
+ "schedule": schedule,
|
|
492
|
+ })
|
|
493
|
+}
|