Эх сурвалжийг харах

Merge branch 'cygx_9.6' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai 2 жил өмнө
parent
commit
da59c05703

+ 65 - 6
controllers/report.go

@@ -1565,21 +1565,62 @@ func (this *ReportController) Detail() {
 		br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
 		return
 	}
+
+	//较上一期有观点变化(后台填写的核心逻辑汇总内容、标签内容有更新),或者新增的公司,显示new标签
+	var isAllNew bool // 判断是否都打新的标签
+	lastPeriods := detail.Periods - 1
+	mapBodyChartSummary := make(map[int]string)
+	mapLabel := make(map[int]string)
+	if lastPeriods > 0 {
+		detailLast, err := models.GetCygxReportSelectionInfoById(articleId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
+			return
+		}
+		articleIdLast := detailLast.ArticleId
+		listLogLast, err := models.GetReportSelectionlogListAll(articleIdLast)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
+			return
+		}
+		for _, v := range listLogLast {
+			mapBodyChartSummary[v.IndustrialSubjectId] = v.Body
+			mapLabel[v.IndustrialSubjectId] = v.Label
+		}
+	} else {
+		isAllNew = true
+	}
 	detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
 	existMap := make(map[int]int)
 	var items []*models.ReportSelectionChartPermission
+	var itemsSubject []*models.ReportSelectionChartLogPermission
 	listLog, err := models.GetReportSelectionlogListAll(articleId)
-	detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
 		return
 	}
