cygx_research_summary.go 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094
  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,1001)`
  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,10075)`
  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,64)`
  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,87)`
  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, 85)`
  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. //消费
  415. {
  416. //10083:消费问答
  417. newCondition := condition + ` AND category_id_two IN(10083) `
  418. list, e := data_manage.GetReportArticleList(newCondition, pars)
  419. if e != nil {
  420. err = e
  421. fmt.Println("GetReportArticleList err:", e)
  422. return
  423. }
  424. for _, article := range list {
  425. sjdpList = append(sjdpList, article)
  426. }
  427. }
  428. //智造
  429. {
  430. //10084:问道
  431. newCondition := condition + ` AND category_id_two IN(10084) `
  432. list, e := data_manage.GetReportArticleList(newCondition, pars)
  433. if e != nil {
  434. err = e
  435. fmt.Println("GetReportArticleList err:", e)
  436. return
  437. }
  438. for _, article := range list {
  439. sjdpList = append(sjdpList, article)
  440. }
  441. }
  442. var logItems []*data_manage.CygxResearchSummaryLog
  443. for _, article := range sjdpList {
  444. head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
  445. sliceSubjects := strings.Split(article.Stock, "/")
  446. var company string
  447. if sliceSubjects[0] != "" {
  448. for _, vSubject := range sliceSubjects {
  449. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  450. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  451. subject := sliceXiahuaxian[0]
  452. company += "#" + subject
  453. }
  454. company = " <span style=\"color: #ff1720\">" + company + "</span>"
  455. }
  456. annotation := strings.ReplaceAll(article.Annotation, "<strong>", "")
  457. annotation = strings.ReplaceAll(annotation, "</strong>", "")
  458. annotation = strings.ReplaceAll(annotation, "</ol>", "</div>")
  459. annotation = strings.ReplaceAll(annotation, "<ol>", "<div>")
  460. annotation = strings.ReplaceAll(annotation, "</li>", "</p>")
  461. annotation = strings.ReplaceAll(annotation, "<li>", "<p>")
  462. re, _ := regexp.Compile("<strong.*?>")
  463. annotation = re.ReplaceAllString(annotation, "")
  464. reLi, _ := regexp.Compile("<li.*?>")
  465. annotation = reLi.ReplaceAllString(annotation, "")
  466. logItem := data_manage.CygxResearchSummaryLog{
  467. ArticleId: int(articleId),
  468. Type: "SJDP",
  469. ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
  470. CreateTime: time.Now(),
  471. Body: head + company + annotation,
  472. LinkArticleId: article.LinkArticleId,
  473. }
  474. if utils.RunMode == "debug" {
  475. logItem.ReportLink = "https://clpttest.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
  476. } else {
  477. logItem.ReportLink = "https://web.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
  478. }
  479. logItems = append(logItems, &logItem)
  480. }
  481. if len(logItems) > 0 {
  482. _, e := data_manage.AddCygxResearchSummaryLogOrm(logItems)
  483. if e != nil {
  484. err = e
  485. return
  486. }
  487. }
  488. }
  489. //买方研选
  490. //{
  491. // ids, e := data_manage.GetYanXuanArticleIdList()
  492. // if e != nil {
  493. // err = e
  494. // fmt.Println("GetReportArticleList err:", e)
  495. // return
  496. // }
  497. //
  498. // var condition string
  499. // var pars []interface{}
  500. // condition += ` AND publish_date < ? AND publish_date >= ? `
  501. // pars = append(pars, friday, lastfriday)
  502. // mfyxList := make([]*data_manage.CygxArticle, 0)
  503. //
  504. // //9.23新增研选所有类型的报告都要
  505. // newCondition := condition + ` AND article_type_id IN (`+ *ids +`) `
  506. // list, e := data_manage.GetReportArticleList(newCondition, pars)
  507. // if e != nil {
  508. // err = e
  509. // fmt.Println("GetReportArticleList err:", e)
  510. // return
  511. // }
  512. // for _, article := range list {
  513. // mfyxList = append(mfyxList, article)
  514. // }
  515. //
  516. // ////纪要
  517. // //{
  518. // // newCondition := condition + ` AND article_type_id = 1 `
  519. // // list, e := data_manage.GetReportArticleList(newCondition, pars)
  520. // // if e != nil {
  521. // // err = e
  522. // // fmt.Println("GetReportArticleList err:", e)
  523. // // return
  524. // // }
  525. // // for _, article := range list {
  526. // // mfyxList = append(mfyxList, article)
  527. // // }
  528. // //}
  529. // ////观点
  530. // //{
  531. // // newCondition := condition + ` AND article_type_id = 2 `
  532. // // list, e := data_manage.GetReportArticleList(newCondition, pars)
  533. // // if e != nil {
  534. // // err = e
  535. // // fmt.Println("GetReportArticleList err:", e)
  536. // // return
  537. // // }
  538. // // for _, article := range list {
  539. // // mfyxList = append(mfyxList, article)
  540. // // }
  541. // //}
  542. // ////沙龙
  543. // //{
  544. // // newCondition := condition + ` AND article_type_id = 13 `
  545. // // list, e := data_manage.GetReportArticleList(newCondition, pars)
  546. // // if e != nil {
  547. // // err = e
  548. // // fmt.Println("GetReportArticleList err:", e)
  549. // // return
  550. // // }
  551. // // for _, article := range list {
  552. // // mfyxList = append(mfyxList, article)
  553. // // }
  554. // //}
  555. // var articleIdStr string
  556. // for _, v := range mfyxList {
  557. // articleIdStr += strconv.Itoa(v.ArticleId) + ","
  558. // }
  559. // mapArticleSubject := make(map[int]string)
  560. // articleIdStr = strings.TrimRight(articleIdStr, ",")
  561. // listSubject, e := data_manage.GetArticleSubjectList(articleIdStr)
  562. // if e != nil {
  563. // err = e
  564. // fmt.Println("GetArticleSubjectList err:", e)
  565. // return
  566. // }
  567. // for _, v := range listSubject {
  568. // mapArticleSubject[v.ArticleId] = v.SubjectName
  569. // }
  570. // var logItems []*data_manage.CygxResearchSummaryLog
  571. // for _, article := range mfyxList {
  572. // head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
  573. // body := strings.ReplaceAll(article.Body, "<strong>", "")
  574. // body = strings.ReplaceAll(body, "</strong>", "")
  575. // body = strings.ReplaceAll(body, "</ol>", "</div>")
  576. // body = strings.ReplaceAll(body, "<ol>", "<div>")
  577. // body = strings.ReplaceAll(body, "</li>", "</p>")
  578. // body = strings.ReplaceAll(body, "<li>", "<p>")
  579. // re, _ := regexp.Compile("<strong.*?>")
  580. // body = re.ReplaceAllString(body, "")
  581. // reLi, _ := regexp.Compile("<li.*?>")
  582. // body = reLi.ReplaceAllString(body, "")
  583. // //研选的公司需要单独处理
  584. // //sliceSubjects := strings.Split(article.Stock, "/")
  585. // var company string
  586. // //if sliceSubjects[0] != "" {
  587. // // for _, vSubject := range sliceSubjects {
  588. // // sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  589. // // sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  590. // // subject := sliceXiahuaxian[0]
  591. // // company += "#" + subject
  592. // // }
  593. // // company = " <span style=\"color: #ff1720\">" + company + "</span>"
  594. // //}
  595. // if mapArticleSubject[article.ArticleId] != "" {
  596. // company = " <span style=\"color: #ff1720\">" + "#" + mapArticleSubject[article.ArticleId] + "</span>"
  597. // }
  598. // var plus int
  599. // coreIndex := strings.Index(body, "核心观点:")
  600. // plus = 15
  601. // if coreIndex == -1 {
  602. // coreIndex = strings.Index(body, "核心观点:")
  603. // plus = 13
  604. // }
  605. // if coreIndex == -1 {
  606. // coreIndex = strings.Index(body, "核心观点")
  607. // plus = 12
  608. // }
  609. // if coreIndex == -1 {
  610. // coreIndex = strings.Index(body, "核心结论:")
  611. // plus = 15
  612. // }
  613. // if coreIndex == -1 {
  614. // coreIndex = strings.Index(body, "核心结论:")
  615. // plus = 13
  616. // }
  617. // if coreIndex == -1 {
  618. // coreIndex = strings.Index(body, "核心结论")
  619. // plus = 12
  620. // }
  621. // endIndex := strings.Index(body, "<hr")
  622. // fmt.Println("ID:", article.ArticleId)
  623. // fmt.Println("coreIndex:", coreIndex, endIndex)
  624. // if coreIndex != -1 && endIndex != -1 {
  625. // body = body[coreIndex+plus : endIndex]
  626. // logItem := data_manage.CygxResearchSummaryLog{
  627. // ArticleId: int(articleId),
  628. // Type: "YANX",
  629. // ChartPermissionId: articleTypeChartPermissionIdMap[article.ArticleTypeId],
  630. // CreateTime: time.Now(),
  631. // Body: head + company + body,
  632. // ReportLink: "https://details.hzinsights.com/cygx/report?id=" + article.ArticleIdMd5,
  633. // LinkArticleId: article.LinkArticleId,
  634. // }
  635. // logItems = append(logItems, &logItem)
  636. // }
  637. // }
  638. // if len(logItems) > 0 {
  639. // _, e := data_manage.AddCygxResearchSummaryLogOrm(logItems)
  640. // if e != nil {
  641. // err = e
  642. // return
  643. // }
  644. // }
  645. //
  646. //}
  647. return
  648. }
  649. func CygxLastWeekSummary(cont context.Context) (err error) {
  650. defer func() {
  651. if err != nil {
  652. go alarm_msg.SendAlarmMsg("CygxLastWeekSummary-定时生成上周纪要汇总失败, ErrMsg:\n"+err.Error(), 3)
  653. fmt.Println(err)
  654. }
  655. }()
  656. tuesday := utils.GetNowWeekTuesday().Add(8 * time.Hour)
  657. lastTuesday := utils.GetLastWeekTuesday().Add(8 * time.Hour)
  658. lastMonth := int(lastTuesday.Month())
  659. month := int(tuesday.Month())
  660. lastDay := lastTuesday.Day()
  661. day := tuesday.Day()
  662. itemCrs := new(data_manage.CygxMinutesSummary)
  663. itemCrs.AdminId = 11
  664. itemCrs.AdminName = "admin"
  665. itemCrs.Title = fmt.Sprintf("上周纪要汇总(%d月%d日至%d月%d日)", lastMonth, lastDay, month, day)
  666. itemCrs.Department = "弘则产品组"
  667. itemCrs.Abstract = ""
  668. itemCrs.PublishStatus = 0
  669. //itemCrs.Periods = strconv.Itoa(total + 1)
  670. itemCrs.CreateTime = time.Now()
  671. itemCrs.LastUpdatedTime = time.Now()
  672. itemCrs.PublishDate = time.Now()
  673. articleId, e := data_manage.AddCygxMinutesSummaryOrm(itemCrs)
  674. if e != nil {
  675. err = e
  676. return
  677. }
  678. mappingList, err := data_manage.CygxReportMappingist()
  679. if err != nil {
  680. return
  681. }
  682. CategoryChartPermissionIdMap := make(map[int]int)
  683. for _, item := range mappingList {
  684. CategoryChartPermissionIdMap[item.CategoryId] = item.ChartPermissionId
  685. }
  686. yanxMappingList, err := data_manage.CygxArticleTypeMappingList()
  687. if err != nil {
  688. return
  689. }
  690. articleTypeChartPermissionIdMap := make(map[int]int)
  691. for _, item := range yanxMappingList {
  692. articleTypeChartPermissionIdMap[item.ArticleTypeId] = item.YanxPermissionId
  693. }
  694. //产业调研纪要
  695. {
  696. var condition string
  697. var pars []interface{}
  698. condition += ` AND publish_date < ? AND publish_date >= ? `
  699. pars = append(pars, tuesday, lastTuesday)
  700. cydyjyList := make([]*data_manage.CygxArticle, 0)
  701. //医药
  702. {
  703. newCondition := condition + ` AND category_id_two IN(28,93,301,71)`
  704. list, e := data_manage.GetReportArticleList(newCondition, pars)
  705. if e != nil {
  706. err = e
  707. fmt.Println("GetReportArticleList err:", e)
  708. return
  709. }
  710. for _, article := range list {
  711. cydyjyList = append(cydyjyList, article)
  712. }
  713. }
  714. //消费
  715. {
  716. newCondition := condition + ` AND category_id_two IN(32,58,62)`
  717. list, e := data_manage.GetReportArticleList(newCondition, pars)
  718. if e != nil {
  719. err = e
  720. fmt.Println("GetReportArticleList err:", e)
  721. return
  722. }
  723. for _, article := range list {
  724. cydyjyList = append(cydyjyList, article)
  725. }
  726. }
  727. //科技
  728. {
  729. newCondition := condition + ` AND category_id_two IN(79)`
  730. list, e := data_manage.GetReportArticleList(newCondition, pars)
  731. if e != nil {
  732. err = e
  733. fmt.Println("GetReportArticleList err:", e)
  734. return
  735. }
  736. for _, article := range list {
  737. cydyjyList = append(cydyjyList, article)
  738. }
  739. }
  740. //智造
  741. {
  742. newCondition := condition + ` AND category_id_two IN(84)`
  743. list, e := data_manage.GetReportArticleList(newCondition, pars)
  744. if e != nil {
  745. err = e
  746. fmt.Println("GetReportArticleList err:", e)
  747. return
  748. }
  749. for _, article := range list {
  750. cydyjyList = append(cydyjyList, article)
  751. }
  752. }
  753. var logItems []*data_manage.CygxMinutesSummaryLog
  754. for _, article := range cydyjyList {
  755. head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
  756. sliceSubjects := strings.Split(article.Stock, "/")
  757. var company string
  758. if sliceSubjects[0] != "" {
  759. for _, vSubject := range sliceSubjects {
  760. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  761. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  762. subject := sliceXiahuaxian[0]
  763. company += "#" + subject
  764. }
  765. company = " <span style=\"color: #ff1720\">" + company + "</span>"
  766. }
  767. annotation := strings.ReplaceAll(article.Annotation, "<strong>", "")
  768. annotation = strings.ReplaceAll(annotation, "</strong>", "")
  769. annotation = strings.ReplaceAll(annotation, "</ol>", "</div>")
  770. annotation = strings.ReplaceAll(annotation, "<ol>", "<div>")
  771. annotation = strings.ReplaceAll(annotation, "</li>", "</p>")
  772. annotation = strings.ReplaceAll(annotation, "<li>", "<p>")
  773. re, _ := regexp.Compile("<strong.*?>")
  774. annotation = re.ReplaceAllString(annotation, "")
  775. reLi, _ := regexp.Compile("<li.*?>")
  776. annotation = reLi.ReplaceAllString(annotation, "")
  777. logItem := data_manage.CygxMinutesSummaryLog{
  778. ArticleId: int(articleId),
  779. Type: "CYDYJY",
  780. ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
  781. CreateTime: time.Now(),
  782. Body: head + company + annotation,
  783. LinkArticleId: article.LinkArticleId,
  784. }
  785. if utils.RunMode == "debug" {
  786. logItem.ReportLink = "https://clpttest.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
  787. } else {
  788. logItem.ReportLink = "https://web.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
  789. }
  790. logItems = append(logItems, &logItem)
  791. }
  792. if len(logItems) > 0 {
  793. _, e := data_manage.AddCygxMinutesSummaryLogOrm(logItems)
  794. if e != nil {
  795. err = e
  796. return
  797. }
  798. }
  799. }
  800. //上市公司调研纪要
  801. {
  802. var condition string
  803. var pars []interface{}
  804. condition += ` AND publish_date < ? AND publish_date >= ? `
  805. pars = append(pars, tuesday, lastTuesday)
  806. ssgsdyjyList := make([]*data_manage.CygxArticle, 0)
  807. //医药
  808. {
  809. newCondition := condition + ` AND category_id_two IN(74,96)`
  810. list, e := data_manage.GetReportArticleList(newCondition, pars)
  811. if e != nil {
  812. err = e
  813. fmt.Println("GetReportArticleList err:", e)
  814. return
  815. }
  816. for _, article := range list {
  817. ssgsdyjyList = append(ssgsdyjyList, article)
  818. }
  819. }
  820. //消费
  821. {
  822. newCondition := condition + ` AND category_id_two IN(88)`
  823. list, e := data_manage.GetReportArticleList(newCondition, pars)
  824. if e != nil {
  825. err = e
  826. fmt.Println("GetReportArticleList err:", e)
  827. return
  828. }
  829. for _, article := range list {
  830. ssgsdyjyList = append(ssgsdyjyList, article)
  831. }
  832. }
  833. //科技
  834. {
  835. newCondition := condition + ` AND category_id_two IN(45)`
  836. list, e := data_manage.GetReportArticleList(newCondition, pars)
  837. if e != nil {
  838. err = e
  839. fmt.Println("GetReportArticleList err:", e)
  840. return
  841. }
  842. for _, article := range list {
  843. ssgsdyjyList = append(ssgsdyjyList, article)
  844. }
  845. }
  846. //智造
  847. {
  848. newCondition := condition + ` AND category_id_two IN(86)`
  849. list, e := data_manage.GetReportArticleList(newCondition, pars)
  850. if e != nil {
  851. err = e
  852. fmt.Println("GetReportArticleList err:", e)
  853. return
  854. }
  855. for _, article := range list {
  856. ssgsdyjyList = append(ssgsdyjyList, article)
  857. }
  858. }
  859. var logItems []*data_manage.CygxMinutesSummaryLog
  860. for _, article := range ssgsdyjyList {
  861. head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
  862. sliceSubjects := strings.Split(article.Stock, "/")
  863. var company string
  864. if sliceSubjects[0] != "" {
  865. for _, vSubject := range sliceSubjects {
  866. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  867. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  868. subject := sliceXiahuaxian[0]
  869. company += "#" + subject
  870. }
  871. company = " <span style=\"color: #ff1720\">" + company + "</span>"
  872. }
  873. annotation := strings.ReplaceAll(article.Annotation, "<strong>", "")
  874. annotation = strings.ReplaceAll(annotation, "</strong>", "")
  875. annotation = strings.ReplaceAll(annotation, "</ol>", "</div>")
  876. annotation = strings.ReplaceAll(annotation, "<ol>", "<div>")
  877. annotation = strings.ReplaceAll(annotation, "</li>", "</p>")
  878. annotation = strings.ReplaceAll(annotation, "<li>", "<p>")
  879. re, _ := regexp.Compile("<strong.*?>")
  880. annotation = re.ReplaceAllString(annotation, "")
  881. reLi, _ := regexp.Compile("<li.*?>")
  882. annotation = reLi.ReplaceAllString(annotation, "")
  883. logItem := data_manage.CygxMinutesSummaryLog{
  884. ArticleId: int(articleId),
  885. Type: "SSGS",
  886. ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
  887. CreateTime: time.Now(),
  888. Body: head + company + annotation,
  889. LinkArticleId: article.LinkArticleId,
  890. }
  891. if utils.RunMode == "debug" {
  892. logItem.ReportLink = "https://clpttest.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
  893. } else {
  894. logItem.ReportLink = "https://web.hzinsights.com/material/info/" + strconv.Itoa(article.ArticleId)
  895. }
  896. logItems = append(logItems, &logItem)
  897. }
  898. if len(logItems) > 0 {
  899. _, e := data_manage.AddCygxMinutesSummaryLogOrm(logItems)
  900. if e != nil {
  901. err = e
  902. return
  903. }
  904. }
  905. }
  906. //买方研选
  907. //{
  908. // var condition string
  909. // var pars []interface{}
  910. // condition += ` AND publish_date < ? AND publish_date >= ? `
  911. // pars = append(pars, tuesday, lastTuesday)
  912. // mfyxList := make([]*data_manage.CygxArticle, 0)
  913. //
  914. // //纪要
  915. // {
  916. // newCondition := condition + ` AND article_type_id = 1 `
  917. // list, e := data_manage.GetReportArticleList(newCondition, pars)
  918. // if e != nil {
  919. // err = e
  920. // fmt.Println("GetReportArticleList err:", e)
  921. // return
  922. // }
  923. // for _, article := range list {
  924. // mfyxList = append(mfyxList, article)
  925. // }
  926. // }
  927. // ////观点
  928. // //{
  929. // // newCondition := condition + ` AND article_type_id = 2 `
  930. // // list ,e := data_manage.GetReportArticleList(newCondition, pars)
  931. // // if e != nil {
  932. // // err = e
  933. // // fmt.Println("GetReportArticleList err:", e)
  934. // // return
  935. // // }
  936. // // for _, article := range list {
  937. // // mfyxList = append(mfyxList, article)
  938. // // }
  939. // //}
  940. // ////沙龙
  941. // //{
  942. // // newCondition := condition + ` AND article_type_id = 13 `
  943. // // list ,e := data_manage.GetReportArticleList(newCondition, pars)
  944. // // if e != nil {
  945. // // err = e
  946. // // fmt.Println("GetReportArticleList err:", e)
  947. // // return
  948. // // }
  949. // // for _, article := range list {
  950. // // mfyxList = append(mfyxList, article)
  951. // // }
  952. // //}
  953. // fmt.Println("mfyxList:", len(mfyxList))
  954. // var articleIdStr string
  955. // for _, v := range mfyxList {
  956. // articleIdStr += strconv.Itoa(v.ArticleId) + ","
  957. // }
  958. // mapArticleSubject := make(map[int]string)
  959. // articleIdStr = strings.TrimRight(articleIdStr, ",")
  960. // listSubject, e := data_manage.GetArticleSubjectList(articleIdStr)
  961. // if e != nil {
  962. // err = e
  963. // fmt.Println("GetArticleSubjectList err:", e)
  964. // return
  965. // }
  966. // for _, v := range listSubject {
  967. // mapArticleSubject[v.ArticleId] = v.SubjectName
  968. // }
  969. // var logItems []*data_manage.CygxMinutesSummaryLog
  970. // for _, article := range mfyxList {
  971. // head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
  972. // body := strings.ReplaceAll(article.Body, "<strong>", "")
  973. // body = strings.ReplaceAll(body, "</strong>", "")
  974. // body = strings.ReplaceAll(body, "</ol>", "</div>")
  975. // body = strings.ReplaceAll(body, "<ol>", "<div>")
  976. // body = strings.ReplaceAll(body, "</li>", "</p>")
  977. // body = strings.ReplaceAll(body, "<li>", "<p>")
  978. // re, _ := regexp.Compile("<strong.*?>")
  979. // body = re.ReplaceAllString(body, "")
  980. // reLi, _ := regexp.Compile("<li.*?>")
  981. // body = reLi.ReplaceAllString(body, "")
  982. // //研选的公司需要单独处理
  983. // //sliceSubjects := strings.Split(article.Stock, "/")
  984. // var company string
  985. // //if sliceSubjects[0] != "" {
  986. // // for _, vSubject := range sliceSubjects {
  987. // // sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  988. // // sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  989. // // subject := sliceXiahuaxian[0]
  990. // // company += "#" + subject
  991. // // }
  992. // // company = " <span style=\"color: #ff1720\">" + company + "</span>"
  993. // //}
  994. // if mapArticleSubject[article.ArticleId] != "" {
  995. // company = " <span style=\"color: #ff1720\">" + "#" + mapArticleSubject[article.ArticleId] + "</span>"
  996. // }
  997. // var plus int
  998. // coreIndex := strings.Index(body, "核心观点:")
  999. // plus = 15
  1000. // if coreIndex == -1 {
  1001. // coreIndex = strings.Index(body, "核心观点:")
  1002. // plus = 13
  1003. // }
  1004. // if coreIndex == -1 {
  1005. // coreIndex = strings.Index(body, "核心观点")
  1006. // plus = 12
  1007. // }
  1008. // if coreIndex == -1 {
  1009. // coreIndex = strings.Index(body, "核心结论:")
  1010. // plus = 15
  1011. // }
  1012. // if coreIndex == -1 {
  1013. // coreIndex = strings.Index(body, "核心结论:")
  1014. // plus = 13
  1015. // }
  1016. // if coreIndex == -1 {
  1017. // coreIndex = strings.Index(body, "核心结论")
  1018. // plus = 12
  1019. // }
  1020. // endIndex := strings.Index(body, "<hr")
  1021. // if coreIndex != -1 && endIndex != -1 {
  1022. // body = body[coreIndex+plus : endIndex]
  1023. // logItem := data_manage.CygxMinutesSummaryLog{
  1024. // ArticleId: int(articleId),
  1025. // Type: "YANX",
  1026. // ChartPermissionId: articleTypeChartPermissionIdMap[article.ArticleTypeId],
  1027. // CreateTime: time.Now(),
  1028. // Body: head + company + body,
  1029. // ReportLink: "https://details.hzinsights.com/cygx/report?id=" + article.ArticleIdMd5,
  1030. // LinkArticleId: article.LinkArticleId,
  1031. // }
  1032. // logItems = append(logItems, &logItem)
  1033. // }
  1034. // }
  1035. // if len(logItems) > 0 {
  1036. // _, e := data_manage.AddCygxMinutesSummaryLogOrm(logItems)
  1037. // if e != nil {
  1038. // err = e
  1039. // return
  1040. // }
  1041. // }
  1042. //
  1043. //}
  1044. return
  1045. }