report.go 84 KB

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