cygx_report_mapping.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. //"time"
  5. )
  6. type CygxReportMapping struct {
  7. SubCategoryName string `description:"主题"`
  8. }
  9. type CygxReportMappingListRep struct {
  10. List []*CygxReportMapping
  11. }
  12. // 主题列表
  13. func CygxReportMappingist(chartPermissionId int) (items []*CygxReportMapping, err error) {
  14. o := orm.NewOrmUsingDB("hz_cygx")
  15. sql := `SELECT sub_category_name FROM cygx_report_mapping WHERE chart_permission_id = ? GROUP BY sub_category_name ORDER BY sort DESC , id ASC `
  16. _, err = o.Raw(sql, chartPermissionId).QueryRows(&items)
  17. return
  18. }
  19. type CygxReportMappingMatchType struct {
  20. MatchTypeName string `description:"匹配类型"`
  21. }
  22. type CygxReportMappingMatchTypeRep struct {
  23. List []*CygxReportMappingMatchType
  24. }
  25. // 主题列表
  26. func CygxReportMappingMatchTypeList() (items []*CygxReportMappingMatchType, err error) {
  27. o := orm.NewOrmUsingDB("hz_cygx")
  28. sql := `SELECT match_type_name FROM cygx_report_mapping WHERE report_type = 2 GROUP BY match_type_name`
  29. _, err = o.Raw(sql).QueryRows(&items)
  30. return
  31. }
  32. // 主题列表所有
  33. func CygxReportMappingMatchTypeListAll() (items []*CygxReportMappingMatchType, err error) {
  34. o := orm.NewOrmUsingDB("hz_cygx")
  35. sql := `SELECT match_type_name FROM cygx_report_mapping WHERE match_type_name != '' GROUP BY match_type_name`
  36. _, err = o.Raw(sql).QueryRows(&items)
  37. return
  38. }
  39. // 主题列表
  40. func CygxReportMappingMatchTypeListExcel() (items []*CygxReportMappingMatchType, err error) {
  41. o := orm.NewOrmUsingDB("hz_cygx")
  42. sql := `SELECT match_type_name FROM cygx_report_mapping WHERE report_type = 2 AND chart_permission_id != 23 GROUP BY match_type_name`
  43. _, err = o.Raw(sql).QueryRows(&items)
  44. return
  45. }
  46. // 获取产业关联的文章数量
  47. func GetReportCount(chartPermissionId, industrialManagementId int, matchTypeName string) (recount int, err error) {
  48. sqlCount := `SELECT COUNT(1) as recount FROM
  49. cygx_industrial_article_group_management AS man_g
  50. INNER JOIN cygx_article as art on art.article_id = man_g.article_id
  51. INNER JOIN cygx_report_mapping as re ON re.category_id = art.category_id
  52. WHERE re.chart_permission_id = ?
  53. AND man_g.industrial_management_id = ?
  54. AND re.match_type_name = ` + "'" + matchTypeName + "'"
  55. o := orm.NewOrmUsingDB("hz_cygx")
  56. err = o.Raw(sqlCount, chartPermissionId, industrialManagementId).QueryRow(&recount)
  57. return
  58. }
  59. type ReportMappingRep struct {
  60. MatchTypeName string `description:"匹配类型"`
  61. ReportType int `description:"报告类型,2产业报告,1行业报告"`
  62. IsSummary int `description:"是否是纪要库,1是,0否"`
  63. IsReport int `description:"是否是报告,1是,0否"`
  64. CategoryId int `description:"分类ID"`
  65. }
  66. func GetMatchTypeNameById(Id int) (item *ReportMappingRep, err error) {
  67. o := orm.NewOrmUsingDB("hz_cygx")
  68. sql := `SELECT * FROM cygx_report_mapping WHERE id = ? `
  69. err = o.Raw(sql, Id).QueryRow(&item)
  70. return
  71. }
  72. func GetMatchTypeNameByPermissionId(permissionId int) (item *ReportMappingRep, err error) {
  73. o := orm.NewOrmUsingDB("hz_cygx")
  74. sql := `SELECT category_id FROM cygx_report_mapping WHERE chart_permission_id = ? AND category_id IN (1004,1005,1006,1007) AND report_type = 2 LIMIT 1 `
  75. err = o.Raw(sql, permissionId).QueryRow(&item)
  76. return
  77. }
  78. func GetMatchTypeNameByKeyword(keyWord string) (items []*CygxReportMapping, err error) {
  79. o := orm.NewOrmUsingDB("hz_cygx")
  80. sql := `SELECT
  81. *
  82. FROM
  83. (
  84. SELECT
  85. match_type_name AS sub_category_name
  86. FROM
  87. cygx_report_mapping_cygx UNION
  88. SELECT
  89. "晨会精华" AS sub_category_name UNION
  90. SELECT
  91. "路演精华" AS sub_category_name UNION
  92. SELECT
  93. "重点公司" AS sub_category_name UNION
  94. SELECT
  95. "本周研究汇总" AS sub_category_name UNION
  96. SELECT
  97. "上周纪要汇总" AS sub_category_name UNION
  98. SELECT
  99. article_type_name AS sub_category_name
  100. FROM
  101. cygx_article_type
  102. ) AS a
  103. WHERE a.sub_category_name LIKE '%` + keyWord + `%' `
  104. _, err = o.Raw(sql).QueryRows(&items)
  105. return
  106. }