doctor_schedule_api_controller.go 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. package controllers
  2. import (
  3. "fmt"
  4. "time"
  5. "XT_New/enums"
  6. "XT_New/models"
  7. "XT_New/service"
  8. "github.com/astaxie/beego"
  9. "github.com/jinzhu/gorm"
  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. doctor_type, _ := this.GetInt64("doctor_type")
  253. start_time, _ := this.GetInt64("start_time")
  254. end_time, _ := this.GetInt64("end_time")
  255. schedule_type, _ := this.GetInt64("schedule_type")
  256. schedule_week, _ := this.GetInt64("schedule_week")
  257. schedule_date, _ := this.GetInt64("schedule_date")
  258. schedule := models.StaffSchedule{
  259. DoctorId: doctor_id,
  260. DoctorType: doctor_type,
  261. ScheduleType: schedule_type,
  262. ScheduleWeek: schedule_week,
  263. UserOrgId: orgId,
  264. StartTime: start_time,
  265. EndTime: end_time,
  266. Status: 1,
  267. Ctime: time.Now().Unix(),
  268. ScheduleDate: schedule_date,
  269. }
  270. _, errcode := service.GetScheduleListDetail(doctor_id, orgId, schedule_date)
  271. fmt.Println("errcode-----", errcode)
  272. if errcode == gorm.ErrRecordNotFound {
  273. err := service.AddSchedule(&schedule)
  274. if err != nil {
  275. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  276. return
  277. }
  278. this.ServeSuccessJSON(map[string]interface{}{
  279. "schedule": schedule,
  280. })
  281. } else if errcode == nil {
  282. schedules, _ := service.GetScheduleListDetail(doctor_id, orgId, schedule_date)
  283. err := service.UpdateStaffList(&schedule, schedules.ID)
  284. if err != nil {
  285. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  286. return
  287. }
  288. this.ServeSuccessJSON(map[string]interface{}{
  289. "schedule": schedule,
  290. })
  291. }
  292. }
  293. func (this *DoctorScheduleApiController) GetStaffScheduleList() {
  294. start_time, _ := this.GetInt64("start_time")
  295. end_time, _ := this.GetInt64("end_time")
  296. orgId := this.GetAdminUserInfo().CurrentOrgId
  297. staffList, err := service.GetStaffScheduleList(orgId, start_time, end_time)
  298. if err != nil {
  299. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  300. return
  301. }
  302. this.ServeSuccessJSON(map[string]interface{}{
  303. "staffList": staffList,
  304. })
  305. }
  306. func (this *DoctorScheduleApiController) GetNextWeekList() {
  307. start_time, _ := this.GetInt64("start_time")
  308. fmt.Println("start_time", start_time)
  309. end_time, _ := this.GetInt64("end_time")
  310. fmt.Println("end_time", end_time)
  311. orgId := this.GetAdminUserInfo().CurrentOrgId
  312. staffList, err := service.GetStaffScheduleList(orgId, start_time, end_time)
  313. if err != nil {
  314. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  315. return
  316. }
  317. this.ServeSuccessJSON(map[string]interface{}{
  318. "staffList": staffList,
  319. })
  320. }
  321. func (this *DoctorScheduleApiController) GetScheduleByDoctorId() {
  322. doctor_id, _ := this.GetInt64("doctor_id")
  323. start_time, _ := this.GetInt64("start_time")
  324. end_time, _ := this.GetInt64("end_time")
  325. orgId := this.GetAdminUserInfo().CurrentOrgId
  326. staffList, err := service.GetScheduleByDoctorId(doctor_id, start_time, end_time, orgId)
  327. if err != nil {
  328. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  329. return
  330. }
  331. this.ServeSuccessJSON(map[string]interface{}{
  332. "staffList": staffList,
  333. })
  334. }
  335. func (this *DoctorScheduleApiController) ToSearchScheduleList() {
  336. //doctor_id, _ := this.GetInt64("doctor_id")
  337. user_name := this.GetString("user_name")
  338. start_time, _ := this.GetInt64("start_time")
  339. end_time, _ := this.GetInt64("end_time")
  340. orgId := this.GetAdminUserInfo().CurrentOrgId
  341. staffList, err := service.ToSearchSeacheduleList(user_name, start_time, end_time, orgId)
  342. if err != nil {
  343. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  344. return
  345. }
  346. this.ServeSuccessJSON(map[string]interface{}{
  347. "staffList": staffList,
  348. })
  349. }
  350. func (this *DoctorScheduleApiController) DeleteStaffSchedule() {
  351. adminUserInfo := this.GetAdminUserInfo()
  352. orgId := adminUserInfo.CurrentOrgId
  353. start_time, _ := this.GetInt64("start_time")
  354. fmt.Println("start_time", start_time)
  355. end_time, _ := this.GetInt64("end_time")
  356. err := service.DeleteStaffSchedule(orgId, start_time, end_time)
  357. if err != nil {
  358. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  359. return
  360. }
  361. returnData := make(map[string]interface{}, 0)
  362. returnData["msg"] = "ok"
  363. this.ServeSuccessJSON(returnData)
  364. return
  365. }
  366. func (this *DoctorScheduleApiController) CopyStaffSchedule() {
  367. adminUserInfo := this.GetAdminUserInfo()
  368. orgId := adminUserInfo.CurrentOrgId
  369. start_time, _ := this.GetInt64("start_time")
  370. fmt.Println("start_time", start_time)
  371. end_time, _ := this.GetInt64("end_time")
  372. fmt.Println("end_time", end_time)
  373. copy_startime, _ := this.GetInt64("copy_startime")
  374. fmt.Println("copy_startime", copy_startime)
  375. copy_endtime, _ := this.GetInt64("copy_endtime")
  376. schedule, err := service.GetStaffScheduleListTwo(orgId, start_time, end_time)
  377. //查询选中日期的排班是否存在
  378. _, errcode := service.GetNextWeekSchedule(orgId, copy_startime, copy_endtime)
  379. if errcode == gorm.ErrRecordNotFound {
  380. for _, item := range schedule {
  381. //fmt.Println(item.StartTime+604800)
  382. //礼拜1
  383. if item.ScheduleWeek == 1 {
  384. item.ScheduleDate = copy_startime
  385. }
  386. if item.ScheduleWeek == 2 {
  387. item.ScheduleDate = copy_startime + 86400
  388. }
  389. if item.ScheduleWeek == 3 {
  390. item.ScheduleDate = copy_startime + 172800
  391. }
  392. if item.ScheduleWeek == 4 {
  393. item.ScheduleDate = copy_startime + 259200
  394. }
  395. if item.ScheduleWeek == 5 {
  396. item.ScheduleDate = copy_startime + 345600
  397. }
  398. if item.ScheduleWeek == 6 {
  399. item.ScheduleDate = copy_startime + 432000
  400. }
  401. //礼拜天
  402. if item.ScheduleWeek == 0 {
  403. item.ScheduleDate = copy_endtime
  404. }
  405. staffSchedule := models.StaffSchedule{
  406. DoctorId: item.DoctorId,
  407. DoctorType: item.DoctorType,
  408. ScheduleType: item.ScheduleType,
  409. ScheduleWeek: item.ScheduleWeek,
  410. UserOrgId: item.UserOrgId,
  411. StartTime: copy_startime,
  412. EndTime: copy_endtime,
  413. Status: 1,
  414. Ctime: time.Now().Unix(),
  415. ScheduleDate: item.ScheduleDate,
  416. }
  417. service.AddSchedule(&staffSchedule)
  418. }
  419. if err != nil {
  420. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  421. return
  422. }
  423. returnData := make(map[string]interface{}, 0)
  424. returnData["msg"] = "ok"
  425. this.ServeSuccessJSON(returnData)
  426. return
  427. } else if errcode == nil {
  428. this.ServeFailJsonSend(enums.ErrorCodeDataException, "排班数据已存在")
  429. fmt.Print("下周排班已存在")
  430. return
  431. }
  432. }
  433. func (this *DoctorScheduleApiController) UpdateContinusSchedule() {
  434. adminUserInfo := this.GetAdminUserInfo()
  435. orgId := adminUserInfo.CurrentOrgId
  436. is_status, _ := this.GetInt64("is_status")
  437. fmt.Println("is_status", is_status)
  438. schedule := models.ContinueSchedule{
  439. IsStatus: is_status,
  440. }
  441. err := service.UpdateContinusSchedule(&schedule, orgId)
  442. if err != nil {
  443. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  444. return
  445. }
  446. this.ServeSuccessJSON(map[string]interface{}{
  447. "schedule": schedule,
  448. })
  449. }
  450. func (this *DoctorScheduleApiController) SaveNureSort() {
  451. id, _ := this.GetInt64("id")
  452. fmt.Println("id", id)
  453. sort, _ := this.GetInt64("sort")
  454. fmt.Println("sort", sort)
  455. role := models.App_Role{
  456. Sort: sort,
  457. }
  458. err := service.SaveNurseSort(&role, id)
  459. if err != nil {
  460. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  461. return
  462. }
  463. this.ServeSuccessJSON(map[string]interface{}{
  464. "role": role,
  465. })
  466. }
  467. func (this *DoctorScheduleApiController) SaveIsSchedule() {
  468. id, _ := this.GetInt64("id")
  469. fmt.Println("id", id)
  470. is_sort, _ := this.GetInt64("is_sort")
  471. fmt.Println("is_sort", is_sort)
  472. role := models.App_Role{
  473. IsSort: is_sort,
  474. }
  475. err := service.SaveIsSchedule(id, &role)
  476. if err != nil {
  477. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  478. return
  479. }
  480. this.ServeSuccessJSON(map[string]interface{}{
  481. "role": role,
  482. })
  483. }
  484. func (this *DoctorScheduleApiController) GetScheduleListTotal() {
  485. start_time, _ := this.GetInt64("start_time")
  486. end_time, _ := this.GetInt64("end_time")
  487. adminUserInfo := this.GetAdminUserInfo()
  488. orgId := adminUserInfo.CurrentOrgId
  489. //统计班次
  490. scheudletotal, err := service.GetScheduleListTotal(orgId, start_time, end_time)
  491. //统计总工时
  492. list, err := service.GetTotalMinutes(orgId, start_time, end_time)
  493. //统计出勤天数
  494. workDay, err := service.GetTotalWorkDay(orgId, start_time, end_time)
  495. //统计缺勤天数
  496. noWorkDay, err := service.GetTotalNoWorkDay(orgId, start_time, end_time)
  497. if err != nil {
  498. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  499. return
  500. }
  501. this.ServeSuccessJSON(map[string]interface{}{
  502. "scheudletotal": scheudletotal,
  503. "list": list,
  504. "workDay": workDay,
  505. "noWorkDay": noWorkDay,
  506. })
  507. }
  508. func (this *DoctorScheduleApiController) ToSeachTotal() {
  509. start_time, _ := this.GetInt64("start_time")
  510. end_time, _ := this.GetInt64("end_time")
  511. adminUserInfo := this.GetAdminUserInfo()
  512. orgId := adminUserInfo.CurrentOrgId
  513. keyword := this.GetString("keyword")
  514. //统计表
  515. scheduletotal, err := service.GetSearchScheduleListTotal(orgId, start_time, end_time, keyword)
  516. list, err := service.GeSearchtTotalMinutes(orgId, start_time, end_time, keyword)
  517. workDay, err := service.GetSearchWorkDay(orgId, start_time, end_time, keyword)
  518. noWorkDay, err := service.GetSearchWorkNoDay(orgId, start_time, end_time, keyword)
  519. //统计图
  520. chartTotalMinute, err := service.GetChartTotalMinutesOne(orgId, start_time, end_time, keyword)
  521. chartWorkDayMinute, err := service.GetChartTotalMinutesTwo(orgId, start_time, end_time, keyword)
  522. if err != nil {
  523. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  524. return
  525. }
  526. this.ServeSuccessJSON(map[string]interface{}{
  527. "scheduletotal": scheduletotal,
  528. "list": list,
  529. "workDay": workDay,
  530. "noWorkDay": noWorkDay,
  531. "chartTotalMinute": chartTotalMinute,
  532. "chartWorkDayMinute": chartWorkDayMinute,
  533. })
  534. }
  535. func (this *DoctorScheduleApiController) ChangeOption() {
  536. start_time, _ := this.GetInt64("start_time")
  537. end_time, _ := this.GetInt64("end_time")
  538. adminUserInfo := this.GetAdminUserInfo()
  539. orgId := adminUserInfo.CurrentOrgId
  540. doctor_type, _ := this.GetInt64("doctor_type")
  541. //统计图
  542. scheduletotal, err := service.ChagneScheduleListTotal(orgId, start_time, end_time, doctor_type)
  543. list, err := service.ChangeScheduleMinute(orgId, start_time, end_time, doctor_type)
  544. workday, err := service.ChangeWorkDay(orgId, start_time, end_time, doctor_type)
  545. worknoday, err := service.ChangeNoWorkDay(orgId, start_time, end_time, doctor_type)
  546. //统计表
  547. chartotalminute, err := service.ChartTotalMinute(orgId, start_time, end_time, doctor_type)
  548. chartworkdayminute, err := service.ChartWorkDayMinute(orgId, start_time, end_time, doctor_type)
  549. if err != nil {
  550. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  551. return
  552. }
  553. this.ServeSuccessJSON(map[string]interface{}{
  554. "scheduletotal": scheduletotal,
  555. "list": list,
  556. "workday": workday,
  557. "worknoday": worknoday,
  558. "chartotalminute": chartotalminute,
  559. "chartworkdayminute": chartworkdayminute,
  560. })
  561. }
  562. func (this *DoctorScheduleApiController) GetChartlist() {
  563. start_time, _ := this.GetInt64("start_time")
  564. end_time, _ := this.GetInt64("end_time")
  565. adminUserInfo := this.GetAdminUserInfo()
  566. orgId := adminUserInfo.CurrentOrgId
  567. //统计总工时
  568. list, err := service.GetTotalMinutesOne(orgId, start_time, end_time)
  569. //统计出勤的总工时
  570. workDaylist, err := service.GetTotalMinutesTwo(orgId, start_time, end_time)
  571. if err != nil {
  572. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  573. return
  574. }
  575. this.ServeSuccessJSON(map[string]interface{}{
  576. "list": list,
  577. "workDaylist": workDaylist,
  578. })
  579. }
  580. func (this *DoctorScheduleApiController) DeleteStaffScheduleById() {
  581. id, _ := this.GetInt64("id")
  582. orgId := this.GetAdminUserInfo().CurrentOrgId
  583. service.DeleteStaffScheduleById(id, orgId)
  584. this.ServeSuccessJSON(map[string]interface{}{
  585. "msg": "ok",
  586. })
  587. }