report.go 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_clpt/models"
  6. "hongze/hongze_clpt/services"
  7. "hongze/hongze_clpt/utils"
  8. "strconv"
  9. "strings"
  10. "time"
  11. )
  12. // 报告
  13. type ReportController struct {
  14. BaseAuthController
  15. }
  16. type ReportCommonController struct {
  17. BaseCommonController
  18. }
  19. type MobileReportController struct {
  20. BaseAuthMobileController
  21. }
  22. // @Title 行业报告分类列表接口
  23. // @Description 获取行业报告分类列表接口
  24. // @Param ChartPermissionId query int true "分类ID"
  25. // @Success 200 {object} models.TradeReportMappingResp
  26. // @router /tradeList [get]
  27. func (this *MobileReportController) TradeList() {
  28. br := new(models.BaseResponse).Init()
  29. defer func() {
  30. this.Data["json"] = br
  31. this.ServeJSON()
  32. }()
  33. user := this.User
  34. if user == nil {
  35. br.Msg = "请重新登录"
  36. br.Ret = 408
  37. return
  38. }
  39. //uid := user.UserId
  40. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  41. if ChartPermissionId < 1 {
  42. br.Msg = "请输入分类ID"
  43. return
  44. }
  45. //var result []*models.SearchItem
  46. var list []*models.TradeReportMapping
  47. var err error
  48. mapCategory := make(map[int]int)
  49. mapCategoryFollowType := make(map[int]int)
  50. if ChartPermissionId == utils.CE_LUE_ID || ChartPermissionId == utils.GU_SHOU_ID {
  51. listTrade, errTrade := models.GetReportMappingStrategyHomeAllByCygx(user.UserId, ChartPermissionId)
  52. err = errTrade
  53. if ChartPermissionId == utils.CE_LUE_ID {
  54. cf, err := models.GetConfigByCode(utils.CYGX_TACTICS_TIME_LINE_STATUS)
  55. if err != nil {
  56. br.Msg = "获取失败"
  57. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  58. return
  59. }
  60. if cf.ConfigValue == "1" || user.CompanyId == utils.HZ_COMPANY_ID {
  61. item := new(models.TradeReportMapping)
  62. item.CategoryId = utils.TIME_LINE_ID
  63. item.MatchTypeName = utils.TIME_LINE_NAME
  64. list = append(list, item)
  65. }
  66. }
  67. if ChartPermissionId == utils.GU_SHOU_ID {
  68. cfGushou, err := models.GetConfigByCode(utils.CYGX_GUSHOU_TIME_LINE_STATUS)
  69. if err != nil {
  70. br.Msg = "获取失败"
  71. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  72. return
  73. }
  74. if cfGushou.ConfigValue == "1" || user.CompanyId == utils.HZ_COMPANY_ID {
  75. item := new(models.TradeReportMapping)
  76. item.CategoryId = utils.TIME_LINE_ID
  77. item.MatchTypeName = utils.TIME_LINE_NAME
  78. list = append(list, item)
  79. }
  80. }
  81. for _, v := range listTrade {
  82. list = append(list, v)
  83. }
  84. if user.Mobile != "" {
  85. //策略的处理
  86. categoryList, err := models.GetCygxXzsChooseCategoryList(user.Mobile)
  87. if err != nil && err.Error() != utils.ErrNoRow() {
  88. br.Msg = "获取信息失败"
  89. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  90. return
  91. }
  92. for _, v := range categoryList {
  93. mapCategory[v.IdCygx] = v.IdCygx
  94. mapCategoryFollowType[v.IdCygx] = v.FollowType
  95. }
  96. }
  97. } else {
  98. listCategory, err := models.GetTradeArticleAndProductInterior(ChartPermissionId)
  99. if err != nil {
  100. br.Msg = "获取信息失败"
  101. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  102. return
  103. }
  104. categoryMap := make(map[int]int)
  105. for _, v := range listCategory {
  106. if categoryMap[v.CategoryId] > 0 {
  107. continue
  108. }
  109. categoryMap[v.CategoryId] = v.CategoryId
  110. list = append(list, v)
  111. }
  112. //加了一个需求,现有数据结构不支持,手动添加 2023-06-12
  113. //if ChartPermissionId == utils.KE_JI_ID {
  114. // list = append(list, &models.TradeReportMapping{MatchTypeName: "AI前沿", CategoryId: utils.ACTEGORY_ID_AI_QY})
  115. //}
  116. }
  117. if err != nil {
  118. br.Msg = "获取信息失败"
  119. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  120. return
  121. }
  122. for k, v := range list {
  123. if ChartPermissionId != utils.CE_LUE_ID && ChartPermissionId != utils.GU_SHOU_ID {
  124. var pageSize int
  125. var listArticle []*models.HomeArticle
  126. pageSize = 3
  127. if v.CategoryId == utils.ACTEGORY_ID_AI_QY {
  128. //加了一个需求,现有数据结构不支持,手动添加 2023-06-12
  129. listArticle, _, err = services.GetAiQianYanArtilceList(0, pageSize)
  130. } else {
  131. listArticle, _, err = models.GetReportAndproductIndustrylList(v.CategoryId, 0, pageSize)
  132. }
  133. if err != nil {
  134. br.Msg = "获取信息失败"
  135. br.Msg = "GetHomeList,Err:" + err.Error()
  136. return
  137. }
  138. if len(listArticle) > 0 {
  139. list[k].UpdateTime = utils.StrTimeToTime(listArticle[0].PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
  140. }
  141. list[k].ListArticle = listArticle
  142. } else {
  143. if mapCategory[v.CategoryId] > 0 {
  144. list[k].IsFollow = true
  145. }
  146. list[k].FollowType = mapCategoryFollowType[v.CategoryId]
  147. list[k].ListArticle = make([]*models.HomeArticle, 0)
  148. }
  149. }
  150. resp := new(models.TradeReportMappingResp)
  151. if len(list) == 0 {
  152. list = make([]*models.TradeReportMapping, 0)
  153. }
  154. resp.List = list
  155. br.Ret = 200
  156. br.Success = true
  157. br.Msg = "获取成功"
  158. br.Data = resp
  159. }
  160. // @Title 产业报告分类列表接口
  161. // @Description 获取产业报告分类列表接口
  162. // @Param ChartPermissionId query int true "分类ID"
  163. // @Param DeepCover query int false "是否选择深度覆盖,1是,0否 不填默认为0"
  164. // @Param RecommendFocus query int false "是否选择推荐关注,1是,0否 不填默认为0"
  165. // @Param PageSize query int true "每页数据条数"
  166. // @Param CurrentIndex query int true "当前页页码,从1开始"
  167. // @Param IsBillboard query bool false "是否属于榜单 是true 否 false"
  168. // @Success 200 {object} models.IndustrialManagementList
  169. // @router /industryList [get]
  170. func (this *MobileReportController) IndustryList() {
  171. br := new(models.BaseResponse).Init()
  172. defer func() {
  173. this.Data["json"] = br
  174. this.ServeJSON()
  175. }()
  176. user := this.User
  177. if user == nil {
  178. br.Msg = "请重新登录"
  179. br.Ret = 408
  180. return
  181. }
  182. uid := user.UserId
  183. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  184. orderColumn := this.GetString("OrderColumn")
  185. orderColumnNew := this.GetString("OrderColumn")
  186. isNewLabel := this.GetString("IsNewLabel")
  187. isDeepLabel := this.GetString("IsDeepLabel")
  188. pageSize, _ := this.GetInt("PageSize")
  189. currentIndex, _ := this.GetInt("CurrentIndex")
  190. deepCover, _ := this.GetInt("DeepCover")
  191. recommendFocus, _ := this.GetInt("RecommendFocus")
  192. isBillboard, _ := this.GetBool("IsBillboard", false)
  193. var orderSrt string
  194. var condition string
  195. var startSize int
  196. resp := new(models.IndustrialManagementList)
  197. if pageSize <= 0 {
  198. pageSize = utils.PageSize20
  199. }
  200. if currentIndex <= 0 {
  201. currentIndex = 1
  202. }
  203. startSize = paging.StartIndex(currentIndex, pageSize)
  204. if ChartPermissionId > 0 {
  205. condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
  206. }
  207. // 获取近一个月产业报告阅读次数最多的产业
  208. var topCond string
  209. var topPars []interface{}
  210. topReadIndustryId := 0
  211. if ChartPermissionId > 0 {
  212. topCond += ` AND chart_permission_id = ?`
  213. topPars = append(topPars, ChartPermissionId)
  214. }
  215. topReadIndustry, e := models.GetTopOneMonthArtReadNumIndustry(topCond, topPars)
  216. if e != nil && e.Error() != utils.ErrNoRow() {
  217. br.Msg = "获取信息失败"
  218. br.ErrMsg = "获取近一个月报告阅读次数最多的产业失败, Err: " + e.Error()
  219. return
  220. }
  221. if topReadIndustry != nil {
  222. topReadIndustryId = topReadIndustry.IndustrialManagementId
  223. }
  224. // 深度覆盖
  225. if deepCover == 1 {
  226. // 查询深标签产业报告数
  227. var deepCondition string
  228. var deepPars []interface{}
  229. deepCondition += ` AND man.is_deep_label = 1`
  230. if ChartPermissionId > 0 {
  231. deepCondition += ` AND man.chart_permission_id = ?`
  232. deepPars = append(deepPars, ChartPermissionId)
  233. }
  234. industryCountList, e := models.GetIndustryArtCountByCondition(deepCondition, deepPars)
  235. if e != nil {
  236. br.Msg = "获取信息失败"
  237. br.ErrMsg = "获取深标签产业报告数失败, Err: " + e.Error()
  238. return
  239. }
  240. deepIdArr := make([]string, 0)
  241. for i := range industryCountList {
  242. if industryCountList[i].ArtNum > 10 {
  243. deepIdArr = append(deepIdArr, strconv.Itoa(industryCountList[i].IndustrialManagementId))
  244. }
  245. }
  246. deepIds := strings.Join(deepIdArr, ",")
  247. if deepIds != "" {
  248. condition = `AND man.industrial_management_id IN (` + deepIds + `)`
  249. }
  250. }
  251. // 推荐关注
  252. if recommendFocus == 1 {
  253. condition += ` AND man.recommended_index >= 80`
  254. }
  255. var list []*models.IndustrialManagement
  256. total, err := models.GetIndustrialManagementAllCount(condition)
  257. if err != nil {
  258. br.Msg = "获取信息失败"
  259. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  260. return
  261. }
  262. if orderColumn == "" {
  263. orderColumn = "NewTime"
  264. }
  265. if orderColumn == "NewTime" {
  266. orderSrt = "update_time DESC"
  267. } else {
  268. orderSrt = "man.recommended_index DESC,update_time DESC"
  269. }
  270. if isBillboard {
  271. // 查询有已归类行业报告的行业IDs
  272. activeIndustryIds, e := models.GetActiveArticleIndustryIds()
  273. if e != nil {
  274. br.Msg = "获取失败"
  275. br.ErrMsg = "获取已归类行业失败, Err:" + e.Error()
  276. return
  277. }
  278. activeIndustryLen := len(activeIndustryIds)
  279. //topNum := pageSize
  280. condition = ""
  281. var parsBd []interface{}
  282. if ChartPermissionId > 0 {
  283. condition += ` AND man.chart_permission_id = ? `
  284. parsBd = append(parsBd, ChartPermissionId)
  285. }
  286. if activeIndustryLen > 0 {
  287. condition += ` AND man.industrial_management_id IN (` + utils.GetOrmInReplace(activeIndustryLen) + `)`
  288. parsBd = append(parsBd, activeIndustryIds)
  289. }
  290. //nowTime := time.Now().Local()
  291. //startTime := nowTime.AddDate(0, -1, 0)
  292. //endTime := nowTime.AddDate(0, 0, -1)
  293. //condition += ` AND idf.create_time BETWEEN ? AND ?`
  294. //parsBd = append(parsBd, startTime, endTime)
  295. list, e = models.GetTopIndustryFollowData(uid, 0, pageSize, condition, parsBd)
  296. if e != nil {
  297. br.Msg = "获取失败"
  298. br.ErrMsg = "获取关注度最高的产业数据失败, Err:" + e.Error()
  299. return
  300. }
  301. } else {
  302. list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize, isBillboard)
  303. if err != nil {
  304. br.Msg = "获取信息失败"
  305. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  306. return
  307. }
  308. }
  309. var resource string
  310. if ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  311. resource = utils.REOURCE_YX
  312. } else {
  313. resource = utils.REOURCE_HZ
  314. }
  315. list, err = services.HandleIndustryList(list, user, resource)
  316. if err != nil {
  317. br.Msg = "获取信息失败"
  318. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  319. return
  320. }
  321. industrialIdArr := make([]int, 0)
  322. for k, v := range list {
  323. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  324. if topReadIndustryId > 0 && list[k].IndustrialManagementId == topReadIndustryId {
  325. list[k].IsHot = true
  326. }
  327. }
  328. if orderColumnNew != "" {
  329. item := new(models.CygxReportIndustrialSeaarchHistory)
  330. item.UserId = user.UserId
  331. item.Mobile = user.Mobile
  332. item.CompanyId = user.CompanyId
  333. item.CompanyName = user.CompanyName
  334. item.CreateTime = time.Now()
  335. item.IsDeepLabel = isDeepLabel
  336. item.IsNewLabel = isNewLabel
  337. item.ChartPermissionId = ChartPermissionId
  338. if orderColumnNew == "NewTime" {
  339. item.OrderColumn = "0"
  340. } else {
  341. item.OrderColumn = "1"
  342. }
  343. go models.AddCygxReportIndustrialSeaarchHistory(item)
  344. }
  345. if len(list) == 0 {
  346. list = make([]*models.IndustrialManagement, 0)
  347. }
  348. page := paging.GetPaging(currentIndex, pageSize, total)
  349. if isBillboard {
  350. total = len(list)
  351. }
  352. resp.List = list
  353. resp.Paging = page
  354. br.Ret = 200
  355. br.Success = true
  356. br.Msg = "获取成功"
  357. br.Data = resp
  358. }
  359. // @Title 产业下所关联的文章分类列表
  360. // @Description 产业下所关联的文章分类列表接口
  361. // @Param IndustrialManagementId query int true "产业ID"
  362. // @Success 200 {object} models.IndustrialToArticleCategoryListRep
  363. // @router /toArticleCategoryList [get]
  364. func (this *MobileReportController) ArticleCategoryList() {
  365. br := new(models.BaseResponse).Init()
  366. defer func() {
  367. this.Data["json"] = br
  368. this.ServeJSON()
  369. }()
  370. user := this.User
  371. if user == nil {
  372. br.Msg = "请重新登录"
  373. br.Ret = 408
  374. return
  375. }
  376. //uid := user.UserId
  377. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  378. if industrialManagementId < 1 {
  379. br.Msg = "请输入分类ID"
  380. return
  381. }
  382. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  383. if err != nil {
  384. br.Msg = "获取信息失败"
  385. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  386. return
  387. }
  388. listCategory, err := models.IndustrialToArticleAndProductInteriorCategoryNew(industrialManagementId)
  389. if err != nil {
  390. br.Msg = "获取信息失败"
  391. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  392. return
  393. }
  394. var list []*models.IndustrialToArticleCategoryRep
  395. categoryMap := make(map[int]int)
  396. for _, v := range listCategory {
  397. if categoryMap[v.CategoryId] > 0 {
  398. continue
  399. }
  400. categoryMap[v.CategoryId] = v.CategoryId
  401. list = append(list, v)
  402. }
  403. //标的列表
  404. industrialSubjectList, err := models.GetIndustrialArticleGroupSubjectListByHz(industrialManagementId)
  405. if err != nil {
  406. br.Msg = "获取信息失败"
  407. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  408. return
  409. }
  410. videoSimple, au, err := services.GetindustryVideo(user, industrialManagementId)
  411. if err != nil {
  412. br.Msg = "获取失败"
  413. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  414. return
  415. }
  416. timeLineItem := models.IndustrialToArticleCategoryRep{
  417. CategoryId: utils.TIME_CATEGORYID,
  418. MatchTypeName: "时间线",
  419. }
  420. timeLineIsRed, err := services.GetShowTimeLineIsRed(user, industrialManagementId)
  421. if err != nil {
  422. br.Msg = "获取失败"
  423. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  424. return
  425. }
  426. followTypeMap := services.GetCygxIndustryFllowListTypeMapByMobile(user.Mobile) // 关注的对应状态
  427. timeLineItem.IsRed = timeLineIsRed
  428. list = append([]*models.IndustrialToArticleCategoryRep{&timeLineItem}, list...)
  429. resp := new(models.IndustrialToArticleCategoryListRep)
  430. resp.List = list
  431. resp.ListSubject = industrialSubjectList
  432. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  433. resp.IndustryName = detail.IndustryName
  434. resp.IndustrialManagementId = industrialManagementId
  435. if videoSimple != nil && videoSimple.Id > 0 {
  436. resp.IndustryVideo = videoSimple
  437. }
  438. resp.AuthInfo = au
  439. resp.FollowType = followTypeMap[industrialManagementId]
  440. br.Ret = 200
  441. br.Success = true
  442. br.Msg = "获取成功"
  443. br.Data = resp
  444. }
  445. // @Title 根据行业分类获取文章列表
  446. // @Description根据行业分类获取文章列表接口
  447. // @Param PageSize query int true "每页数据条数"
  448. // @Param CurrentIndex query int true "当前页页码,从1开始"
  449. // @Param CategoryId query int true "分类ID"
  450. // @Param IndustrialManagementId query int false "产业ID"
  451. // @Success 200 {object} models.TacticsListResp
  452. // @router /articleList/byCategoryId [get]
  453. func (this *MobileReportController) List() {
  454. br := new(models.BaseResponse).Init()
  455. defer func() {
  456. this.Data["json"] = br
  457. this.ServeJSON()
  458. }()
  459. user := this.User
  460. if user == nil {
  461. br.Msg = "请重新登录"
  462. br.Ret = 408
  463. return
  464. }
  465. //uid := user.UserId
  466. pageSize, _ := this.GetInt("PageSize")
  467. currentIndex, _ := this.GetInt("CurrentIndex")
  468. categoryId, _ := this.GetInt("CategoryId")
  469. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  470. uid := user.UserId
  471. var startSize int
  472. if pageSize <= 0 {
  473. pageSize = utils.PageSize20
  474. }
  475. if currentIndex <= 0 {
  476. currentIndex = 1
  477. }
  478. startSize = paging.StartIndex(currentIndex, pageSize)
  479. //var condition string
  480. var pars []interface{}
  481. var total int
  482. resp := new(models.TacticsListResp)
  483. page := paging.GetPaging(currentIndex, pageSize, total)
  484. list := make([]*models.ArticleListResp, 0)
  485. if categoryId == utils.TIME_CATEGORYID {
  486. var err error
  487. list, total, err = models.GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize)
  488. if err != nil {
  489. br.Msg = "获取信息失败"
  490. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  491. return
  492. }
  493. } else {
  494. //获取该产业下所对应的行业图片
  495. //var reportType int
  496. //if industrialManagementId > 0 {
  497. // reportType = 2
  498. //} else {
  499. // reportType = 1
  500. //}
  501. //detail, errCategory := models.GetdetailByCategoryIdOne(categoryId, reportType)
  502. //if errCategory != nil {
  503. // br.Msg = "获取信息失败"
  504. // br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  505. // return
  506. //}
  507. //对应行业的图片
  508. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  509. if err != nil {
  510. br.Msg = "获取数据失败"
  511. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  512. return
  513. }
  514. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  515. mapChartPermission := make(map[string]string)
  516. var permissionName string
  517. var imgUrlChartPermission string
  518. for _, v := range chartPermissionUrlList {
  519. vslice := strings.Split(v, "_")
  520. permissionName = vslice[0]
  521. imgUrlChartPermission = vslice[len(vslice)-1]
  522. mapChartPermission[permissionName] = imgUrlChartPermission
  523. }
  524. //对应分类的所图片
  525. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  526. if err != nil {
  527. br.Msg = "获取数据失败"
  528. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  529. return
  530. }
  531. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  532. mapCategoryUrl := make(map[string]string)
  533. var categoryIdStr string
  534. var imgUrlChart string
  535. for _, v := range categoryUrlList {
  536. vslice := strings.Split(v, "_")
  537. categoryIdStr = vslice[0]
  538. imgUrlChart = vslice[len(vslice)-1]
  539. mapCategoryUrl[categoryIdStr] = imgUrlChart
  540. }
  541. list, total, err = models.GetReportAndproductInteriorIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
  542. if err != nil {
  543. br.Msg = "获取信息失败"
  544. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  545. return
  546. }
  547. articleIdMap, err := services.GetUserArticleHistoryRecord(user)
  548. if err != nil {
  549. br.Msg = "获取信息失败"
  550. br.Msg = "获取帖子数据失败,Err:" + err.Error()
  551. return
  552. }
  553. for k, v := range list {
  554. list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  555. if !articleIdMap[v.ArticleId] && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  556. list[k].IsRed = true
  557. }
  558. }
  559. }
  560. listPublic, err := services.HandleArticleCategoryImg(list, user)
  561. if err != nil {
  562. br.Msg = "获取失败"
  563. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  564. return
  565. }
  566. var articleIds []int
  567. for _, v := range listPublic {
  568. if v.Resource == 1 {
  569. articleIds = append(articleIds, v.ArticleId)
  570. }
  571. }
  572. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  573. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  574. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  575. listResp := make([]*models.HomeArticle, 0)
  576. //listResp :=
  577. for _, v := range listPublic {
  578. listResp = append(listResp, &models.HomeArticle{
  579. ArticleId: v.ArticleId,
  580. Title: v.Title,
  581. Annotation: "核心观点:" + v.Annotation,
  582. Abstract: v.Abstract,
  583. ImgUrlPc: v.ImgUrlPc,
  584. PublishDate: v.PublishDate,
  585. Resource: v.Resource,
  586. Pv: articleMapPv[v.ArticleId],
  587. IsCollect: articleCollectMap[v.ArticleId],
  588. CollectNum: articleCollectNumMap[v.ArticleId],
  589. })
  590. }
  591. //lenList := len(list)
  592. //for i := 0; i < lenList; i++ {
  593. // item := list[i]
  594. // list[i].Body = ""
  595. // list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  596. // list[i].Annotation, _ = services.GetReportContentTextSub(item.Annotation)
  597. // list[i].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
  598. // //行业比较研究、资金流向,显示报告的摘要
  599. // if resp.MatchTypeName == "行业比较研究" || resp.MatchTypeName == "资金流向" {
  600. // list[i].Annotation = list[i].Abstract
  601. // }
  602. //}
  603. if len(listResp) == 0 {
  604. listResp = make([]*models.HomeArticle, 0)
  605. }
  606. page = paging.GetPaging(currentIndex, pageSize, total)
  607. resp.List = listResp
  608. resp.Paging = page
  609. br.Ret = 200
  610. br.Success = true
  611. br.Msg = "获取成功"
  612. br.Data = resp
  613. }
  614. // @Title 产业关注/取消关注
  615. // @Description 产业关注/取消关注 接口
  616. // @Param request body models.CygxIndustryFllowRep true "type json string"
  617. // @Success 200
  618. // @router /industrial/fllow [post]
  619. func (this *ReportController) IndustrialFllow() {
  620. br := new(models.BaseResponse).Init()
  621. defer func() {
  622. this.Data["json"] = br
  623. this.ServeJSON()
  624. }()
  625. user := this.User
  626. if user == nil {
  627. br.Msg = "请重新登录"
  628. br.Ret = 408
  629. return
  630. }
  631. uid := user.UserId
  632. var req models.CygxIndustryFllowRep
  633. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  634. if err != nil {
  635. br.Msg = "参数解析异常!"
  636. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  637. return
  638. }
  639. industrialManagementId := req.IndustrialManagementId
  640. followType := req.FollowType
  641. var condition string
  642. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  643. if err != nil {
  644. br.Msg = "获取数据失败!"
  645. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  646. return
  647. }
  648. if countIndustrial == 0 {
  649. br.Msg = "产业不存在!"
  650. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  651. return
  652. }
  653. count, err := models.GetCountCygxIndustryFllow(industrialManagementId, user.UserId, condition)
  654. if err != nil {
  655. br.Msg = "获取数据失败!"
  656. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  657. return
  658. }
  659. resp := new(models.CygxIndustryFllowResp)
  660. item := new(models.CygxIndustryFllow)
  661. item.IndustrialManagementId = industrialManagementId
  662. item.FollowType = followType
  663. item.UserId = uid
  664. item.Email = user.Email
  665. item.Mobile = user.Mobile
  666. item.RealName = user.RealName
  667. item.Source = utils.REGISTER_PLATFORM
  668. item.CompanyId = user.CompanyId
  669. item.CompanyName = user.CompanyName
  670. if followType == 3 {
  671. item.FollowTypeOrder = -1
  672. } else {
  673. item.FollowTypeOrder = followType
  674. }
  675. //if count == 0 {
  676. item.Type = 1
  677. item.CreateTime = time.Now()
  678. item.ModifyTime = time.Now()
  679. _, err = models.AddCygxIndustryFllow(item)
  680. if err != nil {
  681. br.Msg = "操作失败"
  682. br.ErrMsg = "操作失败,Err:" + err.Error()
  683. return
  684. }
  685. resp.Status = followType
  686. br.Msg = "操作成功"
  687. //} else {
  688. // err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
  689. // if err != nil {
  690. // br.Msg = "操作失败"
  691. // br.ErrMsg = "取消关注失败,Err:" + err.Error()
  692. // return
  693. // }
  694. // resp.Status = 2
  695. // br.Msg = "已取消关注"
  696. //}
  697. //处理是否关注全部赛道字段
  698. //go services.IndustryFllowWithTrack(industrialManagementId, count, uid)
  699. go services.IndustryFllowUserLabelLogAdd(industrialManagementId, count, uid) //处理用户标签
  700. go services.AddCygxIndustryFllowLog(item) //添加操作日志记录
  701. br.Ret = 200
  702. br.Success = true
  703. br.Data = resp
  704. }
  705. // @Title 行业关注/取消关注
  706. // @Description 行业关注/取消关注 接口
  707. // @Param request body models.CygxCategoryFllowRep true "type json string"
  708. // @Success 200
  709. // @router /category/fllow [post]
  710. func (this *ReportController) CategoryFllow() {
  711. br := new(models.BaseResponse).Init()
  712. defer func() {
  713. this.Data["json"] = br
  714. this.ServeJSON()
  715. }()
  716. user := this.User
  717. if user == nil {
  718. br.Msg = "请重新登录"
  719. br.Ret = 408
  720. return
  721. }
  722. uid := user.UserId
  723. var req models.CygxCategoryFllowRep
  724. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  725. if err != nil {
  726. br.Msg = "参数解析异常!"
  727. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  728. return
  729. }
  730. categoryId := req.CategoryId
  731. followType := req.FollowType
  732. var condition string
  733. //countCategory, err := models.GetCategoryCount(categoryId)
  734. //if err != nil {
  735. // br.Msg = "获取数据失败!"
  736. // br.ErrMsg = "获取数据失败,Err:" + err.Error()
  737. // return
  738. //}
  739. //if countCategory == 0 {
  740. // br.Msg = "产业不存在!"
  741. // br.ErrMsg = "产业ID不存在:" + strconv.Itoa(categoryId)
  742. // return
  743. //}
  744. listMap, err := models.GetCygxXzsChooseCategoryMapList()
  745. if err != nil {
  746. br.Msg = "操作失败!"
  747. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  748. return
  749. }
  750. mapReport := make(map[int]int)
  751. for _, v := range listMap {
  752. mapReport[v.Id] = v.CategoryId
  753. }
  754. if mapReport[categoryId] == 0 {
  755. br.Msg = "操作失败!"
  756. br.ErrMsg = "分类ID不存在,ID:" + strconv.Itoa(categoryId)
  757. return
  758. }
  759. count, err := models.GetCountCategoryFllow(mapReport[categoryId], user.Mobile, condition)
  760. if err != nil {
  761. br.Msg = "获取数据失败!"
  762. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  763. return
  764. }
  765. resp := new(models.CygxIndustryFllowResp)
  766. //if count == 0 {
  767. item := new(models.CygxXzsChooseCategory)
  768. item.CategoryId = mapReport[categoryId]
  769. item.IdCygx = categoryId
  770. item.UserId = uid
  771. item.Email = user.Email
  772. item.Mobile = user.Mobile
  773. item.RealName = user.RealName
  774. item.CompanyId = user.CompanyId
  775. item.CompanyName = user.CompanyName
  776. item.FollowType = followType
  777. item.CreateTime = time.Now()
  778. item.ModifyTime = time.Now()
  779. _, err = models.AddCygxCategoryFllow(item)
  780. if err != nil {
  781. br.Msg = "操作失败"
  782. br.ErrMsg = "操作失败,Err:" + err.Error()
  783. return
  784. }
  785. resp.Status = followType
  786. br.Msg = "操作成功"
  787. //} else {
  788. //err = models.RemoveCygxCategoryFllow(user.Mobile, mapReport[categoryId])
  789. // if err != nil {
  790. // br.Msg = "操作失败"
  791. // br.ErrMsg = "取消关注失败,Err:" + err.Error()
  792. // return
  793. // }
  794. // resp.Status = 2
  795. // br.Msg = "已取消关注"
  796. //}
  797. go services.CategoryFllowUserLabelLogAdd(categoryId, count, uid) //处理用户标签
  798. br.Ret = 200
  799. br.Success = true
  800. br.Data = resp
  801. }
  802. // @Title 报告搜索
  803. // @Description 报告搜索接口
  804. // @Param PageSize query int true "每页数据条数"
  805. // @Param CurrentIndex query int true "当前页页码,从1开始"
  806. // @Param KeyWord query string true "搜索关键词"
  807. // @Param ArticleType query int true "文章类型,1弘则报告、2研选 "
  808. // @Param IsAll query bool true "是否为综合 "
  809. // @Success 200 {object} models.ReoprtSearchResp
  810. // @router /searchReport [get]
  811. func (this *MobileReportController) SearchReport() {
  812. br := new(models.BaseResponse).Init()
  813. defer func() {
  814. this.Data["json"] = br
  815. this.ServeJSON()
  816. }()
  817. user := this.User
  818. if user == nil {
  819. br.Msg = "请重新登录"
  820. br.Ret = 408
  821. return
  822. }
  823. pageSize, _ := this.GetInt("PageSize")
  824. currentIndex, _ := this.GetInt("CurrentIndex")
  825. articleType, _ := this.GetInt("ArticleType", 1)
  826. keyWord := this.GetString("KeyWord")
  827. isAll, _ := this.GetBool("IsAll")
  828. var condition string
  829. var conditionYxSpecial string
  830. var pars []interface{}
  831. //var conditionSql string
  832. var total int
  833. var startSize int
  834. if pageSize <= 0 {
  835. pageSize = utils.PageSize20
  836. }
  837. if isAll {
  838. pageSize = utils.PageSize5
  839. }
  840. if currentIndex <= 0 {
  841. currentIndex = 1
  842. }
  843. startSize = paging.StartIndex(currentIndex, pageSize)
  844. resp := new(models.ReoprtSearchResp)
  845. //匹配报告标题、
  846. articleTypeIds, err := services.GetYanXuanArticleTypeIds()
  847. if err != nil {
  848. br.Msg = "获取信息失败"
  849. br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
  850. return
  851. }
  852. if articleTypeIds == "" {
  853. br.Msg = "获取信息失败"
  854. br.ErrMsg = "研选分类ID不能为空"
  855. return
  856. }
  857. //处理对应的文章类型标签按钮
  858. nameMap, styleMap, err := services.GetArticleTypeMap()
  859. if err != nil {
  860. br.Msg = "获取信息失败"
  861. br.ErrMsg = "GetArticleTypeMap Err:" + err.Error()
  862. return
  863. }
  864. if isAll {
  865. total = utils.PageSize5
  866. conditionHz := ` 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 AND a.article_type_id NOT IN (` + articleTypeIds + `) `
  867. conditionYx := ` 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 AND a.article_type_id IN (` + articleTypeIds + `) `
  868. listHz, err := models.GetArticleResearchListHz(conditionHz, pars, startSize, pageSize, user.UserId)
  869. if err != nil {
  870. br.Msg = "获取信息失败"
  871. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  872. return
  873. }
  874. listYx, err := models.GetArticleResearchList(conditionYx, pars, startSize, pageSize, user.UserId, true)
  875. if err != nil {
  876. br.Msg = "获取信息失败"
  877. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  878. return
  879. }
  880. listHz, err = services.HandleArticleCategoryImg(listHz, user)
  881. if err != nil {
  882. br.Msg = "获取信息失败"
  883. br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
  884. return
  885. }
  886. listYx, err = services.HandleArticleCategoryImg(listYx, user)
  887. if err != nil {
  888. br.Msg = "获取信息失败"
  889. br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
  890. return
  891. }
  892. for _, v := range listHz {
  893. item := models.ArticleResearchResp{
  894. ArticleId: v.ArticleId,
  895. ArticleTypeId: v.ArticleTypeId,
  896. Title: v.Title,
  897. PublishDate: v.PublishDate,
  898. DepartmentId: v.DepartmentId,
  899. NickName: v.NickName,
  900. IsCollect: v.IsCollect,
  901. Pv: v.Pv,
  902. CollectNum: v.CollectNum,
  903. Abstract: v.Abstract,
  904. Annotation: v.Annotation,
  905. ImgUrlPc: v.ImgUrlPc,
  906. ArticleTypeName: nameMap[v.ArticleTypeId],
  907. ButtonStyle: styleMap[v.ArticleTypeId],
  908. List: v.List,
  909. }
  910. if v.ReportId > 0 {
  911. item.Resource = 3
  912. item.ReportId = v.ReportId
  913. }
  914. resp.ListHz = append(resp.ListHz, &item)
  915. }
  916. for _, v := range listYx {
  917. item := models.ArticleResearchResp{
  918. ArticleId: v.ArticleId,
  919. ArticleTypeId: v.ArticleTypeId,
  920. Title: v.Title,
  921. PublishDate: v.PublishDate,
  922. DepartmentId: v.DepartmentId,
  923. NickName: v.NickName,
  924. IsCollect: v.IsCollect,
  925. Pv: v.Pv,
  926. CollectNum: v.CollectNum,
  927. Abstract: v.Abstract,
  928. Annotation: v.Annotation,
  929. ImgUrlPc: v.ImgUrlPc,
  930. ArticleTypeName: nameMap[v.ArticleTypeId],
  931. ButtonStyle: styleMap[v.ArticleTypeId],
  932. List: v.List,
  933. }
  934. resp.ListYx = append(resp.ListYx, &item)
  935. }
  936. } else {
  937. if keyWord != "" {
  938. if articleType == 1 {
  939. 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 AND a.article_type_id NOT IN (` + articleTypeIds + `) `
  940. total, err = models.GetReoprtSearchCountHz(condition)
  941. } else {
  942. 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 AND a.article_type_id IN (` + articleTypeIds + `) `
  943. total, err = models.GetReoprtSearchCountYx(condition)
  944. }
  945. conditionYxSpecial = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.content LIKE '%` + keyWord + `%') `
  946. }
  947. if err != nil {
  948. br.Msg = "获取信息失败"
  949. br.Msg = "获取总数失败,Err:" + err.Error()
  950. return
  951. }
  952. var list []*models.ArticleListResp
  953. //list := new([]models.ArticleResearchResp)
  954. if articleType == 1 {
  955. list, err = models.GetArticleResearchListHz(condition, pars, startSize, pageSize, user.UserId)
  956. } else {
  957. total, list, err = models.GetArticleResearchAndYxSpecialList(condition, conditionYxSpecial, pars, startSize, pageSize, user.UserId, true)
  958. }
  959. if err != nil {
  960. br.Msg = "获取信息失败"
  961. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  962. return
  963. }
  964. //return
  965. list, err = services.HandleArticleCategoryImg(list, user)
  966. if err != nil {
  967. br.Msg = "获取信息失败"
  968. br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
  969. return
  970. }
  971. for _, v := range list {
  972. item := models.ArticleResearchResp{
  973. ArticleId: v.ArticleId,
  974. ArticleTypeId: v.ArticleTypeId,
  975. Title: v.Title,
  976. PublishDate: v.PublishDate,
  977. DepartmentId: v.DepartmentId,
  978. NickName: v.NickName,
  979. IsCollect: v.IsCollect,
  980. Pv: v.Pv,
  981. CollectNum: v.CollectNum,
  982. Abstract: v.Abstract,
  983. Annotation: v.Annotation,
  984. ImgUrlPc: v.ImgUrlPc,
  985. ArticleTypeName: nameMap[v.ArticleTypeId],
  986. ButtonStyle: styleMap[v.ArticleTypeId],
  987. List: v.List,
  988. }
  989. if v.ReportId > 0 {
  990. item.Resource = 3
  991. item.ReportId = v.ReportId
  992. }
  993. if v.IsSpecial == 1 {
  994. //去除图片标签
  995. item.Annotation = utils.ArticleRemoveImgUrl(item.Annotation)
  996. item.IsSpecial = true
  997. item.ImgUrlPc = utils.CYGX_YANXUAN_SPECIAL_IMG_PC
  998. if v.CompanyTags != "" {
  999. item.CompanyTags = strings.Split(v.CompanyTags, ",")
  1000. } else {
  1001. item.CompanyTags = []string{}
  1002. }
  1003. if v.IndustryTags != "" {
  1004. item.IndustryTags = strings.Split(v.IndustryTags, ",")
  1005. } else {
  1006. item.IndustryTags = []string{}
  1007. }
  1008. item.ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL
  1009. if v.SpecialType == 1 {
  1010. item.Title = "【笔记】" + item.Title
  1011. } else if v.SpecialType == 2 {
  1012. item.Title = "【观点】" + item.Title
  1013. }
  1014. if v.MyCollectNum > 0 {
  1015. item.IsCollect = true
  1016. }
  1017. }
  1018. if articleType == 1 {
  1019. resp.ListHz = append(resp.ListHz, &item)
  1020. } else {
  1021. resp.ListYx = append(resp.ListYx, &item)
  1022. }
  1023. }
  1024. }
  1025. if keyWord != "" {
  1026. //go services.AddUserSearchLog(user, keyWord, 5)
  1027. }
  1028. if len(resp.ListHz) == 0 {
  1029. resp.ListHz = make([]*models.ArticleResearchResp, 0)
  1030. }
  1031. if len(resp.ListYx) == 0 {
  1032. resp.ListYx = make([]*models.ArticleResearchResp, 0)
  1033. }
  1034. page := paging.GetPaging(currentIndex, pageSize, total)
  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 KeyWord query string true "搜索关键词"
  1044. // @Success 200 {object} models.SearchResourceResp
  1045. // @router /searchResource [get]
  1046. func (this *MobileReportController) SearchResource() {
  1047. br := new(models.BaseResponse).Init()
  1048. defer func() {
  1049. this.Data["json"] = br
  1050. this.ServeJSON()
  1051. }()
  1052. user := this.User
  1053. if user == nil {
  1054. br.Msg = "请重新登录"
  1055. br.Ret = 408
  1056. return
  1057. }
  1058. uid := user.UserId
  1059. fllowList, err := models.GetUserFllowIndustrialList(uid)
  1060. if err != nil {
  1061. br.Msg = "获取失败"
  1062. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  1063. return
  1064. }
  1065. fllowMap := make(map[int]int)
  1066. if len(fllowList) > 0 {
  1067. for _, v := range fllowList {
  1068. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  1069. }
  1070. }
  1071. keyWord := this.GetString("KeyWord")
  1072. var condition string
  1073. articleTypeIds, err := services.GetYanXuanArticleTypeIds()
  1074. if err != nil {
  1075. br.Msg = "获取信息失败"
  1076. br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
  1077. return
  1078. }
  1079. if articleTypeIds == "" {
  1080. br.Msg = "获取信息失败"
  1081. br.ErrMsg = "研选分类ID不能为空"
  1082. return
  1083. }
  1084. condition = ` AND a.publish_status = 1 AND a.article_type_id NOT IN (` + articleTypeIds + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  1085. listHz, err := models.GetSearchResourceList(condition)
  1086. if err != nil {
  1087. br.Msg = "获取信息失败"
  1088. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1089. return
  1090. }
  1091. condition = ` AND a.publish_status = 1 AND a.article_type_id IN (` + articleTypeIds + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
  1092. listYx, err := models.GetSearchResourceList(condition)
  1093. if err != nil {
  1094. br.Msg = "获取信息失败"
  1095. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1096. return
  1097. }
  1098. if len(listYx) > 0 {
  1099. listYx, err = services.HandleIndustryList(listYx, user, "Yx")
  1100. if err != nil {
  1101. br.Msg = "获取信息失败"
  1102. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1103. return
  1104. }
  1105. }
  1106. if len(listHz) > 0 {
  1107. listHz, err = services.HandleIndustryList(listHz, user, "Hz")
  1108. if err != nil {
  1109. br.Msg = "获取信息失败"
  1110. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1111. return
  1112. }
  1113. }
  1114. if keyWord != "" {
  1115. //go services.AddUserSearchLog(user, keyWord, 4)
  1116. }
  1117. resp := new(models.SearchResourceResp)
  1118. if len(listHz) == 0 {
  1119. listHz = make([]*models.IndustrialManagement, 0)
  1120. }
  1121. if len(listYx) == 0 {
  1122. listYx = make([]*models.IndustrialManagement, 0)
  1123. }
  1124. resp.ListHz = listHz
  1125. resp.ListYx = listYx
  1126. br.Ret = 200
  1127. br.Success = true
  1128. br.Msg = "获取成功"
  1129. br.Data = resp
  1130. }
  1131. // @Title 报告搜索、资源包搜索接口
  1132. // @Description 报告搜索、资源包搜索接口接口
  1133. // @Param KeyWord query string true "搜索关键词"
  1134. // @Param PageSize query int true "每页数据条数"
  1135. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1136. // @Param SearchType query int true "1:综合,2:全部"
  1137. // @Success 200 {object} models.SearchReportAndResourceResp
  1138. // @router /searchReportAndResource [get]
  1139. func (this *MobileReportController) SearchReportAndResource() {
  1140. br := new(models.BaseResponse).Init()
  1141. defer func() {
  1142. this.Data["json"] = br
  1143. this.ServeJSON()
  1144. }()
  1145. user := this.User
  1146. if user == nil {
  1147. br.Msg = "请重新登录"
  1148. br.Ret = 408
  1149. return
  1150. }
  1151. //uid := user.UserId
  1152. keyWord := this.GetString("KeyWord")
  1153. pageSize, _ := this.GetInt("PageSize")
  1154. currentIndex, _ := this.GetInt("CurrentIndex")
  1155. searchType, _ := this.GetInt("SearchType")
  1156. var total int
  1157. var startSize int
  1158. if pageSize <= 0 {
  1159. pageSize = utils.PageSize20
  1160. }
  1161. if currentIndex <= 0 {
  1162. currentIndex = 1
  1163. }
  1164. startSize = paging.StartIndex(currentIndex, pageSize)
  1165. page := paging.GetPaging(currentIndex, pageSize, total)
  1166. var condition string
  1167. var conditionSql string
  1168. //匹配报告标题、
  1169. condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
  1170. conditionSql = ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + condition + ` OR ( article_type = 'lyjh' ` + condition + ` ) `
  1171. total, err := models.GetReoprtSearchCount(conditionSql)
  1172. if err != nil {
  1173. br.Msg = "获取信息失败"
  1174. br.Msg = "获取总数失败,Err:" + err.Error()
  1175. return
  1176. }
  1177. if searchType == 1 {
  1178. pageSize = utils.PageSize5
  1179. }
  1180. ListHzReport, err := services.GetReoprtSearchListHz(conditionSql, user.UserId, startSize, pageSize)
  1181. if err != nil {
  1182. br.Msg = "获取失败"
  1183. br.ErrMsg = "获取失败,GetReoprtSearchListHz Err:" + err.Error()
  1184. return
  1185. }
  1186. if len(ListHzReport) == 0 {
  1187. ListHzReport = make([]*models.ArticleCollectionResp, 0)
  1188. }
  1189. var conditionOr string
  1190. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  1191. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  1192. listHzResource, err := services.GetSearchResourceListHz(condition, user)
  1193. if err != nil {
  1194. br.Msg = "获取信息失败"
  1195. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1196. return
  1197. }
  1198. resp := new(models.SearchReportAndResourceResp)
  1199. if len(listHzResource) == 0 {
  1200. listHzResource = make([]*models.IndustrialManagement, 0)
  1201. }
  1202. if keyWord != "" {
  1203. //go services.AddUserSearchLog(user, keyWord, 5)
  1204. }
  1205. page = paging.GetPaging(currentIndex, pageSize, total)
  1206. resp.Paging = page
  1207. resp.ListHzResource = listHzResource
  1208. resp.ListHzReport = ListHzReport
  1209. br.Ret = 200
  1210. br.Success = true
  1211. br.Msg = "获取成功"
  1212. br.Data = resp
  1213. }
  1214. // @Title 公司速览
  1215. // @Description 公司速览接口
  1216. // @Param ChartPermissionId query int false "分类ID"
  1217. // @Success 200 {object} models.ArticleDataLogoListResp
  1218. // @router /companyList [get]
  1219. func (this *ReportCommonController) CompanyList() {
  1220. br := new(models.BaseResponse).Init()
  1221. defer func() {
  1222. this.Data["json"] = br
  1223. this.ServeJSON()
  1224. }()
  1225. var condition string
  1226. var pars []interface{}
  1227. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  1228. if chartPermissionId > 1 {
  1229. categoryId, err := models.GetCategoryId(chartPermissionId)
  1230. if err != nil && err.Error() != utils.ErrNoRow() {
  1231. br.Msg = "获取信息失败"
  1232. br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
  1233. return
  1234. }
  1235. if categoryId != "" {
  1236. condition += ` AND a.category_id IN (` + categoryId + `)`
  1237. }
  1238. }
  1239. condition += ` AND a.type_name = '综述报告' ORDER BY a.modify_time_by_cl DESC `
  1240. list, err := models.CygxArticleDataList(condition, pars)
  1241. if err != nil {
  1242. br.Msg = "获取失败"
  1243. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  1244. return
  1245. }
  1246. listLogo := make([]*models.ArticleDataLogoResp, 0)
  1247. for i := range list {
  1248. v := list[i]
  1249. comapnyList := services.HandleArticleStock(v.Stock)
  1250. if len(comapnyList) > 1 {
  1251. for kC, vC := range comapnyList {
  1252. sliceCovers := strings.Split(v.Cover, "{|}")
  1253. cover := v.Cover
  1254. if len(sliceCovers) == len(comapnyList) {
  1255. cover = sliceCovers[kC]
  1256. }
  1257. listLogo = append(listLogo, &models.ArticleDataLogoResp{
  1258. ArticleId: v.ArticleId,
  1259. Cover: cover,
  1260. ComapnyList: services.HandleArticleStock(vC.ComapnyName),
  1261. })
  1262. }
  1263. } else {
  1264. listLogo = append(listLogo, &models.ArticleDataLogoResp{
  1265. ArticleId: v.ArticleId,
  1266. Cover: v.Cover,
  1267. ComapnyList: services.HandleArticleStock(v.Stock),
  1268. })
  1269. }
  1270. }
  1271. resp := new(models.ArticleDataLogoListResp)
  1272. resp.List = listLogo
  1273. br.Ret = 200
  1274. br.Success = true
  1275. br.Msg = "获取成功"
  1276. br.Data = resp
  1277. }
  1278. // @Title 时间线
  1279. // @Description 时间线接口
  1280. // @Param PageSize query int true "每页数据条数"
  1281. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1282. // @Param IndustrialManagementId query int false "产业ID"
  1283. // @Success 200 {object} models.TacticsListResp
  1284. // @router /timeline [get]
  1285. func (this *MobileReportController) Timeline() {
  1286. br := new(models.BaseResponse).Init()
  1287. defer func() {
  1288. this.Data["json"] = br
  1289. this.ServeJSON()
  1290. }()
  1291. user := this.User
  1292. if user == nil {
  1293. br.Msg = "请重新登录"
  1294. br.Ret = 408
  1295. return
  1296. }
  1297. pageSize, _ := this.GetInt("PageSize")
  1298. currentIndex, _ := this.GetInt("CurrentIndex")
  1299. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  1300. var startSize int
  1301. if pageSize <= 0 {
  1302. pageSize = utils.PageSize20
  1303. }
  1304. if currentIndex <= 0 {
  1305. currentIndex = 1
  1306. }
  1307. startSize = paging.StartIndex(currentIndex, pageSize)
  1308. var total int
  1309. resp := new(models.TacticsListTimeResp)
  1310. page := paging.GetPaging(currentIndex, pageSize, total)
  1311. list := make([]*models.TimeLineReportItem, 0)
  1312. var err error
  1313. list, total, err = models.GetTimeLineReportIndustrialListTime(user.UserId, industrialManagementId, startSize, pageSize)
  1314. if err != nil {
  1315. br.Msg = "获取信息失败"
  1316. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  1317. return
  1318. }
  1319. //处理晨会精华关联的标的,以及要跳转的文章ID
  1320. var meetingreviewchaptIds []int
  1321. var articleIds []int
  1322. mapchaptIdAndArticleId := make(map[int]int) // 晨会精华ID与跳转文章ID的映射关系
  1323. mapchaptIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 晨会精华ID与标的列表的映射关系
  1324. mapArticleIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 报告ID与标的列表的映射关系
  1325. for _, v := range list {
  1326. if v.Resource == 3 {
  1327. meetingreviewchaptIds = append(meetingreviewchaptIds, v.Id)
  1328. }
  1329. if v.Resource == 1 {
  1330. articleIds = append(articleIds, v.ArticleId)
  1331. }
  1332. }
  1333. if len(meetingreviewchaptIds) > 0 {
  1334. listMeet, err := services.GetCygxMorningMeetingReviewChapterListByIds(meetingreviewchaptIds)
  1335. if err != nil {
  1336. br.Msg = "获取失败"
  1337. br.ErrMsg = "GetCygxMorningMeetingReviewChapterListByIds,Err:" + err.Error()
  1338. }
  1339. for _, v := range listMeet {
  1340. mapchaptIdAndArticleId[v.Id] = v.LinkArticleId
  1341. mapchaptIdListSubject[v.Id] = v.ListSubject
  1342. }
  1343. }
  1344. if len(articleIds) > 0 {
  1345. mapArticleIdListSubject = services.GetArticleGroupSubjectMapByIndustrialManagementId(articleIds, industrialManagementId)
  1346. }
  1347. //查询用户今天是否看过时间线
  1348. //count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  1349. //if err != nil {
  1350. // br.Msg = "查询浏览记录数量失败"
  1351. // br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  1352. // return
  1353. //}
  1354. //var recordItem *models.CygxPageHistoryRecord
  1355. //if count > 1 {
  1356. // recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  1357. // if err != nil {
  1358. // br.Msg = "查询浏览记录失败"
  1359. // br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  1360. // return
  1361. // }
  1362. //}
  1363. for k, v := range list {
  1364. if v.SubCategoryName != "时间线" && v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  1365. list[k].IsRed = true
  1366. }
  1367. //timeLineRed := false
  1368. //if count < 2 && v.SubCategoryName == "时间线" {
  1369. // timeLineRed = true
  1370. //} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishDate)) {
  1371. // timeLineRed = true
  1372. //}
  1373. //if v.SubCategoryName == "时间线" && timeLineRed {
  1374. list[k].IsRed = true
  1375. //}
  1376. if v.VideoUrl != "" {
  1377. list[k].IsHaveVideo = true
  1378. }
  1379. v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
  1380. if v.Resource == 3 {
  1381. v.LinkArticleId = mapchaptIdAndArticleId[v.Id]
  1382. v.ListSubject = mapchaptIdListSubject[v.Id]
  1383. }
  1384. if v.Resource == 1 {
  1385. v.ListSubject = mapArticleIdListSubject[v.Id]
  1386. }
  1387. }
  1388. //添加我的日程访问记录
  1389. item := new(models.CygxPageHistoryRecord)
  1390. item.UserId = user.UserId
  1391. item.CreateTime = time.Now()
  1392. item.CompanyId = user.CompanyId
  1393. item.CompanyName = user.CompanyName
  1394. item.Router = utils.TIME_LINE_ROUTE + strconv.Itoa(industrialManagementId)
  1395. go models.AddCygxPageHistoryRecord(item)
  1396. if len(list) == 0 {
  1397. list = make([]*models.TimeLineReportItem, 0)
  1398. }
  1399. go services.AddCygxTimelineLog(user, industrialManagementId)
  1400. page = paging.GetPaging(currentIndex, pageSize, total)
  1401. resp.List = list
  1402. resp.Paging = page
  1403. br.Ret = 200
  1404. br.Success = true
  1405. br.Msg = "获取成功"
  1406. br.Data = resp
  1407. }
  1408. // @Title 文章留言接口
  1409. // @Description 文章留言接口
  1410. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  1411. // @Success 200 {object} models.TacticsListResp
  1412. // @router /commentAdd [post]
  1413. func (this *ReportController) CommentAdd() {
  1414. br := new(models.BaseResponse).Init()
  1415. defer func() {
  1416. this.Data["json"] = br
  1417. this.ServeJSON()
  1418. }()
  1419. user := this.User
  1420. if user == nil {
  1421. br.Msg = "请重新登录"
  1422. br.Ret = 408
  1423. return
  1424. }
  1425. var req models.AddCygxArticleCommentReq
  1426. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1427. if err != nil {
  1428. br.Msg = "参数解析异常!"
  1429. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1430. return
  1431. }
  1432. if req.ArticleId <= 0 {
  1433. br.Msg = "文章不存在"
  1434. br.ErrMsg = "文章不存在,文章ID错误"
  1435. return
  1436. }
  1437. if req.Content == "" {
  1438. br.Msg = "建议内容不可为空"
  1439. return
  1440. }
  1441. content := req.Content
  1442. if content == "" {
  1443. br.Msg = "留言内容不能为空!"
  1444. return
  1445. }
  1446. //itemToken, err := services.WxGetToken()
  1447. //if err != nil {
  1448. // br.Msg = "GetWxAccessToken Err:" + err.Error()
  1449. // return
  1450. //}
  1451. //if itemToken.AccessToken == "" {
  1452. // br.Msg = "accessToken is empty"
  1453. // return
  1454. //}
  1455. //commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  1456. //if err != nil {
  1457. // br.Msg = "内容校验失败!"
  1458. // br.ErrMsg = "内容校验失败,Err:" + err.Error()
  1459. // return
  1460. //}
  1461. //if commerr.ErrCode != 0 {
  1462. // br.Msg = "内容违规,请重新提交!"
  1463. // br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
  1464. // return
  1465. //}
  1466. articleId := req.ArticleId
  1467. articleInfo, errInfo := models.GetArticleDetailById(articleId)
  1468. if articleInfo == nil {
  1469. br.Msg = "操作失败"
  1470. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1471. return
  1472. }
  1473. if errInfo != nil {
  1474. br.Msg = "操作失败"
  1475. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1476. return
  1477. }
  1478. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1479. if err != nil {
  1480. br.Msg = "提交失败!"
  1481. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1482. return
  1483. }
  1484. if companyDetail == nil {
  1485. br.Msg = "提交失败!"
  1486. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  1487. return
  1488. }
  1489. item := models.CygxArticleComment{
  1490. UserId: user.UserId,
  1491. ArticleId: req.ArticleId,
  1492. CreateTime: time.Now(),
  1493. Mobile: user.Mobile,
  1494. Email: user.Email,
  1495. CompanyId: user.CompanyId,
  1496. CompanyName: companyDetail.CompanyName,
  1497. Content: content,
  1498. Title: articleInfo.Title,
  1499. }
  1500. msgId, err := models.AddArticleComment(&item)
  1501. if err != nil {
  1502. br.Msg = "提交失败"
  1503. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  1504. return
  1505. }
  1506. go services.SendCommentWxTemplateMsg(req, user, articleInfo, int(msgId))
  1507. go services.SendCommentWxTemplateMsgByYxCategory(req, user, articleInfo, int(msgId)) // 发送用户留言提醒(研选公众号类目模版消息)
  1508. br.Ret = 200
  1509. br.Success = true
  1510. br.Msg = "提交成功"
  1511. }
  1512. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1513. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1514. // @Param PageSize query int true "每页数据条数"
  1515. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1516. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1517. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1518. // @router /reportList/byType [get]
  1519. func (this *ReportController) ReportListByType() {
  1520. br := new(models.BaseResponse).Init()
  1521. defer func() {
  1522. this.Data["json"] = br
  1523. this.ServeJSON()
  1524. }()
  1525. user := this.User
  1526. if user == nil {
  1527. br.Msg = "请重新登录"
  1528. br.Ret = 408
  1529. return
  1530. }
  1531. uid := user.UserId
  1532. pageSize, _ := this.GetInt("PageSize")
  1533. currentIndex, _ := this.GetInt("CurrentIndex")
  1534. reportType := this.GetString("ReportType")
  1535. var condition string
  1536. var startSize int
  1537. if pageSize <= 0 {
  1538. pageSize = utils.PageSize20
  1539. }
  1540. if currentIndex <= 0 {
  1541. currentIndex = 1
  1542. }
  1543. startSize = paging.StartIndex(currentIndex, pageSize)
  1544. var pars []interface{}
  1545. var total int
  1546. resp := new(models.CygxReportSelectionListPublicRep)
  1547. page := paging.GetPaging(currentIndex, pageSize, total)
  1548. var tbdb string
  1549. var readSql string
  1550. var reportTypeStr string
  1551. if reportType == "1" {
  1552. tbdb = "cygx_report_selection"
  1553. reportTypeStr = "bgjx"
  1554. } else if reportType == "2" {
  1555. tbdb = "cygx_research_summary"
  1556. reportTypeStr = "bzyjhz"
  1557. } else if reportType == "3" {
  1558. tbdb = "cygx_minutes_summary"
  1559. reportTypeStr = "szjyhz"
  1560. } else {
  1561. br.Msg = "请选择报告类型"
  1562. return
  1563. }
  1564. condition = ` AND publish_status = 1 `
  1565. if user.CompanyId != utils.HZ_COMPANY_ID {
  1566. condition += ` AND visible_range = 1 `
  1567. }
  1568. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1569. if err != nil {
  1570. br.Msg = "获取信息失败"
  1571. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1572. return
  1573. }
  1574. //研究汇总--报告精选 只显示最新一期,往期都隐藏
  1575. if reportType == "1" {
  1576. startSize = 0
  1577. pageSize = 1
  1578. total = 1
  1579. }
  1580. 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`
  1581. page = paging.GetPaging(currentIndex, pageSize, total)
  1582. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1583. if err != nil {
  1584. br.Msg = "获取失败"
  1585. br.ErrMsg = "获取失败,Err:" + err.Error()
  1586. return
  1587. }
  1588. for k, v := range list {
  1589. if reportType == "1" {
  1590. list[k].Abstract = v.UpdateDescription
  1591. }
  1592. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1593. if v.ReadNum == 0 {
  1594. list[k].IsRed = true
  1595. }
  1596. }
  1597. resp.List = list
  1598. resp.Paging = page
  1599. br.Ret = 200
  1600. br.Success = true
  1601. br.Msg = "获取成功"
  1602. br.Data = resp
  1603. }
  1604. // @Title 获取本周研究汇总详情
  1605. // @Description 获取本周研究汇总详情接口
  1606. // @Param ArticleId query int true "报告ID"
  1607. // @Success 200 {object} models.ResearchSummaryLetailResp
  1608. // @router /researchSummary/detail [get]
  1609. func (this *ReportController) ResearchDetail() {
  1610. br := new(models.BaseResponse).Init()
  1611. defer func() {
  1612. this.Data["json"] = br
  1613. this.ServeJSON()
  1614. }()
  1615. user := this.User
  1616. if user == nil {
  1617. br.Msg = "请重新登录"
  1618. br.Ret = 408
  1619. return
  1620. }
  1621. //uid := user.UserId
  1622. articleId, _ := this.GetInt("ArticleId")
  1623. if articleId < 0 {
  1624. br.Msg = "参数错误"
  1625. br.ErrMsg = "参数错误"
  1626. return
  1627. }
  1628. resp := new(models.ResearchSummaryLetailResp)
  1629. //判断用户权限
  1630. hasPermission, err := services.GetUserhasPermission(user)
  1631. if err != nil {
  1632. br.Msg = "获取信息失败"
  1633. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1634. }
  1635. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1636. if err != nil {
  1637. br.Msg = "获取信息失败"
  1638. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1639. return
  1640. }
  1641. PermissionNameMap, err := services.GetPermissionNameMap()
  1642. if err != nil {
  1643. br.Msg = "获取失败"
  1644. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1645. return
  1646. }
  1647. PermissionIcoMap, err := services.GetPermissionNameIcoMap()
  1648. if err != nil {
  1649. br.Msg = "获取失败"
  1650. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1651. return
  1652. }
  1653. //未设置全部可见的只能给弘则内部查看
  1654. if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
  1655. resp.IsShow = true
  1656. }
  1657. resp.HasPermission = hasPermission
  1658. if hasPermission != 1 || !resp.IsShow {
  1659. br.Ret = 200
  1660. br.Success = true
  1661. br.Msg = "获取成功"
  1662. br.Data = resp
  1663. return
  1664. }
  1665. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1666. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1667. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1668. if err != nil {
  1669. br.Msg = "获取失败"
  1670. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1671. return
  1672. }
  1673. listArticleType, err := models.GetCygxArticleTypeList()
  1674. if err != nil {
  1675. br.Msg = "获取失败"
  1676. br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
  1677. return
  1678. }
  1679. for k, v := range listFirst {
  1680. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1681. if err != nil && err.Error() != utils.ErrNoRow() {
  1682. br.Msg = "获取信息失败"
  1683. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1684. return
  1685. }
  1686. for k2, v2 := range listSecond {
  1687. v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
  1688. v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
  1689. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1690. if err != nil && err.Error() != utils.ErrNoRow() {
  1691. br.Msg = "获取信息失败"
  1692. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1693. return
  1694. }
  1695. for _, vType := range listArticleType {
  1696. if v2.ChartPermissionId == vType.YanxPermissionId {
  1697. listSecond[k2].IcoLink = vType.IcoLinkM
  1698. listSecond[k2].PermissionName = vType.YanxPermissionName
  1699. }
  1700. }
  1701. if len(listThird) > 0 {
  1702. for k3, v3 := range listThird {
  1703. if v3.VideoUrl != "" {
  1704. listThird[k3].IsHaveVideo = true
  1705. }
  1706. if v3.ReportLink == "0" {
  1707. listThird[k3].ReportLink = ""
  1708. }
  1709. }
  1710. listSecond[k2].List = listThird
  1711. }
  1712. }
  1713. if len(listSecond) > 0 {
  1714. listFirst[k].List = listSecond
  1715. }
  1716. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1717. if v.Type == "SDBG" {
  1718. listFirst[k].ListName = "深度报告"
  1719. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1720. } else if v.Type == "BZCHJH" {
  1721. listFirst[k].ListName = "本周晨会精华"
  1722. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1723. } else if v.Type == "CYDYJY" {
  1724. listFirst[k].ListName = "产业调研纪要"
  1725. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1726. } else if v.Type == "SSGS" {
  1727. listFirst[k].ListName = "上市公司调研纪要篇"
  1728. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1729. } else if v.Type == "SJDP" {
  1730. listFirst[k].ListName = "市场QA汇总"
  1731. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1732. } else if v.Type == "YANX" {
  1733. listFirst[k].ListName = "买方研选"
  1734. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1735. }
  1736. }
  1737. //go services.AddCygxReportHistoryRecord(user, articleId, "bzyjhz")
  1738. go services.ResearchSummaryHistoryUserRmind(user, articleId) // 本周研究汇总用户阅读操作操作行为,模板消息推送
  1739. resp.List = listFirst
  1740. resp.Detail = detail
  1741. br.Ret = 200
  1742. br.Success = true
  1743. br.Msg = "获取成功"
  1744. br.Data = resp
  1745. }
  1746. // @Title 上周纪要汇总内容详情
  1747. // @Description 获取上周纪要汇总内容详情接口
  1748. // @Param ArticleId query int true "报告ID"
  1749. // @Success 200 {object} models.MinutesSummaryLetailResp
  1750. // @router /minutesSummary/detail [get]
  1751. func (this *ReportController) MinutesDetail() {
  1752. br := new(models.BaseResponse).Init()
  1753. defer func() {
  1754. this.Data["json"] = br
  1755. this.ServeJSON()
  1756. }()
  1757. user := this.User
  1758. if user == nil {
  1759. br.Msg = "请重新登录"
  1760. br.Ret = 408
  1761. return
  1762. }
  1763. articleId, _ := this.GetInt("ArticleId")
  1764. if articleId < 0 {
  1765. br.Msg = "参数错误"
  1766. br.ErrMsg = "参数错误"
  1767. return
  1768. }
  1769. resp := new(models.MinutesSummaryLetailRespV4)
  1770. //判断用户权限
  1771. hasPermission, err := services.GetUserhasPermission(user)
  1772. if err != nil {
  1773. br.Msg = "获取信息失败"
  1774. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1775. }
  1776. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1777. if err != nil {
  1778. br.Msg = "获取信息失败"
  1779. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1780. return
  1781. }
  1782. PermissionNameMap, err := services.GetPermissionNameMap()
  1783. if err != nil {
  1784. br.Msg = "获取失败"
  1785. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1786. return
  1787. }
  1788. PermissionIcoMap, err := services.GetPermissionNameIcoMap()
  1789. if err != nil {
  1790. br.Msg = "获取失败"
  1791. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1792. return
  1793. }
  1794. //未设置全部可见的只能给弘则内部查看
  1795. if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
  1796. resp.IsShow = true
  1797. }
  1798. resp.HasPermission = hasPermission
  1799. if hasPermission != 1 || !resp.IsShow {
  1800. br.Ret = 200
  1801. br.Success = true
  1802. br.Msg = "获取成功"
  1803. br.Data = resp
  1804. return
  1805. }
  1806. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1807. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1808. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1809. if err != nil {
  1810. br.Msg = "获取失败"
  1811. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1812. return
  1813. }
  1814. for k, v := range listFirst {
  1815. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1816. if err != nil && err.Error() != utils.ErrNoRow() {
  1817. br.Msg = "获取信息失败"
  1818. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1819. return
  1820. }
  1821. for k2, v2 := range listSecond {
  1822. v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
  1823. v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
  1824. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1825. if err != nil && err.Error() != utils.ErrNoRow() {
  1826. br.Msg = "获取信息失败"
  1827. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1828. return
  1829. }
  1830. if len(listThird) > 0 {
  1831. for k3, v3 := range listThird {
  1832. if v3.VideoUrl != "" {
  1833. listThird[k3].IsHaveVideo = true
  1834. }
  1835. if v3.ReportLink == "0" {
  1836. listThird[k3].ReportLink = ""
  1837. }
  1838. }
  1839. listSecond[k2].List = listThird
  1840. }
  1841. }
  1842. if len(listSecond) > 0 {
  1843. listFirst[k].List = listSecond
  1844. }
  1845. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1846. if v.Type == "CYDYJY" {
  1847. listFirst[k].ListName = "产业调研纪要"
  1848. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1849. } else if v.Type == "SSGS" {
  1850. listFirst[k].ListName = "上市公司调研纪要篇"
  1851. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1852. } else if v.Type == "YANX" {
  1853. listFirst[k].ListName = "买方研选纪要"
  1854. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1855. }
  1856. }
  1857. //go services.AddCygxReportHistoryRecord(user, articleId, "szjyhz")
  1858. go services.MinutesSummaryHistoryUserRmind(user, articleId) // 上周纪要汇总用户阅读,给销售发消息提醒
  1859. resp.List = listFirst
  1860. resp.Detail = detail
  1861. br.Ret = 200
  1862. br.Success = true
  1863. br.Msg = "获取成功"
  1864. br.Data = resp
  1865. }
  1866. // @Title 记录用户浏览音频回放接口
  1867. // @Description 记录用户浏览音频回放接口
  1868. // @Param request body models.ArticleIdReq true "type json string"
  1869. // @Success Ret=200 操作成功
  1870. // @router /voiceHistory/add [post]
  1871. func (this *ReportController) ResearchSummaryVoiceHistoryAdd() {
  1872. br := new(models.BaseResponse).Init()
  1873. defer func() {
  1874. this.Data["json"] = br
  1875. this.ServeJSON()
  1876. }()
  1877. user := this.User
  1878. if user == nil {
  1879. br.Msg = "请登录"
  1880. br.ErrMsg = "请登录,用户信息为空"
  1881. br.Ret = 408
  1882. return
  1883. }
  1884. uid := user.UserId
  1885. var req models.ArticleIdReq
  1886. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1887. if err != nil {
  1888. br.Msg = "参数解析异常!"
  1889. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1890. return
  1891. }
  1892. articleId := req.ArticleId
  1893. playSeconds := req.PlaySeconds
  1894. reportType := req.ReportType
  1895. //本周研究汇总
  1896. if reportType == 2 {
  1897. articleInfo, errInfo := models.GetCygxResearchSummaryInfoById(articleId)
  1898. if articleInfo == nil {
  1899. br.Msg = "操作失败"
  1900. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1901. return
  1902. }
  1903. if errInfo != nil {
  1904. br.Msg = "操作失败"
  1905. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1906. return
  1907. }
  1908. var sellerName string
  1909. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1910. if err != nil {
  1911. br.Msg = "报名失败!"
  1912. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1913. return
  1914. }
  1915. item := models.CygxResearchSummaryVoiceHistory{
  1916. ArticleId: articleId,
  1917. UserId: uid,
  1918. CreateTime: time.Now(),
  1919. Mobile: user.Mobile,
  1920. Email: user.Email,
  1921. CompanyId: user.CompanyId,
  1922. CompanyName: user.CompanyName,
  1923. RealName: user.RealName,
  1924. SellerName: sellerName,
  1925. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  1926. ModifyTime: time.Now(),
  1927. RegisterPlatform: utils.REGISTER_PLATFORM,
  1928. }
  1929. if playSeconds != 0 {
  1930. lastItem, err := models.GetLastCygxResearchSummaryVoiceHistory(articleId, user.UserId)
  1931. if err != nil {
  1932. br.Msg = "操作失败"
  1933. br.ErrMsg = "操作失败,GetLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  1934. return
  1935. }
  1936. err = models.UpdateLastCygxResearchSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  1937. if err != nil {
  1938. br.Msg = "更新失败"
  1939. br.ErrMsg = "更新失败,UpdateLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  1940. return
  1941. }
  1942. } else {
  1943. err = models.AddCygxResearchSummaryVoiceHistory(&item)
  1944. if err != nil {
  1945. br.Msg = "操作失败"
  1946. br.ErrMsg = "操作失败,Err:" + err.Error()
  1947. return
  1948. }
  1949. err = models.UpdateResearchSummaryVoiceCounts(articleId)
  1950. if err != nil {
  1951. br.Msg = "更新失败"
  1952. br.ErrMsg = "更新失败,Err:" + err.Error()
  1953. return
  1954. }
  1955. }
  1956. } else if reportType == 3 {
  1957. articleInfo, errInfo := models.GetCygxMinutesSummaryInfoById(articleId)
  1958. if articleInfo == nil {
  1959. br.Msg = "操作失败"
  1960. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1961. return
  1962. }
  1963. if errInfo != nil {
  1964. br.Msg = "操作失败"
  1965. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1966. return
  1967. }
  1968. var sellerName string
  1969. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  1970. if err != nil {
  1971. br.Msg = "报名失败!"
  1972. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  1973. return
  1974. }
  1975. item := models.CygxMinutesSummaryVoiceHistory{
  1976. ArticleId: articleId,
  1977. UserId: uid,
  1978. CreateTime: time.Now(),
  1979. Mobile: user.Mobile,
  1980. Email: user.Email,
  1981. CompanyId: user.CompanyId,
  1982. CompanyName: user.CompanyName,
  1983. RealName: user.RealName,
  1984. SellerName: sellerName,
  1985. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  1986. ModifyTime: time.Now(),
  1987. RegisterPlatform: utils.REGISTER_PLATFORM,
  1988. }
  1989. if playSeconds != 0 {
  1990. lastItem, err := models.GetLastCygxMinutesSummaryVoiceHistory(articleId, user.UserId)
  1991. if err != nil {
  1992. br.Msg = "操作失败"
  1993. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  1994. return
  1995. }
  1996. err = models.UpdateLastCygxMinutesSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  1997. if err != nil {
  1998. br.Msg = "更新失败"
  1999. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  2000. return
  2001. }
  2002. } else {
  2003. err = models.AddCygxMinutesSummaryVoiceHistory(&item)
  2004. if err != nil {
  2005. br.Msg = "操作失败"
  2006. br.ErrMsg = "操作失败,Err:" + err.Error()
  2007. return
  2008. }
  2009. err = models.UpdateMinutesSummaryVoiceCounts(articleId)
  2010. if err != nil {
  2011. br.Msg = "更新失败"
  2012. br.ErrMsg = "更新失败,Err:" + err.Error()
  2013. return
  2014. }
  2015. }
  2016. }
  2017. br.Ret = 200
  2018. br.Success = true
  2019. br.Msg = "操作成功"
  2020. return
  2021. }
  2022. // @Title 根据行业分类获取行业文章列表
  2023. // @Description 根据行业分类获取行业文章列表接口
  2024. // @Param PageSize query int true "每页数据条数"
  2025. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2026. // @Param CategoryId query int true "分类ID"
  2027. // @Param IndustrialManagementId query int false "产业ID"
  2028. // @Success 200 {object} models.TacticsListResp
  2029. // @router /tactics/list [get]
  2030. func (this *MobileReportController) TacticsList() {
  2031. br := new(models.BaseResponse).Init()
  2032. defer func() {
  2033. this.Data["json"] = br
  2034. this.ServeJSON()
  2035. }()
  2036. user := this.User
  2037. if user == nil {
  2038. br.Msg = "请重新登录"
  2039. br.Ret = 408
  2040. return
  2041. }
  2042. //uid := user.UserId
  2043. pageSize, _ := this.GetInt("PageSize")
  2044. currentIndex, _ := this.GetInt("CurrentIndex")
  2045. categoryId, _ := this.GetInt("CategoryId")
  2046. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  2047. var startSize int
  2048. if pageSize <= 0 {
  2049. pageSize = utils.PageSize20
  2050. }
  2051. if currentIndex <= 0 {
  2052. currentIndex = 1
  2053. }
  2054. startSize = paging.StartIndex(currentIndex, pageSize)
  2055. //var condition string
  2056. //var pars []interface{}
  2057. var total int
  2058. var err error
  2059. resp := new(models.TacticsListResp)
  2060. page := paging.GetPaging(currentIndex, pageSize, total)
  2061. list := make([]*models.ArticleListResp, 0)
  2062. if categoryId == utils.TIME_CATEGORYID {
  2063. list, total, err = models.GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize)
  2064. if err != nil {
  2065. br.Msg = "获取信息失败"
  2066. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  2067. return
  2068. }
  2069. } else {
  2070. if categoryId == utils.ACTEGORY_ID_AI_QY {
  2071. listArticle := make([]*models.HomeArticle, 0)
  2072. listArticle, total, err = services.GetAiQianYanArtilceList(startSize, pageSize)
  2073. if err != nil {
  2074. br.Msg = "获取信息失败"
  2075. br.Msg = "GetAiQianYanArtilceList,Err:" + err.Error()
  2076. return
  2077. }
  2078. for _, v := range listArticle {
  2079. list = append(list, &models.ArticleListResp{
  2080. ArticleId: v.ArticleId,
  2081. Title: v.Title,
  2082. CategoryId: v.CategoryId,
  2083. Annotation: v.Annotation,
  2084. Abstract: v.Abstract,
  2085. Body: v.Body,
  2086. PublishDate: v.PublishDate,
  2087. Resource: 1,
  2088. })
  2089. }
  2090. } else {
  2091. list, total, err = models.GetReportAndproductIndustrylListimg(categoryId, user.UserId, startSize, pageSize)
  2092. if err != nil {
  2093. br.Msg = "获取信息失败"
  2094. br.Msg = "GetHomeList,Err:" + err.Error()
  2095. return
  2096. }
  2097. }
  2098. articleIdMap, err := services.GetUserArticleHistoryRecord(user)
  2099. if err != nil {
  2100. br.Msg = "获取信息失败"
  2101. br.Msg = "获取帖子数据失败,Err:" + err.Error()
  2102. return
  2103. }
  2104. for k, v := range list {
  2105. //list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  2106. if !articleIdMap[v.ArticleId] && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  2107. list[k].IsRed = true
  2108. }
  2109. }
  2110. if categoryId > 0 {
  2111. detail, errCategory := models.GetCygxReportMappingCygxByCategoryId(categoryId)
  2112. if errCategory != nil {
  2113. br.Msg = "获取信息失败"
  2114. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  2115. return
  2116. }
  2117. resp.MatchTypeName = detail.MatchTypeName
  2118. }
  2119. //resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  2120. }
  2121. listPublic, err := services.HandleArticleCategoryImg(list, user)
  2122. if err != nil {
  2123. br.Msg = "获取失败"
  2124. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  2125. return
  2126. }
  2127. var articleIds []int
  2128. var productInteriorIs []int
  2129. for _, v := range listPublic {
  2130. if v.Resource == 1 {
  2131. articleIds = append(articleIds, v.ArticleId)
  2132. }
  2133. if v.Resource == 2 {
  2134. productInteriorIs = append(productInteriorIs, v.ArticleId)
  2135. }
  2136. }
  2137. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  2138. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  2139. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  2140. productInteriorMapPv := services.GetCygxProductInteriorHistoryListPvMap(productInteriorIs) //产品内测Pv
  2141. listResp := make([]*models.HomeArticle, 0)
  2142. for _, v := range listPublic {
  2143. item := new(models.HomeArticle)
  2144. item.ArticleId = v.ArticleId
  2145. item.ReportId = v.ReportId
  2146. item.Title = v.Title
  2147. item.Annotation = v.Annotation
  2148. item.Abstract = v.Abstract
  2149. item.ImgUrlPc = v.ImgUrlPc
  2150. item.PublishDate = v.PublishDate
  2151. item.Resource = v.Resource
  2152. if v.Resource == 1 {
  2153. item.Pv = articleMapPv[v.ArticleId]
  2154. item.IsCollect = articleCollectMap[v.ArticleId]
  2155. item.CollectNum = articleCollectNumMap[v.ArticleId]
  2156. }
  2157. if v.Resource == 2 {
  2158. item.Pv = productInteriorMapPv[v.ArticleId]
  2159. }
  2160. if v.ReportId > 0 {
  2161. item.Resource = 3
  2162. }
  2163. listResp = append(listResp, item)
  2164. }
  2165. if len(listResp) == 0 {
  2166. listResp = make([]*models.HomeArticle, 0)
  2167. }
  2168. page = paging.GetPaging(currentIndex, pageSize, total)
  2169. resp.List = listResp
  2170. resp.Paging = page
  2171. br.Ret = 200
  2172. br.Success = true
  2173. br.Msg = "获取成功"
  2174. br.Data = resp
  2175. }
  2176. // @Title 周期行业报告分类列表接口
  2177. // @Description 周期获取行业报告分类列表接口
  2178. // @Success 200 {object} models.TradeReportMappingResp
  2179. // @router /zhouqi_tradeList [get]
  2180. func (this *MobileReportController) ZouqiTradeList() {
  2181. br := new(models.BaseResponse).Init()
  2182. defer func() {
  2183. this.Data["json"] = br
  2184. this.ServeJSON()
  2185. }()
  2186. user := this.User
  2187. if user == nil {
  2188. br.Msg = "请重新登录"
  2189. br.Ret = 408
  2190. return
  2191. }
  2192. listCategory, err := models.GetCygxZhouqiArticleMapFirst()
  2193. if err != nil {
  2194. br.Msg = "获取信息失败"
  2195. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2196. return
  2197. }
  2198. fllowMap, fllowMapType := services.GetXzsChooseCategoryZhouqiMapByMobile(user.Mobile)
  2199. resp := new(models.TradeReportMappingResp)
  2200. var list []*models.TradeReportMapping
  2201. if len(listCategory) == 0 {
  2202. list = make([]*models.TradeReportMapping, 0)
  2203. } else {
  2204. for _, v := range listCategory {
  2205. item := new(models.TradeReportMapping)
  2206. item.CategoryId = v.CategoryId
  2207. item.MatchTypeName = v.MatchTypeName
  2208. item.UpdateTime = utils.TimeRemoveHms(v.ArticleUpdateTime)
  2209. item.IsFollow = fllowMap[item.CategoryId]
  2210. item.FollowType = fllowMapType[item.CategoryId]
  2211. item.ListArticle = make([]*models.HomeArticle, 0)
  2212. list = append(list, item)
  2213. }
  2214. }
  2215. resp.List = list
  2216. br.Ret = 200
  2217. br.Success = true
  2218. br.Msg = "获取成功"
  2219. br.Data = resp
  2220. }
  2221. // @Title 周期根据行业分类获取行业文章列表
  2222. // @Description 周期根据行业分类获取行业文章列表接口
  2223. // @Param PageSize query int true "每页数据条数"
  2224. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2225. // @Param CategoryId query int true "分类ID"
  2226. // @Success 200 {object} models.TacticsListResp
  2227. // @router /tactics/zhouqi_list [get]
  2228. func (this *MobileReportController) ZhouqiTacticsList() {
  2229. br := new(models.BaseResponse).Init()
  2230. defer func() {
  2231. this.Data["json"] = br
  2232. this.ServeJSON()
  2233. }()
  2234. user := this.User
  2235. if user == nil {
  2236. br.Msg = "请重新登录"
  2237. br.Ret = 408
  2238. return
  2239. }
  2240. //uid := user.UserId
  2241. pageSize, _ := this.GetInt("PageSize")
  2242. currentIndex, _ := this.GetInt("CurrentIndex")
  2243. categoryId, _ := this.GetInt("CategoryId")
  2244. var startSize int
  2245. if pageSize <= 0 {
  2246. pageSize = utils.PageSize20
  2247. }
  2248. if currentIndex <= 0 {
  2249. currentIndex = 1
  2250. }
  2251. startSize = paging.StartIndex(currentIndex, pageSize)
  2252. detail, err := models.GetCygxZhouqiArticleMapInfoById(categoryId)
  2253. if err != nil {
  2254. br.Msg = "获取信息失败"
  2255. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2256. return
  2257. }
  2258. var total int
  2259. //var err error
  2260. resp := new(models.TacticsListResp)
  2261. page := paging.GetPaging(currentIndex, pageSize, total)
  2262. list := make([]*models.ArticleListResp, 0)
  2263. listCategory, err := models.GetCygxZhouqiArticleMapByParentId(categoryId)
  2264. if err != nil {
  2265. br.Msg = "获取信息失败"
  2266. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  2267. return
  2268. }
  2269. var matchTypeName = []string{}
  2270. var seriesName = []string{}
  2271. for _, v := range listCategory {
  2272. if v.MatchTypeName != "" {
  2273. matchTypeName = append(matchTypeName, v.MatchTypeName)
  2274. }
  2275. if v.SeriesName != "" {
  2276. seriesName = append(seriesName, v.SeriesName)
  2277. }
  2278. }
  2279. var conditionOr string
  2280. if detail.FiccReportId != "" {
  2281. conditionOr = " OR art.report_id IN (" + detail.FiccReportId + ")" // 手动配置报告展示逻辑处理
  2282. }
  2283. if len(seriesName) > 0 {
  2284. conditionOr += " OR series_name IN ('" + strings.Join(seriesName, "','") + "') "
  2285. }
  2286. var condition string
  2287. //var pars []interface{}
  2288. //if len(seriesName) == 0 {
  2289. // condition = " AND field_name IN ('" + strings.Join(matchTypeName, "','") + "')"
  2290. //} else {
  2291. // condition = " AND ( field_name IN ('" + strings.Join(matchTypeName, "','") + "') OR series_name IN ('" + strings.Join(seriesName, "','") + "') )"
  2292. //}
  2293. condition = " AND ( field_name IN ('" + strings.Join(matchTypeName, "','") + "') " + conditionOr + " ) "
  2294. list, total, err = models.GetReportAndproductIndustrylListimgZhouqi(condition, startSize, pageSize)
  2295. if err != nil {
  2296. br.Msg = "获取信息失败"
  2297. br.Msg = "GetHomeList,Err:" + err.Error()
  2298. return
  2299. }
  2300. listPublic, err := services.HandleArticleCategoryImg(list, user)
  2301. if err != nil {
  2302. br.Msg = "获取失败"
  2303. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  2304. return
  2305. }
  2306. var articleIds []int
  2307. var productInteriorIs []int
  2308. for _, v := range listPublic {
  2309. if v.Resource == 1 {
  2310. articleIds = append(articleIds, v.ArticleId)
  2311. }
  2312. if v.Resource == 2 {
  2313. productInteriorIs = append(productInteriorIs, v.ArticleId)
  2314. }
  2315. }
  2316. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  2317. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  2318. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  2319. productInteriorMapPv := services.GetCygxProductInteriorHistoryListPvMap(productInteriorIs) //产品内测Pv
  2320. listResp := make([]*models.HomeArticle, 0)
  2321. for _, v := range listPublic {
  2322. item := new(models.HomeArticle)
  2323. item.ArticleId = v.ArticleId
  2324. item.ReportId = v.ReportId
  2325. item.Title = v.Title
  2326. item.Annotation = v.Annotation
  2327. item.Abstract = v.Abstract
  2328. item.ImgUrlPc = v.ImgUrlPc
  2329. item.PublishDate = v.PublishDate
  2330. item.Resource = v.Resource
  2331. if v.Resource == 1 {
  2332. item.Pv = articleMapPv[v.ArticleId]
  2333. item.IsCollect = articleCollectMap[v.ArticleId]
  2334. item.CollectNum = articleCollectNumMap[v.ArticleId]
  2335. }
  2336. if v.Resource == 2 {
  2337. item.Pv = productInteriorMapPv[v.ArticleId]
  2338. }
  2339. if v.ReportId > 0 {
  2340. item.Resource = 3
  2341. }
  2342. listResp = append(listResp, item)
  2343. }
  2344. if len(listResp) == 0 {
  2345. listResp = make([]*models.HomeArticle, 0)
  2346. }
  2347. page = paging.GetPaging(currentIndex, pageSize, total)
  2348. resp.List = listResp
  2349. resp.Paging = page
  2350. br.Ret = 200
  2351. br.Success = true
  2352. br.Msg = "获取成功"
  2353. br.Data = resp
  2354. }
  2355. // @Title 周期行业关注/取消关注
  2356. // @Description 周期行业关注/取消关注 接口
  2357. // @Param request body models.CygxCategoryFllowRep true "type json string"
  2358. // @Success 200
  2359. // @router /category/zhouqi_fllow [post]
  2360. func (this *ReportController) CategoryZhouqiFllow() {
  2361. br := new(models.BaseResponse).Init()
  2362. defer func() {
  2363. this.Data["json"] = br
  2364. this.ServeJSON()
  2365. }()
  2366. user := this.User
  2367. if user == nil {
  2368. br.Msg = "请重新登录"
  2369. br.Ret = 408
  2370. return
  2371. }
  2372. uid := user.UserId
  2373. var req models.CygxCategoryFllowRep
  2374. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  2375. if err != nil {
  2376. br.Msg = "参数解析异常!"
  2377. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  2378. return
  2379. }
  2380. categoryId := req.CategoryId
  2381. followType := req.FollowType
  2382. //count, err := models.GetCountCategoryFllowZhouqi(categoryId, user.Mobile)
  2383. //if err != nil {
  2384. // br.Msg = "获取数据失败!"
  2385. // br.ErrMsg = "获取数据失败,Err:" + err.Error()
  2386. // return
  2387. //}
  2388. resp := new(models.CygxIndustryFllowResp)
  2389. //if count == 0 {
  2390. item := new(models.CygxXzsChooseCategoryZhouqi)
  2391. item.CategoryId = categoryId
  2392. item.UserId = uid
  2393. item.Email = user.Email
  2394. item.Mobile = user.Mobile
  2395. item.RealName = user.RealName
  2396. item.CompanyId = user.CompanyId
  2397. item.CompanyName = user.CompanyName
  2398. item.FollowType = followType
  2399. item.CreateTime = time.Now()
  2400. item.ModifyTime = time.Now()
  2401. _, err = models.AddCygxCategoryFllowZhouqi(item)
  2402. if err != nil {
  2403. br.Msg = "操作失败"
  2404. br.ErrMsg = "操作失败,Err:" + err.Error()
  2405. return
  2406. }
  2407. resp.Status = followType
  2408. br.Msg = "操作成功"
  2409. //} else {
  2410. // err = models.RemoveCygxCategoryFllowZhouqi(user.Mobile, categoryId)
  2411. // if err != nil {
  2412. // br.Msg = "操作失败"
  2413. // br.ErrMsg = "取消关注失败,Err:" + err.Error()
  2414. // return
  2415. // }
  2416. // resp.Status = 2
  2417. // br.Msg = "已取消关注"
  2418. //}
  2419. br.Ret = 200
  2420. br.Success = true
  2421. br.Data = resp
  2422. }