Browse Source

no message

xingzai 4 months ago
parent
commit
e1c1c98d50
2 changed files with 52 additions and 2 deletions
  1. 14 2
      controllers/report.go
  2. 38 0
      services/industrial_subject.go

+ 14 - 2
controllers/report.go

@@ -1334,12 +1334,17 @@ func (this *MobileReportController) Timeline() {
 	}
 	//处理晨会精华关联的标的,以及要跳转的文章ID
 	var meetingreviewchaptIds []int
-	mapchaptIdAndArticleId := make(map[int]int)                            // 晨会精华ID与跳转文章ID的映射关系
-	mapchaptIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 晨会精华ID与标的列表的映射关系
+	var articleIds []int
+	mapchaptIdAndArticleId := make(map[int]int)                              // 晨会精华ID与跳转文章ID的映射关系
+	mapchaptIdListSubject := make(map[int][]*models.CygxIndustrialSubject)   // 晨会精华ID与标的列表的映射关系
+	mapArticleIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 报告ID与标的列表的映射关系
 	for _, v := range list {
 		if v.Resource == 3 {
 			meetingreviewchaptIds = append(meetingreviewchaptIds, v.Id)
 		}
+		if v.Resource == 1 {
+			articleIds = append(articleIds, v.ArticleId)
+		}
 	}
 	if len(meetingreviewchaptIds) > 0 {
 		listMeet, err := services.GetCygxMorningMeetingReviewChapterListByIds(meetingreviewchaptIds)
@@ -1353,6 +1358,10 @@ func (this *MobileReportController) Timeline() {
 		}
 	}
 
+	if len(articleIds) > 0 {
+		mapArticleIdListSubject = services.GetArticleGroupSubjectMapByIndustrialManagementId(articleIds, industrialManagementId)
+	}
+
 	//查询用户今天是否看过时间线
 	//count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
 	//if err != nil {
@@ -1391,6 +1400,9 @@ func (this *MobileReportController) Timeline() {
 			v.LinkArticleId = mapchaptIdAndArticleId[v.Id]
 			v.ListSubject = mapchaptIdListSubject[v.Id]
 		}
+		if v.Resource == 1 {
+			v.ListSubject = mapArticleIdListSubject[v.Id]
+		}
 	}
 
 	//添加我的日程访问记录

+ 38 - 0
services/industrial_subject.go

@@ -2,6 +2,7 @@ package services
 
 import (
 	"errors"
+	"fmt"
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/utils"
 )
@@ -40,3 +41,40 @@ func GetArticleGroupSubjectMap(articleIds []int) (mapResp map[int][]*models.Indu
 	subjectMap = subMap
 	return
 }
+
+// GetArticleGroupSubjectMapByIndustrialManagementId 通过文章ID,产业;获取文章所关联的标的
+func GetArticleGroupSubjectMapByIndustrialManagementId(articleIds []int, industrialManagementId int) (mapResp map[int][]*models.CygxIndustrialSubject) {
+	var err error
+	lenArticleIds := len(articleIds)
+	if lenArticleIds == 0 {
+		return
+	}
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("通过文章ID,产业;获取文章所关联的标的失败 ,GetArticleGroupSubjectMapByIndustrialManagementId err"+err.Error(), "articleIds:", articleIds), 2)
+		}
+	}()
+	var condition string
+	var pars []interface{}
+	condition = ` AND g.article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `)  AND s.industrial_management_id = ? `
+	pars = append(pars, articleIds, industrialManagementId)
+	list, e := models.GetArticleGroupSubjectList(pars, condition)
+	if e != nil {
+		err = errors.New("GetArticleGroupSubjectList " + e.Error())
+		return
+	}
+	listMap := make(map[int][]*models.CygxIndustrialSubject, 0)
+
+	if len(list) > 0 {
+		for _, v := range list {
+			item := models.CygxIndustrialSubject{
+				IndustrialSubjectId:    v.IndustrialSubjectId,
+				IndustrialManagementId: v.IndustrialManagementId,
+				SubjectName:            v.SubjectName,
+			}
+			listMap[v.ArticleId] = append(listMap[v.ArticleId], &item)
+		}
+	}
+	mapResp = listMap
+	return
+}