Browse Source

no message

xingzai 1 year ago
parent
commit
81aeeb9182

+ 3 - 36
controllers/cygx/report_selection.go

@@ -168,38 +168,9 @@ func (this *ReportSelectionController) PreserveAndPublish() {
 			return
 		}
 	}
-	if req.DoType == 1 {
-		//cygxService.DoThisWeekLastWeekWxTemplateMsg(itemCrs.Title, itemCrs.PublishDate.Format(utils.FormatDateTime), itemCrs.ProductDescription, req.ArticleId, 1)
-	}
-	//生成音频文件
-	//articleId := req.ArticleId
-	//existMap := make(map[int]int)
-	//var content string
-	//content = "产品说明" + req.ProductDescription + "变更说明" + req.UpdateDescription + "近期重点关注方向" + req.FocusOn
-	//listLog, err := cygx.GetReportSelectionlogListAll(articleId)
-	//if err != nil {
-	//	br.Msg = "获取失败"
-	//	br.ErrMsg = "获取失败,Err:" + err.Error()
-	//	return
-	//}
-	//for _, v := range listLog {
-	//	if existMap[v.ChartPermissionId] == 0 {
-	//		content += v.PermissionName + "领域深度调研和报告"
-	//		listSonLog, err := cygx.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
-	//		if err != nil && err.Error() != utils.ErrNoRow() {
-	//			br.Msg = "获取信息失败"
-	//			br.ErrMsg = "获取信息失败,Err:" + err.Error()
-	//			return
-	//		}
-	//		if len(listSonLog) > 0 {
-	//			for _, v2 := range listSonLog {
-	//				content += v2.SubjectName + v2.Body
-	//			}
-	//		}
-	//	}
-	//	existMap[v.ChartPermissionId] = v.ChartPermissionId
+	//if req.DoType == 1 {
+	//cygxService.DoThisWeekLastWeekWxTemplateMsg(itemCrs.Title, itemCrs.PublishDate.Format(utils.FormatDateTime), itemCrs.ProductDescription, req.ArticleId, 1)
 	//}
-	//go services.CreateVideoWhithContent(articleId, req.Title, content, "cygx_report_selection")
 
 	br.Ret = 200
 	br.Success = true
@@ -341,11 +312,6 @@ func (this *ReportSelectionController) Detail() {
 			}
 		}
 	}
-	if err != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取失败,Err:" + err.Error()
-		return
-	}
 
 	//获取关联的文章信息
 	mapArticle := make(map[int]string)
@@ -936,6 +902,7 @@ func (this *ReportSelectionController) VisibleRange() {
 		br.ErrMsg = "操作失败,Err:" + err.Error()
 		return
 	}
+	cygxService.UpdateReportSelectionResourceData(articleId) //首页最新页面数据逻辑处理 V11.1.1
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"

+ 26 - 11
models/cygx/cygx_report_mapping.go

@@ -91,15 +91,30 @@ func GetMatchTypeNameByPermissionId(permissionId int) (item *ReportMappingRep, e
 
 func GetMatchTypeNameByKeyword(keyWord string) (items []*CygxReportMapping, err error) {
 	o := orm.NewOrm()
-	sql := ` SELECT
-	* 
-FROM
-( SELECT sub_category_name FROM cygx_report_mapping UNION 
-SELECT "晨会精华" AS sub_category_name UNION 
-SELECT "路演精华" AS sub_category_name UNION 
-SELECT article_type_name AS sub_category_name FROM cygx_article_type ) AS a
-WHERE
-	a.sub_category_name LIKE '%` + keyWord + `%' `
-	_,err = o.Raw(sql).QueryRows(&items)
+	sql := `SELECT
+			* 
+		FROM
+			(
+			SELECT
+				match_type_name 
+			FROM
+				cygx_report_mapping_cygx UNION
+			SELECT
+				"晨会精华" AS sub_category_name UNION
+			SELECT
+				"路演精华" AS sub_category_name UNION
+			SELECT
+				"重点公司" AS sub_category_name UNION
+			SELECT
+				"本周研究汇总" AS sub_category_name UNION
+			SELECT
+				"上周纪要汇总" AS sub_category_name UNION
+			SELECT
+				article_type_name AS sub_category_name 
+			FROM
+			cygx_article_type 
+			) AS a
+		WHERE a.sub_category_name LIKE '%` + keyWord + `%' `
+	_, err = o.Raw(sql).QueryRows(&items)
 	return
-}
+}

