report.go 148 KB

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