doctor_schedule_api_controller.go 20KB

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