report.go 148 KB

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