report.go 148 KB

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