business_calendar.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package business_trip
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. type BusinessTripCalendarAdmin struct {
  6. AdminId int `description:"研究员id"`
  7. RealName string `description:"研究员名称"`
  8. BusinessTripList []*BusinessTripCalendar
  9. }
  10. type BusinessTripCalendar struct {
  11. BusinessApplyId int `description:"出差申请id"`
  12. Status string `description:"状态:'待审批','已审批','已驳回','已撤回','已过期'"`
  13. WeekDate string `description:"开始日期"`
  14. City string `description:"城市"`
  15. Week string `description:"周"`
  16. WeekType string `description:"当前周:current,下一周:next"`
  17. }
  18. // GetResearcherV2 获取研究员列表(冻结的也要)
  19. func GetBusinessTripCalendar(departmentId string) (list []*BusinessTripCalendarAdmin, err error) {
  20. o := orm.NewOrm()
  21. sql := ` SELECT a.admin_id,a.real_name
  22. FROM admin AS a
  23. INNER JOIN sys_group AS b ON a.group_id=b.group_id
  24. WHERE a.enabled=1
  25. AND b.department_id IN(?)
  26. ORDER BY a.admin_id ASC `
  27. _, err = o.Raw(sql, departmentId).QueryRows(&list)
  28. return
  29. }
  30. type BusinessTripCalendarGroup struct {
  31. GroupId int `description:"分组id"`
  32. GroupName string `description:"分组名称"`
  33. DepartmentId string `json:"-" description:"部门id"`
  34. AdminList []*BusinessTripCalendarAdmin
  35. }
  36. type BusinessTripCalendarResp struct {
  37. GroupList []*BusinessTripCalendarGroup
  38. }
  39. func GetBusinessTripList(adminId, startDate, endDate string) (list []*BusinessApplyView, err error) {
  40. o := orm.NewOrm()
  41. sql := ` SELECT *
  42. FROM business_apply AS a
  43. WHERE a.status IN('待审批','已审批')
  44. AND ((a.arrive_date>=? AND a.arrive_date<=?) OR (a.return_date>=? AND a.return_date<=?)) `
  45. if adminId != "" {
  46. sql += ` AND a.apply_admin_id IN (` + adminId + `)`
  47. sql += ` ORDER BY a.apply_admin_id ASC,a.arrive_date ASC `
  48. } else {
  49. sql += ` ORDER BY a.apply_admin_id ASC,a.arrive_date ASC `
  50. }
  51. _, err = o.Raw(sql, startDate, endDate, startDate, endDate).QueryRows(&list)
  52. return
  53. }