|
@@ -0,0 +1,858 @@
|
|
|
+package services
|
|
|
+
|
|
|
+import (
|
|
|
+ "context"
|
|
|
+ "fmt"
|
|
|
+ "hongze/hongze_task/models/data_manage"
|
|
|
+ "hongze/hongze_task/services/alarm_msg"
|
|
|
+ "hongze/hongze_task/utils"
|
|
|
+ "regexp"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+func CygxResearchSummary(cont context.Context) (err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ go alarm_msg.SendAlarmMsg("CygxResearchSummary-定时本周生成研究汇总失败, ErrMsg:\n"+err.Error(), 3)
|
|
|
+ fmt.Println(err)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ //content := "本周研究汇总"
|
|
|
+ friday := utils.GetNowWeekThursday().Add(9 * time.Hour)
|
|
|
+ lastfriday := utils.GetLastWeekThursday().Add(9 * time.Hour)
|
|
|
+ lastMonth := int(lastfriday.Month())
|
|
|
+ month := int(friday.Month())
|
|
|
+ lastDay := lastfriday.Day()
|
|
|
+ day := friday.Day()
|
|
|
+ //friday, _ = time.Parse(utils.FormatDateTime, "2022-09-02 15:00:00")
|
|
|
+ //lastfriday, _ = time.Parse(utils.FormatDateTime, "2022-08-26 15:00:00")
|
|
|
+
|
|
|
+ itemCrs := new(data_manage.CygxResearchSummary)
|
|
|
+ itemCrs.AdminId = 11
|
|
|
+ itemCrs.AdminName = "admin"
|
|
|
+ itemCrs.Title = fmt.Sprintf("本周研究汇总(%d月%d日至%d月%d日)", lastMonth, lastDay, month, day)
|
|
|
+ itemCrs.Department = "弘则产品组"
|
|
|
+ itemCrs.Abstract = ""
|
|
|
+ itemCrs.PublishStatus = 0
|
|
|
+ //itemCrs.Periods = strconv.Itoa(total + 1)
|
|
|
+ itemCrs.CreateTime = time.Now()
|
|
|
+ itemCrs.LastUpdatedTime = time.Now()
|
|
|
+ itemCrs.PublishDate = time.Now()
|
|
|
+
|
|
|
+ articleId, e := data_manage.AddCygxResearchSummaryOrm(itemCrs)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ return
|
|
|
+ }
|
|
|
+ mappingList, err := data_manage.CygxReportMappingist()
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ CategoryChartPermissionIdMap := make(map[int]int)
|
|
|
+ for _, item := range mappingList {
|
|
|
+ CategoryChartPermissionIdMap[item.CategoryId] = item.ChartPermissionId
|
|
|
+ }
|
|
|
+ yanxMappingList, err := data_manage.CygxArticleTypeMappingList()
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ articleTypeChartPermissionIdMap := make(map[int]int)
|
|
|
+ for _, item := range yanxMappingList {
|
|
|
+ articleTypeChartPermissionIdMap[item.ArticleTypeId] = item.YanxPermissionId
|
|
|
+ }
|
|
|
+ //深度报告
|
|
|
+ {
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += ` AND publish_date < ? AND publish_date >= ? `
|
|
|
+ pars = append(pars, friday, lastfriday)
|
|
|
+ sdbgList := make([]*data_manage.CygxArticle, 0)
|
|
|
+
|
|
|
+ //医药
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND category_id_two IN(65,102)`
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ sdbgList = append(sdbgList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //消费
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND category_id_two IN(62,67,1008)`
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ sdbgList = append(sdbgList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //科技
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND category_id_two IN(57,69,1009)`
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ sdbgList = append(sdbgList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //智造
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND category_id_two IN(66,85)`
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ sdbgList = append(sdbgList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var logItems []*data_manage.CygxResearchSummaryLog
|
|
|
+ for _, article := range sdbgList {
|
|
|
+ head := "<div class=\"title-content\">\n<strong> 【" + article.Title + "】</strong>\n "
|
|
|
+ sliceSubjects := strings.Split(article.Stock, "/")
|
|
|
+ var company string
|
|
|
+ if sliceSubjects[0] != "" {
|
|
|
+ for _, vSubject := range sliceSubjects {
|
|
|
+ sliceKuohao := strings.Split(vSubject, "(") //过滤括号
|
|
|
+ sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
|
|
|
+ subject := sliceXiahuaxian[0]
|
|
|
+ company += "#" + subject
|
|
|
+ }
|
|
|
+ company = " <span style=\"color: #ff1720\">" + company + "</span>"
|
|
|
+ }
|
|
|
+ annotation := strings.ReplaceAll(article.Annotation, "<strong>", "")
|
|
|
+ annotation = strings.ReplaceAll(annotation, "</strong>", "")
|
|
|
+ re, _ := regexp.Compile("<strong.*?>")
|
|
|
+ annotation = re.ReplaceAllString(annotation, "")
|
|
|
+ logItem := data_manage.CygxResearchSummaryLog{
|
|
|
+ ArticleId: int(articleId),
|
|
|
+ Type: "SDBG",
|
|
|
+ ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
|
|
|
+ CreateTime: time.Now(),
|
|
|
+ Body: head + company + annotation,
|
|
|
+ ReportLink: "https://vmp.hzinsights.com/v2/articles/" + strconv.Itoa(article.ArticleId),
|
|
|
+ LinkArticleId: article.LinkArticleId,
|
|
|
+ }
|
|
|
+ logItems = append(logItems, &logItem)
|
|
|
+ }
|
|
|
+ if len(logItems) > 0 {
|
|
|
+ _, e := data_manage.AddCygxResearchSummaryLogOrm(logItems)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //产业调研纪要
|
|
|
+ {
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += ` AND publish_date < ? AND publish_date >= ? `
|
|
|
+ pars = append(pars, friday, lastfriday)
|
|
|
+ cydyjyList := make([]*data_manage.CygxArticle, 0)
|
|
|
+
|
|
|
+ //医药
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND category_id_two IN(28,93,301,71)`
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ cydyjyList = append(cydyjyList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //消费
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND category_id_two IN(32,58)`
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ cydyjyList = append(cydyjyList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //科技
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND category_id_two IN(79)`
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ cydyjyList = append(cydyjyList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //智造
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND category_id_two IN(84)`
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ cydyjyList = append(cydyjyList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var logItems []*data_manage.CygxResearchSummaryLog
|
|
|
+ for _, article := range cydyjyList {
|
|
|
+ head := "<div class=\"title-content\">\n<strong> 【" + article.Title + "】</strong>\n "
|
|
|
+ sliceSubjects := strings.Split(article.Stock, "/")
|
|
|
+ var company string
|
|
|
+ if sliceSubjects[0] != "" {
|
|
|
+ for _, vSubject := range sliceSubjects {
|
|
|
+ sliceKuohao := strings.Split(vSubject, "(") //过滤括号
|
|
|
+ sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
|
|
|
+ subject := sliceXiahuaxian[0]
|
|
|
+ company += "#" + subject
|
|
|
+ }
|
|
|
+ company = " <span style=\"color: #ff1720\">" + company + "</span>"
|
|
|
+ }
|
|
|
+ annotation := strings.ReplaceAll(article.Annotation, "<strong>", "")
|
|
|
+ annotation = strings.ReplaceAll(annotation, "</strong>", "")
|
|
|
+ re, _ := regexp.Compile("<strong.*?>")
|
|
|
+ annotation = re.ReplaceAllString(annotation, "")
|
|
|
+ logItem := data_manage.CygxResearchSummaryLog{
|
|
|
+ ArticleId: int(articleId),
|
|
|
+ Type: "CYDYJY",
|
|
|
+ ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
|
|
|
+ CreateTime: time.Now(),
|
|
|
+ Body: head + company + annotation,
|
|
|
+ ReportLink: "https://vmp.hzinsights.com/v2/articles/" + strconv.Itoa(article.ArticleId),
|
|
|
+ LinkArticleId: article.LinkArticleId,
|
|
|
+ }
|
|
|
+ logItems = append(logItems, &logItem)
|
|
|
+ }
|
|
|
+ if len(logItems) > 0 {
|
|
|
+ _, e := data_manage.AddCygxResearchSummaryLogOrm(logItems)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //上市公司调研纪要
|
|
|
+ {
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += ` AND publish_date < ? AND publish_date >= ? `
|
|
|
+ pars = append(pars, friday, lastfriday)
|
|
|
+ ssgsdyjyList := make([]*data_manage.CygxArticle, 0)
|
|
|
+
|
|
|
+ //医药
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND category_id_two IN(74,96)`
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ ssgsdyjyList = append(ssgsdyjyList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //消费
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND category_id_two IN(88)`
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ ssgsdyjyList = append(ssgsdyjyList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //科技
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND category_id_two IN(45)`
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ ssgsdyjyList = append(ssgsdyjyList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //智造
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND category_id_two IN(86)`
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ ssgsdyjyList = append(ssgsdyjyList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var logItems []*data_manage.CygxResearchSummaryLog
|
|
|
+ for _, article := range ssgsdyjyList {
|
|
|
+ head := "<div class=\"title-content\">\n<strong> 【" + article.Title + "】</strong>\n "
|
|
|
+ sliceSubjects := strings.Split(article.Stock, "/")
|
|
|
+ var company string
|
|
|
+ if sliceSubjects[0] != "" {
|
|
|
+ for _, vSubject := range sliceSubjects {
|
|
|
+ sliceKuohao := strings.Split(vSubject, "(") //过滤括号
|
|
|
+ sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
|
|
|
+ subject := sliceXiahuaxian[0]
|
|
|
+ company += "#" + subject
|
|
|
+ }
|
|
|
+ company = " <span style=\"color: #ff1720\">" + company + "</span>"
|
|
|
+ }
|
|
|
+ annotation := strings.ReplaceAll(article.Annotation, "<strong>", "")
|
|
|
+ annotation = strings.ReplaceAll(annotation, "</strong>", "")
|
|
|
+ re, _ := regexp.Compile("<strong.*?>")
|
|
|
+ annotation = re.ReplaceAllString(annotation, "")
|
|
|
+ logItem := data_manage.CygxResearchSummaryLog{
|
|
|
+ ArticleId: int(articleId),
|
|
|
+ Type: "SSGS",
|
|
|
+ ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
|
|
|
+ CreateTime: time.Now(),
|
|
|
+ Body: head + company + annotation,
|
|
|
+ ReportLink: "https://vmp.hzinsights.com/v2/articles/" + strconv.Itoa(article.ArticleId),
|
|
|
+ LinkArticleId: article.LinkArticleId,
|
|
|
+ }
|
|
|
+ logItems = append(logItems, &logItem)
|
|
|
+ }
|
|
|
+ if len(logItems) > 0 {
|
|
|
+ _, e := data_manage.AddCygxResearchSummaryLogOrm(logItems)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //买方研选
|
|
|
+ {
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += ` AND publish_date < ? AND publish_date >= ? `
|
|
|
+ pars = append(pars, friday, lastfriday)
|
|
|
+ mfyxList := make([]*data_manage.CygxArticle, 0)
|
|
|
+
|
|
|
+ //纪要
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND article_type_id = 1 `
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ mfyxList = append(mfyxList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //观点
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND article_type_id = 2 `
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ mfyxList = append(mfyxList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //沙龙
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND article_type_id = 13 `
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ mfyxList = append(mfyxList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fmt.Println("mfyxList:", len(mfyxList))
|
|
|
+ var logItems []*data_manage.CygxResearchSummaryLog
|
|
|
+ for _, article := range mfyxList {
|
|
|
+ head := "<div class=\"title-content\">\n<strong> 【" + article.Title + "】</strong>\n "
|
|
|
+ body := strings.ReplaceAll(article.Body, "<strong>", "")
|
|
|
+ body = strings.ReplaceAll(body, "</strong>", "")
|
|
|
+ re, _ := regexp.Compile("<strong.*?>")
|
|
|
+ body = re.ReplaceAllString(body, "")
|
|
|
+ sliceSubjects := strings.Split(article.Stock, "/")
|
|
|
+ var company string
|
|
|
+ if sliceSubjects[0] != "" {
|
|
|
+ for _, vSubject := range sliceSubjects {
|
|
|
+ sliceKuohao := strings.Split(vSubject, "(") //过滤括号
|
|
|
+ sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
|
|
|
+ subject := sliceXiahuaxian[0]
|
|
|
+ company += "#" + subject
|
|
|
+ }
|
|
|
+ company = " <span style=\"color: #ff1720\">" + company + "</span>"
|
|
|
+ }
|
|
|
+ var plus int
|
|
|
+ coreIndex := strings.Index(body, "核心观点:")
|
|
|
+ plus = 15
|
|
|
+ if coreIndex == -1 {
|
|
|
+ coreIndex = strings.Index(body, "核心观点:")
|
|
|
+ plus = 13
|
|
|
+ }
|
|
|
+ if coreIndex == -1 {
|
|
|
+ coreIndex = strings.Index(body, "核心观点")
|
|
|
+ plus = 12
|
|
|
+ }
|
|
|
+ if coreIndex == -1 {
|
|
|
+ coreIndex = strings.Index(body, "核心结论:")
|
|
|
+ plus = 15
|
|
|
+ }
|
|
|
+ if coreIndex == -1 {
|
|
|
+ coreIndex = strings.Index(body, "核心结论:")
|
|
|
+ plus = 13
|
|
|
+ }
|
|
|
+ if coreIndex == -1 {
|
|
|
+ coreIndex = strings.Index(body, "核心结论")
|
|
|
+ plus = 12
|
|
|
+ }
|
|
|
+ endIndex := strings.Index(body, "<hr")
|
|
|
+ fmt.Println("ID:",article.ArticleId)
|
|
|
+ fmt.Println("coreIndex:", coreIndex, endIndex)
|
|
|
+ if coreIndex != -1 && endIndex != -1 {
|
|
|
+ body = body[coreIndex+plus : endIndex]
|
|
|
+ logItem := data_manage.CygxResearchSummaryLog{
|
|
|
+ ArticleId: int(articleId),
|
|
|
+ Type: "YANX",
|
|
|
+ ChartPermissionId: articleTypeChartPermissionIdMap[article.ArticleTypeId],
|
|
|
+ CreateTime: time.Now(),
|
|
|
+ Body: head + company + body,
|
|
|
+ ReportLink: "https://details.hzinsights.com/cygx/report?id=" + article.ArticleIdMd5,
|
|
|
+ LinkArticleId: article.LinkArticleId,
|
|
|
+ }
|
|
|
+ logItems = append(logItems, &logItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(logItems) > 0 {
|
|
|
+ _, e := data_manage.AddCygxResearchSummaryLogOrm(logItems)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func CygxLastWeekSummary(cont context.Context) (err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ go alarm_msg.SendAlarmMsg("CygxLastWeekSummary-定时生成上周纪要汇总失败, ErrMsg:\n"+err.Error(), 3)
|
|
|
+ fmt.Println(err)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ tuesday := utils.GetNowWeekThursday().Add(8 * time.Hour)
|
|
|
+ lastTuesday := utils.GetLastWeekThursday().Add(8 * time.Hour)
|
|
|
+ lastMonth := int(lastTuesday.Month())
|
|
|
+ month := int(tuesday.Month())
|
|
|
+ lastDay := lastTuesday.Day()
|
|
|
+ day := tuesday.Day()
|
|
|
+
|
|
|
+ itemCrs := new(data_manage.CygxMinutesSummary)
|
|
|
+ itemCrs.AdminId = 11
|
|
|
+ itemCrs.AdminName = "admin"
|
|
|
+ itemCrs.Title = fmt.Sprintf("上周纪要汇总(%d月%d日至%d月%d日)", lastMonth, lastDay, month, day)
|
|
|
+ itemCrs.Department = "弘则产品组"
|
|
|
+ itemCrs.Abstract = ""
|
|
|
+ itemCrs.PublishStatus = 0
|
|
|
+ //itemCrs.Periods = strconv.Itoa(total + 1)
|
|
|
+ itemCrs.CreateTime = time.Now()
|
|
|
+ itemCrs.LastUpdatedTime = time.Now()
|
|
|
+ itemCrs.PublishDate = time.Now()
|
|
|
+
|
|
|
+ articleId, e := data_manage.AddCygxMinutesSummaryOrm(itemCrs)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ return
|
|
|
+ }
|
|
|
+ mappingList, err := data_manage.CygxReportMappingist()
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ CategoryChartPermissionIdMap := make(map[int]int)
|
|
|
+ for _, item := range mappingList {
|
|
|
+ CategoryChartPermissionIdMap[item.CategoryId] = item.ChartPermissionId
|
|
|
+ }
|
|
|
+ yanxMappingList, err := data_manage.CygxArticleTypeMappingList()
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ articleTypeChartPermissionIdMap := make(map[int]int)
|
|
|
+ for _, item := range yanxMappingList {
|
|
|
+ articleTypeChartPermissionIdMap[item.ArticleTypeId] = item.YanxPermissionId
|
|
|
+ }
|
|
|
+ //产业调研纪要
|
|
|
+ {
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += ` AND publish_date < ? AND publish_date >= ? `
|
|
|
+ pars = append(pars, tuesday, lastTuesday)
|
|
|
+ cydyjyList := make([]*data_manage.CygxArticle, 0)
|
|
|
+
|
|
|
+ //医药
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND category_id_two IN(28,93,301,71)`
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ cydyjyList = append(cydyjyList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //消费
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND category_id_two IN(32,58)`
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ cydyjyList = append(cydyjyList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //科技
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND category_id_two IN(79)`
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ cydyjyList = append(cydyjyList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //智造
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND category_id_two IN(84)`
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ cydyjyList = append(cydyjyList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var logItems []*data_manage.CygxMinutesSummaryLog
|
|
|
+ for _, article := range cydyjyList {
|
|
|
+ head := "<div class=\"title-content\">\n<strong> 【" + article.Title + "】</strong>\n "
|
|
|
+ sliceSubjects := strings.Split(article.Stock, "/")
|
|
|
+ var company string
|
|
|
+ if sliceSubjects[0] != "" {
|
|
|
+ for _, vSubject := range sliceSubjects {
|
|
|
+ sliceKuohao := strings.Split(vSubject, "(") //过滤括号
|
|
|
+ sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
|
|
|
+ subject := sliceXiahuaxian[0]
|
|
|
+ company += "#" + subject
|
|
|
+ }
|
|
|
+ company = " <span style=\"color: #ff1720\">" + company + "</span>"
|
|
|
+ }
|
|
|
+ annotation := strings.ReplaceAll(article.Annotation, "<strong>", "")
|
|
|
+ annotation = strings.ReplaceAll(annotation, "</strong>", "")
|
|
|
+ re, _ := regexp.Compile("<strong.*?>")
|
|
|
+ annotation = re.ReplaceAllString(annotation, "")
|
|
|
+ logItem := data_manage.CygxMinutesSummaryLog{
|
|
|
+ ArticleId: int(articleId),
|
|
|
+ Type: "CYDYJY",
|
|
|
+ ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
|
|
|
+ CreateTime: time.Now(),
|
|
|
+ Body: head + company + annotation,
|
|
|
+ ReportLink: "https://vmp.hzinsights.com/v2/articles/" + strconv.Itoa(article.ArticleId),
|
|
|
+ LinkArticleId: article.LinkArticleId,
|
|
|
+ }
|
|
|
+ logItems = append(logItems, &logItem)
|
|
|
+ }
|
|
|
+ if len(logItems) > 0 {
|
|
|
+ _, e := data_manage.AddCygxMinutesSummaryLogOrm(logItems)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //上市公司调研纪要
|
|
|
+ {
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += ` AND publish_date < ? AND publish_date >= ? `
|
|
|
+ pars = append(pars, tuesday, lastTuesday)
|
|
|
+ ssgsdyjyList := make([]*data_manage.CygxArticle, 0)
|
|
|
+
|
|
|
+ //医药
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND category_id_two IN(74,96)`
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ ssgsdyjyList = append(ssgsdyjyList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //消费
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND category_id_two IN(88)`
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ ssgsdyjyList = append(ssgsdyjyList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //科技
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND category_id_two IN(45)`
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ ssgsdyjyList = append(ssgsdyjyList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //智造
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND category_id_two IN(86)`
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ ssgsdyjyList = append(ssgsdyjyList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var logItems []*data_manage.CygxMinutesSummaryLog
|
|
|
+ for _, article := range ssgsdyjyList {
|
|
|
+ head := "<div class=\"title-content\">\n<strong> 【" + article.Title + "】</strong>\n "
|
|
|
+ sliceSubjects := strings.Split(article.Stock, "/")
|
|
|
+ var company string
|
|
|
+ if sliceSubjects[0] != "" {
|
|
|
+ for _, vSubject := range sliceSubjects {
|
|
|
+ sliceKuohao := strings.Split(vSubject, "(") //过滤括号
|
|
|
+ sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
|
|
|
+ subject := sliceXiahuaxian[0]
|
|
|
+ company += "#" + subject
|
|
|
+ }
|
|
|
+ company = " <span style=\"color: #ff1720\">" + company + "</span>"
|
|
|
+ }
|
|
|
+ annotation := strings.ReplaceAll(article.Annotation, "<strong>", "")
|
|
|
+ annotation = strings.ReplaceAll(annotation, "</strong>", "")
|
|
|
+ re, _ := regexp.Compile("<strong.*?>")
|
|
|
+ annotation = re.ReplaceAllString(annotation, "")
|
|
|
+ logItem := data_manage.CygxMinutesSummaryLog{
|
|
|
+ ArticleId: int(articleId),
|
|
|
+ Type: "SSGS",
|
|
|
+ ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
|
|
|
+ CreateTime: time.Now(),
|
|
|
+ Body: head + company + annotation,
|
|
|
+ ReportLink: "https://vmp.hzinsights.com/v2/articles/" + strconv.Itoa(article.ArticleId),
|
|
|
+ LinkArticleId: article.LinkArticleId,
|
|
|
+ }
|
|
|
+ logItems = append(logItems, &logItem)
|
|
|
+ }
|
|
|
+ if len(logItems) > 0 {
|
|
|
+ _, e := data_manage.AddCygxMinutesSummaryLogOrm(logItems)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //买方研选
|
|
|
+ {
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition += ` AND publish_date < ? AND publish_date >= ? `
|
|
|
+ pars = append(pars, tuesday, lastTuesday)
|
|
|
+ mfyxList := make([]*data_manage.CygxArticle, 0)
|
|
|
+
|
|
|
+ //纪要
|
|
|
+ {
|
|
|
+ newCondition := condition + ` AND article_type_id = 1 `
|
|
|
+ list, e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ fmt.Println("GetReportArticleList err:", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, article := range list {
|
|
|
+ mfyxList = append(mfyxList, article)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ////观点
|
|
|
+ //{
|
|
|
+ // newCondition := condition + ` AND article_type_id = 2 `
|
|
|
+ // list ,e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ // if e != nil {
|
|
|
+ // err = e
|
|
|
+ // fmt.Println("GetReportArticleList err:", e)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // for _, article := range list {
|
|
|
+ // mfyxList = append(mfyxList, article)
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ ////沙龙
|
|
|
+ //{
|
|
|
+ // newCondition := condition + ` AND article_type_id = 13 `
|
|
|
+ // list ,e := data_manage.GetReportArticleList(newCondition, pars)
|
|
|
+ // if e != nil {
|
|
|
+ // err = e
|
|
|
+ // fmt.Println("GetReportArticleList err:", e)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // for _, article := range list {
|
|
|
+ // mfyxList = append(mfyxList, article)
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ fmt.Println("mfyxList:", len(mfyxList))
|
|
|
+ var logItems []*data_manage.CygxMinutesSummaryLog
|
|
|
+ for _, article := range mfyxList {
|
|
|
+ head := "<div class=\"title-content\">\n<strong> 【" + article.Title + "】</strong>\n "
|
|
|
+ body := strings.ReplaceAll(article.Body, "<strong>", "")
|
|
|
+ body = strings.ReplaceAll(body, "</strong>", "")
|
|
|
+ re, _ := regexp.Compile("<strong.*?>")
|
|
|
+ body = re.ReplaceAllString(body, "")
|
|
|
+ sliceSubjects := strings.Split(article.Stock, "/")
|
|
|
+ var company string
|
|
|
+ if sliceSubjects[0] != "" {
|
|
|
+ for _, vSubject := range sliceSubjects {
|
|
|
+ sliceKuohao := strings.Split(vSubject, "(") //过滤括号
|
|
|
+ sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
|
|
|
+ subject := sliceXiahuaxian[0]
|
|
|
+ company += "#" + subject
|
|
|
+ }
|
|
|
+ company = " <span style=\"color: #ff1720\">" + company + "</span>"
|
|
|
+ }
|
|
|
+ var plus int
|
|
|
+ coreIndex := strings.Index(body, "核心观点:")
|
|
|
+ plus = 15
|
|
|
+ if coreIndex == -1 {
|
|
|
+ coreIndex = strings.Index(body, "核心观点:")
|
|
|
+ plus = 13
|
|
|
+ }
|
|
|
+ if coreIndex == -1 {
|
|
|
+ coreIndex = strings.Index(body, "核心观点")
|
|
|
+ plus = 12
|
|
|
+ }
|
|
|
+ if coreIndex == -1 {
|
|
|
+ coreIndex = strings.Index(body, "核心结论:")
|
|
|
+ plus = 15
|
|
|
+ }
|
|
|
+ if coreIndex == -1 {
|
|
|
+ coreIndex = strings.Index(body, "核心结论:")
|
|
|
+ plus = 13
|
|
|
+ }
|
|
|
+ if coreIndex == -1 {
|
|
|
+ coreIndex = strings.Index(body, "核心结论")
|
|
|
+ plus = 12
|
|
|
+ }
|
|
|
+ endIndex := strings.Index(body, "<hr")
|
|
|
+ if coreIndex != -1 && endIndex != -1 {
|
|
|
+ body = body[coreIndex+plus:endIndex]
|
|
|
+ logItem := data_manage.CygxMinutesSummaryLog{
|
|
|
+ ArticleId: int(articleId),
|
|
|
+ Type: "YANX",
|
|
|
+ ChartPermissionId: articleTypeChartPermissionIdMap[article.ArticleTypeId],
|
|
|
+ CreateTime: time.Now(),
|
|
|
+ Body: head + company + body,
|
|
|
+ ReportLink: "https://details.hzinsights.com/cygx/report?id=" + article.ArticleIdMd5,
|
|
|
+ LinkArticleId: article.LinkArticleId,
|
|
|
+ }
|
|
|
+ logItems = append(logItems, &logItem)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(logItems) > 0 {
|
|
|
+ _, e := data_manage.AddCygxMinutesSummaryLogOrm(logItems)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return
|
|
|
+}
|