report.go 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503
  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.GetReportMappingStrategyHomeAll(user.UserId, ChartPermissionId)
  51. list = listTrade
  52. err = errTrade
  53. if user.Mobile != "" {
  54. //策略的处理
  55. categoryList, err := models.GetCygxXzsChooseCategoryList(user.Mobile)
  56. if err != nil && err.Error() != utils.ErrNoRow() {
  57. br.Msg = "获取信息失败"
  58. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  59. return
  60. }
  61. for _, v := range categoryList {
  62. mapCategory[v.CategoryId] = v.CategoryId
  63. }
  64. }
  65. for k, v := range list {
  66. count, err := models.GetUserIsReadThisNewCategoryArticleCount(v.CategoryId, uid)
  67. if err != nil && err.Error() != utils.ErrNoRow() {
  68. br.Msg = "获取信息失败"
  69. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  70. return
  71. }
  72. Newdetail, err := models.GetNewArticleByCategoryId(v.CategoryId)
  73. if err != nil {
  74. br.Msg = "获取信息失败"
  75. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  76. return
  77. }
  78. if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
  79. list[k].IsRed = true
  80. }
  81. }
  82. } else {
  83. listTrade, errTrade := models.GetTradeAll(ChartPermissionId)
  84. err = errTrade
  85. list = listTrade
  86. }
  87. if err != nil {
  88. br.Msg = "获取信息失败"
  89. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  90. return
  91. }
  92. for k, v := range list {
  93. var condition string
  94. var pars []interface{}
  95. //categoryIdSet, errCategory := models.GetdetailByCategoryIdSet(v.CategoryId)
  96. //if errCategory != nil {
  97. // br.Msg = "获取信息失败"
  98. // br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(v.CategoryId)
  99. // return
  100. //}
  101. //if categoryIdSet != "" {
  102. // condition = ` AND a.category_id IN(` + categoryIdSet + `)`
  103. //} else {
  104. // condition = ` AND a.category_id IN(` + strconv.Itoa(v.CategoryId) + `)`
  105. //}
  106. if v.PolymerizationId != "" {
  107. condition = ` AND a.category_id IN(` + v.PolymerizationId + `)`
  108. } else {
  109. condition = ` AND a.category_id IN(` + strconv.Itoa(v.CategoryId) + `)`
  110. }
  111. if ChartPermissionId != utils.CE_LUE_ID && ChartPermissionId != utils.GU_SHOU_ID {
  112. var pageSize int
  113. //if ChartPermissionId == utils.KE_JI_ID {
  114. // pageSize = 12
  115. //} else {
  116. // pageSize = 3
  117. //}
  118. pageSize = 3
  119. listArticle, err := models.GetHomeList(condition, pars, 0, pageSize)
  120. if err != nil {
  121. br.Msg = "获取信息失败"
  122. br.Msg = "GetHomeList,Err:" + err.Error()
  123. return
  124. }
  125. if len(listArticle) > 0 {
  126. list[k].UpdateTime = utils.StrTimeToTime(listArticle[0].PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
  127. count, err := models.CheckThisCategoryNewArticleIsRead(uid, v.CategoryId)
  128. if err != nil {
  129. br.Msg = "获取信息失败"
  130. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  131. return
  132. }
  133. if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
  134. list[k].IsRed = true
  135. }
  136. }
  137. list[k].ListArticle = listArticle
  138. } else {
  139. if mapCategory[v.CategoryId] > 0 {
  140. list[k].IsFollow = true
  141. }
  142. list[k].ListArticle = make([]*models.HomeArticle, 0)
  143. }
  144. }
  145. resp := new(models.TradeReportMappingResp)
  146. if len(list) == 0 {
  147. list = make([]*models.TradeReportMapping, 0)
  148. }
  149. resp.List = list
  150. br.Ret = 200
  151. br.Success = true
  152. br.Msg = "获取成功"
  153. br.Data = resp
  154. }
  155. // @Title 产业报告分类列表接口
  156. // @Description 获取产业报告分类列表接口
  157. // @Param ChartPermissionId query int true "分类ID"
  158. // @Param DeepCover query int false "是否选择深度覆盖,1是,0否 不填默认为0"
  159. // @Param RecommendFocus query int false "是否选择推荐关注,1是,0否 不填默认为0"
  160. // @Param PageSize query int true "每页数据条数"
  161. // @Param CurrentIndex query int true "当前页页码,从1开始"
  162. // @Param IsBillboard query bool false "是否属于榜单 是true 否 false"
  163. // @Success 200 {object} models.IndustrialManagementList
  164. // @router /industryList [get]
  165. func (this *MobileReportController) IndustryList() {
  166. br := new(models.BaseResponse).Init()
  167. defer func() {
  168. this.Data["json"] = br
  169. this.ServeJSON()
  170. }()
  171. user := this.User
  172. if user == nil {
  173. br.Msg = "请重新登录"
  174. br.Ret = 408
  175. return
  176. }
  177. uid := user.UserId
  178. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  179. orderColumn := this.GetString("OrderColumn")
  180. orderColumnNew := this.GetString("OrderColumn")
  181. isNewLabel := this.GetString("IsNewLabel")
  182. isDeepLabel := this.GetString("IsDeepLabel")
  183. pageSize, _ := this.GetInt("PageSize")
  184. currentIndex, _ := this.GetInt("CurrentIndex")
  185. deepCover, _ := this.GetInt("DeepCover")
  186. recommendFocus, _ := this.GetInt("RecommendFocus")
  187. isBillboard, _ := this.GetBool("IsBillboard", false)
  188. var orderSrt string
  189. var condition string
  190. var startSize int
  191. resp := new(models.IndustrialManagementList)
  192. if pageSize <= 0 {
  193. pageSize = utils.PageSize20
  194. }
  195. if currentIndex <= 0 {
  196. currentIndex = 1
  197. }
  198. startSize = paging.StartIndex(currentIndex, pageSize)
  199. if ChartPermissionId > 0 {
  200. condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
  201. }
  202. // 获取近一个月产业报告阅读次数最多的产业
  203. var topCond string
  204. var topPars []interface{}
  205. topReadIndustryId := 0
  206. if ChartPermissionId > 0 {
  207. topCond += ` AND chart_permission_id = ?`
  208. topPars = append(topPars, ChartPermissionId)
  209. }
  210. topReadIndustry, e := models.GetTopOneMonthArtReadNumIndustry(topCond, topPars)
  211. if e != nil && e.Error() != utils.ErrNoRow() {
  212. br.Msg = "获取信息失败"
  213. br.ErrMsg = "获取近一个月报告阅读次数最多的产业失败, Err: " + e.Error()
  214. return
  215. }
  216. if topReadIndustry != nil {
  217. topReadIndustryId = topReadIndustry.IndustrialManagementId
  218. }
  219. // 深度覆盖
  220. if deepCover == 1 {
  221. // 查询深标签产业报告数
  222. var deepCondition string
  223. var deepPars []interface{}
  224. deepCondition += ` AND man.is_deep_label = 1`
  225. if ChartPermissionId > 0 {
  226. deepCondition += ` AND man.chart_permission_id = ?`
  227. deepPars = append(deepPars, ChartPermissionId)
  228. }
  229. industryCountList, e := models.GetIndustryArtCountByCondition(deepCondition, deepPars)
  230. if e != nil {
  231. br.Msg = "获取信息失败"
  232. br.ErrMsg = "获取深标签产业报告数失败, Err: " + e.Error()
  233. return
  234. }
  235. deepIdArr := make([]string, 0)
  236. for i := range industryCountList {
  237. if industryCountList[i].ArtNum > 10 {
  238. deepIdArr = append(deepIdArr, strconv.Itoa(industryCountList[i].IndustrialManagementId))
  239. }
  240. }
  241. deepIds := strings.Join(deepIdArr, ",")
  242. if deepIds != "" {
  243. condition = `AND man.industrial_management_id IN (` + deepIds + `)`
  244. }
  245. }
  246. // 推荐关注
  247. if recommendFocus == 1 {
  248. condition += ` AND man.recommended_index >= 80`
  249. }
  250. var list []*models.IndustrialManagement
  251. total, err := models.GetIndustrialManagementAllCount(condition)
  252. if err != nil {
  253. br.Msg = "获取信息失败"
  254. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  255. return
  256. }
  257. if orderColumn == "" {
  258. orderColumn = "NewTime"
  259. }
  260. if orderColumn == "NewTime" {
  261. orderSrt = "update_time DESC"
  262. } else {
  263. orderSrt = "man.recommended_index DESC,update_time DESC"
  264. }
  265. if isBillboard {
  266. // 查询有已归类行业报告的行业IDs
  267. activeIndustryIds, e := models.GetActiveArticleIndustryIds()
  268. if e != nil {
  269. br.Msg = "获取失败"
  270. br.ErrMsg = "获取已归类行业失败, Err:" + e.Error()
  271. return
  272. }
  273. activeIndustryLen := len(activeIndustryIds)
  274. //topNum := pageSize
  275. condition = ""
  276. var parsBd []interface{}
  277. if ChartPermissionId > 0 {
  278. condition += ` AND man.chart_permission_id = ? `
  279. parsBd = append(parsBd, ChartPermissionId)
  280. }
  281. if activeIndustryLen > 0 {
  282. condition += ` AND man.industrial_management_id IN (` + utils.GetOrmInReplace(activeIndustryLen) + `)`
  283. parsBd = append(parsBd, activeIndustryIds)
  284. }
  285. nowTime := time.Now().Local()
  286. startTime := nowTime.AddDate(0, -1, 0)
  287. endTime := nowTime.AddDate(0, 0, -1)
  288. condition += ` AND idf.create_time BETWEEN ? AND ?`
  289. parsBd = append(parsBd, startTime, endTime)
  290. list, e = models.GetTopIndustryFollowData(0, pageSize, condition, parsBd)
  291. if e != nil {
  292. br.Msg = "获取失败"
  293. br.ErrMsg = "获取关注度最高的产业数据失败, Err:" + e.Error()
  294. return
  295. }
  296. } else {
  297. list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize, isBillboard)
  298. if err != nil {
  299. br.Msg = "获取信息失败"
  300. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  301. return
  302. }
  303. }
  304. var resource string
  305. if ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  306. resource = utils.REOURCE_YX
  307. } else {
  308. resource = utils.REOURCE_HZ
  309. }
  310. list, err = services.HandleIndustryList(list, user, resource)
  311. if err != nil {
  312. br.Msg = "获取信息失败"
  313. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  314. return
  315. }
  316. industrialIdArr := make([]int, 0)
  317. for k, v := range list {
  318. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  319. if topReadIndustryId > 0 && list[k].IndustrialManagementId == topReadIndustryId {
  320. list[k].IsHot = true
  321. }
  322. }
  323. if orderColumnNew != "" {
  324. item := new(models.CygxReportIndustrialSeaarchHistory)
  325. item.UserId = user.UserId
  326. item.Mobile = user.Mobile
  327. item.CompanyId = user.CompanyId
  328. item.CompanyName = user.CompanyName
  329. item.CreateTime = time.Now()
  330. item.IsDeepLabel = isDeepLabel
  331. item.IsNewLabel = isNewLabel
  332. item.ChartPermissionId = ChartPermissionId
  333. if orderColumnNew == "NewTime" {
  334. item.OrderColumn = "0"
  335. } else {
  336. item.OrderColumn = "1"
  337. }
  338. go models.AddCygxReportIndustrialSeaarchHistory(item)
  339. }
  340. if len(list) == 0 {
  341. list = make([]*models.IndustrialManagement, 0)
  342. }
  343. page := paging.GetPaging(currentIndex, pageSize, total)
  344. if isBillboard {
  345. total = len(list)
  346. }
  347. resp.List = list
  348. resp.Paging = page
  349. br.Ret = 200
  350. br.Success = true
  351. br.Msg = "获取成功"
  352. br.Data = resp
  353. }
  354. // @Title 产业下所关联的文章分类列表
  355. // @Description 产业下所关联的文章分类列表接口
  356. // @Param IndustrialManagementId query int true "产业ID"
  357. // @Success 200 {object} models.IndustrialToArticleCategoryListRep
  358. // @router /toArticleCategoryList [get]
  359. func (this *MobileReportController) ArticleCategoryList() {
  360. br := new(models.BaseResponse).Init()
  361. defer func() {
  362. this.Data["json"] = br
  363. this.ServeJSON()
  364. }()
  365. user := this.User
  366. if user == nil {
  367. br.Msg = "请重新登录"
  368. br.Ret = 408
  369. return
  370. }
  371. uid := user.UserId
  372. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  373. if industrialManagementId < 1 {
  374. br.Msg = "请输入分类ID"
  375. return
  376. }
  377. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  378. if err != nil {
  379. br.Msg = "获取信息失败"
  380. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  381. return
  382. }
  383. list, err := models.IndustrialToArticleCategory(industrialManagementId, detail.ChartPermissionId)
  384. if err != nil {
  385. br.Msg = "获取信息失败"
  386. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  387. return
  388. }
  389. for k, v := range list {
  390. recordCount, err := models.IndustrialUserRecordArticleCount(uid, industrialManagementId, v.CategoryId)
  391. if err != nil && err.Error() != utils.ErrNoRow() {
  392. br.Msg = "获取信息失败"
  393. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  394. return
  395. }
  396. Newdetail, err := models.GetNewIndustrialUserRecordArticle(industrialManagementId, v.CategoryId)
  397. if err != nil {
  398. br.Msg = "获取信息失败"
  399. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  400. return
  401. }
  402. if Newdetail != nil {
  403. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
  404. list[k].IsRed = true
  405. }
  406. }
  407. }
  408. //标的列表
  409. industrialSubjectList, err := models.GetIndustrialSubjectAll(industrialManagementId)
  410. if err != nil {
  411. br.Msg = "获取信息失败"
  412. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  413. return
  414. }
  415. videoSimple, au, err := services.GetindustryVideo(user, industrialManagementId)
  416. if err != nil {
  417. br.Msg = "获取失败"
  418. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  419. return
  420. }
  421. timeLineItem := models.IndustrialToArticleCategoryRep{
  422. CategoryId: utils.TIME_CATEGORYID,
  423. MatchTypeName: "时间线",
  424. }
  425. timeLineIsRed, err := services.GetShowTimeLineIsRed(user, industrialManagementId)
  426. if err != nil {
  427. br.Msg = "获取失败"
  428. br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
  429. return
  430. }
  431. timeLineItem.IsRed = timeLineIsRed
  432. list = append([]*models.IndustrialToArticleCategoryRep{&timeLineItem}, list...)
  433. resp := new(models.IndustrialToArticleCategoryListRep)
  434. resp.List = list
  435. resp.ListSubject = industrialSubjectList
  436. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  437. resp.IndustryName = detail.IndustryName
  438. resp.IndustrialManagementId = industrialManagementId
  439. if videoSimple != nil && videoSimple.Id > 0 {
  440. resp.IndustryVideo = videoSimple
  441. }
  442. resp.AuthInfo = au
  443. br.Ret = 200
  444. br.Success = true
  445. br.Msg = "获取成功"
  446. br.Data = resp
  447. }
  448. // @Title 根据行业分类获取文章列表
  449. // @Description根据行业分类获取文章列表接口
  450. // @Param PageSize query int true "每页数据条数"
  451. // @Param CurrentIndex query int true "当前页页码,从1开始"
  452. // @Param CategoryId query int true "分类ID"
  453. // @Param IndustrialManagementId query int false "产业ID"
  454. // @Success 200 {object} models.TacticsListResp
  455. // @router /articleList/byCategoryId [get]
  456. func (this *MobileReportController) List() {
  457. br := new(models.BaseResponse).Init()
  458. defer func() {
  459. this.Data["json"] = br
  460. this.ServeJSON()
  461. }()
  462. user := this.User
  463. if user == nil {
  464. br.Msg = "请重新登录"
  465. br.Ret = 408
  466. return
  467. }
  468. //uid := user.UserId
  469. pageSize, _ := this.GetInt("PageSize")
  470. currentIndex, _ := this.GetInt("CurrentIndex")
  471. categoryId, _ := this.GetInt("CategoryId")
  472. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  473. var startSize int
  474. if pageSize <= 0 {
  475. pageSize = utils.PageSize20
  476. }
  477. if currentIndex <= 0 {
  478. currentIndex = 1
  479. }
  480. startSize = paging.StartIndex(currentIndex, pageSize)
  481. var condition string
  482. var pars []interface{}
  483. var total int
  484. resp := new(models.TacticsListResp)
  485. page := paging.GetPaging(currentIndex, pageSize, total)
  486. list := make([]*models.ArticleListResp, 0)
  487. if categoryId == utils.TIME_CATEGORYID {
  488. var err error
  489. list, total, err = models.GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize)
  490. if err != nil {
  491. br.Msg = "获取信息失败"
  492. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  493. return
  494. }
  495. } else {
  496. //获取该产业下所对应的行业图片
  497. var reportType int
  498. if industrialManagementId > 0 {
  499. reportType = 2
  500. } else {
  501. reportType = 1
  502. }
  503. detail, errCategory := models.GetdetailByCategoryIdOne(categoryId, reportType)
  504. if errCategory != nil {
  505. br.Msg = "获取信息失败"
  506. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  507. return
  508. }
  509. //对应行业的图片
  510. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  511. if err != nil {
  512. br.Msg = "获取数据失败"
  513. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  514. return
  515. }
  516. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  517. mapChartPermission := make(map[string]string)
  518. var permissionName string
  519. var imgUrlChartPermission string
  520. for _, v := range chartPermissionUrlList {
  521. vslice := strings.Split(v, "_")
  522. permissionName = vslice[0]
  523. imgUrlChartPermission = vslice[len(vslice)-1]
  524. mapChartPermission[permissionName] = imgUrlChartPermission
  525. }
  526. //对应分类的所图片
  527. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  528. if err != nil {
  529. br.Msg = "获取数据失败"
  530. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  531. return
  532. }
  533. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  534. mapCategoryUrl := make(map[string]string)
  535. var categoryIdStr string
  536. var imgUrlChart string
  537. for _, v := range categoryUrlList {
  538. vslice := strings.Split(v, "_")
  539. categoryIdStr = vslice[0]
  540. imgUrlChart = vslice[len(vslice)-1]
  541. mapCategoryUrl[categoryIdStr] = imgUrlChart
  542. }
  543. if detail.CeLueFieldId != "" {
  544. condition = ` AND ce_lue_field_id IN(` + detail.CeLueFieldId + `)`
  545. } else if detail.PolymerizationId != "" {
  546. condition = ` AND category_id IN(` + detail.PolymerizationId + `)`
  547. } else {
  548. categoryIdSet, errCategory := models.GetdetailByCategoryIdSet(categoryId)
  549. if errCategory != nil {
  550. br.Msg = "获取信息失败"
  551. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  552. return
  553. }
  554. if categoryIdSet != "" {
  555. condition = ` AND category_id IN(` + categoryIdSet + `)`
  556. } else {
  557. condition = ` AND category_id IN(` + strconv.Itoa(categoryId) + `)`
  558. }
  559. }
  560. if industrialManagementId > 0 {
  561. industrialManageentList, err := models.GetIndustrialArticleGroupManagementByIndustrialManagementId(industrialManagementId)
  562. if err != nil {
  563. br.Msg = "获取信息失败"
  564. br.Msg = "获取产业关联的文章ID失败,GetIndustrialArticleGroupManagementByIndustrialManagementIdErr:" + err.Error()
  565. return
  566. }
  567. articleIdList := make([]string, 0)
  568. for _, v := range industrialManageentList {
  569. articleIdList = append(articleIdList, strconv.Itoa(v.ArticleId))
  570. }
  571. condition += ` AND a.article_id IN ( ` + utils.GetOrmInReplace(len(articleIdList)) + ` ) `
  572. pars = append(pars, articleIdList)
  573. }
  574. total, err = models.GetHomeCount(condition, pars)
  575. if err != nil {
  576. br.Msg = "获取信息失败"
  577. br.Msg = "获取帖子总数失败,Err:" + err.Error()
  578. return
  579. }
  580. list, err = models.GetHomeListNew(condition, pars, startSize, pageSize)
  581. if err != nil {
  582. br.Msg = "获取信息失败"
  583. br.Msg = "获取帖子数据失败,Err:" + err.Error()
  584. return
  585. }
  586. articleIdMap, err := services.GetUserArticleHistoryRecord(user)
  587. if err != nil {
  588. br.Msg = "获取信息失败"
  589. br.Msg = "获取帖子数据失败,Err:" + err.Error()
  590. return
  591. }
  592. for k, v := range list {
  593. list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  594. if !articleIdMap[v.ArticleId] && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  595. list[k].IsRed = true
  596. }
  597. }
  598. if categoryId > 0 {
  599. detail, errCategory := models.GetdetailByCategoryId(categoryId)
  600. if errCategory != nil {
  601. br.Msg = "获取信息失败"
  602. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  603. return
  604. }
  605. resp.MatchTypeName = detail.MatchTypeName
  606. }
  607. resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  608. }
  609. listPublic, err := services.HandleArticleCategoryImg(list, user)
  610. if err != nil {
  611. br.Msg = "获取失败"
  612. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  613. return
  614. }
  615. listResp := make([]*models.HomeArticle, 0)
  616. //listResp :=
  617. for _, v := range listPublic {
  618. listResp = append(listResp, &models.HomeArticle{
  619. ArticleId: v.ArticleId,
  620. Title: v.Title,
  621. Annotation: "核心观点:" + v.Annotation,
  622. Abstract: v.Abstract,
  623. ImgUrlPc: v.ImgUrlPc,
  624. PublishDate: v.PublishDate,
  625. })
  626. }
  627. //lenList := len(list)
  628. //for i := 0; i < lenList; i++ {
  629. // item := list[i]
  630. // list[i].Body = ""
  631. // list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  632. // list[i].Annotation, _ = services.GetReportContentTextSub(item.Annotation)
  633. // list[i].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
  634. // //行业比较研究、资金流向,显示报告的摘要
  635. // if resp.MatchTypeName == "行业比较研究" || resp.MatchTypeName == "资金流向" {
  636. // list[i].Annotation = list[i].Abstract
  637. // }
  638. //}
  639. if len(listResp) == 0 {
  640. listResp = make([]*models.HomeArticle, 0)
  641. }
  642. page = paging.GetPaging(currentIndex, pageSize, total)
  643. resp.List = listResp
  644. resp.Paging = page
  645. br.Ret = 200
  646. br.Success = true
  647. br.Msg = "获取成功"
  648. br.Data = resp
  649. }
  650. // @Title 产业关注/取消关注
  651. // @Description 产业关注/取消关注 接口
  652. // @Param request body models.CygxIndustryFllowRep true "type json string"
  653. // @Success 200
  654. // @router /industrial/fllow [post]
  655. func (this *ReportController) IndustrialFllow() {
  656. br := new(models.BaseResponse).Init()
  657. defer func() {
  658. this.Data["json"] = br
  659. this.ServeJSON()
  660. }()
  661. user := this.User
  662. if user == nil {
  663. br.Msg = "请重新登录"
  664. br.Ret = 408
  665. return
  666. }
  667. uid := user.UserId
  668. var req models.CygxIndustryFllowRep
  669. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  670. if err != nil {
  671. br.Msg = "参数解析异常!"
  672. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  673. return
  674. }
  675. industrialManagementId := req.IndustrialManagementId
  676. var condition string
  677. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  678. if err != nil {
  679. br.Msg = "获取数据失败!"
  680. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  681. return
  682. }
  683. if countIndustrial == 0 {
  684. br.Msg = "产业不存在!"
  685. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  686. return
  687. }
  688. count, err := models.GetCountCygxIndustryFllow(industrialManagementId, user.UserId, condition)
  689. if err != nil {
  690. br.Msg = "获取数据失败!"
  691. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  692. return
  693. }
  694. resp := new(models.CygxIndustryFllowResp)
  695. if count == 0 {
  696. item := new(models.CygxIndustryFllow)
  697. item.IndustrialManagementId = industrialManagementId
  698. item.UserId = uid
  699. item.Email = user.Email
  700. item.Mobile = user.Mobile
  701. item.RealName = user.RealName
  702. item.CompanyId = user.CompanyId
  703. item.CompanyName = user.CompanyName
  704. item.Type = 1
  705. item.CreateTime = time.Now()
  706. item.ModifyTime = time.Now()
  707. _, err = models.AddCygxIndustryFllow(item)
  708. if err != nil {
  709. br.Msg = "操作失败"
  710. br.ErrMsg = "操作失败,Err:" + err.Error()
  711. return
  712. }
  713. resp.Status = 1
  714. br.Msg = "关注成功"
  715. } else {
  716. err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
  717. if err != nil {
  718. br.Msg = "操作失败"
  719. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  720. return
  721. }
  722. resp.Status = 2
  723. br.Msg = "已取消关注"
  724. }
  725. //处理是否关注全部赛道字段
  726. go services.IndustryFllowWithTrack(industrialManagementId, count, uid)
  727. br.Ret = 200
  728. br.Success = true
  729. br.Data = resp
  730. }
  731. // @Title 行业关注/取消关注
  732. // @Description 行业关注/取消关注 接口
  733. // @Param request body models.CygxCategoryFllowRep true "type json string"
  734. // @Success 200
  735. // @router /category/fllow [post]
  736. func (this *ReportController) CategoryFllow() {
  737. br := new(models.BaseResponse).Init()
  738. defer func() {
  739. this.Data["json"] = br
  740. this.ServeJSON()
  741. }()
  742. user := this.User
  743. if user == nil {
  744. br.Msg = "请重新登录"
  745. br.Ret = 408
  746. return
  747. }
  748. uid := user.UserId
  749. var req models.CygxCategoryFllowRep
  750. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  751. if err != nil {
  752. br.Msg = "参数解析异常!"
  753. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  754. return
  755. }
  756. categoryId := req.CategoryId
  757. var condition string
  758. countCategory, err := models.GetCategoryCount(categoryId)
  759. if err != nil {
  760. br.Msg = "获取数据失败!"
  761. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  762. return
  763. }
  764. if countCategory == 0 {
  765. br.Msg = "产业不存在!"
  766. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(categoryId)
  767. return
  768. }
  769. count, err := models.GetCountCategoryFllow(categoryId, user.Mobile, condition)
  770. if err != nil {
  771. br.Msg = "获取数据失败!"
  772. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  773. return
  774. }
  775. resp := new(models.CygxIndustryFllowResp)
  776. if count == 0 {
  777. item := new(models.CygxXzsChooseCategory)
  778. item.CategoryId = categoryId
  779. item.UserId = uid
  780. item.Email = user.Email
  781. item.Mobile = user.Mobile
  782. item.RealName = user.RealName
  783. item.CompanyId = user.CompanyId
  784. item.CompanyName = user.CompanyName
  785. item.CreateTime = time.Now()
  786. item.ModifyTime = time.Now()
  787. _, err = models.AddCygxCategoryFllow(item)
  788. if err != nil {
  789. br.Msg = "操作失败"
  790. br.ErrMsg = "操作失败,Err:" + err.Error()
  791. return
  792. }
  793. resp.Status = 1
  794. br.Msg = "关注成功"
  795. } else {
  796. err = models.RemoveCygxCategoryFllow(user.Mobile, categoryId)
  797. if err != nil {
  798. br.Msg = "操作失败"
  799. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  800. return
  801. }
  802. resp.Status = 2
  803. br.Msg = "已取消关注"
  804. }
  805. br.Ret = 200
  806. br.Success = true
  807. br.Data = resp
  808. }
  809. // @Title 报告搜索
  810. // @Description 报告搜索接口
  811. // @Param PageSize query int true "每页数据条数"
  812. // @Param CurrentIndex query int true "当前页页码,从1开始"
  813. // @Param KeyWord query string true "搜索关键词"
  814. // @Param ArticleType query int true "文章类型,1弘则报告、2研选 "
  815. // @Param IsAll query bool true "是否为综合 "
  816. // @Success 200 {object} models.ReoprtSearchResp
  817. // @router /searchReport [get]
  818. func (this *MobileReportController) SearchReport() {
  819. br := new(models.BaseResponse).Init()
  820. defer func() {
  821. this.Data["json"] = br
  822. this.ServeJSON()
  823. }()
  824. user := this.User
  825. if user == nil {
  826. br.Msg = "请重新登录"
  827. br.Ret = 408
  828. return
  829. }
  830. pageSize, _ := this.GetInt("PageSize")
  831. currentIndex, _ := this.GetInt("CurrentIndex")
  832. articleType, _ := this.GetInt("ArticleType", 1)
  833. keyWord := this.GetString("KeyWord")
  834. isAll, _ := this.GetBool("IsAll")
  835. var condition string
  836. var pars []interface{}
  837. //var conditionSql string
  838. var total int
  839. var startSize int
  840. if pageSize <= 0 {
  841. pageSize = utils.PageSize20
  842. }
  843. if isAll {
  844. pageSize = utils.PageSize5
  845. }
  846. if currentIndex <= 0 {
  847. currentIndex = 1
  848. }
  849. startSize = paging.StartIndex(currentIndex, pageSize)
  850. resp := new(models.ReoprtSearchResp)
  851. //匹配报告标题、
  852. articleTypeIds, err := services.GetYanXuanArticleTypeIds()
  853. if err != nil {
  854. br.Msg = "获取信息失败"
  855. br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
  856. return
  857. }
  858. if articleTypeIds == "" {
  859. br.Msg = "获取信息失败"
  860. br.ErrMsg = "研选分类ID不能为空"
  861. return
  862. }
  863. //处理对应的文章类型标签按钮
  864. nameMap, styleMap, err := services.GetArticleTypeMap()
  865. if err != nil {
  866. br.Msg = "获取信息失败"
  867. br.ErrMsg = "GetArticleTypeMap Err:" + err.Error()
  868. return
  869. }
  870. if isAll {
  871. total = utils.PageSize5
  872. 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 + `) `
  873. 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 + `) `
  874. listHz, err := models.GetArticleResearchListHz(conditionHz, pars, startSize, pageSize, user.UserId)
  875. if err != nil {
  876. br.Msg = "获取信息失败"
  877. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  878. return
  879. }
  880. listYx, err := models.GetArticleResearchList(conditionYx, pars, startSize, pageSize, user.UserId)
  881. if err != nil {
  882. br.Msg = "获取信息失败"
  883. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  884. return
  885. }
  886. listHz, err = services.HandleArticleCategoryImg(listHz, user)
  887. if err != nil {
  888. br.Msg = "获取信息失败"
  889. br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
  890. return
  891. }
  892. listYx, err = services.HandleArticleCategoryImg(listYx, user)
  893. if err != nil {
  894. br.Msg = "获取信息失败"
  895. br.ErrMsg = "HandleArticleCategoryImg,Err:" + err.Error()
  896. return
  897. }
  898. for _, v := range listHz {
  899. item := models.ArticleResearchResp{
  900. ArticleId: v.ArticleId,
  901. ArticleTypeId: v.ArticleTypeId,
  902. Title: v.Title,
  903. PublishDate: v.PublishDate,
  904. DepartmentId: v.DepartmentId,
  905. NickName: v.NickName,
  906. IsCollect: v.IsCollect,
  907. Pv: v.Pv,
  908. CollectNum: v.CollectNum,
  909. Abstract: v.Abstract,
  910. Annotation: v.Annotation,
  911. ImgUrlPc: v.ImgUrlPc,
  912. ArticleTypeName: nameMap[v.ArticleTypeId],
  913. ButtonStyle: styleMap[v.ArticleTypeId],
  914. List: v.List,
  915. }
  916. resp.ListHz = append(resp.ListHz, &item)
  917. }
  918. for _, v := range listYx {
  919. item := models.ArticleResearchResp{
  920. ArticleId: v.ArticleId,
  921. ArticleTypeId: v.ArticleTypeId,
  922. Title: v.Title,
  923. PublishDate: v.PublishDate,
  924. DepartmentId: v.DepartmentId,
  925. NickName: v.NickName,
  926. IsCollect: v.IsCollect,
  927. Pv: v.Pv,
  928. CollectNum: v.CollectNum,
  929. Abstract: v.Abstract,
  930. Annotation: v.Annotation,
  931. ImgUrlPc: v.ImgUrlPc,
  932. ArticleTypeName: nameMap[v.ArticleTypeId],
  933. ButtonStyle: styleMap[v.ArticleTypeId],
  934. List: v.List,
  935. }
  936. resp.ListYx = append(resp.ListYx, &item)
  937. }
  938. } else {
  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 `
  940. if articleType == 1 {
  941. 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 + `) `
  942. total, err = models.GetReoprtSearchCountHz(condition)
  943. } else {
  944. 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 + `) `
  945. total, err = models.GetReoprtSearchCountYx(condition)
  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. list, err = models.GetArticleResearchList(condition, pars, startSize, pageSize, user.UserId)
  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 articleType == 1 {
  990. resp.ListHz = append(resp.ListHz, &item)
  991. } else {
  992. resp.ListYx = append(resp.ListYx, &item)
  993. }
  994. }
  995. }
  996. if keyWord != "" {
  997. go services.AddUserSearchLog(user, keyWord, 5)
  998. }
  999. if len(resp.ListHz) == 0 {
  1000. resp.ListHz = make([]*models.ArticleResearchResp, 0)
  1001. }
  1002. if len(resp.ListYx) == 0 {
  1003. resp.ListYx = make([]*models.ArticleResearchResp, 0)
  1004. }
  1005. page := paging.GetPaging(currentIndex, pageSize, total)
  1006. resp.Paging = page
  1007. br.Ret = 200
  1008. br.Success = true
  1009. br.Msg = "获取成功"
  1010. br.Data = resp
  1011. }
  1012. // @Title 资源包搜索
  1013. // @Description 资源包搜索接口
  1014. // @Param KeyWord query string true "搜索关键词"
  1015. // @Success 200 {object} models.SearchResourceResp
  1016. // @router /searchResource [get]
  1017. func (this *MobileReportController) SearchResource() {
  1018. br := new(models.BaseResponse).Init()
  1019. defer func() {
  1020. this.Data["json"] = br
  1021. this.ServeJSON()
  1022. }()
  1023. user := this.User
  1024. if user == nil {
  1025. br.Msg = "请重新登录"
  1026. br.Ret = 408
  1027. return
  1028. }
  1029. uid := user.UserId
  1030. fllowList, err := models.GetUserFllowIndustrialList(uid)
  1031. if err != nil {
  1032. br.Msg = "获取失败"
  1033. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  1034. return
  1035. }
  1036. fllowMap := make(map[int]int)
  1037. if len(fllowList) > 0 {
  1038. for _, v := range fllowList {
  1039. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  1040. }
  1041. }
  1042. keyWord := this.GetString("KeyWord")
  1043. var condition string
  1044. articleTypeIds, err := services.GetYanXuanArticleTypeIds()
  1045. if err != nil {
  1046. br.Msg = "获取信息失败"
  1047. br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
  1048. return
  1049. }
  1050. if articleTypeIds == "" {
  1051. br.Msg = "获取信息失败"
  1052. br.ErrMsg = "研选分类ID不能为空"
  1053. return
  1054. }
  1055. 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 + `%' ) `
  1056. listHz, err := models.GetSearchResourceList(condition)
  1057. if err != nil {
  1058. br.Msg = "获取信息失败"
  1059. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1060. return
  1061. }
  1062. 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 + `%' ) `
  1063. listYx, err := models.GetSearchResourceList(condition)
  1064. if err != nil {
  1065. br.Msg = "获取信息失败"
  1066. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1067. return
  1068. }
  1069. if len(listYx) > 0 {
  1070. listYx, err = services.HandleIndustryList(listYx, user, "Yx")
  1071. if err != nil {
  1072. br.Msg = "获取信息失败"
  1073. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1074. return
  1075. }
  1076. }
  1077. if len(listHz) > 0 {
  1078. listHz, err = services.HandleIndustryList(listHz, user, "Hz")
  1079. if err != nil {
  1080. br.Msg = "获取信息失败"
  1081. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1082. return
  1083. }
  1084. }
  1085. if keyWord != "" {
  1086. go services.AddUserSearchLog(user, keyWord, 4)
  1087. }
  1088. resp := new(models.SearchResourceResp)
  1089. if len(listHz) == 0 {
  1090. listHz = make([]*models.IndustrialManagement, 0)
  1091. }
  1092. if len(listYx) == 0 {
  1093. listYx = make([]*models.IndustrialManagement, 0)
  1094. }
  1095. resp.ListHz = listHz
  1096. resp.ListYx = listYx
  1097. br.Ret = 200
  1098. br.Success = true
  1099. br.Msg = "获取成功"
  1100. br.Data = resp
  1101. }
  1102. // @Title 报告搜索、资源包搜索接口
  1103. // @Description 报告搜索、资源包搜索接口接口
  1104. // @Param KeyWord query string true "搜索关键词"
  1105. // @Param PageSize query int true "每页数据条数"
  1106. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1107. // @Param SearchType query int true "1:综合,2:全部"
  1108. // @Success 200 {object} models.SearchReportAndResourceResp
  1109. // @router /searchReportAndResource [get]
  1110. func (this *MobileReportController) SearchReportAndResource() {
  1111. br := new(models.BaseResponse).Init()
  1112. defer func() {
  1113. this.Data["json"] = br
  1114. this.ServeJSON()
  1115. }()
  1116. user := this.User
  1117. if user == nil {
  1118. br.Msg = "请重新登录"
  1119. br.Ret = 408
  1120. return
  1121. }
  1122. //uid := user.UserId
  1123. keyWord := this.GetString("KeyWord")
  1124. pageSize, _ := this.GetInt("PageSize")
  1125. currentIndex, _ := this.GetInt("CurrentIndex")
  1126. searchType, _ := this.GetInt("SearchType")
  1127. var total int
  1128. var startSize int
  1129. if pageSize <= 0 {
  1130. pageSize = utils.PageSize20
  1131. }
  1132. if currentIndex <= 0 {
  1133. currentIndex = 1
  1134. }
  1135. startSize = paging.StartIndex(currentIndex, pageSize)
  1136. page := paging.GetPaging(currentIndex, pageSize, total)
  1137. var condition string
  1138. var conditionSql string
  1139. //匹配报告标题、
  1140. condition = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
  1141. conditionSql = ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + condition + ` OR ( article_type = 'lyjh' ` + condition + ` ) `
  1142. total, err := models.GetReoprtSearchCount(conditionSql)
  1143. if err != nil {
  1144. br.Msg = "获取信息失败"
  1145. br.Msg = "获取总数失败,Err:" + err.Error()
  1146. return
  1147. }
  1148. if searchType == 1 {
  1149. pageSize = utils.PageSize5
  1150. }
  1151. ListHzReport, err := services.GetReoprtSearchListHz(conditionSql, user.UserId, startSize, pageSize)
  1152. if err != nil {
  1153. br.Msg = "获取失败"
  1154. br.ErrMsg = "获取失败,GetReoprtSearchListHz Err:" + err.Error()
  1155. return
  1156. }
  1157. if len(ListHzReport) == 0 {
  1158. ListHzReport = make([]*models.ArticleCollectionResp, 0)
  1159. }
  1160. var conditionOr string
  1161. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  1162. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  1163. listHzResource, err := services.GetSearchResourceListHz(condition, user)
  1164. if err != nil {
  1165. br.Msg = "获取信息失败"
  1166. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1167. return
  1168. }
  1169. resp := new(models.SearchReportAndResourceResp)
  1170. if len(listHzResource) == 0 {
  1171. listHzResource = make([]*models.IndustrialManagement, 0)
  1172. }
  1173. if keyWord != "" {
  1174. go services.AddUserSearchLog(user, keyWord, 5)
  1175. }
  1176. page = paging.GetPaging(currentIndex, pageSize, total)
  1177. resp.Paging = page
  1178. resp.ListHzResource = listHzResource
  1179. resp.ListHzReport = ListHzReport
  1180. br.Ret = 200
  1181. br.Success = true
  1182. br.Msg = "获取成功"
  1183. br.Data = resp
  1184. }
  1185. // @Title 公司速览
  1186. // @Description 公司速览接口
  1187. // @Param ChartPermissionId query int false "分类ID"
  1188. // @Success 200 {object} models.ArticleDataLogoListResp
  1189. // @router /companyList [get]
  1190. func (this *ReportCommonController) CompanyList() {
  1191. br := new(models.BaseResponse).Init()
  1192. defer func() {
  1193. this.Data["json"] = br
  1194. this.ServeJSON()
  1195. }()
  1196. var condition string
  1197. var pars []interface{}
  1198. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  1199. if chartPermissionId > 1 {
  1200. categoryId, err := models.GetCategoryId(chartPermissionId)
  1201. if err != nil && err.Error() != utils.ErrNoRow() {
  1202. br.Msg = "获取信息失败"
  1203. br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
  1204. return
  1205. }
  1206. if categoryId != "" {
  1207. condition += ` AND a.category_id IN (` + categoryId + `)`
  1208. }
  1209. }
  1210. condition += ` AND a.type_name = '综述报告' ORDER BY a.modify_time_by_cl DESC `
  1211. list, err := models.CygxArticleDataList(condition, pars)
  1212. if err != nil {
  1213. br.Msg = "获取失败"
  1214. br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
  1215. return
  1216. }
  1217. listLogo := make([]*models.ArticleDataLogoResp, 0)
  1218. for i := range list {
  1219. v := list[i]
  1220. comapnyList := services.HandleArticleStock(v.Stock)
  1221. if len(comapnyList) > 1 {
  1222. for kC, vC := range comapnyList {
  1223. sliceCovers := strings.Split(v.Cover, "{|}")
  1224. cover := v.Cover
  1225. if len(sliceCovers) == len(comapnyList) {
  1226. cover = sliceCovers[kC]
  1227. }
  1228. listLogo = append(listLogo, &models.ArticleDataLogoResp{
  1229. ArticleId: v.ArticleId,
  1230. Cover: cover,
  1231. ComapnyList: services.HandleArticleStock(vC.ComapnyName),
  1232. })
  1233. }
  1234. } else {
  1235. listLogo = append(listLogo, &models.ArticleDataLogoResp{
  1236. ArticleId: v.ArticleId,
  1237. Cover: v.Cover,
  1238. ComapnyList: services.HandleArticleStock(v.Stock),
  1239. })
  1240. }
  1241. }
  1242. resp := new(models.ArticleDataLogoListResp)
  1243. resp.List = listLogo
  1244. br.Ret = 200
  1245. br.Success = true
  1246. br.Msg = "获取成功"
  1247. br.Data = resp
  1248. }
  1249. // @Title 时间线
  1250. // @Description 时间线接口
  1251. // @Param PageSize query int true "每页数据条数"
  1252. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1253. // @Param IndustrialManagementId query int false "产业ID"
  1254. // @Success 200 {object} models.TacticsListResp
  1255. // @router /timeline [get]
  1256. func (this *MobileReportController) Timeline() {
  1257. br := new(models.BaseResponse).Init()
  1258. defer func() {
  1259. this.Data["json"] = br
  1260. this.ServeJSON()
  1261. }()
  1262. user := this.User
  1263. if user == nil {
  1264. br.Msg = "请重新登录"
  1265. br.Ret = 408
  1266. return
  1267. }
  1268. pageSize, _ := this.GetInt("PageSize")
  1269. currentIndex, _ := this.GetInt("CurrentIndex")
  1270. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  1271. var startSize int
  1272. if pageSize <= 0 {
  1273. pageSize = utils.PageSize20
  1274. }
  1275. if currentIndex <= 0 {
  1276. currentIndex = 1
  1277. }
  1278. startSize = paging.StartIndex(currentIndex, pageSize)
  1279. var total int
  1280. resp := new(models.TacticsListTimeResp)
  1281. page := paging.GetPaging(currentIndex, pageSize, total)
  1282. list := make([]*models.TimeLineReportItem, 0)
  1283. var err error
  1284. list, total, err = models.GetTimeLineReportIndustrialListTime(user.UserId, industrialManagementId, startSize, pageSize)
  1285. if err != nil {
  1286. br.Msg = "获取信息失败"
  1287. br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
  1288. return
  1289. }
  1290. //查询用户今天是否看过时间线
  1291. count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  1292. if err != nil {
  1293. br.Msg = "查询浏览记录数量失败"
  1294. br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  1295. return
  1296. }
  1297. var recordItem *models.CygxPageHistoryRecord
  1298. if count > 1 {
  1299. recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  1300. if err != nil {
  1301. br.Msg = "查询浏览记录失败"
  1302. br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  1303. return
  1304. }
  1305. }
  1306. for k, v := range list {
  1307. if v.SubCategoryName != "时间线" && v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  1308. list[k].IsRed = true
  1309. }
  1310. timeLineRed := false
  1311. if count < 2 && v.SubCategoryName == "时间线" {
  1312. timeLineRed = true
  1313. } else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishDate)) {
  1314. timeLineRed = true
  1315. }
  1316. if v.SubCategoryName == "时间线" && timeLineRed {
  1317. list[k].IsRed = true
  1318. }
  1319. if v.VideoUrl != "" {
  1320. list[k].IsHaveVideo = true
  1321. }
  1322. }
  1323. //添加我的日程访问记录
  1324. item := new(models.CygxPageHistoryRecord)
  1325. item.UserId = user.UserId
  1326. item.CreateTime = time.Now()
  1327. item.CompanyId = user.CompanyId
  1328. item.CompanyName = user.CompanyName
  1329. item.Router = utils.TIME_LINE_ROUTE + strconv.Itoa(industrialManagementId)
  1330. go models.AddCygxPageHistoryRecord(item)
  1331. if len(list) == 0 {
  1332. list = make([]*models.TimeLineReportItem, 0)
  1333. }
  1334. page = paging.GetPaging(currentIndex, pageSize, total)
  1335. resp.List = list
  1336. resp.Paging = page
  1337. br.Ret = 200
  1338. br.Success = true
  1339. br.Msg = "获取成功"
  1340. br.Data = resp
  1341. }
  1342. // @Title 文章留言接口
  1343. // @Description 文章留言接口
  1344. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  1345. // @Success 200 {object} models.TacticsListResp
  1346. // @router /commentAdd [post]
  1347. func (this *ReportController) CommentAdd() {
  1348. br := new(models.BaseResponse).Init()
  1349. defer func() {
  1350. this.Data["json"] = br
  1351. this.ServeJSON()
  1352. }()
  1353. user := this.User
  1354. if user == nil {
  1355. br.Msg = "请重新登录"
  1356. br.Ret = 408
  1357. return
  1358. }
  1359. var req models.AddCygxArticleCommentReq
  1360. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1361. if err != nil {
  1362. br.Msg = "参数解析异常!"
  1363. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1364. return
  1365. }
  1366. if req.ArticleId <= 0 {
  1367. br.Msg = "文章不存在"
  1368. br.ErrMsg = "文章不存在,文章ID错误"
  1369. return
  1370. }
  1371. if req.Content == "" {
  1372. br.Msg = "建议内容不可为空"
  1373. return
  1374. }
  1375. content := req.Content
  1376. if content == "" {
  1377. br.Msg = "留言内容不能为空!"
  1378. return
  1379. }
  1380. //itemToken, err := services.WxGetToken()
  1381. //if err != nil {
  1382. // br.Msg = "GetWxAccessToken Err:" + err.Error()
  1383. // return
  1384. //}
  1385. //if itemToken.AccessToken == "" {
  1386. // br.Msg = "accessToken is empty"
  1387. // return
  1388. //}
  1389. //commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  1390. //if err != nil {
  1391. // br.Msg = "内容校验失败!"
  1392. // br.ErrMsg = "内容校验失败,Err:" + err.Error()
  1393. // return
  1394. //}
  1395. //if commerr.ErrCode != 0 {
  1396. // br.Msg = "内容违规,请重新提交!"
  1397. // br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
  1398. // return
  1399. //}
  1400. articleId := req.ArticleId
  1401. articleInfo, errInfo := models.GetArticleDetailById(articleId)
  1402. if articleInfo == nil {
  1403. br.Msg = "操作失败"
  1404. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  1405. return
  1406. }
  1407. if errInfo != nil {
  1408. br.Msg = "操作失败"
  1409. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1410. return
  1411. }
  1412. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  1413. if err != nil {
  1414. br.Msg = "提交失败!"
  1415. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1416. return
  1417. }
  1418. if companyDetail == nil {
  1419. br.Msg = "提交失败!"
  1420. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  1421. return
  1422. }
  1423. item := models.CygxArticleComment{
  1424. UserId: user.UserId,
  1425. ArticleId: req.ArticleId,
  1426. CreateTime: time.Now(),
  1427. Mobile: user.Mobile,
  1428. Email: user.Email,
  1429. CompanyId: user.CompanyId,
  1430. CompanyName: companyDetail.CompanyName,
  1431. Content: content,
  1432. Title: articleInfo.Title,
  1433. }
  1434. _, err = models.AddArticleComment(&item)
  1435. if err != nil {
  1436. br.Msg = "提交失败"
  1437. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  1438. return
  1439. }
  1440. services.SendCommentWxTemplateMsg(req, user, articleInfo)
  1441. br.Ret = 200
  1442. br.Success = true
  1443. br.Msg = "提交成功"
  1444. }