Pārlūkot izejas kodu

Merge branch 'cygx_9.2'

ziwen 2 gadi atpakaļ
vecāks
revīzija
0020d8e9ce

+ 171 - 5
controllers/report.go

@@ -389,12 +389,45 @@ func (this *ReportController) ArticleCategoryList() {
 			br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
 			return
 		}
+		//查询用户今天是否看过时间线
+		haveMorningMeeting := false
+		var morningMeetingTime string
+		count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
+		if err != nil {
+			br.Msg = "查询浏览记录数量失败"
+			br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
+			return
+		}
+		var recordItem *models.CygxPageHistoryRecord
+		if count > 1 {
+			recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
+			if err != nil {
+				br.Msg = "查询浏览记录失败"
+				br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
+				return
+			}
+		}
+
 		for _, v := range timeLineList {
 			if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishTime)) {
+				if v.SubCategoryName == "时间线" {
+					haveMorningMeeting = true
+					morningMeetingTime = v.PublishTime
+					continue
+				}
 				timeLineItem.IsRed = true
 			}
 		}
-
+		//因为无法记录用户是否看过晨会点评,所以用用户今天是否看过时间线来判断是否显示小红点,这里是判断分类的小红点
+		timeLineRed := false
+		if count < 2 {
+			timeLineRed = true
+		} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(morningMeetingTime)){
+			timeLineRed = true
+		}
+		if !timeLineItem.IsRed && timeLineRed && haveMorningMeeting {
+			timeLineItem.IsRed = true
+		}
 		list = append([]*models.IndustrialToArticleCategoryRep{&timeLineItem}, list...)
 	}
 
