historytask.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package main
  2. import (
  3. "log"
  4. qu "qfw/util"
  5. "strings"
  6. mgoutil "util/mgodb"
  7. )
  8. func HistoryTask(name string) {
  9. log.Println("开始历史任务...")
  10. //加载一个客户
  11. customer, _ := MgoTag.Find("euser", map[string]interface{}{"s_name": name, "i_push": 1, "b_delete": false}, nil, nil)
  12. if len(customer) == 1 {
  13. c := customer[0]
  14. customerId := mgoutil.BsonTOStringId(c["_id"])
  15. customer := qu.ObjToString(c["s_name"]) //客户名称
  16. appId := qu.ObjToString(c["s_appid"]) //appid
  17. extends := qu.ObjToString(c["s_extends"]) //扩展信息
  18. pushModel := qu.IntAll(c["i_pushmodel"]) //推送模式
  19. cus := &Customer{}
  20. cus.SaveDataMap = map[string]map[string]interface{}{}
  21. cus.SaveDataArr = []map[string]interface{}{}
  22. cus.ID = customerId
  23. cus.Name = customer
  24. cus.PushModel = pushModel
  25. cus.AppId = appId
  26. for _, v := range strings.Split(extends, ",") {
  27. if v == "hospitalgrade" {
  28. cus.IsSearchHosp = true
  29. } else if v == "enterpise" {
  30. cus.IsSearchEnps = true
  31. }
  32. }
  33. cus.GetTagRules() //获取客户打标签规则
  34. cus.GetDepartments("history") //获取客户信息
  35. //PrintLog(cus) //打印查看初始化的信息
  36. qu.Debug("customer:", cus.ID, cus.Name, cus.PushModel, cus.AppId, cus.IsTagRule, cus.IsSearchHosp, cus.IsSearchEnps, len(cus.TagRules), len(cus.Departments))
  37. cus.GetData() //获取数据
  38. cus.RemoveRepeatData() //数据去重
  39. cus.AssembelAndSaveData() //组装、保存数据
  40. } else {
  41. log.Println("初始化客户信息失败")
  42. }
  43. }