report.go 147 KB

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