@@ -632,8 +665,34 @@ func (this *ReportController) List() {
 		//	//list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
 		//}
 
+		//查询用户今天是否看过时间线
+		count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
+		if err != nil {
+			br.Msg = "查询浏览记录数量失败"
+			br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
+			return
+		}
+		var recordItem *models.CygxPageHistoryRecord
+		if count > 1 {
+			recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
+			if err != nil {
+				br.Msg = "查询浏览记录失败"
+				br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
+				return
+			}
+		}
+
 		for k, v := range list {
-			if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishTime)) {
+			if v.SubCategoryName != "时间线" && v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishTime)) {
+				list[k].IsRed = true
+			}
+			timeLineRed := false
+			if count < 2 && v.SubCategoryName == "时间线" {
+				timeLineRed = true
+			} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishTime)){
+				timeLineRed = true
+			}
+			if v.SubCategoryName == "时间线" && timeLineRed {
 				list[k].IsRed = true
 			}
 			if v.VideoUrl != "" {
@@ -2774,6 +2833,7 @@ func (this *ReportController) SearchReportAndResource() {
 		return
 	}
 	for _, v := range listHot {
+		industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
 		mapHot[v.IndustryName] = v.IndustrialManagementId
 	}
 	orderSrt := "man.recommended_index DESC,update_time DESC"
@@ -2831,9 +2891,115 @@ func (this *ReportController) SearchReportAndResource() {
 			return
 		}
 
-		for _, v2 := range list {
-			if mapHistroyArticleId[v2.ArticleId] == 0 && user.CreatedTime.Before(utils.StrDateToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrDateToTime(v.PublishDate)) {
-				listHzResource[k].IsRed = true
+		mapUPdateTime := make(map[int]string)
+		//获取这些产业下最新更新的文章
+
+		//时间线的更新时间
+		//	maptimelineUPdateTime := make(map[int]string)
+		listtimelinePublishdate, err := models.GetTimeLineReportIndustrialPublishdateList(industrialIdArr)
+		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
+				}
+			}
+		}
+
+		//mapHistroyArticleId := make(map[int]int)
+
+		//if userId > 0 {
+		//	listArticleHistory, e := models.GetUserToArticleHistory(userId, articleIdArr)
+		//	if e != nil && e.Error() != utils.ErrNoRow() {
+		//		err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
+		//		return
+		//	}
+		//	for _, v := range listArticleHistory {
+		//		mapHistroyArticleId[v.ArticleId] = v.ArticleId
+		//	}
+		//}
+		var industrialIds string
+		for _, id := range industrialIdArr {
+			industrialIds += strconv.Itoa(id) + ","
+		}
+		industrialIds = strings.TrimRight(industrialIds, ",")
+		articleList, err := models.GetReportIndustrialReadNumList(user.UserId, industrialIds, user.CreatedTime)
+		mapHistroyindustrialId := make(map[int]int)
+		for _, v := range articleList {
+			mapHistroyindustrialId[v.IndustrialManagementId] = v.Readnum
+		}
+		//nowTime := time.Now().Local()
+		//threeMonBefore := nowTime.AddDate(0, -3, 0)
+
+		//查询用户今天是否看过时间线
+		//haveMorningMeeting := false
+		//var morningMeetingTime string
+		recrodList, err := models.GetTimeLineRecordAllCount(user.UserId, time.Now().Format(utils.FormatDate))
+		if err != nil {
+			return
+		}
+		var industrialManagementIdstr string
+		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.Before(v.CreateTime) {
+					industrialIdMap[industrialManagementIdstr] = v.CreateTime
+				}
+			}else {
+				industrialIdMap[industrialManagementIdstr] = v.CreateTime
+			}
+		}
+
+		mmList, err := models.GetCygxMorningMeetingReviewsListByIndustrialIds(industrialIds)
+		if err != nil {
+			return
+		}
+		morningMeetingTimeMap := make(map[int]time.Time)
+		for _, v := range mmList {
+			morningMeetingTimeMap[v.IndustryId] = v.CreateTime
+		}
+		timeLineRedMap := make(map[int]bool, 0)
+
+		for _, industrialId := range industrialIdArr {
+			if createTime, ok := industrialIdMap[strconv.Itoa(industrialId)]; ok{
+				if createTime.Before(morningMeetingTimeMap[industrialId]) {
+					timeLineRedMap[industrialId] = true
+				}
+			}
+		}
+
+		for k, v := range list {
+			list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
+			if user.UserId > 0 {
+				//如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
+				if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
+					if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
+						list[k].IsRed = true
+					}
+				}
+			} else {
+				if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
+					list[k].IsRed = true
+				}
+				list[k].IsFollow = 0
+			}
+
+			list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
+			if user.UserId > 0 {
+				//如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
+				if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
+					if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
+						list[k].IsRed = true
+					}
+				}
+			} else {
+				if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
+					list[k].IsRed = true
+				}
+				list[k].IsFollow = 0
 			}
 		}
 

+ 129 - 0
models/cygx_morning_meeting_review_chapter.go

