cygx_research_summary.go 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956
  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, "2022-09-02 15:00:00")
  28. //lastfriday, _ = time.Parse(utils.FormatDateTime, "2022-08-26 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(62,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. ReportLink: "https://vmp.hzinsights.com/v2/articles/" + strconv.Itoa(article.ArticleId),
  151. LinkArticleId: article.LinkArticleId,
  152. }
  153. logItems = append(logItems, &logItem)
  154. }
  155. if len(logItems) > 0 {
  156. _, e := data_manage.AddCygxResearchSummaryLogOrm(logItems)
  157. if e != nil {
  158. err = e
  159. return
  160. }
  161. }
  162. }
  163. //产业调研纪要
  164. {
  165. var condition string
  166. var pars []interface{}
  167. condition += ` AND publish_date < ? AND publish_date >= ? `
  168. pars = append(pars, friday, lastfriday)
  169. cydyjyList := make([]*data_manage.CygxArticle, 0)
  170. //医药
  171. {
  172. newCondition := condition + ` AND category_id_two IN(28,93,301,71)`
  173. list, e := data_manage.GetReportArticleList(newCondition, pars)
  174. if e != nil {
  175. err = e
  176. fmt.Println("GetReportArticleList err:", e)
  177. return
  178. }
  179. for _, article := range list {
  180. cydyjyList = append(cydyjyList, article)
  181. }
  182. }
  183. //消费
  184. {
  185. newCondition := condition + ` AND category_id_two IN(32,58)`
  186. list, e := data_manage.GetReportArticleList(newCondition, pars)
  187. if e != nil {
  188. err = e
  189. fmt.Println("GetReportArticleList err:", e)
  190. return
  191. }
  192. for _, article := range list {
  193. cydyjyList = append(cydyjyList, article)
  194. }
  195. }
  196. //科技
  197. {
  198. newCondition := condition + ` AND category_id_two IN(79)`
  199. list, e := data_manage.GetReportArticleList(newCondition, pars)
  200. if e != nil {
  201. err = e
  202. fmt.Println("GetReportArticleList err:", e)
  203. return
  204. }
  205. for _, article := range list {
  206. cydyjyList = append(cydyjyList, article)
  207. }
  208. }
  209. //智造
  210. {
  211. newCondition := condition + ` AND category_id_two IN(84)`
  212. list, e := data_manage.GetReportArticleList(newCondition, pars)
  213. if e != nil {
  214. err = e
  215. fmt.Println("GetReportArticleList err:", e)
  216. return
  217. }
  218. for _, article := range list {
  219. cydyjyList = append(cydyjyList, article)
  220. }
  221. }
  222. var logItems []*data_manage.CygxResearchSummaryLog
  223. for _, article := range cydyjyList {
  224. head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
  225. sliceSubjects := strings.Split(article.Stock, "/")
  226. var company string
  227. if sliceSubjects[0] != "" {
  228. for _, vSubject := range sliceSubjects {
  229. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  230. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  231. subject := sliceXiahuaxian[0]
  232. company += "#" + subject
  233. }
  234. company = " <span style=\"color: #ff1720\">" + company + "</span>"
  235. }
  236. annotation := strings.ReplaceAll(article.Annotation, "<strong>", "")
  237. annotation = strings.ReplaceAll(annotation, "</strong>", "")
  238. annotation = strings.ReplaceAll(annotation, "</ol>", "</div>")
  239. annotation = strings.ReplaceAll(annotation, "<ol>", "<div>")
  240. annotation = strings.ReplaceAll(annotation, "</li>", "</p>")
  241. annotation = strings.ReplaceAll(annotation, "<li>", "<p>")
  242. re, _ := regexp.Compile("<strong.*?>")
  243. annotation = re.ReplaceAllString(annotation, "")
  244. reLi, _ := regexp.Compile("<li.*?>")
  245. annotation = reLi.ReplaceAllString(annotation, "")
  246. logItem := data_manage.CygxResearchSummaryLog{
  247. ArticleId: int(articleId),
  248. Type: "CYDYJY",
  249. ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
  250. CreateTime: time.Now(),
  251. Body: head + company + annotation,
  252. ReportLink: "https://vmp.hzinsights.com/v2/articles/" + strconv.Itoa(article.ArticleId),
  253. LinkArticleId: article.LinkArticleId,
  254. }
  255. logItems = append(logItems, &logItem)
  256. }
  257. if len(logItems) > 0 {
  258. _, e := data_manage.AddCygxResearchSummaryLogOrm(logItems)
  259. if e != nil {
  260. err = e
  261. return
  262. }
  263. }
  264. }
  265. //上市公司调研纪要
  266. {
  267. var condition string
  268. var pars []interface{}
  269. condition += ` AND publish_date < ? AND publish_date >= ? `
  270. pars = append(pars, friday, lastfriday)
  271. ssgsdyjyList := make([]*data_manage.CygxArticle, 0)
  272. //医药
  273. {
  274. newCondition := condition + ` AND category_id_two IN(74,96)`
  275. list, e := data_manage.GetReportArticleList(newCondition, pars)
  276. if e != nil {
  277. err = e
  278. fmt.Println("GetReportArticleList err:", e)
  279. return
  280. }
  281. for _, article := range list {
  282. ssgsdyjyList = append(ssgsdyjyList, article)
  283. }
  284. }
  285. //消费
  286. {
  287. newCondition := condition + ` AND category_id_two IN(88)`
  288. list, e := data_manage.GetReportArticleList(newCondition, pars)
  289. if e != nil {
  290. err = e
  291. fmt.Println("GetReportArticleList err:", e)
  292. return
  293. }
  294. for _, article := range list {
  295. ssgsdyjyList = append(ssgsdyjyList, article)
  296. }
  297. }
  298. //科技
  299. {
  300. newCondition := condition + ` AND category_id_two IN(45)`
  301. list, e := data_manage.GetReportArticleList(newCondition, pars)
  302. if e != nil {
  303. err = e
  304. fmt.Println("GetReportArticleList err:", e)
  305. return
  306. }
  307. for _, article := range list {
  308. ssgsdyjyList = append(ssgsdyjyList, article)
  309. }
  310. }
  311. //智造
  312. {
  313. newCondition := condition + ` AND category_id_two IN(86)`
  314. list, e := data_manage.GetReportArticleList(newCondition, pars)
  315. if e != nil {
  316. err = e
  317. fmt.Println("GetReportArticleList err:", e)
  318. return
  319. }
  320. for _, article := range list {
  321. ssgsdyjyList = append(ssgsdyjyList, article)
  322. }
  323. }
  324. var logItems []*data_manage.CygxResearchSummaryLog
  325. for _, article := range ssgsdyjyList {
  326. head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
  327. sliceSubjects := strings.Split(article.Stock, "/")
  328. var company string
  329. if sliceSubjects[0] != "" {
  330. for _, vSubject := range sliceSubjects {
  331. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  332. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  333. subject := sliceXiahuaxian[0]
  334. company += "#" + subject
  335. }
  336. company = " <span style=\"color: #ff1720\">" + company + "</span>"
  337. }
  338. annotation := strings.ReplaceAll(article.Annotation, "<strong>", "")
  339. annotation = strings.ReplaceAll(annotation, "</strong>", "")
  340. annotation = strings.ReplaceAll(annotation, "</ol>", "</div>")
  341. annotation = strings.ReplaceAll(annotation, "<ol>", "<div>")
  342. annotation = strings.ReplaceAll(annotation, "</li>", "</p>")
  343. annotation = strings.ReplaceAll(annotation, "<li>", "<p>")
  344. re, _ := regexp.Compile("<strong.*?>")
  345. annotation = re.ReplaceAllString(annotation, "")
  346. reLi, _ := regexp.Compile("<li.*?>")
  347. annotation = reLi.ReplaceAllString(annotation, "")
  348. logItem := data_manage.CygxResearchSummaryLog{
  349. ArticleId: int(articleId),
  350. Type: "SSGS",
  351. ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
  352. CreateTime: time.Now(),
  353. Body: head + company + annotation,
  354. ReportLink: "https://vmp.hzinsights.com/v2/articles/" + strconv.Itoa(article.ArticleId),
  355. LinkArticleId: article.LinkArticleId,
  356. }
  357. logItems = append(logItems, &logItem)
  358. }
  359. if len(logItems) > 0 {
  360. _, e := data_manage.AddCygxResearchSummaryLogOrm(logItems)
  361. if e != nil {
  362. err = e
  363. return
  364. }
  365. }
  366. }
  367. //买方研选
  368. //{
  369. // ids, e := data_manage.GetYanXuanArticleIdList()
  370. // if e != nil {
  371. // err = e
  372. // fmt.Println("GetReportArticleList err:", e)
  373. // return
  374. // }
  375. //
  376. // var condition string
  377. // var pars []interface{}
  378. // condition += ` AND publish_date < ? AND publish_date >= ? `
  379. // pars = append(pars, friday, lastfriday)
  380. // mfyxList := make([]*data_manage.CygxArticle, 0)
  381. //
  382. // //9.23新增研选所有类型的报告都要
  383. // newCondition := condition + ` AND article_type_id IN (`+ *ids +`) `
  384. // list, e := data_manage.GetReportArticleList(newCondition, pars)
  385. // if e != nil {
  386. // err = e
  387. // fmt.Println("GetReportArticleList err:", e)
  388. // return
  389. // }
  390. // for _, article := range list {
  391. // mfyxList = append(mfyxList, article)
  392. // }
  393. //
  394. // ////纪要
  395. // //{
  396. // // newCondition := condition + ` AND article_type_id = 1 `
  397. // // list, e := data_manage.GetReportArticleList(newCondition, pars)
  398. // // if e != nil {
  399. // // err = e
  400. // // fmt.Println("GetReportArticleList err:", e)
  401. // // return
  402. // // }
  403. // // for _, article := range list {
  404. // // mfyxList = append(mfyxList, article)
  405. // // }
  406. // //}
  407. // ////观点
  408. // //{
  409. // // newCondition := condition + ` AND article_type_id = 2 `
  410. // // list, e := data_manage.GetReportArticleList(newCondition, pars)
  411. // // if e != nil {
  412. // // err = e
  413. // // fmt.Println("GetReportArticleList err:", e)
  414. // // return
  415. // // }
  416. // // for _, article := range list {
  417. // // mfyxList = append(mfyxList, article)
  418. // // }
  419. // //}
  420. // ////沙龙
  421. // //{
  422. // // newCondition := condition + ` AND article_type_id = 13 `
  423. // // list, e := data_manage.GetReportArticleList(newCondition, pars)
  424. // // if e != nil {
  425. // // err = e
  426. // // fmt.Println("GetReportArticleList err:", e)
  427. // // return
  428. // // }
  429. // // for _, article := range list {
  430. // // mfyxList = append(mfyxList, article)
  431. // // }
  432. // //}
  433. // var articleIdStr string
  434. // for _, v := range mfyxList {
  435. // articleIdStr += strconv.Itoa(v.ArticleId) + ","
  436. // }
  437. // mapArticleSubject := make(map[int]string)
  438. // articleIdStr = strings.TrimRight(articleIdStr, ",")
  439. // listSubject, e := data_manage.GetArticleSubjectList(articleIdStr)
  440. // if e != nil {
  441. // err = e
  442. // fmt.Println("GetArticleSubjectList err:", e)
  443. // return
  444. // }
  445. // for _, v := range listSubject {
  446. // mapArticleSubject[v.ArticleId] = v.SubjectName
  447. // }
  448. // var logItems []*data_manage.CygxResearchSummaryLog
  449. // for _, article := range mfyxList {
  450. // head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
  451. // body := strings.ReplaceAll(article.Body, "<strong>", "")
  452. // body = strings.ReplaceAll(body, "</strong>", "")
  453. // body = strings.ReplaceAll(body, "</ol>", "</div>")
  454. // body = strings.ReplaceAll(body, "<ol>", "<div>")
  455. // body = strings.ReplaceAll(body, "</li>", "</p>")
  456. // body = strings.ReplaceAll(body, "<li>", "<p>")
  457. // re, _ := regexp.Compile("<strong.*?>")
  458. // body = re.ReplaceAllString(body, "")
  459. // reLi, _ := regexp.Compile("<li.*?>")
  460. // body = reLi.ReplaceAllString(body, "")
  461. // //研选的公司需要单独处理
  462. // //sliceSubjects := strings.Split(article.Stock, "/")
  463. // var company string
  464. // //if sliceSubjects[0] != "" {
  465. // // for _, vSubject := range sliceSubjects {
  466. // // sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  467. // // sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  468. // // subject := sliceXiahuaxian[0]
  469. // // company += "#" + subject
  470. // // }
  471. // // company = " <span style=\"color: #ff1720\">" + company + "</span>"
  472. // //}
  473. // if mapArticleSubject[article.ArticleId] != "" {
  474. // company = " <span style=\"color: #ff1720\">" + "#" + mapArticleSubject[article.ArticleId] + "</span>"
  475. // }
  476. // var plus int
  477. // coreIndex := strings.Index(body, "核心观点:")
  478. // plus = 15
  479. // if coreIndex == -1 {
  480. // coreIndex = strings.Index(body, "核心观点:")
  481. // plus = 13
  482. // }
  483. // if coreIndex == -1 {
  484. // coreIndex = strings.Index(body, "核心观点")
  485. // plus = 12
  486. // }
  487. // if coreIndex == -1 {
  488. // coreIndex = strings.Index(body, "核心结论:")
  489. // plus = 15
  490. // }
  491. // if coreIndex == -1 {
  492. // coreIndex = strings.Index(body, "核心结论:")
  493. // plus = 13
  494. // }
  495. // if coreIndex == -1 {
  496. // coreIndex = strings.Index(body, "核心结论")
  497. // plus = 12
  498. // }
  499. // endIndex := strings.Index(body, "<hr")
  500. // fmt.Println("ID:", article.ArticleId)
  501. // fmt.Println("coreIndex:", coreIndex, endIndex)
  502. // if coreIndex != -1 && endIndex != -1 {
  503. // body = body[coreIndex+plus : endIndex]
  504. // logItem := data_manage.CygxResearchSummaryLog{
  505. // ArticleId: int(articleId),
  506. // Type: "YANX",
  507. // ChartPermissionId: articleTypeChartPermissionIdMap[article.ArticleTypeId],
  508. // CreateTime: time.Now(),
  509. // Body: head + company + body,
  510. // ReportLink: "https://details.hzinsights.com/cygx/report?id=" + article.ArticleIdMd5,
  511. // LinkArticleId: article.LinkArticleId,
  512. // }
  513. // logItems = append(logItems, &logItem)
  514. // }
  515. // }
  516. // if len(logItems) > 0 {
  517. // _, e := data_manage.AddCygxResearchSummaryLogOrm(logItems)
  518. // if e != nil {
  519. // err = e
  520. // return
  521. // }
  522. // }
  523. //
  524. //}
  525. return
  526. }
  527. func CygxLastWeekSummary(cont context.Context) (err error) {
  528. defer func() {
  529. if err != nil {
  530. go alarm_msg.SendAlarmMsg("CygxLastWeekSummary-定时生成上周纪要汇总失败, ErrMsg:\n"+err.Error(), 3)
  531. fmt.Println(err)
  532. }
  533. }()
  534. tuesday := utils.GetNowWeekTuesday().Add(8 * time.Hour)
  535. lastTuesday := utils.GetLastWeekTuesday().Add(8 * time.Hour)
  536. lastMonth := int(lastTuesday.Month())
  537. month := int(tuesday.Month())
  538. lastDay := lastTuesday.Day()
  539. day := tuesday.Day()
  540. itemCrs := new(data_manage.CygxMinutesSummary)
  541. itemCrs.AdminId = 11
  542. itemCrs.AdminName = "admin"
  543. itemCrs.Title = fmt.Sprintf("上周纪要汇总(%d月%d日至%d月%d日)", lastMonth, lastDay, month, day)
  544. itemCrs.Department = "弘则产品组"
  545. itemCrs.Abstract = ""
  546. itemCrs.PublishStatus = 0
  547. //itemCrs.Periods = strconv.Itoa(total + 1)
  548. itemCrs.CreateTime = time.Now()
  549. itemCrs.LastUpdatedTime = time.Now()
  550. itemCrs.PublishDate = time.Now()
  551. articleId, e := data_manage.AddCygxMinutesSummaryOrm(itemCrs)
  552. if e != nil {
  553. err = e
  554. return
  555. }
  556. mappingList, err := data_manage.CygxReportMappingist()
  557. if err != nil {
  558. return
  559. }
  560. CategoryChartPermissionIdMap := make(map[int]int)
  561. for _, item := range mappingList {
  562. CategoryChartPermissionIdMap[item.CategoryId] = item.ChartPermissionId
  563. }
  564. yanxMappingList, err := data_manage.CygxArticleTypeMappingList()
  565. if err != nil {
  566. return
  567. }
  568. articleTypeChartPermissionIdMap := make(map[int]int)
  569. for _, item := range yanxMappingList {
  570. articleTypeChartPermissionIdMap[item.ArticleTypeId] = item.YanxPermissionId
  571. }
  572. //产业调研纪要
  573. {
  574. var condition string
  575. var pars []interface{}
  576. condition += ` AND publish_date < ? AND publish_date >= ? `
  577. pars = append(pars, tuesday, lastTuesday)
  578. cydyjyList := make([]*data_manage.CygxArticle, 0)
  579. //医药
  580. {
  581. newCondition := condition + ` AND category_id_two IN(28,93,301,71)`
  582. list, e := data_manage.GetReportArticleList(newCondition, pars)
  583. if e != nil {
  584. err = e
  585. fmt.Println("GetReportArticleList err:", e)
  586. return
  587. }
  588. for _, article := range list {
  589. cydyjyList = append(cydyjyList, article)
  590. }
  591. }
  592. //消费
  593. {
  594. newCondition := condition + ` AND category_id_two IN(32,58)`
  595. list, e := data_manage.GetReportArticleList(newCondition, pars)
  596. if e != nil {
  597. err = e
  598. fmt.Println("GetReportArticleList err:", e)
  599. return
  600. }
  601. for _, article := range list {
  602. cydyjyList = append(cydyjyList, article)
  603. }
  604. }
  605. //科技
  606. {
  607. newCondition := condition + ` AND category_id_two IN(79)`
  608. list, e := data_manage.GetReportArticleList(newCondition, pars)
  609. if e != nil {
  610. err = e
  611. fmt.Println("GetReportArticleList err:", e)
  612. return
  613. }
  614. for _, article := range list {
  615. cydyjyList = append(cydyjyList, article)
  616. }
  617. }
  618. //智造
  619. {
  620. newCondition := condition + ` AND category_id_two IN(84)`
  621. list, e := data_manage.GetReportArticleList(newCondition, pars)
  622. if e != nil {
  623. err = e
  624. fmt.Println("GetReportArticleList err:", e)
  625. return
  626. }
  627. for _, article := range list {
  628. cydyjyList = append(cydyjyList, article)
  629. }
  630. }
  631. var logItems []*data_manage.CygxMinutesSummaryLog
  632. for _, article := range cydyjyList {
  633. head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
  634. sliceSubjects := strings.Split(article.Stock, "/")
  635. var company string
  636. if sliceSubjects[0] != "" {
  637. for _, vSubject := range sliceSubjects {
  638. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  639. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  640. subject := sliceXiahuaxian[0]
  641. company += "#" + subject
  642. }
  643. company = " <span style=\"color: #ff1720\">" + company + "</span>"
  644. }
  645. annotation := strings.ReplaceAll(article.Annotation, "<strong>", "")
  646. annotation = strings.ReplaceAll(annotation, "</strong>", "")
  647. annotation = strings.ReplaceAll(annotation, "</ol>", "</div>")
  648. annotation = strings.ReplaceAll(annotation, "<ol>", "<div>")
  649. annotation = strings.ReplaceAll(annotation, "</li>", "</p>")
  650. annotation = strings.ReplaceAll(annotation, "<li>", "<p>")
  651. re, _ := regexp.Compile("<strong.*?>")
  652. annotation = re.ReplaceAllString(annotation, "")
  653. reLi, _ := regexp.Compile("<li.*?>")
  654. annotation = reLi.ReplaceAllString(annotation, "")
  655. logItem := data_manage.CygxMinutesSummaryLog{
  656. ArticleId: int(articleId),
  657. Type: "CYDYJY",
  658. ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
  659. CreateTime: time.Now(),
  660. Body: head + company + annotation,
  661. ReportLink: "https://vmp.hzinsights.com/v2/articles/" + strconv.Itoa(article.ArticleId),
  662. LinkArticleId: article.LinkArticleId,
  663. }
  664. logItems = append(logItems, &logItem)
  665. }
  666. if len(logItems) > 0 {
  667. _, e := data_manage.AddCygxMinutesSummaryLogOrm(logItems)
  668. if e != nil {
  669. err = e
  670. return
  671. }
  672. }
  673. }
  674. //上市公司调研纪要
  675. {
  676. var condition string
  677. var pars []interface{}
  678. condition += ` AND publish_date < ? AND publish_date >= ? `
  679. pars = append(pars, tuesday, lastTuesday)
  680. ssgsdyjyList := make([]*data_manage.CygxArticle, 0)
  681. //医药
  682. {
  683. newCondition := condition + ` AND category_id_two IN(74,96)`
  684. list, e := data_manage.GetReportArticleList(newCondition, pars)
  685. if e != nil {
  686. err = e
  687. fmt.Println("GetReportArticleList err:", e)
  688. return
  689. }
  690. for _, article := range list {
  691. ssgsdyjyList = append(ssgsdyjyList, article)
  692. }
  693. }
  694. //消费
  695. {
  696. newCondition := condition + ` AND category_id_two IN(88)`
  697. list, e := data_manage.GetReportArticleList(newCondition, pars)
  698. if e != nil {
  699. err = e
  700. fmt.Println("GetReportArticleList err:", e)
  701. return
  702. }
  703. for _, article := range list {
  704. ssgsdyjyList = append(ssgsdyjyList, article)
  705. }
  706. }
  707. //科技
  708. {
  709. newCondition := condition + ` AND category_id_two IN(45)`
  710. list, e := data_manage.GetReportArticleList(newCondition, pars)
  711. if e != nil {
  712. err = e
  713. fmt.Println("GetReportArticleList err:", e)
  714. return
  715. }
  716. for _, article := range list {
  717. ssgsdyjyList = append(ssgsdyjyList, article)
  718. }
  719. }
  720. //智造
  721. {
  722. newCondition := condition + ` AND category_id_two IN(86)`
  723. list, e := data_manage.GetReportArticleList(newCondition, pars)
  724. if e != nil {
  725. err = e
  726. fmt.Println("GetReportArticleList err:", e)
  727. return
  728. }
  729. for _, article := range list {
  730. ssgsdyjyList = append(ssgsdyjyList, article)
  731. }
  732. }
  733. var logItems []*data_manage.CygxMinutesSummaryLog
  734. for _, article := range ssgsdyjyList {
  735. head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
  736. sliceSubjects := strings.Split(article.Stock, "/")
  737. var company string
  738. if sliceSubjects[0] != "" {
  739. for _, vSubject := range sliceSubjects {
  740. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  741. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  742. subject := sliceXiahuaxian[0]
  743. company += "#" + subject
  744. }
  745. company = " <span style=\"color: #ff1720\">" + company + "</span>"
  746. }
  747. annotation := strings.ReplaceAll(article.Annotation, "<strong>", "")
  748. annotation = strings.ReplaceAll(annotation, "</strong>", "")
  749. annotation = strings.ReplaceAll(annotation, "</ol>", "</div>")
  750. annotation = strings.ReplaceAll(annotation, "<ol>", "<div>")
  751. annotation = strings.ReplaceAll(annotation, "</li>", "</p>")
  752. annotation = strings.ReplaceAll(annotation, "<li>", "<p>")
  753. re, _ := regexp.Compile("<strong.*?>")
  754. annotation = re.ReplaceAllString(annotation, "")
  755. reLi, _ := regexp.Compile("<li.*?>")
  756. annotation = reLi.ReplaceAllString(annotation, "")
  757. logItem := data_manage.CygxMinutesSummaryLog{
  758. ArticleId: int(articleId),
  759. Type: "SSGS",
  760. ChartPermissionId: CategoryChartPermissionIdMap[article.CategoryIdTwo],
  761. CreateTime: time.Now(),
  762. Body: head + company + annotation,
  763. ReportLink: "https://vmp.hzinsights.com/v2/articles/" + strconv.Itoa(article.ArticleId),
  764. LinkArticleId: article.LinkArticleId,
  765. }
  766. logItems = append(logItems, &logItem)
  767. }
  768. if len(logItems) > 0 {
  769. _, e := data_manage.AddCygxMinutesSummaryLogOrm(logItems)
  770. if e != nil {
  771. err = e
  772. return
  773. }
  774. }
  775. }
  776. //买方研选
  777. //{
  778. // var condition string
  779. // var pars []interface{}
  780. // condition += ` AND publish_date < ? AND publish_date >= ? `
  781. // pars = append(pars, tuesday, lastTuesday)
  782. // mfyxList := make([]*data_manage.CygxArticle, 0)
  783. //
  784. // //纪要
  785. // {
  786. // newCondition := condition + ` AND article_type_id = 1 `
  787. // list, e := data_manage.GetReportArticleList(newCondition, pars)
  788. // if e != nil {
  789. // err = e
  790. // fmt.Println("GetReportArticleList err:", e)
  791. // return
  792. // }
  793. // for _, article := range list {
  794. // mfyxList = append(mfyxList, article)
  795. // }
  796. // }
  797. // ////观点
  798. // //{
  799. // // newCondition := condition + ` AND article_type_id = 2 `
  800. // // list ,e := data_manage.GetReportArticleList(newCondition, pars)
  801. // // if e != nil {
  802. // // err = e
  803. // // fmt.Println("GetReportArticleList err:", e)
  804. // // return
  805. // // }
  806. // // for _, article := range list {
  807. // // mfyxList = append(mfyxList, article)
  808. // // }
  809. // //}
  810. // ////沙龙
  811. // //{
  812. // // newCondition := condition + ` AND article_type_id = 13 `
  813. // // list ,e := data_manage.GetReportArticleList(newCondition, pars)
  814. // // if e != nil {
  815. // // err = e
  816. // // fmt.Println("GetReportArticleList err:", e)
  817. // // return
  818. // // }
  819. // // for _, article := range list {
  820. // // mfyxList = append(mfyxList, article)
  821. // // }
  822. // //}
  823. // fmt.Println("mfyxList:", len(mfyxList))
  824. // var articleIdStr string
  825. // for _, v := range mfyxList {
  826. // articleIdStr += strconv.Itoa(v.ArticleId) + ","
  827. // }
  828. // mapArticleSubject := make(map[int]string)
  829. // articleIdStr = strings.TrimRight(articleIdStr, ",")
  830. // listSubject, e := data_manage.GetArticleSubjectList(articleIdStr)
  831. // if e != nil {
  832. // err = e
  833. // fmt.Println("GetArticleSubjectList err:", e)
  834. // return
  835. // }
  836. // for _, v := range listSubject {
  837. // mapArticleSubject[v.ArticleId] = v.SubjectName
  838. // }
  839. // var logItems []*data_manage.CygxMinutesSummaryLog
  840. // for _, article := range mfyxList {
  841. // head := "<div class=\"title-content\">\n 【" + article.Title + "】 "
  842. // body := strings.ReplaceAll(article.Body, "<strong>", "")
  843. // body = strings.ReplaceAll(body, "</strong>", "")
  844. // body = strings.ReplaceAll(body, "</ol>", "</div>")
  845. // body = strings.ReplaceAll(body, "<ol>", "<div>")
  846. // body = strings.ReplaceAll(body, "</li>", "</p>")
  847. // body = strings.ReplaceAll(body, "<li>", "<p>")
  848. // re, _ := regexp.Compile("<strong.*?>")
  849. // body = re.ReplaceAllString(body, "")
  850. // reLi, _ := regexp.Compile("<li.*?>")
  851. // body = reLi.ReplaceAllString(body, "")
  852. // //研选的公司需要单独处理
  853. // //sliceSubjects := strings.Split(article.Stock, "/")
  854. // var company string
  855. // //if sliceSubjects[0] != "" {
  856. // // for _, vSubject := range sliceSubjects {
  857. // // sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  858. // // sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  859. // // subject := sliceXiahuaxian[0]
  860. // // company += "#" + subject
  861. // // }
  862. // // company = " <span style=\"color: #ff1720\">" + company + "</span>"
  863. // //}
  864. // if mapArticleSubject[article.ArticleId] != "" {
  865. // company = " <span style=\"color: #ff1720\">" + "#" + mapArticleSubject[article.ArticleId] + "</span>"
  866. // }
  867. // var plus int
  868. // coreIndex := strings.Index(body, "核心观点:")
  869. // plus = 15
  870. // if coreIndex == -1 {
  871. // coreIndex = strings.Index(body, "核心观点:")
  872. // plus = 13
  873. // }
  874. // if coreIndex == -1 {
  875. // coreIndex = strings.Index(body, "核心观点")
  876. // plus = 12
  877. // }
  878. // if coreIndex == -1 {
  879. // coreIndex = strings.Index(body, "核心结论:")
  880. // plus = 15
  881. // }
  882. // if coreIndex == -1 {
  883. // coreIndex = strings.Index(body, "核心结论:")
  884. // plus = 13
  885. // }
  886. // if coreIndex == -1 {
  887. // coreIndex = strings.Index(body, "核心结论")
  888. // plus = 12
  889. // }
  890. // endIndex := strings.Index(body, "<hr")
  891. // if coreIndex != -1 && endIndex != -1 {
  892. // body = body[coreIndex+plus : endIndex]
  893. // logItem := data_manage.CygxMinutesSummaryLog{
  894. // ArticleId: int(articleId),
  895. // Type: "YANX",
  896. // ChartPermissionId: articleTypeChartPermissionIdMap[article.ArticleTypeId],
  897. // CreateTime: time.Now(),
  898. // Body: head + company + body,
  899. // ReportLink: "https://details.hzinsights.com/cygx/report?id=" + article.ArticleIdMd5,
  900. // LinkArticleId: article.LinkArticleId,
  901. // }
  902. // logItems = append(logItems, &logItem)
  903. // }
  904. // }
  905. // if len(logItems) > 0 {
  906. // _, e := data_manage.AddCygxMinutesSummaryLogOrm(logItems)
  907. // if e != nil {
  908. // err = e
  909. // return
  910. // }
  911. // }
  912. //
  913. //}
  914. return
  915. }