cygx_research_summary.go 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064
  1. package services
  2. import (
  3. "context"
  4. "fmt"
  5. "hongze/hongze_task/models/data_manage"
  6. "hongze/hongze_task/services/alarm_msg"
  7. "hongze/hongze_task/utils"
  8. "regexp"
  9. "strconv"
  10. "strings"
  11. "time"
  12. )
  13. func CygxResearchSummary(cont context.Context) (err error) {
  14. defer func() {
  15. if err != nil {
  16. go alarm_msg.SendAlarmMsg("CygxResearchSummary-定时本周生成研究汇总失败, ErrMsg:\n"+err.Error(), 3)
  17. fmt.Println(err)
  18. }
  19. }()
  20. //content := "本周研究汇总"
  21. friday := utils.GetNowWeekFriday().Add(15 * time.Hour)
  22. lastfriday := utils.GetLastWeekFriday().Add(15 * time.Hour)
  23. lastMonth := int(lastfriday.Month())
  24. month := int(friday.Month())
  25. lastDay := lastfriday.Day()
  26. day := friday.Day()
  27. //friday, _ = time.Parse(utils.FormatDateTime, "2023-09-29 15:00:00")
  28. //lastfriday, _ = time.Parse(utils.FormatDateTime, "2023-09-22 15:00:00")
  29. itemCrs := new(data_manage.CygxResearchSummary)
  30. itemCrs.AdminId = 11
  31. itemCrs.AdminName = "admin"
  32. itemCrs.Title = fmt.Sprintf("本周研究汇总(%d月%d日至%d月%d日)", lastMonth, lastDay, month, day)
  33. itemCrs.Department = "弘则产品组"
  34. itemCrs.Abstract = ""
  35. itemCrs.PublishStatus = 0
  36. //itemCrs.Periods = strconv.Itoa(total + 1)
  37. itemCrs.CreateTime = time.Now()
  38. itemCrs.LastUpdatedTime = time.Now()
  39. itemCrs.PublishDate = time.Now()
  40. articleId, e := data_manage.AddCygxResearchSummaryOrm(itemCrs)
  41. if e != nil {
  42. err = e
  43. return
  44. }
  45. mappingList, err := data_manage.CygxReportMappingist()
  46. if err != nil {
  47. return
  48. }
  49. CategoryChartPermissionIdMap := make(map[int]int)
  50. for _, item := range mappingList {
  51. CategoryChartPermissionIdMap[item.CategoryId] = item.ChartPermissionId
  52. }
  53. yanxMappingList, err := data_manage.CygxArticleTypeMappingList()
  54. if err != nil {
  55. return
  56. }
  57. articleTypeChartPermissionIdMap := make(map[int]int)
  58. for _, item := range yanxMappingList {
  59. articleTypeChartPermissionIdMap[item.ArticleTypeId] = item.YanxPermissionId
  60. }
  61. //深度报告
  62. {
  63. var condition string
  64. var pars []interface{}
  65. condition += ` AND publish_date < ? AND publish_date >= ? `
  66. pars = append(pars, friday, lastfriday)
  67. sdbgList := make([]*data_manage.CygxArticle, 0)
  68. //医药
  69. {
  70. newCondition := condition + ` AND category_id_two IN(65,102)`
  71. list, e := data_manage.GetReportArticleList(newCondition, pars)
  72. if e != nil {
  73. err = e
  74. fmt.Println("GetReportArticleList err:", e)
  75. return
  76. }
  77. for _, article := range list {
  78. sdbgList = append(sdbgList, article)
  79. }
  80. }
  81. //消费
  82. {
  83. newCondition := condition + ` AND category_id_two IN(67,1008)`
  84. list, e := data_manage.GetReportArticleList(newCondition, pars)
  85. if e != nil {
  86. err = e
  87. fmt.Println("GetReportArticleList err:", e)
  88. return
  89. }
  90. for _, article := range list {
  91. sdbgList = append(sdbgList, article)
  92. }
  93. }
  94. //科技
  95. {
  96. newCondition := condition + ` AND category_id_two IN(57,69,1009)`
  97. list, e := data_manage.GetReportArticleList(newCondition, pars)
  98. if e != nil {
  99. err = e
  100. fmt.Println("GetReportArticleList err:", e)
  101. return
  102. }
  103. for _, article := range list {
  104. sdbgList = append(sdbgList, article)
  105. }
  106. }
  107. //智造
  108. {
  109. newCondition := condition + ` AND category_id_two IN(66,85)`
  110. list, e := data_manage.GetReportArticleList(newCondition, pars)
  111. if e != nil {
  112. err = e
  113. fmt.Println("GetReportArticleList err:", e)
  114. return
  115. }
  116. for _, article := range list {
  117. sdbgList = append(sdbgList, article)
  118. }
  119. }
  120. var logItems []*data_manage.CygxResearchSummaryLog
  121. for _, article := range sdbgList {
  122. head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
  123. sliceSubjects := strings.Split(article.Stock, "/")
  124. var company string
  125. if sliceSubjects[0] != "" {
  126. for _, vSubject := range sliceSubjects {
  127. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  128. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  129. subject := sliceXiahuaxian[0]
  130. company += "#" + subject
  131. }
  132. company = " <span style=\"color: #ff1720\">" + company + "</span>"
  133. }
  134. annotation := strings.ReplaceAll(article.Annotation, "<strong>", "")
  135. annotation = strings.ReplaceAll(annotation, "</strong>", "")
  136. annotation = strings.ReplaceAll(annotation, "</ol>", "</div>")
  137. annotation = strings.ReplaceAll(annotation, "<ol>", "<div>")
  138. annotation = strings.ReplaceAll(annotation, "</li>", "</p>")
  139. annotation = strings.ReplaceAll(annotation, "<li>", "<p>")
  140. re, _ := regexp.Compile("<strong.*?>")
  141. annotation = re.ReplaceAllString(annotation, "")
  142. reLi, _ := regexp.Compile("<li.*?>")
  143. annotation = reLi.ReplaceAllString(annotation, "")
  144. logItem := data_manage.CygxResearchSummaryLog{
  145. ArticleId: int(articleId),
  146. Type: "SDBG",
  147. ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
  148. CreateTime: time.Now(),
  149. Body: head + company + annotation,
  150. LinkArticleId: article.LinkArticleId,
  151. }
  152. if utils.RunMode == "debug" {
  153. logItem.ReportLink = "https://clpttest.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
  154. } else {
  155. logItem.ReportLink = "https://web.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
  156. }
  157. logItems = append(logItems, &logItem)
  158. }
  159. if len(logItems) > 0 {
  160. _, e := data_manage.AddCygxResearchSummaryLogOrm(logItems)
  161. if e != nil {
  162. err = e
  163. return
  164. }
  165. }
  166. }
  167. //产业调研纪要
  168. {
  169. var condition string
  170. var pars []interface{}
  171. condition += ` AND publish_date < ? AND publish_date >= ? `
  172. pars = append(pars, friday, lastfriday)
  173. cydyjyList := make([]*data_manage.CygxArticle, 0)
  174. //医药
  175. {
  176. newCondition := condition + ` AND category_id_two IN(28,93,301,71)`
  177. list, e := data_manage.GetReportArticleList(newCondition, pars)
  178. if e != nil {
  179. err = e
  180. fmt.Println("GetReportArticleList err:", e)
  181. return
  182. }
  183. for _, article := range list {
  184. cydyjyList = append(cydyjyList, article)
  185. }
  186. }
  187. //消费
  188. {
  189. newCondition := condition + ` AND category_id_two IN(32,58)`
  190. list, e := data_manage.GetReportArticleList(newCondition, pars)
  191. if e != nil {
  192. err = e
  193. fmt.Println("GetReportArticleList err:", e)
  194. return
  195. }
  196. for _, article := range list {
  197. cydyjyList = append(cydyjyList, article)
  198. }
  199. }
  200. //科技
  201. {
  202. newCondition := condition + ` AND category_id_two IN(79)`
  203. list, e := data_manage.GetReportArticleList(newCondition, pars)
  204. if e != nil {
  205. err = e
  206. fmt.Println("GetReportArticleList err:", e)
  207. return
  208. }
  209. for _, article := range list {
  210. cydyjyList = append(cydyjyList, article)
  211. }
  212. }
  213. //智造
  214. {
  215. newCondition := condition + ` AND category_id_two IN(84)`
  216. list, e := data_manage.GetReportArticleList(newCondition, pars)
  217. if e != nil {
  218. err = e
  219. fmt.Println("GetReportArticleList err:", e)
  220. return
  221. }
  222. for _, article := range list {
  223. cydyjyList = append(cydyjyList, article)
  224. }
  225. }
  226. var logItems []*data_manage.CygxResearchSummaryLog
  227. for _, article := range cydyjyList {
  228. head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
  229. sliceSubjects := strings.Split(article.Stock, "/")
  230. var company string
  231. if sliceSubjects[0] != "" {
  232. for _, vSubject := range sliceSubjects {
  233. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  234. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  235. subject := sliceXiahuaxian[0]
  236. company += "#" + subject
  237. }
  238. company = " <span style=\"color: #ff1720\">" + company + "</span>"
  239. }
  240. annotation := strings.ReplaceAll(article.Annotation, "<strong>", "")
  241. annotation = strings.ReplaceAll(annotation, "</strong>", "")
  242. annotation = strings.ReplaceAll(annotation, "</ol>", "</div>")
  243. annotation = strings.ReplaceAll(annotation, "<ol>", "<div>")
  244. annotation = strings.ReplaceAll(annotation, "</li>", "</p>")
  245. annotation = strings.ReplaceAll(annotation, "<li>", "<p>")
  246. re, _ := regexp.Compile("<strong.*?>")
  247. annotation = re.ReplaceAllString(annotation, "")
  248. reLi, _ := regexp.Compile("<li.*?>")
  249. annotation = reLi.ReplaceAllString(annotation, "")
  250. logItem := data_manage.CygxResearchSummaryLog{
  251. ArticleId: int(articleId),
  252. Type: "CYDYJY",
  253. ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
  254. CreateTime: time.Now(),
  255. Body: head + company + annotation,
  256. LinkArticleId: article.LinkArticleId,
  257. }
  258. if utils.RunMode == "debug" {
  259. logItem.ReportLink = "https://clpttest.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
  260. } else {
  261. logItem.ReportLink = "https://web.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
  262. }
  263. logItems = append(logItems, &logItem)
  264. }
  265. if len(logItems) > 0 {
  266. _, e := data_manage.AddCygxResearchSummaryLogOrm(logItems)
  267. if e != nil {
  268. err = e
  269. return
  270. }
  271. }
  272. }
  273. //上市公司调研纪要
  274. {
  275. var condition string
  276. var pars []interface{}
  277. condition += ` AND publish_date < ? AND publish_date >= ? `
  278. pars = append(pars, friday, lastfriday)
  279. ssgsdyjyList := make([]*data_manage.CygxArticle, 0)
  280. //医药
  281. {
  282. newCondition := condition + ` AND category_id_two IN(74,96)`
  283. list, e := data_manage.GetReportArticleList(newCondition, pars)
  284. if e != nil {
  285. err = e
  286. fmt.Println("GetReportArticleList err:", e)
  287. return
  288. }
  289. for _, article := range list {
  290. ssgsdyjyList = append(ssgsdyjyList, article)
  291. }
  292. }
  293. //消费
  294. {
  295. newCondition := condition + ` AND category_id_two IN(88)`
  296. list, e := data_manage.GetReportArticleList(newCondition, pars)
  297. if e != nil {
  298. err = e
  299. fmt.Println("GetReportArticleList err:", e)
  300. return
  301. }
  302. for _, article := range list {
  303. ssgsdyjyList = append(ssgsdyjyList, article)
  304. }
  305. }
  306. //科技
  307. {
  308. newCondition := condition + ` AND category_id_two IN(45)`
  309. list, e := data_manage.GetReportArticleList(newCondition, pars)
  310. if e != nil {
  311. err = e
  312. fmt.Println("GetReportArticleList err:", e)
  313. return
  314. }
  315. for _, article := range list {
  316. ssgsdyjyList = append(ssgsdyjyList, article)
  317. }
  318. }
  319. //智造
  320. {
  321. newCondition := condition + ` AND category_id_two IN(86)`
  322. list, e := data_manage.GetReportArticleList(newCondition, pars)
  323. if e != nil {
  324. err = e
  325. fmt.Println("GetReportArticleList err:", e)
  326. return
  327. }
  328. for _, article := range list {
  329. ssgsdyjyList = append(ssgsdyjyList, article)
  330. }
  331. }
  332. var logItems []*data_manage.CygxResearchSummaryLog
  333. for _, article := range ssgsdyjyList {
  334. head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
  335. sliceSubjects := strings.Split(article.Stock, "/")
  336. var company string
  337. if sliceSubjects[0] != "" {
  338. for _, vSubject := range sliceSubjects {
  339. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  340. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  341. subject := sliceXiahuaxian[0]
  342. company += "#" + subject
  343. }
  344. company = " <span style=\"color: #ff1720\">" + company + "</span>"
  345. }
  346. annotation := strings.ReplaceAll(article.Annotation, "<strong>", "")
  347. annotation = strings.ReplaceAll(annotation, "</strong>", "")
  348. annotation = strings.ReplaceAll(annotation, "</ol>", "</div>")
  349. annotation = strings.ReplaceAll(annotation, "<ol>", "<div>")
  350. annotation = strings.ReplaceAll(annotation, "</li>", "</p>")
  351. annotation = strings.ReplaceAll(annotation, "<li>", "<p>")
  352. re, _ := regexp.Compile("<strong.*?>")
  353. annotation = re.ReplaceAllString(annotation, "")
  354. reLi, _ := regexp.Compile("<li.*?>")
  355. annotation = reLi.ReplaceAllString(annotation, "")
  356. logItem := data_manage.CygxResearchSummaryLog{
  357. ArticleId: int(articleId),
  358. Type: "SSGS",
  359. ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
  360. CreateTime: time.Now(),
  361. Body: head + company + annotation,
  362. LinkArticleId: article.LinkArticleId,
  363. }
  364. if utils.RunMode == "debug" {
  365. logItem.ReportLink = "https://clpttest.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
  366. } else {
  367. logItem.ReportLink = "https://web.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
  368. }
  369. logItems = append(logItems, &logItem)
  370. }
  371. if len(logItems) > 0 {
  372. _, e := data_manage.AddCygxResearchSummaryLogOrm(logItems)
  373. if e != nil {
  374. err = e
  375. return
  376. }
  377. }
  378. }
  379. //事件点评 之前叫事件点评,后来改成了 市场QA汇总
  380. {
  381. var condition string
  382. var pars []interface{}
  383. condition += ` AND publish_date < ? AND publish_date >= ? `
  384. pars = append(pars, friday, lastfriday)
  385. sjdpList := make([]*data_manage.CygxArticle, 0)
  386. //科技
  387. {
  388. //10078:AI问答
  389. newCondition := condition + ` AND category_id_two IN(10078) `
  390. list, e := data_manage.GetReportArticleList(newCondition, pars)
  391. if e != nil {
  392. err = e
  393. fmt.Println("GetReportArticleList err:", e)
  394. return
  395. }
  396. for _, article := range list {
  397. sjdpList = append(sjdpList, article)
  398. }
  399. }
  400. //医药
  401. {
  402. //98:N问N答
  403. newCondition := condition + ` AND category_id_two IN(98) `
  404. list, e := data_manage.GetReportArticleList(newCondition, pars)
  405. if e != nil {
  406. err = e
  407. fmt.Println("GetReportArticleList err:", e)
  408. return
  409. }
  410. for _, article := range list {
  411. sjdpList = append(sjdpList, article)
  412. }
  413. }
  414. var logItems []*data_manage.CygxResearchSummaryLog
  415. for _, article := range sjdpList {
  416. head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
  417. sliceSubjects := strings.Split(article.Stock, "/")
  418. var company string
  419. if sliceSubjects[0] != "" {
  420. for _, vSubject := range sliceSubjects {
  421. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  422. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  423. subject := sliceXiahuaxian[0]
  424. company += "#" + subject
  425. }
  426. company = " <span style=\"color: #ff1720\">" + company + "</span>"
  427. }
  428. annotation := strings.ReplaceAll(article.Annotation, "<strong>", "")
  429. annotation = strings.ReplaceAll(annotation, "</strong>", "")
  430. annotation = strings.ReplaceAll(annotation, "</ol>", "</div>")
  431. annotation = strings.ReplaceAll(annotation, "<ol>", "<div>")
  432. annotation = strings.ReplaceAll(annotation, "</li>", "</p>")
  433. annotation = strings.ReplaceAll(annotation, "<li>", "<p>")
  434. re, _ := regexp.Compile("<strong.*?>")
  435. annotation = re.ReplaceAllString(annotation, "")
  436. reLi, _ := regexp.Compile("<li.*?>")
  437. annotation = reLi.ReplaceAllString(annotation, "")
  438. logItem := data_manage.CygxResearchSummaryLog{
  439. ArticleId: int(articleId),
  440. Type: "SJDP",
  441. ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
  442. CreateTime: time.Now(),
  443. Body: head + company + annotation,
  444. LinkArticleId: article.LinkArticleId,
  445. }
  446. if utils.RunMode == "debug" {
  447. logItem.ReportLink = "https://clpttest.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
  448. } else {
  449. logItem.ReportLink = "https://web.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
  450. }
  451. logItems = append(logItems, &logItem)
  452. }
  453. if len(logItems) > 0 {
  454. _, e := data_manage.AddCygxResearchSummaryLogOrm(logItems)
  455. if e != nil {
  456. err = e
  457. return
  458. }
  459. }
  460. }
  461. //买方研选
  462. //{
  463. // ids, e := data_manage.GetYanXuanArticleIdList()
  464. // if e != nil {
  465. // err = e
  466. // fmt.Println("GetReportArticleList err:", e)
  467. // return
  468. // }
  469. //
  470. // var condition string
  471. // var pars []interface{}
  472. // condition += ` AND publish_date < ? AND publish_date >= ? `
  473. // pars = append(pars, friday, lastfriday)
  474. // mfyxList := make([]*data_manage.CygxArticle, 0)
  475. //
  476. // //9.23新增研选所有类型的报告都要
  477. // newCondition := condition + ` AND article_type_id IN (`+ *ids +`) `
  478. // list, e := data_manage.GetReportArticleList(newCondition, pars)
  479. // if e != nil {
  480. // err = e
  481. // fmt.Println("GetReportArticleList err:", e)
  482. // return
  483. // }
  484. // for _, article := range list {
  485. // mfyxList = append(mfyxList, article)
  486. // }
  487. //
  488. // ////纪要
  489. // //{
  490. // // newCondition := condition + ` AND article_type_id = 1 `
  491. // // list, e := data_manage.GetReportArticleList(newCondition, pars)
  492. // // if e != nil {
  493. // // err = e
  494. // // fmt.Println("GetReportArticleList err:", e)
  495. // // return
  496. // // }
  497. // // for _, article := range list {
  498. // // mfyxList = append(mfyxList, article)
  499. // // }
  500. // //}
  501. // ////观点
  502. // //{
  503. // // newCondition := condition + ` AND article_type_id = 2 `
  504. // // list, e := data_manage.GetReportArticleList(newCondition, pars)
  505. // // if e != nil {
  506. // // err = e
  507. // // fmt.Println("GetReportArticleList err:", e)
  508. // // return
  509. // // }
  510. // // for _, article := range list {
  511. // // mfyxList = append(mfyxList, article)
  512. // // }
  513. // //}
  514. // ////沙龙
  515. // //{
  516. // // newCondition := condition + ` AND article_type_id = 13 `
  517. // // list, e := data_manage.GetReportArticleList(newCondition, pars)
  518. // // if e != nil {
  519. // // err = e
  520. // // fmt.Println("GetReportArticleList err:", e)
  521. // // return
  522. // // }
  523. // // for _, article := range list {
  524. // // mfyxList = append(mfyxList, article)
  525. // // }
  526. // //}
  527. // var articleIdStr string
  528. // for _, v := range mfyxList {
  529. // articleIdStr += strconv.Itoa(v.ArticleId) + ","
  530. // }
  531. // mapArticleSubject := make(map[int]string)
  532. // articleIdStr = strings.TrimRight(articleIdStr, ",")
  533. // listSubject, e := data_manage.GetArticleSubjectList(articleIdStr)
  534. // if e != nil {
  535. // err = e
  536. // fmt.Println("GetArticleSubjectList err:", e)
  537. // return
  538. // }
  539. // for _, v := range listSubject {
  540. // mapArticleSubject[v.ArticleId] = v.SubjectName
  541. // }
  542. // var logItems []*data_manage.CygxResearchSummaryLog
  543. // for _, article := range mfyxList {
  544. // head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
  545. // body := strings.ReplaceAll(article.Body, "<strong>", "")
  546. // body = strings.ReplaceAll(body, "</strong>", "")
  547. // body = strings.ReplaceAll(body, "</ol>", "</div>")
  548. // body = strings.ReplaceAll(body, "<ol>", "<div>")
  549. // body = strings.ReplaceAll(body, "</li>", "</p>")
  550. // body = strings.ReplaceAll(body, "<li>", "<p>")
  551. // re, _ := regexp.Compile("<strong.*?>")
  552. // body = re.ReplaceAllString(body, "")
  553. // reLi, _ := regexp.Compile("<li.*?>")
  554. // body = reLi.ReplaceAllString(body, "")
  555. // //研选的公司需要单独处理
  556. // //sliceSubjects := strings.Split(article.Stock, "/")
  557. // var company string
  558. // //if sliceSubjects[0] != "" {
  559. // // for _, vSubject := range sliceSubjects {
  560. // // sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  561. // // sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  562. // // subject := sliceXiahuaxian[0]
  563. // // company += "#" + subject
  564. // // }
  565. // // company = " <span style=\"color: #ff1720\">" + company + "</span>"
  566. // //}
  567. // if mapArticleSubject[article.ArticleId] != "" {
  568. // company = " <span style=\"color: #ff1720\">" + "#" + mapArticleSubject[article.ArticleId] + "</span>"
  569. // }
  570. // var plus int
  571. // coreIndex := strings.Index(body, "核心观点:")
  572. // plus = 15
  573. // if coreIndex == -1 {
  574. // coreIndex = strings.Index(body, "核心观点:")
  575. // plus = 13
  576. // }
  577. // if coreIndex == -1 {
  578. // coreIndex = strings.Index(body, "核心观点")
  579. // plus = 12
  580. // }
  581. // if coreIndex == -1 {
  582. // coreIndex = strings.Index(body, "核心结论:")
  583. // plus = 15
  584. // }
  585. // if coreIndex == -1 {
  586. // coreIndex = strings.Index(body, "核心结论:")
  587. // plus = 13
  588. // }
  589. // if coreIndex == -1 {
  590. // coreIndex = strings.Index(body, "核心结论")
  591. // plus = 12
  592. // }
  593. // endIndex := strings.Index(body, "<hr")
  594. // fmt.Println("ID:", article.ArticleId)
  595. // fmt.Println("coreIndex:", coreIndex, endIndex)
  596. // if coreIndex != -1 && endIndex != -1 {
  597. // body = body[coreIndex+plus : endIndex]
  598. // logItem := data_manage.CygxResearchSummaryLog{
  599. // ArticleId: int(articleId),
  600. // Type: "YANX",
  601. // ChartPermissionId: articleTypeChartPermissionIdMap[article.ArticleTypeId],
  602. // CreateTime: time.Now(),
  603. // Body: head + company + body,
  604. // ReportLink: "https://details.hzinsights.com/cygx/report?id=" + article.ArticleIdMd5,
  605. // LinkArticleId: article.LinkArticleId,
  606. // }
  607. // logItems = append(logItems, &logItem)
  608. // }
  609. // }
  610. // if len(logItems) > 0 {
  611. // _, e := data_manage.AddCygxResearchSummaryLogOrm(logItems)
  612. // if e != nil {
  613. // err = e
  614. // return
  615. // }
  616. // }
  617. //
  618. //}
  619. return
  620. }
  621. func CygxLastWeekSummary(cont context.Context) (err error) {
  622. defer func() {
  623. if err != nil {
  624. go alarm_msg.SendAlarmMsg("CygxLastWeekSummary-定时生成上周纪要汇总失败, ErrMsg:\n"+err.Error(), 3)
  625. fmt.Println(err)
  626. }
  627. }()
  628. tuesday := utils.GetNowWeekTuesday().Add(8 * time.Hour)
  629. lastTuesday := utils.GetLastWeekTuesday().Add(8 * time.Hour)
  630. lastMonth := int(lastTuesday.Month())
  631. month := int(tuesday.Month())
  632. lastDay := lastTuesday.Day()
  633. day := tuesday.Day()
  634. itemCrs := new(data_manage.CygxMinutesSummary)
  635. itemCrs.AdminId = 11
  636. itemCrs.AdminName = "admin"
  637. itemCrs.Title = fmt.Sprintf("上周纪要汇总(%d月%d日至%d月%d日)", lastMonth, lastDay, month, day)
  638. itemCrs.Department = "弘则产品组"
  639. itemCrs.Abstract = ""
  640. itemCrs.PublishStatus = 0
  641. //itemCrs.Periods = strconv.Itoa(total + 1)
  642. itemCrs.CreateTime = time.Now()
  643. itemCrs.LastUpdatedTime = time.Now()
  644. itemCrs.PublishDate = time.Now()
  645. articleId, e := data_manage.AddCygxMinutesSummaryOrm(itemCrs)
  646. if e != nil {
  647. err = e
  648. return
  649. }
  650. mappingList, err := data_manage.CygxReportMappingist()
  651. if err != nil {
  652. return
  653. }
  654. CategoryChartPermissionIdMap := make(map[int]int)
  655. for _, item := range mappingList {
  656. CategoryChartPermissionIdMap[item.CategoryId] = item.ChartPermissionId
  657. }
  658. yanxMappingList, err := data_manage.CygxArticleTypeMappingList()
  659. if err != nil {
  660. return
  661. }
  662. articleTypeChartPermissionIdMap := make(map[int]int)
  663. for _, item := range yanxMappingList {
  664. articleTypeChartPermissionIdMap[item.ArticleTypeId] = item.YanxPermissionId
  665. }
  666. //产业调研纪要
  667. {
  668. var condition string
  669. var pars []interface{}
  670. condition += ` AND publish_date < ? AND publish_date >= ? `
  671. pars = append(pars, tuesday, lastTuesday)
  672. cydyjyList := make([]*data_manage.CygxArticle, 0)
  673. //医药
  674. {
  675. newCondition := condition + ` AND category_id_two IN(28,93,301,71)`
  676. list, e := data_manage.GetReportArticleList(newCondition, pars)
  677. if e != nil {
  678. err = e
  679. fmt.Println("GetReportArticleList err:", e)
  680. return
  681. }
  682. for _, article := range list {
  683. cydyjyList = append(cydyjyList, article)
  684. }
  685. }
  686. //消费
  687. {
  688. newCondition := condition + ` AND category_id_two IN(32,58,62)`
  689. list, e := data_manage.GetReportArticleList(newCondition, pars)
  690. if e != nil {
  691. err = e
  692. fmt.Println("GetReportArticleList err:", e)
  693. return
  694. }
  695. for _, article := range list {
  696. cydyjyList = append(cydyjyList, article)
  697. }
  698. }
  699. //科技
  700. {
  701. newCondition := condition + ` AND category_id_two IN(79)`
  702. list, e := data_manage.GetReportArticleList(newCondition, pars)
  703. if e != nil {
  704. err = e
  705. fmt.Println("GetReportArticleList err:", e)
  706. return
  707. }
  708. for _, article := range list {
  709. cydyjyList = append(cydyjyList, article)
  710. }
  711. }
  712. //智造
  713. {
  714. newCondition := condition + ` AND category_id_two IN(84)`
  715. list, e := data_manage.GetReportArticleList(newCondition, pars)
  716. if e != nil {
  717. err = e
  718. fmt.Println("GetReportArticleList err:", e)
  719. return
  720. }
  721. for _, article := range list {
  722. cydyjyList = append(cydyjyList, article)
  723. }
  724. }
  725. var logItems []*data_manage.CygxMinutesSummaryLog
  726. for _, article := range cydyjyList {
  727. head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
  728. sliceSubjects := strings.Split(article.Stock, "/")
  729. var company string
  730. if sliceSubjects[0] != "" {
  731. for _, vSubject := range sliceSubjects {
  732. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  733. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  734. subject := sliceXiahuaxian[0]
  735. company += "#" + subject
  736. }
  737. company = " <span style=\"color: #ff1720\">" + company + "</span>"
  738. }
  739. annotation := strings.ReplaceAll(article.Annotation, "<strong>", "")
  740. annotation = strings.ReplaceAll(annotation, "</strong>", "")
  741. annotation = strings.ReplaceAll(annotation, "</ol>", "</div>")
  742. annotation = strings.ReplaceAll(annotation, "<ol>", "<div>")
  743. annotation = strings.ReplaceAll(annotation, "</li>", "</p>")
  744. annotation = strings.ReplaceAll(annotation, "<li>", "<p>")
  745. re, _ := regexp.Compile("<strong.*?>")
  746. annotation = re.ReplaceAllString(annotation, "")
  747. reLi, _ := regexp.Compile("<li.*?>")
  748. annotation = reLi.ReplaceAllString(annotation, "")
  749. logItem := data_manage.CygxMinutesSummaryLog{
  750. ArticleId: int(articleId),
  751. Type: "CYDYJY",
  752. ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
  753. CreateTime: time.Now(),
  754. Body: head + company + annotation,
  755. LinkArticleId: article.LinkArticleId,
  756. }
  757. if utils.RunMode == "debug" {
  758. logItem.ReportLink = "https://clpttest.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
  759. } else {
  760. logItem.ReportLink = "https://web.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
  761. }
  762. logItems = append(logItems, &logItem)
  763. }
  764. if len(logItems) > 0 {
  765. _, e := data_manage.AddCygxMinutesSummaryLogOrm(logItems)
  766. if e != nil {
  767. err = e
  768. return
  769. }
  770. }
  771. }
  772. //上市公司调研纪要
  773. {
  774. var condition string
  775. var pars []interface{}
  776. condition += ` AND publish_date < ? AND publish_date >= ? `
  777. pars = append(pars, tuesday, lastTuesday)
  778. ssgsdyjyList := make([]*data_manage.CygxArticle, 0)
  779. //医药
  780. {
  781. newCondition := condition + ` AND category_id_two IN(74,96)`
  782. list, e := data_manage.GetReportArticleList(newCondition, pars)
  783. if e != nil {
  784. err = e
  785. fmt.Println("GetReportArticleList err:", e)
  786. return
  787. }
  788. for _, article := range list {
  789. ssgsdyjyList = append(ssgsdyjyList, article)
  790. }
  791. }
  792. //消费
  793. {
  794. newCondition := condition + ` AND category_id_two IN(88)`
  795. list, e := data_manage.GetReportArticleList(newCondition, pars)
  796. if e != nil {
  797. err = e
  798. fmt.Println("GetReportArticleList err:", e)
  799. return
  800. }
  801. for _, article := range list {
  802. ssgsdyjyList = append(ssgsdyjyList, article)
  803. }
  804. }
  805. //科技
  806. {
  807. newCondition := condition + ` AND category_id_two IN(45)`
  808. list, e := data_manage.GetReportArticleList(newCondition, pars)
  809. if e != nil {
  810. err = e
  811. fmt.Println("GetReportArticleList err:", e)
  812. return
  813. }
  814. for _, article := range list {
  815. ssgsdyjyList = append(ssgsdyjyList, article)
  816. }
  817. }
  818. //智造
  819. {
  820. newCondition := condition + ` AND category_id_two IN(86)`
  821. list, e := data_manage.GetReportArticleList(newCondition, pars)
  822. if e != nil {
  823. err = e
  824. fmt.Println("GetReportArticleList err:", e)
  825. return
  826. }
  827. for _, article := range list {
  828. ssgsdyjyList = append(ssgsdyjyList, article)
  829. }
  830. }
  831. var logItems []*data_manage.CygxMinutesSummaryLog
  832. for _, article := range ssgsdyjyList {
  833. head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
  834. sliceSubjects := strings.Split(article.Stock, "/")
  835. var company string
  836. if sliceSubjects[0] != "" {
  837. for _, vSubject := range sliceSubjects {
  838. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  839. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  840. subject := sliceXiahuaxian[0]
  841. company += "#" + subject
  842. }
  843. company = " <span style=\"color: #ff1720\">" + company + "</span>"
  844. }
  845. annotation := strings.ReplaceAll(article.Annotation, "<strong>", "")
  846. annotation = strings.ReplaceAll(annotation, "</strong>", "")
  847. annotation = strings.ReplaceAll(annotation, "</ol>", "</div>")
  848. annotation = strings.ReplaceAll(annotation, "<ol>", "<div>")
  849. annotation = strings.ReplaceAll(annotation, "</li>", "</p>")
  850. annotation = strings.ReplaceAll(annotation, "<li>", "<p>")
  851. re, _ := regexp.Compile("<strong.*?>")
  852. annotation = re.ReplaceAllString(annotation, "")
  853. reLi, _ := regexp.Compile("<li.*?>")
  854. annotation = reLi.ReplaceAllString(annotation, "")
  855. logItem := data_manage.CygxMinutesSummaryLog{
  856. ArticleId: int(articleId),
  857. Type: "SSGS",
  858. ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
  859. CreateTime: time.Now(),
  860. Body: head + company + annotation,
  861. LinkArticleId: article.LinkArticleId,
  862. }
  863. if utils.RunMode == "debug" {
  864. logItem.ReportLink = "https://clpttest.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
  865. } else {
  866. logItem.ReportLink = "https://web.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
  867. }
  868. logItems = append(logItems, &logItem)
  869. }
  870. if len(logItems) > 0 {
  871. _, e := data_manage.AddCygxMinutesSummaryLogOrm(logItems)
  872. if e != nil {
  873. err = e
  874. return
  875. }
  876. }
  877. }
  878. //买方研选
  879. //{
  880. // var condition string
  881. // var pars []interface{}
  882. // condition += ` AND publish_date < ? AND publish_date >= ? `
  883. // pars = append(pars, tuesday, lastTuesday)
  884. // mfyxList := make([]*data_manage.CygxArticle, 0)
  885. //
  886. // //纪要
  887. // {
  888. // newCondition := condition + ` AND article_type_id = 1 `
  889. // list, e := data_manage.GetReportArticleList(newCondition, pars)
  890. // if e != nil {
  891. // err = e
  892. // fmt.Println("GetReportArticleList err:", e)
  893. // return
  894. // }
  895. // for _, article := range list {
  896. // mfyxList = append(mfyxList, article)
  897. // }
  898. // }
  899. // ////观点
  900. // //{
  901. // // newCondition := condition + ` AND article_type_id = 2 `
  902. // // list ,e := data_manage.GetReportArticleList(newCondition, pars)
  903. // // if e != nil {
  904. // // err = e
  905. // // fmt.Println("GetReportArticleList err:", e)
  906. // // return
  907. // // }
  908. // // for _, article := range list {
  909. // // mfyxList = append(mfyxList, article)
  910. // // }
  911. // //}
  912. // ////沙龙
  913. // //{
  914. // // newCondition := condition + ` AND article_type_id = 13 `
  915. // // list ,e := data_manage.GetReportArticleList(newCondition, pars)
  916. // // if e != nil {
  917. // // err = e
  918. // // fmt.Println("GetReportArticleList err:", e)
  919. // // return
  920. // // }
  921. // // for _, article := range list {
  922. // // mfyxList = append(mfyxList, article)
  923. // // }
  924. // //}
  925. // fmt.Println("mfyxList:", len(mfyxList))
  926. // var articleIdStr string
  927. // for _, v := range mfyxList {
  928. // articleIdStr += strconv.Itoa(v.ArticleId) + ","
  929. // }
  930. // mapArticleSubject := make(map[int]string)
  931. // articleIdStr = strings.TrimRight(articleIdStr, ",")
  932. // listSubject, e := data_manage.GetArticleSubjectList(articleIdStr)
  933. // if e != nil {
  934. // err = e
  935. // fmt.Println("GetArticleSubjectList err:", e)
  936. // return
  937. // }
  938. // for _, v := range listSubject {
  939. // mapArticleSubject[v.ArticleId] = v.SubjectName
  940. // }
  941. // var logItems []*data_manage.CygxMinutesSummaryLog
  942. // for _, article := range mfyxList {
  943. // head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
  944. // body := strings.ReplaceAll(article.Body, "<strong>", "")
  945. // body = strings.ReplaceAll(body, "</strong>", "")
  946. // body = strings.ReplaceAll(body, "</ol>", "</div>")
  947. // body = strings.ReplaceAll(body, "<ol>", "<div>")
  948. // body = strings.ReplaceAll(body, "</li>", "</p>")
  949. // body = strings.ReplaceAll(body, "<li>", "<p>")
  950. // re, _ := regexp.Compile("<strong.*?>")
  951. // body = re.ReplaceAllString(body, "")
  952. // reLi, _ := regexp.Compile("<li.*?>")
  953. // body = reLi.ReplaceAllString(body, "")
  954. // //研选的公司需要单独处理
  955. // //sliceSubjects := strings.Split(article.Stock, "/")
  956. // var company string
  957. // //if sliceSubjects[0] != "" {
  958. // // for _, vSubject := range sliceSubjects {
  959. // // sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  960. // // sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  961. // // subject := sliceXiahuaxian[0]
  962. // // company += "#" + subject
  963. // // }
  964. // // company = " <span style=\"color: #ff1720\">" + company + "</span>"
  965. // //}
  966. // if mapArticleSubject[article.ArticleId] != "" {
  967. // company = " <span style=\"color: #ff1720\">" + "#" + mapArticleSubject[article.ArticleId] + "</span>"
  968. // }
  969. // var plus int
  970. // coreIndex := strings.Index(body, "核心观点:")
  971. // plus = 15
  972. // if coreIndex == -1 {
  973. // coreIndex = strings.Index(body, "核心观点:")
  974. // plus = 13
  975. // }
  976. // if coreIndex == -1 {
  977. // coreIndex = strings.Index(body, "核心观点")
  978. // plus = 12
  979. // }
  980. // if coreIndex == -1 {
  981. // coreIndex = strings.Index(body, "核心结论:")
  982. // plus = 15
  983. // }
  984. // if coreIndex == -1 {
  985. // coreIndex = strings.Index(body, "核心结论:")
  986. // plus = 13
  987. // }
  988. // if coreIndex == -1 {
  989. // coreIndex = strings.Index(body, "核心结论")
  990. // plus = 12
  991. // }
  992. // endIndex := strings.Index(body, "<hr")
  993. // if coreIndex != -1 && endIndex != -1 {
  994. // body = body[coreIndex+plus : endIndex]
  995. // logItem := data_manage.CygxMinutesSummaryLog{
  996. // ArticleId: int(articleId),
  997. // Type: "YANX",
  998. // ChartPermissionId: articleTypeChartPermissionIdMap[article.ArticleTypeId],
  999. // CreateTime: time.Now(),
  1000. // Body: head + company + body,
  1001. // ReportLink: "https://details.hzinsights.com/cygx/report?id=" + article.ArticleIdMd5,
  1002. // LinkArticleId: article.LinkArticleId,
  1003. // }
  1004. // logItems = append(logItems, &logItem)
  1005. // }
  1006. // }
  1007. // if len(logItems) > 0 {
  1008. // _, e := data_manage.AddCygxMinutesSummaryLogOrm(logItems)
  1009. // if e != nil {
  1010. // err = e
  1011. // return
  1012. // }
  1013. // }
  1014. //
  1015. //}
  1016. return
  1017. }