@@ -0,0 +1,129 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+// CygxMorningMeetingReviewChapter [...]
+type CygxMorningMeetingReviewChapter struct {
+	Id                   int       `orm:"column(id);pk"`
+	MeetingTime          time.Time `json:"meetingTime"` // 晨会日期
+	CreateTime           time.Time `json:"createTime"`
+	ModifyTime           time.Time `json:"modifyTime"`
+	IndustryId           int       `json:"industryId"`          // 产业id
+	IndustryName         string    `json:"industryName"`        // 产业名称
+	ChartPermissionName  string    `json:"chartPermissionName"` // 行业名称
+	ChartPermissionId    int       `json:"chartPermissionId"`   // 行业id
+	IndustrialSubjectIds string    `json:"industrialSubjectId"` // 标的id
+	MeetingId            int64     `json:"meetingId"`           // 主表id
+	Content              string    `json:"content"`             // 内容
+}
+
+type AddMorningMeetingReviewItem struct {
+	ChapterId            int
+	Content              string
+	ChartPermissionId    int
+	ChartPermissionName  string
+	IndustryId           int
+	IndustryName         string
+	IndustrialSubjectIds string
+}
+
+type AddMorningMeetingReviewsReq struct {
+	List        []*AddMorningMeetingReviewItem
+	MeetingId   int
+	MeetingTime string
+	PublishTime string
+	DoType      int `description:"操作类型 0,保存 、1,发布"`
+}
+
+//添加晨报点评章节
+func AddCygxMorningMeetingReviewChapter(item *CygxMorningMeetingReviewChapter) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+//列表
+func GetCygxMorningMeetingReviewsListById(meetingId int) (items []*CygxMorningMeetingReviewChapter, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_morning_meeting_review_chapter WHERE meeting_id = ? `
+	_, err = o.Raw(sql, meetingId).QueryRows(&items)
+	return
+}
+
+type IndustrialSubjectItem struct {
+	IndustrialSubjectId int    `orm:"column(industrial_subject_id);pk" description:"标的id"`
+	SubjectName         string `description:"标的名称"`
+}
+
+type CygxMorningMeetingReviewChapterRespItem struct {
+	Id                    int                      `orm:"column(id);pk"`
+	MeetingTime           time.Time                `json:"meetingTime"` // 晨会日期
+	CreateTime            time.Time                `json:"createTime"`
+	ModifyTime            time.Time                `json:"modifyTime"`
+	IndustryId            int                      `json:"industryId"`            // 产业id
+	IndustryName          string                   `json:"industryName"`          // 产业名称
+	ChartPermissionName   string                   `json:"chartPermissionName"`   // 行业名称
+	ChartPermissionId     int                      `json:"chartPermissionId"`     // 行业id
+	IndustrialSubjectList []*IndustrialSubjectItem `json:"industrialSubjectList"` // 标的list
+	MeetingId             int64                    `json:"meetingId"`             // 主表id
+	Content               string                   `json:"content"`               // 内容
+}
+
+type CygxMorningMeetingReviewChapterResp struct {
+	MeetingTime string
+	Status int
+	List []*CygxMorningMeetingReviewChapterRespItem
+}
+
+//删除晨会点评章节
+func DeleteMorningMeetingChapter(reviewId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` DELETE FROM cygx_morning_meeting_review_chapter WHERE meeting_id =? `
+	_, err = o.Raw(sql, reviewId).Exec()
+	return
+}
+
+//更新晨报点评章节
+func UpdateCygxMorningMeetingReviewChapter(item *CygxMorningMeetingReviewChapter) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_morning_meeting_review_chapter
+			SET
+			  meeting_time =?,
+			  modify_time = ?,
+			  industry_id = ?,
+			  industry_name = ?,
+			  chart_permission_id = ?,
+			  chart_permission_name = ?,
+			  industrial_subject_ids = ?,
+			  content = ? 
+			WHERE id = ? `
+	_, err = o.Raw(sql, item.MeetingTime, item.ModifyTime, item.IndustryId, item.IndustryName,
+		item.ChartPermissionId, item.ChartPermissionName, item.IndustrialSubjectIds, item.Content, item.Id).Exec()
+
+	return
+}
+
+func GetCygxMorningMeetingReviewsListByIdAndIndustryId(meetingId,  industryId int) (item *CygxMorningMeetingReviewChapter, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_morning_meeting_review_chapter WHERE meeting_id = ? AND industry_id = ? `
+	err = o.Raw(sql, meetingId, industryId).QueryRow(&item)
+	return
+}
+
+//删除晨会点评章节
+func DeleteMorningMeetingChapterById(chapterId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` DELETE FROM cygx_morning_meeting_review_chapter WHERE id =? `
+	_, err = o.Raw(sql, chapterId).Exec()
+	return
+}
+
+func GetCygxMorningMeetingReviewsListByIndustrialIds(industrialIds string) (items []*CygxMorningMeetingReviewChapter, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_morning_meeting_review_chapter WHERE industry_id IN (` + industrialIds + `)  `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 125 - 0
models/cygx_morning_meeting_reviews.go

@@ -0,0 +1,125 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"time"
+)
+
+// CygxMorningMeetingReviews [...]
+type CygxMorningMeetingReviews struct {
+	Id            int       `orm:"column(id);pk"`
+	MeetingTime   time.Time `json:"meetingTime"` // 晨会日期
+	PublishTime   time.Time `json:"publishTime"` // 发布日期
+	CreateTime    time.Time `json:"createTime"`
+	ModifyTime    time.Time `json:"modifyTime"`
+	Status        int       `json:"status"`       // 0:未发布,1:已发布
+	PartNums      int       `json:"partNums"`     // 段落数
+	IndustryNames string    `json:"industryName"` // 产业名称
+}
+
+//添加晨报点评
+func AddCygxMorningMeetingReviews(item *CygxMorningMeetingReviews) (id int64, err error) {
+	o := orm.NewOrm()
+	id, err = o.Insert(item)
+	return
+}
+
+//列表
+func GetCygxMorningMeetingReviewsList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxMorningMeetingReviews, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_morning_meeting_reviews WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,? `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+func GetCygxMorningMeetingReviewsListCount(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(1) AS count FROM cygx_morning_meeting_reviews WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	err = o.Raw(sql, pars).QueryRow(&count)
+	return
+}
+
+type CygxMorningMeetingReviewItem struct {
+	Id            int    `orm:"column(id);pk"`
+	MeetingTime   string `json:"meetingTime"` // 晨会日期
+	PublishTime   string `json:"publishTime"` // 发布日期
+	CreateTime    string `json:"createTime"`
+	ModifyTime    string `json:"modifyTime"`
+	Status        int    `json:"status"`       // 0:未发布,1:已发布
+	PartNums      int    `json:"partNums"`     // 段落数
+	IndustryNames string `json:"industryName"` // 产业名称
+}
+
+type CygxMorningMeetingReviewsList struct {
+	List   []*CygxMorningMeetingReviewItem
+	Paging *paging.PagingItem `description:"分页数据"`
+}
+
+func GetMorningMeetingReviewById(reviewId int) (item *CygxMorningMeetingReviews, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_morning_meeting_reviews WHERE id=?`
+	err = o.Raw(sql, reviewId).QueryRow(&item)
+	return
+}
+
+// 发布报告
+func PublishMorningMeetingReviewById(reviewId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_morning_meeting_reviews SET status=1,publish_time=now(),modify_time=NOW() WHERE id = ? `
+	_, err = o.Raw(sql, reviewId).Exec()
+	return
+}
+
+type MorningReviewPublishReq struct {
+	ReviewIds string `description:"晨会id,多个用英文逗号隔开"`
+}
+
+type MorningReviewPublishCancelReq struct {
+	ReviewId int `description:"晨会id"`
+}
+
+//取消发布报告
+func PublishCancelMorningMeetingReview(reviewId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` UPDATE cygx_morning_meeting_reviews SET status=0,publish_time=null WHERE id =?  `
+	_, err = o.Raw(sql, reviewId).Exec()
+	return
+}
+
+type MorningReviewDeleteReq struct {
+	ReviewId int `description:"晨会id"`
+}
+
+
+//删除晨会点评
+func DeleteMorningMeeting(reviewId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` DELETE FROM cygx_morning_meeting_reviews WHERE id =? `
+	_, err = o.Raw(sql, reviewId).Exec()
+	return
+}
+
+//更新晨报点评
+func UpdateCygxMorningMeetingReviews(item *CygxMorningMeetingReviews) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_morning_meeting_reviews
+			SET
+			  meeting_time =?,
+			  publish_time = ?,
+			  modify_time = ?,
+			  part_nums = ?,
+			  industry_names = ?,
+			  status = ? 
+			WHERE id = ? `
+	_, err = o.Raw(sql, item.MeetingTime, item.PublishTime, item.ModifyTime, item.PartNums, item.IndustryNames, item.Status, item.Id).Exec()
+
+	return
+}

