xingzai 2 ani în urmă
părinte
comite
19b5d5e486
4 a modificat fișierele cu 206 adăugiri și 0 ștergeri
  1. 102 0
      models/article_category_mapping.go
  2. 3 0
      models/db.go
  3. 31 0
      models/report_mapping.go
  4. 70 0
      services/report_mapping.go

+ 102 - 0
models/article_category_mapping.go

@@ -0,0 +1,102 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+	//"time"
+)
+
+type CygxArticleCategoryMapping struct {
+	Id                  int    `orm:"column(id);pk" description:"id"`
+	ChartPermissionId   int    `description:"行业ID"`
+	CategoryId          int    `description:"分类ID"`
+	ChartPermissionName string `description:"行业名称"`
+	MatchTypeName       string `description:"分类名称"`
+	ReportType          int    `description:"报告类型,2产业报告,1行业报告"`
+	SubCategoryName     string `description:"主题"`
+	Sort                int    `description:"排序"`
+	IsCustom            int    `description:"是否属于自定义的匹配类型 ,1是,0否"`
+	IsSummary           int    `description:"是否是纪要库,1是,0否"`
+	IsReport            int    `description:"是否是报告,1是,0否"`
+	PermissionType      int    `description:"1主观,2客观"`
+	CygxId              int    `description:"分类聚合ID"`
+	CeLueId             int    `description:"策略平台领域ID"`
+}
+
+// 添加
+func AddCygxArticleCategoryMapping(item *CygxArticleCategoryMapping) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+type CygxReportMappingCygx struct {
+	Id                  int    `orm:"column(id);pk" description:"id"`
+	ChartPermissionId   int    `description:"行业ID"`
+	ChartPermissionName string `description:"行业名称"`
+	MatchTypeName       string `description:"分类名称"`
+	ReportType          int    `description:"报告类型,2产业报告,1行业报告"`
+	Sort                int    `description:"排序"`
+	IsCustom            int    `description:"是否属于自定义的匹配类型 ,1是,0否"`
+	IsSummary           int    `description:"是否是纪要库,1是,0否"`
+	IsReport            int    `description:"是否是报告,1是,0否"`
+	PermissionType      int    `description:"1主观,2客观"`
+}
+
+type CygxReportMappingGroup struct {
+	Id              int       `orm:"column(id);pk" description:"id"`
+	IdCygx          int       `description:"分类ID"`
+	CategoryIdCelue int       `description:"分类ID"`
+	CreateTime      time.Time `description:"创建时间"`
+	ModifyTime      time.Time `description:"更新时间"`
+}
+
+// 添加
+func AddCygxReportMappingGroup(item *CygxReportMappingGroup) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+// 添加
+func AddCygxReportMappingCygx(item *CygxReportMappingCygx) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+// 获取数量
+func GetCygxReportMappingCygxCount(condition string) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_report_mapping_cygx as art WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount).QueryRow(&count)
+	return
+}
+
+// 获取所有的报告分类 查研观向
+func GetCygxReportMappingCygx() (items []*CygxReportMappingCygx, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+				* 
+			FROM
+				cygx_report_mapping_cygx `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 获取所有的报告分类 策略
+func GetCygxReportMappingcelue(condition string) (items []*CygxReportMapping, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+				* 
+			FROM
+				cygx_report_mapping_celue WHERE 1= 1  `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 3 - 0
models/db.go

@@ -137,6 +137,9 @@ func init() {
 		new(CygxTacticsTimeLineHistory),
 		new(CygxProductInteriorHistory),
 		new(CygxMorningMeetingGather),
+		new(CygxArticleCategoryMapping),
+		new(CygxReportMappingCygx),
+		new(CygxReportMappingGroup),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 31 - 0
models/report_mapping.go

@@ -4,6 +4,26 @@ import (
 	"github.com/beego/beego/v2/client/orm"
 )
 
+type CygxReportMapping struct {
+	Id                  int    `description:"id"`
+	ChartPermissionId   int    `description:"行业ID"`
+	CategoryId          int    `description:"分类ID"`
+	SubCategoryId       int    `description:"主题"`
+	CategoryName        int    `description:"主题"`
+	ChartPermissionName string `description:"行业名称"`
+	SubCategoryName     int    `description:"主题"`
+	MatchTypeName       string `description:"分类名称"`
+	ReportType          int    `description:"报告类型,2产业报告,1行业报告"`
+	Sort                int    `description:"排序"`
+	IsCustom            int    `description:"是否属于自定义的匹配类型 ,1是,0否"`
+	IsSummary           int    `description:"是否是纪要库,1是,0否"`
+	IsReport            int    `description:"是否是报告,1是,0否"`
+	PermissionType      int    `description:"1主观,2客观"`
+	CategoryIdSet       int    `description:"分类ID手动设置的分类"`
+	PolymerizationId    string `description:"分类聚合ID"`
+	CeLueFieldId        string `description:"策略平台领域ID"`
+}
+
 type ReportMapping struct {
 	CategoryId          int    `description:"分类ID"`
 	CategoryIdSet       int    `description:"分类ID手动设置的分类"`
@@ -277,3 +297,14 @@ func GetReportMappingByPermissionName(chartPermissionName string) (items []*Repo
 	_, err = o.Raw(sql, chartPermissionName).QueryRows(&items)
 	return
 }
+
+// 获取所有的报告分类
+func GetReportMapping() (items []*CygxReportMapping, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+				* 
+			FROM
+				cygx_report_mapping `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 70 - 0
services/report_mapping.go

@@ -1,8 +1,11 @@
 package services
 
 import (
+	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
+	"strconv"
+	"time"
 )
 
 func GetReportMappingMap() (mapResp map[int]bool, err error) {
@@ -24,3 +27,70 @@ func GetReportMappingMap() (mapResp map[int]bool, err error) {
 	return
 
 }
+
+// 生成查研观向的报告匹配类型
+func init111() {
+	list, err := models.GetReportMapping()
+	if err != nil {
+		fmt.Print(err)
+	}
+	var condition string
+	for _, v := range list {
+		if v.MatchTypeName == "" {
+			continue
+		}
+		item := new(models.CygxReportMappingCygx)
+		item.ChartPermissionId = v.ChartPermissionId
+		item.ChartPermissionName = v.ChartPermissionName
+		item.MatchTypeName = v.MatchTypeName
+		item.ReportType = v.ReportType
+		item.Sort = v.Sort
+		item.IsCustom = v.IsCustom
+		item.IsSummary = v.IsSummary
+		item.IsReport = v.IsReport
+		item.PermissionType = v.PermissionType
+		condition = ` AND match_type_name = '` + v.MatchTypeName + `' AND chart_permission_id =  ` + strconv.Itoa(v.ChartPermissionId)
+		total, err := models.GetCygxReportMappingCygxCount(condition)
+		if err != nil {
+			fmt.Print(err)
+		}
+		if total == 0 {
+			_, err = models.AddCygxReportMappingCygx(item)
+			if err != nil {
+				fmt.Print(err)
+			}
+		}
+	}
+}
+
+// 生成多对多关系表
+func init1232() {
+	list, err := models.GetCygxReportMappingCygx()
+	if err != nil {
+		fmt.Print(err)
+	}
+	var condition string
+	for _, v := range list {
+		if v.MatchTypeName == "" {
+			continue
+		}
+		condition = ` AND match_type_name = '` + v.MatchTypeName + `' AND chart_permission_id =  ` + strconv.Itoa(v.ChartPermissionId)
+		listCelue, err := models.GetCygxReportMappingcelue(condition)
+		if err != nil {
+			fmt.Print(err)
+		}
+		for _, vC := range listCelue {
+			item := new(models.CygxReportMappingGroup)
+			item.IdCygx = v.Id
+			item.CategoryIdCelue = vC.CategoryId
+			item.CreateTime = time.Now()
+			item.ModifyTime = time.Now()
+			fmt.Println(item)
+			_, err = models.AddCygxReportMappingGroup(item)
+			if err != nil {
+				fmt.Print(err)
+			}
+		}
+
+	}
+}