research_summary.go 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235
  1. package cygx
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "hongze/hz_crm_api/controllers"
  7. "hongze/hz_crm_api/models"
  8. "hongze/hz_crm_api/models/cygx"
  9. "hongze/hz_crm_api/services"
  10. cygxService "hongze/hz_crm_api/services/cygx"
  11. "hongze/hz_crm_api/utils"
  12. "regexp"
  13. "strconv"
  14. "strings"
  15. "time"
  16. )
  17. // 研究汇总
  18. type ResearchSummaryController struct {
  19. controllers.BaseAuthController
  20. }
  21. // @Title 本周研究汇总内容的保存与发布
  22. // @Description 本周研究汇总内容的保存与发布接口
  23. // @Param request body cygx.AddCygxResearchSummary true "type json string"
  24. // @Success 200 操作成功
  25. // @router /researchSummary/PreserveAndPublish [post]
  26. func (this *ResearchSummaryController) PreserveAndPublish() {
  27. br := new(models.BaseResponse).Init()
  28. defer func() {
  29. this.Data["json"] = br
  30. this.ServeJSON()
  31. }()
  32. AdminUser := this.SysUser
  33. if AdminUser == nil {
  34. br.Msg = "请登录"
  35. br.ErrMsg = "请登录,用户信息为空"
  36. br.Ret = 408
  37. return
  38. }
  39. var req cygx.AddCygxResearchSummary
  40. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  41. if err != nil {
  42. br.Msg = "参数解析异常!"
  43. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  44. return
  45. }
  46. //`description:"类型'SDBG:深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP:事件点评,’BZCHJH:本周晨会精华’,’SSGS:上市公司调研纪要篇’"`
  47. content := req.Content
  48. sortSdbg := content.SortSdbg
  49. var sortSdbgStr string
  50. var msgErr string
  51. if sortSdbg != "" {
  52. match, _ := regexp.MatchString(`^[A-Za-z]+$`, sortSdbg)
  53. if !match || len(sortSdbg) > 1 {
  54. br.Msg = "深度报告篇排序有误"
  55. return
  56. }
  57. content.SortSdbg = strings.ToUpper(content.SortSdbg)
  58. sortSdbgStr += content.SortSdbg
  59. }
  60. sortCydyjy := content.SortCydyjy
  61. if sortCydyjy != "" {
  62. match, _ := regexp.MatchString(`^[A-Za-z]+$`, sortCydyjy)
  63. if !match || len(sortCydyjy) > 1 {
  64. br.Msg = "产业调研纪要排序有误"
  65. return
  66. }
  67. content.SortCydyjy = strings.ToUpper(content.SortCydyjy)
  68. if strings.Contains(sortSdbgStr, content.SortCydyjy) {
  69. br.Msg = "产业调研纪要排序有误"
  70. return
  71. }
  72. sortSdbgStr += content.SortCydyjy
  73. }
  74. sortSjdp := content.SortSjdp
  75. if sortSjdp != "" {
  76. match, _ := regexp.MatchString(`^[A-Za-z]+$`, sortSjdp)
  77. if !match || len(sortSjdp) > 1 {
  78. br.Msg = "事件点评排序有误"
  79. return
  80. }
  81. content.SortSjdp = strings.ToUpper(content.SortSjdp)
  82. if strings.Contains(sortSdbgStr, content.SortSjdp) {
  83. br.Msg = "事件点评排序有误"
  84. return
  85. }
  86. sortSdbgStr += content.SortSjdp
  87. }
  88. sortBzchjh := content.SortBzchjh
  89. if sortBzchjh != "" {
  90. match, _ := regexp.MatchString(`^[A-Za-z]+$`, sortBzchjh)
  91. if !match || len(sortBzchjh) > 1 {
  92. br.Msg = "本周晨会精华排序有误"
  93. return
  94. }
  95. content.SortBzchjh = strings.ToUpper(content.SortBzchjh)
  96. if strings.Contains(sortSdbgStr, content.SortBzchjh) {
  97. br.Msg = "本周晨会精华排序有误"
  98. return
  99. }
  100. }
  101. sortYanx := content.SortYanx
  102. if sortYanx != "" {
  103. match, _ := regexp.MatchString(`^[A-Za-z]+$`, sortYanx)
  104. if !match || len(sortYanx) > 1 {
  105. br.Msg = "研选排序有误"
  106. return
  107. }
  108. content.SortYanx = strings.ToUpper(content.SortYanx)
  109. if strings.Contains(sortSdbgStr, content.SortYanx) {
  110. br.Msg = "研选排序有误"
  111. return
  112. }
  113. }
  114. sortSsgs := content.SortSsgs
  115. if sortSsgs != "" {
  116. match, _ := regexp.MatchString(`^[A-Za-z]+$`, sortSsgs)
  117. if !match || len(sortSsgs) > 1 {
  118. br.Msg = "上市公司调研纪要篇排序有误"
  119. return
  120. }
  121. content.SortSsgs = strings.ToUpper(content.SortSsgs)
  122. if strings.Contains(sortSdbgStr, content.SortSsgs) {
  123. br.Msg = "上市公司调研纪要篇序有误"
  124. return
  125. }
  126. }
  127. var items []*cygx.CygxResearchSummaryLog
  128. //合并深度报告片篇
  129. if len(content.ListSdbg) > 0 {
  130. items, msgErr, err = cygxService.AppendItemsLog(items, content.ListSdbg, "SDBG", strings.ToUpper(content.SortSdbg))
  131. if msgErr != "" {
  132. br.Msg = msgErr
  133. return
  134. }
  135. if err != nil {
  136. br.Msg = "操作失败"
  137. br.ErrMsg = "获取失败,Err:" + err.Error()
  138. return
  139. }
  140. }
  141. //产业调研纪要
  142. if len(content.ListCydyjy) > 0 {
  143. items, msgErr, err = cygxService.AppendItemsLog(items, content.ListCydyjy, "CYDYJY", strings.ToUpper(content.SortCydyjy))
  144. if msgErr != "" {
  145. br.Msg = msgErr
  146. return
  147. }
  148. if err != nil {
  149. br.Msg = "操作失败"
  150. br.ErrMsg = "获取失败,Err:" + err.Error()
  151. return
  152. }
  153. }
  154. //上市公司调研纪要篇
  155. if len(content.ListSsgs) > 0 {
  156. items, msgErr, err = cygxService.AppendItemsLog(items, content.ListSsgs, "SSGS", strings.ToUpper(content.SortSsgs))
  157. if msgErr != "" {
  158. br.Msg = msgErr
  159. return
  160. }
  161. if err != nil {
  162. br.Msg = "操作失败"
  163. br.ErrMsg = "获取失败,Err:" + err.Error()
  164. return
  165. }
  166. }
  167. //事件点评
  168. if len(content.ListSjdp) > 0 {
  169. for _, v := range content.ListSjdp {
  170. item := new(cygx.CygxResearchSummaryLog)
  171. item.Type = "SJDP"
  172. item.Sort = strings.ToUpper(content.SortSjdp)
  173. item.CreateTime = time.Now()
  174. item.Body = cygxService.GetRichtext(v.Body)
  175. item.ReportLink = v.ReportLink
  176. if item.ReportLink != "" {
  177. articleIdLink, err := cygxService.GetReportLinkToArticleid(item.ReportLink)
  178. if err != nil {
  179. br.Msg = "操作失败"
  180. br.ErrMsg = "解析报告链接ID失败,Err:" + err.Error()
  181. return
  182. }
  183. item.LinkArticleId = articleIdLink
  184. }
  185. items = append(items, item)
  186. }
  187. }
  188. //本周晨会精华
  189. if len(content.ListBzchjh) > 0 {
  190. items, msgErr, err = cygxService.AppendItemsLog(items, content.ListBzchjh, "BZCHJH", strings.ToUpper(content.SortBzchjh))
  191. if msgErr != "" {
  192. br.Msg = msgErr
  193. return
  194. }
  195. if err != nil {
  196. br.Msg = "操作失败"
  197. br.ErrMsg = "获取失败,Err:" + err.Error()
  198. return
  199. }
  200. }
  201. //研选
  202. if len(content.ListYanx) > 0 {
  203. items, msgErr, err = cygxService.AppendItemsLog(items, content.ListYanx, "YANX", strings.ToUpper(content.SortYanx))
  204. if msgErr != "" {
  205. br.Msg = msgErr
  206. return
  207. }
  208. if err != nil {
  209. br.Msg = "操作失败"
  210. br.ErrMsg = "获取失败,Err:" + err.Error()
  211. return
  212. }
  213. }
  214. condition := ` AND have_publish = 1 `
  215. var pars []interface{}
  216. total, err := cygx.GetCygxResearchSummary(condition, pars)
  217. if err != nil {
  218. br.Msg = "获取失败"
  219. br.ErrMsg = "获取失败,Err:" + err.Error()
  220. return
  221. }
  222. itemCrs := new(cygx.CygxResearchSummary)
  223. itemCrs.AdminId = AdminUser.AdminId
  224. itemCrs.AdminName = AdminUser.RealName
  225. itemCrs.Title = req.Title
  226. itemCrs.Department = req.Department
  227. itemCrs.Abstract = req.Abstract
  228. itemCrs.PublishStatus = req.DoType
  229. if req.DoType == 1 {
  230. itemCrs.HavePublish = 1
  231. itemCrs.Periods = strconv.Itoa(total + 1)
  232. }
  233. itemCrs.PublishDate = utils.StrTimeToTime(req.PublishDate + " 00:00:00")
  234. itemCrs.CreateTime = time.Now()
  235. itemCrs.LastUpdatedTime = time.Now()
  236. if req.ArticleId == 0 {
  237. articleId, err := cygx.AddCygxResearchSummaryOrm(itemCrs, items)
  238. if err != nil {
  239. br.Msg = "操作失败"
  240. br.ErrMsg = "发布失败,Err:" + err.Error()
  241. return
  242. }
  243. req.ArticleId = int(articleId)
  244. } else {
  245. detail, err := cygx.GetCygxResearchSummaryInfoById(req.ArticleId)
  246. if err != nil {
  247. br.Msg = "内容不存在"
  248. br.ErrMsg = "操作失败,Err:" + err.Error()
  249. return
  250. }
  251. if itemCrs.PublishStatus == 0 {
  252. itemCrs.PublishStatus = detail.PublishStatus
  253. itemCrs.AdminId = detail.AdminId
  254. itemCrs.AdminName = detail.AdminName
  255. }
  256. if detail.HavePublish == 1 {
  257. itemCrs.Periods = detail.Periods
  258. itemCrs.HavePublish = detail.HavePublish
  259. }
  260. itemCrs.ArticleId = req.ArticleId
  261. _, err = cygx.UpdateCygxResearchSummaryOrm(itemCrs, items)
  262. if err != nil {
  263. br.Msg = "操作失败"
  264. br.ErrMsg = "发布失败,Err:" + err.Error()
  265. return
  266. }
  267. }
  268. //if req.DoType == 1 {
  269. // cygxService.DoThisWeekLastWeekWxTemplateMsg(itemCrs.Title, itemCrs.PublishDate.Format(utils.FormatDateTime), itemCrs.Abstract, req.ArticleId, 2)
  270. //}
  271. //生成音频文件
  272. articleId := req.ArticleId
  273. var contentVideo string
  274. contentVideo = "摘要" + req.Abstract
  275. listFirst, err := cygx.GetResearchSummarylogListFirst(articleId)
  276. if err != nil {
  277. br.Msg = "获取失败"
  278. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  279. return
  280. }
  281. listArticleType, err := cygx.GetCygxArticleTypeList()
  282. if err != nil {
  283. br.Msg = "获取失败"
  284. br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
  285. return
  286. }
  287. for k, v := range listFirst {
  288. if v.Type == "SDBG" {
  289. contentVideo += "深度报告篇"
  290. } else if v.Type == "BZCHJH" {
  291. contentVideo += "本周晨会精华"
  292. } else if v.Type == "CYDYJY" {
  293. contentVideo += "产业调研纪要篇"
  294. } else if v.Type == "SSGS" {
  295. contentVideo += "上市公司调研纪要篇"
  296. } else if v.Type == "YANX" {
  297. contentVideo += utils.CHART_PERMISSION_NAME_MF_YANXUAN
  298. } else {
  299. contentVideo += "事件点评"
  300. }
  301. listSecond, err := cygx.GetResearchSummarylogSonListSecond(articleId, v.Type)
  302. if err != nil && err.Error() != utils.ErrNoRow() {
  303. br.Msg = "获取信息失败"
  304. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  305. return
  306. }
  307. for k2, v2 := range listSecond {
  308. if v.Type == "YANX" {
  309. for _, vType := range listArticleType {
  310. if v2.ChartPermissionId == vType.YanxPermissionId {
  311. contentVideo += vType.YanxPermissionName
  312. }
  313. }
  314. } else {
  315. contentVideo += v2.PermissionName
  316. }
  317. //if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
  318. // contentVideo += utils.CHART_PERMISSION_NAME_MF_YANXUAN + "纪要"
  319. //} else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
  320. // contentVideo += utils.CHART_PERMISSION_NAME_MF_YANXUAN + "观点"
  321. //} else {
  322. // contentVideo += v2.PermissionName
  323. //}
  324. listThird, err := cygx.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  325. if err != nil && err.Error() != utils.ErrNoRow() {
  326. br.Msg = "获取信息失败"
  327. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  328. return
  329. }
  330. if len(listThird) > 0 {
  331. listSecond[k2].List = listThird
  332. for _, v3 := range listThird {
  333. contentVideo += v3.Body
  334. }
  335. }
  336. }
  337. if len(listSecond) > 0 {
  338. listFirst[k].List = listSecond
  339. }
  340. }
  341. go services.CreateVideoWhithContent(articleId, req.Title, contentVideo, "cygx_research_summary")
  342. go cygxService.UpdateResearchSummaryResourceData(articleId) //写入首页最新 cygx_resource_data 表
  343. br.Ret = 200
  344. br.Success = true
  345. br.Msg = "操作成功"
  346. br.IsAddLog = true
  347. }
  348. // @Title 删除本周研究汇总内容
  349. // @Description 删除本周研究汇总内容接口
  350. // @Param request body cygx.ResearchSummaryId true "type json string"
  351. // @Success Ret=200
  352. // @router /researchSummary/delete [post]
  353. func (this *ResearchSummaryController) Delete() {
  354. br := new(models.BaseResponse).Init()
  355. defer func() {
  356. this.Data["json"] = br
  357. this.ServeJSON()
  358. }()
  359. AdminUser := this.SysUser
  360. if AdminUser == nil {
  361. br.Msg = "请登录"
  362. br.ErrMsg = "请登录,SysUser Is Empty"
  363. br.Ret = 408
  364. return
  365. }
  366. var req cygx.ResearchSummaryId
  367. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  368. if err != nil {
  369. br.Msg = "参数解析异常!"
  370. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  371. return
  372. }
  373. articleId := req.ArticleId
  374. detail, err := cygx.GetCygxResearchSummaryInfoById(articleId)
  375. if err != nil {
  376. br.Msg = "内容不存在"
  377. br.ErrMsg = "操作失败,Err:" + err.Error()
  378. return
  379. }
  380. if detail.HavePublish != 0 {
  381. br.Msg = "删除失败"
  382. br.ErrMsg = "已经存在期数无法删除"
  383. return
  384. }
  385. err = cygx.DeleteCygxResearchSummary(articleId)
  386. if err != nil {
  387. br.Msg = "删除信息失败"
  388. br.ErrMsg = "删除信息失败,Err:" + err.Error()
  389. return
  390. }
  391. br.Ret = 200
  392. br.Success = true
  393. br.Msg = "已删除"
  394. br.IsAddLog = true
  395. }
  396. // @Title 本周研究汇总内容详情
  397. // @Description 本周研究汇总内容详情接口
  398. // @Param ArticleId query int true "报告Id"
  399. // @Success Ret=200 {object} cygx.DetailCygxResearchSummaryRep
  400. // @router /researchSummary/detail [get]
  401. func (this *ResearchSummaryController) Detail() {
  402. br := new(models.BaseResponse).Init()
  403. defer func() {
  404. this.Data["json"] = br
  405. this.ServeJSON()
  406. }()
  407. AdminUser := this.SysUser
  408. if AdminUser == nil {
  409. br.Msg = "请登录"
  410. br.ErrMsg = "请登录,用户信息为空"
  411. br.Ret = 408
  412. return
  413. }
  414. articleId, _ := this.GetInt("ArticleId")
  415. detail, err := cygx.GetCygxResearchSummaryInfoById(articleId)
  416. if err != nil {
  417. br.Msg = "内容不存在"
  418. br.ErrMsg = "操作失败,Err:" + err.Error()
  419. return
  420. }
  421. resp := new(cygx.DetailCygxResearchSummaryRep)
  422. resp.ArticleId = detail.ArticleId
  423. resp.Title = detail.Title
  424. resp.Department = detail.Department
  425. resp.Abstract = detail.Abstract
  426. resp.PublishStatus = detail.PublishStatus
  427. resp.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  428. //var items []*cygx.CygxRSlChartPermissionIco
  429. //`description:"类型'SDBG:深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP:事件点评,’BZCHJH:本周晨会精华’,’SSGS:本周晨会精华’"`
  430. var condition string
  431. condition = ` AND chart_permission_id IN (19,20,21,22) `
  432. listLess, err := cygx.GetChartPermissionIcoDetail(condition)
  433. if err != nil {
  434. br.Msg = "获取失败"
  435. br.ErrMsg = "获取失败,Err:" + err.Error()
  436. return
  437. }
  438. condition = ` AND chart_permission_id IN (19,20,21,22,23) `
  439. listMore, err := cygx.GetChartPermissionIcoDetail(condition)
  440. if err != nil {
  441. br.Msg = "获取失败"
  442. br.ErrMsg = "获取失败,Err:" + err.Error()
  443. return
  444. }
  445. listSdbg, err := cygx.GetCygxResearchSummaryLogRepList(articleId, "SDBG")
  446. if err != nil {
  447. br.Msg = "获取失败"
  448. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  449. return
  450. }
  451. for _, v := range listSdbg {
  452. listSon, err := cygx.GetCygxResearchSummaryLogRepListSon(articleId, v.ChartPermissionId, "SDBG")
  453. if err != nil {
  454. br.Msg = "获取失败"
  455. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  456. return
  457. }
  458. for k2, v2 := range listMore {
  459. if v2.ChartPermissionId == v.ChartPermissionId {
  460. listMore[k2].List = listSon
  461. listMore[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
  462. }
  463. }
  464. resp.SortSdbg = v.Sort
  465. }
  466. resp.ListSdbg = listMore
  467. //产业调研纪要
  468. //items = make([]*cygx.CygxRSlChartPermissionIco, 0)
  469. listCydyjy, err := cygx.GetCygxResearchSummaryLogRepList(articleId, "CYDYJY")
  470. if err != nil {
  471. br.Msg = "获取失败"
  472. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  473. return
  474. }
  475. for _, v := range listCydyjy {
  476. listSon, err := cygx.GetCygxResearchSummaryLogRepListSon(articleId, v.ChartPermissionId, "CYDYJY")
  477. if err != nil {
  478. br.Msg = "获取失败"
  479. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  480. return
  481. }
  482. for k2, v2 := range listLess {
  483. if v2.ChartPermissionId == v.ChartPermissionId {
  484. listLess[k2].List = listSon
  485. listLess[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
  486. }
  487. }
  488. resp.SortCydyjy = v.Sort
  489. }
  490. resp.ListCydyjy = listLess
  491. //上市公司
  492. condition = ` AND chart_permission_id IN (19,20,21,22) `
  493. listLess, err = cygx.GetChartPermissionIcoDetail(condition)
  494. if err != nil {
  495. br.Msg = "获取失败"
  496. br.ErrMsg = "获取失败,Err:" + err.Error()
  497. return
  498. }
  499. listSsgs, err := cygx.GetCygxResearchSummaryLogRepList(articleId, "SSGS")
  500. if err != nil {
  501. br.Msg = "获取失败"
  502. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  503. return
  504. }
  505. for _, v := range listSsgs {
  506. listSon, err := cygx.GetCygxResearchSummaryLogRepListSon(articleId, v.ChartPermissionId, "SSGS")
  507. if err != nil {
  508. br.Msg = "获取失败"
  509. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  510. return
  511. }
  512. for k2, v2 := range listLess {
  513. if v2.ChartPermissionId == v.ChartPermissionId {
  514. listLess[k2].List = listSon
  515. listLess[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
  516. }
  517. }
  518. resp.SortSsgs = v.Sort
  519. }
  520. resp.ListSsgs = listLess
  521. //研选
  522. var listYanxItem []*cygx.CygxRSlChartPermissionIco
  523. listType, err := cygx.GetCygxArticleTypeList()
  524. if err != nil {
  525. br.Msg = "获取失败"
  526. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  527. return
  528. }
  529. for _, v := range listType {
  530. item := new(cygx.CygxRSlChartPermissionIco)
  531. item.ChartPermissionId = v.YanxPermissionId
  532. item.ChartPermissionName = v.YanxPermissionName
  533. item.IcoLink = v.IcoLink
  534. item.List = make([]*cygx.AddCygxResearchSummaryLog, 0)
  535. listYanxItem = append(listYanxItem, item)
  536. }
  537. itemList := listYanxItem
  538. condition = ` AND chart_permission_id IN (19,20,21,22,31) `
  539. listLess, err = cygx.GetChartPermissionIcoDetail(condition)
  540. if err != nil {
  541. br.Msg = "获取失败"
  542. br.ErrMsg = "获取失败,Err:" + err.Error()
  543. return
  544. }
  545. listYanx, err := cygx.GetCygxResearchSummaryLogRepList(articleId, "YANX")
  546. if err != nil {
  547. br.Msg = "获取失败"
  548. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  549. return
  550. }
  551. for _, v := range listYanx {
  552. listSon, err := cygx.GetCygxResearchSummaryLogRepListSon(articleId, v.ChartPermissionId, "YANX")
  553. if err != nil {
  554. br.Msg = "获取失败"
  555. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  556. return
  557. }
  558. for k2, v2 := range itemList {
  559. if v2.ChartPermissionId == v.ChartPermissionId {
  560. itemList[k2].List = listSon
  561. itemList[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
  562. }
  563. }
  564. resp.SortYanx = v.Sort
  565. }
  566. resp.ListYanx = itemList
  567. //事件点评
  568. listSjdp, err := cygx.GetCygxResearchSummarySjdpList(articleId, "SJDP")
  569. if err != nil {
  570. br.Msg = "获取失败"
  571. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  572. return
  573. }
  574. var itemsSjdp []*cygx.AddCygxResearchSummaryLog
  575. for _, v := range listSjdp {
  576. item := new(cygx.AddCygxResearchSummaryLog)
  577. item.Body = v.Body
  578. item.ReportLink = v.ReportLink
  579. itemsSjdp = append(itemsSjdp, item)
  580. resp.SortSjdp = v.Sort
  581. }
  582. resp.ListSjdp = itemsSjdp
  583. //items = make([]*cygx.CygxRSlChartPermissionIco, 0)
  584. condition = ` AND chart_permission_id IN (19,20,21,22,23) `
  585. listMore, err = cygx.GetChartPermissionIcoDetail(condition)
  586. if err != nil {
  587. br.Msg = "获取失败"
  588. br.ErrMsg = "获取失败,Err:" + err.Error()
  589. return
  590. }
  591. listBzchjh, err := cygx.GetCygxResearchSummaryLogRepList(articleId, "BZCHJH")
  592. if err != nil {
  593. br.Msg = "获取失败"
  594. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  595. return
  596. }
  597. for _, v := range listBzchjh {
  598. listSon, err := cygx.GetCygxResearchSummaryLogRepListSon(articleId, v.ChartPermissionId, "BZCHJH")
  599. if err != nil {
  600. br.Msg = "获取失败"
  601. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  602. return
  603. }
  604. for k2, v2 := range listMore {
  605. if v2.ChartPermissionId == v.ChartPermissionId {
  606. listMore[k2].List = listSon
  607. listMore[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
  608. }
  609. }
  610. resp.SortBzchjh = v.Sort
  611. }
  612. resp.ListBzchjh = listMore
  613. br.Ret = 200
  614. br.Success = true
  615. br.Msg = "获取成功"
  616. br.Data = resp
  617. }
  618. // @Title 本周研究汇总列表
  619. // @Description 获取本周研究汇总列表接口
  620. // @Param PageSize query int true "每页数据条数"
  621. // @Param CurrentIndex query int true "当前页页码,从1开始"
  622. // @Param PublishStatus query int false "发布状态 ,1未发布,1已发布,传2查询所有"
  623. // @Param StartDate query string false "开始时间 ,列如2021-03-06 "
  624. // @Param EndDate query string false "结束时间,列如2021-03-06 "
  625. // @Success 200 {object} cygx.CygxResearchSummaryListRep
  626. // @router /researchSummary/list [get]
  627. func (this *ResearchSummaryController) List() {
  628. br := new(models.BaseResponse).Init()
  629. defer func() {
  630. this.Data["json"] = br
  631. this.ServeJSON()
  632. }()
  633. AdminUser := this.SysUser
  634. if AdminUser == nil {
  635. br.Msg = "请登录"
  636. br.ErrMsg = "请登录,SysUser Is Empty"
  637. return
  638. }
  639. pageSize, _ := this.GetInt("PageSize")
  640. currentIndex, _ := this.GetInt("CurrentIndex")
  641. publishStatus, _ := this.GetInt("PublishStatus")
  642. startDate := this.GetString("StartDate")
  643. endDate := this.GetString("EndDate")
  644. var startSize int
  645. if pageSize <= 0 {
  646. pageSize = utils.PageSize20
  647. }
  648. if currentIndex <= 0 {
  649. currentIndex = 1
  650. }
  651. startSize = utils.StartIndex(currentIndex, pageSize)
  652. var condition string
  653. var pars []interface{}
  654. if startDate != "" {
  655. condition += ` AND rs.publish_date >= ` + "'" + startDate + " 00:00:00'"
  656. }
  657. if endDate != "" {
  658. condition += ` AND rs.publish_date <= ` + "'" + endDate + " 23:59:59'"
  659. }
  660. if publishStatus == 0 || publishStatus == 1 {
  661. condition += ` AND rs.publish_status = ` + strconv.Itoa(publishStatus)
  662. }
  663. total, err := cygx.GetCygxResearchSummary(condition, pars)
  664. if err != nil {
  665. br.Msg = "获取失败"
  666. br.ErrMsg = "获取失败,Err:" + err.Error()
  667. return
  668. }
  669. list, err := cygx.GetResearchSummaryList(condition, pars, startSize, pageSize)
  670. if err != nil {
  671. br.Msg = "获取失败"
  672. br.ErrMsg = "获取失败,Err:" + err.Error()
  673. return
  674. }
  675. for k, v := range list {
  676. if v.Periods != "" && v.Periods != "0" {
  677. list[k].Periods = "第" + v.Periods + "期"
  678. } else {
  679. list[k].Periods = ""
  680. }
  681. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  682. }
  683. page := paging.GetPaging(currentIndex, pageSize, total)
  684. resp := new(cygx.CygxResearchSummaryListRep)
  685. resp.List = list
  686. resp.Paging = page
  687. br.Ret = 200
  688. br.Success = true
  689. br.Msg = "获取成功"
  690. br.Data = resp
  691. }
  692. // @Title 本周研究汇总的发布与取消发布
  693. // @Description 本周研究汇总的发布与取消发布接口
  694. // @Param request body cygx.ResearchSummaryId true "type json string"
  695. // @Success 200 操作成功
  696. // @router /researchSummary/PublishAndCancel [post]
  697. func (this *ResearchSummaryController) PublishAndCancel() {
  698. br := new(models.BaseResponse).Init()
  699. defer func() {
  700. this.Data["json"] = br
  701. this.ServeJSON()
  702. }()
  703. AdminUser := this.SysUser
  704. if AdminUser == nil {
  705. br.Msg = "请登录"
  706. br.ErrMsg = "请登录,用户信息为空"
  707. br.Ret = 408
  708. return
  709. }
  710. var req cygx.ResearchSummaryId
  711. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  712. if err != nil {
  713. br.Msg = "参数解析异常!"
  714. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  715. return
  716. }
  717. articleId := req.ArticleId
  718. detail, err := cygx.GetCygxResearchSummaryInfoById(articleId)
  719. if err != nil {
  720. br.Msg = "内容不存在"
  721. br.ErrMsg = "操作失败,Err:" + err.Error()
  722. return
  723. }
  724. item := new(cygx.CygxResearchSummaryRep)
  725. item.ArticleId = articleId
  726. if detail.PublishStatus == 0 {
  727. item.PublishStatus = 1
  728. item.AdminId = AdminUser.AdminId
  729. item.AdminName = AdminUser.RealName
  730. //cygxService.DoThisWeekLastWeekWxTemplateMsg(detail.Title, detail.PublishDate, detail.Abstract, req.ArticleId, 2)
  731. } else {
  732. item.AdminId = detail.AdminId
  733. item.AdminName = detail.AdminName
  734. item.PublishStatus = 0
  735. }
  736. if detail.HavePublish == 0 {
  737. condition := ` AND have_publish = 1 `
  738. var pars []interface{}
  739. total, err := cygx.GetCygxResearchSummary(condition, pars)
  740. if err != nil {
  741. br.Msg = "获取失败"
  742. br.ErrMsg = "获取失败,Err:" + err.Error()
  743. return
  744. }
  745. item.Periods = strconv.Itoa(total + 1)
  746. } else {
  747. item.Periods = detail.Periods
  748. }
  749. err = cygx.ResearchSummaryPublishAndCancel(item)
  750. if err != nil {
  751. br.Msg = "操作失败"
  752. br.ErrMsg = "操作失败,Err:" + err.Error()
  753. return
  754. }
  755. br.Ret = 200
  756. br.Success = true
  757. br.Msg = "操作成功"
  758. br.IsAddLog = true
  759. }
  760. // @Title 本周研究汇总初始模板
  761. // @Description 本周研究汇总初始模板接口
  762. // @Success Ret=200 {object} cygx.DetailCygxResearchSummaryRep
  763. // @router /researchSummary/detailTemplate [get]
  764. func (this *ResearchSummaryController) DetailTemplate() {
  765. br := new(models.BaseResponse).Init()
  766. defer func() {
  767. this.Data["json"] = br
  768. this.ServeJSON()
  769. }()
  770. AdminUser := this.SysUser
  771. if AdminUser == nil {
  772. br.Msg = "请登录"
  773. br.ErrMsg = "请登录,用户信息为空"
  774. br.Ret = 408
  775. return
  776. }
  777. resp := new(cygx.DetailCygxResearchSummaryTmpRep)
  778. //`description:"类型'SDBG:深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP:事件点评,’BZCHJH:本周晨会精华’,'YANX:研选'"`
  779. var condition string
  780. condition = ` AND chart_permission_id IN (19,20,21,22,23) `
  781. listMore, err := cygx.GetChartPermissionIcoNew(condition)
  782. if err != nil {
  783. br.Msg = "获取失败"
  784. br.ErrMsg = "获取失败,Err:" + err.Error()
  785. return
  786. }
  787. condition = ` AND chart_permission_id IN (19,20,21,22) `
  788. listLess, err := cygx.GetChartPermissionIcoNew(condition)
  789. if err != nil {
  790. br.Msg = "获取失败"
  791. br.ErrMsg = "获取失败,Err:" + err.Error()
  792. return
  793. }
  794. for k := range listMore {
  795. listMore[k].List = make([]string, 0)
  796. }
  797. for k := range listLess {
  798. listLess[k].List = make([]string, 0)
  799. }
  800. listType, err := cygx.GetCygxArticleTypeList()
  801. if err != nil {
  802. br.Msg = "获取失败"
  803. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  804. return
  805. }
  806. var listYanx []*cygx.CygxRSlChartPermissionIcoTmp
  807. for _, v := range listType {
  808. item := new(cygx.CygxRSlChartPermissionIcoTmp)
  809. item.ChartPermissionId = v.YanxPermissionId
  810. item.ChartPermissionName = v.YanxPermissionName
  811. item.IcoLink = v.IcoLink
  812. item.List = make([]string, 0)
  813. listYanx = append(listYanx, item)
  814. }
  815. //listYanx := []*cygx.CygxRSlChartPermissionIcoTmp{{ChartPermissionId: utils.YanxSummaryPermissionId, ChartPermissionName: "研选纪要", ChartPermissionSort: "", IcoLink: "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png", List: make([]string, 0)}, {ChartPermissionId: utils.YanxViewpointPermissionId, ChartPermissionName: "研选观点", ChartPermissionSort: "", IcoLink: "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png", List: make([]string, 0)}}
  816. resp.ListBzchjh = listMore
  817. resp.ListSdbg = listMore
  818. resp.ListCydyjy = listLess
  819. resp.ListSsgs = listLess
  820. resp.ListYanx = listYanx
  821. br.Ret = 200
  822. br.Success = true
  823. br.Msg = "获取成功"
  824. br.Data = resp
  825. }
  826. // 批量修改已生成的音频文件
  827. func init111() {
  828. var pars []interface{}
  829. list, err := cygx.GetResearchSummaryList("", pars, 0, 1000)
  830. if err != nil {
  831. fmt.Println(err)
  832. return
  833. }
  834. for k, v := range list {
  835. fmt.Println(k)
  836. //生成音频文件
  837. articleId := v.ArticleId
  838. var contentVideo string
  839. contentVideo = "摘要" + v.Abstract
  840. listFirst, err := cygx.GetResearchSummarylogListFirst(articleId)
  841. if err != nil {
  842. fmt.Println(err)
  843. return
  844. }
  845. listArticleType, err := cygx.GetCygxArticleTypeList()
  846. if err != nil {
  847. fmt.Println(err)
  848. return
  849. }
  850. for k, v := range listFirst {
  851. if v.Type == "SDBG" {
  852. contentVideo += "深度报告"
  853. } else if v.Type == "BZCHJH" {
  854. contentVideo += "本周晨会精华"
  855. } else if v.Type == "CYDYJY" {
  856. contentVideo += "产业调研纪要"
  857. } else if v.Type == "SSGS" {
  858. contentVideo += "上市公司调研纪要"
  859. } else if v.Type == "YANX" {
  860. contentVideo += utils.CHART_PERMISSION_NAME_MF_YANXUAN
  861. } else {
  862. contentVideo += "事件点评"
  863. }
  864. listSecond, err := cygx.GetResearchSummarylogSonListSecond(articleId, v.Type)
  865. if err != nil && err.Error() != utils.ErrNoRow() {
  866. fmt.Println(err)
  867. return
  868. }
  869. for k2, v2 := range listSecond {
  870. if v.Type == "YANX" {
  871. for _, vType := range listArticleType {
  872. if v2.ChartPermissionId == vType.YanxPermissionId {
  873. contentVideo += vType.YanxPermissionName
  874. }
  875. }
  876. } else {
  877. contentVideo += v2.PermissionName
  878. }
  879. //if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
  880. // contentVideo += utils.CHART_PERMISSION_NAME_MF_YANXUAN + "纪要"
  881. //} else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
  882. // contentVideo += utils.CHART_PERMISSION_NAME_MF_YANXUAN + "观点"
  883. //} else {
  884. // contentVideo += v2.PermissionName
  885. //}
  886. listThird, err := cygx.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  887. if err != nil && err.Error() != utils.ErrNoRow() {
  888. fmt.Println(err)
  889. return
  890. }
  891. if len(listThird) > 0 {
  892. listSecond[k2].List = listThird
  893. for _, v3 := range listThird {
  894. contentVideo += v3.Body
  895. }
  896. }
  897. }
  898. if len(listSecond) > 0 {
  899. listFirst[k].List = listSecond
  900. }
  901. }
  902. go services.CreateVideoWhithContent(articleId, v.Title, contentVideo, "cygx_research_summary")
  903. }
  904. }
  905. // @Title 本周研究汇总邮件发送
  906. // @Description 本周研究汇总邮件发送接口
  907. // @Param ArticleId query int true "报告Id"
  908. // @router /researchSummary/sendMail [get]
  909. func (this *ResearchSummaryController) ResearchSummarySendMail() {
  910. br := new(models.BaseResponse).Init()
  911. defer func() {
  912. this.Data["json"] = br
  913. this.ServeJSON()
  914. }()
  915. AdminUser := this.SysUser
  916. if AdminUser == nil {
  917. br.Msg = "请登录"
  918. br.ErrMsg = "请登录,用户信息为空"
  919. br.Ret = 408
  920. return
  921. }
  922. articleId, _ := this.GetInt("ArticleId")
  923. detail, err := cygx.GetCygxResearchSummaryInfoById(articleId)
  924. if err != nil {
  925. br.Msg = "内容不存在"
  926. br.ErrMsg = "操作失败,Err:" + err.Error()
  927. return
  928. }
  929. resp := new(cygx.DetailCygxResearchSummaryRep)
  930. resp.ArticleId = detail.ArticleId
  931. resp.Title = detail.Title
  932. resp.Department = detail.Department
  933. resp.Abstract = detail.Abstract
  934. resp.PublishStatus = detail.PublishStatus
  935. resp.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  936. //var items []*cygx.CygxRSlChartPermissionIco
  937. //`description:"类型'SDBG:深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP:事件点评,’BZCHJH:本周晨会精华’,’SSGS:本周晨会精华’"`
  938. var condition string
  939. condition = ` AND chart_permission_id IN (19,20,21,22) `
  940. listLess, err := cygx.GetChartPermissionIcoDetail(condition)
  941. if err != nil {
  942. br.Msg = "获取失败"
  943. br.ErrMsg = "获取失败,Err:" + err.Error()
  944. return
  945. }
  946. condition = ` AND chart_permission_id IN (19,20,21,22,23) `
  947. listMore, err := cygx.GetChartPermissionIcoDetail(condition)
  948. if err != nil {
  949. br.Msg = "获取失败"
  950. br.ErrMsg = "获取失败,Err:" + err.Error()
  951. return
  952. }
  953. listSdbg, err := cygx.GetCygxResearchSummaryLogRepList(articleId, "SDBG")
  954. if err != nil {
  955. br.Msg = "获取失败"
  956. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  957. return
  958. }
  959. for _, v := range listSdbg {
  960. listSon, err := cygx.GetCygxResearchSummaryLogRepListSon(articleId, v.ChartPermissionId, "SDBG")
  961. if err != nil {
  962. br.Msg = "获取失败"
  963. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  964. return
  965. }
  966. for k2, v2 := range listMore {
  967. if v2.ChartPermissionId == v.ChartPermissionId {
  968. listMore[k2].List = listSon
  969. listMore[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
  970. }
  971. }
  972. resp.SortSdbg = v.Sort
  973. }
  974. resp.ListSdbg = listMore
  975. //产业调研纪要
  976. //items = make([]*cygx.CygxRSlChartPermissionIco, 0)
  977. listCydyjy, err := cygx.GetCygxResearchSummaryLogRepList(articleId, "CYDYJY")
  978. if err != nil {
  979. br.Msg = "获取失败"
  980. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  981. return
  982. }
  983. for _, v := range listCydyjy {
  984. listSon, err := cygx.GetCygxResearchSummaryLogRepListSon(articleId, v.ChartPermissionId, "CYDYJY")
  985. if err != nil {
  986. br.Msg = "获取失败"
  987. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  988. return
  989. }
  990. for k2, v2 := range listLess {
  991. if v2.ChartPermissionId == v.ChartPermissionId {
  992. listLess[k2].List = listSon
  993. listLess[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
  994. }
  995. }
  996. resp.SortCydyjy = v.Sort
  997. }
  998. resp.ListCydyjy = listLess
  999. //上市公司
  1000. condition = ` AND chart_permission_id IN (19,20,21,22) `
  1001. listLess, err = cygx.GetChartPermissionIcoDetail(condition)
  1002. if err != nil {
  1003. br.Msg = "获取失败"
  1004. br.ErrMsg = "获取失败,Err:" + err.Error()
  1005. return
  1006. }
  1007. listSsgs, err := cygx.GetCygxResearchSummaryLogRepList(articleId, "SSGS")
  1008. if err != nil {
  1009. br.Msg = "获取失败"
  1010. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1011. return
  1012. }
  1013. for _, v := range listSsgs {
  1014. listSon, err := cygx.GetCygxResearchSummaryLogRepListSon(articleId, v.ChartPermissionId, "SSGS")
  1015. if err != nil {
  1016. br.Msg = "获取失败"
  1017. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1018. return
  1019. }
  1020. for k2, v2 := range listLess {
  1021. if v2.ChartPermissionId == v.ChartPermissionId {
  1022. listLess[k2].List = listSon
  1023. listLess[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
  1024. }
  1025. }
  1026. resp.SortSsgs = v.Sort
  1027. }
  1028. resp.ListSsgs = listLess
  1029. //研选
  1030. var listYanxItem []*cygx.CygxRSlChartPermissionIco
  1031. listType, err := cygx.GetCygxArticleTypeList()
  1032. if err != nil {
  1033. br.Msg = "获取失败"
  1034. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1035. return
  1036. }
  1037. for _, v := range listType {
  1038. item := new(cygx.CygxRSlChartPermissionIco)
  1039. item.ChartPermissionId = v.YanxPermissionId
  1040. item.ChartPermissionName = v.YanxPermissionName
  1041. item.IcoLink = v.IcoLink
  1042. item.List = make([]*cygx.AddCygxResearchSummaryLog, 0)
  1043. listYanxItem = append(listYanxItem, item)
  1044. }
  1045. itemList := listYanxItem
  1046. condition = ` AND chart_permission_id IN (19,20,21,22,31) `
  1047. listLess, err = cygx.GetChartPermissionIcoDetail(condition)
  1048. if err != nil {
  1049. br.Msg = "获取失败"
  1050. br.ErrMsg = "获取失败,Err:" + err.Error()
  1051. return
  1052. }
  1053. listYanx, err := cygx.GetCygxResearchSummaryLogRepList(articleId, "YANX")
  1054. if err != nil {
  1055. br.Msg = "获取失败"
  1056. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1057. return
  1058. }
  1059. for _, v := range listYanx {
  1060. listSon, err := cygx.GetCygxResearchSummaryLogRepListSon(articleId, v.ChartPermissionId, "YANX")
  1061. if err != nil {
  1062. br.Msg = "获取失败"
  1063. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1064. return
  1065. }
  1066. for k2, v2 := range itemList {
  1067. if v2.ChartPermissionId == v.ChartPermissionId {
  1068. itemList[k2].List = listSon
  1069. itemList[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
  1070. }
  1071. }
  1072. resp.SortYanx = v.Sort
  1073. }
  1074. resp.ListYanx = itemList
  1075. //事件点评
  1076. listSjdp, err := cygx.GetCygxResearchSummarySjdpList(articleId, "SJDP")
  1077. if err != nil {
  1078. br.Msg = "获取失败"
  1079. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1080. return
  1081. }
  1082. var itemsSjdp []*cygx.AddCygxResearchSummaryLog
  1083. for _, v := range listSjdp {
  1084. item := new(cygx.AddCygxResearchSummaryLog)
  1085. item.Body = v.Body
  1086. item.ReportLink = v.ReportLink
  1087. itemsSjdp = append(itemsSjdp, item)
  1088. resp.SortSjdp = v.Sort
  1089. }
  1090. resp.ListSjdp = itemsSjdp
  1091. //items = make([]*cygx.CygxRSlChartPermissionIco, 0)
  1092. condition = ` AND chart_permission_id IN (19,20,21,22,23) `
  1093. listMore, err = cygx.GetChartPermissionIcoDetail(condition)
  1094. if err != nil {
  1095. br.Msg = "获取失败"
  1096. br.ErrMsg = "获取失败,Err:" + err.Error()
  1097. return
  1098. }
  1099. listBzchjh, err := cygx.GetCygxResearchSummaryLogRepList(articleId, "BZCHJH")
  1100. if err != nil {
  1101. br.Msg = "获取失败"
  1102. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1103. return
  1104. }
  1105. for _, v := range listBzchjh {
  1106. listSon, err := cygx.GetCygxResearchSummaryLogRepListSon(articleId, v.ChartPermissionId, "BZCHJH")
  1107. if err != nil {
  1108. br.Msg = "获取失败"
  1109. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1110. return
  1111. }
  1112. for k2, v2 := range listMore {
  1113. if v2.ChartPermissionId == v.ChartPermissionId {
  1114. listMore[k2].List = listSon
  1115. listMore[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
  1116. }
  1117. }
  1118. resp.SortBzchjh = v.Sort
  1119. }
  1120. resp.ListBzchjh = listMore
  1121. var list []string
  1122. //添加测试环境的过滤
  1123. if utils.RunMode == "release" {
  1124. list, err = cygx.GetAllOverseasRaiEmail()
  1125. if err != nil {
  1126. br.Msg = "获取失败"
  1127. br.ErrMsg = "获取邮箱列表失败,Err:" + err.Error()
  1128. return
  1129. }
  1130. }
  1131. go cygxService.SendResearchSummaryEmail(resp, list)
  1132. br.Success = true
  1133. br.Msg = "发送成功"
  1134. br.Ret = 200
  1135. //br.Data = resp
  1136. }
  1137. // @Title 本周研究汇总的可见范围修改
  1138. // @Description 本周研究汇总的可见范围修改接口
  1139. // @Param request body cygx.ResearchSummaryId true "type json string"
  1140. // @Success 200 操作成功
  1141. // @router /researchSummary/visibleRange [post]
  1142. func (this *ResearchSummaryController) VisibleRange() {
  1143. br := new(models.BaseResponse).Init()
  1144. defer func() {
  1145. this.Data["json"] = br
  1146. this.ServeJSON()
  1147. }()
  1148. AdminUser := this.SysUser
  1149. if AdminUser == nil {
  1150. br.Msg = "请登录"
  1151. br.ErrMsg = "请登录,用户信息为空"
  1152. br.Ret = 408
  1153. return
  1154. }
  1155. var req cygx.ResearchSummaryId
  1156. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1157. if err != nil {
  1158. br.Msg = "参数解析异常!"
  1159. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1160. return
  1161. }
  1162. articleId := req.ArticleId
  1163. detail, err := cygx.GetCygxResearchSummaryInfoById(articleId)
  1164. if err != nil {
  1165. br.Msg = "内容不存在"
  1166. br.ErrMsg = "操作失败,Err:" + err.Error()
  1167. return
  1168. }
  1169. item := new(cygx.CygxResearchSummaryRep)
  1170. item.ArticleId = articleId
  1171. if detail.VisibleRange == 0 {
  1172. item.VisibleRange = 1
  1173. item.AdminId = AdminUser.AdminId
  1174. item.AdminName = AdminUser.RealName
  1175. if detail.IsSendWxMsg == 0 {
  1176. cygxService.DoThisWeekLastWeekWxTemplateMsg(detail.Title, detail.PublishDate, detail.Abstract, req.ArticleId, 2)
  1177. }
  1178. //go cygxService.UpdateResourceData(articleId, "researchsummary", "add", time.Now().Format(utils.FormatDateTime))
  1179. } else {
  1180. item.AdminId = detail.AdminId
  1181. item.AdminName = detail.AdminName
  1182. item.VisibleRange = 0
  1183. //go cygxService.UpdateResourceData(articleId, "researchsummary", "delete", time.Now().Format(utils.FormatDateTime))
  1184. }
  1185. err = cygx.ResearchSummaryVisibleRange(item)
  1186. if err != nil {
  1187. br.Msg = "操作失败"
  1188. br.ErrMsg = "操作失败,Err:" + err.Error()
  1189. return
  1190. }
  1191. go cygxService.UpdateResearchSummaryResourceData(articleId) //写入首页最新 cygx_resource_data 表
  1192. br.Ret = 200
  1193. br.Success = true
  1194. br.Msg = "操作成功"
  1195. br.IsAddLog = true
  1196. }