report_mapping.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package cygx
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hz_crm_api/models/cygx"
  6. "hongze/hz_crm_api/services/alarm_msg"
  7. "hongze/hz_crm_api/utils"
  8. )
  9. // 报告匹配类型映射
  10. func GetCygxReportMappingCygxListMap() (mapResp map[int]string) {
  11. var err error
  12. defer func() {
  13. if err != nil {
  14. fmt.Println(err)
  15. go alarm_msg.SendAlarmMsg("报告匹配类型映射,信息失败,Err:"+err.Error(), 3)
  16. }
  17. }()
  18. var condition string
  19. var pars []interface{}
  20. list, err := cygx.GetCygxReportMappingCygxList(condition, pars, 0, 0)
  21. if err != nil {
  22. return
  23. }
  24. mapResp = make(map[int]string, 0)
  25. for _, v := range list {
  26. mapResp[v.Id] = v.MatchTypeName
  27. }
  28. return
  29. }
  30. // 根据文章ID获取文章行业分类
  31. func GetCygxArticlePerssionNameListMap(articleIdArr []int) (mapResp map[int]string) {
  32. lenArr := len(articleIdArr)
  33. if lenArr == 0 {
  34. return
  35. }
  36. var err error
  37. defer func() {
  38. if err != nil {
  39. fmt.Println(err)
  40. go alarm_msg.SendAlarmMsg("根据文章ID获取文章行业分类,信息失败,GetCygxArticlePerssionNameListMap Err:"+err.Error(), 3)
  41. }
  42. }()
  43. var condition string
  44. var pars []interface{}
  45. //获取分类名称
  46. perssionNameList, e := cygx.GetCygxReportMappingList(condition, pars)
  47. if e != nil {
  48. err = errors.New("GetCygxReportMappingCelueList, Err: " + e.Error())
  49. return
  50. }
  51. mapName := make(map[int]string)
  52. for _, v := range perssionNameList {
  53. mapName[v.CategoryId] = v.ChartPermissionName
  54. }
  55. pars = make([]interface{}, 0)
  56. condition = ` AND article_id IN (` + utils.GetOrmInReplace(lenArr) + `)`
  57. pars = append(pars, articleIdArr)
  58. listArticle, e := cygx.GetArticlList(condition, pars, 0, 999)
  59. if e != nil && e.Error() != utils.ErrNoRow() {
  60. err = errors.New("GetArticlList, Err: " + e.Error())
  61. return
  62. }
  63. mapResp = make(map[int]string, 0)
  64. for _, v := range listArticle {
  65. if v.CategoryId == 0 {
  66. mapResp[v.ArticleId] = utils.CHART_PERMISSION_NAME_MF_YANXUAN
  67. } else {
  68. mapResp[v.ArticleId] = mapName[v.CategoryId]
  69. }
  70. }
  71. return
  72. }