report.go 148 KB

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