Bläddra i källkod

Merge branch 'cygx_10.3' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai 2 år sedan
förälder
incheckning
95616e40f5

+ 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
+}

+ 1 - 0
models/resource_data.go

@@ -32,6 +32,7 @@ type CygxResourceDataResp struct {
 	Researchsummary    *CygxReportSelectionRep                 `description:"本周研究汇总"`
 	Minutessummary     *CygxReportSelectionRep                 `description:"上周纪要汇总"`
 	Meetingreviewchapt *CygxMorningMeetingGatherDetailListResp `description:"晨会精华"`
+	ProductInterior    *CygxProductInteriorResp                `description:"产品内测"`
 }
 
 // Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`

+ 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)
+			}
+		}
+
+	}
+}

+ 20 - 0
services/resource_data.go

@@ -39,6 +39,7 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 	var researchsummaryIds []int
 	var minutessummaryIds []int
 	var meetingreviewchaptIds []int
+	var productinteriorIds []int
 	//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial 、 本周研究汇总: researchsummary 、 上周纪要汇总 :minutessummary 、晨会精华 :meetingreviewchapt "`
 	for _, v := range list {
 		if v.Source == "article" {
@@ -61,7 +62,10 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 			minutessummaryIds = append(minutessummaryIds, v.SourceId)
 		} else if v.Source == "meetingreviewchapt" {
 			meetingreviewchaptIds = append(meetingreviewchaptIds, v.SourceId)
+		} else if v.Source == "productinterior" {
+			productinteriorIds = append(productinteriorIds, v.SourceId)
 		}
+
 	}
 
 	//处理文章
@@ -139,6 +143,22 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 		}
 	}
 
+	//处理产品内测
+	if len(productinteriorIds) > 0 {
+		pars = make([]interface{}, 0)
+		condition = `  AND art.status = 1 AND art.product_interior_id  IN (` + utils.GetOrmInReplace(len(productinteriorIds)) + `)`
+		pars = append(pars, productinteriorIds)
+		listProductInterior, e := models.GetCygxProductInteriorList(condition, pars, 0, len(researchsummaryIds))
+		if e != nil {
+			err = errors.New("GetCygxProductInteriorList, Err: " + e.Error())
+			return
+		}
+		for _, v := range listProductInterior {
+			v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
+			mapItems[fmt.Sprint("productinterior", v.ProductInteriorId)].ProductInterior = v
+		}
+	}
+
 	detail, e := models.GetConfigByCode("city_img_url")
 	if e != nil {
 		err = errors.New("GetResourceDataList, Err: " + e.Error())