12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094 |
- 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.GetNowWeekFriday().Add(15 * time.Hour)
- lastfriday := utils.GetLastWeekFriday().Add(15 * time.Hour)
- lastMonth := int(lastfriday.Month())
- month := int(friday.Month())
- lastDay := lastfriday.Day()
- day := friday.Day()
- //friday, _ = time.Parse(utils.FormatDateTime, "2023-09-29 15:00:00")
- //lastfriday, _ = time.Parse(utils.FormatDateTime, "2023-09-22 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,1001)`
- 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(67,1008,10075)`
- 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,64)`
- 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,87)`
- 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 【" + article.Title + "】 "
- 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>", "")
- annotation = strings.ReplaceAll(annotation, "</ol>", "</div>")
- annotation = strings.ReplaceAll(annotation, "<ol>", "<div>")
- annotation = strings.ReplaceAll(annotation, "</li>", "</p>")
- annotation = strings.ReplaceAll(annotation, "<li>", "<p>")
- re, _ := regexp.Compile("<strong.*?>")
- annotation = re.ReplaceAllString(annotation, "")
- reLi, _ := regexp.Compile("<li.*?>")
- annotation = reLi.ReplaceAllString(annotation, "")
- logItem := data_manage.CygxResearchSummaryLog{
- ArticleId: int(articleId),
- Type: "SDBG",
- ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
- CreateTime: time.Now(),
- Body: head + company + annotation,
- LinkArticleId: article.LinkArticleId,
- }
- if utils.RunMode == "debug" {
- logItem.ReportLink = "https://clpttest.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
- } else {
- logItem.ReportLink = "https://web.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
- }
- 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, 85)`
- 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 【" + article.Title + "】 "
- 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>", "")
- annotation = strings.ReplaceAll(annotation, "</ol>", "</div>")
- annotation = strings.ReplaceAll(annotation, "<ol>", "<div>")
- annotation = strings.ReplaceAll(annotation, "</li>", "</p>")
- annotation = strings.ReplaceAll(annotation, "<li>", "<p>")
- re, _ := regexp.Compile("<strong.*?>")
- annotation = re.ReplaceAllString(annotation, "")
- reLi, _ := regexp.Compile("<li.*?>")
- annotation = reLi.ReplaceAllString(annotation, "")
- logItem := data_manage.CygxResearchSummaryLog{
- ArticleId: int(articleId),
- Type: "CYDYJY",
- ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
- CreateTime: time.Now(),
- Body: head + company + annotation,
- LinkArticleId: article.LinkArticleId,
- }
- if utils.RunMode == "debug" {
- logItem.ReportLink = "https://clpttest.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
- } else {
- logItem.ReportLink = "https://web.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
- }
- 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 【" + article.Title + "】 "
- 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>", "")
- annotation = strings.ReplaceAll(annotation, "</ol>", "</div>")
- annotation = strings.ReplaceAll(annotation, "<ol>", "<div>")
- annotation = strings.ReplaceAll(annotation, "</li>", "</p>")
- annotation = strings.ReplaceAll(annotation, "<li>", "<p>")
- re, _ := regexp.Compile("<strong.*?>")
- annotation = re.ReplaceAllString(annotation, "")
- reLi, _ := regexp.Compile("<li.*?>")
- annotation = reLi.ReplaceAllString(annotation, "")
- logItem := data_manage.CygxResearchSummaryLog{
- ArticleId: int(articleId),
- Type: "SSGS",
- ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
- CreateTime: time.Now(),
- Body: head + company + annotation,
- LinkArticleId: article.LinkArticleId,
- }
- if utils.RunMode == "debug" {
- logItem.ReportLink = "https://clpttest.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
- } else {
- logItem.ReportLink = "https://web.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
- }
- logItems = append(logItems, &logItem)
- }
- if len(logItems) > 0 {
- _, e := data_manage.AddCygxResearchSummaryLogOrm(logItems)
- if e != nil {
- err = e
- return
- }
- }
- }
- //事件点评 之前叫事件点评,后来改成了 市场QA汇总
- {
- var condition string
- var pars []interface{}
- condition += ` AND publish_date < ? AND publish_date >= ? `
- pars = append(pars, friday, lastfriday)
- sjdpList := make([]*data_manage.CygxArticle, 0)
- //科技
- {
- //10078:AI问答
- newCondition := condition + ` AND category_id_two IN(10078) `
- list, e := data_manage.GetReportArticleList(newCondition, pars)
- if e != nil {
- err = e
- fmt.Println("GetReportArticleList err:", e)
- return
- }
- for _, article := range list {
- sjdpList = append(sjdpList, article)
- }
- }
- //医药
- {
- //98:N问N答
- newCondition := condition + ` AND category_id_two IN(98) `
- list, e := data_manage.GetReportArticleList(newCondition, pars)
- if e != nil {
- err = e
- fmt.Println("GetReportArticleList err:", e)
- return
- }
- for _, article := range list {
- sjdpList = append(sjdpList, article)
- }
- }
- //消费
- {
- //10083:消费问答
- newCondition := condition + ` AND category_id_two IN(10083) `
- list, e := data_manage.GetReportArticleList(newCondition, pars)
- if e != nil {
- err = e
- fmt.Println("GetReportArticleList err:", e)
- return
- }
- for _, article := range list {
- sjdpList = append(sjdpList, article)
- }
- }
- //智造
- {
- //10084:问道
- newCondition := condition + ` AND category_id_two IN(10084) `
- list, e := data_manage.GetReportArticleList(newCondition, pars)
- if e != nil {
- err = e
- fmt.Println("GetReportArticleList err:", e)
- return
- }
- for _, article := range list {
- sjdpList = append(sjdpList, article)
- }
- }
- var logItems []*data_manage.CygxResearchSummaryLog
- for _, article := range sjdpList {
- head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
- 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>", "")
- annotation = strings.ReplaceAll(annotation, "</ol>", "</div>")
- annotation = strings.ReplaceAll(annotation, "<ol>", "<div>")
- annotation = strings.ReplaceAll(annotation, "</li>", "</p>")
- annotation = strings.ReplaceAll(annotation, "<li>", "<p>")
- re, _ := regexp.Compile("<strong.*?>")
- annotation = re.ReplaceAllString(annotation, "")
- reLi, _ := regexp.Compile("<li.*?>")
- annotation = reLi.ReplaceAllString(annotation, "")
- logItem := data_manage.CygxResearchSummaryLog{
- ArticleId: int(articleId),
- Type: "SJDP",
- ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
- CreateTime: time.Now(),
- Body: head + company + annotation,
- LinkArticleId: article.LinkArticleId,
- }
- if utils.RunMode == "debug" {
- logItem.ReportLink = "https://clpttest.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
- } else {
- logItem.ReportLink = "https://web.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
- }
- logItems = append(logItems, &logItem)
- }
- if len(logItems) > 0 {
- _, e := data_manage.AddCygxResearchSummaryLogOrm(logItems)
- if e != nil {
- err = e
- return
- }
- }
- }
- //买方研选
- //{
- // ids, e := data_manage.GetYanXuanArticleIdList()
- // if e != nil {
- // err = e
- // fmt.Println("GetReportArticleList 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)
- //
- // //9.23新增研选所有类型的报告都要
- // newCondition := condition + ` AND article_type_id IN (`+ *ids +`) `
- // 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 = 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)
- // // }
- // //}
- // var articleIdStr string
- // for _, v := range mfyxList {
- // articleIdStr += strconv.Itoa(v.ArticleId) + ","
- // }
- // mapArticleSubject := make(map[int]string)
- // articleIdStr = strings.TrimRight(articleIdStr, ",")
- // listSubject, e := data_manage.GetArticleSubjectList(articleIdStr)
- // if e != nil {
- // err = e
- // fmt.Println("GetArticleSubjectList err:", e)
- // return
- // }
- // for _, v := range listSubject {
- // mapArticleSubject[v.ArticleId] = v.SubjectName
- // }
- // var logItems []*data_manage.CygxResearchSummaryLog
- // for _, article := range mfyxList {
- // head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
- // body := strings.ReplaceAll(article.Body, "<strong>", "")
- // body = strings.ReplaceAll(body, "</strong>", "")
- // body = strings.ReplaceAll(body, "</ol>", "</div>")
- // body = strings.ReplaceAll(body, "<ol>", "<div>")
- // body = strings.ReplaceAll(body, "</li>", "</p>")
- // body = strings.ReplaceAll(body, "<li>", "<p>")
- // re, _ := regexp.Compile("<strong.*?>")
- // body = re.ReplaceAllString(body, "")
- // reLi, _ := regexp.Compile("<li.*?>")
- // body = reLi.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>"
- // //}
- // if mapArticleSubject[article.ArticleId] != "" {
- // company = " <span style=\"color: #ff1720\">" + "#" + mapArticleSubject[article.ArticleId] + "</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.GetNowWeekTuesday().Add(8 * time.Hour)
- lastTuesday := utils.GetLastWeekTuesday().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,62)`
- 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 【" + article.Title + "】 "
- 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>", "")
- annotation = strings.ReplaceAll(annotation, "</ol>", "</div>")
- annotation = strings.ReplaceAll(annotation, "<ol>", "<div>")
- annotation = strings.ReplaceAll(annotation, "</li>", "</p>")
- annotation = strings.ReplaceAll(annotation, "<li>", "<p>")
- re, _ := regexp.Compile("<strong.*?>")
- annotation = re.ReplaceAllString(annotation, "")
- reLi, _ := regexp.Compile("<li.*?>")
- annotation = reLi.ReplaceAllString(annotation, "")
- logItem := data_manage.CygxMinutesSummaryLog{
- ArticleId: int(articleId),
- Type: "CYDYJY",
- ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
- CreateTime: time.Now(),
- Body: head + company + annotation,
- LinkArticleId: article.LinkArticleId,
- }
- if utils.RunMode == "debug" {
- logItem.ReportLink = "https://clpttest.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
- } else {
- logItem.ReportLink = "https://web.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
- }
- 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 【" + article.Title + "】 "
- 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>", "")
- annotation = strings.ReplaceAll(annotation, "</ol>", "</div>")
- annotation = strings.ReplaceAll(annotation, "<ol>", "<div>")
- annotation = strings.ReplaceAll(annotation, "</li>", "</p>")
- annotation = strings.ReplaceAll(annotation, "<li>", "<p>")
- re, _ := regexp.Compile("<strong.*?>")
- annotation = re.ReplaceAllString(annotation, "")
- reLi, _ := regexp.Compile("<li.*?>")
- annotation = reLi.ReplaceAllString(annotation, "")
- logItem := data_manage.CygxMinutesSummaryLog{
- ArticleId: int(articleId),
- Type: "SSGS",
- ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
- CreateTime: time.Now(),
- Body: head + company + annotation,
- LinkArticleId: article.LinkArticleId,
- }
- if utils.RunMode == "debug" {
- logItem.ReportLink = "https://clpttest.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
- } else {
- logItem.ReportLink = "https://web.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
- }
- 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 articleIdStr string
- // for _, v := range mfyxList {
- // articleIdStr += strconv.Itoa(v.ArticleId) + ","
- // }
- // mapArticleSubject := make(map[int]string)
- // articleIdStr = strings.TrimRight(articleIdStr, ",")
- // listSubject, e := data_manage.GetArticleSubjectList(articleIdStr)
- // if e != nil {
- // err = e
- // fmt.Println("GetArticleSubjectList err:", e)
- // return
- // }
- // for _, v := range listSubject {
- // mapArticleSubject[v.ArticleId] = v.SubjectName
- // }
- // var logItems []*data_manage.CygxMinutesSummaryLog
- // for _, article := range mfyxList {
- // head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
- // body := strings.ReplaceAll(article.Body, "<strong>", "")
- // body = strings.ReplaceAll(body, "</strong>", "")
- // body = strings.ReplaceAll(body, "</ol>", "</div>")
- // body = strings.ReplaceAll(body, "<ol>", "<div>")
- // body = strings.ReplaceAll(body, "</li>", "</p>")
- // body = strings.ReplaceAll(body, "<li>", "<p>")
- // re, _ := regexp.Compile("<strong.*?>")
- // body = re.ReplaceAllString(body, "")
- // reLi, _ := regexp.Compile("<li.*?>")
- // body = reLi.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>"
- // //}
- // if mapArticleSubject[article.ArticleId] != "" {
- // company = " <span style=\"color: #ff1720\">" + "#" + mapArticleSubject[article.ArticleId] + "</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
- }
|