Browse Source

Merge branch 'cygx_13.8' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai 6 months ago
parent
commit
ebecdb5bc8
5 changed files with 89 additions and 3 deletions
  1. 8 0
      models/article.go
  2. 1 1
      models/ficc_report/report.go
  3. 36 0
      models/resource_data.go
  4. 43 2
      services/ficc_report.go
  5. 1 0
      services/resource_data.go

+ 8 - 0
models/article.go

@@ -1041,3 +1041,11 @@ func GetCygxCygxArticleListByReportIds(reportIds []int) (items []*CygxArticle, e
 	_, err = o.Raw(sql, pars, 0, lenArr).QueryRows(&items)
 	return
 }
+
+// 已经同步到查研的FICC研报列表
+func GetCygxCygxArticleFiccReportList() (items []*CygxArticle, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT article_id ,report_id FROM cygx_article as art WHERE report_id > 0 `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 1 - 1
models/ficc_report/report.go

@@ -136,7 +136,7 @@ func GetByReportId(reportId int) (item *Report, err error) {
 
 func GetFiccRreportToCygxArticle(condition string, pars []interface{}) (items []*Report, err error) {
 	o := orm.NewOrmUsingDB("rddp")
-	sql := ` SELECT	* FROM report WHERE state = 2
+	sql := ` SELECT	* FROM report WHERE state = 2 AND  is_public_publish = 1 
 			AND classify_name_first IN ('宏观报告','晨会纪要','调研纪要')
 			AND classify_name_second IN ('大类资产周报','晨会纪要','黑色调研')
 			AND IF ( classify_name_first = '宏观报告' , classify_name_second = '大类资产周报' ,1=1 )

+ 36 - 0
models/resource_data.go

@@ -3,6 +3,7 @@ package models
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_cygx/utils"
 	"time"
 )
 
@@ -180,3 +181,38 @@ func GetCygxResourceDataBySourceAndIdCount(sourceId int, source string) (count i
 	err = o.Raw(sqlCount, sourceId, source).QueryRow(&count)
 	return
 }
+
+// 隐藏同步过来的报告
+func HideCygxResourceDataFiccReport(sourceIds []int) (err error) {
+	lenArr := len(sourceIds)
+	if lenArr == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	to, err := o.Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err != nil {
+			_ = to.Rollback()
+		} else {
+			_ = to.Commit()
+		}
+	}()
+	//隐藏资源表
+	sql := ` UPDATE cygx_resource_data SET is_hide= 1  WHERE source_id IN (` + utils.GetOrmInReplace(lenArr) + `)  AND source = ? `
+	_, err = to.Raw(sql, sourceIds, utils.CYGX_OBJ_FICC_REPORT).Exec()
+	if err != nil {
+		return
+	}
+
+	//对应文章取消发布
+	sql = ` UPDATE cygx_article SET publish_status= 0  WHERE report_id IN (` + utils.GetOrmInReplace(lenArr) + `) `
+	_, err = to.Raw(sql, sourceIds, utils.CYGX_OBJ_FICC_REPORT).Exec()
+	if err != nil {
+		return
+	}
+
+	return
+}

+ 43 - 2
services/ficc_report.go

@@ -457,13 +457,13 @@ func GetFiccRreportToCygxArticle() (err error) {
 	for _, v := range reportList {
 		reportIds = append(reportIds, v.Id)
 	}
-	listaFiccReport, e := models.GetCygxCygxArticleListByReportIds(reportIds)
+	listFiccReport, e := models.GetCygxCygxArticleListByReportIds(reportIds)
 	if e != nil {
 		err = errors.New("GetCygxCygxArticleListByReportIds, Err: " + e.Error())
 		return
 	}
 	mapFiccReport := make(map[int]int)
-	for _, v := range listaFiccReport {
+	for _, v := range listFiccReport {
 		mapFiccReport[v.ReportId] = v.ArticleId
 	}
 
@@ -533,6 +533,47 @@ func GetFiccRreportToCygxArticle() (err error) {
 
 		AddCygxReportMappingCategoryGroupByArticleId(articleIdMax)
 	}
+
+	//获取已经同步到查研的FICC研报 对比,如果FICC研报已经取消发布,查研也做对应的删除
+	listCygxFiccReport, e := models.GetCygxCygxArticleFiccReportList()
+	if e != nil {
+		err = errors.New("GetCygxCygxArticleFiccReportList, Err: " + e.Error())
+		return
+	}
+	var cygxFiccReportIds []int
+	for _, v := range listCygxFiccReport {
+		cygxFiccReportIds = append(cygxFiccReportIds, v.ReportId)
+	}
+	lenArr := len(cygxFiccReportIds)
+	if lenArr == 0 {
+		return
+	}
+	condition = ` AND id IN (` + utils.GetOrmInReplace(lenArr) + `) `
+	pars = append(pars, cygxFiccReportIds)
+	ficcReportListPush, e := ficc_report.GetFiccRreportToCygxArticle(condition, pars)
+	if e != nil {
+		err = errors.New("GetFiccRreportToCygxArticle, Err: " + e.Error())
+		return
+	}
+	var removeficcReporIds []int           // 需要移除的报告ID
+	ficcReporIdsPush := make(map[int]bool) // Ficc 研报还存在的报告ID
+	for _, v := range ficcReportListPush {
+		ficcReporIdsPush[v.Id] = true
+	}
+
+	for _, v := range listCygxFiccReport {
+		if !ficcReporIdsPush[v.ReportId] {
+			removeficcReporIds = append(removeficcReporIds, v.ReportId)
+		}
+	}
+	if len(removeficcReporIds) > 0 {
+		e = models.HideCygxResourceDataFiccReport(removeficcReporIds)
+		if e != nil {
+			err = errors.New("HideCygxResourceDataFiccReport, Err: " + e.Error())
+			return
+		}
+	}
+
 	fmt.Println("end")
 	return
 }

+ 1 - 0
services/resource_data.go

@@ -471,6 +471,7 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 			//fmt.Println(v.ArticleId)
 			v.Body = ""
 			v.BodyHtml = ""
+			v.Source = 0 //配合前端这里强制改为 0
 			//v.Source = utils.CYGX_OBJ_YANXUANSPECIAL
 			mapItems[fmt.Sprint("ficcreport", v.ReportId)].FiccReport = v
 		}