public_meeting.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package roadshow
  2. import (
  3. "fmt"
  4. "hongze/hongze_task/models/roadshow"
  5. "hongze/hongze_task/utils"
  6. "strconv"
  7. "time"
  8. "context"
  9. )
  10. func SetPublicMeetingUnionCode(cont context.Context)(err error) {
  11. now:=time.Now().Format(utils.FormatDate)
  12. list, err := roadshow.GetPublicMeetingList(now)
  13. if err != nil {
  14. return
  15. }
  16. for _, v := range list {
  17. calendarResearchItem, err := roadshow.GetRsCalendarResearcherById(v.RsCalendarResearcherId)
  18. if err != nil {
  19. fmt.Println("GetRsCalendarById Err:" + err.Error())
  20. return
  21. }
  22. if calendarResearchItem == nil {
  23. continue
  24. }
  25. if calendarResearchItem.UnionCode != "" {
  26. continue
  27. }
  28. //生成当前公开会议联合编码
  29. unionCodeStr := strconv.Itoa(v.RsCalendarId) + "_" + strconv.Itoa(int(time.Now().Unix()))
  30. unionCode := utils.MD5(unionCodeStr)
  31. err = roadshow.ModifyCalendarUnionCode(unionCode, v.RsCalendarId)
  32. if err != nil {
  33. fmt.Println("ModifyCalendarUnionCode Err:" + err.Error())
  34. return
  35. }
  36. startDateTime := v.StartDate + " " + v.StartTime
  37. endDateTime := v.EndDate + " " + v.EndTime
  38. coincideList, err := roadshow.GetCoincideMeeting(startDateTime, endDateTime)
  39. if err != nil {
  40. return
  41. }
  42. for _, cv := range coincideList {
  43. err = roadshow.ModifyCalendarUnionCode(unionCode, cv.RsCalendarId)
  44. if err != nil {
  45. fmt.Println("ModifyCalendarUnionCode Err:" + err.Error())
  46. return
  47. }
  48. }
  49. }
  50. return
  51. }