+ 22 - 0
models/page_history_record.go

@@ -2,6 +2,7 @@ package models
 
 import (
 	"github.com/beego/beego/v2/client/orm"
+	"strconv"
 	"time"
 )
 
@@ -48,4 +49,25 @@ func AddCygxPageHistoryRecord(item *CygxPageHistoryRecord) (lastId int64, err er
 
 type PageRouter struct {
 	PageRouter string
+}
+
+func GetTimeLineRecordCount(userId, industrialManagementId int) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(1) AS count FROM cygx_page_history_record WHERE user_id=? AND router = '/api/report/industry/ArticleList?PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=`+strconv.Itoa(industrialManagementId)+`'`
+	err = o.Raw(sql, userId).QueryRow(&count)
+	return
+}
+
+func GetTimeLineRecordItem(userId, industrialManagementId int) (item *CygxPageHistoryRecord, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_page_history_record WHERE user_id=? AND router = '/api/report/industry/ArticleList?PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=`+strconv.Itoa(industrialManagementId)+ `' ORDER BY create_time DESC LIMIT 1,1 `
+	err = o.Raw(sql, userId).QueryRow(&item)
+	return
+}
+
+func GetTimeLineRecordAllCount(userId int, date string) (items []*CygxPageHistoryRecord, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_page_history_record WHERE user_id=? AND router LIKE '%/api/report/industry/ArticleList?PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=%' AND create_time > ? `
+	_, err = o.Raw(sql, userId, date).QueryRows(&items)
+	return
 }

+ 29 - 2
models/report.go

@@ -4,6 +4,8 @@ import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"strconv"
+	"time"
+
 	//"github.com/rdlucklib/rdluck_tools/paging"
 )
 
@@ -159,7 +161,8 @@ WHERE
 //获取最新文章
 func GetNewIndustrialUserRecordArticle(industrialManagementId, categoryId int) (item *ArticleDetail, err error) {
 	o := orm.NewOrm()
-	sql := ` SELECT * FROM cygx_article WHERE article_id IN (SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id = ? ) AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ? ) ORDER BY publish_date DESC LIMIT 0, 1`
+	//sql := ` SELECT * FROM cygx_article WHERE article_id IN (SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id = ? ) AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ? ) ORDER BY publish_date DESC LIMIT 0, 1`
+	sql := ` SELECT * FROM cygx_article WHERE article_id IN (SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id = ? ) AND category_id = ? ORDER BY publish_date DESC LIMIT 0, 1`
 	err = o.Raw(sql, industrialManagementId, categoryId).QueryRow(&item)
 	return
 }
@@ -894,7 +897,7 @@ FROM
 	SELECT
 		mmc.id,
 		'' AS title,
-		mm.meeting_time AS publish_time,
+		mm.publish_time AS publish_time,
 		'' AS video_url,
 		'时间线' AS sub_category_name,
 		mmc.content,
@@ -919,3 +922,27 @@ type ArticleIdReq struct {
 	PlaySeconds int    `description:"播放时长"`
 	PageRouter  string `description:"页面路径"`
 }
+
+type IndustrialReadNum struct {
+	IndustrialManagementId int `description:"产业id"`
+	Readnum                int `description:"阅读次数"`
+}
+
+//获取该产业下文章的用户阅读次数-小红点用
+func GetReportIndustrialReadNumList(userId int, industrialIds string, createtime time.Time) (items []*IndustrialReadNum, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT a.industrial_management_id, MIN(a.readnum) AS readnum FROM (
+SELECT man_g.industrial_management_id,( SELECT COUNT( 1 ) FROM cygx_article_history_record AS rec WHERE rec.user_id = ` + strconv.Itoa(userId) + ` AND rec.article_id = a.article_id ) AS readnum 
+FROM
+	cygx_article AS a 
+	INNER JOIN cygx_industrial_article_group_management as man_g ON man_g.article_id = a.article_id
+WHERE
+	a.publish_status = 1 
+	AND a.is_class = 1
+	AND man_g.industrial_management_id IN (` + industrialIds + `)  
+	AND a.publish_date > ? 
+GROUP BY a.article_id ORDER BY publish_date DESC
+) AS a GROUP BY industrial_management_id`
+	_, err = o.Raw(sql, createtime).QueryRows(&items)
+	return
+}

