report.go 131 KB

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