|
@@ -6,7 +6,6 @@ import (
|
|
"errors"
|
|
"errors"
|
|
"fmt"
|
|
"fmt"
|
|
"github.com/PuerkitoBio/goquery"
|
|
"github.com/PuerkitoBio/goquery"
|
|
- "github.com/beego/beego/v2/client/orm"
|
|
|
|
"hongze/hongze_cygx/models"
|
|
"hongze/hongze_cygx/models"
|
|
"hongze/hongze_cygx/models/company"
|
|
"hongze/hongze_cygx/models/company"
|
|
"hongze/hongze_cygx/utils"
|
|
"hongze/hongze_cygx/utils"
|
|
@@ -17,34 +16,8 @@ import (
|
|
"strconv"
|
|
"strconv"
|
|
"strings"
|
|
"strings"
|
|
"time"
|
|
"time"
|
|
- "unicode/utf8"
|
|
|
|
)
|
|
)
|
|
|
|
|
|
-func GetReportContentSub(content string) (contentSub string, err error) {
|
|
|
|
- content = html.UnescapeString(content)
|
|
|
|
- doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("create doc err:", err.Error())
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- n := 0
|
|
|
|
- doc.Find("p").Each(func(i int, s *goquery.Selection) {
|
|
|
|
- if n > 3 {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- n++
|
|
|
|
- phtml, err := s.Html()
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("get html err", err.Error())
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- if s.Text() != "" || strings.Contains(phtml, "src") {
|
|
|
|
- contentSub = contentSub + "<p>" + phtml + "</p>"
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
func GetReportContentTextSub(content string) (contentSub string, err error) {
|
|
func GetReportContentTextSub(content string) (contentSub string, err error) {
|
|
content = html.UnescapeString(content)
|
|
content = html.UnescapeString(content)
|
|
doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))
|
|
doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))
|
|
@@ -78,233 +51,6 @@ func GetReportContentTextSubNew(content string) (contentSub string, err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-// GetReportContentTextSubByarticle 解析文章内容
|
|
|
|
-func GetReportContentTextSubByarticle(content, abstract string, articleId int) (contentSub string, err error) {
|
|
|
|
- var lenabstract int
|
|
|
|
- //如果不是研选就这么展示
|
|
|
|
- if articleId < utils.SummaryArticleId {
|
|
|
|
- abstract = html.UnescapeString(abstract)
|
|
|
|
- doc, errdoc := goquery.NewDocumentFromReader(strings.NewReader(abstract))
|
|
|
|
- if errdoc != nil {
|
|
|
|
- err = errdoc
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- docabstract := doc.Text()
|
|
|
|
- lenabstract = utf8.RuneCountInString(docabstract)
|
|
|
|
- if lenabstract >= 20 {
|
|
|
|
- contentSub = docabstract
|
|
|
|
- return
|
|
|
|
- } else {
|
|
|
|
- contentSub, err = GetReportContentTextSubNew(content)
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- contentSub, err = GetReportContentTextSubNew(content)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return
|
|
|
|
-
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// 解析文章内容
|
|
|
|
-func GetArticleAll() {
|
|
|
|
- var err error
|
|
|
|
- defer func() {
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("err:", err.Error())
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- }()
|
|
|
|
- list, err := models.GetArticleAll()
|
|
|
|
- if err != nil {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- for _, v := range list {
|
|
|
|
- fmt.Println(v.ArticleId, v.Title)
|
|
|
|
- FixArticleContent(v.ArticleId)
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// 解析报告
|
|
|
|
-func FixArticleContent(articleId int) {
|
|
|
|
- item, err := models.GetArticleDetailById(articleId)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("GetArticleDetailById Err:" + err.Error())
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- content := item.Body
|
|
|
|
- bodyText, _ := GetReportContentTextSub(content)
|
|
|
|
- content = html.UnescapeString(content)
|
|
|
|
-
|
|
|
|
- content = strings.Replace(content, "http", "https", -1)
|
|
|
|
-
|
|
|
|
- doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("create doc err:", err.Error())
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var expertNumArr []string
|
|
|
|
- var expertContentArr []string
|
|
|
|
- var interviewDateArr []string
|
|
|
|
-
|
|
|
|
- doc.Find("p").Each(func(i int, s *goquery.Selection) {
|
|
|
|
- contentTxt := s.Text()
|
|
|
|
- if strings.Contains(contentTxt, "#访谈时间:") || strings.Contains(contentTxt, "访谈时间:") {
|
|
|
|
- interviewDate := s.Next().Text()
|
|
|
|
- interviewDateArr = append(interviewDateArr, interviewDate)
|
|
|
|
- }
|
|
|
|
- if strings.Contains(contentTxt, "#专家评价") || strings.Contains(contentTxt, "专家评价") {
|
|
|
|
- expertContent := s.Next().Text()
|
|
|
|
- if expertContent == "" {
|
|
|
|
- expertContent = contentTxt
|
|
|
|
- }
|
|
|
|
- if expertContent != "" {
|
|
|
|
- rightIndex := strings.Index(expertContent, ")")
|
|
|
|
- if rightIndex == 0 {
|
|
|
|
- rightIndex = strings.Index(expertContent, ")")
|
|
|
|
- }
|
|
|
|
- if rightIndex > 0 {
|
|
|
|
- expertNum := expertContent[:rightIndex]
|
|
|
|
- expertNum = strings.Replace(expertNum, "(", "", -1)
|
|
|
|
- expertNum = strings.Replace(expertNum, "(", "", -1)
|
|
|
|
- expertNum = strings.Replace(expertNum, "专家评价", "", -1)
|
|
|
|
- if expertNum != "" {
|
|
|
|
- expertNumArr = append(expertNumArr, expertNum)
|
|
|
|
- rightIndex = rightIndex
|
|
|
|
- expertContentStr := expertContent[rightIndex:]
|
|
|
|
- expertContentStr = strings.Replace(expertContentStr, ")", "", -1)
|
|
|
|
- expertContentStr = strings.TrimLeft(expertContentStr, ":")
|
|
|
|
- expertContentStr = strings.TrimRight(expertContentStr, "(推荐")
|
|
|
|
- expertContentArr = append(expertContentArr, expertContentStr)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
- if len(expertContentArr) <= 0 {
|
|
|
|
- doc.Find("pre").Each(func(i int, pre *goquery.Selection) {
|
|
|
|
- pre.Find("span").Each(func(n int, span *goquery.Selection) {
|
|
|
|
- contentTxt := span.Text()
|
|
|
|
- if strings.Contains(contentTxt, "#专家评价") || strings.Contains(contentTxt, "专家评价") {
|
|
|
|
- span.Find("span").Each(func(m int, subspan *goquery.Selection) {
|
|
|
|
- subspanText := subspan.Text()
|
|
|
|
- if strings.Contains(subspanText, "专家评价") {
|
|
|
|
- expertContent := subspan.Next().Text()
|
|
|
|
- if expertContent != "" {
|
|
|
|
- rightIndex := strings.Index(expertContent, ")")
|
|
|
|
- if rightIndex == 0 {
|
|
|
|
- rightIndex = strings.Index(expertContent, ")")
|
|
|
|
- }
|
|
|
|
- if rightIndex > 0 {
|
|
|
|
- expertNum := expertContent[:rightIndex]
|
|
|
|
- expertNum = strings.Replace(expertNum, "(", "", -1)
|
|
|
|
- expertNum = strings.Replace(expertNum, "(", "", -1)
|
|
|
|
- expertNum = strings.Replace(expertNum, "专家评价", "", -1)
|
|
|
|
- if expertNum != "" {
|
|
|
|
- expertNumArr = append(expertNumArr, expertNum)
|
|
|
|
- rightIndex = rightIndex
|
|
|
|
- expertContentStr := expertContent[rightIndex:]
|
|
|
|
- expertContentStr = strings.Replace(expertContentStr, ")", "", -1)
|
|
|
|
- expertContentStr = strings.TrimLeft(expertContentStr, ":")
|
|
|
|
- expertContentStr = strings.TrimRight(expertContentStr, "(推荐")
|
|
|
|
- expertContentArr = append(expertContentArr, expertContentStr)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- span.Find("span").Each(func(k int, sspan *goquery.Selection) {
|
|
|
|
- sspanText := sspan.Text()
|
|
|
|
- if strings.Contains(sspanText, "访谈时间") {
|
|
|
|
- sspanText = strings.Replace(sspanText, "#访谈时间:", "", -1)
|
|
|
|
- sspanText = strings.Replace(sspanText, "访谈时间:", "", -1)
|
|
|
|
- sspanText = strings.Replace(sspanText, "\n", "", -1)
|
|
|
|
- sspanText = strings.Replace(sspanText, " ", "", -1)
|
|
|
|
- sspanText = strings.Trim(sspanText, " ")
|
|
|
|
- sspanText = sspanText[:10]
|
|
|
|
- interviewDate := sspanText
|
|
|
|
- if interviewDate != "" {
|
|
|
|
- interviewDateArr = append(interviewDateArr, interviewDate)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- })
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if len(expertContentArr) <= 0 {
|
|
|
|
- doc.Find("span").Each(func(i int, span *goquery.Selection) {
|
|
|
|
- span.Find("strong").Each(func(n int, strong *goquery.Selection) {
|
|
|
|
- spanText := span.Text()
|
|
|
|
- strongText := strong.Text()
|
|
|
|
- if strings.Contains(strongText, "#专家评价") || strings.Contains(strongText, "专家评价") {
|
|
|
|
- expertContent := strong.Parents().Text()
|
|
|
|
- if expertContent != "" {
|
|
|
|
- rightIndex := strings.Index(expertContent, ")")
|
|
|
|
- if rightIndex == 0 {
|
|
|
|
- rightIndex = strings.Index(expertContent, ")")
|
|
|
|
- }
|
|
|
|
- if rightIndex > 0 {
|
|
|
|
- expertNum := expertContent[:rightIndex]
|
|
|
|
- expertNum = strings.Replace(expertNum, "(", "", -1)
|
|
|
|
- expertNum = strings.Replace(expertNum, "(", "", -1)
|
|
|
|
- expertNum = strings.Replace(expertNum, "专家评价", "", -1)
|
|
|
|
- expertNum = strings.Replace(expertNum, "#", "", -1)
|
|
|
|
- expertNum = strings.Replace(expertNum, ":", "", -1)
|
|
|
|
- expertNum = strings.Replace(expertNum, "\n", "", -1)
|
|
|
|
- if expertNum != "" {
|
|
|
|
- expertNumArr = append(expertNumArr, expertNum)
|
|
|
|
- rightIndex = rightIndex
|
|
|
|
- expertContentStr := expertContent[rightIndex:]
|
|
|
|
- expertContentStr = strings.Replace(expertContentStr, ")", "", -1)
|
|
|
|
- expertContentStr = strings.TrimLeft(expertContentStr, ":")
|
|
|
|
- expertContentStr = strings.TrimRight(expertContentStr, "(推荐")
|
|
|
|
- expertContentArr = append(expertContentArr, expertContentStr)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if strings.Contains(spanText, "访谈时间") {
|
|
|
|
- spanText = strings.Replace(spanText, "#访谈时间:", "", -1)
|
|
|
|
- spanText = strings.Replace(spanText, "访谈时间:", "", -1)
|
|
|
|
- spanText = strings.Replace(spanText, "\n", "", -1)
|
|
|
|
- spanText = strings.Replace(spanText, " ", "", -1)
|
|
|
|
- spanText = strings.Trim(spanText, " ")
|
|
|
|
- spanText = spanText[:10]
|
|
|
|
- interviewDate := spanText
|
|
|
|
- if interviewDate != "" {
|
|
|
|
- interviewDateArr = append(interviewDateArr, interviewDate)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var expertNumStr, expertContentStr, interviewDateStr string
|
|
|
|
- if len(expertNumArr) > 0 {
|
|
|
|
- expertNumStr = expertNumArr[0]
|
|
|
|
- }
|
|
|
|
- if len(expertContentArr) > 0 {
|
|
|
|
- expertContentStr = expertContentArr[0]
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if len(interviewDateArr) > 0 {
|
|
|
|
- interviewDateStr = interviewDateArr[0]
|
|
|
|
- }
|
|
|
|
- expertNumStr = strings.Replace(expertNumStr, "#:", "", -1)
|
|
|
|
- err = models.ModifyArticleExpert(articleId, expertNumStr, expertContentStr, interviewDateStr, bodyText)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("ModifyArticleExpert Err:" + err.Error())
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
func FixArticleImgUrl(body string) (contentSub string, err error) {
|
|
func FixArticleImgUrl(body string) (contentSub string, err error) {
|
|
r := strings.NewReader(string(body))
|
|
r := strings.NewReader(string(body))
|
|
doc, err := goquery.NewDocumentFromReader(r)
|
|
doc, err := goquery.NewDocumentFromReader(r)
|
|
@@ -321,21 +67,6 @@ func FixArticleImgUrl(body string) (contentSub string, err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-// 获取标签里的第一个内容
|
|
|
|
-func FixArticleFirstCount(body string) (contentSub string, err error) {
|
|
|
|
-
|
|
|
|
- doc, err := goquery.NewDocumentFromReader(strings.NewReader(body))
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("create doc err:", err.Error())
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- doc.Find("p").Each(func(i int, s *goquery.Selection) {
|
|
|
|
- contentTxt := s.Text()
|
|
|
|
- fmt.Println(contentTxt)
|
|
|
|
- })
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
func SynchronizationArtclehistory() {
|
|
func SynchronizationArtclehistory() {
|
|
fmt.Println("同步开始")
|
|
fmt.Println("同步开始")
|
|
list, err := models.GetArticleHistoryList()
|
|
list, err := models.GetArticleHistoryList()
|
|
@@ -371,138 +102,6 @@ func SynchronizationArtclehistory() {
|
|
fmt.Println("同步结束")
|
|
fmt.Println("同步结束")
|
|
}
|
|
}
|
|
|
|
|
|
-// 统计报表
|
|
|
|
-func StatisticalReport() {
|
|
|
|
- var isSummaryNumAll, isClassNum, pvNumAll, uvNumAll int
|
|
|
|
- list, err := models.GetChartPermissionActivity()
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("获取列表失败", err)
|
|
|
|
- }
|
|
|
|
- for _, v := range list {
|
|
|
|
- var listPv []*models.ReportMappingStatistical
|
|
|
|
- if v.PermissionName == "研选" {
|
|
|
|
- listPv, err = models.GetStatisticalReportArtilceExpert()
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("获取Pv列表失败", err)
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- listPv, err = models.GetStatisticalReportArtilce(v.ChartPermissionId)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("获取Pv列表失败", err)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- var pvNum, uvNum, isSummaryNum int
|
|
|
|
- for _, v2 := range listPv {
|
|
|
|
- pvNum += v2.Pv
|
|
|
|
- uvNum += v2.Uv
|
|
|
|
- if v2.IsSummary == "1" {
|
|
|
|
- isSummaryNum += 1
|
|
|
|
- }
|
|
|
|
- if v2.IsClass == "1" && v.ChartPermissionId <= 22 {
|
|
|
|
- isClassNum += 1
|
|
|
|
- }
|
|
|
|
- if v2.IsSummary == "1" && v.ChartPermissionId <= 22 {
|
|
|
|
- isSummaryNumAll += 1
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if v.ChartPermissionId <= 22 {
|
|
|
|
- pvNumAll += pvNum
|
|
|
|
- uvNumAll += uvNum
|
|
|
|
- }
|
|
|
|
- fmt.Println(v.PermissionName+"行业", len(listPv), "篇,其中主观类报告", isSummaryNum, "篇,客观类报告", len(listPv)-isSummaryNum, "篇。共产生阅读量pv-,", pvNum, ",uv-", uvNum)
|
|
|
|
- }
|
|
|
|
- fmt.Println("目前同步四大行业的总报告(已归类)数量", isClassNum, "篇,其中主观类报告", isSummaryNumAll, "篇,客观类报告", isClassNum-isSummaryNumAll, "篇。共产生阅读量pv-", pvNumAll, ",uv-", uvNumAll)
|
|
|
|
- var totalOnline int //线上
|
|
|
|
- var totalOffline int //线下
|
|
|
|
- var totalPeople int //共累计预约外呼人数
|
|
|
|
- var totalSignUpOff int //线下报名人数
|
|
|
|
- var totalSignUpOffTime int //线下报名人数
|
|
|
|
- var totalPeopleMeet int //线下参会人数
|
|
|
|
- o := orm.NewOrm()
|
|
|
|
- sql := `SELECT COUNT(1) FROM cygx_activity WHERE activity_type_id IN (1,2,3) AND publish_status = 1 AND is_submit_meeting = 1 AND activity_time <= NOW();`
|
|
|
|
- err = o.Raw(sql).QueryRow(&totalOnline)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("获取线上", err)
|
|
|
|
- }
|
|
|
|
- sql = `SELECT COUNT(1) FROM cygx_activity WHERE activity_type_id IN (4,5,6) AND publish_status = 1 AND is_submit_meeting = 1 AND activity_time <= NOW();`
|
|
|
|
- err = o.Raw(sql).QueryRow(&totalOffline)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("获取线下", err)
|
|
|
|
- }
|
|
|
|
- sql = `SELECT COUNT( 1 ) FROM
|
|
|
|
- cygx_activity_signup as s
|
|
|
|
- INNER JOIN cygx_activity as a ON a.activity_id = s.activity_id
|
|
|
|
- WHERE
|
|
|
|
- s.do_fail_type = 0
|
|
|
|
- AND a.is_submit_meeting = 1
|
|
|
|
- AND a.activity_time <= NOW()
|
|
|
|
- AND a.publish_status = 1`
|
|
|
|
- err = o.Raw(sql).QueryRow(&totalPeople)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("共累计预约外呼人数", err)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- sql = `SELECT COUNT( 1 ) FROM
|
|
|
|
- cygx_activity_signup as s
|
|
|
|
- INNER JOIN cygx_activity as a ON a.activity_id = s.activity_id
|
|
|
|
- WHERE
|
|
|
|
- s.do_fail_type = 0
|
|
|
|
- AND a.is_submit_meeting = 1
|
|
|
|
- AND a.activity_time <= NOW()
|
|
|
|
- AND a.activity_type_id IN (4,5,6)
|
|
|
|
- AND a.publish_status = 1`
|
|
|
|
- err = o.Raw(sql).QueryRow(&totalSignUpOff)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("共累计预约外呼人数", err)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- sql = `SELECT COUNT( 1 ) FROM
|
|
|
|
- cygx_activity_signup as s
|
|
|
|
- INNER JOIN cygx_activity as a ON a.activity_id = s.activity_id
|
|
|
|
- WHERE
|
|
|
|
- s.do_fail_type = 0
|
|
|
|
- AND a.publish_status = 1
|
|
|
|
- AND a.is_submit_meeting = 1
|
|
|
|
- AND a.activity_time <= NOW()
|
|
|
|
- AND a.is_submit_meeting = 1
|
|
|
|
- AND a.activity_type_id IN (4,5,6);`
|
|
|
|
- err = o.Raw(sql).QueryRow(&totalSignUpOffTime)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("线下报名参会人数", err)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- sql = `SELECT COUNT( 1 ) FROM
|
|
|
|
- cygx_activity_signup as s
|
|
|
|
- INNER JOIN cygx_activity as a ON a.activity_id = s.activity_id
|
|
|
|
- WHERE
|
|
|
|
- s.do_fail_type = 0
|
|
|
|
- AND a.is_submit_meeting = 1
|
|
|
|
- AND a.activity_time <= NOW()
|
|
|
|
- AND a.publish_status = 1
|
|
|
|
- AND s.is_meeting = 1
|
|
|
|
- AND a.activity_type_id IN (4,5,6);`
|
|
|
|
- err = o.Raw(sql).QueryRow(&totalPeopleMeet)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("线下参会人数", err)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- fmt.Println("共上线活动", totalOnline+totalOffline, "个,其中线上", totalOnline, "个,线下", totalOffline, "个")
|
|
|
|
- fmt.Println("共累计预约外呼人数", totalPeople, "人")
|
|
|
|
- fmt.Println("报名线下参会", totalSignUpOff, "人,实际到会人数", totalPeopleMeet, "人,线下到会率约", totalPeopleMeet*100/totalSignUpOff, "%")
|
|
|
|
-
|
|
|
|
- num := totalPeopleMeet / totalSignUpOffTime
|
|
|
|
- fmt.Println(num)
|
|
|
|
- fmt.Println(totalOnline)
|
|
|
|
- fmt.Println(totalOffline)
|
|
|
|
- fmt.Println(totalPeople)
|
|
|
|
- fmt.Println(totalSignUpOff)
|
|
|
|
- fmt.Println(totalPeopleMeet)
|
|
|
|
- fmt.Println(totalSignUpOffTime)
|
|
|
|
- fmt.Println(totalPeopleMeet / totalSignUpOffTime)
|
|
|
|
- return
|
|
|
|
-
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// UserViewRedisData 阅读数据
|
|
// UserViewRedisData 阅读数据
|
|
type UserViewRedisData struct {
|
|
type UserViewRedisData struct {
|
|
Mobile string `json:"mobile"`
|
|
Mobile string `json:"mobile"`
|
|
@@ -572,22 +171,12 @@ func PushViewRecordNewRedisData(reportViewRecord *ReportViewRecord, companyId in
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
|
|
|
|
-//func GetCeLueArticlePv() {
|
|
|
|
-// sum := 0
|
|
|
|
-// for i := 0; i <= 450; i++ {
|
|
|
|
-// if i >= 102 {
|
|
|
|
-// //GetCeLueArticlePvs(strconv.Itoa(i * 1000))
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// fmt.Println(sum)
|
|
|
|
-//}
|
|
|
|
-
|
|
|
|
// 获取策略平台报告阅读数据
|
|
// 获取策略平台报告阅读数据
|
|
func GetCeLueArticlePv(cont context.Context) (err error) {
|
|
func GetCeLueArticlePv(cont context.Context) (err error) {
|
|
//func GetCeLueArticlePv() (err error) {
|
|
//func GetCeLueArticlePv() (err error) {
|
|
defer func() {
|
|
defer func() {
|
|
if err != nil {
|
|
if err != nil {
|
|
- go utils.SendAlarmMsg("同步策略平台阅读数据失败", 2)
|
|
|
|
|
|
+ go utils.SendAlarmMsg("同步策略平台阅读数据失败"+err.Error(), 2)
|
|
go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "GetCeLueArticlePv ErrMsg:"+err.Error(), utils.EmailSendToUsers)
|
|
go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "GetCeLueArticlePv ErrMsg:"+err.Error(), utils.EmailSendToUsers)
|
|
}
|
|
}
|
|
}()
|
|
}()
|
|
@@ -803,22 +392,6 @@ func UpdateArticleByRedis() (err error) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-//func init() {
|
|
|
|
-// // allList, err := models.GetArticleAll()
|
|
|
|
-// //
|
|
|
|
-// // fmt.Println(err)
|
|
|
|
-// //
|
|
|
|
-// // for _, v := range allList {
|
|
|
|
-// // HandleArticleListByApi(v.ArticleId)
|
|
|
|
-// // }
|
|
|
|
-//
|
|
|
|
-// //for i := 8648; i < 9004; i++ {
|
|
|
|
-// // HandleArticleListByApi(9552)
|
|
|
|
-// //}
|
|
|
|
-// HandleArticleListByApi(10914)
|
|
|
|
-// //UpdateArticleResourceData(9551)
|
|
|
|
-//}
|
|
|
|
-
|
|
|
|
// 处理同步过来的文章
|
|
// 处理同步过来的文章
|
|
func HandleArticleListByApi(artcleId int) (err error) {
|
|
func HandleArticleListByApi(artcleId int) (err error) {
|
|
defer func() {
|
|
defer func() {
|
|
@@ -964,6 +537,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
|
|
item.Stock = stock
|
|
item.Stock = stock
|
|
}
|
|
}
|
|
item.FieldName = articleResult.Field.Name
|
|
item.FieldName = articleResult.Field.Name
|
|
|
|
+ item.SeriesName = articleResult.Series.Name
|
|
item.TypeName = articleResult.Type.Name
|
|
item.TypeName = articleResult.Type.Name
|
|
item.UpdateDate = articleResult.UpdateDate
|
|
item.UpdateDate = articleResult.UpdateDate
|
|
item.CeLueFieldId = articleResult.Field.Id
|
|
item.CeLueFieldId = articleResult.Field.Id
|
|
@@ -1097,7 +671,17 @@ func HandleArticleListByApi(artcleId int) (err error) {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
v.CategoryId = detailCategory.CategoryId
|
|
v.CategoryId = detailCategory.CategoryId
|
|
- v.IsSummary = 0
|
|
|
|
|
|
+ matchTypeName = "路演精华"
|
|
|
|
+ if v.IsClass == 0 {
|
|
|
|
+ v.IsSummary = 0
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ var chartPermissionId int
|
|
|
|
+ var chartPermissionName string
|
|
|
|
+ categoryDetail, _ := models.GetdetailByCategoryIdPush(v.CategoryId)
|
|
|
|
+ if categoryDetail != nil {
|
|
|
|
+ chartPermissionId = categoryDetail.ChartPermissionId
|
|
|
|
+ chartPermissionName = categoryDetail.ChartPermissionName
|
|
}
|
|
}
|
|
|
|
|
|
if count > 0 {
|
|
if count > 0 {
|
|
@@ -1109,13 +693,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
|
|
}
|
|
}
|
|
bodyTextOld, _ := GetReportContentTextSubNew(articleIfoOld.Body)
|
|
bodyTextOld, _ := GetReportContentTextSubNew(articleIfoOld.Body)
|
|
bodyText, _ := GetReportContentTextSubNew(v.Body)
|
|
bodyText, _ := GetReportContentTextSubNew(v.Body)
|
|
- if len(bodyText)-len(bodyTextOld) > 100 {
|
|
|
|
- //fmt.Println("触发推送规则")
|
|
|
|
- //更新字数大于一百字触发推送规则
|
|
|
|
- go DoArticleOnenIdWxTemplateMsg(v.ArticleId)
|
|
|
|
- go UpdateArticleResourceData(v.ArticleId) //把数据写入 cygx_resource_data 表
|
|
|
|
- //go UpdateResourceData(v.ArticleId, "article", "update", time.Now().Format(utils.FormatDateTime))
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
var isCustom bool
|
|
var isCustom bool
|
|
updateParams := make(map[string]interface{})
|
|
updateParams := make(map[string]interface{})
|
|
//updateParams["Title"] = v.Title
|
|
//updateParams["Title"] = v.Title
|
|
@@ -1154,18 +732,29 @@ func HandleArticleListByApi(artcleId int) (err error) {
|
|
updateParams["FileLink"] = v.File
|
|
updateParams["FileLink"] = v.File
|
|
updateParams["Stock"] = v.Stock
|
|
updateParams["Stock"] = v.Stock
|
|
updateParams["FieldName"] = v.FieldName
|
|
updateParams["FieldName"] = v.FieldName
|
|
|
|
+ updateParams["SeriesName"] = v.SeriesName
|
|
updateParams["Annotation"] = v.Annotation
|
|
updateParams["Annotation"] = v.Annotation
|
|
updateParams["TypeName"] = v.TypeName
|
|
updateParams["TypeName"] = v.TypeName
|
|
updateParams["ModifyTimeByCl"] = v.UpdateDate
|
|
updateParams["ModifyTimeByCl"] = v.UpdateDate
|
|
updateParams["CeLueFieldId"] = v.CeLueFieldId
|
|
updateParams["CeLueFieldId"] = v.CeLueFieldId
|
|
updateParams["Cover"] = v.Cover
|
|
updateParams["Cover"] = v.Cover
|
|
|
|
+ updateParams["ChartPermissionId"] = chartPermissionId
|
|
|
|
+ updateParams["ChartPermissionName"] = chartPermissionName
|
|
whereParam := map[string]interface{}{"article_id": v.ArticleId}
|
|
whereParam := map[string]interface{}{"article_id": v.ArticleId}
|
|
err = models.UpdateByExpr(models.CygxArticle{}, whereParam, updateParams)
|
|
err = models.UpdateByExpr(models.CygxArticle{}, whereParam, updateParams)
|
|
if err != nil {
|
|
if err != nil {
|
|
fmt.Println("UpdateByExpr Err:" + err.Error())
|
|
fmt.Println("UpdateByExpr Err:" + err.Error())
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ if len(bodyText)-len(bodyTextOld) > 100 {
|
|
|
|
+ //fmt.Println("触发推送规则")
|
|
|
|
+ //更新字数大于一百字触发推送规则
|
|
|
|
+ go DoArticleOnenIdWxTemplateMsg(v.ArticleId)
|
|
|
|
+ UpdateArticleResourceData(v.ArticleId) //把数据写入 cygx_resource_data 表
|
|
|
|
+ //go UpdateResourceData(v.ArticleId, "article", "update", time.Now().Format(utils.FormatDateTime))
|
|
|
|
+ } else {
|
|
|
|
+ models.UpdatecygxResourceDatasearchTitle(v.Title, v.ArticleId)
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
fmt.Println(k, v.ArticleId, "add")
|
|
fmt.Println(k, v.ArticleId, "add")
|
|
item := new(models.CygxArticle)
|
|
item := new(models.CygxArticle)
|
|
@@ -1198,18 +787,23 @@ func HandleArticleListByApi(artcleId int) (err error) {
|
|
item.MatchTypeName = matchTypeName
|
|
item.MatchTypeName = matchTypeName
|
|
item.Stock = v.Stock
|
|
item.Stock = v.Stock
|
|
item.FieldName = v.FieldName
|
|
item.FieldName = v.FieldName
|
|
|
|
+ item.SeriesName = v.SeriesName
|
|
item.Annotation = v.Annotation
|
|
item.Annotation = v.Annotation
|
|
item.TypeName = v.TypeName
|
|
item.TypeName = v.TypeName
|
|
item.ModifyTimeByCl = v.UpdateDate
|
|
item.ModifyTimeByCl = v.UpdateDate
|
|
item.CeLueFieldId = v.CeLueFieldId
|
|
item.CeLueFieldId = v.CeLueFieldId
|
|
item.Cover = v.Cover
|
|
item.Cover = v.Cover
|
|
|
|
+ item.ChartPermissionId = chartPermissionId
|
|
|
|
+ item.ChartPermissionName = chartPermissionName
|
|
|
|
+ item.Cover = v.Cover
|
|
|
|
+ item.CreateTime = time.Now()
|
|
newId, err := models.AddCygxArticles(item)
|
|
newId, err := models.AddCygxArticles(item)
|
|
if err != nil {
|
|
if err != nil {
|
|
fmt.Println("AddCygxArticle Err:", err.Error())
|
|
fmt.Println("AddCygxArticle Err:", err.Error())
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
//go UpdateResourceData(v.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime))
|
|
//go UpdateResourceData(v.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime))
|
|
- go UpdateArticleResourceData(v.ArticleId) //把数据写入 cygx_resource_data 表
|
|
|
|
|
|
+ UpdateArticleResourceData(v.ArticleId) //把数据写入 cygx_resource_data 表
|
|
//fmt.Println(newId)
|
|
//fmt.Println(newId)
|
|
//报告自动归类,以及推送相关模板消息
|
|
//报告自动归类,以及推送相关模板消息
|
|
if v.ReportType == 2 {
|
|
if v.ReportType == 2 {
|
|
@@ -1293,6 +887,9 @@ func HandleArticleListByApi(artcleId int) (err error) {
|
|
go DoArticleOnenIdWxTemplateMsg(v.ArticleId)
|
|
go DoArticleOnenIdWxTemplateMsg(v.ArticleId)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if v.CategoryName == utils.ZHOU_QI_NAME {
|
|
|
|
+ UpdateCygxZhouqiArticleMapTime(v.FieldName) //更新周期对应分类下所管理文章的更新时间
|
|
|
|
+ }
|
|
//【公司调研】系列纪要发布/更新后 end
|
|
//【公司调研】系列纪要发布/更新后 end
|
|
|
|
|
|
//查研观向6.9模板消息推送规则
|
|
//查研观向6.9模板消息推送规则
|
|
@@ -1334,6 +931,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
|
|
}
|
|
}
|
|
|
|
|
|
AddCygxReportMappingCategoryGroupByArticleId(artcleId)
|
|
AddCygxReportMappingCategoryGroupByArticleId(artcleId)
|
|
|
|
+
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1782,58 +1380,6 @@ func GetSpecialArticleDetailUserPower(user *models.WxUserItem, articleInfo *mode
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-//func init() {
|
|
|
|
-// GetArticNewLabelWhithActivity3Month()
|
|
|
|
-//}
|
|
|
|
-
|
|
|
|
-// 弘则报告发布日期在三个月以内的
|
|
|
|
-func GetArticNewLabelWhithActivity3Month() (labelMap map[int]bool, err error) {
|
|
|
|
- var condition string
|
|
|
|
- var pars []interface{}
|
|
|
|
- condition += ` AND publish_date <= ? AND article_id < ? `
|
|
|
|
- pars = append(pars, time.Now().AddDate(0, -3, 0), utils.SummaryArticleId)
|
|
|
|
- articleList, e := models.GetArticleList(condition, pars)
|
|
|
|
- if e != nil {
|
|
|
|
- err = errors.New("GetArticleList, Err: " + e.Error())
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- var articleIds []int
|
|
|
|
- for _, v := range articleList {
|
|
|
|
- articleIds = append(articleIds, v.ArticleId)
|
|
|
|
- }
|
|
|
|
- if len(articleIds) == 0 {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- pars = make([]interface{}, 0)
|
|
|
|
- condition = ` AND article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `)`
|
|
|
|
- pars = append(pars, articleIds)
|
|
|
|
- industrialList, e := models.GetIndustrialArticleGroupManagementList(condition, pars)
|
|
|
|
- if e != nil {
|
|
|
|
- err = errors.New("GetIndustrialArticleGroupManagementList, Err: " + e.Error())
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- labelMap = make(map[int]bool, 0)
|
|
|
|
- var industrialIds []int
|
|
|
|
- for _, v := range industrialList {
|
|
|
|
- industrialIds = append(industrialIds, v.IndustrialManagementId)
|
|
|
|
- }
|
|
|
|
- // 获取活动关联的产业
|
|
|
|
- var groupCond string
|
|
|
|
- var groupPars []interface{}
|
|
|
|
- groupCond += ` AND b.industrial_management_id IN (` + utils.GetOrmInReplace(len(industrialIds)) + `) AND b.source = 1 `
|
|
|
|
- groupPars = append(groupPars, industrialIds)
|
|
|
|
- groups, e := models.GetActivityIndustryRelationList(groupCond, groupPars)
|
|
|
|
- if e != nil {
|
|
|
|
- err = errors.New("获取活动产业关联列表失败, Err: " + e.Error())
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- for _, v := range groups {
|
|
|
|
- labelMap[v.ActivityId] = true
|
|
|
|
- }
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// HandleArticleCategoryImg 预处理文章的封面图片
|
|
// HandleArticleCategoryImg 预处理文章的封面图片
|
|
func HandleArticleCategoryImg(list []*models.HomeArticle) (items []*models.HomeArticle, err error) {
|
|
func HandleArticleCategoryImg(list []*models.HomeArticle) (items []*models.HomeArticle, err error) {
|
|
//研选的五张图片
|
|
//研选的五张图片
|
|
@@ -2052,12 +1598,6 @@ func ArticleAnnotation(item *models.HomeArticle) (annotation string) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-//func init() {
|
|
|
|
-// strss := AnnotationHtml("")
|
|
|
|
-//
|
|
|
|
-// fmt.Println(strss)
|
|
|
|
-//}
|
|
|
|
-
|
|
|
|
// 处理核心观点的展示规则
|
|
// 处理核心观点的展示规则
|
|
func AnnotationHtml(bodyText string) (annotation string) {
|
|
func AnnotationHtml(bodyText string) (annotation string) {
|
|
if bodyText == "" {
|
|
if bodyText == "" {
|
|
@@ -2379,841 +1919,3 @@ func GetYxArticleIdMap(articleIds []int) (mapResp map[int]bool) {
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|
|
-
|
|
|
|
-//func init() {
|
|
|
|
-//
|
|
|
|
-// //listarticle, err := models.GetArticleInit13_5()
|
|
|
|
-// //fmt.Println(err)
|
|
|
|
-// //fmt.Println("listarticle", len(listarticle))
|
|
|
|
-// //
|
|
|
|
-// //for _, v := range listarticle {
|
|
|
|
-// // HandleArticleListByApiInit13_5(v.ArticleId)
|
|
|
|
-// //}
|
|
|
|
-// //HandleArticleListByApiInit13_5(10825)
|
|
|
|
-//
|
|
|
|
-// listarticle, err := models.GetArticleInit13_5GuSHou()
|
|
|
|
-// fmt.Println(err)
|
|
|
|
-// fmt.Println("listarticle", len(listarticle))
|
|
|
|
-//
|
|
|
|
-// for _, v := range listarticle {
|
|
|
|
-// HandleArticleListByApiInit13_5GuShou(v.ArticleId)
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-//}
|
|
|
|
-
|
|
|
|
-// 处理同步过来的文章
|
|
|
|
-func HandleArticleListByApiInit13_5(artcleId int) (err error) {
|
|
|
|
- defer func() {
|
|
|
|
- if err != nil {
|
|
|
|
- go utils.SendAlarmMsg("处理同步策略平台数据失败"+"GetArticleListByApi ErrMsg:"+err.Error()+"artcleId:"+strconv.Itoa(artcleId), 2)
|
|
|
|
- go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "GetArticleListByApi ErrMsg:"+err.Error()+"artcleId:"+strconv.Itoa(artcleId), utils.EmailSendToUsers)
|
|
|
|
- }
|
|
|
|
- }()
|
|
|
|
- var clueApiUrl string
|
|
|
|
- clueApiUrl = fmt.Sprint(utils.ApiUrl, "articles/", artcleId)
|
|
|
|
- fmt.Println(clueApiUrl)
|
|
|
|
-
|
|
|
|
- authorization := utils.ApiAuthorization
|
|
|
|
- body, err := PublicGetDate(clueApiUrl, authorization)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println(err)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- var articleResultDate models.ArticleDetailResultApi
|
|
|
|
- err = json.Unmarshal(body, &articleResultDate)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("Getres.PublicGetDate Err:", err.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- item := new(models.CygxShanghaiCompanyLog)
|
|
|
|
- item.CreateTime = time.Now()
|
|
|
|
- item.Url = clueApiUrl
|
|
|
|
- item.Body = ""
|
|
|
|
- item.Result = string(body)
|
|
|
|
-
|
|
|
|
- articleResult := articleResultDate.Data
|
|
|
|
-
|
|
|
|
- exitMap := make(map[int]int)
|
|
|
|
- categoryIdMap := make(map[int]int)
|
|
|
|
- classMap := make(map[int]int)
|
|
|
|
- reportMap := make(map[int]int)
|
|
|
|
- summaryMap := make(map[int]int)
|
|
|
|
- listMap, err := models.GetArticleApiMap()
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("GetlistMap Err:", err.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //新旧分类 反向隐射,是否归类,是否是报告,是否是纪要库
|
|
|
|
- for _, v := range listMap {
|
|
|
|
- exitMap[v.SeriesId] = v.OldId
|
|
|
|
- categoryIdMap[v.SeriesId] = v.OldIdMap
|
|
|
|
- if v.IsClass == 1 {
|
|
|
|
- classMap[v.OldId] = 1
|
|
|
|
- }
|
|
|
|
- if v.IsReport == 1 {
|
|
|
|
- reportMap[v.OldId] = 1
|
|
|
|
- }
|
|
|
|
- if v.IsSummary == 1 {
|
|
|
|
- summaryMap[v.OldId] = 1
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- var list []*models.Tactics2
|
|
|
|
- var listArticleData []*models.CygxArticleData
|
|
|
|
- var listAuthor []*models.CygxArticleAuthor
|
|
|
|
- //如果是英文报告 ,或者香港类型那么则不同步 publish_area :all 全部 ;hk 香港
|
|
|
|
- if articleResult.TypeId == 9 || articleResult.PublishArea != "all" {
|
|
|
|
- // 如果是英文报告,或者是香港报告就进行删除处理
|
|
|
|
- err = models.UpdateArticlePublish(artcleId, 0)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("UpdateArticlePublish Err:", err.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- UpdateArticleResourceData(artcleId) //把数据写入 cygx_resource_data 表
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var cover string
|
|
|
|
- if articleResult.Series.Name == "图解市场" {
|
|
|
|
- cover = GetArticleCoverByChartFirst(articleResult.Content.Body)
|
|
|
|
- } else if articleResult.Series.Name == "行业深度" {
|
|
|
|
- cover = articleResult.Cover
|
|
|
|
- }
|
|
|
|
- fmt.Println(cover)
|
|
|
|
- //return
|
|
|
|
- //状态等于 2 跟 4 的进行同步 IsActive 为false 软删除的也不同步
|
|
|
|
- if exitMap[articleResult.SeriesId] > 0 && (articleResult.PublishStatus == 2 || articleResult.PublishStatus == 4) && articleResult.IsActive {
|
|
|
|
- articleResult.PublishDate = time.Date(articleResult.PublishDate.Year(), articleResult.PublishDate.Month(), articleResult.PublishDate.Day(), articleResult.PublishDate.Hour(), articleResult.PublishDate.Minute(), articleResult.PublishDate.Second(), articleResult.PublishDate.Nanosecond(), time.Local)
|
|
|
|
- item := new(models.Tactics2)
|
|
|
|
- itemArticleData := new(models.CygxArticleData)
|
|
|
|
- itemArticleData.ArticleId = articleResult.ArticleId
|
|
|
|
- itemArticleData.Cover = articleResult.Cover
|
|
|
|
- itemArticleData.CreateTime = time.Now()
|
|
|
|
- listArticleData = append(listArticleData, itemArticleData)
|
|
|
|
- itemAuthor := new(models.CygxArticleAuthor)
|
|
|
|
- item.ArticleId = articleResult.ArticleId
|
|
|
|
- item.Title = articleResult.Title
|
|
|
|
- item.TitleEn = articleResult.TitleEn
|
|
|
|
- item.File = articleResult.File
|
|
|
|
- if articleResult.Frequency == "日度" {
|
|
|
|
- item.UpdateFrequency = "daily"
|
|
|
|
- } else if articleResult.Frequency == "周度" {
|
|
|
|
- item.UpdateFrequency = "weekly"
|
|
|
|
- } else if articleResult.Frequency == "月度" {
|
|
|
|
- item.UpdateFrequency = "monthly"
|
|
|
|
- } else if articleResult.Frequency == "季度" {
|
|
|
|
- item.UpdateFrequency = "quarterly"
|
|
|
|
- } else if articleResult.Frequency == "年度" {
|
|
|
|
- item.UpdateFrequency = "yearly"
|
|
|
|
- } else {
|
|
|
|
- item.UpdateFrequency = "unknow"
|
|
|
|
- }
|
|
|
|
- item.CreateDate = articleResult.CreateDate
|
|
|
|
- item.PublishDate = articleResult.PublishDate.Add(time.Hour * 8)
|
|
|
|
- item.PublishStatus = 1
|
|
|
|
- item.Body = articleResult.Content.Body
|
|
|
|
- item.Abstract = articleResult.Content.Abstract
|
|
|
|
- item.Annotation = articleResult.Content.Annotation
|
|
|
|
- item.CategoryName = articleResult.Industry.Name
|
|
|
|
- item.CategoryId = categoryIdMap[articleResult.SeriesId]
|
|
|
|
- item.CategoryIdTwo = exitMap[articleResult.SeriesId]
|
|
|
|
- item.SubCategoryName = articleResult.Series.Name
|
|
|
|
- item.Cover = cover
|
|
|
|
-
|
|
|
|
- fmt.Println("item.CategoryIdTwo", item.CategoryIdTwo)
|
|
|
|
- fmt.Println("item.CategoryId", item.CategoryId)
|
|
|
|
-
|
|
|
|
- {
|
|
|
|
- //这两种情况特殊处理
|
|
|
|
- if articleResult.Field.Name == "宏观利率" {
|
|
|
|
- item.CategoryId = 10070
|
|
|
|
- item.CategoryIdTwo = item.CategoryId
|
|
|
|
- }
|
|
|
|
- if articleResult.Field.Name == "信用" {
|
|
|
|
- item.CategoryId = 10082
|
|
|
|
- item.CategoryIdTwo = item.CategoryId
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if len(articleResult.Stock) > 0 {
|
|
|
|
- var stock string
|
|
|
|
- for _, vS := range articleResult.Stock {
|
|
|
|
- stock += vS + "/"
|
|
|
|
- }
|
|
|
|
- stock = strings.TrimRight(stock, "/")
|
|
|
|
- item.Stock = stock
|
|
|
|
- }
|
|
|
|
- item.FieldName = articleResult.Field.Name
|
|
|
|
- item.TypeName = articleResult.Type.Name
|
|
|
|
- item.UpdateDate = articleResult.UpdateDate
|
|
|
|
- item.CeLueFieldId = articleResult.Field.Id
|
|
|
|
- list = append(list, item)
|
|
|
|
- itemAuthor.ArticleId = articleResult.ArticleId
|
|
|
|
- itemAuthor.Name = articleResult.Author.Name
|
|
|
|
- itemAuthor.Mobile = articleResult.Author.PhoneNumber
|
|
|
|
- fmt.Println(articleResult.Cover)
|
|
|
|
- listAuthor = append(listAuthor, itemAuthor)
|
|
|
|
- } else {
|
|
|
|
- // 如果这篇文章没有发布,那么就不作处理。
|
|
|
|
- err = models.UpdateArticlePublish(artcleId, 0)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("UpdateArticlePublish Err:", err.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- UpdateArticleResourceData(artcleId) //把数据写入 cygx_resource_data 表
|
|
|
|
- //go UpdateResourceData(artcleId, "article", "delete", time.Now().Format(utils.FormatDateTime))
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- fmt.Println("同步文章条数:", len(list))
|
|
|
|
- listCustomArticle, err := models.GetCustomArticleId() //手动归类的文章,不替换文章类型
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("GetTacticsList Err:", err.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- listGetMatchTypeName, errMatch := models.GetMatchTypeNamenNotNull() //手动归类的文章,不替换文章类型
|
|
|
|
- if errMatch != nil {
|
|
|
|
- fmt.Println("GetTacticsList Err:", errMatch.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- //mapCategoryIdSet := make(map[int]int)
|
|
|
|
- //for _, vMatch := range listGetMatchTypeName {
|
|
|
|
- // mapCategoryIdSet[vMatch.CategoryId] = vMatch.CategoryIdSet
|
|
|
|
- //}
|
|
|
|
- fmt.Println("list len:", len(list))
|
|
|
|
- noSummaryArticleIds := "" //非纪要库类型的文章ID
|
|
|
|
- listNoSummaryArticleIds := strings.Split(noSummaryArticleIds, ",")
|
|
|
|
- for k, v := range list {
|
|
|
|
- //同步匹配类型
|
|
|
|
- matchTypeName := ""
|
|
|
|
- for _, vMatch := range listGetMatchTypeName {
|
|
|
|
- if v.CategoryId == vMatch.CategoryId {
|
|
|
|
- matchTypeName = vMatch.MatchTypeName
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //是否属于纪要库的数据
|
|
|
|
- //if _, has := summaryMap[v.CategoryId]; has {
|
|
|
|
- // v.IsSummary = 1
|
|
|
|
- //}
|
|
|
|
- if v.TypeName == "纪要" {
|
|
|
|
- v.IsSummary = 1
|
|
|
|
- }
|
|
|
|
- //排除不属于纪要库类型的文章
|
|
|
|
- for _, vArt := range listNoSummaryArticleIds {
|
|
|
|
- vArtInt, _ := strconv.Atoi(vArt)
|
|
|
|
- if v.ArticleId == vArtInt {
|
|
|
|
- v.IsSummary = 0
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if _, has := reportMap[v.CategoryIdTwo]; has {
|
|
|
|
- v.IsReport = 1
|
|
|
|
- if _, ok := classMap[v.CategoryIdTwo]; ok {
|
|
|
|
- v.IsClass = 1
|
|
|
|
- v.ReportType = 1 //是否属于行业报告
|
|
|
|
- } else {
|
|
|
|
- v.ReportType = 2 //是否属于产业报告
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- v.Department = "弘则权益研究"
|
|
|
|
- //判断是否已经存在
|
|
|
|
- if v.ArticleId < 0 {
|
|
|
|
- fmt.Println("AddCygxArticle Err:")
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- var count int
|
|
|
|
- count, err = models.GetArticleCountById(v.ArticleId)
|
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
|
- fmt.Println("AddCygxArticle Err:", err.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- v.Body = strings.Replace(v.Body, "http://vmp.hzinsights.com", "https://vmp.hzinsights.com", -1)
|
|
|
|
- expertNumStr, expertContentStr, interviewDateStr, _, bodyReturn := BodyAnalysis2(v.Body)
|
|
|
|
- if strings.Index(v.Body, "报告全文(") > 0 && strings.Index(v.Body, "PDF格式报告下载.pdf") > 0 {
|
|
|
|
- v.Body = strings.Replace(v.Body, "报告全文(", "", -1)
|
|
|
|
- v.Body = strings.Replace(v.Body, "PDF格式报告下载.pdf", "", -1)
|
|
|
|
- v.Body = strings.Replace(v.Body, "):", "", -1)
|
|
|
|
- }
|
|
|
|
- var titleNew string
|
|
|
|
- titleNew = v.Title
|
|
|
|
- // 7资金流向 、11大类资产 、51每日复盘 、80医药周报、9估值研究
|
|
|
|
- if v.CategoryId == 7 || v.CategoryId == 11 || v.CategoryId == 51 || v.CategoryId == 9 {
|
|
|
|
- if v.UpdateFrequency == "daily" {
|
|
|
|
- var daystr string
|
|
|
|
- daystr = strconv.Itoa(v.PublishDate.Day())
|
|
|
|
- if len(daystr) == 1 {
|
|
|
|
- daystr = "0" + daystr
|
|
|
|
- }
|
|
|
|
- titleNew = v.Title + "(" + strconv.Itoa(v.PublishDate.Year())[2:len(strconv.Itoa(v.PublishDate.Year()))-0] + v.PublishDate.Format("01") + daystr + ")"
|
|
|
|
- } else if v.UpdateFrequency == "weekly" {
|
|
|
|
- titleNew = v.Title + utils.WeekByDate(v.PublishDate)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if v.CategoryId == 80 {
|
|
|
|
- titleNew = v.Title + utils.WeekByDate(v.PublishDate)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //类型是综述报告的,不区分是什么系列,统一归类到对应产业的路演精华
|
|
|
|
- if articleResult.Type.Name == "综述报告" {
|
|
|
|
- detailCategory, err := models.GetdetailByCategoryIdLyjh(v.CategoryIdTwo)
|
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- v.CategoryId = detailCategory.CategoryId
|
|
|
|
- v.IsSummary = 0
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if count > 0 {
|
|
|
|
- fmt.Println(k, v.ArticleId, "edit")
|
|
|
|
-
|
|
|
|
- bodyText, _ := GetReportContentTextSubNew(v.Body)
|
|
|
|
-
|
|
|
|
- var isCustom bool
|
|
|
|
- updateParams := make(map[string]interface{})
|
|
|
|
- //updateParams["Title"] = v.Title
|
|
|
|
- updateParams["Title"] = titleNew
|
|
|
|
- updateParams["TitleEn"] = v.TitleEn
|
|
|
|
- updateParams["UpdateFrequency"] = v.UpdateFrequency
|
|
|
|
- updateParams["CreateDate"] = v.CreateDate
|
|
|
|
- updateParams["PublishDate"] = v.PublishDate
|
|
|
|
- //updateParams["Body"] = html.EscapeString(v.Body)
|
|
|
|
- updateParams["Body"] = html.EscapeString(bodyReturn)
|
|
|
|
- updateParams["BodyText"] = bodyText
|
|
|
|
- updateParams["Abstract"] = html.EscapeString(v.Abstract)
|
|
|
|
- updateParams["CategoryName"] = v.CategoryName
|
|
|
|
- for _, vCustom := range listCustomArticle {
|
|
|
|
- if v.ArticleId == vCustom.ArticleId {
|
|
|
|
- fmt.Println("手动归类的文章:" + strconv.Itoa(v.ArticleId))
|
|
|
|
- isCustom = true
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if isCustom == false {
|
|
|
|
- updateParams["CategoryId"] = v.CategoryId
|
|
|
|
- updateParams["MatchTypeName"] = matchTypeName
|
|
|
|
- updateParams["IsSummary"] = v.IsSummary
|
|
|
|
- updateParams["IsReport"] = v.IsReport
|
|
|
|
- updateParams["ReportType"] = v.ReportType
|
|
|
|
- updateParams["SubCategoryName"] = v.SubCategoryName
|
|
|
|
- }
|
|
|
|
- //updateParams["CategoryId"] = v.CategoryId
|
|
|
|
- updateParams["PublishStatus"] = 1
|
|
|
|
- updateParams["ExpertBackground"] = expertContentStr
|
|
|
|
- updateParams["ExpertNumber"] = expertNumStr
|
|
|
|
- updateParams["InterviewDate"] = interviewDateStr
|
|
|
|
- //updateParams["IsClass"] = v.IsClass
|
|
|
|
- v.Department = "弘则权益研究"
|
|
|
|
- updateParams["Department"] = v.Department
|
|
|
|
- updateParams["FileLink"] = v.File
|
|
|
|
- updateParams["Stock"] = v.Stock
|
|
|
|
- updateParams["FieldName"] = v.FieldName
|
|
|
|
- updateParams["Annotation"] = v.Annotation
|
|
|
|
- updateParams["TypeName"] = v.TypeName
|
|
|
|
- updateParams["ModifyTimeByCl"] = v.UpdateDate
|
|
|
|
- updateParams["CeLueFieldId"] = v.CeLueFieldId
|
|
|
|
- updateParams["Cover"] = v.Cover
|
|
|
|
- //whereParam := map[string]interface{}{"article_id": v.ArticleId}
|
|
|
|
- //err = models.UpdateByExpr(models.CygxArticle{}, whereParam, updateParams)
|
|
|
|
- //if err != nil {
|
|
|
|
- // fmt.Println("UpdateByExpr Err:" + err.Error())
|
|
|
|
- // return err
|
|
|
|
- //}
|
|
|
|
- fmt.Println("v.ReportType", v.ReportType)
|
|
|
|
-
|
|
|
|
- //if v.ReportType == 2 {
|
|
|
|
- var subjectStr string
|
|
|
|
- var industrialManagementIdStr string
|
|
|
|
- var industrialSubjectIdStr string
|
|
|
|
-
|
|
|
|
- sliceSubjects := strings.Split(v.Stock, "/")
|
|
|
|
- mapManagementForSubject := make(map[string]string)
|
|
|
|
- mapIndustrialId := make(map[int]int)
|
|
|
|
- if len(sliceSubjects) > 0 {
|
|
|
|
- for _, vSubject := range sliceSubjects {
|
|
|
|
- sliceKuohao := strings.Split(vSubject, "(") //过滤括号
|
|
|
|
- sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
|
|
|
|
- subject := sliceXiahuaxian[0]
|
|
|
|
- subjectStr += "'" + subject + "',"
|
|
|
|
- }
|
|
|
|
- //获取该产业下所对应的行业图片
|
|
|
|
- detailCategory, errCategory := models.GetdetailByCategoryIdOne(v.CategoryId)
|
|
|
|
- if errCategory != nil {
|
|
|
|
- fmt.Println("GetdetailByCategoryIdOne Err:", err.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- subjectStr = strings.TrimRight(subjectStr, ",")
|
|
|
|
- if subjectStr != "" {
|
|
|
|
- listIndustrial, err := models.GetIndustrialManagementForSubjecName(subjectStr, detailCategory.ChartPermissionId)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("GetIndustrialManagementForSubjecName Err:", err.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- subjectStr = strings.Replace(subjectStr, "','", "】【", -1)
|
|
|
|
- subjectStr = strings.Replace(subjectStr, "'", "", -1)
|
|
|
|
- subjectStr = "【" + subjectStr + "】"
|
|
|
|
- if len(listIndustrial) > 0 {
|
|
|
|
- for _, vIndustrial := range listIndustrial {
|
|
|
|
- if _, ok := mapIndustrialId[vIndustrial.IndustrialManagementId]; !ok {
|
|
|
|
- industrialManagementIdStr += strconv.Itoa(vIndustrial.IndustrialManagementId) + ","
|
|
|
|
- }
|
|
|
|
- mapIndustrialId[vIndustrial.IndustrialManagementId] = vIndustrial.IndustrialManagementId
|
|
|
|
- industrialSubjectIdStr += strconv.Itoa(vIndustrial.IndustrialSubjectId) + ","
|
|
|
|
- mapManagementForSubject[vIndustrial.IndustryName] += vIndustrial.SubjectName + "/"
|
|
|
|
- if vIndustrial.LayoutTime == "0000-00-00 00:00:00" {
|
|
|
|
- go models.UpdateIndustrialManagementLayoutTime(v.PublishDate.AddDate(0, 0, -10).Format(utils.FormatDateTime), vIndustrial.IndustrialManagementId)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- industrialManagementIdStr = strings.TrimRight(industrialManagementIdStr, ",")
|
|
|
|
- industrialSubjectIdStr = strings.TrimRight(industrialSubjectIdStr, ",")
|
|
|
|
- if industrialManagementIdStr != "" {
|
|
|
|
- err = models.ReportArticleClassificationEditNew(artcleId, industrialManagementIdStr, v.ArticleId, industrialSubjectIdStr)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("ReportArticleClassificationEditNew Err:", err.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //}
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- AddComprehensiveIndustrialSource("Hz", artcleId) // 同步到综合页面的搜索引擎(添加产业资源包)
|
|
|
|
-
|
|
|
|
- AddCygxReportMappingCategoryGroupByArticleId(artcleId)
|
|
|
|
- return err
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-func HandleArticleListByApiInit13_5GuShou(artcleId int) (err error) {
|
|
|
|
- defer func() {
|
|
|
|
- if err != nil {
|
|
|
|
- go utils.SendAlarmMsg("处理同步策略平台数据失败"+"GetArticleListByApi ErrMsg:"+err.Error()+"artcleId:"+strconv.Itoa(artcleId), 2)
|
|
|
|
- go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "GetArticleListByApi ErrMsg:"+err.Error()+"artcleId:"+strconv.Itoa(artcleId), utils.EmailSendToUsers)
|
|
|
|
- }
|
|
|
|
- }()
|
|
|
|
- var clueApiUrl string
|
|
|
|
- clueApiUrl = fmt.Sprint(utils.ApiUrl, "articles/", artcleId)
|
|
|
|
- fmt.Println(clueApiUrl)
|
|
|
|
-
|
|
|
|
- authorization := utils.ApiAuthorization
|
|
|
|
- body, err := PublicGetDate(clueApiUrl, authorization)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println(err)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- var articleResultDate models.ArticleDetailResultApi
|
|
|
|
- err = json.Unmarshal(body, &articleResultDate)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("Getres.PublicGetDate Err:", err.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- item := new(models.CygxShanghaiCompanyLog)
|
|
|
|
- item.CreateTime = time.Now()
|
|
|
|
- item.Url = clueApiUrl
|
|
|
|
- item.Body = ""
|
|
|
|
- item.Result = string(body)
|
|
|
|
-
|
|
|
|
- articleResult := articleResultDate.Data
|
|
|
|
-
|
|
|
|
- exitMap := make(map[int]int)
|
|
|
|
- categoryIdMap := make(map[int]int)
|
|
|
|
- classMap := make(map[int]int)
|
|
|
|
- reportMap := make(map[int]int)
|
|
|
|
- summaryMap := make(map[int]int)
|
|
|
|
- listMap, err := models.GetArticleApiMap()
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("GetlistMap Err:", err.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //新旧分类 反向隐射,是否归类,是否是报告,是否是纪要库
|
|
|
|
- for _, v := range listMap {
|
|
|
|
- exitMap[v.SeriesId] = v.OldId
|
|
|
|
- categoryIdMap[v.SeriesId] = v.OldIdMap
|
|
|
|
- if v.IsClass == 1 {
|
|
|
|
- classMap[v.OldId] = 1
|
|
|
|
- }
|
|
|
|
- if v.IsReport == 1 {
|
|
|
|
- reportMap[v.OldId] = 1
|
|
|
|
- }
|
|
|
|
- if v.IsSummary == 1 {
|
|
|
|
- summaryMap[v.OldId] = 1
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- var list []*models.Tactics2
|
|
|
|
- var listArticleData []*models.CygxArticleData
|
|
|
|
- var listAuthor []*models.CygxArticleAuthor
|
|
|
|
- //如果是英文报告 ,或者香港类型那么则不同步 publish_area :all 全部 ;hk 香港
|
|
|
|
- if articleResult.TypeId == 9 || articleResult.PublishArea != "all" {
|
|
|
|
- // 如果是英文报告,或者是香港报告就进行删除处理
|
|
|
|
- err = models.UpdateArticlePublish(artcleId, 0)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("UpdateArticlePublish Err:", err.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- UpdateArticleResourceData(artcleId) //把数据写入 cygx_resource_data 表
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var cover string
|
|
|
|
- if articleResult.Series.Name == "图解市场" {
|
|
|
|
- cover = GetArticleCoverByChartFirst(articleResult.Content.Body)
|
|
|
|
- } else if articleResult.Series.Name == "行业深度" {
|
|
|
|
- cover = articleResult.Cover
|
|
|
|
- }
|
|
|
|
- fmt.Println(cover)
|
|
|
|
- //return
|
|
|
|
- //状态等于 2 跟 4 的进行同步 IsActive 为false 软删除的也不同步
|
|
|
|
- if exitMap[articleResult.SeriesId] > 0 && (articleResult.PublishStatus == 2 || articleResult.PublishStatus == 4) && articleResult.IsActive {
|
|
|
|
- articleResult.PublishDate = time.Date(articleResult.PublishDate.Year(), articleResult.PublishDate.Month(), articleResult.PublishDate.Day(), articleResult.PublishDate.Hour(), articleResult.PublishDate.Minute(), articleResult.PublishDate.Second(), articleResult.PublishDate.Nanosecond(), time.Local)
|
|
|
|
- item := new(models.Tactics2)
|
|
|
|
- itemArticleData := new(models.CygxArticleData)
|
|
|
|
- itemArticleData.ArticleId = articleResult.ArticleId
|
|
|
|
- itemArticleData.Cover = articleResult.Cover
|
|
|
|
- itemArticleData.CreateTime = time.Now()
|
|
|
|
- listArticleData = append(listArticleData, itemArticleData)
|
|
|
|
- itemAuthor := new(models.CygxArticleAuthor)
|
|
|
|
- item.ArticleId = articleResult.ArticleId
|
|
|
|
- item.Title = articleResult.Title
|
|
|
|
- item.TitleEn = articleResult.TitleEn
|
|
|
|
- item.File = articleResult.File
|
|
|
|
- if articleResult.Frequency == "日度" {
|
|
|
|
- item.UpdateFrequency = "daily"
|
|
|
|
- } else if articleResult.Frequency == "周度" {
|
|
|
|
- item.UpdateFrequency = "weekly"
|
|
|
|
- } else if articleResult.Frequency == "月度" {
|
|
|
|
- item.UpdateFrequency = "monthly"
|
|
|
|
- } else if articleResult.Frequency == "季度" {
|
|
|
|
- item.UpdateFrequency = "quarterly"
|
|
|
|
- } else if articleResult.Frequency == "年度" {
|
|
|
|
- item.UpdateFrequency = "yearly"
|
|
|
|
- } else {
|
|
|
|
- item.UpdateFrequency = "unknow"
|
|
|
|
- }
|
|
|
|
- item.CreateDate = articleResult.CreateDate
|
|
|
|
- item.PublishDate = articleResult.PublishDate.Add(time.Hour * 8)
|
|
|
|
- item.PublishStatus = 1
|
|
|
|
- item.Body = articleResult.Content.Body
|
|
|
|
- item.Abstract = articleResult.Content.Abstract
|
|
|
|
- item.Annotation = articleResult.Content.Annotation
|
|
|
|
- item.CategoryName = articleResult.Industry.Name
|
|
|
|
- item.CategoryId = categoryIdMap[articleResult.SeriesId]
|
|
|
|
- item.CategoryIdTwo = exitMap[articleResult.SeriesId]
|
|
|
|
- item.SubCategoryName = articleResult.Series.Name
|
|
|
|
- item.Cover = cover
|
|
|
|
-
|
|
|
|
- fmt.Println("item.CategoryIdTwo", item.CategoryIdTwo)
|
|
|
|
- fmt.Println("item.CategoryId", item.CategoryId)
|
|
|
|
-
|
|
|
|
- {
|
|
|
|
- //这两种情况特殊处理
|
|
|
|
- if articleResult.Field.Name == "宏观利率" {
|
|
|
|
- item.CategoryId = 10070
|
|
|
|
- item.CategoryIdTwo = item.CategoryId
|
|
|
|
- }
|
|
|
|
- if articleResult.Field.Name == "信用" {
|
|
|
|
- item.CategoryId = 10082
|
|
|
|
- item.CategoryIdTwo = item.CategoryId
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if len(articleResult.Stock) > 0 {
|
|
|
|
- var stock string
|
|
|
|
- for _, vS := range articleResult.Stock {
|
|
|
|
- stock += vS + "/"
|
|
|
|
- }
|
|
|
|
- stock = strings.TrimRight(stock, "/")
|
|
|
|
- item.Stock = stock
|
|
|
|
- }
|
|
|
|
- item.FieldName = articleResult.Field.Name
|
|
|
|
- item.TypeName = articleResult.Type.Name
|
|
|
|
- item.UpdateDate = articleResult.UpdateDate
|
|
|
|
- item.CeLueFieldId = articleResult.Field.Id
|
|
|
|
- list = append(list, item)
|
|
|
|
- itemAuthor.ArticleId = articleResult.ArticleId
|
|
|
|
- itemAuthor.Name = articleResult.Author.Name
|
|
|
|
- itemAuthor.Mobile = articleResult.Author.PhoneNumber
|
|
|
|
- fmt.Println(articleResult.Cover)
|
|
|
|
- listAuthor = append(listAuthor, itemAuthor)
|
|
|
|
- } else {
|
|
|
|
- // 如果这篇文章没有发布,那么就不作处理。
|
|
|
|
- //err = models.UpdateArticlePublish(artcleId, 0)
|
|
|
|
- //if err != nil {
|
|
|
|
- // fmt.Println("UpdateArticlePublish Err:", err.Error())
|
|
|
|
- // return err
|
|
|
|
- //}
|
|
|
|
- //UpdateArticleResourceData(artcleId) //把数据写入 cygx_resource_data 表
|
|
|
|
- //go UpdateResourceData(artcleId, "article", "delete", time.Now().Format(utils.FormatDateTime))
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- fmt.Println("同步文章条数:", len(list))
|
|
|
|
- listCustomArticle, err := models.GetCustomArticleId() //手动归类的文章,不替换文章类型
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("GetTacticsList Err:", err.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- listGetMatchTypeName, errMatch := models.GetMatchTypeNamenNotNull() //手动归类的文章,不替换文章类型
|
|
|
|
- if errMatch != nil {
|
|
|
|
- fmt.Println("GetTacticsList Err:", errMatch.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- //mapCategoryIdSet := make(map[int]int)
|
|
|
|
- //for _, vMatch := range listGetMatchTypeName {
|
|
|
|
- // mapCategoryIdSet[vMatch.CategoryId] = vMatch.CategoryIdSet
|
|
|
|
- //}
|
|
|
|
- fmt.Println("list len:", len(list))
|
|
|
|
- noSummaryArticleIds := "" //非纪要库类型的文章ID
|
|
|
|
- listNoSummaryArticleIds := strings.Split(noSummaryArticleIds, ",")
|
|
|
|
- for k, v := range list {
|
|
|
|
- //同步匹配类型
|
|
|
|
- matchTypeName := ""
|
|
|
|
- for _, vMatch := range listGetMatchTypeName {
|
|
|
|
- if v.CategoryId == vMatch.CategoryId {
|
|
|
|
- matchTypeName = vMatch.MatchTypeName
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //是否属于纪要库的数据
|
|
|
|
- //if _, has := summaryMap[v.CategoryId]; has {
|
|
|
|
- // v.IsSummary = 1
|
|
|
|
- //}
|
|
|
|
- if v.TypeName == "纪要" {
|
|
|
|
- v.IsSummary = 1
|
|
|
|
- }
|
|
|
|
- //排除不属于纪要库类型的文章
|
|
|
|
- for _, vArt := range listNoSummaryArticleIds {
|
|
|
|
- vArtInt, _ := strconv.Atoi(vArt)
|
|
|
|
- if v.ArticleId == vArtInt {
|
|
|
|
- v.IsSummary = 0
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if _, has := reportMap[v.CategoryIdTwo]; has {
|
|
|
|
- v.IsReport = 1
|
|
|
|
- if _, ok := classMap[v.CategoryIdTwo]; ok {
|
|
|
|
- v.IsClass = 1
|
|
|
|
- v.ReportType = 1 //是否属于行业报告
|
|
|
|
- } else {
|
|
|
|
- v.ReportType = 2 //是否属于产业报告
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- v.Department = "弘则权益研究"
|
|
|
|
- //判断是否已经存在
|
|
|
|
- if v.ArticleId < 0 {
|
|
|
|
- fmt.Println("AddCygxArticle Err:")
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- var count int
|
|
|
|
- count, err = models.GetArticleCountById(v.ArticleId)
|
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
|
- fmt.Println("AddCygxArticle Err:", err.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- v.Body = strings.Replace(v.Body, "http://vmp.hzinsights.com", "https://vmp.hzinsights.com", -1)
|
|
|
|
- expertNumStr, expertContentStr, interviewDateStr, _, bodyReturn := BodyAnalysis2(v.Body)
|
|
|
|
- if strings.Index(v.Body, "报告全文(") > 0 && strings.Index(v.Body, "PDF格式报告下载.pdf") > 0 {
|
|
|
|
- v.Body = strings.Replace(v.Body, "报告全文(", "", -1)
|
|
|
|
- v.Body = strings.Replace(v.Body, "PDF格式报告下载.pdf", "", -1)
|
|
|
|
- v.Body = strings.Replace(v.Body, "):", "", -1)
|
|
|
|
- }
|
|
|
|
- var titleNew string
|
|
|
|
- titleNew = v.Title
|
|
|
|
- // 7资金流向 、11大类资产 、51每日复盘 、80医药周报、9估值研究
|
|
|
|
- if v.CategoryId == 7 || v.CategoryId == 11 || v.CategoryId == 51 || v.CategoryId == 9 {
|
|
|
|
- if v.UpdateFrequency == "daily" {
|
|
|
|
- var daystr string
|
|
|
|
- daystr = strconv.Itoa(v.PublishDate.Day())
|
|
|
|
- if len(daystr) == 1 {
|
|
|
|
- daystr = "0" + daystr
|
|
|
|
- }
|
|
|
|
- titleNew = v.Title + "(" + strconv.Itoa(v.PublishDate.Year())[2:len(strconv.Itoa(v.PublishDate.Year()))-0] + v.PublishDate.Format("01") + daystr + ")"
|
|
|
|
- } else if v.UpdateFrequency == "weekly" {
|
|
|
|
- titleNew = v.Title + utils.WeekByDate(v.PublishDate)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if v.CategoryId == 80 {
|
|
|
|
- titleNew = v.Title + utils.WeekByDate(v.PublishDate)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //类型是综述报告的,不区分是什么系列,统一归类到对应产业的路演精华
|
|
|
|
- if articleResult.Type.Name == "综述报告" {
|
|
|
|
- detailCategory, err := models.GetdetailByCategoryIdLyjh(v.CategoryIdTwo)
|
|
|
|
- if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- v.CategoryId = detailCategory.CategoryId
|
|
|
|
- v.IsSummary = 0
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if count > 0 {
|
|
|
|
- fmt.Println(k, v.ArticleId, "edit")
|
|
|
|
-
|
|
|
|
- bodyText, _ := GetReportContentTextSubNew(v.Body)
|
|
|
|
-
|
|
|
|
- var isCustom bool
|
|
|
|
- updateParams := make(map[string]interface{})
|
|
|
|
- //updateParams["Title"] = v.Title
|
|
|
|
- updateParams["Title"] = titleNew
|
|
|
|
- updateParams["TitleEn"] = v.TitleEn
|
|
|
|
- updateParams["UpdateFrequency"] = v.UpdateFrequency
|
|
|
|
- updateParams["CreateDate"] = v.CreateDate
|
|
|
|
- updateParams["PublishDate"] = v.PublishDate
|
|
|
|
- //updateParams["Body"] = html.EscapeString(v.Body)
|
|
|
|
- updateParams["Body"] = html.EscapeString(bodyReturn)
|
|
|
|
- updateParams["BodyText"] = bodyText
|
|
|
|
- updateParams["Abstract"] = html.EscapeString(v.Abstract)
|
|
|
|
- updateParams["CategoryName"] = v.CategoryName
|
|
|
|
- for _, vCustom := range listCustomArticle {
|
|
|
|
- if v.ArticleId == vCustom.ArticleId {
|
|
|
|
- fmt.Println("手动归类的文章:" + strconv.Itoa(v.ArticleId))
|
|
|
|
- isCustom = true
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if isCustom == false {
|
|
|
|
- updateParams["CategoryId"] = v.CategoryId
|
|
|
|
- updateParams["MatchTypeName"] = matchTypeName
|
|
|
|
- updateParams["IsSummary"] = v.IsSummary
|
|
|
|
- updateParams["IsReport"] = v.IsReport
|
|
|
|
- updateParams["ReportType"] = v.ReportType
|
|
|
|
- updateParams["SubCategoryName"] = v.SubCategoryName
|
|
|
|
- }
|
|
|
|
- //updateParams["CategoryId"] = v.CategoryId
|
|
|
|
- updateParams["PublishStatus"] = 1
|
|
|
|
- updateParams["ExpertBackground"] = expertContentStr
|
|
|
|
- updateParams["ExpertNumber"] = expertNumStr
|
|
|
|
- updateParams["InterviewDate"] = interviewDateStr
|
|
|
|
- //updateParams["IsClass"] = v.IsClass
|
|
|
|
- v.Department = "弘则权益研究"
|
|
|
|
- updateParams["Department"] = v.Department
|
|
|
|
- updateParams["FileLink"] = v.File
|
|
|
|
- updateParams["Stock"] = v.Stock
|
|
|
|
- updateParams["FieldName"] = v.FieldName
|
|
|
|
- updateParams["Annotation"] = v.Annotation
|
|
|
|
- updateParams["TypeName"] = v.TypeName
|
|
|
|
- updateParams["ModifyTimeByCl"] = v.UpdateDate
|
|
|
|
- updateParams["CeLueFieldId"] = v.CeLueFieldId
|
|
|
|
- updateParams["Cover"] = v.Cover
|
|
|
|
- whereParam := map[string]interface{}{"article_id": v.ArticleId}
|
|
|
|
- err = models.UpdateByExpr(models.CygxArticle{}, whereParam, updateParams)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("UpdateByExpr Err:" + err.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- fmt.Println("v.ReportType", v.ReportType)
|
|
|
|
-
|
|
|
|
- if v.ReportType == 2 {
|
|
|
|
- var subjectStr string
|
|
|
|
- var industrialManagementIdStr string
|
|
|
|
- var industrialSubjectIdStr string
|
|
|
|
-
|
|
|
|
- sliceSubjects := strings.Split(v.Stock, "/")
|
|
|
|
- mapManagementForSubject := make(map[string]string)
|
|
|
|
- mapIndustrialId := make(map[int]int)
|
|
|
|
- if len(sliceSubjects) > 0 {
|
|
|
|
- for _, vSubject := range sliceSubjects {
|
|
|
|
- sliceKuohao := strings.Split(vSubject, "(") //过滤括号
|
|
|
|
- sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
|
|
|
|
- subject := sliceXiahuaxian[0]
|
|
|
|
- subjectStr += "'" + subject + "',"
|
|
|
|
- }
|
|
|
|
- //获取该产业下所对应的行业图片
|
|
|
|
- detailCategory, errCategory := models.GetdetailByCategoryIdOne(v.CategoryId)
|
|
|
|
- if errCategory != nil {
|
|
|
|
- fmt.Println("GetdetailByCategoryIdOne Err:", err.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- subjectStr = strings.TrimRight(subjectStr, ",")
|
|
|
|
- if subjectStr != "" {
|
|
|
|
- listIndustrial, err := models.GetIndustrialManagementForSubjecName(subjectStr, detailCategory.ChartPermissionId)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("GetIndustrialManagementForSubjecName Err:", err.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- subjectStr = strings.Replace(subjectStr, "','", "】【", -1)
|
|
|
|
- subjectStr = strings.Replace(subjectStr, "'", "", -1)
|
|
|
|
- subjectStr = "【" + subjectStr + "】"
|
|
|
|
- if len(listIndustrial) > 0 {
|
|
|
|
- for _, vIndustrial := range listIndustrial {
|
|
|
|
- if _, ok := mapIndustrialId[vIndustrial.IndustrialManagementId]; !ok {
|
|
|
|
- industrialManagementIdStr += strconv.Itoa(vIndustrial.IndustrialManagementId) + ","
|
|
|
|
- }
|
|
|
|
- mapIndustrialId[vIndustrial.IndustrialManagementId] = vIndustrial.IndustrialManagementId
|
|
|
|
- industrialSubjectIdStr += strconv.Itoa(vIndustrial.IndustrialSubjectId) + ","
|
|
|
|
- mapManagementForSubject[vIndustrial.IndustryName] += vIndustrial.SubjectName + "/"
|
|
|
|
- if vIndustrial.LayoutTime == "0000-00-00 00:00:00" {
|
|
|
|
- go models.UpdateIndustrialManagementLayoutTime(v.PublishDate.AddDate(0, 0, -10).Format(utils.FormatDateTime), vIndustrial.IndustrialManagementId)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- industrialManagementIdStr = strings.TrimRight(industrialManagementIdStr, ",")
|
|
|
|
- industrialSubjectIdStr = strings.TrimRight(industrialSubjectIdStr, ",")
|
|
|
|
- if industrialManagementIdStr != "" {
|
|
|
|
- err = models.ReportArticleClassificationEditNew(artcleId, industrialManagementIdStr, v.ArticleId, industrialSubjectIdStr)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("ReportArticleClassificationEditNew Err:", err.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //}
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- AddComprehensiveIndustrialSource("Hz", artcleId) // 同步到综合页面的搜索引擎(添加产业资源包)
|
|
|
|
-
|
|
|
|
- AddCygxReportMappingCategoryGroupByArticleId(artcleId)
|
|
|
|
- return err
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// 需求池972 修改部分报告类型title
|
|
|
|
-func initweek() {
|
|
|
|
- var category_id int
|
|
|
|
- //category_id = 52
|
|
|
|
- //category_id = 10074
|
|
|
|
- //category_id = 1008
|
|
|
|
- //category_id = 10071
|
|
|
|
- //category_id = 10073
|
|
|
|
- //category_id = 50
|
|
|
|
- var condition string
|
|
|
|
- var pars []interface{}
|
|
|
|
- condition += ` AND category_id = ? AND publish_date > '2023-12-31' `
|
|
|
|
- pars = append(pars, category_id)
|
|
|
|
- articleList, e := models.GetCygxCygxArticleList(condition, pars, 0, 1000)
|
|
|
|
- if e != nil {
|
|
|
|
- fmt.Println(e)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- var clueApiUrl string
|
|
|
|
- for _, v := range articleList {
|
|
|
|
-
|
|
|
|
- clueApiUrl = fmt.Sprint(utils.ApiUrl, "articles/", v.ArticleId)
|
|
|
|
- fmt.Println(clueApiUrl)
|
|
|
|
-
|
|
|
|
- authorization := utils.ApiAuthorization
|
|
|
|
- body, err := PublicGetDate(clueApiUrl, authorization)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println(err)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- var articleResultDate models.ArticleDetailResultApi
|
|
|
|
- err = json.Unmarshal(body, &articleResultDate)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println(err)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- articleResult := articleResultDate.Data
|
|
|
|
-
|
|
|
|
- titleWeek := articleResult.Title + utils.WeekByDate(articleResult.PublishDate)
|
|
|
|
-
|
|
|
|
- fmt.Println(titleWeek)
|
|
|
|
- e = models.ModifyArticleTitleByarticleId(v.ArticleId, titleWeek)
|
|
|
|
- if e != nil {
|
|
|
|
- fmt.Println(e)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}
|
|
|