-	//var itemLogs []*models.CygxReportSelectionLogDetail
+	detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
+	//获取行业核心逻辑汇总
+	listChartLog, err := models.GetCygxReportSelectionChartLogRepList(articleId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	mapChartLog := make(map[string]string)
+	for _, v := range listChartLog {
+		mapChartLog[v.ChartPermissionName] = v.BodyChartSummary
+	}
 	for _, v := range listLog {
 		item := new(models.ReportSelectionChartPermission)
+		itemSubject := new(models.ReportSelectionChartLogPermission)
+		itemSubject.PermissionName = v.PermissionName
 		if existMap[v.ChartPermissionId] == 0 {
-			item.PermissionName = v.PermissionName + "领域深度报告和调研"
+			//item.PermissionName = v.PermissionName + "领域深度报告和调研"
+			item.PermissionName = v.PermissionName
 			item.IcoLink = v.IcoLink
 			listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
 			if err != nil && err.Error() != utils.ErrNoRow() {
@@ -1588,6 +1629,14 @@ func (this *ReportController) Detail() {
 				return
 			}
 			for k2, v2 := range listSonLog {
+				var isNew bool
+				if isAllNew {
+					isNew = true
+				} else {
+					if mapBodyChartSummary[v2.IndustrialSubjectId] != v2.Body || mapLabel[v2.IndustrialSubjectId] != v2.Label {
+						isNew = true
+					}
+				}
 				if v2.IndustrialManagementId != "" {
 					listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
 					if err != nil && err.Error() != utils.ErrNoRow() {
@@ -1595,15 +1644,23 @@ func (this *ReportController) Detail() {
 						br.ErrMsg = "获取信息失败,Err:" + err.Error()
 						return
 					}
+					v2.IsNew = isNew
 					listSonLog[k2].List = listIndustrial
+					if v2.Label != "" {
+						v2.CompanyLabel = strings.Split(v2.Label, "{|}")
+					}
 				}
+				itemSubject.ListSubject = append(itemSubject.ListSubject, &models.ReportSelectionChartLogSubjectName{SubjectName: v2.SubjectName, IsNew: isNew, IndustrialSubjectId: v2.IndustrialSubjectId})
 			}
+			item.BodyChartSummary = mapChartLog[v.PermissionName]
 			item.List = listSonLog
 			items = append(items, item)
+			itemsSubject = append(itemsSubject, itemSubject)
 			//itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
 		}
 		existMap[v.ChartPermissionId] = v.ChartPermissionId
 	}
+
 	historyRecord := new(models.CygxReportHistoryRecord)
 	historyRecord.UserId = uid
 	historyRecord.ArticleId = articleId
@@ -1623,8 +1680,10 @@ func (this *ReportController) Detail() {
 	if sellerItem != nil {
 		historyRecord.SellerName = sellerItem.RealName
 	}
+
 	go models.AddCygxReportHistoryRecord(historyRecord)
 	resp.List = items
+	resp.ListPermissionSubject = itemsSubject
 	resp.Detail = detail
 	br.Ret = 200
 	br.Success = true
@@ -3025,11 +3084,11 @@ func (this *ReportController) SearchReportAndResource() {
 		industrialIdMap := make(map[string]time.Time)
 		for _, v := range recrodList {
 			industrialManagementIdstr = strings.TrimLeft(v.Parameter, "PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=")
-			if createTime, ok := industrialIdMap[industrialManagementIdstr]; ok{
+			if createTime, ok := industrialIdMap[industrialManagementIdstr]; ok {
 				if createTime.Before(v.CreateTime) {
 					industrialIdMap[industrialManagementIdstr] = v.CreateTime
 				}
-			}else {
+			} else {
 				industrialIdMap[industrialManagementIdstr] = v.CreateTime
 			}
 		}
@@ -3045,7 +3104,7 @@ func (this *ReportController) SearchReportAndResource() {
 		timeLineRedMap := make(map[int]bool, 0)
 
 		for _, industrialId := range industrialIdArr {
-			if createTime, ok := industrialIdMap[strconv.Itoa(industrialId)]; ok{
+			if createTime, ok := industrialIdMap[strconv.Itoa(industrialId)]; ok {
 				if createTime.Before(morningMeetingTimeMap[industrialId]) {
 					timeLineRedMap[industrialId] = true
 				}

+ 49 - 17
models/report_selection.go

@@ -30,31 +30,52 @@ type DetailCygxReportSelectionRep struct {
 	PublishDate        string `description:"发布时间"`
 	CreateTime         string `description:"创建时间"`
 	LastUpdatedTime    string `description:"最后一次更新时间"`
-	Periods            string `description:"期数"`
+	Periods            int    `description:"期数"`
 	VideoUrl           string `description:"链接"`
 	VideoPlaySeconds   string `description:"时长"`
 	VideoName          string `description:"音频名称"`
 	ProductDescription string `description:"产品说明"`
 	UpdateDescription  string `description:"更新说明"`
 	FocusOn            string `description:"近期重点关注方向"`
+	MarketStrategy     string `description:"市场策略核心逻辑汇总"`
+	ReportLink         string `description:"报告链接"`
+	CeLueArticleId     int    `description:"策略报告详情"`
 }
 
 type ReportSelectionLetailResp struct {
-	Detail        *DetailCygxReportSelectionRep
-	HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
-	List          []*ReportSelectionChartPermission
+	Detail                *DetailCygxReportSelectionRep
+	HasPermission         int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	List                  []*ReportSelectionChartPermission
+	ListPermissionSubject []*ReportSelectionChartLogPermission `description:"行业列表"`
 }
 
 type ReportSelectionChartPermission struct {
-	PermissionName string `description:"权限名称"`
-	IcoLink        string `orm:"column(image_url)"description:"图标链接"`
-	List           []*CygxReportSelectionLogDetail
+	PermissionName   string `description:"权限名称"`
+	IcoLink          string `orm:"column(image_url)"description:"图标链接"`
+	List             []*CygxReportSelectionLogDetail
+	BodyChartSummary string `description:"行业核心逻辑汇总"`
+}
+
+type ReportSelectionChartLogPermission struct {
+	PermissionName string                                `description:"权限名称"`
+	ListSubject    []*ReportSelectionChartLogSubjectName `description:"标的列表"`
+}
+
+type ReportSelectionChartLogSubjectName struct {
+	SubjectName         string `description:"标的名称"`
+	IndustrialSubjectId int    `description:"标的ID"`
+	IsNew               bool   `description:"是否展示新标签"`
 }
 
 type CygxReportSelectionLogDetail struct {
-	IndustrialManagementId string `description:"产业Id"`
-	SubjectName            string `description:"标的名称"`
-	Body                   string `description:"内容"`
+	IndustrialManagementId string   `description:"产业Id"`
+	IndustrialSubjectId    int      `description:"标的ID"`
+	SubjectName            string   `description:"标的名称"`
+	IsNew                  bool     `description:"是否展示新标签"`
+	Body                   string   `description:"内容"`
+	CompanyLabel           []string `description:"公司标签"`
+	Label                  string   `description:"公司标签"`
+	OverviewArticleId      int      `description:"综述报告Id"`
 	List                   []*IndustriaReportSelection
 }
 type IndustriaReportSelection struct {
@@ -66,7 +87,7 @@ type ReportSelectionId struct {
 	ArticleId int `description:"报告I"`
 }
 
-//获取数量
+// 获取数量
 func GetCygxReportSelectionPublic(condition, tbdb string, pars []interface{}) (count int, err error) {
 	sqlCount := ` SELECT COUNT(1) AS count  FROM ` + tbdb + ` as art WHERE 1= 1 AND art.publish_status = 1   `
 	if condition != "" {
@@ -77,7 +98,7 @@ func GetCygxReportSelectionPublic(condition, tbdb string, pars []interface{}) (c
 	return
 }
 
-//通过纪要ID获取活动详情
+// 通过ID获取详情
 func GetCygxReportSelectionInfoById(articleId int) (item *DetailCygxReportSelectionRep, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_report_selection  WHERE article_id=? AND publish_status = 1 `
@@ -85,7 +106,15 @@ func GetCygxReportSelectionInfoById(articleId int) (item *DetailCygxReportSelect
 	return
 }
 
-//列表
+// 通过期数获取详情
+func GetCygxReportSelectionInfoByperiods(periods int) (item *DetailCygxReportSelectionRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_selection  WHERE periods=?  `
+	err = o.Raw(sql, periods).QueryRow(&item)
+	return
+}
+
+// 列表
 func GetReportSelectionListPublic(condition, readSql, tbdb string, pars []interface{}, startSize, pageSize int) (items []*CygxReportSelectionRep, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * ,` + readSql + ` FROM  ` + tbdb + ` as art WHERE 1= 1 AND art.publish_status = 1  `
@@ -104,13 +133,16 @@ type CygxReportSelectionLog struct {
 	PermissionName         string    `description:"行业ID"`
 	CreateTime             time.Time `description:"创建时间"`
 	Body                   string    `description:"内容"`
-	IndustrialSubjectId    string    `description:"标的ID"`
+	IndustrialSubjectId    int       `description:"标的ID"`
 	IndustrialManagementId string    `description:"产业资源包Id  多个用 , 隔开"`
 	SubjectName            string    `description:"标的名称"`
 	IcoLink                string    `orm:"column(image_url)"description:"图标链接"`
+	CompanyLabel           []string  `description:"公司标签"`
+	Label                  string    `description:"公司标签"`
+	OverviewArticleId      int       `description:"综述报告Id"`
 }
 
-//列表
+// 列表
 func GetReportSelectionlogListAll(articleId int) (items []*CygxReportSelectionLog, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT c.permission_name ,c.image_url,s.subject_name , l.* 
@@ -123,10 +155,10 @@ func GetReportSelectionlogListAll(articleId int) (items []*CygxReportSelectionLo
 	return
 }
 
-//列表
+// 列表
 func GetReportSelectionlogSonListAll(articleId, chartPermissionId int) (items []*CygxReportSelectionLogDetail, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT c.permission_name , l.* 
+	sql := `SELECT c.permission_name , l.* ,l.company_label as label
 			FROM
 			cygx_report_selection_log AS l
 			INNER JOIN chart_permission AS c ON c.chart_permission_id = l.chart_permission_id 

+ 36 - 0
models/report_selection_chart_log.go

@@ -0,0 +1,36 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxReportSelectionChartLog struct {
+	ArticleSunId      int       `orm:"column(article_sun_id);pk"description:"子级报告id"`
+	ArticleId         int       `description:"父级报告Id"`
+	ChartPermissionId int       `description:"行业ID"`
+	CreateTime        time.Time `description:"创建时间"`
+	Body              string    `description:"内容"`
+}
+
+type CygxReportSelectionChartLogRep struct {
+	ChartPermissionId   int    `description:"行业ID"`
+	ChartPermissionName string `description:"行业ID"`
+	BodyChartSummary    string `orm:"column(body)"description:"内容"`
+}
+
+type AddCygxReportSelectionChartLog struct {
+	ChartPermissionId   int    `description:"行业ID"`
+	ChartPermissionName string `description:"行业ID"`
+	BodyChartSummary    string `orm:"column(body)"description:"内容"`
+}
+
+func GetCygxReportSelectionChartLogRepList(articleId int) (items []*CygxReportSelectionChartLogRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT l.*,c.chart_permission_name
+			FROM cygx_report_selection_chart_log AS l
+			LEFT JOIN chart_permission as c  ON c.chart_permission_id = l.chart_permission_id
+			WHERE  1= 1 AND article_id=?  `
+	_, err = o.Raw(sql, articleId).QueryRows(&items)
+	return
+}