report.go 66 KB

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