+ 12 - 3
models/cygx/resource_data.go

@@ -14,16 +14,17 @@ type CygxResourceData struct {
 	CreateTime  time.Time `description:"创建时间"`
 	PublishDate string    `description:"发布时间"`
 	Abstract    string    `description:"摘要"`
+	SearchTag   string    `description:"搜索标签"`
 }
 
-//添加
+// 添加
 func AddCygxResourceData(item *CygxResourceData) (lastId int64, err error) {
 	o := orm.NewOrm()
 	lastId, err = o.Insert(item)
 	return
 }
 
-//删除数据
+// 删除数据
 func DeleteResourceData(sourceId int, source string) (err error) {
 	o := orm.NewOrm()
 	sql := ` DELETE FROM cygx_resource_data WHERE source_id = ? AND source =?  `
@@ -31,10 +32,18 @@ func DeleteResourceData(sourceId int, source string) (err error) {
 	return
 }
 
-//修改数据
+// 修改数据
 func UpdateResourceData(sourceId int, source, publishDate string) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE cygx_resource_data SET publish_date=?  WHERE source_id=?  AND source =? `
 	_, err = o.Raw(sql, publishDate, sourceId, source).Exec()
 	return
 }
+
+// 获取数量
+func GetCygxReportSelectionBySourceAndId(sourceId int, source string) (count int, err error) {
+	o := orm.NewOrm()
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_resource_data  WHERE  source_id = ? AND source =?  `
+	err = o.Raw(sqlCount, sourceId, source).QueryRow(&count)
+	return
+}

+ 66 - 0
services/cygx/resource_data.go

@@ -0,0 +1,66 @@
+package cygx
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hz_crm_api/models/cygx"
+	"hongze/hz_crm_api/services/alarm_msg"
+	"hongze/hz_crm_api/utils"
+	"strconv"
+	"strings"
+	"time"
+)
+
+//首页最新页面数据逻辑处理
+
+// 更新报告精选(重点公司)
+func UpdateReportSelectionResourceData(sourceId int) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println("err:", err)
+			go alarm_msg.SendAlarmMsg("更新报告精选(重点公司) 失败,UpdateReportSelectionResourceData Err:"+err.Error()+"资源ID"+strconv.Itoa(sourceId), 3)
+		}
+	}()
+	var source = utils.CYGX_OBJ_REPORTSELECTION
+	var condition string
+	var pars []interface{}
+	condition = ` AND visible_range = 1 `
+	total, e := cygx.GetCygxReportSelection(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxReportSelection, Err: " + err.Error())
+		return
+	}
+	//如果取消发布了就做删除处理
+	if total == 0 {
+		e = cygx.DeleteResourceData(sourceId, source)
+		if e != nil {
+			err = errors.New("DeleteResourceData, Err: " + err.Error())
+			return
+		}
+	} else {
+		//判断是否存在,如果不存在就新增,存在就更新
+		totalData, e := cygx.GetCygxReportSelectionBySourceAndId(sourceId, source)
+		if e != nil {
+			err = errors.New("GetCygxReportSelection, Err: " + err.Error())
+			return
+		}
+		detail, e := cygx.GetCygxReportSelectionInfoById(sourceId)
+		if e != nil {
+			err = errors.New("GetCygxReportSelectionInfoById, Err: " + err.Error())
+			return
+		}
+		publishDate := detail.PublishDate
+		if totalData == 0 {
+			item := new(cygx.CygxResourceData)
+			item.SourceId = sourceId
+			item.Source = source
+			item.SearchTag = "重点公司"
+			item.PublishDate = publishDate
+			item.CreateTime = time.Now()
+			_, err = cygx.AddCygxResourceData(item)
+		} else {
+			err = cygx.UpdateResourceData(sourceId, source, publishDate)
+		}
+	}
+	return
+}

+ 1 - 1
utils/constants.go

@@ -411,9 +411,9 @@ const (
 	CYGX_OBJ_ACTIVITYSPECIAL    string = "activityspecial"    // 对象类型:专项调研活动
 	CYGX_OBJ_MEETINGREVIEWCHAPT string = "meetingreviewchapt" // 对象类型:晨会精华
 	CYGX_OBJ_ROADSHOW           string = "roadshow"           // 对象类型:路演
+	CYGX_OBJ_REPORTSELECTION    string = "reportselection"    // 对象类型:报告精选(重点公司)
 )
 
-
 const (
 	SendTemplateMsgAuthorization = "dc855fce962a639faa779cbdd4cd332f"
 )