report.go 131 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "fmt"
  6. "github.com/medivhzhan/weapp/v2"
  7. "github.com/rdlucklib/rdluck_tools/paging"
  8. "hongze/hongze_cygx/models"
  9. "hongze/hongze_cygx/services"
  10. "hongze/hongze_cygx/utils"
  11. "html"
  12. "strconv"
  13. "strings"
  14. "time"
  15. )
  16. // 报告
  17. type ReportController struct {
  18. BaseAuthController
  19. }
  20. type ReportCommonController struct {
  21. BaseCommonController
  22. }
  23. // @Title 行业报告分类列表接口
  24. // @Description 获取行业报告分类列表接口
  25. // @Param ChartPermissionId query int true "分类ID"
  26. // @Success 200 {object} models.IndustrialManagementList
  27. // @router /home/tradeList [get]
  28. func (this *ReportController) TradeList() {
  29. br := new(models.BaseResponse).Init()
  30. defer func() {
  31. this.Data["json"] = br
  32. this.ServeJSON()
  33. }()
  34. user := this.User
  35. if user == nil {
  36. br.Msg = "请重新登录"
  37. br.Ret = 408
  38. return
  39. }
  40. //uid := user.UserId
  41. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  42. if ChartPermissionId < 1 {
  43. br.Msg = "请输入分类ID"
  44. return
  45. }
  46. listCategory, err := models.GetTradeArticleAndProductInterior(ChartPermissionId)
  47. if err != nil {
  48. br.Msg = "获取信息失败"
  49. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  50. return
  51. }
  52. var list []*models.TradeReportMapping
  53. categoryMap := make(map[int]int)
  54. for _, v := range listCategory {
  55. if categoryMap[v.CategoryId] > 0 {
  56. continue
  57. }
  58. categoryMap[v.CategoryId] = v.CategoryId
  59. list = append(list, v)
  60. }
  61. //加了一个需求,现有数据结构不支持,手动添加 2023-06-12
  62. //if ChartPermissionId == utils.KE_JI_ID {
  63. // list = append(list, &models.TradeReportMapping{MatchTypeName: "AI前沿", CategoryId: utils.ACTEGORY_ID_AI_QY})
  64. //}
  65. //var condition string
  66. //var pars []interface{}
  67. for k, v := range list {
  68. //if v.PolymerizationId != "" {
  69. // condition = ` AND a.category_id IN(` + v.PolymerizationId + `)`
  70. //} else {
  71. // condition = ` AND a.category_id IN(` + strconv.Itoa(v.CategoryId) + `)`
  72. //}
  73. pageSize := 1
  74. var listArticle []*models.ReportArticle
  75. if v.CategoryId == utils.ACTEGORY_ID_AI_QY {
  76. //加了一个需求,现有数据结构不支持,手动添加 2023-06-12
  77. listArticle, _, err = services.GetAiQianYanArtilceList(0, pageSize)
  78. if err != nil && err.Error() != utils.ErrNoRow() {
  79. br.Msg = "获取信息失败"
  80. br.Msg = "GetHomeList,Err:" + err.Error()
  81. return
  82. }
  83. //for _, vAi := range listArticleAi {
  84. // listArticle = append(listArticle, &models.ReportArticle{
  85. // CategoryId: vAi.CategoryId,
  86. // PublishDate: vAi.PublishDate,
  87. // })
  88. //}
  89. } else {
  90. listArticle, _, err = models.GetReportAndproductIndustrylList(v.CategoryId, 0, pageSize)
  91. if err != nil && err.Error() != utils.ErrNoRow() {
  92. br.Msg = "获取信息失败"
  93. br.Msg = "GetHomeList,Err:" + err.Error()
  94. return
  95. }
  96. }
  97. //listArticle, _, err := models.GetReportAndproductIndustrylList(v.CategoryId, 0, 1)
  98. if len(listArticle) > 0 {
  99. list[k].UpdateTime = utils.StrTimeToTime(listArticle[0].PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式 }
  100. }
  101. }
  102. resp := new(models.TradeReportMappingResp)
  103. resp.List = list
  104. br.Ret = 200
  105. br.Success = true
  106. br.Msg = "获取成功"
  107. br.Data = resp
  108. }
  109. // @Title 产业报告分类列表接口
  110. // @Description 获取产业报告分类列表接口
  111. // @Param ChartPermissionId query int true "分类ID"
  112. // @Param IsNewLabel query string true "是否属于新标签,1是,0否"
  113. // @Param IsDeepLabel query string true "是否属于深标签,1是,0否"
  114. // @Param KeyWord query string true "搜索关键词"
  115. // @Param OrderColumn query int true "排序字段 ,NewTime 最近更新 ,Recommend弘则推荐"
  116. // @Param DeepCover query int false "深度覆盖:0-否;1-是"
  117. // @Param RecommendFocus query int false "推荐关注:0-否;1-是"
  118. // @Param PageSize query int true "每页数据条数"
  119. // @Param CurrentIndex query int true "当前页页码,从1开始"
  120. // @Success 200 {object} models.IndustrialManagementList
  121. // @router /home/industryList [get]
  122. func (this *ReportController) IndustryList() {
  123. br := new(models.BaseResponse).Init()
  124. defer func() {
  125. this.Data["json"] = br
  126. this.ServeJSON()
  127. }()
  128. user := this.User
  129. if user == nil {
  130. br.Msg = "请重新登录"
  131. br.Ret = 408
  132. return
  133. }
  134. uid := user.UserId
  135. fmt.Println(uid)
  136. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  137. orderColumn := this.GetString("OrderColumn")
  138. orderColumnNew := this.GetString("OrderColumn")
  139. isNewLabel := this.GetString("IsNewLabel")
  140. isDeepLabel := this.GetString("IsDeepLabel")
  141. keyWord := this.GetString("KeyWord")
  142. pageSize, _ := this.GetInt("PageSize")
  143. currentIndex, _ := this.GetInt("CurrentIndex")
  144. deepCover, _ := this.GetInt("DeepCover")
  145. recommendFocus, _ := this.GetInt("RecommendFocus")
  146. var orderSrt string
  147. var condition string
  148. var startSize int
  149. resp := new(models.IndustrialManagementList)
  150. if pageSize <= 0 {
  151. pageSize = utils.PageSize20
  152. }
  153. if currentIndex <= 0 {
  154. currentIndex = 1
  155. }
  156. startSize = paging.StartIndex(currentIndex, pageSize)
  157. if isNewLabel == "1" {
  158. condition += ` AND is_new_label = ` + isNewLabel
  159. }
  160. if isDeepLabel == "1" {
  161. condition += ` AND is_deep_label = ` + isDeepLabel
  162. }
  163. if keyWord != "" {
  164. condition += ` AND subject_names LIKE '%` + keyWord + `%'`
  165. }
  166. var sqlChartPermissionId string
  167. if ChartPermissionId > 0 {
  168. sqlChartPermissionId += ` AND man_g.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE chart_permission_id = ` + strconv.Itoa(ChartPermissionId) + ` ) `
  169. condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
  170. }
  171. // 深度覆盖
  172. if deepCover == 1 {
  173. // 查询深标签产业报告数
  174. var deepCondition string
  175. var deepPars []interface{}
  176. deepCondition += ` AND man.is_deep_label = 1`
  177. if ChartPermissionId > 0 {
  178. deepCondition += ` AND man.chart_permission_id = ?`
  179. deepPars = append(deepPars, ChartPermissionId)
  180. }
  181. industryCountList, e := models.GetIndustryArtCountByCondition(deepCondition, deepPars)
  182. if e != nil {
  183. br.Msg = "获取信息失败"
  184. br.ErrMsg = "获取深标签产业报告数失败, Err: " + e.Error()
  185. return
  186. }
  187. deepIdArr := make([]string, 0)
  188. for i := range industryCountList {
  189. if industryCountList[i].ArtNum > 10 {
  190. deepIdArr = append(deepIdArr, strconv.Itoa(industryCountList[i].IndustrialManagementId))
  191. }
  192. }
  193. deepIds := strings.Join(deepIdArr, ",")
  194. if deepIds != "" {
  195. condition = `AND man.industrial_management_id IN (` + deepIds + `)`
  196. }
  197. }
  198. // 推荐关注
  199. if recommendFocus == 1 {
  200. condition += ` AND man.recommended_index >= 80`
  201. }
  202. // 列表总数据量
  203. var list []*models.IndustrialManagement
  204. total, err := models.GetIndustrialManagementAllCount(condition)
  205. if err != nil {
  206. br.Msg = "获取信息失败"
  207. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  208. return
  209. }
  210. page := paging.GetPaging(currentIndex, pageSize, total)
  211. if orderColumn == "" {
  212. orderColumn = "NewTime"
  213. }
  214. if orderColumn == "NewTime" {
  215. orderSrt = "update_time DESC"
  216. } else {
  217. orderSrt = "man.recommended_index DESC,update_time DESC"
  218. }
  219. if ChartPermissionId == 0 {
  220. ChartPermissionId = 20
  221. }
  222. // 阅读第三的产业详情
  223. //detailHot3, err := models.GetIndustrialManagementHot3(ChartPermissionId)
  224. //if err != nil {
  225. // br.Msg = "获取信息失败"
  226. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  227. // return
  228. //}
  229. list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize)
  230. if err != nil {
  231. br.Msg = "获取信息失败"
  232. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  233. return
  234. }
  235. // 获取近一个月产业报告阅读次数最多的产业
  236. var topCond string
  237. var topPars []interface{}
  238. //topReadIndustryId := 0
  239. if ChartPermissionId > 0 {
  240. topCond += ` AND chart_permission_id = ?`
  241. topPars = append(topPars, ChartPermissionId)
  242. }
  243. list, err = services.HandleIndustryList(list, user)
  244. if orderColumnNew != "" {
  245. item := new(models.CygxReportIndustrialSeaarchHistory)
  246. item.UserId = user.UserId
  247. item.Mobile = user.Mobile
  248. item.CompanyId = user.CompanyId
  249. item.CompanyName = user.CompanyName
  250. item.CreateTime = time.Now()
  251. item.IsDeepLabel = isDeepLabel
  252. item.IsNewLabel = isNewLabel
  253. item.ChartPermissionId = ChartPermissionId
  254. if orderColumnNew == "NewTime" {
  255. item.OrderColumn = "0"
  256. } else {
  257. item.OrderColumn = "1"
  258. }
  259. go models.AddCygxReportIndustrialSeaarchHistory(item)
  260. }
  261. resp.List = list
  262. resp.Paging = page
  263. br.Ret = 200
  264. br.Success = true
  265. br.Msg = "获取成功"
  266. br.Data = resp
  267. }
  268. // @Title 产业下所关联的文章分类列表
  269. // @Description 产业下所关联的文章分类列表接口
  270. // @Param IndustrialManagementId query int true "产业ID"
  271. // @Param ShowTimeLine query int true "是否展示时间线 0不展示,1展示"
  272. // @Param IsSendWx query int false "是否是通过微信模版进来的 1是,其它否"
  273. // @Param ChapterId query int false "晨会精华段落ID"
  274. // @Success 200 {object} models.IndustrialToArticleCategoryListRep
  275. // @router /toArticleCategoryList [get]
  276. func (this *ReportController) ArticleCategoryList() {
  277. br := new(models.BaseResponse).Init()
  278. defer func() {
  279. this.Data["json"] = br
  280. this.ServeJSON()
  281. }()
  282. user := this.User
  283. if user == nil {
  284. br.Msg = "请重新登录"
  285. br.Ret = 408
  286. return
  287. }
  288. //uid := user.UserId
  289. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  290. if industrialManagementId < 1 {
  291. br.Msg = "请输入分类ID"
  292. return
  293. }
  294. showTimeLine, _ := this.GetInt("ShowTimeLine", 0)
  295. isSendWx, _ := this.GetInt("IsSendWx")
  296. chapterId, _ := this.GetInt("ChapterId")
  297. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  298. if err != nil {
  299. br.Msg = "获取信息失败"
  300. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  301. return
  302. }
  303. listCategory, err := models.IndustrialToArticleAndProductInteriorCategoryNew(industrialManagementId)
  304. if err != nil {
  305. br.Msg = "获取信息失败"
  306. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  307. return
  308. }
  309. var list []*models.IndustrialToArticleCategoryRep
  310. categoryMap := make(map[int]int)
  311. for _, v := range listCategory {
  312. if categoryMap[v.CategoryId] > 0 {
  313. continue
  314. }
  315. categoryMap[v.CategoryId] = v.CategoryId
  316. list = append(list, v)
  317. }
  318. // 用户权限
  319. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  320. if e != nil {
  321. br.Msg = "获取失败"
  322. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  323. return
  324. }
  325. videoSimple := new(models.MicroVideoSimpleInfo)
  326. // 权限
  327. var au *models.UserPermissionAuthInfo
  328. video, err := models.GetMicroRoadshowVideoByIndustryId(industrialManagementId)
  329. if err != nil {
  330. if err.Error() != utils.ErrNoRow() {
  331. br.Msg = "获取产业视频失败"
  332. br.ErrMsg = "获取产业视频失败,Err:" + err.Error()
  333. return
  334. }
  335. } else {
  336. videoSimple.Id = video.VideoId
  337. videoSimple.Title = "5min逻辑【" + video.IndustryName + "】解析"
  338. videoSimple.BackgroundImg = video.ImgUrl
  339. videoSimple.DetailImgUrl = video.DetailImgUrl
  340. if videoSimple.BackgroundImg == "" {
  341. // 获取默认图配置
  342. _, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
  343. if e != nil {
  344. br.Msg = "获取视频默认配置图失败"
  345. br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
  346. return
  347. }
  348. videoSimple.BackgroundImg = videoMap[video.ChartPermissionId]
  349. }
  350. videoSimple.PlaySeconds = video.VideoDuration
  351. videoSimple.ResourceUrl = video.VideoUrl
  352. au = new(models.UserPermissionAuthInfo)
  353. au.SellerName = authInfo.SellerName
  354. au.SellerMobile = authInfo.SellerMobile
  355. au.HasPermission = authInfo.HasPermission
  356. au.OperationMode = authInfo.OperationMode
  357. if au.HasPermission == 1 {
  358. // 非宏观权限进一步判断是否有权限
  359. if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
  360. au.HasPermission = 2
  361. }
  362. }
  363. // 无权限的弹框提示
  364. if au.HasPermission != 1 {
  365. if au.OperationMode == services.UserPermissionOperationModeCall {
  366. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  367. } else {
  368. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  369. }
  370. videoSimple.ResourceUrl = ""
  371. }
  372. }
  373. //detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  374. //if err != nil {
  375. // br.Msg = "获取信息失败"
  376. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  377. // return
  378. //}
  379. //时间线
  380. if showTimeLine == 1 {
  381. timeLineItem := models.IndustrialToArticleCategoryRep{
  382. CategoryId: 99999,
  383. MatchTypeName: "时间线",
  384. }
  385. timeLineList, err := models.GetTimeLineReportIndustrialList(user.UserId, industrialManagementId, 0, 30)
  386. if err != nil {
  387. br.Msg = "获取信息失败"
  388. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  389. return
  390. }
  391. //查询用户今天是否看过时间线
  392. //haveMorningMeeting := false
  393. //var morningMeetingTime string
  394. //count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  395. //if err != nil {
  396. // br.Msg = "查询浏览记录数量失败"
  397. // br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  398. // return
  399. //}
  400. //var recordItem *models.CygxPageHistoryRecord
  401. //if count > 1 {
  402. // recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  403. // if err != nil {
  404. // br.Msg = "查询浏览记录失败"
  405. // br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  406. // return
  407. // }
  408. //}
  409. for _, v := range timeLineList {
  410. if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishTime)) {
  411. if v.SubCategoryName == "时间线" {
  412. //haveMorningMeeting = true
  413. //morningMeetingTime = v.PublishTime
  414. continue
  415. }
  416. timeLineItem.IsRed = true
  417. }
  418. }
  419. //因为无法记录用户是否看过晨会点评,所以用用户今天是否看过时间线来判断是否显示小红点,这里是判断分类的小红点
  420. //timeLineRed := false
  421. //if count < 2 {
  422. // timeLineRed = true
  423. //} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(morningMeetingTime)) {
  424. // timeLineRed = true
  425. //}
  426. //if !timeLineItem.IsRed && timeLineRed && haveMorningMeeting {
  427. // timeLineItem.IsRed = true
  428. //}
  429. list = append([]*models.IndustrialToArticleCategoryRep{&timeLineItem}, list...)
  430. if chapterId > 0 && isSendWx == 1 {
  431. go services.AddCygxMorningMeetingReviewChapterHistory(user, chapterId, "微信")
  432. }
  433. }
  434. resp := new(models.IndustrialToArticleCategoryListRep)
  435. resp.List = list
  436. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  437. resp.IndustryName = detail.IndustryName
  438. resp.IndustrialManagementId = industrialManagementId
  439. resp.AuthInfo = au
  440. if videoSimple.Id > 0 {
  441. resp.IndustryVideo = videoSimple
  442. }
  443. if isSendWx == 1 {
  444. industryUserFollowMap, err := services.GetIndustryUserFollowMap(user)
  445. if err != nil {
  446. br.Msg = "获取信息失败"
  447. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  448. return
  449. }
  450. resp.IsFollowButton = industryUserFollowMap[industrialManagementId]
  451. resp.IsShowFollowButton = true
  452. }
  453. br.Ret = 200
  454. br.Success = true
  455. br.Msg = "获取成功"
  456. br.Data = resp
  457. }
  458. // @Title 产业文章列表接口
  459. // @Description 获取产业文章列表接口
  460. // @Param PageSize query int true "每页数据条数"
  461. // @Param CurrentIndex query int true "当前页页码,从1开始"
  462. // @Param CategoryId query int true "分类ID"
  463. // @Param IndustrialManagementId query int true "产业ID"
  464. // @Success 200 {object} models.TacticsListResp
  465. // @router /industry/ArticleList [get]
  466. func (this *ReportController) List() {
  467. br := new(models.BaseResponse).Init()
  468. defer func() {
  469. this.Data["json"] = br
  470. this.ServeJSON()
  471. }()
  472. user := this.User
  473. if user == nil {
  474. br.Msg = "请重新登录"
  475. br.Ret = 408
  476. return
  477. }
  478. uid := user.UserId
  479. pageSize, _ := this.GetInt("PageSize")
  480. currentIndex, _ := this.GetInt("CurrentIndex")
  481. categoryId, _ := this.GetInt("CategoryId")
  482. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  483. var startSize int
  484. if pageSize <= 0 {
  485. pageSize = utils.PageSize20
  486. }
  487. if currentIndex <= 0 {
  488. currentIndex = 1
  489. }
  490. startSize = paging.StartIndex(currentIndex, pageSize)
  491. var pars []interface{}
  492. var total int
  493. page := paging.GetPaging(currentIndex, pageSize, total)
  494. if categoryId < 1 {
  495. br.Msg = "请输入分类ID"
  496. return
  497. }
  498. if industrialManagementId < 1 {
  499. br.Msg = "请输入产业ID"
  500. return
  501. }
  502. if categoryId != 99999 {
  503. resp := new(models.TacticsListResp)
  504. list, total, err := models.GetReportAndproductInteriorIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
  505. if err != nil {
  506. br.Msg = "获取信息失败"
  507. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  508. return
  509. }
  510. page = paging.GetPaging(currentIndex, pageSize, total)
  511. //对应分类的所图片
  512. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  513. if err != nil {
  514. br.Msg = "获取数据失败"
  515. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  516. return
  517. }
  518. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  519. mapCategoryUrl := make(map[string]string)
  520. var categoryIdStr string
  521. var imgUrlChart string
  522. for _, v := range categoryUrlList {
  523. vslice := strings.Split(v, "_")
  524. categoryIdStr = vslice[0]
  525. imgUrlChart = vslice[len(vslice)-1]
  526. mapCategoryUrl[categoryIdStr] = imgUrlChart
  527. }
  528. var articleIds []int
  529. lenList := len(list)
  530. for i := 0; i < lenList; i++ {
  531. item := list[i]
  532. list[i].Body, _ = services.GetReportContentTextSub(item.Body)
  533. //list[i].Abstract = html.UnescapeString(item.Abstract)
  534. list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  535. if item.Resource == 1 {
  536. articleIds = append(articleIds, item.ArticleId)
  537. }
  538. }
  539. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  540. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  541. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  542. for k, v := range list {
  543. if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  544. list[k].IsRed = true
  545. }
  546. if v.VideoUrl != "" {
  547. list[k].IsHaveVideo = true
  548. }
  549. list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  550. if v.Resource == 1 {
  551. v.Pv = articleMapPv[v.ArticleId]
  552. v.IsCollect = articleCollectMap[v.ArticleId]
  553. v.CollectNum = articleCollectNumMap[v.ArticleId]
  554. }
  555. if v.Resource == 2 {
  556. v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
  557. }
  558. }
  559. //resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  560. //resp.ChartPermissionId = detail.ChartPermissionId
  561. resp.List = list
  562. resp.Paging = page
  563. br.Ret = 200
  564. br.Success = true
  565. br.Msg = "获取成功"
  566. br.Data = resp
  567. } else {
  568. //获取该产业下所对应的行业图片
  569. //因为时间线不属于数据表里的二级分类,所以图片Id用产业id查到的list中的任意一个categoryId取到的图片替代
  570. categoryList, err := models.IndustrialToArticleCategoryNew(industrialManagementId)
  571. if err != nil {
  572. br.Msg = "获取信息失败"
  573. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  574. return
  575. }
  576. var timeLineCategoryId int
  577. if len(categoryList) > 0 {
  578. timeLineCategoryId = categoryList[0].CategoryId
  579. }
  580. var detail *models.ReportMapping
  581. var errCategory error
  582. if timeLineCategoryId > 0 {
  583. detail, errCategory = models.GetdetailByCategoryIdOne(timeLineCategoryId)
  584. if errCategory != nil {
  585. br.Msg = "获取信息失败"
  586. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  587. return
  588. }
  589. }
  590. //对应行业的图片
  591. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  592. if err != nil {
  593. br.Msg = "获取数据失败"
  594. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  595. return
  596. }
  597. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  598. mapChartPermission := make(map[string]string)
  599. var permissionName string
  600. var imgUrlChartPermission string
  601. for _, v := range chartPermissionUrlList {
  602. vslice := strings.Split(v, "_")
  603. permissionName = vslice[0]
  604. imgUrlChartPermission = vslice[len(vslice)-1]
  605. mapChartPermission[permissionName] = imgUrlChartPermission
  606. }
  607. total, err := models.GetTimeLineReportIndustrialCount(industrialManagementId)
  608. if err != nil {
  609. br.Msg = "获取信息失败"
  610. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  611. return
  612. }
  613. page = paging.GetPaging(currentIndex, pageSize, total)
  614. list, err := models.GetTimeLineReportIndustrialList(user.UserId, industrialManagementId, startSize, pageSize)
  615. if err != nil {
  616. br.Msg = "获取信息失败"
  617. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  618. return
  619. }
  620. //处理晨会精华关联的标的,以及要跳转的文章ID
  621. var meetingreviewchaptIds []int
  622. var articleIds []int
  623. mapchaptIdAndArticleId := make(map[int]int) // 晨会精华ID与跳转文章ID的映射关系
  624. mapchaptIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 晨会精华ID与标的列表的映射关系
  625. mapArticleIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 报告ID与标的列表的映射关系
  626. for _, v := range list {
  627. if v.Resource == 3 {
  628. meetingreviewchaptIds = append(meetingreviewchaptIds, v.Id)
  629. v.Content = services.AnnotationHtml(v.Content)
  630. }
  631. if v.Resource == 1 {
  632. articleIds = append(articleIds, v.Id)
  633. }
  634. }
  635. if len(meetingreviewchaptIds) > 0 {
  636. listMeet, err := services.GetCygxMorningMeetingReviewChapterListByIds(meetingreviewchaptIds)
  637. if err != nil {
  638. br.Msg = "获取失败"
  639. br.ErrMsg = "GetCygxMorningMeetingReviewChapterListByIds,Err:" + err.Error()
  640. }
  641. for _, v := range listMeet {
  642. mapchaptIdAndArticleId[v.Id] = v.LinkArticleId
  643. mapchaptIdListSubject[v.Id] = v.ListSubject
  644. }
  645. }
  646. if len(articleIds) > 0 {
  647. mapArticleIdListSubject = services.GetArticleGroupSubjectMapByIndustrialManagementId(articleIds, industrialManagementId)
  648. }
  649. //对应分类的所图片
  650. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  651. if err != nil {
  652. br.Msg = "获取数据失败"
  653. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  654. return
  655. }
  656. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  657. mapCategoryUrl := make(map[string]string)
  658. var categoryIdStr string
  659. var imgUrlChart string
  660. for _, v := range categoryUrlList {
  661. vslice := strings.Split(v, "_")
  662. categoryIdStr = vslice[0]
  663. imgUrlChart = vslice[len(vslice)-1]
  664. mapCategoryUrl[categoryIdStr] = imgUrlChart
  665. }
  666. //lenList := len(list)
  667. //for i := 0; i < lenList; i++ {
  668. // item := list[i]
  669. // list[i].Content, _ = services.GetReportContentTextSub(item.Content)
  670. // //list[i].Abstract = html.UnescapeString(item.Abstract)
  671. // //list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  672. //}
  673. //查询用户今天是否看过时间线
  674. //count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  675. //if err != nil {
  676. // br.Msg = "查询浏览记录数量失败"
  677. // br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  678. // return
  679. //}
  680. //var recordItem *models.CygxPageHistoryRecord
  681. //if count > 1 {
  682. // recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  683. // if err != nil {
  684. // br.Msg = "查询浏览记录失败"
  685. // br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  686. // return
  687. // }
  688. //}
  689. for k, v := range list {
  690. if v.SubCategoryName != "时间线" && v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishTime)) {
  691. list[k].IsRed = true
  692. }
  693. //timeLineRed := false
  694. //if count < 2 && v.SubCategoryName == "时间线" {
  695. // timeLineRed = true
  696. //} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishTime)) {
  697. // timeLineRed = true
  698. //}
  699. //if v.SubCategoryName == "时间线" && timeLineRed {
  700. list[k].IsRed = true
  701. //}
  702. if v.VideoUrl != "" {
  703. list[k].IsHaveVideo = true
  704. }
  705. id := strconv.Itoa(timeLineCategoryId)
  706. list[k].ImgUrlPc = mapCategoryUrl[id]
  707. if mapCategoryUrl[id] == "" {
  708. if detail != nil {
  709. if detail.ChartPermissionId == utils.YI_YAO_ID {
  710. list[k].ImgUrlPc = utils.YI_YAO_QI_TA
  711. }
  712. }
  713. }
  714. if v.Resource == 3 {
  715. v.LinkArticleId = mapchaptIdAndArticleId[v.Id]
  716. v.ListSubject = mapchaptIdListSubject[v.Id]
  717. }
  718. if v.Resource == 1 {
  719. v.ListSubject = mapArticleIdListSubject[v.Id]
  720. }
  721. }
  722. resp := new(models.TimeLineReportListResp)
  723. //resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  724. go services.AddCygxTimelineLog(user, industrialManagementId)
  725. resp.List = list
  726. resp.Paging = page
  727. br.Ret = 200
  728. br.Success = true
  729. br.Msg = "获取成功"
  730. br.Data = resp
  731. }
  732. }
  733. // @Title 置顶/取消置顶
  734. // @Description 置顶
  735. // @Param request body models.CygxIndustryTopRep true "type json string"
  736. // @Success 200
  737. // @router /top [post]
  738. func (this *ReportController) ArticleCollect() {
  739. br := new(models.BaseResponse).Init()
  740. defer func() {
  741. this.Data["json"] = br
  742. this.ServeJSON()
  743. }()
  744. user := this.User
  745. if user == nil {
  746. br.Msg = "请重新登录"
  747. br.Ret = 408
  748. return
  749. }
  750. uid := user.UserId
  751. var req models.CygxIndustryTopRep
  752. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  753. if err != nil {
  754. br.Msg = "参数解析异常!"
  755. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  756. return
  757. }
  758. industrialManagementId := req.IndustrialManagementId
  759. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  760. if err != nil {
  761. br.Msg = "获取数据失败!"
  762. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  763. return
  764. }
  765. if countIndustrial == 0 {
  766. br.Msg = "产业不存在!"
  767. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  768. return
  769. }
  770. count, err := models.GetCygxIndustryTop(uid, industrialManagementId)
  771. if err != nil {
  772. br.Msg = "获取数据失败!"
  773. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  774. return
  775. }
  776. resp := new(models.ArticleCollectResp)
  777. if count <= 0 {
  778. item := new(models.CygxIndustryTop)
  779. item.IndustrialManagementId = req.IndustrialManagementId
  780. item.UserId = uid
  781. item.CreateTime = time.Now()
  782. _, err = models.AddCygxIndustryTop(item)
  783. if err != nil {
  784. br.Msg = "置顶失败"
  785. br.ErrMsg = "置顶失败,Err:" + err.Error()
  786. return
  787. }
  788. br.Msg = "置顶成功"
  789. resp.Status = 1
  790. } else {
  791. err = models.RemoveCygxIndustryTop(uid, industrialManagementId)
  792. if err != nil {
  793. br.Msg = "取消置顶失败"
  794. br.ErrMsg = "取消置顶失败,Err:" + err.Error()
  795. return
  796. }
  797. br.Msg = "已取消置顶"
  798. resp.Status = 2
  799. }
  800. br.Ret = 200
  801. br.Success = true
  802. br.Data = resp
  803. }
  804. // @Title 关注/取消关注产业
  805. // @Description 关注/取消关注 接口
  806. // @Param request body models.CygxIndustryFllowRep true "type json string"
  807. // @Success 200
  808. // @router /fllow [post]
  809. func (this *ReportController) Fllow() {
  810. br := new(models.BaseResponse).Init()
  811. defer func() {
  812. this.Data["json"] = br
  813. this.ServeJSON()
  814. }()
  815. user := this.User
  816. if user == nil {
  817. br.Msg = "请重新登录"
  818. br.Ret = 408
  819. return
  820. }
  821. uid := user.UserId
  822. var req models.CygxIndustryFllowRep
  823. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  824. if err != nil {
  825. br.Msg = "参数解析异常!"
  826. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  827. return
  828. }
  829. industrialManagementId := req.IndustrialManagementId
  830. var condition string
  831. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  832. if err != nil {
  833. br.Msg = "获取数据失败!"
  834. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  835. return
  836. }
  837. if countIndustrial == 0 {
  838. br.Msg = "产业不存在!"
  839. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  840. return
  841. }
  842. count, err := models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
  843. if err != nil {
  844. br.Msg = "获取数据失败!"
  845. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  846. return
  847. }
  848. resp := new(models.CygxIndustryFllowResp)
  849. countUser, err := models.GetCountCygxIndustryFllowByUid(uid)
  850. if countUser == 0 {
  851. resp.GoFollow = true
  852. }
  853. item := new(models.CygxIndustryFllow)
  854. item.IndustrialManagementId = industrialManagementId
  855. item.UserId = uid
  856. item.Email = user.Email
  857. item.Mobile = user.Mobile
  858. item.RealName = user.RealName
  859. item.Source = utils.REGISTER_PLATFORM
  860. item.CompanyId = user.CompanyId
  861. item.CompanyName = user.CompanyName
  862. if count == 0 {
  863. item.Type = 1
  864. item.CreateTime = time.Now()
  865. item.ModifyTime = time.Now()
  866. _, err = models.AddCygxIndustryFllow(item)
  867. if err != nil {
  868. br.Msg = "操作失败"
  869. br.ErrMsg = "操作失败,Err:" + err.Error()
  870. return
  871. }
  872. resp.Status = 1
  873. } else {
  874. item.Type = 2
  875. err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
  876. if err != nil {
  877. br.Msg = "操作失败"
  878. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  879. return
  880. }
  881. }
  882. go services.IndustryFllowWithTrack(industrialManagementId, count, uid) //处理是否关注全部赛道字段
  883. go services.IndustryFllowUserLabelLogAdd(industrialManagementId, count, uid) //处理用户标签
  884. go services.AddCygxIndustryFllowLog(item) //添加操作日志记录
  885. br.Msg = "操作成功"
  886. br.Ret = 200
  887. br.Success = true
  888. br.Data = resp
  889. }
  890. // @Title 产业报告分类关联作者列表接口
  891. // @Description 获取产业报告分类关联作者列表接口
  892. // @Param ChartPermissionId query int true "分类ID"
  893. // @Param PageSize query int true "每页数据条数"
  894. // @Param CurrentIndex query int true "当前页页码,从1开始"
  895. // @Success 200 {object} models.CygxArticleDepartmentList
  896. // @router /industryListByDepartment [get]
  897. func (this *ReportController) IndustryListByDepartment() {
  898. br := new(models.BaseResponse).Init()
  899. defer func() {
  900. this.Data["json"] = br
  901. this.ServeJSON()
  902. }()
  903. user := this.User
  904. if user == nil {
  905. br.Msg = "请重新登录"
  906. br.Ret = 408
  907. return
  908. }
  909. uid := user.UserId
  910. pageSize, _ := this.GetInt("PageSize")
  911. currentIndex, _ := this.GetInt("CurrentIndex")
  912. //chartPermissionId, _ := this.GetInt("ChartPermissionId")
  913. var startSize int
  914. var condition string
  915. //condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  916. condition = ` AND a.publish_status=1 `
  917. if pageSize <= 0 {
  918. pageSize = utils.PageSize20
  919. }
  920. if currentIndex <= 0 {
  921. currentIndex = 1
  922. }
  923. startSize = paging.StartIndex(currentIndex, pageSize)
  924. total, err := models.GetArticleDepartmentCount(condition)
  925. page := paging.GetPaging(currentIndex, pageSize, total)
  926. resp := new(models.CygxArticleDepartmentList)
  927. userType, _, err := services.GetUserType(user.CompanyId)
  928. if err != nil {
  929. br.Msg = "获取信息失败"
  930. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  931. return
  932. }
  933. if userType == 1 {
  934. resp.Paging = page
  935. br.Ret = 200
  936. br.Success = true
  937. br.Msg = "获取成功"
  938. br.Data = resp
  939. return
  940. }
  941. resp.HaveResearch = true
  942. //获取作者信息,并排序
  943. list, err := models.GetCygxArticleDepartmentList(startSize, pageSize, condition, uid)
  944. if err != nil {
  945. br.Msg = "获取信息失败"
  946. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  947. return
  948. }
  949. for k, v := range list {
  950. artList, err := models.GetArticleByDepartmentId(v.DepartmentId)
  951. if err != nil {
  952. br.Msg = "获取信息失败"
  953. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  954. return
  955. }
  956. for k2, v2 := range artList {
  957. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  958. if err != nil {
  959. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  960. br.ErrMsg = "获取失败,Err:" + err.Error()
  961. return
  962. }
  963. var subjectNamesNew string
  964. if len(subjectNames) > 0 {
  965. slice := strings.Split(subjectNames, "/")
  966. for k3, v3 := range slice {
  967. if k3 < 4 {
  968. subjectNamesNew += v3 + "/"
  969. }
  970. }
  971. }
  972. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  973. if err != nil && err.Error() != utils.ErrNoRow() {
  974. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  975. br.ErrMsg = "获取失败,Err:" + err.Error()
  976. return
  977. }
  978. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  979. artList[k2].SubjectName = subjectNamesNew
  980. artList[k2].DepartmentId = v.DepartmentId
  981. if subjectNamesNew == "" {
  982. artList[k2].IndustryName = industryName
  983. } else {
  984. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  985. }
  986. if artList[k2].IsReport == "1" {
  987. artList[k2].IndustryName = "【观点】" + artList[k2].IndustryName
  988. } else {
  989. artList[k2].IndustryName = "【纪要】" + artList[k2].IndustryName
  990. }
  991. }
  992. list[k].List = artList
  993. if v.FollowNum > 0 {
  994. list[k].IsMyFollow = true
  995. }
  996. }
  997. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  998. if err != nil {
  999. br.Msg = "获取信息失败"
  1000. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1001. return
  1002. }
  1003. if len(listnNew) > 0 {
  1004. for _, v := range listnNew {
  1005. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  1006. Management := new(models.IndustrialManagementIdInt)
  1007. if firstStr == 0 {
  1008. Management.IndustryName = v.IndustryName
  1009. } else {
  1010. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  1011. if err != nil {
  1012. br.Msg = "获取信息失败"
  1013. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  1014. return
  1015. }
  1016. var subjectNamesNew string
  1017. for _, v1 := range listSub {
  1018. subjectNamesNew += v1.SubjectName + "/"
  1019. }
  1020. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1021. Management.IndustryName = subjectNamesNew
  1022. }
  1023. Management.IndustrialManagementId = v.IndustrialManagementId
  1024. Management.ArticleId = v.ArticleId
  1025. resp.ListnNew = append(resp.ListnNew, Management)
  1026. }
  1027. }
  1028. resp.List = list
  1029. resp.Paging = page
  1030. br.Ret = 200
  1031. br.Success = true
  1032. br.Msg = "获取成功"
  1033. br.Data = resp
  1034. }
  1035. // @Title 关注作者/取消关注作者
  1036. // @Description 关注作者/取消关注作者 接口
  1037. // @Param request body models.CygxArticleDepartmentId true "type json string"
  1038. // @Success 200
  1039. // @router /fllowDepartment [post]
  1040. func (this *ReportController) FllowDepartment() {
  1041. br := new(models.BaseResponse).Init()
  1042. defer func() {
  1043. this.Data["json"] = br
  1044. this.ServeJSON()
  1045. }()
  1046. user := this.User
  1047. if user == nil {
  1048. br.Msg = "请重新登录"
  1049. br.Ret = 408
  1050. return
  1051. }
  1052. uid := user.UserId
  1053. var req models.CygxArticleDepartmentId
  1054. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1055. if err != nil {
  1056. br.Msg = "参数解析异常!"
  1057. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1058. return
  1059. }
  1060. departmentId := req.DepartmentId
  1061. var condition string
  1062. countDepartment, err := models.GetDepartmentCount(departmentId)
  1063. if err != nil {
  1064. br.Msg = "获取数据失败!"
  1065. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1066. return
  1067. }
  1068. if countDepartment == 0 {
  1069. br.Msg = "作者不存在!"
  1070. br.ErrMsg = "作者ID不存在:" + strconv.Itoa(departmentId)
  1071. return
  1072. }
  1073. countUser, err := models.GetArticleDepartmentFollowByUid(uid)
  1074. count, err := models.GetArticleDepartmentFollow(uid, departmentId, condition)
  1075. if err != nil {
  1076. br.Msg = "获取数据失败!"
  1077. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1078. return
  1079. }
  1080. resp := new(models.CygxArticleDepartmentFollowResp)
  1081. if countUser == 0 {
  1082. resp.GoFollow = true
  1083. }
  1084. if count == 0 {
  1085. item := new(models.CygxArticleDepartmentFollow)
  1086. item.DepartmentId = departmentId
  1087. item.UserId = uid
  1088. item.Email = user.Email
  1089. item.Mobile = user.Mobile
  1090. item.RealName = user.RealName
  1091. item.CompanyId = user.CompanyId
  1092. item.CompanyName = user.CompanyName
  1093. item.Type = 1
  1094. item.CreateTime = time.Now()
  1095. item.ModifyTime = time.Now()
  1096. _, err = models.AddArticleDepartmentFollow(item)
  1097. if err != nil {
  1098. br.Msg = "操作失败"
  1099. br.ErrMsg = "操作失败,Err:" + err.Error()
  1100. return
  1101. }
  1102. resp.Status = 1
  1103. } else {
  1104. var doType int
  1105. condition = ` AND type = 1`
  1106. count, err = models.GetArticleDepartmentFollow(uid, departmentId, condition)
  1107. if err != nil {
  1108. br.Msg = "操作失败!"
  1109. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1110. return
  1111. }
  1112. if count == 1 {
  1113. resp.Status = 2
  1114. doType = 2
  1115. } else {
  1116. resp.Status = 1
  1117. doType = 1
  1118. }
  1119. err = models.RemoveArticleDepartmentFollow(uid, departmentId, doType)
  1120. if err != nil {
  1121. br.Msg = "操作失败"
  1122. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  1123. return
  1124. }
  1125. }
  1126. br.Msg = "操作成功"
  1127. br.Ret = 200
  1128. br.Success = true
  1129. br.Data = resp
  1130. }
  1131. // @Title 研选文章列表接口
  1132. // @Description 获取研选文章列表接口
  1133. // @Param PageSize query int true "每页数据条数"
  1134. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1135. // @Param ArticleId query int true "文章id"
  1136. // @Param DepartmentId query int true "作者ID"
  1137. // @Param IndustrialManagementId query int true "产业ID"
  1138. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  1139. // @router /industry/reportList [get]
  1140. func (this *ReportController) ReportList() {
  1141. br := new(models.BaseResponse).Init()
  1142. defer func() {
  1143. this.Data["json"] = br
  1144. this.ServeJSON()
  1145. }()
  1146. user := this.User
  1147. if user == nil {
  1148. br.Msg = "请重新登录"
  1149. br.Ret = 408
  1150. return
  1151. }
  1152. uid := user.UserId
  1153. pageSize, _ := this.GetInt("PageSize")
  1154. currentIndex, _ := this.GetInt("CurrentIndex")
  1155. departmentId, _ := this.GetInt("DepartmentId")
  1156. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  1157. articleId, _ := this.GetInt("ArticleId")
  1158. var condition string
  1159. var startSize int
  1160. if pageSize <= 0 {
  1161. pageSize = utils.PageSize20
  1162. }
  1163. if currentIndex <= 0 {
  1164. currentIndex = 1
  1165. }
  1166. startSize = paging.StartIndex(currentIndex, pageSize)
  1167. var pars []interface{}
  1168. var total int
  1169. resp := new(models.ReportArticleWhichIndustrialRepList)
  1170. page := paging.GetPaging(currentIndex, pageSize, total)
  1171. userType, _, err := services.GetUserType(user.CompanyId)
  1172. if err != nil {
  1173. br.Msg = "获取信息失败"
  1174. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1175. return
  1176. }
  1177. if userType == 1 {
  1178. resp.Paging = page
  1179. br.Ret = 200
  1180. br.Success = true
  1181. br.Msg = "获取成功"
  1182. br.Data = resp
  1183. return
  1184. }
  1185. resp.HaveResearch = true
  1186. if departmentId > 0 {
  1187. condition += ` AND art.department_id = ` + strconv.Itoa(departmentId)
  1188. detail, err := models.GetArticleDepartmentDateilById(departmentId)
  1189. if err != nil {
  1190. br.Msg = "获取信息失败"
  1191. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1192. return
  1193. }
  1194. resp.NickName = detail.NickName
  1195. }
  1196. if industrialManagementId > 0 {
  1197. condition += ` AND m.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
  1198. }
  1199. if articleId > 0 {
  1200. detail, err := models.GetArticleDetailById(articleId)
  1201. if err != nil {
  1202. br.Msg = "获取信息失败"
  1203. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1204. return
  1205. }
  1206. condition += ` AND art.subject_ids = '` + detail.SubjectIds + `'`
  1207. }
  1208. total, err = models.GetWhichDepartmentCount(condition)
  1209. if err != nil {
  1210. br.Msg = "获取信息失败"
  1211. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1212. return
  1213. }
  1214. page = paging.GetPaging(currentIndex, pageSize, total)
  1215. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  1216. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  1217. if err != nil {
  1218. br.Msg = "获取失败"
  1219. br.ErrMsg = "获取失败,Err:" + err.Error()
  1220. return
  1221. }
  1222. for k, v := range list {
  1223. if v.Readnum == 0 {
  1224. list[k].IsRed = true
  1225. }
  1226. list[k].IsResearch = true
  1227. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1228. if err != nil {
  1229. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1230. br.ErrMsg = "获取失败,Err:" + err.Error()
  1231. return
  1232. }
  1233. var subjectNamesNew string
  1234. if len(subjectNames) > 0 {
  1235. slice := strings.Split(subjectNames, "/")
  1236. for k3, v3 := range slice {
  1237. if k3 < 4 {
  1238. subjectNamesNew += v3 + "/"
  1239. }
  1240. }
  1241. }
  1242. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1243. if err != nil && err.Error() != utils.ErrNoRow() {
  1244. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1245. br.ErrMsg = "获取失败,Err:" + err.Error()
  1246. return
  1247. }
  1248. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1249. list[k].SubjectName = subjectNamesNew
  1250. if subjectNamesNew != "" {
  1251. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1252. } else {
  1253. list[k].IndustryName = industryName
  1254. }
  1255. resp.IndustryName = industryName
  1256. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1257. }
  1258. resp.List = list
  1259. resp.Paging = page
  1260. br.Ret = 200
  1261. br.Success = true
  1262. br.Msg = "获取成功"
  1263. br.Data = resp
  1264. }
  1265. // @Title 研选最新主题关键词文章列表接口
  1266. // @Description 获取研选最新主题关键词文章列表接口
  1267. // @Param PageSize query int true "每页数据条数"
  1268. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1269. // @Param ArticleId query int true "文章id"
  1270. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  1271. // @router /industry/reportListNew [get]
  1272. func (this *ReportController) ReportListNew() {
  1273. br := new(models.BaseResponse).Init()
  1274. defer func() {
  1275. this.Data["json"] = br
  1276. this.ServeJSON()
  1277. }()
  1278. user := this.User
  1279. if user == nil {
  1280. br.Msg = "请重新登录"
  1281. br.Ret = 408
  1282. return
  1283. }
  1284. uid := user.UserId
  1285. pageSize, _ := this.GetInt("PageSize")
  1286. currentIndex, _ := this.GetInt("CurrentIndex")
  1287. articleId, _ := this.GetInt("ArticleId")
  1288. var condition string
  1289. var startSize int
  1290. if pageSize <= 0 {
  1291. pageSize = utils.PageSize20
  1292. }
  1293. if currentIndex <= 0 {
  1294. currentIndex = 1
  1295. }
  1296. startSize = paging.StartIndex(currentIndex, pageSize)
  1297. var pars []interface{}
  1298. var total int
  1299. resp := new(models.ReportArticleWhichIndustrialRepList)
  1300. page := paging.GetPaging(currentIndex, pageSize, total)
  1301. userType, _, err := services.GetUserType(user.CompanyId)
  1302. if err != nil {
  1303. br.Msg = "获取信息失败"
  1304. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1305. return
  1306. }
  1307. if userType == 1 {
  1308. resp.Paging = page
  1309. br.Ret = 200
  1310. br.Success = true
  1311. br.Msg = "获取成功"
  1312. br.Data = resp
  1313. return
  1314. }
  1315. resp.HaveResearch = true
  1316. if articleId > 0 {
  1317. detail, err := models.GetArticleDetailById(articleId)
  1318. if err != nil {
  1319. br.Msg = "获取信息失败"
  1320. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1321. return
  1322. }
  1323. firstStr := strings.Index(detail.IndustrialAndSubjectIds, "—")
  1324. if firstStr == 0 {
  1325. condition += ` AND art.industrial_management_id = '` + strconv.Itoa(detail.IndustrialManagementId) + `'`
  1326. } else {
  1327. condition += ` AND art.industrial_and_subject_ids = '` + detail.IndustrialAndSubjectIds + `'`
  1328. }
  1329. }
  1330. total, err = models.GetWhichDepartmentCount(condition)
  1331. if err != nil {
  1332. br.Msg = "获取信息失败"
  1333. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1334. return
  1335. }
  1336. page = paging.GetPaging(currentIndex, pageSize, total)
  1337. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  1338. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  1339. if err != nil {
  1340. br.Msg = "获取失败"
  1341. br.ErrMsg = "获取失败,Err:" + err.Error()
  1342. return
  1343. }
  1344. for k, v := range list {
  1345. if v.Readnum == 0 {
  1346. list[k].IsRed = true
  1347. }
  1348. list[k].IsResearch = true
  1349. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1350. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1351. if err != nil {
  1352. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1353. br.ErrMsg = "获取失败,Err:" + err.Error()
  1354. return
  1355. }
  1356. var subjectNamesNew string
  1357. if len(subjectNames) > 0 {
  1358. slice := strings.Split(subjectNames, "/")
  1359. for k3, v3 := range slice {
  1360. if k3 < 4 {
  1361. subjectNamesNew += v3 + "/"
  1362. }
  1363. }
  1364. }
  1365. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1366. if err != nil && err.Error() != utils.ErrNoRow() {
  1367. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1368. br.ErrMsg = "获取失败,Err:" + err.Error()
  1369. return
  1370. }
  1371. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1372. list[k].SubjectName = subjectNamesNew
  1373. if subjectNamesNew != "" {
  1374. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1375. } else {
  1376. list[k].IndustryName = industryName
  1377. }
  1378. resp.IndustryName = industryName
  1379. }
  1380. resp.List = list
  1381. resp.Paging = page
  1382. br.Ret = 200
  1383. br.Success = true
  1384. br.Msg = "获取成功"
  1385. br.Data = resp
  1386. }
  1387. // @Title 是否展示绝密内参
  1388. // @Description 获取是否展示绝密内参接口
  1389. // @Param request body models.IsShow true "type json string"
  1390. // @Success 200
  1391. // @router /isShow [get]
  1392. func (this *ReportController) IsShow() {
  1393. br := new(models.BaseResponse).Init()
  1394. defer func() {
  1395. this.Data["json"] = br
  1396. this.ServeJSON()
  1397. }()
  1398. user := this.User
  1399. if user == nil {
  1400. br.Msg = "请重新登录"
  1401. br.Ret = 408
  1402. return
  1403. }
  1404. var resp models.IsShow
  1405. IsShowFreeButton, err := services.GetfreeButtonIsShow(user)
  1406. if err != nil {
  1407. br.Msg = "获取失败"
  1408. br.ErrMsg = "获取失败,GetfreeButtonIsShow Err:" + err.Error()
  1409. return
  1410. }
  1411. resp.IsShowChart = true
  1412. //resp.IsShowResearch = true
  1413. resp.LinkWxExplain = utils.LINK_WX_EXPLAIN
  1414. resp.ActivitySpecialExplain = utils.ACTIVITY_SPECIAL_EXPLAIN
  1415. //resp.YanXuan_Explain = true
  1416. resp.IsShowFreeButton = IsShowFreeButton
  1417. resp.IsBelongRai = services.GetBelongingRai(user.Mobile)
  1418. resp.IsShowQuestionnaire = services.GetQuestionnaireButtonIsShow() // 获取研选问卷调查按钮是否展示
  1419. resp.IsShowResearchPoints = true
  1420. if utils.RunMode == "release" { //是否展示关于我们的视频,测试环境审核做隐藏
  1421. resp.IsShowAboutVideo = true
  1422. } else {
  1423. resp.IsShowMobileAndEmailButton = true //是否展示手机号跟邮箱按钮
  1424. }
  1425. //mobile := user.Mobile
  1426. //if mobile == "" {
  1427. // br.Ret = 200
  1428. // br.Success = true
  1429. // br.Data = resp
  1430. // return
  1431. //}
  1432. //total, _ := models.GetUserIsAdminCount(mobile)
  1433. //if total > 0 {
  1434. // resp.IsShowList = true
  1435. //}
  1436. resp.IsShowList = true
  1437. resp.SearchTxtList.SummarySearch = "全局搜索"
  1438. resp.SearchTxtList.ReportSearch = "全局搜索"
  1439. resp.SearchTxtList.YanXuanSearch = "全局搜索"
  1440. resp.SearchTxtList.ActivitySearch = "全局搜索"
  1441. resp.SearchTxtList.TabSearch = "请输入关键词"
  1442. resp.IsShow = true
  1443. br.Ret = 200
  1444. br.Success = true
  1445. br.Data = resp
  1446. }
  1447. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1448. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1449. // @Param PageSize query int true "每页数据条数"
  1450. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1451. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1452. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1453. // @router /reportList/byType [get]
  1454. func (this *ReportController) ReportListByType() {
  1455. br := new(models.BaseResponse).Init()
  1456. defer func() {
  1457. this.Data["json"] = br
  1458. this.ServeJSON()
  1459. }()
  1460. user := this.User
  1461. if user == nil {
  1462. br.Msg = "请重新登录"
  1463. br.Ret = 408
  1464. return
  1465. }
  1466. uid := user.UserId
  1467. pageSize, _ := this.GetInt("PageSize")
  1468. currentIndex, _ := this.GetInt("CurrentIndex")
  1469. reportType := this.GetString("ReportType")
  1470. var condition string
  1471. var startSize int
  1472. if pageSize <= 0 {
  1473. pageSize = utils.PageSize20
  1474. }
  1475. if currentIndex <= 0 {
  1476. currentIndex = 1
  1477. }
  1478. startSize = paging.StartIndex(currentIndex, pageSize)
  1479. var pars []interface{}
  1480. var total int
  1481. resp := new(models.CygxReportSelectionListPublicRep)
  1482. page := paging.GetPaging(currentIndex, pageSize, total)
  1483. var tbdb string
  1484. var readSql string
  1485. var reportTypeStr string
  1486. if reportType == "1" {
  1487. tbdb = "cygx_report_selection"
  1488. reportTypeStr = "bgjx"
  1489. } else if reportType == "2" {
  1490. tbdb = "cygx_research_summary"
  1491. reportTypeStr = "bzyjhz"
  1492. } else if reportType == "3" {
  1493. tbdb = "cygx_minutes_summary"
  1494. reportTypeStr = "szjyhz"
  1495. } else {
  1496. br.Msg = "请选择报告类型"
  1497. return
  1498. }
  1499. condition = ` AND publish_status = 1 `
  1500. if user.CompanyId != utils.HZ_COMPANY_ID {
  1501. condition += ` AND visible_range = 1 `
  1502. }
  1503. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1504. if err != nil {
  1505. br.Msg = "获取信息失败"
  1506. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1507. return
  1508. }
  1509. //研究汇总--报告精选 只显示最新一期,往期都隐藏
  1510. if reportType == "1" {
  1511. startSize = 0
  1512. pageSize = 1
  1513. total = 1
  1514. }
  1515. readSql = ` (SELECT COUNT(1) AS count FROM cygx_report_history_record AS h WHERE h.article_id = art.article_id AND report_type ='` + reportTypeStr + `' AND h.user_id = ` + strconv.Itoa(uid) + `) as read_num`
  1516. page = paging.GetPaging(currentIndex, pageSize, total)
  1517. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1518. if err != nil {
  1519. br.Msg = "获取失败"
  1520. br.ErrMsg = "获取失败,Err:" + err.Error()
  1521. return
  1522. }
  1523. for k, v := range list {
  1524. if reportType == "1" {
  1525. list[k].Abstract = v.UpdateDescription
  1526. }
  1527. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1528. if v.ReadNum == 0 {
  1529. list[k].IsRed = true
  1530. }
  1531. }
  1532. resp.List = list
  1533. resp.Paging = page
  1534. br.Ret = 200
  1535. br.Success = true
  1536. br.Msg = "获取成功"
  1537. br.Data = resp
  1538. }
  1539. // @Title 获取报告精选详情
  1540. // @Description 获取报告精选详情接口
  1541. // @Param ArticleId query int true "报告ID"
  1542. // @Param IsBestNew query bool false "是否获取最新的一篇报告"
  1543. // @Success 200 {object} models.ReportSelectionLetailResp
  1544. // @router /reportSelection/detail [get]
  1545. func (this *ReportController) Detail() {
  1546. br := new(models.BaseResponse).Init()
  1547. defer func() {
  1548. this.Data["json"] = br
  1549. this.ServeJSON()
  1550. }()
  1551. user := this.User
  1552. if user == nil {
  1553. br.Msg = "请重新登录"
  1554. br.Ret = 408
  1555. return
  1556. }
  1557. //if user.CompanyId != utils.HZ_COMPANY_ID {
  1558. // br.Msg = "报告编辑中,请稍后"
  1559. // br.IsSendEmail = false
  1560. // return
  1561. //}
  1562. //uid := user.UserId
  1563. articleId, _ := this.GetInt("ArticleId")
  1564. isBestNew, _ := this.GetBool("IsBestNew")
  1565. if isBestNew {
  1566. tbdb := "cygx_report_selection"
  1567. //reportTypeStr := "bgjx"
  1568. condition := ` AND publish_status = 1 `
  1569. var pars []interface{}
  1570. list, err := models.GetReportSelectionListPublic(condition, "1", tbdb, pars, 0, 1)
  1571. if err != nil {
  1572. br.Msg = "获取失败"
  1573. br.ErrMsg = "获取失败,Err:" + err.Error()
  1574. return
  1575. }
  1576. for _, v := range list {
  1577. articleId = v.ArticleId
  1578. }
  1579. }
  1580. if articleId < 1 {
  1581. br.Msg = "获取信息失败"
  1582. br.ErrMsg = "报告ID错误" + strconv.Itoa(articleId)
  1583. return
  1584. }
  1585. resp := new(models.ReportSelectionLetailResp)
  1586. //判断用户权限
  1587. hasPermission, err := services.GetUserhasPermission(user)
  1588. if err != nil {
  1589. br.Msg = "获取信息失败"
  1590. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1591. }
  1592. resp.HasPermission = hasPermission
  1593. if hasPermission != 1 {
  1594. br.Ret = 200
  1595. br.Success = true
  1596. br.Msg = "获取成功"
  1597. br.Data = resp
  1598. return
  1599. }
  1600. detail, err := models.GetCygxReportSelectionInfoById(articleId)
  1601. if err != nil {
  1602. br.Msg = "获取信息失败"
  1603. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1604. return
  1605. }
  1606. if detail.ReportLink != "" {
  1607. articleIdLink, _ := services.GetReportLinkToArticleid(detail.ReportLink)
  1608. detail.CeLueArticleId = articleIdLink
  1609. }
  1610. //较上一期有观点变化(后台填写的核心逻辑汇总内容、标签内容有更新),或者新增的公司,显示new标签
  1611. var isAllNew bool // 判断是否都打新的标签
  1612. lastPeriods := detail.Periods - 1
  1613. mapBodyChartSummary := make(map[int]string)
  1614. mapLabel := make(map[int]string)
  1615. if lastPeriods > 0 {
  1616. detailLast, err := models.GetCygxReportSelectionInfoByperiods(lastPeriods)
  1617. if err != nil && err.Error() != utils.ErrNoRow() {
  1618. br.Msg = "获取信息失败"
  1619. br.ErrMsg = "报告不存在,Err:" + err.Error() + "Periods:" + strconv.Itoa(lastPeriods)
  1620. return
  1621. }
  1622. if detailLast != nil {
  1623. articleIdLast := detailLast.ArticleId
  1624. listLogLast, err := models.GetReportSelectionlogListAll(articleIdLast)
  1625. if err != nil {
  1626. br.Msg = "获取失败"
  1627. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1628. return
  1629. }
  1630. for _, v := range listLogLast {
  1631. mapBodyChartSummary[v.IndustrialSubjectId], _ = services.GetReportContentTextSubNew(v.Body)
  1632. mapLabel[v.IndustrialSubjectId] = v.Label
  1633. }
  1634. }
  1635. } else {
  1636. isAllNew = true
  1637. }
  1638. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1639. existMap := make(map[int]int)
  1640. var items []*models.ReportSelectionChartPermission
  1641. var itemsSubject []*models.ReportSelectionChartLogPermission
  1642. listLog, err := models.GetReportSelectionlogListAll(articleId)
  1643. if err != nil {
  1644. br.Msg = "获取失败"
  1645. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1646. return
  1647. }
  1648. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1649. //获取行业核心逻辑汇总
  1650. listChartLog, err := models.GetCygxReportSelectionChartLogRepList(articleId)
  1651. if err != nil {
  1652. br.Msg = "获取失败"
  1653. br.ErrMsg = "获取失败,Err:" + err.Error()
  1654. return
  1655. }
  1656. mapChartLog := make(map[string]string)
  1657. for _, v := range listChartLog {
  1658. mapChartLog[v.ChartPermissionName] = v.BodyChartSummary
  1659. }
  1660. for _, v := range listLog {
  1661. item := new(models.ReportSelectionChartPermission)
  1662. itemSubject := new(models.ReportSelectionChartLogPermission)
  1663. itemSubject.PermissionName = v.PermissionName
  1664. if existMap[v.ChartPermissionId] == 0 {
  1665. //item.PermissionName = v.PermissionName + "领域深度报告和调研"
  1666. item.PermissionName = v.PermissionName
  1667. item.IcoLink = v.IcoLink
  1668. listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
  1669. if err != nil && err.Error() != utils.ErrNoRow() {
  1670. br.Msg = "获取信息失败"
  1671. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1672. return
  1673. }
  1674. for k2, v2 := range listSonLog {
  1675. var isNew bool
  1676. if isAllNew {
  1677. isNew = true
  1678. } else {
  1679. v2Body, _ := services.GetReportContentTextSubNew(v2.Body)
  1680. if mapBodyChartSummary[v2.IndustrialSubjectId] != v2Body || mapLabel[v2.IndustrialSubjectId] != v2.Label {
  1681. isNew = true
  1682. }
  1683. }
  1684. if v2.IndustrialManagementId != "" {
  1685. listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
  1686. if err != nil && err.Error() != utils.ErrNoRow() {
  1687. br.Msg = "获取信息失败"
  1688. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1689. return
  1690. }
  1691. //v2.IsNew = isNew
  1692. listSonLog[k2].List = listIndustrial
  1693. if v2.Label != "" {
  1694. v2.CompanyLabel = strings.Split(v2.Label, "{|}")
  1695. }
  1696. }
  1697. isNew = false
  1698. itemSubject.ListSubject = append(itemSubject.ListSubject, &models.ReportSelectionChartLogSubjectName{SubjectName: v2.SubjectName, IsNew: isNew, IndustrialSubjectId: v2.IndustrialSubjectId})
  1699. }
  1700. item.BodyChartSummary = mapChartLog[v.PermissionName]
  1701. item.List = listSonLog
  1702. items = append(items, item)
  1703. itemsSubject = append(itemsSubject, itemSubject)
  1704. //itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
  1705. }
  1706. existMap[v.ChartPermissionId] = v.ChartPermissionId
  1707. }
  1708. //historyRecord := new(models.CygxReportHistoryRecord)
  1709. //historyRecord.UserId = uid
  1710. //historyRecord.ArticleId = articleId
  1711. //historyRecord.CreateTime = time.Now()
  1712. //historyRecord.Mobile = user.Mobile
  1713. //historyRecord.Email = user.Email
  1714. //historyRecord.CompanyId = user.CompanyId
  1715. //historyRecord.CompanyName = user.CompanyName
  1716. //historyRecord.ReportType = "bgjx"
  1717. //sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1718. //if err != nil && err.Error() != utils.ErrNoRow() {
  1719. // br.Msg = "获取信息失败"
  1720. // br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1721. // return
  1722. //}
  1723. //historyRecord.RealName = user.RealName
  1724. //if sellerItem != nil {
  1725. // historyRecord.SellerName = sellerItem.RealName
  1726. //}
  1727. //
  1728. //go models.AddCygxReportHistoryRecord(historyRecord)
  1729. resp.List = items
  1730. resp.ListPermissionSubject = itemsSubject
  1731. resp.Detail = detail
  1732. br.Ret = 200
  1733. br.Success = true
  1734. br.Msg = "获取成功"
  1735. br.Data = resp
  1736. }
  1737. // @Title 获取本周研究汇总详情
  1738. // @Description 获取本周研究汇总详情接口
  1739. // @Param ArticleId query int true "报告ID"
  1740. // @Success 200 {object} models.ResearchSummaryLetailResp
  1741. // @router /researchSummary/detail [get]
  1742. func (this *ReportController) ResearchDetail() {
  1743. br := new(models.BaseResponse).Init()
  1744. defer func() {
  1745. this.Data["json"] = br
  1746. this.ServeJSON()
  1747. }()
  1748. user := this.User
  1749. if user == nil {
  1750. br.Msg = "请重新登录"
  1751. br.Ret = 408
  1752. return
  1753. }
  1754. //uid := user.UserId
  1755. articleId, _ := this.GetInt("ArticleId")
  1756. if articleId < 0 {
  1757. br.Msg = "参数错误"
  1758. br.ErrMsg = "参数错误"
  1759. return
  1760. }
  1761. resp := new(models.ResearchSummaryLetailResp)
  1762. //判断用户权限
  1763. hasPermission, err := services.GetUserhasPermission(user)
  1764. if err != nil {
  1765. br.Msg = "获取信息失败"
  1766. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1767. }
  1768. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1769. if err != nil {
  1770. br.Msg = "获取信息失败"
  1771. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1772. return
  1773. }
  1774. PermissionNameMap, err := services.GetPermissionNameMap()
  1775. if err != nil {
  1776. br.Msg = "获取失败"
  1777. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1778. return
  1779. }
  1780. PermissionIcoMap, err := services.GetPermissionNameIcoMap()
  1781. if err != nil {
  1782. br.Msg = "获取失败"
  1783. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1784. return
  1785. }
  1786. //未设置全部可见的只能给弘则内部查看
  1787. if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
  1788. resp.IsShow = true
  1789. }
  1790. resp.HasPermission = hasPermission
  1791. if hasPermission != 1 || !resp.IsShow {
  1792. br.Ret = 200
  1793. br.Success = true
  1794. br.Msg = "获取成功"
  1795. br.Data = resp
  1796. return
  1797. }
  1798. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1799. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1800. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1801. if err != nil {
  1802. br.Msg = "获取失败"
  1803. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1804. return
  1805. }
  1806. listArticleType, err := models.GetCygxArticleTypeList()
  1807. if err != nil {
  1808. br.Msg = "获取失败"
  1809. br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
  1810. return
  1811. }
  1812. for k, v := range listFirst {
  1813. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1814. if err != nil && err.Error() != utils.ErrNoRow() {
  1815. br.Msg = "获取信息失败"
  1816. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1817. return
  1818. }
  1819. for k2, v2 := range listSecond {
  1820. v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
  1821. v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
  1822. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1823. if err != nil && err.Error() != utils.ErrNoRow() {
  1824. br.Msg = "获取信息失败"
  1825. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1826. return
  1827. }
  1828. for _, vType := range listArticleType {
  1829. if v2.ChartPermissionId == vType.YanxPermissionId {
  1830. listSecond[k2].IcoLink = vType.IcoLinkM
  1831. listSecond[k2].PermissionName = vType.YanxPermissionName
  1832. }
  1833. }
  1834. //if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
  1835. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1836. // listSecond[k2].PermissionName = "买方研选纪要"
  1837. //} else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
  1838. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1839. // listSecond[k2].PermissionName = "买方研选观点"
  1840. //}
  1841. if len(listThird) > 0 {
  1842. for k3, v3 := range listThird {
  1843. if v3.VideoUrl != "" {
  1844. listThird[k3].IsHaveVideo = true
  1845. }
  1846. if v3.ReportLink == "0" {
  1847. listThird[k3].ReportLink = ""
  1848. }
  1849. }
  1850. listSecond[k2].List = listThird
  1851. }
  1852. }
  1853. if len(listSecond) > 0 {
  1854. listFirst[k].List = listSecond
  1855. }
  1856. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1857. if v.Type == "SDBG" {
  1858. listFirst[k].ListName = "深度报告"
  1859. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1860. } else if v.Type == "BZCHJH" {
  1861. listFirst[k].ListName = "本周晨会精华"
  1862. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1863. } else if v.Type == "CYDYJY" {
  1864. listFirst[k].ListName = "产业调研纪要"
  1865. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1866. } else if v.Type == "SSGS" {
  1867. listFirst[k].ListName = "上市公司调研纪要篇"
  1868. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1869. } else if v.Type == "SJDP" {
  1870. listFirst[k].ListName = "市场QA汇总"
  1871. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1872. } else if v.Type == "YANX" {
  1873. listFirst[k].ListName = "买方研选"
  1874. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1875. }
  1876. }
  1877. //historyRecord := new(models.CygxReportHistoryRecord)
  1878. //historyRecord.UserId = uid
  1879. //historyRecord.ArticleId = articleId
  1880. //historyRecord.CreateTime = time.Now()
  1881. //historyRecord.Mobile = user.Mobile
  1882. //historyRecord.Email = user.Email
  1883. //historyRecord.CompanyId = user.CompanyId
  1884. //historyRecord.CompanyName = user.CompanyName
  1885. //historyRecord.ReportType = "bzyjhz"
  1886. //sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1887. //if err != nil && err.Error() != utils.ErrNoRow() {
  1888. // br.Msg = "获取信息失败"
  1889. // br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1890. // return
  1891. //}
  1892. //historyRecord.RealName = user.RealName
  1893. //if sellerItem != nil {
  1894. // historyRecord.SellerName = sellerItem.RealName
  1895. //}
  1896. //go models.AddCygxReportHistoryRecord(historyRecord)
  1897. go services.ResearchSummaryHistoryUserRmind(user, articleId) // 本周研究汇总用户阅读操作操作行为,模板消息推送
  1898. resp.List = listFirst
  1899. resp.Detail = detail
  1900. br.Ret = 200
  1901. br.Success = true
  1902. br.Msg = "获取成功"
  1903. br.Data = resp
  1904. }
  1905. // @Title 上周纪要汇总内容详情
  1906. // @Description 获取上周纪要汇总内容详情接口
  1907. // @Param ArticleId query int true "报告ID"
  1908. // @Success 200 {object} models.MinutesSummaryLetailResp
  1909. // @router /minutesSummary/detailv4 [get]
  1910. func (this *ReportController) MinutesDetailV4() {
  1911. br := new(models.BaseResponse).Init()
  1912. defer func() {
  1913. this.Data["json"] = br
  1914. this.ServeJSON()
  1915. }()
  1916. user := this.User
  1917. if user == nil {
  1918. br.Msg = "请重新登录"
  1919. br.Ret = 408
  1920. return
  1921. }
  1922. //uid := user.UserId
  1923. articleId, _ := this.GetInt("ArticleId")
  1924. if articleId < 0 {
  1925. br.Msg = "参数错误"
  1926. br.ErrMsg = "参数错误"
  1927. return
  1928. }
  1929. resp := new(models.MinutesSummaryLetailRespV4)
  1930. //判断用户权限
  1931. hasPermission, err := services.GetUserhasPermission(user)
  1932. if err != nil {
  1933. br.Msg = "获取信息失败"
  1934. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1935. }
  1936. //resp.HasPermission = hasPermission
  1937. //if hasPermission != 1 {
  1938. // br.Ret = 200
  1939. // br.Success = true
  1940. // br.Msg = "获取成功"
  1941. // br.Data = resp
  1942. // return
  1943. //}
  1944. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1945. if err != nil {
  1946. br.Msg = "获取信息失败"
  1947. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1948. return
  1949. }
  1950. PermissionNameMap, err := services.GetPermissionNameMap()
  1951. if err != nil {
  1952. br.Msg = "获取失败"
  1953. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1954. return
  1955. }
  1956. PermissionIcoMap, err := services.GetPermissionNameIcoMap()
  1957. if err != nil {
  1958. br.Msg = "获取失败"
  1959. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1960. return
  1961. }
  1962. //未设置全部可见的只能给弘则内部查看
  1963. if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
  1964. resp.IsShow = true
  1965. }
  1966. resp.HasPermission = hasPermission
  1967. if hasPermission != 1 || !resp.IsShow {
  1968. br.Ret = 200
  1969. br.Success = true
  1970. br.Msg = "获取成功"
  1971. br.Data = resp
  1972. return
  1973. }
  1974. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1975. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1976. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1977. if err != nil {
  1978. br.Msg = "获取失败"
  1979. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1980. return
  1981. }
  1982. for k, v := range listFirst {
  1983. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1984. if err != nil && err.Error() != utils.ErrNoRow() {
  1985. br.Msg = "获取信息失败"
  1986. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1987. return
  1988. }
  1989. for k2, v2 := range listSecond {
  1990. v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
  1991. v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
  1992. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1993. if err != nil && err.Error() != utils.ErrNoRow() {
  1994. br.Msg = "获取信息失败"
  1995. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1996. return
  1997. }
  1998. if len(listThird) > 0 {
  1999. for k3, v3 := range listThird {
  2000. if v3.VideoUrl != "" {
  2001. listThird[k3].IsHaveVideo = true
  2002. }
  2003. if v3.ReportLink == "0" {
  2004. listThird[k3].ReportLink = ""
  2005. }
  2006. }
  2007. listSecond[k2].List = listThird
  2008. }
  2009. }
  2010. if len(listSecond) > 0 {
  2011. listFirst[k].List = listSecond
  2012. }
  2013. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  2014. if v.Type == "CYDYJY" {
  2015. listFirst[k].ListName = "产业调研纪要"
  2016. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  2017. } else if v.Type == "SSGS" {
  2018. listFirst[k].ListName = "上市公司调研纪要篇"
  2019. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  2020. } else if v.Type == "YANX" {
  2021. listFirst[k].ListName = "买方研选纪要"
  2022. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  2023. }
  2024. }
  2025. //historyRecord := new(models.CygxReportHistoryRecord)
  2026. //historyRecord.UserId = uid
  2027. //historyRecord.ArticleId = articleId
  2028. //historyRecord.CreateTime = time.Now()
  2029. //historyRecord.Mobile = user.Mobile
  2030. //historyRecord.Email = user.Email
  2031. //historyRecord.CompanyId = user.CompanyId
  2032. //historyRecord.CompanyName = user.CompanyName
  2033. //historyRecord.ReportType = "szjyhz"
  2034. //sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  2035. //if err != nil && err.Error() != utils.ErrNoRow() {
  2036. // br.Msg = "获取信息失败"
  2037. // br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  2038. // return
  2039. //}
  2040. //historyRecord.RealName = user.RealName
  2041. //if sellerItem != nil {
  2042. // historyRecord.SellerName = sellerItem.RealName
  2043. //}
  2044. //go models.AddCygxReportHistoryRecord(historyRecord)
  2045. go services.MinutesSummaryHistoryUserRmind(user, articleId) // 上周纪要汇总用户阅读,给销售发消息提醒
  2046. resp.List = listFirst
  2047. resp.Detail = detail
  2048. br.Ret = 200
  2049. br.Success = true
  2050. br.Msg = "获取成功"
  2051. br.Data = resp
  2052. }
  2053. // @Title 上周纪要汇总内容详情
  2054. // @Description 获取上周纪要汇总内容详情接口
  2055. // @Param ArticleId query int true "报告ID"
  2056. // @Success 200 {object} models.MinutesSummaryLetailResp
  2057. // @router /minutesSummary/detail [get]
  2058. func (this *ReportController) MinutesDetail() {
  2059. br := new(models.BaseResponse).Init()
  2060. defer func() {
  2061. this.Data["json"] = br
  2062. this.ServeJSON()
  2063. }()
  2064. user := this.User
  2065. if user == nil {
  2066. br.Msg = "请重新登录"
  2067. br.Ret = 408
  2068. return
  2069. }
  2070. //uid := user.UserId
  2071. articleId, _ := this.GetInt("ArticleId")
  2072. if articleId < 0 {
  2073. br.Msg = "参数错误"
  2074. br.ErrMsg = "参数错误"
  2075. return
  2076. }
  2077. resp := new(models.MinutesSummaryLetailResp)
  2078. //判断用户权限
  2079. hasPermission, err := services.GetUserhasPermission(user)
  2080. if err != nil {
  2081. br.Msg = "获取信息失败"
  2082. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  2083. }
  2084. resp.HasPermission = hasPermission
  2085. if hasPermission != 1 {
  2086. br.Ret = 200
  2087. br.Success = true
  2088. br.Msg = "获取成功"
  2089. br.Data = resp
  2090. return
  2091. }
  2092. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  2093. if err != nil {
  2094. br.Msg = "获取信息失败"
  2095. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  2096. return
  2097. }
  2098. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  2099. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  2100. listLog, err := models.GetMinutesSummarylogListAll(articleId)
  2101. if err != nil {
  2102. br.Msg = "获取失败"
  2103. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  2104. return
  2105. }
  2106. for k, v := range listLog {
  2107. listSonLog, err := models.GetMinutesSummarylogSonListAll(articleId, v.ChartPermissionId)
  2108. if err != nil && err.Error() != utils.ErrNoRow() {
  2109. br.Msg = "获取信息失败"
  2110. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2111. return
  2112. }
  2113. if len(listSonLog) > 0 {
  2114. for k2, v2 := range listSonLog {
  2115. if v2.ReportLink == "0" {
  2116. listSonLog[k2].ReportLink = ""
  2117. }
  2118. }
  2119. listLog[k].List = listSonLog
  2120. }
  2121. }
  2122. //historyRecord := new(models.CygxReportHistoryRecord)
  2123. //historyRecord.UserId = uid
  2124. //historyRecord.ArticleId = articleId
  2125. //historyRecord.CreateTime = time.Now()
  2126. //historyRecord.Mobile = user.Mobile
  2127. //historyRecord.Email = user.Email
  2128. //historyRecord.CompanyId = user.CompanyId
  2129. //historyRecord.CompanyName = user.CompanyName
  2130. //historyRecord.ReportType = "szjyhz"
  2131. //sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  2132. //if err != nil && err.Error() != utils.ErrNoRow() {
  2133. // br.Msg = "获取信息失败"
  2134. // br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  2135. // return
  2136. //}
  2137. //historyRecord.RealName = user.RealName
  2138. //if sellerItem != nil {
  2139. // historyRecord.SellerName = sellerItem.RealName
  2140. //}
  2141. //go models.AddCygxReportHistoryRecord(historyRecord)
  2142. resp.List = listLog
  2143. resp.Detail = detail
  2144. br.Ret = 200
  2145. br.Success = true
  2146. br.Msg = "获取成功"
  2147. br.Data = resp
  2148. }
  2149. // @Title 获取路演精华详情
  2150. // @Description 获取路演精华详情接口
  2151. // @Param ArticleId query int true "报告ID"
  2152. // @Success 200 {object} models.RoadshowDetailResp
  2153. // @router /roadshowEssence/detail [get]
  2154. func (this *ReportController) RoadshowDetail() {
  2155. br := new(models.BaseResponse).Init()
  2156. defer func() {
  2157. this.Data["json"] = br
  2158. this.ServeJSON()
  2159. }()
  2160. user := this.User
  2161. if user == nil {
  2162. br.Msg = "请登录"
  2163. br.ErrMsg = "请登录,用户信息为空"
  2164. br.Ret = 408
  2165. return
  2166. }
  2167. uid := user.UserId
  2168. articleId, err := this.GetInt("ArticleId")
  2169. if articleId <= 0 {
  2170. br.Msg = "文章不存在"
  2171. br.ErrMsg = "文章不存在,文章ID错误"
  2172. return
  2173. }
  2174. detail := new(models.ReportDetailRoadshow)
  2175. hasPermission := 0
  2176. hasFree := 0
  2177. //判断是否已经申请过
  2178. applyCount, err := models.GetApplyRecordCount(uid)
  2179. if err != nil && err.Error() != utils.ErrNoRow() {
  2180. br.Msg = "获取信息失败"
  2181. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2182. return
  2183. }
  2184. articleLyjhMap, _ := services.GetLyjhArticleMap()
  2185. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId)
  2186. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  2187. if user.CompanyId > 1 {
  2188. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  2189. if err != nil {
  2190. br.Msg = "获取信息失败"
  2191. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  2192. return
  2193. }
  2194. detail, err = models.GetReportRoadshowDetailById(articleId)
  2195. if err != nil {
  2196. br.Msg = "获取信息失败"
  2197. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2198. return
  2199. }
  2200. detail.IsCollect = articleCollectMap[detail.ArticleId]
  2201. detail.IsRoadShow = articleLyjhMap[detail.ArticleId]
  2202. detail.Body = html.UnescapeString(detail.Body)
  2203. detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
  2204. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  2205. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  2206. if detail.ReportLink == "0" {
  2207. detail.ReportLink = ""
  2208. }
  2209. if companyPermission == "" {
  2210. if applyCount > 0 {
  2211. hasPermission = 5
  2212. } else {
  2213. hasPermission = 2
  2214. }
  2215. hasFree = 2
  2216. goto Loop
  2217. } else {
  2218. hasFree = 1
  2219. var articlePermissionPermissionName string
  2220. articlePermissionPermissionName = detail.CategoryName
  2221. var hasPersion bool
  2222. slice := strings.Split(articlePermissionPermissionName, ",")
  2223. for _, v := range slice {
  2224. if strings.Contains(companyPermission, v) {
  2225. hasPersion = true
  2226. }
  2227. }
  2228. if hasPersion {
  2229. hasPermission = 1
  2230. historyRecord := new(models.CygxArticleHistoryRecord)
  2231. historyRecord.UserId = uid
  2232. historyRecord.ArticleId = articleId
  2233. historyRecord.CreateTime = time.Now()
  2234. historyRecord.Mobile = user.Mobile
  2235. historyRecord.Email = user.Email
  2236. historyRecord.CompanyId = user.CompanyId
  2237. historyRecord.CompanyName = user.CompanyName
  2238. go models.AddCygxArticleHistoryRecord(historyRecord)
  2239. } else { //无该行业权限
  2240. hasPermission = 3
  2241. }
  2242. if hasPermission == 1 {
  2243. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  2244. if !utils.Rc.IsExist(key) {
  2245. //新增浏览记录
  2246. record := new(models.CygxArticleViewRecord)
  2247. record.UserId = uid
  2248. record.ArticleId = articleId
  2249. record.CreateTime = time.Now()
  2250. record.Mobile = user.Mobile
  2251. record.Email = user.Email
  2252. record.CompanyId = user.CompanyId
  2253. record.CompanyName = user.CompanyName
  2254. go models.AddCygxArticleViewRecord(record)
  2255. utils.Rc.Put(key, 1, 5*time.Second)
  2256. models.ModifyReportLastViewTime(uid)
  2257. }
  2258. }
  2259. }
  2260. } else { //潜在客户
  2261. if applyCount > 0 {
  2262. hasPermission = 5
  2263. } else {
  2264. hasPermission = 4
  2265. }
  2266. }
  2267. Loop:
  2268. if hasPermission != 1 {
  2269. detail.Body = ""
  2270. detail.Abstract = ""
  2271. }
  2272. resp := new(models.RoadshowDetailResp)
  2273. resp.HasPermission = hasPermission
  2274. resp.HasFree = hasFree
  2275. resp.Detail = detail
  2276. br.Ret = 200
  2277. br.Success = true
  2278. br.Msg = "获取成功"
  2279. br.Data = resp
  2280. }
  2281. // @Title 产业文章列表接口
  2282. // @Description 获取产业文章列表接口
  2283. // @Param KeyWord query string true "搜索关键词"
  2284. // @Success 200 {object} models.CygxIndustrySearchList
  2285. // @router /industryAndArticle/list [get]
  2286. func (this *ReportController) IndustryAndArticleList() {
  2287. br := new(models.BaseResponse).Init()
  2288. defer func() {
  2289. this.Data["json"] = br
  2290. this.ServeJSON()
  2291. }()
  2292. user := this.User
  2293. if user == nil {
  2294. br.Msg = "请重新登录"
  2295. br.Ret = 408
  2296. return
  2297. }
  2298. uid := user.UserId
  2299. keyWord := this.GetString("KeyWord")
  2300. orderSrt := "update_time DESC"
  2301. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2302. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2303. if err != nil {
  2304. br.Msg = "获取信息失败"
  2305. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2306. return
  2307. }
  2308. for k, v := range list {
  2309. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2310. if err != nil {
  2311. br.Msg = "获取信息失败"
  2312. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2313. return
  2314. }
  2315. list[k].IndustrialSubjectList = industrialSubjectList
  2316. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2317. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2318. if err != nil {
  2319. br.Msg = "获取信息失败"
  2320. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2321. return
  2322. }
  2323. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2324. }
  2325. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2326. if err != nil {
  2327. br.Msg = "获取失败"
  2328. br.ErrMsg = "获取失败,Err:" + err.Error()
  2329. return
  2330. }
  2331. for k2, v2 := range artList {
  2332. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  2333. if err != nil {
  2334. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  2335. br.ErrMsg = "获取失败,Err:" + err.Error()
  2336. return
  2337. }
  2338. var subjectNamesNew string
  2339. if len(subjectNames) > 0 {
  2340. slice := strings.Split(subjectNames, "/")
  2341. for k3, v3 := range slice {
  2342. if k3 < 4 {
  2343. subjectNamesNew += v3 + "/"
  2344. }
  2345. }
  2346. }
  2347. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  2348. if err != nil && err.Error() != utils.ErrNoRow() {
  2349. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  2350. br.ErrMsg = "获取失败,Err:" + err.Error()
  2351. return
  2352. }
  2353. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2354. artList[k2].SubjectName = subjectNamesNew
  2355. if subjectNamesNew == "" {
  2356. artList[k2].IndustryName = industryName
  2357. } else {
  2358. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  2359. }
  2360. }
  2361. if keyWord != "" {
  2362. keyWordItem := new(models.CygxUserSearchKeyWord)
  2363. keyWordItem.UserId = user.UserId
  2364. keyWordItem.KeyWord = keyWord
  2365. keyWordItem.PageType = "ReortSearch"
  2366. keyWordItem.CreateTime = time.Now()
  2367. go models.AddUserSearchKeyWord(keyWordItem)
  2368. }
  2369. resp := new(models.CygxIndustrySearchList)
  2370. resp.ArtList = artList
  2371. resp.IndList = list
  2372. br.Ret = 200
  2373. br.Success = true
  2374. br.Msg = "获取成功"
  2375. br.Data = resp
  2376. }
  2377. // @Title 产业报告分类关联作者列表接口Pc端
  2378. // @Description 获取产业报告分类关联作者列表接口Pc端
  2379. // @Param ChartPermissionId query int true "分类ID"
  2380. // @Param KeyWord query string true "搜索关键词"
  2381. // @Param PageSize query int true "每页数据条数"
  2382. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2383. // @Success 200 {object} models.CygxArticleDepartmentListPc
  2384. // @router /industryListByDepartmentPc [get]
  2385. func (this *ReportController) IndustryListByDepartmentPc() {
  2386. br := new(models.BaseResponse).Init()
  2387. defer func() {
  2388. this.Data["json"] = br
  2389. this.ServeJSON()
  2390. }()
  2391. user := this.User
  2392. if user == nil {
  2393. br.Msg = "请重新登录"
  2394. br.Ret = 408
  2395. return
  2396. }
  2397. uid := user.UserId
  2398. pageSize, _ := this.GetInt("PageSize")
  2399. currentIndex, _ := this.GetInt("CurrentIndex")
  2400. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  2401. keyWord := this.GetString("KeyWord")
  2402. var startSize int
  2403. var condition string
  2404. condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  2405. if pageSize <= 0 {
  2406. pageSize = utils.PageSize20
  2407. }
  2408. if currentIndex <= 0 {
  2409. currentIndex = 1
  2410. }
  2411. var articleIdGroup string
  2412. if keyWord != "" {
  2413. //获取标的关联的文章ID
  2414. articleIdSub, err := models.GetArticleIdSubjectGroup(keyWord)
  2415. if err != nil {
  2416. br.Msg = "获取信息失败"
  2417. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2418. return
  2419. }
  2420. //获取产业关联的标的
  2421. articleIdInd, err := models.GetArticleIndustrialIdGroup(keyWord)
  2422. if err != nil {
  2423. br.Msg = "获取信息失败"
  2424. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  2425. return
  2426. }
  2427. if articleIdSub != "" && articleIdInd != "" {
  2428. articleIdGroup = articleIdSub + "," + articleIdInd
  2429. } else if articleIdSub != "" && articleIdInd == "" {
  2430. articleIdGroup = articleIdSub
  2431. } else if articleIdSub == "" && articleIdInd != "" {
  2432. articleIdGroup = articleIdInd
  2433. }
  2434. slice := strings.Split(keyWord, "/")
  2435. if len(slice) > 1 {
  2436. var subjectIds string
  2437. for _, v := range slice {
  2438. subjectId, err := models.GetcygxIndustrialSubjectByName(v)
  2439. if err != nil && err.Error() != utils.ErrNoRow() {
  2440. br.Msg = "获取信息失败"
  2441. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  2442. return
  2443. }
  2444. if subjectId != "" {
  2445. subjectIds += subjectId + ","
  2446. }
  2447. }
  2448. subjectIds = strings.TrimRight(subjectIds, ",")
  2449. if len(subjectIds) > 0 {
  2450. articleBySub, err := models.GetArticleIdsBySubId(subjectIds)
  2451. if err != nil {
  2452. br.Msg = "获取信息失败"
  2453. br.ErrMsg = "获取文章关联的标的失败,Err:" + err.Error()
  2454. return
  2455. }
  2456. if articleIdGroup != "" {
  2457. if articleBySub != "" {
  2458. articleIdGroup += "," + articleBySub
  2459. }
  2460. } else {
  2461. articleIdGroup = articleBySub
  2462. }
  2463. }
  2464. }
  2465. }
  2466. if articleIdGroup != "" {
  2467. condition += ` AND a.article_id IN (` + articleIdGroup + `)`
  2468. }
  2469. startSize = paging.StartIndex(currentIndex, pageSize)
  2470. total, err := models.GetArticleDepartmentCount(condition)
  2471. page := paging.GetPaging(currentIndex, pageSize, total)
  2472. resp := new(models.CygxArticleDepartmentListPc)
  2473. userType, _, err := services.GetUserType(user.CompanyId)
  2474. if err != nil {
  2475. br.Msg = "获取信息失败"
  2476. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  2477. return
  2478. }
  2479. if userType == 1 {
  2480. resp.Paging = page
  2481. br.Ret = 200
  2482. br.Success = true
  2483. br.Msg = "获取成功"
  2484. br.Data = resp
  2485. return
  2486. }
  2487. resp.HaveResearch = true
  2488. //获取作者信息,并排序
  2489. list, err := models.GetCygxArticleDepartmentListPc(startSize, pageSize, condition, uid)
  2490. if err != nil {
  2491. br.Msg = "获取信息失败"
  2492. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2493. return
  2494. }
  2495. for k, v := range list {
  2496. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIdGroup)
  2497. if err != nil {
  2498. br.Msg = "获取信息失败"
  2499. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2500. return
  2501. }
  2502. for k2, v2 := range artList {
  2503. if artList[k2].IsReport == "1" {
  2504. artList[k2].Title = v2.Title
  2505. } else {
  2506. artList[k2].Title = v2.Title
  2507. }
  2508. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2509. }
  2510. list[k].List = artList
  2511. if v.FollowNum > 0 {
  2512. list[k].IsMyFollow = true
  2513. }
  2514. }
  2515. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  2516. if err != nil {
  2517. br.Msg = "获取信息失败"
  2518. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2519. return
  2520. }
  2521. if len(listnNew) > 0 {
  2522. for _, v := range listnNew {
  2523. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  2524. Management := new(models.IndustrialManagementIdInt)
  2525. if firstStr == 0 {
  2526. Management.IndustryName = v.IndustryName
  2527. } else {
  2528. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  2529. if err != nil {
  2530. br.Msg = "获取信息失败"
  2531. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  2532. return
  2533. }
  2534. var subjectNamesNew string
  2535. for _, v1 := range listSub {
  2536. subjectNamesNew += v1.SubjectName + "/"
  2537. }
  2538. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2539. Management.IndustryName = subjectNamesNew
  2540. }
  2541. Management.IndustrialManagementId = v.IndustrialManagementId
  2542. Management.ArticleId = v.ArticleId
  2543. resp.ListnNew = append(resp.ListnNew, Management)
  2544. }
  2545. }
  2546. resp.List = list
  2547. resp.Paging = page
  2548. br.Ret = 200
  2549. br.Success = true
  2550. br.Msg = "获取成功"
  2551. br.Data = resp
  2552. }
  2553. // @Title 产业文章列表接口Pc端
  2554. // @Description 获取产业文章列表接口Pc端
  2555. // @Param KeyWord query string true "搜索关键词"
  2556. // @Success 200 {object} models.CygxIndustrySearchListPc
  2557. // @router /industryAndArticle/listPc [get]
  2558. func (this *ReportController) IndustryAndArticleListPc() {
  2559. br := new(models.BaseResponse).Init()
  2560. defer func() {
  2561. this.Data["json"] = br
  2562. this.ServeJSON()
  2563. }()
  2564. user := this.User
  2565. if user == nil {
  2566. br.Msg = "请重新登录"
  2567. br.Ret = 408
  2568. return
  2569. }
  2570. uid := user.UserId
  2571. keyWord := this.GetString("KeyWord")
  2572. resp := new(models.CygxIndustrySearchListPc)
  2573. orderSrt := "update_time DESC"
  2574. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2575. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2576. if err != nil {
  2577. br.Msg = "获取信息失败"
  2578. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2579. return
  2580. }
  2581. for k, v := range list {
  2582. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2583. if err != nil {
  2584. br.Msg = "获取信息失败"
  2585. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2586. return
  2587. }
  2588. list[k].IndustrialSubjectList = industrialSubjectList
  2589. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2590. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2591. if err != nil {
  2592. br.Msg = "获取信息失败"
  2593. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2594. return
  2595. }
  2596. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2597. }
  2598. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2599. if err != nil {
  2600. br.Msg = "获取失败"
  2601. br.ErrMsg = "获取失败,Err:" + err.Error()
  2602. return
  2603. }
  2604. if len(artList) > 0 {
  2605. var articleIds string
  2606. for _, v := range artList {
  2607. articleIds += strconv.Itoa(v.ArticleId) + ","
  2608. }
  2609. articleIds = strings.TrimRight(articleIds, ",")
  2610. if articleIds != "" {
  2611. condition = ` AND a.article_id IN (` + articleIds + `)`
  2612. DepartmentList, err := models.GetCygxArticleDepartmentListPc(0, 20, condition, uid)
  2613. if err != nil {
  2614. br.Msg = "获取信息失败"
  2615. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2616. return
  2617. }
  2618. for k, v := range DepartmentList {
  2619. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIds)
  2620. if err != nil {
  2621. br.Msg = "获取信息失败"
  2622. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2623. return
  2624. }
  2625. for k2, v2 := range artList {
  2626. if artList[k2].IsReport == "1" {
  2627. artList[k2].Title = v2.Title
  2628. } else {
  2629. artList[k2].Title = v2.Title
  2630. }
  2631. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2632. }
  2633. DepartmentList[k].List = artList
  2634. if v.FollowNum > 0 {
  2635. DepartmentList[k].IsMyFollow = true
  2636. }
  2637. }
  2638. resp.DepartmentList = DepartmentList
  2639. }
  2640. }
  2641. if keyWord != "" {
  2642. keyWordItem := new(models.CygxUserSearchKeyWord)
  2643. keyWordItem.UserId = user.UserId
  2644. keyWordItem.KeyWord = keyWord
  2645. keyWordItem.PageType = "ReortSearch"
  2646. keyWordItem.CreateTime = time.Now()
  2647. go models.AddUserSearchKeyWord(keyWordItem)
  2648. }
  2649. resp.IndList = list
  2650. br.Ret = 200
  2651. br.Success = true
  2652. br.Msg = "获取成功"
  2653. br.Data = resp
  2654. }
  2655. // @Title 报告搜索
  2656. // @Description 报告搜索接口
  2657. // @Param KeyWord query string true "搜索关键词"
  2658. // @Success 200 {object} models.ReoprtSearchResp
  2659. // @router /searchReport [get]
  2660. func (this *ReportController) SearchReport() {
  2661. br := new(models.BaseResponse).Init()
  2662. defer func() {
  2663. this.Data["json"] = br
  2664. this.ServeJSON()
  2665. }()
  2666. user := this.User
  2667. if user == nil {
  2668. br.Msg = "请重新登录"
  2669. br.Ret = 408
  2670. return
  2671. }
  2672. keyWord := this.GetString("KeyWord")
  2673. var condition string
  2674. var sqlGroup string
  2675. //匹配报告标题、
  2676. condition = `AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
  2677. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2678. //对应产业名称、标的名称。
  2679. listYx, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
  2680. if err != nil {
  2681. br.Msg = "获取信息失败"
  2682. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2683. return
  2684. }
  2685. for k, v := range listYx {
  2686. listYx[k].Source = 2
  2687. if v.MyCollectNum > 0 {
  2688. listYx[k].IsCollect = true
  2689. }
  2690. }
  2691. listHz, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId)
  2692. if err != nil {
  2693. br.Msg = "获取信息失败"
  2694. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2695. return
  2696. }
  2697. for k, v := range listHz {
  2698. listHz[k].Source = 1
  2699. if v.MyCollectNum > 0 {
  2700. listHz[k].IsCollect = true
  2701. }
  2702. }
  2703. if keyWord != "" {
  2704. keyWordItem := new(models.CygxUserSearchKeyWord)
  2705. keyWordItem.UserId = user.UserId
  2706. keyWordItem.KeyWord = keyWord
  2707. keyWordItem.PageType = "ReortSearch"
  2708. keyWordItem.CreateTime = time.Now()
  2709. go models.AddUserSearchKeyWord(keyWordItem)
  2710. //go services.AddUserSearchLog(user, keyWord, 5)
  2711. }
  2712. if len(listYx) == 0 {
  2713. listYx = make([]*models.ArticleCollectionResp, 0)
  2714. }
  2715. if len(listHz) == 0 {
  2716. listHz = make([]*models.ArticleCollectionResp, 0)
  2717. }
  2718. resp := new(models.ReoprtSearchResp)
  2719. resp.ListYx = listYx
  2720. resp.ListHz = listHz
  2721. br.Ret = 200
  2722. br.Success = true
  2723. br.Msg = "获取成功"
  2724. br.Data = resp
  2725. }
  2726. // @Title 资源包搜索
  2727. // @Description 资源包搜索接口
  2728. // @Param KeyWord query string true "搜索关键词"
  2729. // @Success 200 {object} models.SearchResourceResp
  2730. // @router /searchResource [get]
  2731. func (this *ReportController) SearchResource() {
  2732. br := new(models.BaseResponse).Init()
  2733. defer func() {
  2734. this.Data["json"] = br
  2735. this.ServeJSON()
  2736. }()
  2737. user := this.User
  2738. if user == nil {
  2739. br.Msg = "请重新登录"
  2740. br.Ret = 408
  2741. return
  2742. }
  2743. uid := user.UserId
  2744. fllowList, err := models.GetUserFllowIndustrialList(uid)
  2745. if err != nil {
  2746. br.Msg = "获取失败"
  2747. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  2748. return
  2749. }
  2750. fllowMap := make(map[int]int)
  2751. if len(fllowList) > 0 {
  2752. for _, v := range fllowList {
  2753. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  2754. }
  2755. }
  2756. keyWord := this.GetString("KeyWord")
  2757. var condition string
  2758. var conditionOr string
  2759. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2760. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2761. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2762. listHz, err := models.GetSearchResourceList(user.UserId, condition, 0, 0)
  2763. if err != nil {
  2764. br.Msg = "获取信息失败"
  2765. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2766. return
  2767. }
  2768. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2769. conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2770. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2771. listYx, err := models.GetSearchResourceList(user.UserId, condition, 0, 0)
  2772. if err != nil {
  2773. br.Msg = "获取信息失败"
  2774. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2775. return
  2776. }
  2777. //合并产业关联的标的
  2778. listSubjcet, err := models.GetThemeHeatSubjectList("")
  2779. if err != nil {
  2780. br.Msg = "获取信息失败"
  2781. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2782. return
  2783. }
  2784. industrialIdArr := make([]int, 0)
  2785. for k, v := range listHz {
  2786. listHz[k].Source = 1
  2787. if fllowMap[v.IndustrialManagementId] > 0 {
  2788. listHz[k].IsFollw = true
  2789. }
  2790. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2791. }
  2792. for k, v := range listYx {
  2793. listYx[k].Source = 2
  2794. if fllowMap[v.IndustrialManagementId] > 0 {
  2795. listYx[k].IsFollw = true
  2796. }
  2797. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2798. }
  2799. if len(industrialIdArr) > 0 {
  2800. //合并产业关联的标的
  2801. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  2802. if err != nil {
  2803. br.Msg = "获取信息失败"
  2804. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2805. return
  2806. }
  2807. mapIndustrial := make(map[string]int)
  2808. for _, v := range listSubjcet {
  2809. for k2, v2 := range listYx {
  2810. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
  2811. listYx[k2].IndustrialSubjectList = append(listYx[k2].IndustrialSubjectList, v)
  2812. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  2813. }
  2814. }
  2815. for k2, v2 := range listHz {
  2816. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  2817. listHz[k2].IndustrialSubjectList = append(listHz[k2].IndustrialSubjectList, v)
  2818. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  2819. }
  2820. }
  2821. }
  2822. }
  2823. if keyWord != "" {
  2824. keyWordItem := new(models.CygxUserSearchKeyWord)
  2825. keyWordItem.UserId = user.UserId
  2826. keyWordItem.KeyWord = keyWord
  2827. keyWordItem.PageType = "ReortSearch"
  2828. keyWordItem.CreateTime = time.Now()
  2829. go models.AddUserSearchKeyWord(keyWordItem)
  2830. }
  2831. resp := new(models.SearchResourceResp)
  2832. if len(listYx) == 0 {
  2833. listYx = make([]*models.IndustrialManagementHotResp, 0)
  2834. }
  2835. if len(listHz) == 0 {
  2836. listHz = make([]*models.IndustrialManagementHotResp, 0)
  2837. }
  2838. resp.ListYx = listYx
  2839. resp.ListHz = listHz
  2840. br.Ret = 200
  2841. br.Success = true
  2842. br.Msg = "获取成功"
  2843. br.Data = resp
  2844. }
  2845. // @Title 报告搜索、资源包搜索接口
  2846. // @Description 报告搜索、资源包搜索接口接口
  2847. // @Param KeyWord query string true "搜索关键词"
  2848. // @Param PageSize query int true "每页数据条数"
  2849. // @Success 200 {object} models.SearchReportAndResourceResp
  2850. // @router /searchReportAndResource [get]
  2851. func (this *ReportController) SearchReportAndResource() {
  2852. br := new(models.BaseResponse).Init()
  2853. defer func() {
  2854. this.Data["json"] = br
  2855. this.ServeJSON()
  2856. }()
  2857. user := this.User
  2858. if user == nil {
  2859. br.Msg = "请重新登录"
  2860. br.Ret = 408
  2861. return
  2862. }
  2863. uid := user.UserId
  2864. keyWord := this.GetString("KeyWord")
  2865. pageSize, _ := this.GetInt("PageSize")
  2866. var condition string
  2867. var conditionSpecial string // 研选专栏
  2868. var sqlGroup string
  2869. articleTypeIds, err := services.GetYanXuanArticleTypeIds()
  2870. if err != nil {
  2871. br.Msg = "获取信息失败"
  2872. br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
  2873. return
  2874. }
  2875. if articleTypeIds == "" {
  2876. br.Msg = "获取信息失败"
  2877. br.ErrMsg = "研选分类ID不能为空"
  2878. return
  2879. }
  2880. //匹配报告标题、
  2881. //condition = `AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
  2882. condition = `AND ( a.title LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
  2883. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2884. if pageSize > 0 {
  2885. sqlGroup += ` LIMIT 5 `
  2886. } else {
  2887. sqlGroup += ` LIMIT 100 `
  2888. }
  2889. conditionSpecial = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.content LIKE '%` + keyWord + `%' )`
  2890. ListYxReport, err := models.GetArticleAndYxSpecialList(` AND a.article_type_id IN (`+articleTypeIds+`) `+condition, conditionSpecial, user.UserId)
  2891. if err != nil {
  2892. br.Msg = "获取信息失败"
  2893. br.ErrMsg = "获取研选文章列表失败,Err:" + err.Error()
  2894. return
  2895. }
  2896. ListHzReport, err := models.GetReoprtSearchList(` AND a.article_type_id NOT IN (`+articleTypeIds+`) `+condition+sqlGroup, user.UserId)
  2897. if err != nil {
  2898. br.Msg = "获取信息失败"
  2899. br.ErrMsg = "获取弘则报告文章列表失败,Err:" + err.Error()
  2900. return
  2901. }
  2902. keyWordArr, err := services.GetIndustryMapNameSliceV3(keyWord)
  2903. if err != nil {
  2904. br.Msg = "获取失败"
  2905. br.ErrMsg = "获取分词失败,GetIndustryMapNameSliceV3 Err: " + err.Error()
  2906. return
  2907. }
  2908. keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
  2909. var keyWordIk string
  2910. if len(keyWordArr) > 1 {
  2911. keyWordIk = services.KeyWordArrSqlRegexp(keyWordArr)
  2912. var conditionIk string
  2913. var sqlGroupIk string
  2914. conditionIk = `AND ( a.title REGEXP '` + keyWordIk + `' OR a.annotation REGEXP '` + keyWordIk + `' OR a.abstract REGEXP '` + keyWordIk + `') AND a.publish_status = 1 `
  2915. sqlGroupIk = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2916. if pageSize > 0 {
  2917. sqlGroupIk += ` LIMIT 5 `
  2918. } else {
  2919. sqlGroupIk += ` LIMIT 20 `
  2920. }
  2921. //conditionIk += ` AND ( a.title NOT LIKE '%` + keyWord + `%' AND a.body NOT LIKE '%` + keyWord + `%' AND a.annotation NOT LIKE '%` + keyWord + `%' AND a.abstract NOT LIKE '%` + keyWord + `%') `
  2922. conditionIk += ` AND ( a.title NOT LIKE '%` + keyWord + `%' AND a.annotation NOT LIKE '%` + keyWord + `%' AND a.abstract NOT LIKE '%` + keyWord + `%') `
  2923. //研选的联想词列表
  2924. ListYxReportIk, err := models.GetArticleCollectionList(` AND a.article_type_id IN (`+articleTypeIds+`) `+conditionIk+sqlGroupIk, user.UserId)
  2925. if err != nil && err.Error() != utils.ErrNoRow() {
  2926. br.Msg = "获取信息失败"
  2927. br.ErrMsg = "获取研选IK文章列表失败,Err:" + err.Error()
  2928. return
  2929. }
  2930. if len(ListYxReportIk) > 0 {
  2931. for _, v := range ListYxReportIk {
  2932. ListYxReport = append(ListYxReport, v)
  2933. }
  2934. }
  2935. //弘则的联想词列表
  2936. ListHzReportIk, err := models.GetReoprtSearchList(` AND a.article_type_id NOT IN (`+articleTypeIds+`) `+conditionIk+sqlGroupIk, user.UserId)
  2937. if err != nil && err.Error() != utils.ErrNoRow() {
  2938. br.Msg = "获取信息失败"
  2939. br.ErrMsg = "获取研选IK文章列表失败,Err:" + err.Error()
  2940. return
  2941. }
  2942. if len(ListHzReportIk) > 0 {
  2943. for _, v := range ListHzReportIk {
  2944. ListHzReport = append(ListHzReport, v)
  2945. }
  2946. }
  2947. }
  2948. var articleIdsArr []int
  2949. var articleIdsSpecialArr []int // 研选专栏ID
  2950. for k, v := range ListHzReport {
  2951. ListHzReport[k].Source = 1
  2952. //if v.MyCollectNum > 0 {
  2953. // ListHzReport[k].IsCollect = true
  2954. //}
  2955. articleIdsArr = append(articleIdsArr, v.ArticleId)
  2956. }
  2957. for k, v := range ListYxReport {
  2958. ListYxReport[k].Source = 2
  2959. //if v.MyCollectNum > 0 {
  2960. // ListYxReport[k].IsCollect = true
  2961. //}
  2962. if v.ArticleTypeId == -1 {
  2963. articleIdsSpecialArr = append(articleIdsSpecialArr, v.ArticleId)
  2964. } else {
  2965. articleIdsArr = append(articleIdsArr, v.ArticleId)
  2966. }
  2967. }
  2968. var articleIds string
  2969. for _, v := range ListHzReport {
  2970. articleIds += strconv.Itoa(v.ArticleId) + ","
  2971. }
  2972. articleMapPv := services.GetArticleHistoryByArticleId(articleIdsArr) //文章Pv
  2973. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  2974. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIdsArr) //文章收藏的数量
  2975. articleCollectYanxuanSpecialMap, _ := services.GetYanxuanSpecialCollectMap(user.UserId) //用户收藏的研选专栏
  2976. for i, v := range ListYxReport {
  2977. articleIds += strconv.Itoa(v.ArticleId) + ","
  2978. if v.ArticleTypeId == -1 {
  2979. v.ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL
  2980. v.IsCollect = articleCollectYanxuanSpecialMap[v.ArticleId]
  2981. } else if v.ArticleTypeId > 0 {
  2982. ListYxReport[i].ArticleTypeName = utils.CYGX_YANXUAN_ARTICLE
  2983. ListYxReport[i].Pv = articleMapPv[v.ArticleId]
  2984. ListYxReport[i].CollectNum = articleCollectNumMap[v.ArticleId]
  2985. ListYxReport[i].IsCollect = articleCollectMap[v.ArticleId]
  2986. }
  2987. if v.SpecialType == 1 {
  2988. ListYxReport[i].Title = "【笔记】" + ListYxReport[i].Title
  2989. } else if ListYxReport[i].SpecialType == 2 {
  2990. ListYxReport[i].Title = "【观点】" + ListYxReport[i].Title
  2991. }
  2992. if v.CompanyTags != "" {
  2993. v.SpecialTags += v.CompanyTags
  2994. }
  2995. if v.IndustryTags != "" {
  2996. if v.SpecialTags != "" {
  2997. v.SpecialTags += ","
  2998. }
  2999. v.SpecialTags += v.IndustryTags
  3000. }
  3001. v.SpecialTags = v.SpecialTags
  3002. }
  3003. articleIds = strings.TrimRight(articleIds, ",")
  3004. silcearticleIds := strings.Split(articleIds, ",")
  3005. var parsindustrial []interface{}
  3006. parsindustrial = make([]interface{}, 0)
  3007. articleIdList := make([]string, 0)
  3008. for _, v := range silcearticleIds {
  3009. articleIdList = append(articleIdList, v)
  3010. }
  3011. conditionindustrial := ` AND mg.article_id IN ( ` + utils.GetOrmInReplace(len(silcearticleIds)) + ` ) `
  3012. parsindustrial = append(parsindustrial, articleIdList)
  3013. industrialList, err := models.GetIndustrialListByarticleId(parsindustrial, conditionindustrial)
  3014. if err != nil {
  3015. return
  3016. }
  3017. industrialMap := make(map[int][]*models.IndustrialManagementResp)
  3018. if len(industrialList) > 0 {
  3019. for _, v := range industrialList {
  3020. item := new(models.IndustrialManagementResp)
  3021. //item.ArticleId = v.ArticleId
  3022. item.IndustrialManagementId = v.IndustrialManagementId
  3023. item.IndustryName = v.IndustryName
  3024. item.ChartPermissionId = v.ChartPermissionId
  3025. industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
  3026. }
  3027. }
  3028. for k, v := range ListHzReport {
  3029. if len(industrialMap[v.ArticleId]) > 0 {
  3030. ListHzReport[k].List = industrialMap[v.ArticleId]
  3031. } else {
  3032. ListHzReport[k].List = make([]*models.IndustrialManagementResp, 0)
  3033. }
  3034. v.Pv = articleMapPv[v.ArticleId]
  3035. v.CollectNum = articleCollectNumMap[v.ArticleId]
  3036. v.IsCollect = articleCollectMap[v.ArticleId]
  3037. if v.ReportId > 0 {
  3038. v.Resource = 3
  3039. }
  3040. }
  3041. for k, v := range ListYxReport {
  3042. if len(industrialMap[v.ArticleId]) > 0 {
  3043. ListYxReport[k].List = industrialMap[v.ArticleId]
  3044. } else {
  3045. ListYxReport[k].List = make([]*models.IndustrialManagementResp, 0)
  3046. }
  3047. }
  3048. //获取文章关联的产业
  3049. if len(ListYxReport) == 0 {
  3050. ListYxReport = make([]*models.ArticleCollectionResp, 0)
  3051. }
  3052. if len(ListHzReport) == 0 {
  3053. ListHzReport = make([]*models.ArticleCollectionResp, 0)
  3054. }
  3055. fllowList, err := models.GetUserFllowIndustrialList(uid)
  3056. if err != nil {
  3057. br.Msg = "获取失败"
  3058. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  3059. return
  3060. }
  3061. fllowMap := make(map[int]int)
  3062. if len(fllowList) > 0 {
  3063. for _, v := range fllowList {
  3064. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  3065. }
  3066. }
  3067. condition = ` AND a.publish_status = 1 AND a.article_type_id NOT IN (` + articleTypeIds + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  3068. listHzResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
  3069. if err != nil {
  3070. br.Msg = "获取信息失败"
  3071. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  3072. return
  3073. }
  3074. condition = ` AND a.publish_status = 1 AND a.article_type_id IN (` + articleTypeIds + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  3075. hotMapindustrial, e := services.IndustrialManagementHotMapGropuPermission()
  3076. if e != nil {
  3077. br.Msg = "获取信息失败"
  3078. br.ErrMsg = "获取hot标签失败,IndustrialManagementHotMapGropuPermission ,Err:" + err.Error()
  3079. return
  3080. }
  3081. listYxResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
  3082. if err != nil {
  3083. br.Msg = "获取信息失败"
  3084. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  3085. return
  3086. }
  3087. //合并产业关联的标的
  3088. listSubjcet, err := models.GetThemeHeatSubjectList("")
  3089. if err != nil {
  3090. br.Msg = "获取信息失败"
  3091. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  3092. return
  3093. }
  3094. industrialIdArr := make([]int, 0)
  3095. nowTime := time.Now().Local()
  3096. threeMonBefore := nowTime.AddDate(0, -3, 0)
  3097. mapHot := make(map[int]bool)
  3098. //if themeType == 2 {
  3099. mapHot, err = services.GetYanXuanIndustrialManagementIdHotMap(articleTypeIds)
  3100. if err != nil {
  3101. br.Msg = "获取信息失败"
  3102. br.ErrMsg = "GetYanXuanIndustrialManagementIdNewMap,Err:" + err.Error()
  3103. return
  3104. }
  3105. //conditionOrder := ` ORDER BY sum_num DESC `
  3106. //listHot, err := models.GetThemeHeatList(user.UserId, condition, conditionOrder, 0, 3)
  3107. //if err != nil {
  3108. // br.Msg = "获取信息失败"
  3109. // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  3110. // return
  3111. //}
  3112. for k, _ := range mapHot {
  3113. industrialIdArr = append(industrialIdArr, k)
  3114. }
  3115. orderSrt := "man.recommended_index DESC,update_time DESC"
  3116. for k, v := range listHzResource {
  3117. // 关联报告发布时间均在3个月内则标记New
  3118. if v.MinReportTime != "" {
  3119. t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  3120. if e != nil {
  3121. err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
  3122. return
  3123. }
  3124. if t.After(threeMonBefore) {
  3125. listHzResource[k].IsNew = true
  3126. }
  3127. }
  3128. //弘则资源包不展示hot标签
  3129. //if mapHot[v.IndustryName] > 0 {
  3130. // listHzResource[k].IsHot = true
  3131. //}
  3132. listHzResource[k].Source = 1
  3133. if fllowMap[v.IndustrialManagementId] > 0 {
  3134. listHzResource[k].IsFollw = true
  3135. }
  3136. v.IsHot = hotMapindustrial[v.IndustrialManagementId]
  3137. industrialIdSlice := make([]int, 0)
  3138. articleIdArr := make([]int, 0)
  3139. industrialIdSlice = append(industrialIdSlice, v.IndustrialManagementId)
  3140. listUpdateTime, err := models.GetNewArticleDetailByIndustrialIds(industrialIdSlice)
  3141. if err != nil && err.Error() != utils.ErrNoRow() {
  3142. return
  3143. }
  3144. for _, v := range listUpdateTime {
  3145. articleIdArr = append(articleIdArr, v.ArticleId)
  3146. }
  3147. if err != nil {
  3148. return
  3149. }
  3150. mapHistroyArticleId := make(map[int]int)
  3151. if user.UserId > 0 {
  3152. listArticleHistory, e := models.GetUserToArticleHistory(user.UserId, articleIdArr)
  3153. if e != nil && e.Error() != utils.ErrNoRow() {
  3154. err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
  3155. return
  3156. }
  3157. for _, v := range listArticleHistory {
  3158. mapHistroyArticleId[v.ArticleId] = v.ArticleId
  3159. }
  3160. }
  3161. condition2 := ` AND man.industry_name LIKE '%` + keyWord + `%' `
  3162. list, err := models.GetIndustrialManagementAll(uid, condition2, orderSrt, 0, 20)
  3163. if err != nil {
  3164. br.Msg = "获取信息失败"
  3165. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  3166. return
  3167. }
  3168. mapUPdateTime := make(map[int]string)
  3169. //获取这些产业下最新更新的文章
  3170. //时间线的更新时间
  3171. // maptimelineUPdateTime := make(map[int]string)
  3172. listtimelinePublishdate, err := models.GetTimeLineReportIndustrialPublishdateList(industrialIdArr)
  3173. if err != nil && err.Error() != utils.ErrNoRow() {
  3174. br.Msg = "获取信息失败"
  3175. br.ErrMsg = "GetTimeLineReportIndustrialPublishdateList,Err:" + err.Error()
  3176. return
  3177. }
  3178. for _, v := range listtimelinePublishdate {
  3179. if mapUPdateTime[v.IndustrialManagementId] != "" {
  3180. if utils.StrTimeToTime(v.PublishDate).After(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3181. mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
  3182. }
  3183. }
  3184. }
  3185. //mapHistroyArticleId := make(map[int]int)
  3186. //if userId > 0 {
  3187. // listArticleHistory, e := models.GetUserToArticleHistory(userId, articleIdArr)
  3188. // if e != nil && e.Error() != utils.ErrNoRow() {
  3189. // err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
  3190. // return
  3191. // }
  3192. // for _, v := range listArticleHistory {
  3193. // mapHistroyArticleId[v.ArticleId] = v.ArticleId
  3194. // }
  3195. //}
  3196. var industrialIds string
  3197. for _, id := range industrialIdArr {
  3198. industrialIds += strconv.Itoa(id) + ","
  3199. }
  3200. industrialIds = strings.TrimRight(industrialIds, ",")
  3201. articleList, err := models.GetReportIndustrialReadNumList(user.UserId, industrialIds, user.CreatedTime)
  3202. if err != nil && err.Error() != utils.ErrNoRow() {
  3203. br.Msg = "获取信息失败"
  3204. br.ErrMsg = "GetReportIndustrialReadNumList,Err:" + err.Error()
  3205. return
  3206. }
  3207. mapHistroyindustrialId := make(map[int]int)
  3208. for _, v := range articleList {
  3209. mapHistroyindustrialId[v.IndustrialManagementId] = v.Readnum
  3210. }
  3211. //nowTime := time.Now().Local()
  3212. //threeMonBefore := nowTime.AddDate(0, -3, 0)
  3213. //查询用户今天是否看过时间线
  3214. //haveMorningMeeting := false
  3215. //var morningMeetingTime string
  3216. recrodList, err := models.GetTimeLineRecordAllCount(user.UserId, time.Now().Format(utils.FormatDate))
  3217. if err != nil {
  3218. br.Msg = "获取信息失败"
  3219. br.ErrMsg = "GetTimeLineRecordAllCount,Err:" + err.Error()
  3220. return
  3221. }
  3222. var industrialManagementIdstr string
  3223. industrialIdMap := make(map[string]time.Time)
  3224. for _, v := range recrodList {
  3225. industrialManagementIdstr = strings.TrimLeft(v.Parameter, "PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=")
  3226. if createTime, ok := industrialIdMap[industrialManagementIdstr]; ok {
  3227. if createTime.Before(v.CreateTime) {
  3228. industrialIdMap[industrialManagementIdstr] = v.CreateTime
  3229. }
  3230. } else {
  3231. industrialIdMap[industrialManagementIdstr] = v.CreateTime
  3232. }
  3233. }
  3234. mmList, err := models.GetCygxMorningMeetingReviewsListByIndustrialIds(industrialIds)
  3235. if err != nil {
  3236. return
  3237. }
  3238. morningMeetingTimeMap := make(map[int]time.Time)
  3239. for _, v := range mmList {
  3240. morningMeetingTimeMap[v.IndustryId] = v.CreateTime
  3241. }
  3242. timeLineRedMap := make(map[int]bool, 0)
  3243. for _, industrialId := range industrialIdArr {
  3244. if createTime, ok := industrialIdMap[strconv.Itoa(industrialId)]; ok {
  3245. if createTime.Before(morningMeetingTimeMap[industrialId]) {
  3246. timeLineRedMap[industrialId] = true
  3247. }
  3248. }
  3249. }
  3250. for k, v := range list {
  3251. list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
  3252. if user.UserId > 0 {
  3253. //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
  3254. if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
  3255. if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3256. list[k].IsRed = true
  3257. }
  3258. }
  3259. } else {
  3260. if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3261. list[k].IsRed = true
  3262. }
  3263. list[k].IsFollow = 0
  3264. }
  3265. list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
  3266. if user.UserId > 0 {
  3267. //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
  3268. if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
  3269. if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3270. list[k].IsRed = true
  3271. }
  3272. }
  3273. } else {
  3274. if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3275. list[k].IsRed = true
  3276. }
  3277. list[k].IsFollow = 0
  3278. }
  3279. }
  3280. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  3281. }
  3282. for k, v := range listYxResource {
  3283. // 关联报告发布时间均在3个月内则标记New
  3284. if v.MinReportTime != "" {
  3285. t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  3286. if e != nil {
  3287. err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
  3288. return
  3289. }
  3290. if t.After(threeMonBefore) {
  3291. listYxResource[k].IsNew = true
  3292. }
  3293. }
  3294. listYxResource[k].IsHot = mapHot[v.IndustrialManagementId]
  3295. listYxResource[k].Source = 2
  3296. if fllowMap[v.IndustrialManagementId] > 0 {
  3297. listYxResource[k].IsFollw = true
  3298. }
  3299. v.IsHot = hotMapindustrial[v.IndustrialManagementId]
  3300. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  3301. }
  3302. if len(industrialIdArr) > 0 {
  3303. //查询产业视频
  3304. industrialVideoMap := make(map[int]*models.MicroVideoSimpleInfo)
  3305. // 获取默认图配置
  3306. _, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
  3307. if e != nil {
  3308. br.Msg = "获取视频默认配置图失败"
  3309. br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
  3310. return
  3311. }
  3312. videoList, err := models.GetMicroRoadshowVideoByIndustryIds(industrialIdArr)
  3313. if err != nil {
  3314. br.Msg = "产业视频列表失败"
  3315. br.ErrMsg = "产业视频列表失败, Err: " + err.Error()
  3316. return
  3317. }
  3318. for _, v := range videoList {
  3319. tmp := &models.MicroVideoSimpleInfo{
  3320. Id: v.VideoId,
  3321. Title: "5min逻辑【" + v.IndustryName + "】解析",
  3322. ResourceUrl: v.VideoUrl,
  3323. BackgroundImg: v.ImgUrl,
  3324. PlaySeconds: v.VideoDuration,
  3325. DetailImgUrl: v.DetailImgUrl,
  3326. ChartPermissionName: v.ChartPermissionName,
  3327. ChartPermissionId: v.ChartPermissionId,
  3328. }
  3329. if tmp.BackgroundImg == "" {
  3330. tmp.BackgroundImg = videoMap[v.ChartPermissionId]
  3331. }
  3332. industrialVideoMap[v.IndustryId] = tmp
  3333. }
  3334. //查询权限
  3335. // 用户权限
  3336. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  3337. if e != nil {
  3338. br.Msg = "获取失败"
  3339. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  3340. return
  3341. }
  3342. for k, v := range listHzResource {
  3343. //展示产业视频
  3344. if video, ok := industrialVideoMap[v.IndustrialManagementId]; ok {
  3345. au := new(models.UserPermissionAuthInfo)
  3346. au.SellerName = authInfo.SellerName
  3347. au.SellerMobile = authInfo.SellerMobile
  3348. au.HasPermission = authInfo.HasPermission
  3349. au.OperationMode = authInfo.OperationMode
  3350. if au.HasPermission == 1 {
  3351. // 非宏观权限进一步判断是否有权限
  3352. if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
  3353. au.HasPermission = 2
  3354. }
  3355. }
  3356. // 无权限的弹框提示
  3357. if au.HasPermission != 1 {
  3358. if au.OperationMode == services.UserPermissionOperationModeCall {
  3359. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  3360. } else {
  3361. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  3362. }
  3363. video.ResourceUrl = ""
  3364. }
  3365. listHzResource[k].AuthInfo = au
  3366. listHzResource[k].IndustryVideo = video
  3367. }
  3368. }
  3369. //合并产业关联的标的
  3370. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  3371. if err != nil {
  3372. br.Msg = "获取信息失败"
  3373. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  3374. return
  3375. }
  3376. //严选的产业只关联研选下面的标的
  3377. var yxcondition string
  3378. var yxPer []interface{}
  3379. yxcondition = ` AND ag.article_id >= ?`
  3380. yxPer = append(yxPer, utils.SummaryArticleId)
  3381. listYxAticleSubject, err := models.GetSubjectArticleGroupManagementList(yxcondition, yxPer)
  3382. if err != nil && err.Error() != utils.ErrNoRow() {
  3383. br.Msg = "获取信息失败"
  3384. br.ErrMsg = "获取研选报告关联的标的信息失败,GetSubjectArticleGroupManagementListErr:" + err.Error()
  3385. return
  3386. }
  3387. mapYxSubject := make(map[int]int)
  3388. for _, v := range listYxAticleSubject {
  3389. mapYxSubject[v.IndustrialSubjectId] = v.IndustrialSubjectId
  3390. }
  3391. mapIndustrial := make(map[string]int)
  3392. for _, v := range listSubjcet {
  3393. for k2, v2 := range listYxResource {
  3394. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 && mapYxSubject[v.IndustrialSubjectId] > 0 {
  3395. listYxResource[k2].IndustrialSubjectList = append(listYxResource[k2].IndustrialSubjectList, v)
  3396. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  3397. }
  3398. }
  3399. for k2, v2 := range listHzResource {
  3400. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  3401. listHzResource[k2].IndustrialSubjectList = append(listHzResource[k2].IndustrialSubjectList, v)
  3402. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  3403. }
  3404. }
  3405. }
  3406. }
  3407. resp := new(models.SearchReportAndResourceResp)
  3408. if len(listYxResource) == 0 {
  3409. listYxResource = make([]*models.IndustrialManagementHotResp, 0)
  3410. }
  3411. if len(listHzResource) == 0 {
  3412. listHzResource = make([]*models.IndustrialManagementHotResp, 0)
  3413. }
  3414. if keyWord != "" {
  3415. keyWordItem := new(models.CygxUserSearchKeyWord)
  3416. keyWordItem.UserId = user.UserId
  3417. keyWordItem.KeyWord = keyWord
  3418. keyWordItem.PageType = "ReortSearch"
  3419. keyWordItem.CreateTime = time.Now()
  3420. go models.AddUserSearchKeyWord(keyWordItem)
  3421. //go services.AddUserSearchLog(user, keyWord, 5)
  3422. }
  3423. resp.ListHzResource = listHzResource
  3424. resp.ListYxResource = listYxResource
  3425. resp.ListYxReport = ListYxReport
  3426. resp.ListHzReport = ListHzReport
  3427. br.Ret = 200
  3428. br.Success = true
  3429. br.Msg = "获取成功"
  3430. br.Data = resp
  3431. }
  3432. // @Title 产业报告公司列表
  3433. // @Description 获取产业报告公司列表接口
  3434. // @Param ChartPermissionId query int true "行业id"
  3435. // @Success 200 {object} models.IndustrialManagementList
  3436. // @router /home/stockName [get]
  3437. func (this *ReportController) StockNameList() {
  3438. br := new(models.BaseResponse).Init()
  3439. defer func() {
  3440. this.Data["json"] = br
  3441. this.ServeJSON()
  3442. }()
  3443. user := this.User
  3444. if user == nil {
  3445. br.Msg = "请重新登录"
  3446. br.Ret = 408
  3447. return
  3448. }
  3449. //uid := user.UserId
  3450. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  3451. list, err := models.GetSummaryArticle(chartPermissionId)
  3452. if err != nil {
  3453. br.Msg = "获取综述报告公司名称失败"
  3454. br.ErrMsg = "获取综述报告公司名称失败,Err:" + err.Error()
  3455. return
  3456. }
  3457. var respList []*models.SummaryArticleStock
  3458. for _, item := range list {
  3459. sliceSubjects := strings.Split(item.Stock, "/")
  3460. if len(sliceSubjects) > 0 {
  3461. for i, vSubject := range sliceSubjects {
  3462. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  3463. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  3464. subject := sliceXiahuaxian[0]
  3465. if i > 0 {
  3466. newItem := models.SummaryArticleStock{
  3467. Id: item.Id,
  3468. ArticleId: item.ArticleId,
  3469. Stock: subject,
  3470. }
  3471. respList = append(respList, &newItem)
  3472. } else {
  3473. item.Stock = subject
  3474. respList = append(respList, item)
  3475. }
  3476. }
  3477. }
  3478. //index := strings.Index(item.Stock, "(")
  3479. //item.Stock = item.Stock[:index]
  3480. //if strings.Contains(item.Stock, "-B"){
  3481. // item.Stock = strings.Replace(item.Stock, "-B", "", -1)
  3482. //}
  3483. //if strings.Contains(item.Stock, "-W"){
  3484. // item.Stock = strings.Replace(item.Stock, "-W", "", -1)
  3485. //}
  3486. }
  3487. resp := new(models.SummaryArticleStockResp)
  3488. resp.List = respList
  3489. br.Ret = 200
  3490. br.Success = true
  3491. br.Msg = "获取成功"
  3492. br.Data = resp
  3493. }
  3494. // @Title 文章留言接口
  3495. // @Description 文章留言接口
  3496. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  3497. // @Success 200 {object} models.TacticsListResp
  3498. // @router /commentAdd [post]
  3499. func (this *ReportController) CommentAdd() {
  3500. br := new(models.BaseResponse).Init()
  3501. defer func() {
  3502. this.Data["json"] = br
  3503. this.ServeJSON()
  3504. }()
  3505. user := this.User
  3506. if user == nil {
  3507. br.Msg = "请重新登录"
  3508. br.Ret = 408
  3509. return
  3510. }
  3511. var req models.AddCygxArticleCommentReq
  3512. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3513. if err != nil {
  3514. br.Msg = "参数解析异常!"
  3515. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3516. return
  3517. }
  3518. if req.ArticleId <= 0 {
  3519. br.Msg = "文章不存在"
  3520. br.ErrMsg = "文章不存在,文章ID错误"
  3521. return
  3522. }
  3523. if req.Content == "" {
  3524. br.Msg = "建议内容不可为空"
  3525. return
  3526. }
  3527. content := req.Content
  3528. itemToken, err := services.WxGetToken()
  3529. if err != nil {
  3530. br.Msg = "GetWxAccessToken Err:" + err.Error()
  3531. return
  3532. }
  3533. if itemToken.AccessToken == "" {
  3534. br.Msg = "accessToken is empty"
  3535. return
  3536. }
  3537. commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  3538. if err != nil {
  3539. br.Msg = "内容校验失败!"
  3540. br.ErrMsg = "内容校验失败,Err:" + err.Error()
  3541. return
  3542. }
  3543. if commerr.ErrCode != 0 {
  3544. br.Msg = "内容违规,请重新提交!"
  3545. br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
  3546. return
  3547. }
  3548. articleId := req.ArticleId
  3549. articleInfo, errInfo := models.GetArticleDetailById(articleId)
  3550. if articleInfo == nil {
  3551. br.Msg = "操作失败"
  3552. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3553. return
  3554. }
  3555. if errInfo != nil {
  3556. br.Msg = "操作失败"
  3557. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3558. return
  3559. }
  3560. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  3561. if err != nil {
  3562. br.Msg = "提交失败!"
  3563. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3564. return
  3565. }
  3566. if companyDetail == nil {
  3567. br.Msg = "提交失败!"
  3568. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  3569. return
  3570. }
  3571. item := models.CygxArticleComment{
  3572. UserId: user.UserId,
  3573. ArticleId: req.ArticleId,
  3574. CreateTime: time.Now(),
  3575. Mobile: user.Mobile,
  3576. Email: user.Email,
  3577. CompanyId: user.CompanyId,
  3578. CompanyName: companyDetail.CompanyName,
  3579. Content: content,
  3580. Title: articleInfo.Title,
  3581. }
  3582. msgId, err := models.AddArticleComment(&item)
  3583. if err != nil {
  3584. br.Msg = "提交失败"
  3585. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  3586. return
  3587. }
  3588. go services.SendCommentWxTemplateMsg(req, user, articleInfo, int(msgId))
  3589. go services.SendCommentWxTemplateMsgByYxCategory(req, user, articleInfo, int(msgId)) // 发送用户留言提醒(研选公众号类目模版消息)
  3590. br.Ret = 200
  3591. br.Success = true
  3592. br.Msg = "提交成功"
  3593. }
  3594. // @Title 记录用户浏览音频回放接口
  3595. // @Description 记录用户浏览音频回放接口
  3596. // @Param request body models.ArticleIdReq true "type json string"
  3597. // @Success Ret=200 操作成功
  3598. // @router /voiceHistory/add [post]
  3599. func (this *ReportController) ResearchSummaryVoiceHistoryAdd() {
  3600. br := new(models.BaseResponse).Init()
  3601. defer func() {
  3602. this.Data["json"] = br
  3603. this.ServeJSON()
  3604. }()
  3605. user := this.User
  3606. if user == nil {
  3607. br.Msg = "请登录"
  3608. br.ErrMsg = "请登录,用户信息为空"
  3609. br.Ret = 408
  3610. return
  3611. }
  3612. uid := user.UserId
  3613. var req models.ArticleIdReq
  3614. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3615. if err != nil {
  3616. br.Msg = "参数解析异常!"
  3617. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3618. return
  3619. }
  3620. articleId := req.ArticleId
  3621. playSeconds := req.PlaySeconds
  3622. pageRouter := req.PageRouter
  3623. if pageRouter == "本周研究汇总" {
  3624. articleInfo, errInfo := models.GetCygxResearchSummaryInfoById(articleId)
  3625. if articleInfo == nil {
  3626. br.Msg = "操作失败"
  3627. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3628. return
  3629. }
  3630. if errInfo != nil {
  3631. br.Msg = "操作失败"
  3632. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3633. return
  3634. }
  3635. var sellerName string
  3636. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3637. if err != nil {
  3638. br.Msg = "报名失败!"
  3639. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3640. return
  3641. }
  3642. item := models.CygxResearchSummaryVoiceHistory{
  3643. ArticleId: articleId,
  3644. UserId: uid,
  3645. CreateTime: time.Now(),
  3646. Mobile: user.Mobile,
  3647. Email: user.Email,
  3648. CompanyId: user.CompanyId,
  3649. CompanyName: user.CompanyName,
  3650. RealName: user.RealName,
  3651. SellerName: sellerName,
  3652. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3653. ModifyTime: time.Now(),
  3654. }
  3655. if playSeconds != 0 {
  3656. lastItem, err := models.GetLastCygxResearchSummaryVoiceHistory(articleId, user.UserId)
  3657. if err != nil {
  3658. br.Msg = "操作失败"
  3659. br.ErrMsg = "操作失败,GetLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  3660. return
  3661. }
  3662. err = models.UpdateLastCygxResearchSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3663. if err != nil {
  3664. br.Msg = "更新失败"
  3665. br.ErrMsg = "更新失败,UpdateLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  3666. return
  3667. }
  3668. } else {
  3669. err = models.AddCygxResearchSummaryVoiceHistory(&item)
  3670. if err != nil {
  3671. br.Msg = "操作失败"
  3672. br.ErrMsg = "操作失败,Err:" + err.Error()
  3673. return
  3674. }
  3675. err = models.UpdateResearchSummaryVoiceCounts(articleId)
  3676. if err != nil {
  3677. br.Msg = "更新失败"
  3678. br.ErrMsg = "更新失败,Err:" + err.Error()
  3679. return
  3680. }
  3681. }
  3682. } else if pageRouter == "上周纪要汇总" {
  3683. articleInfo, errInfo := models.GetCygxMinutesSummaryInfoById(articleId)
  3684. if articleInfo == nil {
  3685. br.Msg = "操作失败"
  3686. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3687. return
  3688. }
  3689. if errInfo != nil {
  3690. br.Msg = "操作失败"
  3691. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3692. return
  3693. }
  3694. var sellerName string
  3695. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3696. if err != nil {
  3697. br.Msg = "报名失败!"
  3698. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3699. return
  3700. }
  3701. item := models.CygxMinutesSummaryVoiceHistory{
  3702. ArticleId: articleId,
  3703. UserId: uid,
  3704. CreateTime: time.Now(),
  3705. Mobile: user.Mobile,
  3706. Email: user.Email,
  3707. CompanyId: user.CompanyId,
  3708. CompanyName: user.CompanyName,
  3709. RealName: user.RealName,
  3710. SellerName: sellerName,
  3711. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3712. ModifyTime: time.Now(),
  3713. }
  3714. if playSeconds != 0 {
  3715. lastItem, err := models.GetLastCygxMinutesSummaryVoiceHistory(articleId, user.UserId)
  3716. if err != nil {
  3717. br.Msg = "操作失败"
  3718. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  3719. return
  3720. }
  3721. err = models.UpdateLastCygxMinutesSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3722. if err != nil {
  3723. br.Msg = "更新失败"
  3724. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  3725. return
  3726. }
  3727. } else {
  3728. err = models.AddCygxMinutesSummaryVoiceHistory(&item)
  3729. if err != nil {
  3730. br.Msg = "操作失败"
  3731. br.ErrMsg = "操作失败,Err:" + err.Error()
  3732. return
  3733. }
  3734. err = models.UpdateMinutesSummaryVoiceCounts(articleId)
  3735. if err != nil {
  3736. br.Msg = "更新失败"
  3737. br.ErrMsg = "更新失败,Err:" + err.Error()
  3738. return
  3739. }
  3740. }
  3741. } else if pageRouter == "报告精选" {
  3742. articleInfo, errInfo := models.GetCygxReportSelectionInfoById(articleId)
  3743. if articleInfo == nil {
  3744. br.Msg = "操作失败"
  3745. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3746. return
  3747. }
  3748. if errInfo != nil {
  3749. br.Msg = "操作失败"
  3750. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3751. return
  3752. }
  3753. var sellerName string
  3754. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3755. if err != nil {
  3756. br.Msg = "报名失败!"
  3757. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3758. return
  3759. }
  3760. item := models.CygxReportSelectionVoiceHistory{
  3761. ArticleId: articleId,
  3762. UserId: uid,
  3763. CreateTime: time.Now(),
  3764. Mobile: user.Mobile,
  3765. Email: user.Email,
  3766. CompanyId: user.CompanyId,
  3767. CompanyName: user.CompanyName,
  3768. RealName: user.RealName,
  3769. SellerName: sellerName,
  3770. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3771. ModifyTime: time.Now(),
  3772. }
  3773. if playSeconds != 0 {
  3774. lastItem, err := models.GetLastCygxReportSelectionVoiceHistory(articleId, user.UserId)
  3775. if err != nil {
  3776. br.Msg = "操作失败"
  3777. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  3778. return
  3779. }
  3780. err = models.UpdateLastCygxReportSelectionVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3781. if err != nil {
  3782. br.Msg = "更新失败"
  3783. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  3784. return
  3785. }
  3786. } else {
  3787. err = models.AddCygxReportSelectionVoiceHistory(&item)
  3788. if err != nil {
  3789. br.Msg = "操作失败"
  3790. br.ErrMsg = "操作失败,Err:" + err.Error()
  3791. return
  3792. }
  3793. err = models.UpdateReportSelectionVoiceCounts(articleId)
  3794. if err != nil {
  3795. br.Msg = "更新失败"
  3796. br.ErrMsg = "更新失败,Err:" + err.Error()
  3797. return
  3798. }
  3799. }
  3800. }
  3801. br.Ret = 200
  3802. br.Success = true
  3803. br.Msg = "操作成功"
  3804. return
  3805. }
  3806. // @Title 周期行业报告分类列表接口
  3807. // @Description 周期获取行业报告分类列表接口
  3808. // @Success 200 {object} models.TradeReportMappingResp
  3809. // @router /zhouqi_tradeList [get]
  3810. func (this *ReportController) ZouqiTradeList() {
  3811. br := new(models.BaseResponse).Init()
  3812. defer func() {
  3813. this.Data["json"] = br
  3814. this.ServeJSON()
  3815. }()
  3816. user := this.User
  3817. if user == nil {
  3818. br.Msg = "请重新登录"
  3819. br.Ret = 408
  3820. return
  3821. }
  3822. listCategory, err := models.GetCygxZhouqiArticleMapFirst()
  3823. if err != nil {
  3824. br.Msg = "获取信息失败"
  3825. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  3826. return
  3827. }
  3828. resp := new(models.TradeReportMappingResp)
  3829. var list []*models.TradeReportMapping
  3830. if len(listCategory) == 0 {
  3831. list = make([]*models.TradeReportMapping, 0)
  3832. } else {
  3833. for _, v := range listCategory {
  3834. item := new(models.TradeReportMapping)
  3835. item.CategoryId = v.CategoryId
  3836. item.MatchTypeName = v.MatchTypeName
  3837. item.UpdateTime = v.ArticleUpdateTime
  3838. //item.ListArticle = make([]*models.HomeArticle, 0)
  3839. list = append(list, item)
  3840. }
  3841. }
  3842. resp.List = list
  3843. br.Ret = 200
  3844. br.Success = true
  3845. br.Msg = "获取成功"
  3846. br.Data = resp
  3847. }
  3848. // @Title 周期根据行业分类获取行业文章列表
  3849. // @Description 周期根据行业分类获取行业文章列表接口
  3850. // @Param PageSize query int true "每页数据条数"
  3851. // @Param CurrentIndex query int true "当前页页码,从1开始"
  3852. // @Param CategoryId query int true "分类ID"
  3853. // @Success 200 {object} models.TacticsListResp
  3854. // @router /tactics/zhouqi_list [get]
  3855. func (this *ReportController) ZhouqiTacticsList() {
  3856. br := new(models.BaseResponse).Init()
  3857. defer func() {
  3858. this.Data["json"] = br
  3859. this.ServeJSON()
  3860. }()
  3861. user := this.User
  3862. if user == nil {
  3863. br.Msg = "请重新登录"
  3864. br.Ret = 408
  3865. return
  3866. }
  3867. //uid := user.UserId
  3868. pageSize, _ := this.GetInt("PageSize")
  3869. currentIndex, _ := this.GetInt("CurrentIndex")
  3870. categoryId, _ := this.GetInt("CategoryId")
  3871. var startSize int
  3872. if pageSize <= 0 {
  3873. pageSize = utils.PageSize20
  3874. }
  3875. if currentIndex <= 0 {
  3876. currentIndex = 1
  3877. }
  3878. startSize = paging.StartIndex(currentIndex, pageSize)
  3879. var total int
  3880. var err error
  3881. resp := new(models.TacticsListZhouqiResp)
  3882. page := paging.GetPaging(currentIndex, pageSize, total)
  3883. list := make([]*models.HomeArticle, 0)
  3884. listCategory, err := models.GetCygxZhouqiArticleMapByParentId(categoryId)
  3885. if err != nil {
  3886. br.Msg = "获取信息失败"
  3887. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  3888. return
  3889. }
  3890. var matchTypeName = []string{}
  3891. var seriesName = []string{}
  3892. for _, v := range listCategory {
  3893. if v.MatchTypeName != "" {
  3894. matchTypeName = append(matchTypeName, v.MatchTypeName)
  3895. }
  3896. if v.SeriesName != "" {
  3897. seriesName = append(seriesName, v.SeriesName)
  3898. }
  3899. }
  3900. var condition string
  3901. //var pars []interface{}
  3902. if len(seriesName) == 0 {
  3903. condition = " AND field_name IN ('" + strings.Join(matchTypeName, "','") + "')"
  3904. } else {
  3905. condition = " AND ( field_name IN ('" + strings.Join(matchTypeName, "','") + "') OR series_name IN ('" + strings.Join(seriesName, "','") + "') )"
  3906. }
  3907. list, total, err = models.GetReportAndproductIndustrylListimgZhouqi(condition, startSize, pageSize)
  3908. if err != nil {
  3909. br.Msg = "获取信息失败"
  3910. br.Msg = "GetReportAndproductIndustrylListimgZhouqi,Err:" + err.Error()
  3911. return
  3912. }
  3913. listPublic, err := services.HandleArticleCategoryImg(list)
  3914. if err != nil {
  3915. br.Msg = "获取失败"
  3916. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  3917. return
  3918. }
  3919. var articleIds []int
  3920. for _, v := range listPublic {
  3921. if v.Resource == 1 {
  3922. articleIds = append(articleIds, v.ArticleId)
  3923. }
  3924. }
  3925. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  3926. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  3927. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  3928. listResp := make([]*models.HomeArticle, 0)
  3929. for _, v := range listPublic {
  3930. item := new(models.HomeArticle)
  3931. item.ArticleId = v.ArticleId
  3932. item.ReportId = v.ReportId
  3933. item.Title = v.Title
  3934. item.Annotation = v.Annotation
  3935. item.Abstract = v.Abstract
  3936. item.ImgUrlPc = v.ImgUrlPc
  3937. item.PublishDate = v.PublishDate
  3938. item.Resource = v.Resource
  3939. if v.Resource == 1 {
  3940. item.Pv = articleMapPv[v.ArticleId]
  3941. item.IsCollect = articleCollectMap[v.ArticleId]
  3942. item.CollectNum = articleCollectNumMap[v.ArticleId]
  3943. }
  3944. if v.ReportId > 0 {
  3945. item.Resource = 3
  3946. }
  3947. listResp = append(listResp, item)
  3948. }
  3949. if len(listResp) == 0 {
  3950. listResp = make([]*models.HomeArticle, 0)
  3951. }
  3952. page = paging.GetPaging(currentIndex, pageSize, total)
  3953. resp.List = listResp
  3954. resp.Paging = page
  3955. br.Ret = 200
  3956. br.Success = true
  3957. br.Msg = "获取成功"
  3958. br.Data = resp
  3959. }