report.go 84 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698
  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 >= 50`
  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.YanXuan_Explain = true
  1191. resp.IsShowFreeButton = IsShowFreeButton
  1192. mobile := user.Mobile
  1193. if mobile == "" {
  1194. br.Ret = 200
  1195. br.Success = true
  1196. br.Data = resp
  1197. return
  1198. }
  1199. total, _ := models.GetUserIsAdminCount(mobile)
  1200. if total > 0 {
  1201. resp.IsShowList = true
  1202. }
  1203. resp.SearchTxtList.SummarySearch = "全局搜索"
  1204. resp.SearchTxtList.ReportSearch = "全局搜索"
  1205. resp.SearchTxtList.YanXuanSearch = "全局搜索"
  1206. resp.SearchTxtList.ActivitySearch = "全局搜索"
  1207. resp.SearchTxtList.TabSearch = "请输入关键词"
  1208. resp.IsShow = true
  1209. br.Ret = 200
  1210. br.Success = true
  1211. br.Data = resp
  1212. }
  1213. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1214. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1215. // @Param PageSize query int true "每页数据条数"
  1216. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1217. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1218. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1219. // @router /reportList/byType [get]
  1220. func (this *ReportController) ReportListByType() {
  1221. br := new(models.BaseResponse).Init()
  1222. defer func() {
  1223. this.Data["json"] = br
  1224. this.ServeJSON()
  1225. }()
  1226. user := this.User
  1227. if user == nil {
  1228. br.Msg = "请重新登录"
  1229. br.Ret = 408
  1230. return
  1231. }
  1232. uid := user.UserId
  1233. pageSize, _ := this.GetInt("PageSize")
  1234. currentIndex, _ := this.GetInt("CurrentIndex")
  1235. reportType := this.GetString("ReportType")
  1236. var condition string
  1237. var startSize int
  1238. if pageSize <= 0 {
  1239. pageSize = utils.PageSize20
  1240. }
  1241. if currentIndex <= 0 {
  1242. currentIndex = 1
  1243. }
  1244. startSize = paging.StartIndex(currentIndex, pageSize)
  1245. var pars []interface{}
  1246. var total int
  1247. resp := new(models.CygxReportSelectionListPublicRep)
  1248. page := paging.GetPaging(currentIndex, pageSize, total)
  1249. var tbdb string
  1250. var readSql string
  1251. var reportTypeStr string
  1252. if reportType == "1" {
  1253. tbdb = "cygx_report_selection"
  1254. reportTypeStr = "bgjx"
  1255. } else if reportType == "2" {
  1256. tbdb = "cygx_research_summary"
  1257. reportTypeStr = "bzyjhz"
  1258. } else if reportType == "3" {
  1259. tbdb = "cygx_minutes_summary"
  1260. reportTypeStr = "szjyhz"
  1261. } else {
  1262. br.Msg = "请选择报告类型"
  1263. return
  1264. }
  1265. fmt.Println(tbdb)
  1266. condition = ` AND publish_status = 1 `
  1267. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1268. if err != nil {
  1269. br.Msg = "获取信息失败"
  1270. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1271. return
  1272. }
  1273. //研究汇总--报告精选 只显示最新一期,往期都隐藏
  1274. if reportType == "1" {
  1275. startSize = 0
  1276. pageSize = 1
  1277. total = 1
  1278. }
  1279. 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`
  1280. page = paging.GetPaging(currentIndex, pageSize, total)
  1281. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1282. if err != nil {
  1283. br.Msg = "获取失败"
  1284. br.ErrMsg = "获取失败,Err:" + err.Error()
  1285. return
  1286. }
  1287. for k, v := range list {
  1288. if reportType == "1" {
  1289. list[k].Abstract = v.UpdateDescription
  1290. }
  1291. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1292. if v.ReadNum == 0 {
  1293. list[k].IsRed = true
  1294. }
  1295. }
  1296. resp.List = list
  1297. resp.Paging = page
  1298. br.Ret = 200
  1299. br.Success = true
  1300. br.Msg = "获取成功"
  1301. br.Data = resp
  1302. }
  1303. // @Title 获取报告精选详情
  1304. // @Description 获取报告精选详情接口
  1305. // @Param ArticleId query int true "报告ID"
  1306. // @Success 200 {object} models.ReportSelectionLetailResp
  1307. // @router /reportSelection/detail [get]
  1308. func (this *ReportController) Detail() {
  1309. br := new(models.BaseResponse).Init()
  1310. defer func() {
  1311. this.Data["json"] = br
  1312. this.ServeJSON()
  1313. }()
  1314. user := this.User
  1315. if user == nil {
  1316. br.Msg = "请重新登录"
  1317. br.Ret = 408
  1318. return
  1319. }
  1320. uid := user.UserId
  1321. articleId, _ := this.GetInt("ArticleId")
  1322. if articleId < 0 {
  1323. br.Msg = "参数错误"
  1324. br.ErrMsg = "参数错误"
  1325. return
  1326. }
  1327. resp := new(models.ReportSelectionLetailResp)
  1328. //判断用户权限
  1329. hasPermission, err := services.GetUserhasPermission(user)
  1330. if err != nil {
  1331. br.Msg = "获取信息失败"
  1332. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1333. }
  1334. resp.HasPermission = hasPermission
  1335. if hasPermission != 1 {
  1336. br.Ret = 200
  1337. br.Success = true
  1338. br.Msg = "获取成功"
  1339. br.Data = resp
  1340. return
  1341. }
  1342. detail, err := models.GetCygxReportSelectionInfoById(articleId)
  1343. if err != nil {
  1344. br.Msg = "获取信息失败"
  1345. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1346. return
  1347. }
  1348. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1349. existMap := make(map[int]int)
  1350. var items []*models.ReportSelectionChartPermission
  1351. listLog, err := models.GetReportSelectionlogListAll(articleId)
  1352. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1353. if err != nil {
  1354. br.Msg = "获取失败"
  1355. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1356. return
  1357. }
  1358. //var itemLogs []*models.CygxReportSelectionLogDetail
  1359. for _, v := range listLog {
  1360. item := new(models.ReportSelectionChartPermission)
  1361. if existMap[v.ChartPermissionId] == 0 {
  1362. item.PermissionName = v.PermissionName + "领域深度报告和调研"
  1363. item.IcoLink = v.IcoLink
  1364. listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
  1365. if err != nil && err.Error() != utils.ErrNoRow() {
  1366. br.Msg = "获取信息失败"
  1367. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1368. return
  1369. }
  1370. for k2, v2 := range listSonLog {
  1371. if v2.IndustrialManagementId != "" {
  1372. listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
  1373. if err != nil && err.Error() != utils.ErrNoRow() {
  1374. br.Msg = "获取信息失败"
  1375. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1376. return
  1377. }
  1378. listSonLog[k2].List = listIndustrial
  1379. }
  1380. }
  1381. item.List = listSonLog
  1382. items = append(items, item)
  1383. //itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
  1384. }
  1385. existMap[v.ChartPermissionId] = v.ChartPermissionId
  1386. }
  1387. historyRecord := new(models.CygxReportHistoryRecord)
  1388. historyRecord.UserId = uid
  1389. historyRecord.ArticleId = articleId
  1390. historyRecord.CreateTime = time.Now()
  1391. historyRecord.Mobile = user.Mobile
  1392. historyRecord.Email = user.Email
  1393. historyRecord.CompanyId = user.CompanyId
  1394. historyRecord.CompanyName = user.CompanyName
  1395. historyRecord.ReportType = "bgjx"
  1396. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1397. if err != nil && err.Error() != utils.ErrNoRow() {
  1398. br.Msg = "获取信息失败"
  1399. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1400. return
  1401. }
  1402. historyRecord.RealName = user.RealName
  1403. if sellerItem != nil {
  1404. historyRecord.SellerName = sellerItem.RealName
  1405. }
  1406. go models.AddCygxReportHistoryRecord(historyRecord)
  1407. resp.List = items
  1408. resp.Detail = detail
  1409. br.Ret = 200
  1410. br.Success = true
  1411. br.Msg = "获取成功"
  1412. br.Data = resp
  1413. }
  1414. // @Title 获取本周研究汇总详情
  1415. // @Description 获取本周研究汇总详情接口
  1416. // @Param ArticleId query int true "报告ID"
  1417. // @Success 200 {object} models.ResearchSummaryLetailResp
  1418. // @router /researchSummary/detail [get]
  1419. func (this *ReportController) ResearchDetail() {
  1420. br := new(models.BaseResponse).Init()
  1421. defer func() {
  1422. this.Data["json"] = br
  1423. this.ServeJSON()
  1424. }()
  1425. user := this.User
  1426. if user == nil {
  1427. br.Msg = "请重新登录"
  1428. br.Ret = 408
  1429. return
  1430. }
  1431. uid := user.UserId
  1432. articleId, _ := this.GetInt("ArticleId")
  1433. if articleId < 0 {
  1434. br.Msg = "参数错误"
  1435. br.ErrMsg = "参数错误"
  1436. return
  1437. }
  1438. resp := new(models.ResearchSummaryLetailResp)
  1439. //判断用户权限
  1440. hasPermission, err := services.GetUserhasPermission(user)
  1441. if err != nil {
  1442. br.Msg = "获取信息失败"
  1443. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1444. }
  1445. resp.HasPermission = hasPermission
  1446. if hasPermission != 1 {
  1447. br.Ret = 200
  1448. br.Success = true
  1449. br.Msg = "获取成功"
  1450. br.Data = resp
  1451. return
  1452. }
  1453. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1454. if err != nil {
  1455. br.Msg = "获取信息失败"
  1456. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1457. return
  1458. }
  1459. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1460. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1461. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1462. if err != nil {
  1463. br.Msg = "获取失败"
  1464. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1465. return
  1466. }
  1467. listArticleType, err := models.GetCygxArticleTypeList()
  1468. if err != nil {
  1469. br.Msg = "获取失败"
  1470. br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
  1471. return
  1472. }
  1473. for k, v := range listFirst {
  1474. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1475. if err != nil && err.Error() != utils.ErrNoRow() {
  1476. br.Msg = "获取信息失败"
  1477. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1478. return
  1479. }
  1480. for k2, v2 := range listSecond {
  1481. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1482. if err != nil && err.Error() != utils.ErrNoRow() {
  1483. br.Msg = "获取信息失败"
  1484. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1485. return
  1486. }
  1487. for _, vType := range listArticleType {
  1488. if v2.ChartPermissionId == vType.YanxPermissionId {
  1489. listSecond[k2].IcoLink = vType.IcoLinkM
  1490. listSecond[k2].PermissionName = vType.YanxPermissionName
  1491. }
  1492. }
  1493. //if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
  1494. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1495. // listSecond[k2].PermissionName = "买方研选纪要"
  1496. //} else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
  1497. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1498. // listSecond[k2].PermissionName = "买方研选观点"
  1499. //}
  1500. if len(listThird) > 0 {
  1501. for k3, v3 := range listThird {
  1502. if v3.VideoUrl != "" {
  1503. listThird[k3].IsHaveVideo = true
  1504. }
  1505. if v3.ReportLink == "0" {
  1506. listThird[k3].ReportLink = ""
  1507. }
  1508. }
  1509. listSecond[k2].List = listThird
  1510. }
  1511. }
  1512. if len(listSecond) > 0 {
  1513. listFirst[k].List = listSecond
  1514. }
  1515. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1516. if v.Type == "SDBG" {
  1517. listFirst[k].ListName = "深度报告"
  1518. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1519. } else if v.Type == "BZCHJH" {
  1520. listFirst[k].ListName = "本周晨会精华"
  1521. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1522. } else if v.Type == "CYDYJY" {
  1523. listFirst[k].ListName = "产业调研纪要"
  1524. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1525. } else if v.Type == "SSGS" {
  1526. listFirst[k].ListName = "上市公司调研纪要篇"
  1527. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1528. } else if v.Type == "SJDP" {
  1529. listFirst[k].ListName = "事件点评"
  1530. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1531. } else if v.Type == "YANX" {
  1532. listFirst[k].ListName = "买方研选"
  1533. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1534. }
  1535. }
  1536. historyRecord := new(models.CygxReportHistoryRecord)
  1537. historyRecord.UserId = uid
  1538. historyRecord.ArticleId = articleId
  1539. historyRecord.CreateTime = time.Now()
  1540. historyRecord.Mobile = user.Mobile
  1541. historyRecord.Email = user.Email
  1542. historyRecord.CompanyId = user.CompanyId
  1543. historyRecord.CompanyName = user.CompanyName
  1544. historyRecord.ReportType = "bzyjhz"
  1545. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1546. if err != nil && err.Error() != utils.ErrNoRow() {
  1547. br.Msg = "获取信息失败"
  1548. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1549. return
  1550. }
  1551. historyRecord.RealName = user.RealName
  1552. if sellerItem != nil {
  1553. historyRecord.SellerName = sellerItem.RealName
  1554. }
  1555. go models.AddCygxReportHistoryRecord(historyRecord)
  1556. resp.List = listFirst
  1557. resp.Detail = detail
  1558. br.Ret = 200
  1559. br.Success = true
  1560. br.Msg = "获取成功"
  1561. br.Data = resp
  1562. }
  1563. // @Title 上周纪要汇总内容详情
  1564. // @Description 获取上周纪要汇总内容详情接口
  1565. // @Param ArticleId query int true "报告ID"
  1566. // @Success 200 {object} models.MinutesSummaryLetailResp
  1567. // @router /minutesSummary/detailv4 [get]
  1568. func (this *ReportController) MinutesDetailV4() {
  1569. br := new(models.BaseResponse).Init()
  1570. defer func() {
  1571. this.Data["json"] = br
  1572. this.ServeJSON()
  1573. }()
  1574. user := this.User
  1575. if user == nil {
  1576. br.Msg = "请重新登录"
  1577. br.Ret = 408
  1578. return
  1579. }
  1580. uid := user.UserId
  1581. articleId, _ := this.GetInt("ArticleId")
  1582. if articleId < 0 {
  1583. br.Msg = "参数错误"
  1584. br.ErrMsg = "参数错误"
  1585. return
  1586. }
  1587. resp := new(models.MinutesSummaryLetailRespV4)
  1588. //判断用户权限
  1589. hasPermission, err := services.GetUserhasPermission(user)
  1590. if err != nil {
  1591. br.Msg = "获取信息失败"
  1592. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1593. }
  1594. resp.HasPermission = hasPermission
  1595. if hasPermission != 1 {
  1596. br.Ret = 200
  1597. br.Success = true
  1598. br.Msg = "获取成功"
  1599. br.Data = resp
  1600. return
  1601. }
  1602. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1603. if err != nil {
  1604. br.Msg = "获取信息失败"
  1605. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1606. return
  1607. }
  1608. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1609. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1610. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1611. if err != nil {
  1612. br.Msg = "获取失败"
  1613. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1614. return
  1615. }
  1616. for k, v := range listFirst {
  1617. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1618. if err != nil && err.Error() != utils.ErrNoRow() {
  1619. br.Msg = "获取信息失败"
  1620. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1621. return
  1622. }
  1623. for k2, v2 := range listSecond {
  1624. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1625. if err != nil && err.Error() != utils.ErrNoRow() {
  1626. br.Msg = "获取信息失败"
  1627. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1628. return
  1629. }
  1630. if len(listThird) > 0 {
  1631. for k3, v3 := range listThird {
  1632. if v3.VideoUrl != "" {
  1633. listThird[k3].IsHaveVideo = true
  1634. }
  1635. if v3.ReportLink == "0" {
  1636. listThird[k3].ReportLink = ""
  1637. }
  1638. }
  1639. listSecond[k2].List = listThird
  1640. }
  1641. }
  1642. if len(listSecond) > 0 {
  1643. listFirst[k].List = listSecond
  1644. }
  1645. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1646. if v.Type == "CYDYJY" {
  1647. listFirst[k].ListName = "产业调研纪要"
  1648. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1649. } else if v.Type == "SSGS" {
  1650. listFirst[k].ListName = "上市公司调研纪要篇"
  1651. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1652. } else if v.Type == "YANX" {
  1653. listFirst[k].ListName = "买方研选纪要"
  1654. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1655. }
  1656. }
  1657. historyRecord := new(models.CygxReportHistoryRecord)
  1658. historyRecord.UserId = uid
  1659. historyRecord.ArticleId = articleId
  1660. historyRecord.CreateTime = time.Now()
  1661. historyRecord.Mobile = user.Mobile
  1662. historyRecord.Email = user.Email
  1663. historyRecord.CompanyId = user.CompanyId
  1664. historyRecord.CompanyName = user.CompanyName
  1665. historyRecord.ReportType = "szjyhz"
  1666. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1667. if err != nil && err.Error() != utils.ErrNoRow() {
  1668. br.Msg = "获取信息失败"
  1669. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1670. return
  1671. }
  1672. historyRecord.RealName = user.RealName
  1673. if sellerItem != nil {
  1674. historyRecord.SellerName = sellerItem.RealName
  1675. }
  1676. go models.AddCygxReportHistoryRecord(historyRecord)
  1677. resp.List = listFirst
  1678. resp.Detail = detail
  1679. br.Ret = 200
  1680. br.Success = true
  1681. br.Msg = "获取成功"
  1682. br.Data = resp
  1683. }
  1684. // @Title 上周纪要汇总内容详情
  1685. // @Description 获取上周纪要汇总内容详情接口
  1686. // @Param ArticleId query int true "报告ID"
  1687. // @Success 200 {object} models.MinutesSummaryLetailResp
  1688. // @router /minutesSummary/detail [get]
  1689. func (this *ReportController) MinutesDetail() {
  1690. br := new(models.BaseResponse).Init()
  1691. defer func() {
  1692. this.Data["json"] = br
  1693. this.ServeJSON()
  1694. }()
  1695. user := this.User
  1696. if user == nil {
  1697. br.Msg = "请重新登录"
  1698. br.Ret = 408
  1699. return
  1700. }
  1701. uid := user.UserId
  1702. articleId, _ := this.GetInt("ArticleId")
  1703. if articleId < 0 {
  1704. br.Msg = "参数错误"
  1705. br.ErrMsg = "参数错误"
  1706. return
  1707. }
  1708. resp := new(models.MinutesSummaryLetailResp)
  1709. //判断用户权限
  1710. hasPermission, err := services.GetUserhasPermission(user)
  1711. if err != nil {
  1712. br.Msg = "获取信息失败"
  1713. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1714. }
  1715. resp.HasPermission = hasPermission
  1716. if hasPermission != 1 {
  1717. br.Ret = 200
  1718. br.Success = true
  1719. br.Msg = "获取成功"
  1720. br.Data = resp
  1721. return
  1722. }
  1723. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1724. if err != nil {
  1725. br.Msg = "获取信息失败"
  1726. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1727. return
  1728. }
  1729. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1730. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1731. listLog, err := models.GetMinutesSummarylogListAll(articleId)
  1732. if err != nil {
  1733. br.Msg = "获取失败"
  1734. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1735. return
  1736. }
  1737. for k, v := range listLog {
  1738. listSonLog, err := models.GetMinutesSummarylogSonListAll(articleId, v.ChartPermissionId)
  1739. if err != nil && err.Error() != utils.ErrNoRow() {
  1740. br.Msg = "获取信息失败"
  1741. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1742. return
  1743. }
  1744. if len(listSonLog) > 0 {
  1745. listLog[k].List = listSonLog
  1746. for k2, v2 := range listSonLog {
  1747. if v2.ReportLink == "0" {
  1748. listSonLog[k2].ReportLink = ""
  1749. }
  1750. }
  1751. }
  1752. }
  1753. historyRecord := new(models.CygxReportHistoryRecord)
  1754. historyRecord.UserId = uid
  1755. historyRecord.ArticleId = articleId
  1756. historyRecord.CreateTime = time.Now()
  1757. historyRecord.Mobile = user.Mobile
  1758. historyRecord.Email = user.Email
  1759. historyRecord.CompanyId = user.CompanyId
  1760. historyRecord.CompanyName = user.CompanyName
  1761. historyRecord.ReportType = "szjyhz"
  1762. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1763. if err != nil && err.Error() != utils.ErrNoRow() {
  1764. br.Msg = "获取信息失败"
  1765. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1766. return
  1767. }
  1768. historyRecord.RealName = user.RealName
  1769. if sellerItem != nil {
  1770. historyRecord.SellerName = sellerItem.RealName
  1771. }
  1772. go models.AddCygxReportHistoryRecord(historyRecord)
  1773. resp.List = listLog
  1774. resp.Detail = detail
  1775. br.Ret = 200
  1776. br.Success = true
  1777. br.Msg = "获取成功"
  1778. br.Data = resp
  1779. }
  1780. // @Title 获取路演精华详情
  1781. // @Description 获取路演精华详情接口
  1782. // @Param ArticleId query int true "报告ID"
  1783. // @Success 200 {object} models.RoadshowDetailResp
  1784. // @router /roadshowEssence/detail [get]
  1785. func (this *ReportController) RoadshowDetail() {
  1786. br := new(models.BaseResponse).Init()
  1787. defer func() {
  1788. this.Data["json"] = br
  1789. this.ServeJSON()
  1790. }()
  1791. user := this.User
  1792. if user == nil {
  1793. br.Msg = "请登录"
  1794. br.ErrMsg = "请登录,用户信息为空"
  1795. br.Ret = 408
  1796. return
  1797. }
  1798. uid := user.UserId
  1799. articleId, err := this.GetInt("ArticleId")
  1800. if articleId <= 0 {
  1801. br.Msg = "文章不存在"
  1802. br.ErrMsg = "文章不存在,文章ID错误"
  1803. return
  1804. }
  1805. detail := new(models.ReportDetailRoadshow)
  1806. hasPermission := 0
  1807. hasFree := 0
  1808. //判断是否已经申请过
  1809. applyCount, err := models.GetApplyRecordCount(uid)
  1810. if err != nil && err.Error() != utils.ErrNoRow() {
  1811. br.Msg = "获取信息失败"
  1812. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1813. return
  1814. }
  1815. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  1816. if user.CompanyId > 1 {
  1817. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  1818. if err != nil {
  1819. br.Msg = "获取信息失败"
  1820. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1821. return
  1822. }
  1823. detail, err = models.GetReportRoadshowDetailById(articleId)
  1824. if err != nil {
  1825. br.Msg = "获取信息失败"
  1826. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1827. return
  1828. }
  1829. detail.Body = html.UnescapeString(detail.Body)
  1830. detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
  1831. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1832. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1833. if detail.ReportLink == "0" {
  1834. detail.ReportLink = ""
  1835. }
  1836. if companyPermission == "" {
  1837. if applyCount > 0 {
  1838. hasPermission = 5
  1839. } else {
  1840. hasPermission = 2
  1841. }
  1842. hasFree = 2
  1843. goto Loop
  1844. } else {
  1845. hasFree = 1
  1846. var articlePermissionPermissionName string
  1847. articlePermissionPermissionName = detail.CategoryName
  1848. var hasPersion bool
  1849. slice := strings.Split(articlePermissionPermissionName, ",")
  1850. for _, v := range slice {
  1851. if strings.Contains(companyPermission, v) {
  1852. hasPersion = true
  1853. }
  1854. }
  1855. if hasPersion {
  1856. hasPermission = 1
  1857. historyRecord := new(models.CygxArticleHistoryRecord)
  1858. historyRecord.UserId = uid
  1859. historyRecord.ArticleId = articleId
  1860. historyRecord.CreateTime = time.Now()
  1861. historyRecord.Mobile = user.Mobile
  1862. historyRecord.Email = user.Email
  1863. historyRecord.CompanyId = user.CompanyId
  1864. historyRecord.CompanyName = user.CompanyName
  1865. go models.AddCygxArticleHistoryRecord(historyRecord)
  1866. } else { //无该行业权限
  1867. hasPermission = 3
  1868. }
  1869. if hasPermission == 1 {
  1870. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  1871. if !utils.Rc.IsExist(key) {
  1872. //新增浏览记录
  1873. record := new(models.CygxArticleViewRecord)
  1874. record.UserId = uid
  1875. record.ArticleId = articleId
  1876. record.CreateTime = time.Now()
  1877. record.Mobile = user.Mobile
  1878. record.Email = user.Email
  1879. record.CompanyId = user.CompanyId
  1880. record.CompanyName = user.CompanyName
  1881. go models.AddCygxArticleViewRecord(record)
  1882. utils.Rc.Put(key, 1, 5*time.Second)
  1883. models.ModifyReportLastViewTime(uid)
  1884. }
  1885. }
  1886. }
  1887. } else { //潜在客户
  1888. if applyCount > 0 {
  1889. hasPermission = 5
  1890. } else {
  1891. hasPermission = 4
  1892. }
  1893. }
  1894. Loop:
  1895. if hasPermission != 1 {
  1896. detail.Body = ""
  1897. detail.Abstract = ""
  1898. }
  1899. resp := new(models.RoadshowDetailResp)
  1900. resp.HasPermission = hasPermission
  1901. resp.HasFree = hasFree
  1902. resp.Detail = detail
  1903. br.Ret = 200
  1904. br.Success = true
  1905. br.Msg = "获取成功"
  1906. br.Data = resp
  1907. }
  1908. // @Title 产业文章列表接口
  1909. // @Description 获取产业文章列表接口
  1910. // @Param KeyWord query string true "搜索关键词"
  1911. // @Success 200 {object} models.CygxIndustrySearchList
  1912. // @router /industryAndArticle/list [get]
  1913. func (this *ReportController) IndustryAndArticleList() {
  1914. br := new(models.BaseResponse).Init()
  1915. defer func() {
  1916. this.Data["json"] = br
  1917. this.ServeJSON()
  1918. }()
  1919. user := this.User
  1920. if user == nil {
  1921. br.Msg = "请重新登录"
  1922. br.Ret = 408
  1923. return
  1924. }
  1925. uid := user.UserId
  1926. keyWord := this.GetString("KeyWord")
  1927. orderSrt := "update_time DESC"
  1928. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  1929. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  1930. if err != nil {
  1931. br.Msg = "获取信息失败"
  1932. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1933. return
  1934. }
  1935. for k, v := range list {
  1936. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  1937. if err != nil {
  1938. br.Msg = "获取信息失败"
  1939. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1940. return
  1941. }
  1942. list[k].IndustrialSubjectList = industrialSubjectList
  1943. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  1944. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  1945. if err != nil {
  1946. br.Msg = "获取信息失败"
  1947. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1948. return
  1949. }
  1950. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  1951. }
  1952. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  1953. if err != nil {
  1954. br.Msg = "获取失败"
  1955. br.ErrMsg = "获取失败,Err:" + err.Error()
  1956. return
  1957. }
  1958. for k2, v2 := range artList {
  1959. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  1960. if err != nil {
  1961. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  1962. br.ErrMsg = "获取失败,Err:" + err.Error()
  1963. return
  1964. }
  1965. var subjectNamesNew string
  1966. if len(subjectNames) > 0 {
  1967. slice := strings.Split(subjectNames, "/")
  1968. for k3, v3 := range slice {
  1969. if k3 < 4 {
  1970. subjectNamesNew += v3 + "/"
  1971. }
  1972. }
  1973. }
  1974. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  1975. if err != nil && err.Error() != utils.ErrNoRow() {
  1976. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  1977. br.ErrMsg = "获取失败,Err:" + err.Error()
  1978. return
  1979. }
  1980. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1981. artList[k2].SubjectName = subjectNamesNew
  1982. if subjectNamesNew == "" {
  1983. artList[k2].IndustryName = industryName
  1984. } else {
  1985. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  1986. }
  1987. }
  1988. if keyWord != "" {
  1989. keyWordItem := new(models.CygxUserSearchKeyWord)
  1990. keyWordItem.UserId = user.UserId
  1991. keyWordItem.KeyWord = keyWord
  1992. keyWordItem.PageType = "ReortSearch"
  1993. keyWordItem.CreateTime = time.Now()
  1994. go models.AddUserSearchKeyWord(keyWordItem)
  1995. }
  1996. resp := new(models.CygxIndustrySearchList)
  1997. resp.ArtList = artList
  1998. resp.IndList = list
  1999. br.Ret = 200
  2000. br.Success = true
  2001. br.Msg = "获取成功"
  2002. br.Data = resp
  2003. }
  2004. // @Title 产业报告分类关联作者列表接口Pc端
  2005. // @Description 获取产业报告分类关联作者列表接口Pc端
  2006. // @Param ChartPermissionId query int true "分类ID"
  2007. // @Param KeyWord query string true "搜索关键词"
  2008. // @Param PageSize query int true "每页数据条数"
  2009. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2010. // @Success 200 {object} models.CygxArticleDepartmentListPc
  2011. // @router /industryListByDepartmentPc [get]
  2012. func (this *ReportController) IndustryListByDepartmentPc() {
  2013. br := new(models.BaseResponse).Init()
  2014. defer func() {
  2015. this.Data["json"] = br
  2016. this.ServeJSON()
  2017. }()
  2018. user := this.User
  2019. if user == nil {
  2020. br.Msg = "请重新登录"
  2021. br.Ret = 408
  2022. return
  2023. }
  2024. uid := user.UserId
  2025. pageSize, _ := this.GetInt("PageSize")
  2026. currentIndex, _ := this.GetInt("CurrentIndex")
  2027. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  2028. keyWord := this.GetString("KeyWord")
  2029. var startSize int
  2030. var condition string
  2031. condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  2032. if pageSize <= 0 {
  2033. pageSize = utils.PageSize20
  2034. }
  2035. if currentIndex <= 0 {
  2036. currentIndex = 1
  2037. }
  2038. var articleIdGroup string
  2039. if keyWord != "" {
  2040. //获取标的关联的文章ID
  2041. articleIdSub, err := models.GetArticleIdSubjectGroup(keyWord)
  2042. if err != nil {
  2043. br.Msg = "获取信息失败"
  2044. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2045. return
  2046. }
  2047. //获取产业关联的标的
  2048. articleIdInd, err := models.GetArticleIndustrialIdGroup(keyWord)
  2049. if err != nil {
  2050. br.Msg = "获取信息失败"
  2051. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  2052. return
  2053. }
  2054. if articleIdSub != "" && articleIdInd != "" {
  2055. articleIdGroup = articleIdSub + "," + articleIdInd
  2056. } else if articleIdSub != "" && articleIdInd == "" {
  2057. articleIdGroup = articleIdSub
  2058. } else if articleIdSub == "" && articleIdInd != "" {
  2059. articleIdGroup = articleIdInd
  2060. }
  2061. slice := strings.Split(keyWord, "/")
  2062. if len(slice) > 1 {
  2063. var subjectIds string
  2064. for _, v := range slice {
  2065. subjectId, err := models.GetcygxIndustrialSubjectByName(v)
  2066. if err != nil && err.Error() != utils.ErrNoRow() {
  2067. br.Msg = "获取信息失败"
  2068. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  2069. return
  2070. }
  2071. if subjectId != "" {
  2072. subjectIds += subjectId + ","
  2073. }
  2074. }
  2075. subjectIds = strings.TrimRight(subjectIds, ",")
  2076. if len(subjectIds) > 0 {
  2077. articleBySub, err := models.GetArticleIdsBySubId(subjectIds)
  2078. if err != nil {
  2079. br.Msg = "获取信息失败"
  2080. br.ErrMsg = "获取文章关联的标的失败,Err:" + err.Error()
  2081. return
  2082. }
  2083. if articleIdGroup != "" {
  2084. if articleBySub != "" {
  2085. articleIdGroup += "," + articleBySub
  2086. }
  2087. } else {
  2088. articleIdGroup = articleBySub
  2089. }
  2090. }
  2091. }
  2092. }
  2093. if articleIdGroup != "" {
  2094. condition += ` AND a.article_id IN (` + articleIdGroup + `)`
  2095. }
  2096. startSize = paging.StartIndex(currentIndex, pageSize)
  2097. total, err := models.GetArticleDepartmentCount(condition)
  2098. page := paging.GetPaging(currentIndex, pageSize, total)
  2099. resp := new(models.CygxArticleDepartmentListPc)
  2100. userType, _, err := services.GetUserType(user.CompanyId)
  2101. if err != nil {
  2102. br.Msg = "获取信息失败"
  2103. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  2104. return
  2105. }
  2106. if userType == 1 {
  2107. resp.Paging = page
  2108. br.Ret = 200
  2109. br.Success = true
  2110. br.Msg = "获取成功"
  2111. br.Data = resp
  2112. return
  2113. }
  2114. resp.HaveResearch = true
  2115. //获取作者信息,并排序
  2116. list, err := models.GetCygxArticleDepartmentListPc(startSize, pageSize, condition, uid)
  2117. if err != nil {
  2118. br.Msg = "获取信息失败"
  2119. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2120. return
  2121. }
  2122. for k, v := range list {
  2123. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIdGroup)
  2124. if err != nil {
  2125. br.Msg = "获取信息失败"
  2126. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2127. return
  2128. }
  2129. for k2, v2 := range artList {
  2130. if artList[k2].IsReport == "1" {
  2131. artList[k2].Title = v2.Title
  2132. } else {
  2133. artList[k2].Title = v2.Title
  2134. }
  2135. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2136. }
  2137. list[k].List = artList
  2138. if v.FollowNum > 0 {
  2139. list[k].IsMyFollow = true
  2140. }
  2141. }
  2142. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  2143. if err != nil {
  2144. br.Msg = "获取信息失败"
  2145. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2146. return
  2147. }
  2148. if len(listnNew) > 0 {
  2149. for _, v := range listnNew {
  2150. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  2151. Management := new(models.IndustrialManagementIdInt)
  2152. if firstStr == 0 {
  2153. Management.IndustryName = v.IndustryName
  2154. } else {
  2155. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  2156. if err != nil {
  2157. br.Msg = "获取信息失败"
  2158. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  2159. return
  2160. }
  2161. var subjectNamesNew string
  2162. for _, v1 := range listSub {
  2163. subjectNamesNew += v1.SubjectName + "/"
  2164. }
  2165. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2166. Management.IndustryName = subjectNamesNew
  2167. }
  2168. Management.IndustrialManagementId = v.IndustrialManagementId
  2169. Management.ArticleId = v.ArticleId
  2170. resp.ListnNew = append(resp.ListnNew, Management)
  2171. }
  2172. }
  2173. resp.List = list
  2174. resp.Paging = page
  2175. br.Ret = 200
  2176. br.Success = true
  2177. br.Msg = "获取成功"
  2178. br.Data = resp
  2179. }
  2180. // @Title 产业文章列表接口Pc端
  2181. // @Description 获取产业文章列表接口Pc端
  2182. // @Param KeyWord query string true "搜索关键词"
  2183. // @Success 200 {object} models.CygxIndustrySearchListPc
  2184. // @router /industryAndArticle/listPc [get]
  2185. func (this *ReportController) IndustryAndArticleListPc() {
  2186. br := new(models.BaseResponse).Init()
  2187. defer func() {
  2188. this.Data["json"] = br
  2189. this.ServeJSON()
  2190. }()
  2191. user := this.User
  2192. if user == nil {
  2193. br.Msg = "请重新登录"
  2194. br.Ret = 408
  2195. return
  2196. }
  2197. uid := user.UserId
  2198. keyWord := this.GetString("KeyWord")
  2199. resp := new(models.CygxIndustrySearchListPc)
  2200. orderSrt := "update_time DESC"
  2201. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2202. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2203. if err != nil {
  2204. br.Msg = "获取信息失败"
  2205. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2206. return
  2207. }
  2208. for k, v := range list {
  2209. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2210. if err != nil {
  2211. br.Msg = "获取信息失败"
  2212. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2213. return
  2214. }
  2215. list[k].IndustrialSubjectList = industrialSubjectList
  2216. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2217. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2218. if err != nil {
  2219. br.Msg = "获取信息失败"
  2220. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2221. return
  2222. }
  2223. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2224. }
  2225. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2226. if err != nil {
  2227. br.Msg = "获取失败"
  2228. br.ErrMsg = "获取失败,Err:" + err.Error()
  2229. return
  2230. }
  2231. if len(artList) > 0 {
  2232. var articleIds string
  2233. for _, v := range artList {
  2234. articleIds += strconv.Itoa(v.ArticleId) + ","
  2235. }
  2236. articleIds = strings.TrimRight(articleIds, ",")
  2237. if articleIds != "" {
  2238. condition = ` AND a.article_id IN (` + articleIds + `)`
  2239. DepartmentList, err := models.GetCygxArticleDepartmentListPc(0, 20, condition, uid)
  2240. if err != nil {
  2241. br.Msg = "获取信息失败"
  2242. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2243. return
  2244. }
  2245. for k, v := range DepartmentList {
  2246. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIds)
  2247. if err != nil {
  2248. br.Msg = "获取信息失败"
  2249. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2250. return
  2251. }
  2252. for k2, v2 := range artList {
  2253. if artList[k2].IsReport == "1" {
  2254. artList[k2].Title = v2.Title
  2255. } else {
  2256. artList[k2].Title = v2.Title
  2257. }
  2258. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2259. }
  2260. DepartmentList[k].List = artList
  2261. if v.FollowNum > 0 {
  2262. DepartmentList[k].IsMyFollow = true
  2263. }
  2264. }
  2265. resp.DepartmentList = DepartmentList
  2266. }
  2267. }
  2268. if keyWord != "" {
  2269. keyWordItem := new(models.CygxUserSearchKeyWord)
  2270. keyWordItem.UserId = user.UserId
  2271. keyWordItem.KeyWord = keyWord
  2272. keyWordItem.PageType = "ReortSearch"
  2273. keyWordItem.CreateTime = time.Now()
  2274. go models.AddUserSearchKeyWord(keyWordItem)
  2275. }
  2276. resp.IndList = list
  2277. br.Ret = 200
  2278. br.Success = true
  2279. br.Msg = "获取成功"
  2280. br.Data = resp
  2281. }
  2282. // @Title 报告搜索
  2283. // @Description 报告搜索接口
  2284. // @Param KeyWord query string true "搜索关键词"
  2285. // @Success 200 {object} models.ReoprtSearchResp
  2286. // @router /searchReport [get]
  2287. func (this *ReportController) SearchReport() {
  2288. br := new(models.BaseResponse).Init()
  2289. defer func() {
  2290. this.Data["json"] = br
  2291. this.ServeJSON()
  2292. }()
  2293. user := this.User
  2294. if user == nil {
  2295. br.Msg = "请重新登录"
  2296. br.Ret = 408
  2297. return
  2298. }
  2299. keyWord := this.GetString("KeyWord")
  2300. var condition string
  2301. var sqlGroup string
  2302. //匹配报告标题、
  2303. 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 `
  2304. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2305. //对应产业名称、标的名称。
  2306. listYx, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
  2307. if err != nil {
  2308. br.Msg = "获取信息失败"
  2309. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2310. return
  2311. }
  2312. for k, v := range listYx {
  2313. listYx[k].Source = 2
  2314. if v.MyCollectNum > 0 {
  2315. listYx[k].IsCollect = true
  2316. }
  2317. }
  2318. listHz, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId)
  2319. if err != nil {
  2320. br.Msg = "获取信息失败"
  2321. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2322. return
  2323. }
  2324. for k, v := range listHz {
  2325. listHz[k].Source = 1
  2326. if v.MyCollectNum > 0 {
  2327. listHz[k].IsCollect = true
  2328. }
  2329. }
  2330. if keyWord != "" {
  2331. keyWordItem := new(models.CygxUserSearchKeyWord)
  2332. keyWordItem.UserId = user.UserId
  2333. keyWordItem.KeyWord = keyWord
  2334. keyWordItem.PageType = "ReortSearch"
  2335. keyWordItem.CreateTime = time.Now()
  2336. go models.AddUserSearchKeyWord(keyWordItem)
  2337. go services.AddUserSearchLog(user, keyWord, 5)
  2338. }
  2339. if len(listYx) == 0 {
  2340. listYx = make([]*models.ArticleCollectionResp, 0)
  2341. }
  2342. if len(listHz) == 0 {
  2343. listHz = make([]*models.ArticleCollectionResp, 0)
  2344. }
  2345. resp := new(models.ReoprtSearchResp)
  2346. resp.ListYx = listYx
  2347. resp.ListHz = listHz
  2348. br.Ret = 200
  2349. br.Success = true
  2350. br.Msg = "获取成功"
  2351. br.Data = resp
  2352. }
  2353. // @Title 资源包搜索
  2354. // @Description 资源包搜索接口
  2355. // @Param KeyWord query string true "搜索关键词"
  2356. // @Success 200 {object} models.SearchResourceResp
  2357. // @router /searchResource [get]
  2358. func (this *ReportController) SearchResource() {
  2359. br := new(models.BaseResponse).Init()
  2360. defer func() {
  2361. this.Data["json"] = br
  2362. this.ServeJSON()
  2363. }()
  2364. user := this.User
  2365. if user == nil {
  2366. br.Msg = "请重新登录"
  2367. br.Ret = 408
  2368. return
  2369. }
  2370. uid := user.UserId
  2371. fllowList, err := models.GetUserFllowIndustrialList(uid)
  2372. if err != nil {
  2373. br.Msg = "获取失败"
  2374. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  2375. return
  2376. }
  2377. fllowMap := make(map[int]int)
  2378. if len(fllowList) > 0 {
  2379. for _, v := range fllowList {
  2380. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  2381. }
  2382. }
  2383. keyWord := this.GetString("KeyWord")
  2384. var condition string
  2385. var conditionOr string
  2386. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2387. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2388. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2389. listHz, err := models.GetSearchResourceList(condition, 0, 0)
  2390. if err != nil {
  2391. br.Msg = "获取信息失败"
  2392. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2393. return
  2394. }
  2395. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2396. conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2397. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2398. listYx, err := models.GetSearchResourceList(condition, 0, 0)
  2399. if err != nil {
  2400. br.Msg = "获取信息失败"
  2401. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2402. return
  2403. }
  2404. //合并产业关联的标的
  2405. listSubjcet, err := models.GetThemeHeatSubjectList("")
  2406. if err != nil {
  2407. br.Msg = "获取信息失败"
  2408. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2409. return
  2410. }
  2411. industrialIdArr := make([]int, 0)
  2412. for k, v := range listHz {
  2413. listHz[k].Source = 1
  2414. if fllowMap[v.IndustrialManagementId] > 0 {
  2415. listHz[k].IsFollw = true
  2416. }
  2417. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2418. }
  2419. for k, v := range listYx {
  2420. listYx[k].Source = 2
  2421. if fllowMap[v.IndustrialManagementId] > 0 {
  2422. listYx[k].IsFollw = true
  2423. }
  2424. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2425. }
  2426. if len(industrialIdArr) > 0 {
  2427. //合并产业关联的标的
  2428. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  2429. if err != nil {
  2430. br.Msg = "获取信息失败"
  2431. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2432. return
  2433. }
  2434. mapIndustrial := make(map[string]int)
  2435. for _, v := range listSubjcet {
  2436. for k2, v2 := range listYx {
  2437. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
  2438. listYx[k2].IndustrialSubjectList = append(listYx[k2].IndustrialSubjectList, v)
  2439. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  2440. }
  2441. }
  2442. for k2, v2 := range listHz {
  2443. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  2444. listHz[k2].IndustrialSubjectList = append(listHz[k2].IndustrialSubjectList, v)
  2445. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  2446. }
  2447. }
  2448. }
  2449. }
  2450. if keyWord != "" {
  2451. keyWordItem := new(models.CygxUserSearchKeyWord)
  2452. keyWordItem.UserId = user.UserId
  2453. keyWordItem.KeyWord = keyWord
  2454. keyWordItem.PageType = "ReortSearch"
  2455. keyWordItem.CreateTime = time.Now()
  2456. go models.AddUserSearchKeyWord(keyWordItem)
  2457. go services.AddUserSearchLog(user, keyWord, 4)
  2458. }
  2459. resp := new(models.SearchResourceResp)
  2460. if len(listYx) == 0 {
  2461. listYx = make([]*models.IndustrialManagementHotResp, 0)
  2462. }
  2463. if len(listHz) == 0 {
  2464. listHz = make([]*models.IndustrialManagementHotResp, 0)
  2465. }
  2466. resp.ListYx = listYx
  2467. resp.ListHz = listHz
  2468. br.Ret = 200
  2469. br.Success = true
  2470. br.Msg = "获取成功"
  2471. br.Data = resp
  2472. }
  2473. // @Title 报告搜索、资源包搜索接口
  2474. // @Description 报告搜索、资源包搜索接口接口
  2475. // @Param KeyWord query string true "搜索关键词"
  2476. // @Param PageSize query int true "每页数据条数"
  2477. // @Success 200 {object} models.SearchReportAndResourceResp
  2478. // @router /searchReportAndResource [get]
  2479. func (this *ReportController) SearchReportAndResource() {
  2480. br := new(models.BaseResponse).Init()
  2481. defer func() {
  2482. this.Data["json"] = br
  2483. this.ServeJSON()
  2484. }()
  2485. user := this.User
  2486. if user == nil {
  2487. br.Msg = "请重新登录"
  2488. br.Ret = 408
  2489. return
  2490. }
  2491. uid := user.UserId
  2492. keyWord := this.GetString("KeyWord")
  2493. pageSize, _ := this.GetInt("PageSize")
  2494. var condition string
  2495. var sqlGroup string
  2496. //匹配报告标题、
  2497. 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 `
  2498. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2499. if pageSize > 0 {
  2500. sqlGroup += ` LIMIT 5 `
  2501. }
  2502. ListYxReport, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
  2503. if err != nil {
  2504. br.Msg = "获取信息失败"
  2505. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2506. return
  2507. }
  2508. for k, v := range ListYxReport {
  2509. ListYxReport[k].Source = 2
  2510. if v.MyCollectNum > 0 {
  2511. ListYxReport[k].IsCollect = true
  2512. }
  2513. }
  2514. ListHzReport, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId)
  2515. if err != nil {
  2516. br.Msg = "获取信息失败"
  2517. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2518. return
  2519. }
  2520. for k, v := range ListHzReport {
  2521. ListHzReport[k].Source = 1
  2522. if v.MyCollectNum > 0 {
  2523. ListHzReport[k].IsCollect = true
  2524. }
  2525. }
  2526. if len(ListYxReport) == 0 {
  2527. ListYxReport = make([]*models.ArticleCollectionResp, 0)
  2528. }
  2529. if len(ListHzReport) == 0 {
  2530. ListHzReport = make([]*models.ArticleCollectionResp, 0)
  2531. }
  2532. fllowList, err := models.GetUserFllowIndustrialList(uid)
  2533. if err != nil {
  2534. br.Msg = "获取失败"
  2535. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  2536. return
  2537. }
  2538. fllowMap := make(map[int]int)
  2539. if len(fllowList) > 0 {
  2540. for _, v := range fllowList {
  2541. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  2542. }
  2543. }
  2544. var conditionOr string
  2545. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2546. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2547. listHzResource, err := models.GetSearchResourceList(condition, 0, pageSize)
  2548. if err != nil {
  2549. br.Msg = "获取信息失败"
  2550. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2551. return
  2552. }
  2553. conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2554. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2555. listYxResource, err := models.GetSearchResourceList(condition, 0, pageSize)
  2556. if err != nil {
  2557. br.Msg = "获取信息失败"
  2558. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2559. return
  2560. }
  2561. //合并产业关联的标的
  2562. listSubjcet, err := models.GetThemeHeatSubjectList("")
  2563. if err != nil {
  2564. br.Msg = "获取信息失败"
  2565. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2566. return
  2567. }
  2568. industrialIdArr := make([]int, 0)
  2569. for k, v := range listHzResource {
  2570. listHzResource[k].Source = 1
  2571. if fllowMap[v.IndustrialManagementId] > 0 {
  2572. listHzResource[k].IsFollw = true
  2573. }
  2574. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2575. }
  2576. for k, v := range listYxResource {
  2577. listYxResource[k].Source = 2
  2578. if fllowMap[v.IndustrialManagementId] > 0 {
  2579. listYxResource[k].IsFollw = true
  2580. }
  2581. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2582. }
  2583. if len(industrialIdArr) > 0 {
  2584. //合并产业关联的标的
  2585. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  2586. if err != nil {
  2587. br.Msg = "获取信息失败"
  2588. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2589. return
  2590. }
  2591. mapIndustrial := make(map[string]int)
  2592. for _, v := range listSubjcet {
  2593. for k2, v2 := range listYxResource {
  2594. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
  2595. listYxResource[k2].IndustrialSubjectList = append(listYxResource[k2].IndustrialSubjectList, v)
  2596. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  2597. }
  2598. }
  2599. for k2, v2 := range listHzResource {
  2600. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  2601. listHzResource[k2].IndustrialSubjectList = append(listHzResource[k2].IndustrialSubjectList, v)
  2602. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  2603. }
  2604. }
  2605. }
  2606. }
  2607. resp := new(models.SearchReportAndResourceResp)
  2608. if len(listYxResource) == 0 {
  2609. listYxResource = make([]*models.IndustrialManagementHotResp, 0)
  2610. }
  2611. if len(listHzResource) == 0 {
  2612. listHzResource = make([]*models.IndustrialManagementHotResp, 0)
  2613. }
  2614. if keyWord != "" {
  2615. keyWordItem := new(models.CygxUserSearchKeyWord)
  2616. keyWordItem.UserId = user.UserId
  2617. keyWordItem.KeyWord = keyWord
  2618. keyWordItem.PageType = "ReortSearch"
  2619. keyWordItem.CreateTime = time.Now()
  2620. go models.AddUserSearchKeyWord(keyWordItem)
  2621. go services.AddUserSearchLog(user, keyWord, 5)
  2622. }
  2623. resp.ListHzResource = listHzResource
  2624. resp.ListYxResource = listYxResource
  2625. resp.ListYxReport = ListYxReport
  2626. resp.ListHzReport = ListHzReport
  2627. br.Ret = 200
  2628. br.Success = true
  2629. br.Msg = "获取成功"
  2630. br.Data = resp
  2631. }