TaskList.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package TimeTask
  2. import (
  3. "ColdVerify_server/lib"
  4. "ColdVerify_server/lib/wx"
  5. "ColdVerify_server/logs"
  6. "ColdVerify_server/models/Account"
  7. "ColdVerify_server/models/InfoCollection"
  8. "ColdVerify_server/models/Task"
  9. "fmt"
  10. "github.com/robfig/cron/v3"
  11. "time"
  12. )
  13. func TaskList() {
  14. crontab := cron.New(cron.WithSeconds())
  15. ss := "0 10 * * *"
  16. _, err := crontab.AddFunc(ss, TaskList_return)
  17. if err != nil {
  18. fmt.Printf("err: %v\n", err)
  19. }
  20. crontab.Start()
  21. defer crontab.Stop()
  22. select {}
  23. }
  24. // 回款
  25. func TaskList_return() {
  26. logs.Println("------- 任务回款 定时任务 --------")
  27. List, _ := Task.Read_Task_List_All()
  28. for _,T := range List{
  29. logs.Println("任务ID:",T.Id)
  30. var InfoCollection_r InfoCollection.InfoCollection //信息采集
  31. if len(T.T_InfoCollection_id) == 0 {
  32. logs.Println("信息采集表获取 为空!!")
  33. continue;
  34. }
  35. var is bool
  36. InfoCollection_r, is = InfoCollection.Read_InfoCollection(T.T_InfoCollection_id)
  37. if !is {
  38. logs.Println("信息采集表获取错误 T_InfoCollection_id ",T.T_InfoCollection_id)
  39. continue;
  40. }
  41. if InfoCollection_r.T_State == 5 {
  42. logs.Println("已经回款")
  43. continue;
  44. }
  45. if len(T.T_reporting_end_time) == 0{
  46. logs.Println("正在进行中")
  47. continue;
  48. }
  49. T_collection_time_interval, _ := lib.MinutesDifference(T.T_reporting_end_time, time.Now().Format("2006-01-02 15:04:05") )
  50. T_collection_time_interval = T_collection_time_interval / 60 / 24
  51. logs.Println("用时 天:",T_collection_time_interval)
  52. if T_collection_time_interval <= 30 {
  53. logs.Println("未超时!!!",)
  54. continue;
  55. }
  56. _, company_r := Account.Read_User_ByT_uuid(T.T_uuid)
  57. //AdminMap := Account.AdminListToMap(Account.Read_Admin_List_ALL_1())
  58. //go System.Send_Weichat_News(AdminMap[T.T_scheme], fmt.Sprintf("【项目回款】项目回款已经超过%d天【%s-%s】", int(T_collection_time_interval) ,company_r.T_name, T.T_name), "")
  59. go wx.WxSend(T.T_scheme, fmt.Sprintf("【项目回款】项目回款已经超过%d天【%s-%s】", int(T_collection_time_interval) ,company_r.T_name, T.T_name))
  60. }
  61. }