report.go 77 KB

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