doctor_schedule_api_controller.go 23KB

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