doctor_schedule_api_controller.go 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776
  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. end_time, _ := this.GetInt64("end_time")
  373. copy_startime, _ := this.GetInt64("copy_startime")
  374. copy_endtime, _ := this.GetInt64("copy_endtime")
  375. remark := this.GetString("remark")
  376. if len(remark) > 0 {
  377. scheduleRemark, _ := service.GetStaffScheduleRemark(orgId, copy_startime, copy_endtime)
  378. remark := models.XtStaffScheduleRemark{
  379. ID: scheduleRemark.ID,
  380. StartTime: copy_startime,
  381. EndTime: copy_endtime,
  382. Remark: remark,
  383. UserOrgId: orgId,
  384. Status: 1,
  385. Ctime: 0,
  386. Mtime: 0,
  387. }
  388. if scheduleRemark.ID == 0 {
  389. service.CreateStaffScheduleRemark(remark)
  390. }
  391. if scheduleRemark.ID > 0 {
  392. service.SaveStaffScheduleRemarkOne(remark)
  393. }
  394. }
  395. schedule, err := service.GetStaffScheduleListTwo(orgId, start_time, end_time)
  396. //查询选中日期的排班是否存在
  397. _, errcode := service.GetNextWeekSchedule(orgId, copy_startime, copy_endtime)
  398. if errcode == gorm.ErrRecordNotFound {
  399. for _, item := range schedule {
  400. //fmt.Println(item.StartTime+604800)
  401. //礼拜1
  402. if item.ScheduleWeek == 1 {
  403. item.ScheduleDate = copy_startime
  404. }
  405. if item.ScheduleWeek == 2 {
  406. item.ScheduleDate = copy_startime + 86400
  407. }
  408. if item.ScheduleWeek == 3 {
  409. item.ScheduleDate = copy_startime + 172800
  410. }
  411. if item.ScheduleWeek == 4 {
  412. item.ScheduleDate = copy_startime + 259200
  413. }
  414. if item.ScheduleWeek == 5 {
  415. item.ScheduleDate = copy_startime + 345600
  416. }
  417. if item.ScheduleWeek == 6 {
  418. item.ScheduleDate = copy_startime + 432000
  419. }
  420. //礼拜天
  421. if item.ScheduleWeek == 0 {
  422. item.ScheduleDate = copy_endtime
  423. }
  424. staffSchedule := models.StaffSchedule{
  425. DoctorId: item.DoctorId,
  426. DoctorType: item.DoctorType,
  427. ScheduleType: item.ScheduleType,
  428. ScheduleWeek: item.ScheduleWeek,
  429. UserOrgId: item.UserOrgId,
  430. StartTime: copy_startime,
  431. EndTime: copy_endtime,
  432. Status: 1,
  433. Ctime: time.Now().Unix(),
  434. ScheduleDate: item.ScheduleDate,
  435. Remark: item.Remark,
  436. }
  437. service.AddSchedule(&staffSchedule)
  438. }
  439. if err != nil {
  440. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  441. return
  442. }
  443. returnData := make(map[string]interface{}, 0)
  444. returnData["msg"] = "ok"
  445. this.ServeSuccessJSON(returnData)
  446. return
  447. } else if errcode == nil {
  448. this.ServeFailJsonSend(enums.ErrorCodeDataException, "排班数据已存在")
  449. fmt.Print("下周排班已存在")
  450. return
  451. }
  452. }
  453. func (this *DoctorScheduleApiController) UpdateContinusSchedule() {
  454. adminUserInfo := this.GetAdminUserInfo()
  455. orgId := adminUserInfo.CurrentOrgId
  456. is_status, _ := this.GetInt64("is_status")
  457. fmt.Println("is_status", is_status)
  458. schedule := models.ContinueSchedule{
  459. IsStatus: is_status,
  460. }
  461. err := service.UpdateContinusSchedule(&schedule, orgId)
  462. if err != nil {
  463. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  464. return
  465. }
  466. this.ServeSuccessJSON(map[string]interface{}{
  467. "schedule": schedule,
  468. })
  469. }
  470. func (this *DoctorScheduleApiController) SaveNureSort() {
  471. id, _ := this.GetInt64("id")
  472. fmt.Println("id", id)
  473. sort, _ := this.GetInt64("sort")
  474. fmt.Println("sort", sort)
  475. role := models.App_Role{
  476. Sort: sort,
  477. }
  478. err := service.SaveNurseSort(&role, id)
  479. if err != nil {
  480. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  481. return
  482. }
  483. this.ServeSuccessJSON(map[string]interface{}{
  484. "role": role,
  485. })
  486. }
  487. func (this *DoctorScheduleApiController) SaveIsSchedule() {
  488. id, _ := this.GetInt64("id")
  489. fmt.Println("id", id)
  490. is_sort, _ := this.GetInt64("is_sort")
  491. fmt.Println("is_sort", is_sort)
  492. role := models.App_Role{
  493. IsSort: is_sort,
  494. }
  495. err := service.SaveIsSchedule(id, &role)
  496. if err != nil {
  497. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  498. return
  499. }
  500. this.ServeSuccessJSON(map[string]interface{}{
  501. "role": role,
  502. })
  503. }
  504. func (this *DoctorScheduleApiController) GetScheduleListTotal() {
  505. start_time, _ := this.GetInt64("start_time")
  506. end_time, _ := this.GetInt64("end_time")
  507. adminUserInfo := this.GetAdminUserInfo()
  508. orgId := adminUserInfo.CurrentOrgId
  509. //统计班次
  510. scheudletotal, err := service.GetScheduleListTotal(orgId, start_time, end_time)
  511. //统计总工时
  512. list, err := service.GetTotalMinutes(orgId, start_time, end_time)
  513. //统计出勤天数
  514. workDay, err := service.GetTotalWorkDay(orgId, start_time, end_time)
  515. //统计缺勤天数
  516. noWorkDay, err := service.GetTotalNoWorkDay(orgId, start_time, end_time)
  517. if err != nil {
  518. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  519. return
  520. }
  521. this.ServeSuccessJSON(map[string]interface{}{
  522. "scheudletotal": scheudletotal,
  523. "list": list,
  524. "workDay": workDay,
  525. "noWorkDay": noWorkDay,
  526. })
  527. }
  528. func (this *DoctorScheduleApiController) ToSeachTotal() {
  529. start_time, _ := this.GetInt64("start_time")
  530. end_time, _ := this.GetInt64("end_time")
  531. adminUserInfo := this.GetAdminUserInfo()
  532. orgId := adminUserInfo.CurrentOrgId
  533. keyword := this.GetString("keyword")
  534. //统计表
  535. scheduletotal, err := service.GetSearchScheduleListTotal(orgId, start_time, end_time, keyword)
  536. list, err := service.GeSearchtTotalMinutes(orgId, start_time, end_time, keyword)
  537. workDay, err := service.GetSearchWorkDay(orgId, start_time, end_time, keyword)
  538. noWorkDay, err := service.GetSearchWorkNoDay(orgId, start_time, end_time, keyword)
  539. //统计图
  540. chartTotalMinute, err := service.GetChartTotalMinutesOne(orgId, start_time, end_time, keyword)
  541. chartWorkDayMinute, err := service.GetChartTotalMinutesTwo(orgId, start_time, end_time, keyword)
  542. if err != nil {
  543. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  544. return
  545. }
  546. this.ServeSuccessJSON(map[string]interface{}{
  547. "scheduletotal": scheduletotal,
  548. "list": list,
  549. "workDay": workDay,
  550. "noWorkDay": noWorkDay,
  551. "chartTotalMinute": chartTotalMinute,
  552. "chartWorkDayMinute": chartWorkDayMinute,
  553. })
  554. }
  555. func (this *DoctorScheduleApiController) ChangeOption() {
  556. start_time, _ := this.GetInt64("start_time")
  557. end_time, _ := this.GetInt64("end_time")
  558. adminUserInfo := this.GetAdminUserInfo()
  559. orgId := adminUserInfo.CurrentOrgId
  560. doctor_type, _ := this.GetInt64("doctor_type")
  561. //统计图
  562. scheduletotal, err := service.ChagneScheduleListTotal(orgId, start_time, end_time, doctor_type)
  563. list, err := service.ChangeScheduleMinute(orgId, start_time, end_time, doctor_type)
  564. workday, err := service.ChangeWorkDay(orgId, start_time, end_time, doctor_type)
  565. worknoday, err := service.ChangeNoWorkDay(orgId, start_time, end_time, doctor_type)
  566. //统计表
  567. chartotalminute, err := service.ChartTotalMinute(orgId, start_time, end_time, doctor_type)
  568. chartworkdayminute, err := service.ChartWorkDayMinute(orgId, start_time, end_time, doctor_type)
  569. if err != nil {
  570. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  571. return
  572. }
  573. this.ServeSuccessJSON(map[string]interface{}{
  574. "scheduletotal": scheduletotal,
  575. "list": list,
  576. "workday": workday,
  577. "worknoday": worknoday,
  578. "chartotalminute": chartotalminute,
  579. "chartworkdayminute": chartworkdayminute,
  580. })
  581. }
  582. func (this *DoctorScheduleApiController) GetChartlist() {
  583. start_time, _ := this.GetInt64("start_time")
  584. end_time, _ := this.GetInt64("end_time")
  585. adminUserInfo := this.GetAdminUserInfo()
  586. orgId := adminUserInfo.CurrentOrgId
  587. //统计总工时
  588. list, err := service.GetTotalMinutesOne(orgId, start_time, end_time)
  589. //统计出勤的总工时
  590. workDaylist, err := service.GetTotalMinutesTwo(orgId, start_time, end_time)
  591. if err != nil {
  592. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  593. return
  594. }
  595. this.ServeSuccessJSON(map[string]interface{}{
  596. "list": list,
  597. "workDaylist": workDaylist,
  598. })
  599. }
  600. func (this *DoctorScheduleApiController) DeleteStaffScheduleById() {
  601. id, _ := this.GetInt64("id")
  602. orgId := this.GetAdminUserInfo().CurrentOrgId
  603. service.DeleteStaffScheduleById(id, orgId)
  604. this.ServeSuccessJSON(map[string]interface{}{
  605. "msg": "ok",
  606. })
  607. }
  608. func (this *DoctorScheduleApiController) SaveStaffScheduleRemark() {
  609. orgId := this.GetAdminUserInfo().CurrentOrgId
  610. admin_user_id, _ := this.GetInt64("admin_user_id")
  611. start_time, _ := this.GetInt64("start_time")
  612. end_time, _ := this.GetInt64("end_time")
  613. content := this.GetString("content")
  614. schedule := models.StaffSchedule{
  615. DoctorId: admin_user_id,
  616. UserOrgId: orgId,
  617. StartTime: start_time,
  618. EndTime: end_time,
  619. Remark: content,
  620. }
  621. service.UpdateSgjAdminUser(orgId, admin_user_id, content)
  622. service.SaveStaffScheduleRemark(schedule)
  623. this.ServeSuccessJSON(map[string]interface{}{
  624. "msg": "ok",
  625. })
  626. }
  627. func (this *DoctorScheduleApiController) ChangeStaffRemark() {
  628. org_id := this.GetAdminUserInfo().CurrentOrgId
  629. content := this.GetString("content")
  630. start_time, _ := this.GetInt64("start_time")
  631. end_time, _ := this.GetInt64("end_time")
  632. scheduleRemark, _ := service.GetStaffScheduleRemark(org_id, start_time, end_time)
  633. remark := models.XtStaffScheduleRemark{
  634. ID: scheduleRemark.ID,
  635. StartTime: start_time,
  636. EndTime: end_time,
  637. Remark: content,
  638. UserOrgId: org_id,
  639. Status: 1,
  640. Ctime: 0,
  641. Mtime: 0,
  642. }
  643. if scheduleRemark.ID == 0 {
  644. service.CreateStaffScheduleRemark(remark)
  645. }
  646. if scheduleRemark.ID > 0 {
  647. service.SaveStaffScheduleRemarkOne(remark)
  648. }
  649. this.ServeSuccessJSON(map[string]interface{}{
  650. "msg": "ok",
  651. })
  652. }
  653. func (this *DoctorScheduleApiController) GetStaffScheduleRemarkList() {
  654. org_id := this.GetAdminUserInfo().CurrentOrgId
  655. start_time, _ := this.GetInt64("start_time")
  656. end_time, _ := this.GetInt64("end_time")
  657. scheduleRemark, _ := service.GetStaffScheduleRemark(org_id, start_time, end_time)
  658. this.ServeSuccessJSON(map[string]interface{}{
  659. "scheduleRemark": scheduleRemark,
  660. })
  661. }