浏览代码

no message

zhangchuanxing 2 天之前
父节点
当前提交
f29336ba2c
共有 3 个文件被更改,包括 70 次插入0 次删除
  1. 3 0
      controllers/cygx/report_selection.go
  2. 8 0
      models/cygx/report_selection.go
  3. 59 0
      services/cygx/report_selection.go

+ 3 - 0
controllers/cygx/report_selection.go

@@ -208,6 +208,7 @@ func (this *ReportSelectionController) PreserveAndPublish() {
 	//	existMap[v.ChartPermissionId] = v.ChartPermissionId
 	//}
 	go cygxService.UpdateReportSelectionResourceData(req.ArticleId) //首页最新页面数据逻辑处理 V11.1.1
+	go cygxService.UpdateReportSelectionSubjectNameList()           //获取报告精选最新一期标的名称
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"
@@ -582,6 +583,7 @@ func (this *ReportSelectionController) PublishAndCancel() {
 		return
 	}
 	go cygxService.UpdateReportSelectionResourceData(articleId) //首页最新页面数据逻辑处理 V11.1.1
+	go cygxService.UpdateReportSelectionSubjectNameList()       //获取报告精选最新一期标的名称
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"
@@ -969,6 +971,7 @@ func (this *ReportSelectionController) VisibleRange() {
 		return
 	}
 	go cygxService.UpdateReportSelectionResourceData(articleId) //首页最新页面数据逻辑处理 V11.1.1
+	go cygxService.UpdateReportSelectionSubjectNameList()       //获取报告精选最新一期标的名称
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"

+ 8 - 0
models/cygx/report_selection.go

@@ -370,3 +370,11 @@ func GetArticleInfoByIdAndTable(table string, articleId int) (item *CygxArticleI
 	err = o.Raw(sql, articleId).QueryRow(&item)
 	return
 }
+
+// 获取最新一期
+func GetCygxReportSelectionInfoBestNew() (item *CygxReportSelectionRep, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT * FROM cygx_report_selection WHERE   publish_status = 1  ORDER BY  article_id  DESC  LIMIT  1  `
+	err = o.Raw(sql).QueryRow(&item)
+	return
+}

+ 59 - 0
services/cygx/report_selection.go

@@ -0,0 +1,59 @@
+package cygx
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hz_crm_api/models/cygx"
+	"hongze/hz_crm_api/services/alarm_msg"
+	"strings"
+	"time"
+)
+
+//func init() {
+//	UpdateReportSelectionSubjectNameList()
+//}
+
+// 获取报告精选最新一期标的名称
+func UpdateReportSelectionSubjectNameList() {
+	time.Sleep(2 * time.Second)
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println("err:", err)
+			go alarm_msg.SendAlarmMsg("获取报告精选最新一期标的名称,UpdateReportSelectionSubjectNameList Err:"+err.Error(), 3)
+		}
+	}()
+	detail, e := cygx.GetCygxReportSelectionInfoBestNew()
+	if e != nil {
+		err = errors.New("GetCygxReportSelectionInfoBestNew, Err: " + e.Error())
+		return
+	}
+
+	articleId := detail.ArticleId
+	listSelectionLog, e := cygx.GetReportSelectionlogListAll(articleId)
+	if e != nil {
+		err = errors.New("GetReportSelectionlogListAll, Err: " + e.Error())
+		return
+	}
+
+	var keyNames []string
+	for _, v := range listSelectionLog {
+		if v.ThirdName != "" {
+			keyNames = append(keyNames, v.ThirdName)
+		} else if v.SubjectName != "" {
+			keyNames = append(keyNames, v.SubjectName)
+		} else {
+			keyNames = append(keyNames, v.IndustrialManagementNames)
+		}
+	}
+
+	keyNameStr := strings.Join(keyNames, ",")
+	keyNameStr = strings.Replace(keyNameStr, "/", ",", -1)
+	e = cygx.CygxConfigUpdateByCode(keyNameStr, "cygx_report_selection_subject")
+	if e != nil {
+		err = errors.New("CygxConfigUpdateByCode, Err: " + e.Error())
+		return
+	}
+	return
+
+}