report.go 84 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "hongze/hongze_cygx/models"
  7. "hongze/hongze_cygx/services"
  8. "hongze/hongze_cygx/utils"
  9. "html"
  10. "strconv"
  11. "strings"
  12. "time"
  13. )
  14. //报告
  15. type ReportController struct {
  16. BaseAuthController
  17. }
  18. type ReportCommonController struct {
  19. BaseCommonController
  20. }
  21. // @Title 行业报告分类列表接口
  22. // @Description 获取行业报告分类列表接口
  23. // @Param ChartPermissionId query int true "分类ID"
  24. // @Success 200 {object} models.IndustrialManagementList
  25. // @router /home/tradeList [get]
  26. func (this *ReportController) TradeList() {
  27. br := new(models.BaseResponse).Init()
  28. defer func() {
  29. this.Data["json"] = br
  30. this.ServeJSON()
  31. }()
  32. user := this.User
  33. if user == nil {
  34. br.Msg = "请重新登录"
  35. br.Ret = 408
  36. return
  37. }
  38. uid := user.UserId
  39. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  40. if ChartPermissionId < 1 {
  41. br.Msg = "请输入分类ID"
  42. return
  43. }
  44. list, err := models.GetTradeAll(ChartPermissionId)
  45. if err != nil {
  46. br.Msg = "获取信息失败"
  47. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  48. return
  49. }
  50. for k, v := range list {
  51. list[k].UpdateTime = utils.TimeRemoveHms(v.UpdateTime)
  52. count, err := models.CheckThisCategoryNewArticleIsRead(uid, v.CategoryId)
  53. if err != nil {
  54. br.Msg = "获取信息失败"
  55. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  56. return
  57. }
  58. if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
  59. list[k].IsRed = true
  60. }
  61. }
  62. resp := new(models.TradeReportMappingResp)
  63. resp.List = list
  64. br.Ret = 200
  65. br.Success = true
  66. br.Msg = "获取成功"
  67. br.Data = resp
  68. }
  69. // @Title 产业报告分类列表接口
  70. // @Description 获取产业报告分类列表接口
  71. // @Param ChartPermissionId query int true "分类ID"
  72. // @Param IsNewLabel query string true "是否属于新标签,1是,0否"
  73. // @Param IsDeepLabel query string true "是否属于深标签,1是,0否"
  74. // @Param KeyWord query string true "搜索关键词"
  75. // @Param OrderColumn query int true "排序字段 ,NewTime 最近更新 ,Recommend弘则推荐"
  76. // @Param DeepCover query int false "深度覆盖:0-否;1-是"
  77. // @Param RecommendFocus query int false "推荐关注:0-否;1-是"
  78. // @Param PageSize query int true "每页数据条数"
  79. // @Param CurrentIndex query int true "当前页页码,从1开始"
  80. // @Success 200 {object} models.IndustrialManagementList
  81. // @router /home/industryList [get]
  82. func (this *ReportController) IndustryList() {
  83. br := new(models.BaseResponse).Init()
  84. defer func() {
  85. this.Data["json"] = br
  86. this.ServeJSON()
  87. }()
  88. user := this.User
  89. if user == nil {
  90. br.Msg = "请重新登录"
  91. br.Ret = 408
  92. return
  93. }
  94. uid := user.UserId
  95. fmt.Println(uid)
  96. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  97. orderColumn := this.GetString("OrderColumn")
  98. orderColumnNew := this.GetString("OrderColumn")
  99. isNewLabel := this.GetString("IsNewLabel")
  100. isDeepLabel := this.GetString("IsDeepLabel")
  101. keyWord := this.GetString("KeyWord")
  102. pageSize, _ := this.GetInt("PageSize")
  103. currentIndex, _ := this.GetInt("CurrentIndex")
  104. deepCover, _ := this.GetInt("DeepCover")
  105. recommendFocus, _ := this.GetInt("RecommendFocus")
  106. var orderSrt string
  107. var condition string
  108. var startSize int
  109. resp := new(models.IndustrialManagementList)
  110. if pageSize <= 0 {
  111. pageSize = utils.PageSize20
  112. }
  113. if currentIndex <= 0 {
  114. currentIndex = 1
  115. }
  116. startSize = paging.StartIndex(currentIndex, pageSize)
  117. if isNewLabel == "1" {
  118. condition += ` AND is_new_label = ` + isNewLabel
  119. }
  120. if isDeepLabel == "1" {
  121. condition += ` AND is_deep_label = ` + isDeepLabel
  122. }
  123. if keyWord != "" {
  124. //keyWordArr, err := services.GetIndustryMapNameSliceV2(keyWord)
  125. //if err != nil {
  126. // br.Msg = "获取信息失败"
  127. // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  128. // return
  129. //}
  130. //var conditionkeyWord string
  131. //conditionkeyWord += ` subject_names LIKE '%` + keyWord + `%'`
  132. //keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
  133. //keyWordLen := len(keyWordArr)
  134. //if keyWordLen <= 0 {
  135. // keyWordArr = append(keyWordArr, keyWord)
  136. // keyWordLen = len(keyWordArr)
  137. //}
  138. //for _, v := range keyWordArr {
  139. // conditionkeyWord += ` OR subject_names LIKE '%` + v + `%'`
  140. //}
  141. //industrialManagementIds, err := models.GetIndustrialManagementIdsBykeyWord(conditionkeyWord)
  142. //if err != nil {
  143. // br.Msg = "获取信息失败"
  144. // br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  145. // return
  146. //}
  147. //if industrialManagementIds == "" {
  148. // br.Ret = 200
  149. // br.Success = true
  150. // br.Msg = "获取成功"
  151. // br.Data = resp
  152. // return
  153. //}
  154. //condition += ` AND man.industrial_management_id IN (` + industrialManagementIds + `)`
  155. condition += ` AND subject_names LIKE '%` + keyWord + `%'`
  156. }
  157. var sqlChartPermissionId string
  158. if ChartPermissionId > 0 {
  159. sqlChartPermissionId += ` AND man_g.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE chart_permission_id = ` + strconv.Itoa(ChartPermissionId) + ` ) `
  160. condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
  161. }
  162. // 深度覆盖
  163. if deepCover == 1 {
  164. // 查询深标签产业报告数
  165. var deepCondition string
  166. var deepPars []interface{}
  167. deepCondition += ` AND man.is_deep_label = 1`
  168. if ChartPermissionId > 0 {
  169. deepCondition += ` AND man.chart_permission_id = ?`
  170. deepPars = append(deepPars, ChartPermissionId)
  171. }
  172. industryCountList, e := models.GetIndustryArtCountByCondition(deepCondition, deepPars)
  173. if e != nil {
  174. br.Msg = "获取信息失败"
  175. br.ErrMsg = "获取深标签产业报告数失败, Err: " + e.Error()
  176. return
  177. }
  178. deepIdArr := make([]string, 0)
  179. for i := range industryCountList {
  180. if industryCountList[i].ArtNum > 10 {
  181. deepIdArr = append(deepIdArr, strconv.Itoa(industryCountList[i].IndustrialManagementId))
  182. }
  183. }
  184. deepIds := strings.Join(deepIdArr, ",")
  185. if deepIds != "" {
  186. condition = `AND man.industrial_management_id IN (` + deepIds + `)`
  187. }
  188. }
  189. // 推荐关注
  190. if recommendFocus == 1 {
  191. condition += ` AND man.recommended_index >= 80`
  192. }
  193. // 列表总数据量
  194. var list []*models.IndustrialManagement
  195. total, err := models.GetIndustrialManagementAllCount(condition)
  196. if err != nil {
  197. br.Msg = "获取信息失败"
  198. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  199. return
  200. }
  201. page := paging.GetPaging(currentIndex, pageSize, total)
  202. if orderColumn == "" {
  203. orderColumn = "NewTime"
  204. }
  205. if orderColumn == "NewTime" {
  206. orderSrt = "update_time DESC"
  207. } else {
  208. orderSrt = "man.recommended_index DESC,update_time DESC"
  209. }
  210. if ChartPermissionId == 0 {
  211. ChartPermissionId = 20
  212. }
  213. // 阅读第三的产业详情
  214. //detailHot3, err := models.GetIndustrialManagementHot3(ChartPermissionId)
  215. //if err != nil {
  216. // br.Msg = "获取信息失败"
  217. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  218. // return
  219. //}
  220. list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize)
  221. if err != nil {
  222. br.Msg = "获取信息失败"
  223. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  224. return
  225. }
  226. // 获取近一个月产业报告阅读次数最多的产业
  227. var topCond string
  228. var topPars []interface{}
  229. topReadIndustryId := 0
  230. if ChartPermissionId > 0 {
  231. topCond += ` AND chart_permission_id = ?`
  232. topPars = append(topPars, ChartPermissionId)
  233. }
  234. topReadIndustry, e := models.GetTopOneMonthArtReadNumIndustry(topCond, topPars)
  235. if e != nil && e.Error() != utils.ErrNoRow() {
  236. br.Msg = "获取信息失败"
  237. br.ErrMsg = "获取近一个月报告阅读次数最多的产业失败, Err: " + e.Error()
  238. return
  239. }
  240. if topReadIndustry != nil {
  241. topReadIndustryId = topReadIndustry.IndustrialManagementId
  242. }
  243. nowTime := time.Now().Local()
  244. threeMonBefore := nowTime.AddDate(0, -3, 0)
  245. for k, v := range list {
  246. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  247. if err != nil {
  248. br.Msg = "获取信息失败"
  249. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  250. return
  251. }
  252. list[k].IndustrialSubjectList = industrialSubjectList
  253. list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  254. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  255. if err != nil {
  256. br.Msg = "获取信息失败"
  257. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  258. return
  259. }
  260. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  261. recordCount, err := models.GetUserToArticleCount(uid, newArtinfo.ArticleId)
  262. if err != nil && err.Error() != utils.ErrNoRow() {
  263. br.Msg = "获取信息失败"
  264. br.ErrMsg = "获取信息失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(newArtinfo.ArticleId)
  265. return
  266. }
  267. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(newArtinfo.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(newArtinfo.PublishDate)) {
  268. list[k].IsRed = true
  269. }
  270. // 原:关联的报告阅读量大于等于阅读第三的产业,则标记热门
  271. //if v.ArticleReadNum >= detailHot3.ArticleReadNum {
  272. // list[k].IsHot = true
  273. //}
  274. // 近一个月报告阅读次数最多的产业标记Hot
  275. if topReadIndustryId > 0 && list[k].IndustrialManagementId == topReadIndustryId {
  276. list[k].IsHot = true
  277. }
  278. // 关联报告发布时间均在3个月内则标记New
  279. if v.MinReportTime != "" {
  280. t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  281. if e != nil {
  282. br.Msg = "获取信息失败"
  283. br.ErrMsg = "报告最早发布时间有误, Err: " + e.Error()
  284. return
  285. }
  286. if t.After(threeMonBefore) {
  287. list[k].IsNew = true
  288. }
  289. }
  290. }
  291. //记录用户搜索的筛选条件
  292. if orderColumnNew != "" {
  293. item := new(models.CygxReportIndustrialSeaarchHistory)
  294. item.UserId = user.UserId
  295. item.Mobile = user.Mobile
  296. item.CompanyId = user.CompanyId
  297. item.CompanyName = user.CompanyName
  298. item.CreateTime = time.Now()
  299. item.IsDeepLabel = isDeepLabel
  300. item.IsNewLabel = isNewLabel
  301. item.ChartPermissionId = ChartPermissionId
  302. if orderColumnNew == "NewTime" {
  303. item.OrderColumn = "0"
  304. } else {
  305. item.OrderColumn = "1"
  306. }
  307. go models.AddCygxReportIndustrialSeaarchHistory(item)
  308. }
  309. resp.List = list
  310. resp.Paging = page
  311. br.Ret = 200
  312. br.Success = true
  313. br.Msg = "获取成功"
  314. br.Data = resp
  315. }
  316. // @Title 产业下所关联的文章分类列表
  317. // @Description 产业下所关联的文章分类列表接口
  318. // @Param IndustrialManagementId query int true "产业ID"
  319. // @Success 200 {object} models.IndustrialToArticleCategoryListRep
  320. // @router /toArticleCategoryList [get]
  321. func (this *ReportController) ArticleCategoryList() {
  322. br := new(models.BaseResponse).Init()
  323. defer func() {
  324. this.Data["json"] = br
  325. this.ServeJSON()
  326. }()
  327. user := this.User
  328. if user == nil {
  329. br.Msg = "请重新登录"
  330. br.Ret = 408
  331. return
  332. }
  333. uid := user.UserId
  334. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  335. if industrialManagementId < 1 {
  336. br.Msg = "请输入分类ID"
  337. return
  338. }
  339. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  340. if err != nil {
  341. br.Msg = "获取信息失败"
  342. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  343. return
  344. }
  345. list, err := models.IndustrialToArticleCategoryNew(industrialManagementId)
  346. if err != nil {
  347. br.Msg = "获取信息失败"
  348. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  349. return
  350. }
  351. for k, v := range list {
  352. recordCount, err := models.IndustrialUserRecordArticleCount(uid, industrialManagementId, v.CategoryId)
  353. if err != nil && err.Error() != utils.ErrNoRow() {
  354. br.Msg = "获取信息失败"
  355. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  356. return
  357. }
  358. Newdetail, err := models.GetNewIndustrialUserRecordArticle(industrialManagementId, v.CategoryId)
  359. if err != nil {
  360. br.Msg = "获取信息失败"
  361. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  362. return
  363. }
  364. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
  365. list[k].IsRed = true
  366. }
  367. }
  368. //detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  369. //if err != nil {
  370. // br.Msg = "获取信息失败"
  371. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  372. // return
  373. //}
  374. resp := new(models.IndustrialToArticleCategoryListRep)
  375. resp.List = list
  376. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  377. resp.IndustryName = detail.IndustryName
  378. resp.IndustrialManagementId = industrialManagementId
  379. br.Ret = 200
  380. br.Success = true
  381. br.Msg = "获取成功"
  382. br.Data = resp
  383. }
  384. // @Title 产业文章列表接口
  385. // @Description 获取产业文章列表接口
  386. // @Param PageSize query int true "每页数据条数"
  387. // @Param CurrentIndex query int true "当前页页码,从1开始"
  388. // @Param CategoryId query int true "分类ID"
  389. // @Param IndustrialManagementId query int true "产业ID"
  390. // @Success 200 {object} models.TacticsListResp
  391. // @router /industry/ArticleList [get]
  392. func (this *ReportController) List() {
  393. br := new(models.BaseResponse).Init()
  394. defer func() {
  395. this.Data["json"] = br
  396. this.ServeJSON()
  397. }()
  398. user := this.User
  399. if user == nil {
  400. br.Msg = "请重新登录"
  401. br.Ret = 408
  402. return
  403. }
  404. uid := user.UserId
  405. pageSize, _ := this.GetInt("PageSize")
  406. currentIndex, _ := this.GetInt("CurrentIndex")
  407. categoryId, _ := this.GetInt("CategoryId")
  408. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  409. var startSize int
  410. if pageSize <= 0 {
  411. pageSize = utils.PageSize20
  412. }
  413. if currentIndex <= 0 {
  414. currentIndex = 1
  415. }
  416. startSize = paging.StartIndex(currentIndex, pageSize)
  417. var pars []interface{}
  418. var total int
  419. resp := new(models.TacticsListResp)
  420. page := paging.GetPaging(currentIndex, pageSize, total)
  421. if categoryId < 1 {
  422. br.Msg = "请输入分类ID"
  423. return
  424. }
  425. if industrialManagementId < 1 {
  426. br.Msg = "请输入产业ID"
  427. return
  428. }
  429. //获取该产业下所对应的行业图片
  430. detail, errCategory := models.GetdetailByCategoryIdOne(categoryId)
  431. if errCategory != nil {
  432. br.Msg = "获取信息失败"
  433. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  434. return
  435. }
  436. //对应行业的图片
  437. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  438. if err != nil {
  439. br.Msg = "获取数据失败"
  440. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  441. return
  442. }
  443. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  444. mapChartPermission := make(map[string]string)
  445. var permissionName string
  446. var imgUrlChartPermission string
  447. for _, v := range chartPermissionUrlList {
  448. vslice := strings.Split(v, "_")
  449. permissionName = vslice[0]
  450. imgUrlChartPermission = vslice[len(vslice)-1]
  451. mapChartPermission[permissionName] = imgUrlChartPermission
  452. }
  453. total, err = models.GetReportIndustrialCount(categoryId, industrialManagementId)
  454. if err != nil {
  455. br.Msg = "获取信息失败"
  456. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  457. return
  458. }
  459. page = paging.GetPaging(currentIndex, pageSize, total)
  460. list, err := models.GetReportIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
  461. if err != nil {
  462. br.Msg = "获取信息失败"
  463. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  464. return
  465. }
  466. //对应分类的所图片
  467. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  468. if err != nil {
  469. br.Msg = "获取数据失败"
  470. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  471. return
  472. }
  473. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  474. mapCategoryUrl := make(map[string]string)
  475. var categoryIdStr string
  476. var imgUrlChart string
  477. for _, v := range categoryUrlList {
  478. vslice := strings.Split(v, "_")
  479. categoryIdStr = vslice[0]
  480. imgUrlChart = vslice[len(vslice)-1]
  481. mapCategoryUrl[categoryIdStr] = imgUrlChart
  482. }
  483. lenList := len(list)
  484. for i := 0; i < lenList; i++ {
  485. item := list[i]
  486. list[i].Body, _ = services.GetReportContentTextSub(item.Body)
  487. //list[i].Abstract = html.UnescapeString(item.Abstract)
  488. list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  489. }
  490. for k, v := range list {
  491. if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  492. list[k].IsRed = true
  493. }
  494. if v.VideoUrl != "" {
  495. list[k].IsHaveVideo = true
  496. }
  497. list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  498. if mapCategoryUrl[v.CategoryId] == "" {
  499. if detail.ChartPermissionId == utils.YI_YAO_ID {
  500. list[k].ImgUrlPc = utils.YI_YAO_QI_TA
  501. }
  502. }
  503. }
  504. resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  505. resp.ChartPermissionId = detail.ChartPermissionId
  506. resp.List = list
  507. resp.Paging = page
  508. br.Ret = 200
  509. br.Success = true
  510. br.Msg = "获取成功"
  511. br.Data = resp
  512. }
  513. // @Title 置顶/取消置顶
  514. // @Description 置顶
  515. // @Param request body models.CygxIndustryTopRep true "type json string"
  516. // @Success 200
  517. // @router /top [post]
  518. func (this *ReportController) ArticleCollect() {
  519. br := new(models.BaseResponse).Init()
  520. defer func() {
  521. this.Data["json"] = br
  522. this.ServeJSON()
  523. }()
  524. user := this.User
  525. if user == nil {
  526. br.Msg = "请重新登录"
  527. br.Ret = 408
  528. return
  529. }
  530. uid := user.UserId
  531. var req models.CygxIndustryTopRep
  532. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  533. if err != nil {
  534. br.Msg = "参数解析异常!"
  535. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  536. return
  537. }
  538. industrialManagementId := req.IndustrialManagementId
  539. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  540. if err != nil {
  541. br.Msg = "获取数据失败!"
  542. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  543. return
  544. }
  545. if countIndustrial == 0 {
  546. br.Msg = "产业不存在!"
  547. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  548. return
  549. }
  550. count, err := models.GetCygxIndustryTop(uid, industrialManagementId)
  551. if err != nil {
  552. br.Msg = "获取数据失败!"
  553. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  554. return
  555. }
  556. resp := new(models.ArticleCollectResp)
  557. if count <= 0 {
  558. item := new(models.CygxIndustryTop)
  559. item.IndustrialManagementId = req.IndustrialManagementId
  560. item.UserId = uid
  561. item.CreateTime = time.Now()
  562. _, err = models.AddCygxIndustryTop(item)
  563. if err != nil {
  564. br.Msg = "置顶失败"
  565. br.ErrMsg = "置顶失败,Err:" + err.Error()
  566. return
  567. }
  568. br.Msg = "置顶成功"
  569. resp.Status = 1
  570. } else {
  571. err = models.RemoveCygxIndustryTop(uid, industrialManagementId)
  572. if err != nil {
  573. br.Msg = "取消置顶失败"
  574. br.ErrMsg = "取消置顶失败,Err:" + err.Error()
  575. return
  576. }
  577. br.Msg = "已取消置顶"
  578. resp.Status = 2
  579. }
  580. br.Ret = 200
  581. br.Success = true
  582. br.Data = resp
  583. }
  584. // @Title 关注/取消关注产业
  585. // @Description 关注/取消关注 接口
  586. // @Param request body models.CygxIndustryFllowRep true "type json string"
  587. // @Success 200
  588. // @router /fllow [post]
  589. func (this *ReportController) Fllow() {
  590. br := new(models.BaseResponse).Init()
  591. defer func() {
  592. this.Data["json"] = br
  593. this.ServeJSON()
  594. }()
  595. user := this.User
  596. if user == nil {
  597. br.Msg = "请重新登录"
  598. br.Ret = 408
  599. return
  600. }
  601. uid := user.UserId
  602. var req models.CygxIndustryFllowRep
  603. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  604. if err != nil {
  605. br.Msg = "参数解析异常!"
  606. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  607. return
  608. }
  609. industrialManagementId := req.IndustrialManagementId
  610. var condition string
  611. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  612. if err != nil {
  613. br.Msg = "获取数据失败!"
  614. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  615. return
  616. }
  617. if countIndustrial == 0 {
  618. br.Msg = "产业不存在!"
  619. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  620. return
  621. }
  622. count, err := models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
  623. if err != nil {
  624. br.Msg = "获取数据失败!"
  625. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  626. return
  627. }
  628. resp := new(models.CygxIndustryFllowResp)
  629. countUser, err := models.GetCountCygxIndustryFllowByUid(uid)
  630. if countUser == 0 {
  631. resp.GoFollow = true
  632. }
  633. if count == 0 {
  634. item := new(models.CygxIndustryFllow)
  635. item.IndustrialManagementId = industrialManagementId
  636. item.UserId = uid
  637. item.Email = user.Email
  638. item.Mobile = user.Mobile
  639. item.RealName = user.RealName
  640. item.CompanyId = user.CompanyId
  641. item.CompanyName = user.CompanyName
  642. item.Type = 1
  643. item.CreateTime = time.Now()
  644. item.ModifyTime = time.Now()
  645. _, err = models.AddCygxIndustryFllow(item)
  646. if err != nil {
  647. br.Msg = "操作失败"
  648. br.ErrMsg = "操作失败,Err:" + err.Error()
  649. return
  650. }
  651. resp.Status = 1
  652. } else {
  653. err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
  654. if err != nil {
  655. br.Msg = "操作失败"
  656. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  657. return
  658. }
  659. }
  660. //处理是否关注全部赛道字段
  661. go services.IndustryFllowWithTrack(industrialManagementId, count, uid)
  662. br.Msg = "操作成功"
  663. br.Ret = 200
  664. br.Success = true
  665. br.Data = resp
  666. }
  667. // @Title 产业报告分类关联作者列表接口
  668. // @Description 获取产业报告分类关联作者列表接口
  669. // @Param ChartPermissionId query int true "分类ID"
  670. // @Param PageSize query int true "每页数据条数"
  671. // @Param CurrentIndex query int true "当前页页码,从1开始"
  672. // @Success 200 {object} models.CygxArticleDepartmentList
  673. // @router /industryListByDepartment [get]
  674. func (this *ReportController) IndustryListByDepartment() {
  675. br := new(models.BaseResponse).Init()
  676. defer func() {
  677. this.Data["json"] = br
  678. this.ServeJSON()
  679. }()
  680. user := this.User
  681. if user == nil {
  682. br.Msg = "请重新登录"
  683. br.Ret = 408
  684. return
  685. }
  686. uid := user.UserId
  687. pageSize, _ := this.GetInt("PageSize")
  688. currentIndex, _ := this.GetInt("CurrentIndex")
  689. //chartPermissionId, _ := this.GetInt("ChartPermissionId")
  690. var startSize int
  691. var condition string
  692. //condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  693. condition = ` AND a.publish_status=1 `
  694. if pageSize <= 0 {
  695. pageSize = utils.PageSize20
  696. }
  697. if currentIndex <= 0 {
  698. currentIndex = 1
  699. }
  700. startSize = paging.StartIndex(currentIndex, pageSize)
  701. total, err := models.GetArticleDepartmentCount(condition)
  702. page := paging.GetPaging(currentIndex, pageSize, total)
  703. resp := new(models.CygxArticleDepartmentList)
  704. userType, _, err := services.GetUserType(user.CompanyId)
  705. if err != nil {
  706. br.Msg = "获取信息失败"
  707. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  708. return
  709. }
  710. if userType == 1 {
  711. resp.Paging = page
  712. br.Ret = 200
  713. br.Success = true
  714. br.Msg = "获取成功"
  715. br.Data = resp
  716. return
  717. }
  718. resp.HaveResearch = true
  719. //获取作者信息,并排序
  720. list, err := models.GetCygxArticleDepartmentList(startSize, pageSize, condition, uid)
  721. if err != nil {
  722. br.Msg = "获取信息失败"
  723. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  724. return
  725. }
  726. for k, v := range list {
  727. artList, err := models.GetArticleByDepartmentId(v.DepartmentId)
  728. if err != nil {
  729. br.Msg = "获取信息失败"
  730. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  731. return
  732. }
  733. for k2, v2 := range artList {
  734. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  735. if err != nil {
  736. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  737. br.ErrMsg = "获取失败,Err:" + err.Error()
  738. return
  739. }
  740. var subjectNamesNew string
  741. if len(subjectNames) > 0 {
  742. slice := strings.Split(subjectNames, "/")
  743. for k3, v3 := range slice {
  744. if k3 < 4 {
  745. subjectNamesNew += v3 + "/"
  746. }
  747. }
  748. }
  749. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  750. if err != nil && err.Error() != utils.ErrNoRow() {
  751. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  752. br.ErrMsg = "获取失败,Err:" + err.Error()
  753. return
  754. }
  755. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  756. artList[k2].SubjectName = subjectNamesNew
  757. artList[k2].DepartmentId = v.DepartmentId
  758. if subjectNamesNew == "" {
  759. artList[k2].IndustryName = industryName
  760. } else {
  761. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  762. }
  763. if artList[k2].IsReport == "1" {
  764. artList[k2].IndustryName = "【观点】" + artList[k2].IndustryName
  765. } else {
  766. artList[k2].IndustryName = "【纪要】" + artList[k2].IndustryName
  767. }
  768. }
  769. list[k].List = artList
  770. if v.FollowNum > 0 {
  771. list[k].IsMyFollow = true
  772. }
  773. }
  774. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  775. if err != nil {
  776. br.Msg = "获取信息失败"
  777. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  778. return
  779. }
  780. if len(listnNew) > 0 {
  781. for _, v := range listnNew {
  782. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  783. Management := new(models.IndustrialManagementIdInt)
  784. if firstStr == 0 {
  785. Management.IndustryName = v.IndustryName
  786. } else {
  787. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  788. if err != nil {
  789. br.Msg = "获取信息失败"
  790. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  791. return
  792. }
  793. var subjectNamesNew string
  794. for _, v1 := range listSub {
  795. subjectNamesNew += v1.SubjectName + "/"
  796. }
  797. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  798. Management.IndustryName = subjectNamesNew
  799. }
  800. Management.IndustrialManagementId = v.IndustrialManagementId
  801. Management.ArticleId = v.ArticleId
  802. resp.ListnNew = append(resp.ListnNew, Management)
  803. }
  804. }
  805. resp.List = list
  806. resp.Paging = page
  807. br.Ret = 200
  808. br.Success = true
  809. br.Msg = "获取成功"
  810. br.Data = resp
  811. }
  812. // @Title 关注作者/取消关注作者
  813. // @Description 关注作者/取消关注作者 接口
  814. // @Param request body models.CygxArticleDepartmentId true "type json string"
  815. // @Success 200
  816. // @router /fllowDepartment [post]
  817. func (this *ReportController) FllowDepartment() {
  818. br := new(models.BaseResponse).Init()
  819. defer func() {
  820. this.Data["json"] = br
  821. this.ServeJSON()
  822. }()
  823. user := this.User
  824. if user == nil {
  825. br.Msg = "请重新登录"
  826. br.Ret = 408
  827. return
  828. }
  829. uid := user.UserId
  830. var req models.CygxArticleDepartmentId
  831. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  832. if err != nil {
  833. br.Msg = "参数解析异常!"
  834. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  835. return
  836. }
  837. departmentId := req.DepartmentId
  838. var condition string
  839. countDepartment, err := models.GetDepartmentCount(departmentId)
  840. if err != nil {
  841. br.Msg = "获取数据失败!"
  842. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  843. return
  844. }
  845. if countDepartment == 0 {
  846. br.Msg = "作者不存在!"
  847. br.ErrMsg = "作者ID不存在:" + strconv.Itoa(departmentId)
  848. return
  849. }
  850. countUser, err := models.GetArticleDepartmentFollowByUid(uid)
  851. count, err := models.GetArticleDepartmentFollow(uid, departmentId, condition)
  852. if err != nil {
  853. br.Msg = "获取数据失败!"
  854. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  855. return
  856. }
  857. resp := new(models.CygxArticleDepartmentFollowResp)
  858. if countUser == 0 {
  859. resp.GoFollow = true
  860. }
  861. if count == 0 {
  862. item := new(models.CygxArticleDepartmentFollow)
  863. item.DepartmentId = departmentId
  864. item.UserId = uid
  865. item.Email = user.Email
  866. item.Mobile = user.Mobile
  867. item.RealName = user.RealName
  868. item.CompanyId = user.CompanyId
  869. item.CompanyName = user.CompanyName
  870. item.Type = 1
  871. item.CreateTime = time.Now()
  872. item.ModifyTime = time.Now()
  873. _, err = models.AddArticleDepartmentFollow(item)
  874. if err != nil {
  875. br.Msg = "操作失败"
  876. br.ErrMsg = "操作失败,Err:" + err.Error()
  877. return
  878. }
  879. resp.Status = 1
  880. } else {
  881. var doType int
  882. condition = ` AND type = 1`
  883. count, err = models.GetArticleDepartmentFollow(uid, departmentId, condition)
  884. if err != nil {
  885. br.Msg = "操作失败!"
  886. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  887. return
  888. }
  889. if count == 1 {
  890. resp.Status = 2
  891. doType = 2
  892. } else {
  893. resp.Status = 1
  894. doType = 1
  895. }
  896. err = models.RemoveArticleDepartmentFollow(uid, departmentId, doType)
  897. if err != nil {
  898. br.Msg = "操作失败"
  899. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  900. return
  901. }
  902. }
  903. br.Msg = "操作成功"
  904. br.Ret = 200
  905. br.Success = true
  906. br.Data = resp
  907. }
  908. // @Title 研选文章列表接口
  909. // @Description 获取研选文章列表接口
  910. // @Param PageSize query int true "每页数据条数"
  911. // @Param CurrentIndex query int true "当前页页码,从1开始"
  912. // @Param ArticleId query int true "文章id"
  913. // @Param DepartmentId query int true "作者ID"
  914. // @Param IndustrialManagementId query int true "产业ID"
  915. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  916. // @router /industry/reportList [get]
  917. func (this *ReportController) ReportList() {
  918. br := new(models.BaseResponse).Init()
  919. defer func() {
  920. this.Data["json"] = br
  921. this.ServeJSON()
  922. }()
  923. user := this.User
  924. if user == nil {
  925. br.Msg = "请重新登录"
  926. br.Ret = 408
  927. return
  928. }
  929. uid := user.UserId
  930. pageSize, _ := this.GetInt("PageSize")
  931. currentIndex, _ := this.GetInt("CurrentIndex")
  932. departmentId, _ := this.GetInt("DepartmentId")
  933. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  934. articleId, _ := this.GetInt("ArticleId")
  935. var condition string
  936. var startSize int
  937. if pageSize <= 0 {
  938. pageSize = utils.PageSize20
  939. }
  940. if currentIndex <= 0 {
  941. currentIndex = 1
  942. }
  943. startSize = paging.StartIndex(currentIndex, pageSize)
  944. var pars []interface{}
  945. var total int
  946. resp := new(models.ReportArticleWhichIndustrialRepList)
  947. page := paging.GetPaging(currentIndex, pageSize, total)
  948. userType, _, err := services.GetUserType(user.CompanyId)
  949. if err != nil {
  950. br.Msg = "获取信息失败"
  951. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  952. return
  953. }
  954. if userType == 1 {
  955. resp.Paging = page
  956. br.Ret = 200
  957. br.Success = true
  958. br.Msg = "获取成功"
  959. br.Data = resp
  960. return
  961. }
  962. resp.HaveResearch = true
  963. if departmentId > 0 {
  964. condition += ` AND art.department_id = ` + strconv.Itoa(departmentId)
  965. detail, err := models.GetArticleDepartmentDateilById(departmentId)
  966. if err != nil {
  967. br.Msg = "获取信息失败"
  968. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  969. return
  970. }
  971. resp.NickName = detail.NickName
  972. }
  973. if industrialManagementId > 0 {
  974. condition += ` AND m.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
  975. }
  976. if articleId > 0 {
  977. detail, err := models.GetArticleDetailById(articleId)
  978. if err != nil {
  979. br.Msg = "获取信息失败"
  980. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  981. return
  982. }
  983. condition += ` AND art.subject_ids = '` + detail.SubjectIds + `'`
  984. }
  985. total, err = models.GetWhichDepartmentCount(condition)
  986. if err != nil {
  987. br.Msg = "获取信息失败"
  988. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  989. return
  990. }
  991. page = paging.GetPaging(currentIndex, pageSize, total)
  992. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  993. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  994. if err != nil {
  995. br.Msg = "获取失败"
  996. br.ErrMsg = "获取失败,Err:" + err.Error()
  997. return
  998. }
  999. for k, v := range list {
  1000. if v.Readnum == 0 {
  1001. list[k].IsRed = true
  1002. }
  1003. list[k].IsResearch = true
  1004. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1005. if err != nil {
  1006. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1007. br.ErrMsg = "获取失败,Err:" + err.Error()
  1008. return
  1009. }
  1010. var subjectNamesNew string
  1011. if len(subjectNames) > 0 {
  1012. slice := strings.Split(subjectNames, "/")
  1013. for k3, v3 := range slice {
  1014. if k3 < 4 {
  1015. subjectNamesNew += v3 + "/"
  1016. }
  1017. }
  1018. }
  1019. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1020. if err != nil && err.Error() != utils.ErrNoRow() {
  1021. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1022. br.ErrMsg = "获取失败,Err:" + err.Error()
  1023. return
  1024. }
  1025. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1026. list[k].SubjectName = subjectNamesNew
  1027. if subjectNamesNew != "" {
  1028. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1029. } else {
  1030. list[k].IndustryName = industryName
  1031. }
  1032. resp.IndustryName = industryName
  1033. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1034. }
  1035. resp.List = list
  1036. resp.Paging = page
  1037. br.Ret = 200
  1038. br.Success = true
  1039. br.Msg = "获取成功"
  1040. br.Data = resp
  1041. }
  1042. // @Title 研选最新主题关键词文章列表接口
  1043. // @Description 获取研选最新主题关键词文章列表接口
  1044. // @Param PageSize query int true "每页数据条数"
  1045. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1046. // @Param ArticleId query int true "文章id"
  1047. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  1048. // @router /industry/reportListNew [get]
  1049. func (this *ReportController) ReportListNew() {
  1050. br := new(models.BaseResponse).Init()
  1051. defer func() {
  1052. this.Data["json"] = br
  1053. this.ServeJSON()
  1054. }()
  1055. user := this.User
  1056. if user == nil {
  1057. br.Msg = "请重新登录"
  1058. br.Ret = 408
  1059. return
  1060. }
  1061. uid := user.UserId
  1062. pageSize, _ := this.GetInt("PageSize")
  1063. currentIndex, _ := this.GetInt("CurrentIndex")
  1064. articleId, _ := this.GetInt("ArticleId")
  1065. var condition string
  1066. var startSize int
  1067. if pageSize <= 0 {
  1068. pageSize = utils.PageSize20
  1069. }
  1070. if currentIndex <= 0 {
  1071. currentIndex = 1
  1072. }
  1073. startSize = paging.StartIndex(currentIndex, pageSize)
  1074. var pars []interface{}
  1075. var total int
  1076. resp := new(models.ReportArticleWhichIndustrialRepList)
  1077. page := paging.GetPaging(currentIndex, pageSize, total)
  1078. userType, _, err := services.GetUserType(user.CompanyId)
  1079. if err != nil {
  1080. br.Msg = "获取信息失败"
  1081. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1082. return
  1083. }
  1084. if userType == 1 {
  1085. resp.Paging = page
  1086. br.Ret = 200
  1087. br.Success = true
  1088. br.Msg = "获取成功"
  1089. br.Data = resp
  1090. return
  1091. }
  1092. resp.HaveResearch = true
  1093. if articleId > 0 {
  1094. detail, err := models.GetArticleDetailById(articleId)
  1095. if err != nil {
  1096. br.Msg = "获取信息失败"
  1097. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1098. return
  1099. }
  1100. firstStr := strings.Index(detail.IndustrialAndSubjectIds, "—")
  1101. if firstStr == 0 {
  1102. condition += ` AND art.industrial_management_id = '` + strconv.Itoa(detail.IndustrialManagementId) + `'`
  1103. } else {
  1104. condition += ` AND art.industrial_and_subject_ids = '` + detail.IndustrialAndSubjectIds + `'`
  1105. }
  1106. }
  1107. total, err = models.GetWhichDepartmentCount(condition)
  1108. if err != nil {
  1109. br.Msg = "获取信息失败"
  1110. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1111. return
  1112. }
  1113. page = paging.GetPaging(currentIndex, pageSize, total)
  1114. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  1115. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  1116. if err != nil {
  1117. br.Msg = "获取失败"
  1118. br.ErrMsg = "获取失败,Err:" + err.Error()
  1119. return
  1120. }
  1121. for k, v := range list {
  1122. if v.Readnum == 0 {
  1123. list[k].IsRed = true
  1124. }
  1125. list[k].IsResearch = true
  1126. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1127. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1128. if err != nil {
  1129. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1130. br.ErrMsg = "获取失败,Err:" + err.Error()
  1131. return
  1132. }
  1133. var subjectNamesNew string
  1134. if len(subjectNames) > 0 {
  1135. slice := strings.Split(subjectNames, "/")
  1136. for k3, v3 := range slice {
  1137. if k3 < 4 {
  1138. subjectNamesNew += v3 + "/"
  1139. }
  1140. }
  1141. }
  1142. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1143. if err != nil && err.Error() != utils.ErrNoRow() {
  1144. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1145. br.ErrMsg = "获取失败,Err:" + err.Error()
  1146. return
  1147. }
  1148. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1149. list[k].SubjectName = subjectNamesNew
  1150. if subjectNamesNew != "" {
  1151. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1152. } else {
  1153. list[k].IndustryName = industryName
  1154. }
  1155. resp.IndustryName = industryName
  1156. }
  1157. resp.List = list
  1158. resp.Paging = page
  1159. br.Ret = 200
  1160. br.Success = true
  1161. br.Msg = "获取成功"
  1162. br.Data = resp
  1163. }
  1164. // @Title 是否展示绝密内参
  1165. // @Description 获取是否展示绝密内参接口
  1166. // @Param request body models.IsShow true "type json string"
  1167. // @Success 200
  1168. // @router /isShow [get]
  1169. func (this *ReportController) IsShow() {
  1170. br := new(models.BaseResponse).Init()
  1171. defer func() {
  1172. this.Data["json"] = br
  1173. this.ServeJSON()
  1174. }()
  1175. user := this.User
  1176. if user == nil {
  1177. br.Msg = "请重新登录"
  1178. br.Ret = 408
  1179. return
  1180. }
  1181. var resp models.IsShow
  1182. IsShowFreeButton, err := services.GetfreeButtonIsShow(user)
  1183. if err != nil {
  1184. br.Msg = "获取失败"
  1185. br.ErrMsg = "获取失败,GetfreeButtonIsShow Err:" + err.Error()
  1186. return
  1187. }
  1188. resp.IsShowChart = true
  1189. //resp.IsShowResearch = true
  1190. resp.LinkWxExplain = utils.LINK_WX_EXPLAIN
  1191. resp.ActivitySpecialExplain = utils.ACTIVITY_SPECIAL_EXPLAIN
  1192. //resp.YanXuan_Explain = true
  1193. resp.IsShowFreeButton = IsShowFreeButton
  1194. mobile := user.Mobile
  1195. if mobile == "" {
  1196. br.Ret = 200
  1197. br.Success = true
  1198. br.Data = resp
  1199. return
  1200. }
  1201. total, _ := models.GetUserIsAdminCount(mobile)
  1202. if total > 0 {
  1203. resp.IsShowList = true
  1204. }
  1205. resp.SearchTxtList.SummarySearch = "全局搜索"
  1206. resp.SearchTxtList.ReportSearch = "全局搜索"
  1207. resp.SearchTxtList.YanXuanSearch = "全局搜索"
  1208. resp.SearchTxtList.ActivitySearch = "全局搜索"
  1209. resp.SearchTxtList.TabSearch = "请输入关键词"
  1210. resp.IsShow = true
  1211. br.Ret = 200
  1212. br.Success = true
  1213. br.Data = resp
  1214. }
  1215. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1216. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1217. // @Param PageSize query int true "每页数据条数"
  1218. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1219. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1220. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1221. // @router /reportList/byType [get]
  1222. func (this *ReportController) ReportListByType() {
  1223. br := new(models.BaseResponse).Init()
  1224. defer func() {
  1225. this.Data["json"] = br
  1226. this.ServeJSON()
  1227. }()
  1228. user := this.User
  1229. if user == nil {
  1230. br.Msg = "请重新登录"
  1231. br.Ret = 408
  1232. return
  1233. }
  1234. uid := user.UserId
  1235. pageSize, _ := this.GetInt("PageSize")
  1236. currentIndex, _ := this.GetInt("CurrentIndex")
  1237. reportType := this.GetString("ReportType")
  1238. var condition string
  1239. var startSize int
  1240. if pageSize <= 0 {
  1241. pageSize = utils.PageSize20
  1242. }
  1243. if currentIndex <= 0 {
  1244. currentIndex = 1
  1245. }
  1246. startSize = paging.StartIndex(currentIndex, pageSize)
  1247. var pars []interface{}
  1248. var total int
  1249. resp := new(models.CygxReportSelectionListPublicRep)
  1250. page := paging.GetPaging(currentIndex, pageSize, total)
  1251. var tbdb string
  1252. var readSql string
  1253. var reportTypeStr string
  1254. if reportType == "1" {
  1255. tbdb = "cygx_report_selection"
  1256. reportTypeStr = "bgjx"
  1257. } else if reportType == "2" {
  1258. tbdb = "cygx_research_summary"
  1259. reportTypeStr = "bzyjhz"
  1260. } else if reportType == "3" {
  1261. tbdb = "cygx_minutes_summary"
  1262. reportTypeStr = "szjyhz"
  1263. } else {
  1264. br.Msg = "请选择报告类型"
  1265. return
  1266. }
  1267. fmt.Println(tbdb)
  1268. condition = ` AND publish_status = 1 `
  1269. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1270. if err != nil {
  1271. br.Msg = "获取信息失败"
  1272. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1273. return
  1274. }
  1275. //研究汇总--报告精选 只显示最新一期,往期都隐藏
  1276. if reportType == "1" {
  1277. startSize = 0
  1278. pageSize = 1
  1279. total = 1
  1280. }
  1281. 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`
  1282. page = paging.GetPaging(currentIndex, pageSize, total)
  1283. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1284. if err != nil {
  1285. br.Msg = "获取失败"
  1286. br.ErrMsg = "获取失败,Err:" + err.Error()
  1287. return
  1288. }
  1289. for k, v := range list {
  1290. if reportType == "1" {
  1291. list[k].Abstract = v.UpdateDescription
  1292. }
  1293. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1294. if v.ReadNum == 0 {
  1295. list[k].IsRed = true
  1296. }
  1297. }
  1298. resp.List = list
  1299. resp.Paging = page
  1300. br.Ret = 200
  1301. br.Success = true
  1302. br.Msg = "获取成功"
  1303. br.Data = resp
  1304. }
  1305. // @Title 获取报告精选详情
  1306. // @Description 获取报告精选详情接口
  1307. // @Param ArticleId query int true "报告ID"
  1308. // @Success 200 {object} models.ReportSelectionLetailResp
  1309. // @router /reportSelection/detail [get]
  1310. func (this *ReportController) Detail() {
  1311. br := new(models.BaseResponse).Init()
  1312. defer func() {
  1313. this.Data["json"] = br
  1314. this.ServeJSON()
  1315. }()
  1316. user := this.User
  1317. if user == nil {
  1318. br.Msg = "请重新登录"
  1319. br.Ret = 408
  1320. return
  1321. }
  1322. uid := user.UserId
  1323. articleId, _ := this.GetInt("ArticleId")
  1324. if articleId < 0 {
  1325. br.Msg = "参数错误"
  1326. br.ErrMsg = "参数错误"
  1327. return
  1328. }
  1329. resp := new(models.ReportSelectionLetailResp)
  1330. //判断用户权限
  1331. hasPermission, err := services.GetUserhasPermission(user)
  1332. if err != nil {
  1333. br.Msg = "获取信息失败"
  1334. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1335. }
  1336. resp.HasPermission = hasPermission
  1337. if hasPermission != 1 {
  1338. br.Ret = 200
  1339. br.Success = true
  1340. br.Msg = "获取成功"
  1341. br.Data = resp
  1342. return
  1343. }
  1344. detail, err := models.GetCygxReportSelectionInfoById(articleId)
  1345. if err != nil {
  1346. br.Msg = "获取信息失败"
  1347. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1348. return
  1349. }
  1350. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1351. existMap := make(map[int]int)
  1352. var items []*models.ReportSelectionChartPermission
  1353. listLog, err := models.GetReportSelectionlogListAll(articleId)
  1354. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1355. if err != nil {
  1356. br.Msg = "获取失败"
  1357. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1358. return
  1359. }
  1360. //var itemLogs []*models.CygxReportSelectionLogDetail
  1361. for _, v := range listLog {
  1362. item := new(models.ReportSelectionChartPermission)
  1363. if existMap[v.ChartPermissionId] == 0 {
  1364. item.PermissionName = v.PermissionName + "领域深度报告和调研"
  1365. item.IcoLink = v.IcoLink
  1366. listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
  1367. if err != nil && err.Error() != utils.ErrNoRow() {
  1368. br.Msg = "获取信息失败"
  1369. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1370. return
  1371. }
  1372. for k2, v2 := range listSonLog {
  1373. if v2.IndustrialManagementId != "" {
  1374. listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
  1375. if err != nil && err.Error() != utils.ErrNoRow() {
  1376. br.Msg = "获取信息失败"
  1377. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1378. return
  1379. }
  1380. listSonLog[k2].List = listIndustrial
  1381. }
  1382. }
  1383. item.List = listSonLog
  1384. items = append(items, item)
  1385. //itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
  1386. }
  1387. existMap[v.ChartPermissionId] = v.ChartPermissionId
  1388. }
  1389. historyRecord := new(models.CygxReportHistoryRecord)
  1390. historyRecord.UserId = uid
  1391. historyRecord.ArticleId = articleId
  1392. historyRecord.CreateTime = time.Now()
  1393. historyRecord.Mobile = user.Mobile
  1394. historyRecord.Email = user.Email
  1395. historyRecord.CompanyId = user.CompanyId
  1396. historyRecord.CompanyName = user.CompanyName
  1397. historyRecord.ReportType = "bgjx"
  1398. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1399. if err != nil && err.Error() != utils.ErrNoRow() {
  1400. br.Msg = "获取信息失败"
  1401. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1402. return
  1403. }
  1404. historyRecord.RealName = user.RealName
  1405. if sellerItem != nil {
  1406. historyRecord.SellerName = sellerItem.RealName
  1407. }
  1408. go models.AddCygxReportHistoryRecord(historyRecord)
  1409. resp.List = items
  1410. resp.Detail = detail
  1411. br.Ret = 200
  1412. br.Success = true
  1413. br.Msg = "获取成功"
  1414. br.Data = resp
  1415. }
  1416. // @Title 获取本周研究汇总详情
  1417. // @Description 获取本周研究汇总详情接口
  1418. // @Param ArticleId query int true "报告ID"
  1419. // @Success 200 {object} models.ResearchSummaryLetailResp
  1420. // @router /researchSummary/detail [get]
  1421. func (this *ReportController) ResearchDetail() {
  1422. br := new(models.BaseResponse).Init()
  1423. defer func() {
  1424. this.Data["json"] = br
  1425. this.ServeJSON()
  1426. }()
  1427. user := this.User
  1428. if user == nil {
  1429. br.Msg = "请重新登录"
  1430. br.Ret = 408
  1431. return
  1432. }
  1433. uid := user.UserId
  1434. articleId, _ := this.GetInt("ArticleId")
  1435. if articleId < 0 {
  1436. br.Msg = "参数错误"
  1437. br.ErrMsg = "参数错误"
  1438. return
  1439. }
  1440. resp := new(models.ResearchSummaryLetailResp)
  1441. //判断用户权限
  1442. hasPermission, err := services.GetUserhasPermission(user)
  1443. if err != nil {
  1444. br.Msg = "获取信息失败"
  1445. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1446. }
  1447. resp.HasPermission = hasPermission
  1448. if hasPermission != 1 {
  1449. br.Ret = 200
  1450. br.Success = true
  1451. br.Msg = "获取成功"
  1452. br.Data = resp
  1453. return
  1454. }
  1455. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1456. if err != nil {
  1457. br.Msg = "获取信息失败"
  1458. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1459. return
  1460. }
  1461. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1462. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1463. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1464. if err != nil {
  1465. br.Msg = "获取失败"
  1466. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1467. return
  1468. }
  1469. listArticleType, err := models.GetCygxArticleTypeList()
  1470. if err != nil {
  1471. br.Msg = "获取失败"
  1472. br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
  1473. return
  1474. }
  1475. for k, v := range listFirst {
  1476. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1477. if err != nil && err.Error() != utils.ErrNoRow() {
  1478. br.Msg = "获取信息失败"
  1479. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1480. return
  1481. }
  1482. for k2, v2 := range listSecond {
  1483. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1484. if err != nil && err.Error() != utils.ErrNoRow() {
  1485. br.Msg = "获取信息失败"
  1486. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1487. return
  1488. }
  1489. for _, vType := range listArticleType {
  1490. if v2.ChartPermissionId == vType.YanxPermissionId {
  1491. listSecond[k2].IcoLink = vType.IcoLinkM
  1492. listSecond[k2].PermissionName = vType.YanxPermissionName
  1493. }
  1494. }
  1495. //if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
  1496. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1497. // listSecond[k2].PermissionName = "买方研选纪要"
  1498. //} else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
  1499. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1500. // listSecond[k2].PermissionName = "买方研选观点"
  1501. //}
  1502. if len(listThird) > 0 {
  1503. for k3, v3 := range listThird {
  1504. if v3.VideoUrl != "" {
  1505. listThird[k3].IsHaveVideo = true
  1506. }
  1507. if v3.ReportLink == "0" {
  1508. listThird[k3].ReportLink = ""
  1509. }
  1510. }
  1511. listSecond[k2].List = listThird
  1512. }
  1513. }
  1514. if len(listSecond) > 0 {
  1515. listFirst[k].List = listSecond
  1516. }
  1517. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1518. if v.Type == "SDBG" {
  1519. listFirst[k].ListName = "深度报告"
  1520. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1521. } else if v.Type == "BZCHJH" {
  1522. listFirst[k].ListName = "本周晨会精华"
  1523. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1524. } else if v.Type == "CYDYJY" {
  1525. listFirst[k].ListName = "产业调研纪要"
  1526. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1527. } else if v.Type == "SSGS" {
  1528. listFirst[k].ListName = "上市公司调研纪要篇"
  1529. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1530. } else if v.Type == "SJDP" {
  1531. listFirst[k].ListName = "事件点评"
  1532. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1533. } else if v.Type == "YANX" {
  1534. listFirst[k].ListName = "买方研选"
  1535. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1536. }
  1537. }
  1538. historyRecord := new(models.CygxReportHistoryRecord)
  1539. historyRecord.UserId = uid
  1540. historyRecord.ArticleId = articleId
  1541. historyRecord.CreateTime = time.Now()
  1542. historyRecord.Mobile = user.Mobile
  1543. historyRecord.Email = user.Email
  1544. historyRecord.CompanyId = user.CompanyId
  1545. historyRecord.CompanyName = user.CompanyName
  1546. historyRecord.ReportType = "bzyjhz"
  1547. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1548. if err != nil && err.Error() != utils.ErrNoRow() {
  1549. br.Msg = "获取信息失败"
  1550. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1551. return
  1552. }
  1553. historyRecord.RealName = user.RealName
  1554. if sellerItem != nil {
  1555. historyRecord.SellerName = sellerItem.RealName
  1556. }
  1557. go models.AddCygxReportHistoryRecord(historyRecord)
  1558. resp.List = listFirst
  1559. resp.Detail = detail
  1560. br.Ret = 200
  1561. br.Success = true
  1562. br.Msg = "获取成功"
  1563. br.Data = resp
  1564. }
  1565. // @Title 上周纪要汇总内容详情
  1566. // @Description 获取上周纪要汇总内容详情接口
  1567. // @Param ArticleId query int true "报告ID"
  1568. // @Success 200 {object} models.MinutesSummaryLetailResp
  1569. // @router /minutesSummary/detailv4 [get]
  1570. func (this *ReportController) MinutesDetailV4() {
  1571. br := new(models.BaseResponse).Init()
  1572. defer func() {
  1573. this.Data["json"] = br
  1574. this.ServeJSON()
  1575. }()
  1576. user := this.User
  1577. if user == nil {
  1578. br.Msg = "请重新登录"
  1579. br.Ret = 408
  1580. return
  1581. }
  1582. uid := user.UserId
  1583. articleId, _ := this.GetInt("ArticleId")
  1584. if articleId < 0 {
  1585. br.Msg = "参数错误"
  1586. br.ErrMsg = "参数错误"
  1587. return
  1588. }
  1589. resp := new(models.MinutesSummaryLetailRespV4)
  1590. //判断用户权限
  1591. hasPermission, err := services.GetUserhasPermission(user)
  1592. if err != nil {
  1593. br.Msg = "获取信息失败"
  1594. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1595. }
  1596. resp.HasPermission = hasPermission
  1597. if hasPermission != 1 {
  1598. br.Ret = 200
  1599. br.Success = true
  1600. br.Msg = "获取成功"
  1601. br.Data = resp
  1602. return
  1603. }
  1604. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1605. if err != nil {
  1606. br.Msg = "获取信息失败"
  1607. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1608. return
  1609. }
  1610. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1611. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1612. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1613. if err != nil {
  1614. br.Msg = "获取失败"
  1615. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1616. return
  1617. }
  1618. for k, v := range listFirst {
  1619. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1620. if err != nil && err.Error() != utils.ErrNoRow() {
  1621. br.Msg = "获取信息失败"
  1622. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1623. return
  1624. }
  1625. for k2, v2 := range listSecond {
  1626. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1627. if err != nil && err.Error() != utils.ErrNoRow() {
  1628. br.Msg = "获取信息失败"
  1629. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1630. return
  1631. }
  1632. if len(listThird) > 0 {
  1633. for k3, v3 := range listThird {
  1634. if v3.VideoUrl != "" {
  1635. listThird[k3].IsHaveVideo = true
  1636. }
  1637. if v3.ReportLink == "0" {
  1638. listThird[k3].ReportLink = ""
  1639. }
  1640. }
  1641. listSecond[k2].List = listThird
  1642. }
  1643. }
  1644. if len(listSecond) > 0 {
  1645. listFirst[k].List = listSecond
  1646. }
  1647. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1648. if v.Type == "CYDYJY" {
  1649. listFirst[k].ListName = "产业调研纪要"
  1650. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1651. } else if v.Type == "SSGS" {
  1652. listFirst[k].ListName = "上市公司调研纪要篇"
  1653. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1654. } else if v.Type == "YANX" {
  1655. listFirst[k].ListName = "买方研选纪要"
  1656. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1657. }
  1658. }
  1659. historyRecord := new(models.CygxReportHistoryRecord)
  1660. historyRecord.UserId = uid
  1661. historyRecord.ArticleId = articleId
  1662. historyRecord.CreateTime = time.Now()
  1663. historyRecord.Mobile = user.Mobile
  1664. historyRecord.Email = user.Email
  1665. historyRecord.CompanyId = user.CompanyId
  1666. historyRecord.CompanyName = user.CompanyName
  1667. historyRecord.ReportType = "szjyhz"
  1668. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1669. if err != nil && err.Error() != utils.ErrNoRow() {
  1670. br.Msg = "获取信息失败"
  1671. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1672. return
  1673. }
  1674. historyRecord.RealName = user.RealName
  1675. if sellerItem != nil {
  1676. historyRecord.SellerName = sellerItem.RealName
  1677. }
  1678. go models.AddCygxReportHistoryRecord(historyRecord)
  1679. resp.List = listFirst
  1680. resp.Detail = detail
  1681. br.Ret = 200
  1682. br.Success = true
  1683. br.Msg = "获取成功"
  1684. br.Data = resp
  1685. }
  1686. // @Title 上周纪要汇总内容详情
  1687. // @Description 获取上周纪要汇总内容详情接口
  1688. // @Param ArticleId query int true "报告ID"
  1689. // @Success 200 {object} models.MinutesSummaryLetailResp
  1690. // @router /minutesSummary/detail [get]
  1691. func (this *ReportController) MinutesDetail() {
  1692. br := new(models.BaseResponse).Init()
  1693. defer func() {
  1694. this.Data["json"] = br
  1695. this.ServeJSON()
  1696. }()
  1697. user := this.User
  1698. if user == nil {
  1699. br.Msg = "请重新登录"
  1700. br.Ret = 408
  1701. return
  1702. }
  1703. uid := user.UserId
  1704. articleId, _ := this.GetInt("ArticleId")
  1705. if articleId < 0 {
  1706. br.Msg = "参数错误"
  1707. br.ErrMsg = "参数错误"
  1708. return
  1709. }
  1710. resp := new(models.MinutesSummaryLetailResp)
  1711. //判断用户权限
  1712. hasPermission, err := services.GetUserhasPermission(user)
  1713. if err != nil {
  1714. br.Msg = "获取信息失败"
  1715. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1716. }
  1717. resp.HasPermission = hasPermission
  1718. if hasPermission != 1 {
  1719. br.Ret = 200
  1720. br.Success = true
  1721. br.Msg = "获取成功"
  1722. br.Data = resp
  1723. return
  1724. }
  1725. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1726. if err != nil {
  1727. br.Msg = "获取信息失败"
  1728. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1729. return
  1730. }
  1731. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1732. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1733. listLog, err := models.GetMinutesSummarylogListAll(articleId)
  1734. if err != nil {
  1735. br.Msg = "获取失败"
  1736. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1737. return
  1738. }
  1739. for k, v := range listLog {
  1740. listSonLog, err := models.GetMinutesSummarylogSonListAll(articleId, v.ChartPermissionId)
  1741. if err != nil && err.Error() != utils.ErrNoRow() {
  1742. br.Msg = "获取信息失败"
  1743. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1744. return
  1745. }
  1746. if len(listSonLog) > 0 {
  1747. listLog[k].List = listSonLog
  1748. for k2, v2 := range listSonLog {
  1749. if v2.ReportLink == "0" {
  1750. listSonLog[k2].ReportLink = ""
  1751. }
  1752. }
  1753. }
  1754. }
  1755. historyRecord := new(models.CygxReportHistoryRecord)
  1756. historyRecord.UserId = uid
  1757. historyRecord.ArticleId = articleId
  1758. historyRecord.CreateTime = time.Now()
  1759. historyRecord.Mobile = user.Mobile
  1760. historyRecord.Email = user.Email
  1761. historyRecord.CompanyId = user.CompanyId
  1762. historyRecord.CompanyName = user.CompanyName
  1763. historyRecord.ReportType = "szjyhz"
  1764. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1765. if err != nil && err.Error() != utils.ErrNoRow() {
  1766. br.Msg = "获取信息失败"
  1767. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1768. return
  1769. }
  1770. historyRecord.RealName = user.RealName
  1771. if sellerItem != nil {
  1772. historyRecord.SellerName = sellerItem.RealName
  1773. }
  1774. go models.AddCygxReportHistoryRecord(historyRecord)
  1775. resp.List = listLog
  1776. resp.Detail = detail
  1777. br.Ret = 200
  1778. br.Success = true
  1779. br.Msg = "获取成功"
  1780. br.Data = resp
  1781. }
  1782. // @Title 获取路演精华详情
  1783. // @Description 获取路演精华详情接口
  1784. // @Param ArticleId query int true "报告ID"
  1785. // @Success 200 {object} models.RoadshowDetailResp
  1786. // @router /roadshowEssence/detail [get]
  1787. func (this *ReportController) RoadshowDetail() {
  1788. br := new(models.BaseResponse).Init()
  1789. defer func() {
  1790. this.Data["json"] = br
  1791. this.ServeJSON()
  1792. }()
  1793. user := this.User
  1794. if user == nil {
  1795. br.Msg = "请登录"
  1796. br.ErrMsg = "请登录,用户信息为空"
  1797. br.Ret = 408
  1798. return
  1799. }
  1800. uid := user.UserId
  1801. articleId, err := this.GetInt("ArticleId")
  1802. if articleId <= 0 {
  1803. br.Msg = "文章不存在"
  1804. br.ErrMsg = "文章不存在,文章ID错误"
  1805. return
  1806. }
  1807. detail := new(models.ReportDetailRoadshow)
  1808. hasPermission := 0
  1809. hasFree := 0
  1810. //判断是否已经申请过
  1811. applyCount, err := models.GetApplyRecordCount(uid)
  1812. if err != nil && err.Error() != utils.ErrNoRow() {
  1813. br.Msg = "获取信息失败"
  1814. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1815. return
  1816. }
  1817. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  1818. if user.CompanyId > 1 {
  1819. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  1820. if err != nil {
  1821. br.Msg = "获取信息失败"
  1822. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1823. return
  1824. }
  1825. detail, err = models.GetReportRoadshowDetailById(articleId)
  1826. if err != nil {
  1827. br.Msg = "获取信息失败"
  1828. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1829. return
  1830. }
  1831. detail.Body = html.UnescapeString(detail.Body)
  1832. detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
  1833. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1834. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1835. if detail.ReportLink == "0" {
  1836. detail.ReportLink = ""
  1837. }
  1838. if companyPermission == "" {
  1839. if applyCount > 0 {
  1840. hasPermission = 5
  1841. } else {
  1842. hasPermission = 2
  1843. }
  1844. hasFree = 2
  1845. goto Loop
  1846. } else {
  1847. hasFree = 1
  1848. var articlePermissionPermissionName string
  1849. articlePermissionPermissionName = detail.CategoryName
  1850. var hasPersion bool
  1851. slice := strings.Split(articlePermissionPermissionName, ",")
  1852. for _, v := range slice {
  1853. if strings.Contains(companyPermission, v) {
  1854. hasPersion = true
  1855. }
  1856. }
  1857. if hasPersion {
  1858. hasPermission = 1
  1859. historyRecord := new(models.CygxArticleHistoryRecord)
  1860. historyRecord.UserId = uid
  1861. historyRecord.ArticleId = articleId
  1862. historyRecord.CreateTime = time.Now()
  1863. historyRecord.Mobile = user.Mobile
  1864. historyRecord.Email = user.Email
  1865. historyRecord.CompanyId = user.CompanyId
  1866. historyRecord.CompanyName = user.CompanyName
  1867. go models.AddCygxArticleHistoryRecord(historyRecord)
  1868. } else { //无该行业权限
  1869. hasPermission = 3
  1870. }
  1871. if hasPermission == 1 {
  1872. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  1873. if !utils.Rc.IsExist(key) {
  1874. //新增浏览记录
  1875. record := new(models.CygxArticleViewRecord)
  1876. record.UserId = uid
  1877. record.ArticleId = articleId
  1878. record.CreateTime = time.Now()
  1879. record.Mobile = user.Mobile
  1880. record.Email = user.Email
  1881. record.CompanyId = user.CompanyId
  1882. record.CompanyName = user.CompanyName
  1883. go models.AddCygxArticleViewRecord(record)
  1884. utils.Rc.Put(key, 1, 5*time.Second)
  1885. models.ModifyReportLastViewTime(uid)
  1886. }
  1887. }
  1888. }
  1889. } else { //潜在客户
  1890. if applyCount > 0 {
  1891. hasPermission = 5
  1892. } else {
  1893. hasPermission = 4
  1894. }
  1895. }
  1896. Loop:
  1897. if hasPermission != 1 {
  1898. detail.Body = ""
  1899. detail.Abstract = ""
  1900. }
  1901. resp := new(models.RoadshowDetailResp)
  1902. resp.HasPermission = hasPermission
  1903. resp.HasFree = hasFree
  1904. resp.Detail = detail
  1905. br.Ret = 200
  1906. br.Success = true
  1907. br.Msg = "获取成功"
  1908. br.Data = resp
  1909. }
  1910. // @Title 产业文章列表接口
  1911. // @Description 获取产业文章列表接口
  1912. // @Param KeyWord query string true "搜索关键词"
  1913. // @Success 200 {object} models.CygxIndustrySearchList
  1914. // @router /industryAndArticle/list [get]
  1915. func (this *ReportController) IndustryAndArticleList() {
  1916. br := new(models.BaseResponse).Init()
  1917. defer func() {
  1918. this.Data["json"] = br
  1919. this.ServeJSON()
  1920. }()
  1921. user := this.User
  1922. if user == nil {
  1923. br.Msg = "请重新登录"
  1924. br.Ret = 408
  1925. return
  1926. }
  1927. uid := user.UserId
  1928. keyWord := this.GetString("KeyWord")
  1929. orderSrt := "update_time DESC"
  1930. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  1931. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  1932. if err != nil {
  1933. br.Msg = "获取信息失败"
  1934. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1935. return
  1936. }
  1937. for k, v := range list {
  1938. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  1939. if err != nil {
  1940. br.Msg = "获取信息失败"
  1941. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1942. return
  1943. }
  1944. list[k].IndustrialSubjectList = industrialSubjectList
  1945. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  1946. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  1947. if err != nil {
  1948. br.Msg = "获取信息失败"
  1949. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1950. return
  1951. }
  1952. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  1953. }
  1954. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  1955. if err != nil {
  1956. br.Msg = "获取失败"
  1957. br.ErrMsg = "获取失败,Err:" + err.Error()
  1958. return
  1959. }
  1960. for k2, v2 := range artList {
  1961. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  1962. if err != nil {
  1963. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  1964. br.ErrMsg = "获取失败,Err:" + err.Error()
  1965. return
  1966. }
  1967. var subjectNamesNew string
  1968. if len(subjectNames) > 0 {
  1969. slice := strings.Split(subjectNames, "/")
  1970. for k3, v3 := range slice {
  1971. if k3 < 4 {
  1972. subjectNamesNew += v3 + "/"
  1973. }
  1974. }
  1975. }
  1976. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  1977. if err != nil && err.Error() != utils.ErrNoRow() {
  1978. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  1979. br.ErrMsg = "获取失败,Err:" + err.Error()
  1980. return
  1981. }
  1982. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1983. artList[k2].SubjectName = subjectNamesNew
  1984. if subjectNamesNew == "" {
  1985. artList[k2].IndustryName = industryName
  1986. } else {
  1987. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  1988. }
  1989. }
  1990. if keyWord != "" {
  1991. keyWordItem := new(models.CygxUserSearchKeyWord)
  1992. keyWordItem.UserId = user.UserId
  1993. keyWordItem.KeyWord = keyWord
  1994. keyWordItem.PageType = "ReortSearch"
  1995. keyWordItem.CreateTime = time.Now()
  1996. go models.AddUserSearchKeyWord(keyWordItem)
  1997. }
  1998. resp := new(models.CygxIndustrySearchList)
  1999. resp.ArtList = artList
  2000. resp.IndList = list
  2001. br.Ret = 200
  2002. br.Success = true
  2003. br.Msg = "获取成功"
  2004. br.Data = resp
  2005. }
  2006. // @Title 产业报告分类关联作者列表接口Pc端
  2007. // @Description 获取产业报告分类关联作者列表接口Pc端
  2008. // @Param ChartPermissionId query int true "分类ID"
  2009. // @Param KeyWord query string true "搜索关键词"
  2010. // @Param PageSize query int true "每页数据条数"
  2011. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2012. // @Success 200 {object} models.CygxArticleDepartmentListPc
  2013. // @router /industryListByDepartmentPc [get]
  2014. func (this *ReportController) IndustryListByDepartmentPc() {
  2015. br := new(models.BaseResponse).Init()
  2016. defer func() {
  2017. this.Data["json"] = br
  2018. this.ServeJSON()
  2019. }()
  2020. user := this.User
  2021. if user == nil {
  2022. br.Msg = "请重新登录"
  2023. br.Ret = 408
  2024. return
  2025. }
  2026. uid := user.UserId
  2027. pageSize, _ := this.GetInt("PageSize")
  2028. currentIndex, _ := this.GetInt("CurrentIndex")
  2029. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  2030. keyWord := this.GetString("KeyWord")
  2031. var startSize int
  2032. var condition string
  2033. condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  2034. if pageSize <= 0 {
  2035. pageSize = utils.PageSize20
  2036. }
  2037. if currentIndex <= 0 {
  2038. currentIndex = 1
  2039. }
  2040. var articleIdGroup string
  2041. if keyWord != "" {
  2042. //获取标的关联的文章ID
  2043. articleIdSub, err := models.GetArticleIdSubjectGroup(keyWord)
  2044. if err != nil {
  2045. br.Msg = "获取信息失败"
  2046. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2047. return
  2048. }
  2049. //获取产业关联的标的
  2050. articleIdInd, err := models.GetArticleIndustrialIdGroup(keyWord)
  2051. if err != nil {
  2052. br.Msg = "获取信息失败"
  2053. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  2054. return
  2055. }
  2056. if articleIdSub != "" && articleIdInd != "" {
  2057. articleIdGroup = articleIdSub + "," + articleIdInd
  2058. } else if articleIdSub != "" && articleIdInd == "" {
  2059. articleIdGroup = articleIdSub
  2060. } else if articleIdSub == "" && articleIdInd != "" {
  2061. articleIdGroup = articleIdInd
  2062. }
  2063. slice := strings.Split(keyWord, "/")
  2064. if len(slice) > 1 {
  2065. var subjectIds string
  2066. for _, v := range slice {
  2067. subjectId, err := models.GetcygxIndustrialSubjectByName(v)
  2068. if err != nil && err.Error() != utils.ErrNoRow() {
  2069. br.Msg = "获取信息失败"
  2070. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  2071. return
  2072. }
  2073. if subjectId != "" {
  2074. subjectIds += subjectId + ","
  2075. }
  2076. }
  2077. subjectIds = strings.TrimRight(subjectIds, ",")
  2078. if len(subjectIds) > 0 {
  2079. articleBySub, err := models.GetArticleIdsBySubId(subjectIds)
  2080. if err != nil {
  2081. br.Msg = "获取信息失败"
  2082. br.ErrMsg = "获取文章关联的标的失败,Err:" + err.Error()
  2083. return
  2084. }
  2085. if articleIdGroup != "" {
  2086. if articleBySub != "" {
  2087. articleIdGroup += "," + articleBySub
  2088. }
  2089. } else {
  2090. articleIdGroup = articleBySub
  2091. }
  2092. }
  2093. }
  2094. }
  2095. if articleIdGroup != "" {
  2096. condition += ` AND a.article_id IN (` + articleIdGroup + `)`
  2097. }
  2098. startSize = paging.StartIndex(currentIndex, pageSize)
  2099. total, err := models.GetArticleDepartmentCount(condition)
  2100. page := paging.GetPaging(currentIndex, pageSize, total)
  2101. resp := new(models.CygxArticleDepartmentListPc)
  2102. userType, _, err := services.GetUserType(user.CompanyId)
  2103. if err != nil {
  2104. br.Msg = "获取信息失败"
  2105. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  2106. return
  2107. }
  2108. if userType == 1 {
  2109. resp.Paging = page
  2110. br.Ret = 200
  2111. br.Success = true
  2112. br.Msg = "获取成功"
  2113. br.Data = resp
  2114. return
  2115. }
  2116. resp.HaveResearch = true
  2117. //获取作者信息,并排序
  2118. list, err := models.GetCygxArticleDepartmentListPc(startSize, pageSize, condition, uid)
  2119. if err != nil {
  2120. br.Msg = "获取信息失败"
  2121. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2122. return
  2123. }
  2124. for k, v := range list {
  2125. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIdGroup)
  2126. if err != nil {
  2127. br.Msg = "获取信息失败"
  2128. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2129. return
  2130. }
  2131. for k2, v2 := range artList {
  2132. if artList[k2].IsReport == "1" {
  2133. artList[k2].Title = v2.Title
  2134. } else {
  2135. artList[k2].Title = v2.Title
  2136. }
  2137. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2138. }
  2139. list[k].List = artList
  2140. if v.FollowNum > 0 {
  2141. list[k].IsMyFollow = true
  2142. }
  2143. }
  2144. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  2145. if err != nil {
  2146. br.Msg = "获取信息失败"
  2147. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2148. return
  2149. }
  2150. if len(listnNew) > 0 {
  2151. for _, v := range listnNew {
  2152. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  2153. Management := new(models.IndustrialManagementIdInt)
  2154. if firstStr == 0 {
  2155. Management.IndustryName = v.IndustryName
  2156. } else {
  2157. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  2158. if err != nil {
  2159. br.Msg = "获取信息失败"
  2160. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  2161. return
  2162. }
  2163. var subjectNamesNew string
  2164. for _, v1 := range listSub {
  2165. subjectNamesNew += v1.SubjectName + "/"
  2166. }
  2167. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2168. Management.IndustryName = subjectNamesNew
  2169. }
  2170. Management.IndustrialManagementId = v.IndustrialManagementId
  2171. Management.ArticleId = v.ArticleId
  2172. resp.ListnNew = append(resp.ListnNew, Management)
  2173. }
  2174. }
  2175. resp.List = list
  2176. resp.Paging = page
  2177. br.Ret = 200
  2178. br.Success = true
  2179. br.Msg = "获取成功"
  2180. br.Data = resp
  2181. }
  2182. // @Title 产业文章列表接口Pc端
  2183. // @Description 获取产业文章列表接口Pc端
  2184. // @Param KeyWord query string true "搜索关键词"
  2185. // @Success 200 {object} models.CygxIndustrySearchListPc
  2186. // @router /industryAndArticle/listPc [get]
  2187. func (this *ReportController) IndustryAndArticleListPc() {
  2188. br := new(models.BaseResponse).Init()
  2189. defer func() {
  2190. this.Data["json"] = br
  2191. this.ServeJSON()
  2192. }()
  2193. user := this.User
  2194. if user == nil {
  2195. br.Msg = "请重新登录"
  2196. br.Ret = 408
  2197. return
  2198. }
  2199. uid := user.UserId
  2200. keyWord := this.GetString("KeyWord")
  2201. resp := new(models.CygxIndustrySearchListPc)
  2202. orderSrt := "update_time DESC"
  2203. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2204. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2205. if err != nil {
  2206. br.Msg = "获取信息失败"
  2207. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2208. return
  2209. }
  2210. for k, v := range list {
  2211. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2212. if err != nil {
  2213. br.Msg = "获取信息失败"
  2214. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2215. return
  2216. }
  2217. list[k].IndustrialSubjectList = industrialSubjectList
  2218. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2219. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2220. if err != nil {
  2221. br.Msg = "获取信息失败"
  2222. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2223. return
  2224. }
  2225. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2226. }
  2227. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2228. if err != nil {
  2229. br.Msg = "获取失败"
  2230. br.ErrMsg = "获取失败,Err:" + err.Error()
  2231. return
  2232. }
  2233. if len(artList) > 0 {
  2234. var articleIds string
  2235. for _, v := range artList {
  2236. articleIds += strconv.Itoa(v.ArticleId) + ","
  2237. }
  2238. articleIds = strings.TrimRight(articleIds, ",")
  2239. if articleIds != "" {
  2240. condition = ` AND a.article_id IN (` + articleIds + `)`
  2241. DepartmentList, err := models.GetCygxArticleDepartmentListPc(0, 20, condition, uid)
  2242. if err != nil {
  2243. br.Msg = "获取信息失败"
  2244. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2245. return
  2246. }
  2247. for k, v := range DepartmentList {
  2248. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIds)
  2249. if err != nil {
  2250. br.Msg = "获取信息失败"
  2251. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2252. return
  2253. }
  2254. for k2, v2 := range artList {
  2255. if artList[k2].IsReport == "1" {
  2256. artList[k2].Title = v2.Title
  2257. } else {
  2258. artList[k2].Title = v2.Title
  2259. }
  2260. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2261. }
  2262. DepartmentList[k].List = artList
  2263. if v.FollowNum > 0 {
  2264. DepartmentList[k].IsMyFollow = true
  2265. }
  2266. }
  2267. resp.DepartmentList = DepartmentList
  2268. }
  2269. }
  2270. if keyWord != "" {
  2271. keyWordItem := new(models.CygxUserSearchKeyWord)
  2272. keyWordItem.UserId = user.UserId
  2273. keyWordItem.KeyWord = keyWord
  2274. keyWordItem.PageType = "ReortSearch"
  2275. keyWordItem.CreateTime = time.Now()
  2276. go models.AddUserSearchKeyWord(keyWordItem)
  2277. }
  2278. resp.IndList = list
  2279. br.Ret = 200
  2280. br.Success = true
  2281. br.Msg = "获取成功"
  2282. br.Data = resp
  2283. }
  2284. // @Title 报告搜索
  2285. // @Description 报告搜索接口
  2286. // @Param KeyWord query string true "搜索关键词"
  2287. // @Success 200 {object} models.ReoprtSearchResp
  2288. // @router /searchReport [get]
  2289. func (this *ReportController) SearchReport() {
  2290. br := new(models.BaseResponse).Init()
  2291. defer func() {
  2292. this.Data["json"] = br
  2293. this.ServeJSON()
  2294. }()
  2295. user := this.User
  2296. if user == nil {
  2297. br.Msg = "请重新登录"
  2298. br.Ret = 408
  2299. return
  2300. }
  2301. keyWord := this.GetString("KeyWord")
  2302. var condition string
  2303. var sqlGroup string
  2304. //匹配报告标题、
  2305. 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 `
  2306. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2307. //对应产业名称、标的名称。
  2308. listYx, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
  2309. if err != nil {
  2310. br.Msg = "获取信息失败"
  2311. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2312. return
  2313. }
  2314. for k, v := range listYx {
  2315. listYx[k].Source = 2
  2316. if v.MyCollectNum > 0 {
  2317. listYx[k].IsCollect = true
  2318. }
  2319. }
  2320. listHz, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId)
  2321. if err != nil {
  2322. br.Msg = "获取信息失败"
  2323. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2324. return
  2325. }
  2326. for k, v := range listHz {
  2327. listHz[k].Source = 1
  2328. if v.MyCollectNum > 0 {
  2329. listHz[k].IsCollect = true
  2330. }
  2331. }
  2332. if keyWord != "" {
  2333. keyWordItem := new(models.CygxUserSearchKeyWord)
  2334. keyWordItem.UserId = user.UserId
  2335. keyWordItem.KeyWord = keyWord
  2336. keyWordItem.PageType = "ReortSearch"
  2337. keyWordItem.CreateTime = time.Now()
  2338. go models.AddUserSearchKeyWord(keyWordItem)
  2339. go services.AddUserSearchLog(user, keyWord, 5)
  2340. }
  2341. if len(listYx) == 0 {
  2342. listYx = make([]*models.ArticleCollectionResp, 0)
  2343. }
  2344. if len(listHz) == 0 {
  2345. listHz = make([]*models.ArticleCollectionResp, 0)
  2346. }
  2347. resp := new(models.ReoprtSearchResp)
  2348. resp.ListYx = listYx
  2349. resp.ListHz = listHz
  2350. br.Ret = 200
  2351. br.Success = true
  2352. br.Msg = "获取成功"
  2353. br.Data = resp
  2354. }
  2355. // @Title 资源包搜索
  2356. // @Description 资源包搜索接口
  2357. // @Param KeyWord query string true "搜索关键词"
  2358. // @Success 200 {object} models.SearchResourceResp
  2359. // @router /searchResource [get]
  2360. func (this *ReportController) SearchResource() {
  2361. br := new(models.BaseResponse).Init()
  2362. defer func() {
  2363. this.Data["json"] = br
  2364. this.ServeJSON()
  2365. }()
  2366. user := this.User
  2367. if user == nil {
  2368. br.Msg = "请重新登录"
  2369. br.Ret = 408
  2370. return
  2371. }
  2372. uid := user.UserId
  2373. fllowList, err := models.GetUserFllowIndustrialList(uid)
  2374. if err != nil {
  2375. br.Msg = "获取失败"
  2376. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  2377. return
  2378. }
  2379. fllowMap := make(map[int]int)
  2380. if len(fllowList) > 0 {
  2381. for _, v := range fllowList {
  2382. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  2383. }
  2384. }
  2385. keyWord := this.GetString("KeyWord")
  2386. var condition string
  2387. var conditionOr string
  2388. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2389. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2390. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2391. listHz, err := models.GetSearchResourceList(condition, 0, 0)
  2392. if err != nil {
  2393. br.Msg = "获取信息失败"
  2394. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2395. return
  2396. }
  2397. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2398. conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2399. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2400. listYx, err := models.GetSearchResourceList(condition, 0, 0)
  2401. if err != nil {
  2402. br.Msg = "获取信息失败"
  2403. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2404. return
  2405. }
  2406. //合并产业关联的标的
  2407. listSubjcet, err := models.GetThemeHeatSubjectList("")
  2408. if err != nil {
  2409. br.Msg = "获取信息失败"
  2410. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2411. return
  2412. }
  2413. industrialIdArr := make([]int, 0)
  2414. for k, v := range listHz {
  2415. listHz[k].Source = 1
  2416. if fllowMap[v.IndustrialManagementId] > 0 {
  2417. listHz[k].IsFollw = true
  2418. }
  2419. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2420. }
  2421. for k, v := range listYx {
  2422. listYx[k].Source = 2
  2423. if fllowMap[v.IndustrialManagementId] > 0 {
  2424. listYx[k].IsFollw = true
  2425. }
  2426. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2427. }
  2428. if len(industrialIdArr) > 0 {
  2429. //合并产业关联的标的
  2430. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  2431. if err != nil {
  2432. br.Msg = "获取信息失败"
  2433. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2434. return
  2435. }
  2436. mapIndustrial := make(map[string]int)
  2437. for _, v := range listSubjcet {
  2438. for k2, v2 := range listYx {
  2439. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
  2440. listYx[k2].IndustrialSubjectList = append(listYx[k2].IndustrialSubjectList, v)
  2441. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  2442. }
  2443. }
  2444. for k2, v2 := range listHz {
  2445. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  2446. listHz[k2].IndustrialSubjectList = append(listHz[k2].IndustrialSubjectList, v)
  2447. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  2448. }
  2449. }
  2450. }
  2451. }
  2452. if keyWord != "" {
  2453. keyWordItem := new(models.CygxUserSearchKeyWord)
  2454. keyWordItem.UserId = user.UserId
  2455. keyWordItem.KeyWord = keyWord
  2456. keyWordItem.PageType = "ReortSearch"
  2457. keyWordItem.CreateTime = time.Now()
  2458. go models.AddUserSearchKeyWord(keyWordItem)
  2459. go services.AddUserSearchLog(user, keyWord, 4)
  2460. }
  2461. resp := new(models.SearchResourceResp)
  2462. if len(listYx) == 0 {
  2463. listYx = make([]*models.IndustrialManagementHotResp, 0)
  2464. }
  2465. if len(listHz) == 0 {
  2466. listHz = make([]*models.IndustrialManagementHotResp, 0)
  2467. }
  2468. resp.ListYx = listYx
  2469. resp.ListHz = listHz
  2470. br.Ret = 200
  2471. br.Success = true
  2472. br.Msg = "获取成功"
  2473. br.Data = resp
  2474. }
  2475. // @Title 报告搜索、资源包搜索接口
  2476. // @Description 报告搜索、资源包搜索接口接口
  2477. // @Param KeyWord query string true "搜索关键词"
  2478. // @Param PageSize query int true "每页数据条数"
  2479. // @Success 200 {object} models.SearchReportAndResourceResp
  2480. // @router /searchReportAndResource [get]
  2481. func (this *ReportController) SearchReportAndResource() {
  2482. br := new(models.BaseResponse).Init()
  2483. defer func() {
  2484. this.Data["json"] = br
  2485. this.ServeJSON()
  2486. }()
  2487. user := this.User
  2488. if user == nil {
  2489. br.Msg = "请重新登录"
  2490. br.Ret = 408
  2491. return
  2492. }
  2493. uid := user.UserId
  2494. keyWord := this.GetString("KeyWord")
  2495. pageSize, _ := this.GetInt("PageSize")
  2496. var condition string
  2497. var sqlGroup string
  2498. //匹配报告标题、
  2499. 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 `
  2500. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2501. if pageSize > 0 {
  2502. sqlGroup += ` LIMIT 5 `
  2503. }
  2504. ListYxReport, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
  2505. if err != nil {
  2506. br.Msg = "获取信息失败"
  2507. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2508. return
  2509. }
  2510. for k, v := range ListYxReport {
  2511. ListYxReport[k].Source = 2
  2512. if v.MyCollectNum > 0 {
  2513. ListYxReport[k].IsCollect = true
  2514. }
  2515. }
  2516. ListHzReport, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId)
  2517. if err != nil {
  2518. br.Msg = "获取信息失败"
  2519. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2520. return
  2521. }
  2522. for k, v := range ListHzReport {
  2523. ListHzReport[k].Source = 1
  2524. if v.MyCollectNum > 0 {
  2525. ListHzReport[k].IsCollect = true
  2526. }
  2527. }
  2528. if len(ListYxReport) == 0 {
  2529. ListYxReport = make([]*models.ArticleCollectionResp, 0)
  2530. }
  2531. if len(ListHzReport) == 0 {
  2532. ListHzReport = make([]*models.ArticleCollectionResp, 0)
  2533. }
  2534. fllowList, err := models.GetUserFllowIndustrialList(uid)
  2535. if err != nil {
  2536. br.Msg = "获取失败"
  2537. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  2538. return
  2539. }
  2540. fllowMap := make(map[int]int)
  2541. if len(fllowList) > 0 {
  2542. for _, v := range fllowList {
  2543. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  2544. }
  2545. }
  2546. var conditionOr string
  2547. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2548. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2549. listHzResource, err := models.GetSearchResourceList(condition, 0, pageSize)
  2550. if err != nil {
  2551. br.Msg = "获取信息失败"
  2552. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2553. return
  2554. }
  2555. conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2556. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2557. listYxResource, err := models.GetSearchResourceList(condition, 0, pageSize)
  2558. if err != nil {
  2559. br.Msg = "获取信息失败"
  2560. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2561. return
  2562. }
  2563. //合并产业关联的标的
  2564. listSubjcet, err := models.GetThemeHeatSubjectList("")
  2565. if err != nil {
  2566. br.Msg = "获取信息失败"
  2567. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2568. return
  2569. }
  2570. industrialIdArr := make([]int, 0)
  2571. for k, v := range listHzResource {
  2572. listHzResource[k].Source = 1
  2573. if fllowMap[v.IndustrialManagementId] > 0 {
  2574. listHzResource[k].IsFollw = true
  2575. }
  2576. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2577. }
  2578. for k, v := range listYxResource {
  2579. listYxResource[k].Source = 2
  2580. if fllowMap[v.IndustrialManagementId] > 0 {
  2581. listYxResource[k].IsFollw = true
  2582. }
  2583. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2584. }
  2585. if len(industrialIdArr) > 0 {
  2586. //合并产业关联的标的
  2587. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  2588. if err != nil {
  2589. br.Msg = "获取信息失败"
  2590. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2591. return
  2592. }
  2593. mapIndustrial := make(map[string]int)
  2594. for _, v := range listSubjcet {
  2595. for k2, v2 := range listYxResource {
  2596. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
  2597. listYxResource[k2].IndustrialSubjectList = append(listYxResource[k2].IndustrialSubjectList, v)
  2598. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  2599. }
  2600. }
  2601. for k2, v2 := range listHzResource {
  2602. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  2603. listHzResource[k2].IndustrialSubjectList = append(listHzResource[k2].IndustrialSubjectList, v)
  2604. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  2605. }
  2606. }
  2607. }
  2608. }
  2609. resp := new(models.SearchReportAndResourceResp)
  2610. if len(listYxResource) == 0 {
  2611. listYxResource = make([]*models.IndustrialManagementHotResp, 0)
  2612. }
  2613. if len(listHzResource) == 0 {
  2614. listHzResource = make([]*models.IndustrialManagementHotResp, 0)
  2615. }
  2616. if keyWord != "" {
  2617. keyWordItem := new(models.CygxUserSearchKeyWord)
  2618. keyWordItem.UserId = user.UserId
  2619. keyWordItem.KeyWord = keyWord
  2620. keyWordItem.PageType = "ReortSearch"
  2621. keyWordItem.CreateTime = time.Now()
  2622. go models.AddUserSearchKeyWord(keyWordItem)
  2623. go services.AddUserSearchLog(user, keyWord, 5)
  2624. }
  2625. resp.ListHzResource = listHzResource
  2626. resp.ListYxResource = listYxResource
  2627. resp.ListYxReport = ListYxReport
  2628. resp.ListHzReport = ListHzReport
  2629. br.Ret = 200
  2630. br.Success = true
  2631. br.Msg = "获取成功"
  2632. br.Data = resp
  2633. }