Browse Source

Merge branch 'cygx_8.2' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai 2 years ago
parent
commit
6769dc5566
2 changed files with 79 additions and 1 deletions
  1. 24 1
      controllers/report.go
  2. 55 0
      models/industrial_management.go

+ 24 - 1
controllers/report.go

@@ -268,6 +268,7 @@ func (this *ReportController) IndustryList() {
 		br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
 		return
 	}
+	mapUPdateTime := make(map[int]string)
 
 	if len(industrialManagementIds) > 0 {
 		// 获取默认图配置
@@ -299,6 +300,28 @@ func (this *ReportController) IndustryList() {
 			}
 			industrialVideoMap[v.IndustryId] = tmp
 		}
+		//获取这些产业下最新更新的文章
+		listUpdateTime, err := models.GetNewArticleDetailByIndustrialIds(industrialManagementIds)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			return
+		}
+		for _, v := range listUpdateTime {
+			mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
+		}
+
+		//时间线的更新时间
+		//	maptimelineUPdateTime := make(map[int]string)
+		listtimelinePublishdate, err := models.GetTimeLineReportIndustrialPublishdateList(industrialManagementIds)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			return
+		}
+		for _, v := range listtimelinePublishdate {
+			if mapUPdateTime[v.IndustrialManagementId] != "" {
+				if utils.StrTimeToTime(v.PublishDate).After(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
+					mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
+				}
+			}
+		}
 	}
 
 	nowTime := time.Now().Local()
@@ -318,7 +341,7 @@ func (this *ReportController) IndustryList() {
 			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 			return
 		}
-		list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
+		list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
 		recordCount, err := models.GetUserToArticleCount(uid, newArtinfo.ArticleId)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"

+ 55 - 0
models/industrial_management.go

@@ -627,3 +627,58 @@ func GetIndustryByName(industryName string) (item *IndustrialManagement, err err
 	err = orm.NewOrm().Raw(sql, industryName).QueryRow(&item)
 	return
 }
+
+type IndustrialManagementArticle struct {
+	IndustrialManagementId int    `description:"产业Id"`
+	IndustryName           string `description:"产业名称"`
+	ArticleId              int    `description:"文章ID"`
+	PublishDate            string `description:"发布时间"`
+}
+
+//时间线的更新时间
+func GetTimeLineReportIndustrialPublishdateList(industrialIdArr []int) (items []*IndustrialManagementArticle, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT	
+			mmc.id,
+			0,
+			mmc.industry_id AS industrial_management_id,			
+			mmc.content AS title,
+			mm.meeting_time AS publish_date
+		FROM
+			cygx_morning_meeting_review_chapter AS mmc
+			INNER JOIN cygx_morning_meeting_reviews AS mm 
+		WHERE
+			mm.id = mmc.meeting_id 
+			AND mm.STATUS = 1 
+			AND mmc.industry_id IN (` + utils.GetOrmInReplace(len(industrialIdArr)) + `)
+		GROUP BY industrial_management_id ORDER BY publish_date DESC  `
+	_, err = o.Raw(sql, industrialIdArr).QueryRows(&items)
+	return
+}
+
+//获取该产业下最新的文章详情
+func GetNewArticleDetailByIndustrialIds(industrialIdArr []int) (items []*IndustrialManagementArticle, err error) {
+	arrLen := len(industrialIdArr)
+	if arrLen == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	sql := `SELECT
+			mg.industrial_management_id,
+			MAX( a.article_id ) AS article_id,
+			a.title,
+			MAX( a.publish_date ) AS publish_date 
+		FROM
+			cygx_industrial_article_group_management AS mg
+			INNER JOIN cygx_article AS a ON mg.article_id = a.article_id 
+		WHERE
+			1 = 1 
+			AND a.article_id < ?
+			AND a.is_report = 1
+			AND a.is_class = 1
+			AND mg.industrial_management_id IN(` + utils.GetOrmInReplace(len(industrialIdArr)) + `)   
+		GROUP BY
+			mg.industrial_management_id `
+	_, err = o.Raw(sql, utils.SummaryArticleId, industrialIdArr).QueryRows(&items)
+	return
+}