doctor_schedule_api_controller.go 21KB

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