doctor_schedule_api_controller.go 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  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. beego.Router("/api/schedule/getchartlist", &DoctorScheduleApiController{}, "Get:GetChartlist")
  36. beego.Router("/api/deletestaffschedulebyid", &DoctorScheduleApiController{}, "Get:DeleteStaffScheduleById")
  37. }
  38. func (this *DoctorScheduleApiController) SaveDoctorSchedules() {
  39. adminUser := this.GetAdminUserInfo()
  40. orgId := adminUser.CurrentOrgId
  41. class_name := this.GetString("class_name")
  42. class_attributes, _ := this.GetInt64("class_attributes")
  43. timeone_start := this.GetString("timeone_start")
  44. timeone_type, _ := this.GetInt64("timeone_type")
  45. timeone_end := this.GetString("timeone_end")
  46. timetwo_start := this.GetString("timetwo_start")
  47. timetwo_type, _ := this.GetInt64("timetwo_type")
  48. timetwo_end := this.GetString("timetwo_end")
  49. work_time := this.GetString("work_time")
  50. remarks := this.GetString("remarks")
  51. minute, _ := this.GetInt64("minute")
  52. schedules := models.DoctorSchedules{
  53. ClassName: class_name,
  54. ClassAttributes: class_attributes,
  55. TimeoneStart: timeone_start,
  56. TimeoneType: timeone_type,
  57. TimeoneEnd: timeone_end,
  58. TimetwoStart: timetwo_start,
  59. TimetwoEnd: timetwo_end,
  60. TimetwoType: timetwo_type,
  61. WorkTime: work_time,
  62. Remarks: remarks,
  63. UserOrgId: orgId,
  64. Status: 1,
  65. Ctime: time.Now().Unix(),
  66. Minute: minute,
  67. }
  68. //查询班种名称是否存在
  69. _, errcode := service.GetClassName(orgId, class_name)
  70. //如果不存在
  71. if errcode == gorm.ErrRecordNotFound {
  72. err := service.CreateDotorSchedule(&schedules)
  73. if err != nil {
  74. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  75. return
  76. }
  77. this.ServeSuccessJSON(map[string]interface{}{
  78. "schedules": schedules,
  79. })
  80. } else if errcode == nil {
  81. this.ServeFailJsonSend(enums.ErrorCodeDataException, "班种名称已存在")
  82. return
  83. }
  84. }
  85. func (this *DoctorScheduleApiController) GetDoctorScheduleList() {
  86. adminUserInfo := this.GetAdminUserInfo()
  87. orgId := adminUserInfo.CurrentOrgId
  88. page, _ := this.GetInt64("page")
  89. limit, _ := this.GetInt64("limit")
  90. schedules, total, err := service.GetDoctorScheduleList(orgId, page, limit)
  91. if err != nil {
  92. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  93. return
  94. }
  95. this.ServeSuccessJSON(map[string]interface{}{
  96. "schedules": schedules,
  97. "total": total,
  98. })
  99. //查询该机构是否有班种,如果没有去读系统默认的
  100. //_, errcode := service.GetDoctorScheduleByOrgId(orgId)
  101. //if errcode == gorm.ErrRecordNotFound{
  102. // schedules, total, err := service.GetDoctorScheduleList(0,page, limit)
  103. // if err != nil {
  104. // this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  105. // return
  106. // }
  107. //
  108. // this.ServeSuccessJSON(map[string]interface{}{
  109. // "schedules": schedules,
  110. // "total":total,
  111. // })
  112. //}else if errcode == nil{
  113. // schedules, total, err := service.GetDoctorScheduleList(orgId, page, limit)
  114. // if err != nil {
  115. // this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  116. // return
  117. // }
  118. //
  119. // this.ServeSuccessJSON(map[string]interface{}{
  120. // "schedules": schedules,
  121. // "total":total,
  122. // })
  123. //}
  124. }
  125. func (this *DoctorScheduleApiController) GetScheduleDetail() {
  126. id, _ := this.GetInt64("id")
  127. scheduleDetail, err := service.GetScheduleDetail(id)
  128. if err != nil {
  129. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  130. return
  131. }
  132. this.ServeSuccessJSON(map[string]interface{}{
  133. "scheduleDetail": scheduleDetail,
  134. })
  135. }
  136. func (this *DoctorScheduleApiController) UpdateSchedule() {
  137. id, _ := this.GetInt64("id")
  138. class_name := this.GetString("class_name")
  139. class_attributes, _ := this.GetInt64("class_attributes")
  140. timeone_start := this.GetString("timeone_start")
  141. timeone_type, _ := this.GetInt64("timeone_type")
  142. timeone_end := this.GetString("timeone_end")
  143. timetwo_start := this.GetString("timetwo_start")
  144. timetwo_type, _ := this.GetInt64("timetwo_type")
  145. timetwo_end := this.GetString("timetwo_end")
  146. work_time := this.GetString("work_time")
  147. remarks := this.GetString("remarks")
  148. user_org_id, _ := this.GetInt64("user_org_id")
  149. minute, _ := this.GetInt64("minute")
  150. schedules := models.DoctorSchedules{
  151. ClassName: class_name,
  152. ClassAttributes: class_attributes,
  153. TimeoneStart: timeone_start,
  154. TimeoneType: timeone_type,
  155. TimeoneEnd: timeone_end,
  156. TimetwoStart: timetwo_start,
  157. TimetwoEnd: timetwo_end,
  158. TimetwoType: timetwo_type,
  159. WorkTime: work_time,
  160. Remarks: remarks,
  161. Minute: minute,
  162. }
  163. if user_org_id == 0 {
  164. err := service.CreateDotorSchedule(&schedules)
  165. if err != nil {
  166. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  167. return
  168. }
  169. } else {
  170. //查询是否班种名称已存在
  171. scheduledata, _ := service.GetClassNameIsExsit(class_name, user_org_id, id)
  172. if scheduledata.ID > 0 && scheduledata.ID != id {
  173. this.ServeFailJsonSend(enums.ErrorCodeDataException, "班种名称已存在")
  174. return
  175. }
  176. err := service.UpdateScheduleList(id, &schedules)
  177. if err != nil {
  178. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  179. return
  180. }
  181. }
  182. this.ServeSuccessJSON(map[string]interface{}{
  183. "schedules": schedules,
  184. })
  185. }
  186. func (this *DoctorScheduleApiController) DeleteSchedule() {
  187. adminUserInfo := this.GetAdminUserInfo()
  188. orgId := adminUserInfo.CurrentOrgId
  189. id, _ := this.GetInt64("id")
  190. //产寻该班种是否存在排班,如果存在不能删除
  191. _, errcode := service.GetStaffScheduleByScheduleType(id, orgId)
  192. if errcode == gorm.ErrRecordNotFound {
  193. err := service.DeleteScheduleById(id)
  194. if err != nil {
  195. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  196. return
  197. }
  198. returnData := make(map[string]interface{}, 0)
  199. returnData["msg"] = "ok"
  200. this.ServeSuccessJSON(returnData)
  201. return
  202. } else if errcode == nil {
  203. this.ServeFailJsonSend(enums.ErrorCodeDataException, "该班种已存在排班,不能删除")
  204. return
  205. }
  206. }
  207. func (this *DoctorScheduleApiController) GetDoctorList() {
  208. orgId := this.GetAdminUserInfo().CurrentOrgId
  209. appId := this.GetAdminUserInfo().CurrentAppId
  210. //admin_user_id := this.GetAdminUserInfo().AdminUser.Id
  211. list, err := service.GetDoctorList(orgId, appId)
  212. //获取所有的医生
  213. doctorList, err := service.GetAllDoctorList(orgId, appId)
  214. //获取所有的护士
  215. nurseList, err := service.GetAllNurseList(orgId, appId)
  216. if err != nil {
  217. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  218. return
  219. }
  220. this.ServeSuccessJSON(map[string]interface{}{
  221. "list": list,
  222. "doctorlist": doctorList,
  223. "nurselist": nurseList,
  224. })
  225. }
  226. func (this *DoctorScheduleApiController) GetScheduleList() {
  227. orgId := this.GetAdminUserInfo().CurrentOrgId
  228. _, errcode := service.GetDoctorScheduleByOrgId(orgId)
  229. if errcode == gorm.ErrRecordNotFound {
  230. scheduleList, err := service.GetScheduleList(0)
  231. if err != nil {
  232. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  233. return
  234. }
  235. this.ServeSuccessJSON(map[string]interface{}{
  236. "scheduleList": scheduleList,
  237. })
  238. } else {
  239. scheduleList, err := service.GetScheduleList(orgId)
  240. if err != nil {
  241. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  242. return
  243. }
  244. this.ServeSuccessJSON(map[string]interface{}{
  245. "scheduleList": scheduleList,
  246. })
  247. }
  248. }
  249. func (this *DoctorScheduleApiController) AddSchedule() {
  250. orgId := this.GetAdminUserInfo().CurrentOrgId
  251. doctor_id, _ := this.GetInt64("doctor_id")
  252. fmt.Println("doctor_id", doctor_id)
  253. doctor_type, _ := this.GetInt64("doctor_type")
  254. fmt.Println("doctor_type", doctor_type)
  255. start_time, _ := this.GetInt64("start_time")
  256. fmt.Println("start_time", start_time)
  257. end_time, _ := this.GetInt64("end_time")
  258. fmt.Println("end_time", end_time)
  259. schedule_type, _ := this.GetInt64("schedule_type")
  260. fmt.Println("schedule_type", schedule_type)
  261. schedule_week, _ := this.GetInt64("schedule_week")
  262. fmt.Println("schedule_week", schedule_week)
  263. schedule_date, _ := this.GetInt64("schedule_date")
  264. schedule := models.StaffSchedule{
  265. DoctorId: doctor_id,
  266. DoctorType: doctor_type,
  267. ScheduleType: schedule_type,
  268. ScheduleWeek: schedule_week,
  269. UserOrgId: orgId,
  270. StartTime: start_time,
  271. EndTime: end_time,
  272. Status: 1,
  273. Ctime: time.Now().Unix(),
  274. ScheduleDate: schedule_date,
  275. }
  276. _, errcode := service.GetScheduleListDetail(doctor_id, orgId, schedule_date)
  277. fmt.Println("errcode-----", errcode)
  278. if errcode == gorm.ErrRecordNotFound {
  279. err := service.AddSchedule(&schedule)
  280. if err != nil {
  281. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  282. return
  283. }
  284. this.ServeSuccessJSON(map[string]interface{}{
  285. "schedule": schedule,
  286. })
  287. } else if errcode == nil {
  288. schedules, _ := service.GetScheduleListDetail(doctor_id, orgId, schedule_date)
  289. err := service.UpdateStaffList(&schedule, schedules.ID)
  290. if err != nil {
  291. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  292. return
  293. }
  294. this.ServeSuccessJSON(map[string]interface{}{
  295. "schedule": schedule,
  296. })
  297. }
  298. }
  299. func (this *DoctorScheduleApiController) GetStaffScheduleList() {
  300. start_time, _ := this.GetInt64("start_time")
  301. end_time, _ := this.GetInt64("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. end_time, _ := this.GetInt64("end_time")
  493. adminUserInfo := this.GetAdminUserInfo()
  494. orgId := adminUserInfo.CurrentOrgId
  495. //统计班次
  496. scheudletotal, err := service.GetScheduleListTotal(orgId, start_time, end_time)
  497. //统计总工时
  498. list, err := service.GetTotalMinutes(orgId, start_time, end_time)
  499. //统计出勤天数
  500. workDay, err := service.GetTotalWorkDay(orgId, start_time, end_time)
  501. //统计缺勤天数
  502. noWorkDay, err := service.GetTotalNoWorkDay(orgId, start_time, end_time)
  503. if err != nil {
  504. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  505. return
  506. }
  507. this.ServeSuccessJSON(map[string]interface{}{
  508. "scheudletotal": scheudletotal,
  509. "list": list,
  510. "workDay": workDay,
  511. "noWorkDay": noWorkDay,
  512. })
  513. }
  514. func (this *DoctorScheduleApiController) ToSeachTotal() {
  515. start_time, _ := this.GetInt64("start_time")
  516. end_time, _ := this.GetInt64("end_time")
  517. adminUserInfo := this.GetAdminUserInfo()
  518. orgId := adminUserInfo.CurrentOrgId
  519. keyword := this.GetString("keyword")
  520. //统计表
  521. scheduletotal, err := service.GetSearchScheduleListTotal(orgId, start_time, end_time, keyword)
  522. list, err := service.GeSearchtTotalMinutes(orgId, start_time, end_time, keyword)
  523. workDay, err := service.GetSearchWorkDay(orgId, start_time, end_time, keyword)
  524. noWorkDay, err := service.GetSearchWorkNoDay(orgId, start_time, end_time, keyword)
  525. //统计图
  526. chartTotalMinute, err := service.GetChartTotalMinutesOne(orgId, start_time, end_time, keyword)
  527. chartWorkDayMinute, err := service.GetChartTotalMinutesTwo(orgId, start_time, end_time, keyword)
  528. if err != nil {
  529. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  530. return
  531. }
  532. this.ServeSuccessJSON(map[string]interface{}{
  533. "scheduletotal": scheduletotal,
  534. "list": list,
  535. "workDay": workDay,
  536. "noWorkDay": noWorkDay,
  537. "chartTotalMinute": chartTotalMinute,
  538. "chartWorkDayMinute": chartWorkDayMinute,
  539. })
  540. }
  541. func (this *DoctorScheduleApiController) ChangeOption() {
  542. start_time, _ := this.GetInt64("start_time")
  543. end_time, _ := this.GetInt64("end_time")
  544. adminUserInfo := this.GetAdminUserInfo()
  545. orgId := adminUserInfo.CurrentOrgId
  546. doctor_type, _ := this.GetInt64("doctor_type")
  547. //统计图
  548. scheduletotal, err := service.ChagneScheduleListTotal(orgId, start_time, end_time, doctor_type)
  549. list, err := service.ChangeScheduleMinute(orgId, start_time, end_time, doctor_type)
  550. workday, err := service.ChangeWorkDay(orgId, start_time, end_time, doctor_type)
  551. worknoday, err := service.ChangeNoWorkDay(orgId, start_time, end_time, doctor_type)
  552. //统计表
  553. chartotalminute, err := service.ChartTotalMinute(orgId, start_time, end_time, doctor_type)
  554. chartworkdayminute, err := service.ChartWorkDayMinute(orgId, start_time, end_time, doctor_type)
  555. if err != nil {
  556. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  557. return
  558. }
  559. this.ServeSuccessJSON(map[string]interface{}{
  560. "scheduletotal": scheduletotal,
  561. "list": list,
  562. "workday": workday,
  563. "worknoday": worknoday,
  564. "chartotalminute": chartotalminute,
  565. "chartworkdayminute": chartworkdayminute,
  566. })
  567. }
  568. func (this *DoctorScheduleApiController) GetChartlist() {
  569. start_time, _ := this.GetInt64("start_time")
  570. end_time, _ := this.GetInt64("end_time")
  571. adminUserInfo := this.GetAdminUserInfo()
  572. orgId := adminUserInfo.CurrentOrgId
  573. //统计总工时
  574. list, err := service.GetTotalMinutesOne(orgId, start_time, end_time)
  575. //统计出勤的总工时
  576. workDaylist, err := service.GetTotalMinutesTwo(orgId, start_time, end_time)
  577. if err != nil {
  578. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  579. return
  580. }
  581. this.ServeSuccessJSON(map[string]interface{}{
  582. "list": list,
  583. "workDaylist": workDaylist,
  584. })
  585. }
  586. func (this *DoctorScheduleApiController) DeleteStaffScheduleById() {
  587. id, _ := this.GetInt64("id")
  588. orgId := this.GetAdminUserInfo().CurrentOrgId
  589. service.DeleteStaffScheduleById(id, orgId)
  590. this.ServeSuccessJSON(map[string]interface{}{
  591. "msg": "ok",
  592. })
  593. }