+ 68 - 14
services/industrial_management.go

@@ -6,6 +6,7 @@ import (
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
+	"strconv"
 	"strings"
 	"time"
 )
@@ -395,26 +396,77 @@ func HandleIndustryList(list []*models.IndustrialManagement, user *models.WxUser
 		}
 	}
 
-	mapHistroyArticleId := make(map[int]int)
+	//mapHistroyArticleId := make(map[int]int)
 
-	if userId > 0 {
-		listArticleHistory, e := models.GetUserToArticleHistory(userId, articleIdArr)
-		if e != nil && e.Error() != utils.ErrNoRow() {
-			err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
-			return
-		}
-		for _, v := range listArticleHistory {
-			mapHistroyArticleId[v.ArticleId] = v.ArticleId
-		}
+	//if userId > 0 {
+	//	listArticleHistory, e := models.GetUserToArticleHistory(userId, articleIdArr)
+	//	if e != nil && e.Error() != utils.ErrNoRow() {
+	//		err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
+	//		return
+	//	}
+	//	for _, v := range listArticleHistory {
+	//		mapHistroyArticleId[v.ArticleId] = v.ArticleId
+	//	}
+	//}
+	var industrialIds string
+	for _, id := range industrialIdArr {
+		industrialIds += strconv.Itoa(id) + ","
+	}
+	industrialIds = strings.TrimRight(industrialIds, ",")
+	articleList, err := models.GetReportIndustrialReadNumList(userId, industrialIds, user.CreatedTime)
+	mapHistroyindustrialId := make(map[int]int)
+	for _, v := range articleList {
+		mapHistroyindustrialId[v.IndustrialManagementId] = v.Readnum
 	}
 	nowTime := time.Now().Local()
 	threeMonBefore := nowTime.AddDate(0, -3, 0)
+
+	//查询用户今天是否看过时间线
+	//haveMorningMeeting := false
+	//var morningMeetingTime string
+	recrodList, err := models.GetTimeLineRecordAllCount(user.UserId, time.Now().Format(utils.FormatDate))
+	if err != nil {
+		return
+	}
+	var industrialManagementIdstr string
+	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.Before(v.CreateTime) {
+				industrialIdMap[industrialManagementIdstr] = v.CreateTime
+			}
+		}else {
+			industrialIdMap[industrialManagementIdstr] = v.CreateTime
+		}
+	}
+
+	mmList, err := models.GetCygxMorningMeetingReviewsListByIndustrialIds(industrialIds)
+	if err != nil {
+		return
+	}
+	morningMeetingTimeMap := make(map[int]time.Time)
+	for _, v := range mmList {
+		morningMeetingTimeMap[v.IndustryId] = v.CreateTime
+	}
+	timeLineRedMap := make(map[int]bool, 0)
+
+	for _, industrialId := range industrialIdArr {
+		if createTime, ok := industrialIdMap[strconv.Itoa(industrialId)]; ok{
+			if createTime.Before(morningMeetingTimeMap[industrialId]) {
+				timeLineRedMap[industrialId] = true
+			}
+		}
+	}
+
 	for k, v := range list {
 		list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
 		if userId > 0 {
 			//如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
-			if mapHistroyArticleId[v.ArticleId] == 0 && user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
-				list[k].IsRed = true
+			if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
+				if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
+					list[k].IsRed = true
+				}
 			}
 		} else {
 			if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
@@ -426,8 +478,10 @@ func HandleIndustryList(list []*models.IndustrialManagement, user *models.WxUser
 		list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
 		if userId > 0 {
 			//如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
-			if mapHistroyArticleId[v.ArticleId] == 0 && user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
-				list[k].IsRed = true
+			if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
+				if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
+					list[k].IsRed = true
+				}
 			}
 		} else {
 			if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {