minutes_summary.go 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833
  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 MinutesSummaryController struct {
  19. controllers.BaseAuthController
  20. }
  21. // @Title 上周纪要汇总内容的保存与发布
  22. // @Description 上周纪要汇总内容的保存与发布接口
  23. // @Param request body cygx.AddCygxMinutesSummary true "type json string"
  24. // @Success 200 操作成功
  25. // @router /minutesSummary/PreserveAndPublish [post]
  26. func (this *MinutesSummaryController) 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.AddCygxMinutesSummary
  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. var sortSdbgStr, msgErr string
  47. content := req.Content
  48. sortYanx := content.SortYanx
  49. if sortYanx != "" {
  50. match, _ := regexp.MatchString(`^[A-Za-z]+$`, sortYanx)
  51. if !match || len(sortYanx) > 1 {
  52. br.Msg = "研选排序有误"
  53. return
  54. }
  55. content.SortYanx = strings.ToUpper(content.SortYanx)
  56. if strings.Contains(sortSdbgStr, content.SortYanx) {
  57. br.Msg = "研选排序有误"
  58. return
  59. }
  60. }
  61. sortCydyjy := content.SortCydyjy
  62. if sortCydyjy != "" {
  63. match, _ := regexp.MatchString(`^[A-Za-z]+$`, sortCydyjy)
  64. if !match || len(sortCydyjy) > 1 {
  65. br.Msg = "产业调研纪要排序有误"
  66. return
  67. }
  68. content.SortCydyjy = strings.ToUpper(content.SortCydyjy)
  69. if strings.Contains(sortSdbgStr, content.SortCydyjy) {
  70. br.Msg = "产业调研纪要排序有误"
  71. return
  72. }
  73. sortSdbgStr += content.SortCydyjy
  74. }
  75. sortSsgs := content.SortSsgs
  76. if sortSsgs != "" {
  77. match, _ := regexp.MatchString(`^[A-Za-z]+$`, sortSsgs)
  78. if !match || len(sortSsgs) > 1 {
  79. br.Msg = "上市公司调研纪要篇排序有误"
  80. return
  81. }
  82. content.SortSsgs = strings.ToUpper(content.SortSsgs)
  83. if strings.Contains(sortSdbgStr, content.SortSsgs) {
  84. br.Msg = "上市公司调研纪要篇序有误"
  85. return
  86. }
  87. }
  88. var items []*cygx.CygxMinutesSummaryLog
  89. mapSort := make(map[string]int)
  90. if len(req.List) > 0 {
  91. for _, v := range req.List {
  92. for _, v2 := range v.List {
  93. item := new(cygx.CygxMinutesSummaryLog)
  94. chartPermissionSort := v.ChartPermissionSort
  95. match, _ := regexp.MatchString(`^[A-Za-z]+$`, chartPermissionSort)
  96. if !match || len(chartPermissionSort) > 1 {
  97. br.Msg = "排序有误"
  98. return
  99. }
  100. item.ChartPermissionSort = strings.ToUpper(chartPermissionSort)
  101. if mapSort[v.ChartPermissionSort] != 0 && mapSort[v.ChartPermissionSort] != v.ChartPermissionId {
  102. br.Msg = "排序有误,排序重复"
  103. return
  104. }
  105. mapSort[v.ChartPermissionSort] = v.ChartPermissionId
  106. item.ChartPermissionId = v.ChartPermissionId
  107. item.CreateTime = time.Now()
  108. item.Body = cygxService.GetRichtext(v2.Body)
  109. item.ReportLink = v2.ReportLink
  110. if item.ReportLink != "" {
  111. articleIdLink, err := cygxService.GetReportLinkToArticleid(item.ReportLink)
  112. if err != nil {
  113. br.Msg = "操作失败"
  114. br.ErrMsg = "解析报告链接ID失败,Err:" + err.Error()
  115. return
  116. }
  117. item.LinkArticleId = articleIdLink
  118. }
  119. items = append(items, item)
  120. }
  121. }
  122. }
  123. //产业调研纪要
  124. if len(content.ListCydyjy) > 0 {
  125. items, msgErr, err = cygxService.AppendMinutesItemsLog(items, content.ListCydyjy, "CYDYJY", strings.ToUpper(content.SortCydyjy))
  126. if msgErr != "" {
  127. br.Msg = msgErr
  128. return
  129. }
  130. if err != nil {
  131. br.Msg = "操作失败"
  132. br.ErrMsg = "获取失败,Err:" + err.Error()
  133. return
  134. }
  135. }
  136. //上市公司调研纪要篇
  137. if len(content.ListSsgs) > 0 {
  138. items, msgErr, err = cygxService.AppendMinutesItemsLog(items, content.ListSsgs, "SSGS", strings.ToUpper(content.SortSsgs))
  139. if msgErr != "" {
  140. br.Msg = msgErr
  141. return
  142. }
  143. if err != nil {
  144. br.Msg = "操作失败"
  145. br.ErrMsg = "获取失败,Err:" + err.Error()
  146. return
  147. }
  148. }
  149. //研选
  150. if len(content.ListYanx) > 0 {
  151. for _, v := range content.ListYanx {
  152. item := new(cygx.CygxMinutesSummaryLog)
  153. item.Type = "YANX"
  154. item.Sort = strings.ToUpper(content.SortYanx)
  155. item.CreateTime = time.Now()
  156. item.Body = cygxService.GetRichtext(v.Body)
  157. item.ReportLink = v.ReportLink
  158. if item.ReportLink != "" {
  159. articleIdLink, err := cygxService.GetReportLinkToArticleid(item.ReportLink)
  160. if err != nil {
  161. br.Msg = "操作失败"
  162. br.ErrMsg = "解析报告链接ID失败,Err:" + err.Error()
  163. return
  164. }
  165. item.LinkArticleId = articleIdLink
  166. }
  167. items = append(items, item)
  168. }
  169. }
  170. condition := ` AND have_publish = 1 `
  171. var pars []interface{}
  172. total, err := cygx.GetCygxMinutesSummary(condition, pars)
  173. if err != nil {
  174. br.Msg = "获取失败"
  175. br.ErrMsg = "获取失败,Err:" + err.Error()
  176. return
  177. }
  178. itemCrs := new(cygx.CygxMinutesSummary)
  179. itemCrs.AdminId = AdminUser.AdminId
  180. itemCrs.AdminName = AdminUser.RealName
  181. itemCrs.Title = req.Title
  182. itemCrs.Department = req.Department
  183. itemCrs.Abstract = req.Abstract
  184. itemCrs.PublishStatus = req.DoType
  185. if req.DoType == 1 {
  186. itemCrs.HavePublish = 1
  187. itemCrs.Periods = strconv.Itoa(total + 1)
  188. }
  189. itemCrs.PublishDate = utils.StrTimeToTime(req.PublishDate + " 00:00:00")
  190. itemCrs.CreateTime = time.Now()
  191. itemCrs.LastUpdatedTime = time.Now()
  192. if req.ArticleId == 0 {
  193. articleId, err := cygx.AddCygxMinutesSummaryOrm(itemCrs, items)
  194. if err != nil {
  195. br.Msg = "操作失败"
  196. br.ErrMsg = "发布失败,Err:" + err.Error()
  197. return
  198. }
  199. req.ArticleId = int(articleId)
  200. } else {
  201. detail, err := cygx.GetCygxMinutesSummaryInfoById(req.ArticleId)
  202. if err != nil {
  203. br.Msg = "内容不存在"
  204. br.ErrMsg = "操作失败,Err:" + err.Error()
  205. return
  206. }
  207. //如果点发布PublishStatus = 1 如果点保存,PublishStatus则为之前的状态 发布人还是之前的发布人
  208. if itemCrs.PublishStatus == 0 {
  209. itemCrs.PublishStatus = detail.PublishStatus
  210. itemCrs.AdminId = detail.AdminId
  211. itemCrs.AdminName = detail.AdminName
  212. }
  213. if detail.HavePublish == 1 {
  214. itemCrs.Periods = detail.Periods
  215. itemCrs.HavePublish = detail.HavePublish
  216. }
  217. itemCrs.ArticleId = req.ArticleId
  218. _, err = cygx.UpdateCygxMinutesSummaryOrm(itemCrs, items)
  219. if err != nil {
  220. br.Msg = "操作失败"
  221. br.ErrMsg = "发布失败,Err:" + err.Error()
  222. return
  223. }
  224. }
  225. //if req.DoType == 1 {
  226. // cygxService.DoThisWeekLastWeekWxTemplateMsg(itemCrs.Title, itemCrs.PublishDate.Format(utils.FormatDateTime), itemCrs.Abstract, req.ArticleId, 3)
  227. //}
  228. //生成音频文件
  229. articleId := req.ArticleId
  230. var contentVideo string
  231. contentVideo = "摘要" + req.Abstract
  232. listFirst, err := cygx.GetMinutesSummarylogListAll(articleId)
  233. if err != nil {
  234. br.Msg = "获取失败"
  235. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  236. return
  237. }
  238. for k, v := range listFirst {
  239. if v.Type == "CYDYJY" {
  240. contentVideo += "产业调研纪要"
  241. } else if v.Type == "SSGS" {
  242. contentVideo += "上市公司调研纪要篇"
  243. } else if v.Type == "YANX" {
  244. contentVideo += utils.CHART_PERMISSION_NAME_MF_YANXUAN + "纪要"
  245. }
  246. listSecond, err := cygx.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  247. if err != nil && err.Error() != utils.ErrNoRow() {
  248. br.Msg = "获取信息失败"
  249. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  250. return
  251. }
  252. for k2, v2 := range listSecond {
  253. contentVideo += v2.PermissionName
  254. listThird, err := cygx.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  255. if err != nil && err.Error() != utils.ErrNoRow() {
  256. br.Msg = "获取信息失败"
  257. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  258. return
  259. }
  260. if len(listThird) > 0 {
  261. listSecond[k2].List = listThird
  262. for _, v3 := range listThird {
  263. contentVideo += v3.Body
  264. }
  265. }
  266. }
  267. if len(listSecond) > 0 {
  268. listFirst[k].List = listSecond
  269. }
  270. }
  271. go services.CreateVideoWhithContent(articleId, req.Title, contentVideo, "cygx_minutes_summary")
  272. go cygxService.UpdateMinutesSummaryResourceData(articleId) //写入首页最新 cygx_resource_data 表
  273. br.Ret = 200
  274. br.Success = true
  275. br.Msg = "操作成功"
  276. br.IsAddLog = true
  277. }
  278. // @Title 删除上周纪要汇总内容
  279. // @Description 删除上周纪要汇总内容接口
  280. // @Param request body cygx.MinutesSummaryId true "type json string"
  281. // @Success Ret=200
  282. // @router /minutesSummary/delete [post]
  283. func (this *MinutesSummaryController) Delete() {
  284. br := new(models.BaseResponse).Init()
  285. defer func() {
  286. this.Data["json"] = br
  287. this.ServeJSON()
  288. }()
  289. AdminUser := this.SysUser
  290. if AdminUser == nil {
  291. br.Msg = "请登录"
  292. br.ErrMsg = "请登录,SysUser Is Empty"
  293. br.Ret = 408
  294. return
  295. }
  296. var req cygx.MinutesSummaryId
  297. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  298. if err != nil {
  299. br.Msg = "参数解析异常!"
  300. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  301. return
  302. }
  303. articleId := req.ArticleId
  304. detail, err := cygx.GetCygxMinutesSummaryInfoById(articleId)
  305. if err != nil {
  306. br.Msg = "内容不存在"
  307. br.ErrMsg = "操作失败,Err:" + err.Error()
  308. return
  309. }
  310. if detail.HavePublish != 0 {
  311. br.Msg = "删除失败"
  312. br.ErrMsg = "已经存在期数无法删除"
  313. return
  314. }
  315. err = cygx.DeleteCygxMinutesSummary(articleId)
  316. if err != nil {
  317. br.Msg = "删除信息失败"
  318. br.ErrMsg = "删除信息失败,Err:" + err.Error()
  319. return
  320. }
  321. br.Ret = 200
  322. br.Success = true
  323. br.Msg = "已删除"
  324. br.IsAddLog = true
  325. }
  326. // @Title 上周纪要汇总内容详情
  327. // @Description 上周纪要汇总内容详情接口
  328. // @Param ArticleId query int true "报告Id"
  329. // @Success Ret=200 {object} cygx.DetailCygxMinutesSummaryRep
  330. // @router /minutesSummary/detail [get]
  331. func (this *MinutesSummaryController) Detail() {
  332. br := new(models.BaseResponse).Init()
  333. defer func() {
  334. this.Data["json"] = br
  335. this.ServeJSON()
  336. }()
  337. AdminUser := this.SysUser
  338. if AdminUser == nil {
  339. br.Msg = "请登录"
  340. br.ErrMsg = "请登录,用户信息为空"
  341. br.Ret = 408
  342. return
  343. }
  344. articleId, _ := this.GetInt("ArticleId")
  345. detail, err := cygx.GetCygxMinutesSummaryInfoById(articleId)
  346. if err != nil {
  347. br.Msg = "内容不存在"
  348. br.ErrMsg = "操作失败,Err:" + err.Error()
  349. return
  350. }
  351. resp := new(cygx.DetailCygxMinutesSummaryRep)
  352. resp.ArticleId = detail.ArticleId
  353. resp.Title = detail.Title
  354. resp.Department = detail.Department
  355. resp.Abstract = detail.Abstract
  356. resp.PublishStatus = detail.PublishStatus
  357. resp.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  358. var condition string
  359. condition = ` AND chart_permission_id IN (19,20,21,22) `
  360. listLess, err := cygx.GetChartPermissionIcoDetail(condition)
  361. if err != nil {
  362. br.Msg = "获取失败"
  363. br.ErrMsg = "获取失败,Err:" + err.Error()
  364. return
  365. }
  366. listCydyjy, err := cygx.GetCygxMinutesSummaryLogRepList(articleId, "CYDYJY")
  367. if err != nil {
  368. br.Msg = "获取失败"
  369. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  370. return
  371. }
  372. for _, v := range listCydyjy {
  373. listSon, err := cygx.GetCygxMinutesSummaryLogRepListSon(articleId, v.ChartPermissionId, "CYDYJY")
  374. if err != nil {
  375. br.Msg = "获取失败"
  376. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  377. return
  378. }
  379. for k2, v2 := range listLess {
  380. if v2.ChartPermissionId == v.ChartPermissionId {
  381. listLess[k2].List = listSon
  382. listLess[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
  383. }
  384. }
  385. resp.SortCydyjy = v.Sort
  386. }
  387. resp.ListCydyjy = listLess
  388. //产业调研纪要
  389. listLess, err = cygx.GetChartPermissionIcoDetail(condition)
  390. if err != nil {
  391. br.Msg = "获取失败"
  392. br.ErrMsg = "获取失败,Err:" + err.Error()
  393. return
  394. }
  395. listSsgs, err := cygx.GetCygxMinutesSummaryLogRepList(articleId, "SSGS")
  396. if err != nil {
  397. br.Msg = "获取失败"
  398. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  399. return
  400. }
  401. for _, v := range listSsgs {
  402. listSon, err := cygx.GetCygxMinutesSummaryLogRepListSon(articleId, v.ChartPermissionId, "SSGS")
  403. if err != nil {
  404. br.Msg = "获取失败"
  405. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  406. return
  407. }
  408. for k2, v2 := range listLess {
  409. if v2.ChartPermissionId == v.ChartPermissionId {
  410. listLess[k2].List = listSon
  411. listLess[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
  412. }
  413. }
  414. resp.SortSsgs = v.Sort
  415. }
  416. resp.ListSsgs = listLess
  417. //事件点评
  418. listYanx, err := cygx.GetCygxMinutesSummaryYanxList(articleId, "YANX")
  419. if err != nil {
  420. br.Msg = "获取失败"
  421. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  422. return
  423. }
  424. var itemsYanx []*cygx.AddCygxMinutesSummaryLog
  425. for _, v := range listYanx {
  426. item := new(cygx.AddCygxMinutesSummaryLog)
  427. item.Body = v.Body
  428. item.ReportLink = v.ReportLink
  429. itemsYanx = append(itemsYanx, item)
  430. resp.SortYanx = v.Sort
  431. }
  432. resp.ListYanx = itemsYanx
  433. br.Ret = 200
  434. br.Success = true
  435. br.Msg = "获取成功"
  436. br.Data = resp
  437. }
  438. // @Title 上周纪要汇总列表
  439. // @Description 获取上周纪要汇总列表接口
  440. // @Param PageSize query int true "每页数据条数"
  441. // @Param CurrentIndex query int true "当前页页码,从1开始"
  442. // @Param PublishStatus query int false "发布状态 ,1未发布,1已发布,传2查询所有"
  443. // @Param StartDate query string false "开始时间 ,列如2021-03-06 "
  444. // @Param EndDate query string false "结束时间,列如2021-03-06 "
  445. // @Success 200 {object} cygx.CygxMinutesSummaryListRep
  446. // @router /minutesSummary/list [get]
  447. func (this *MinutesSummaryController) List() {
  448. br := new(models.BaseResponse).Init()
  449. defer func() {
  450. this.Data["json"] = br
  451. this.ServeJSON()
  452. }()
  453. AdminUser := this.SysUser
  454. if AdminUser == nil {
  455. br.Msg = "请登录"
  456. br.ErrMsg = "请登录,SysUser Is Empty"
  457. return
  458. }
  459. pageSize, _ := this.GetInt("PageSize")
  460. currentIndex, _ := this.GetInt("CurrentIndex")
  461. publishStatus, _ := this.GetInt("PublishStatus")
  462. startDate := this.GetString("StartDate")
  463. endDate := this.GetString("EndDate")
  464. var startSize int
  465. if pageSize <= 0 {
  466. pageSize = utils.PageSize20
  467. }
  468. if currentIndex <= 0 {
  469. currentIndex = 1
  470. }
  471. startSize = utils.StartIndex(currentIndex, pageSize)
  472. var condition string
  473. var pars []interface{}
  474. if startDate != "" {
  475. condition += ` AND rs.publish_date >= ` + "'" + startDate + " 00:00:00'"
  476. }
  477. if endDate != "" {
  478. condition += ` AND rs.publish_date <= ` + "'" + endDate + " 23:59:59'"
  479. }
  480. if publishStatus == 0 || publishStatus == 1 {
  481. condition += ` AND rs.publish_status = ` + strconv.Itoa(publishStatus)
  482. }
  483. total, err := cygx.GetCygxMinutesSummary(condition, pars)
  484. if err != nil {
  485. br.Msg = "获取失败"
  486. br.ErrMsg = "获取失败,Err:" + err.Error()
  487. return
  488. }
  489. list, err := cygx.GetMinutesSummaryList(condition, pars, startSize, pageSize)
  490. if err != nil {
  491. br.Msg = "获取失败"
  492. br.ErrMsg = "获取失败,Err:" + err.Error()
  493. return
  494. }
  495. for k, v := range list {
  496. if v.Periods != "" && v.Periods != "0" {
  497. list[k].Periods = "第" + v.Periods + "期"
  498. } else {
  499. list[k].Periods = ""
  500. }
  501. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  502. }
  503. page := paging.GetPaging(currentIndex, pageSize, total)
  504. resp := new(cygx.CygxMinutesSummaryListRep)
  505. resp.List = list
  506. resp.Paging = page
  507. br.Ret = 200
  508. br.Success = true
  509. br.Msg = "获取成功"
  510. br.Data = resp
  511. }
  512. // @Title 上周纪要汇总的发布与取消发布
  513. // @Description 上周纪要汇总的发布与取消发布接口
  514. // @Param request body cygx.ResearchSummaryId true "type json string"
  515. // @Success 200 操作成功
  516. // @router /minutesSummary/PublishAndCancel [post]
  517. func (this *MinutesSummaryController) PublishAndCancel() {
  518. br := new(models.BaseResponse).Init()
  519. defer func() {
  520. this.Data["json"] = br
  521. this.ServeJSON()
  522. }()
  523. AdminUser := this.SysUser
  524. if AdminUser == nil {
  525. br.Msg = "请登录"
  526. br.ErrMsg = "请登录,用户信息为空"
  527. br.Ret = 408
  528. return
  529. }
  530. var req cygx.ResearchSummaryId
  531. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  532. if err != nil {
  533. br.Msg = "参数解析异常!"
  534. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  535. return
  536. }
  537. articleId := req.ArticleId
  538. detail, err := cygx.GetCygxMinutesSummaryInfoById(articleId)
  539. if err != nil {
  540. br.Msg = "内容不存在"
  541. br.ErrMsg = "操作失败,Err:" + err.Error()
  542. return
  543. }
  544. item := new(cygx.CygxMinutesSummaryRep)
  545. item.ArticleId = articleId
  546. if detail.PublishStatus == 0 {
  547. item.PublishStatus = 1
  548. item.AdminId = AdminUser.AdminId
  549. item.AdminName = AdminUser.RealName
  550. //cygxService.DoThisWeekLastWeekWxTemplateMsg(detail.Title, detail.PublishDate, detail.Abstract, req.ArticleId, 3)
  551. } else {
  552. item.AdminId = detail.AdminId
  553. item.AdminName = detail.AdminName
  554. item.PublishStatus = 0
  555. }
  556. if detail.HavePublish == 0 {
  557. condition := ` AND have_publish = 1 `
  558. var pars []interface{}
  559. total, err := cygx.GetCygxMinutesSummary(condition, pars)
  560. if err != nil {
  561. br.Msg = "获取失败"
  562. br.ErrMsg = "获取失败,Err:" + err.Error()
  563. return
  564. }
  565. item.Periods = strconv.Itoa(total + 1)
  566. } else {
  567. item.Periods = detail.Periods
  568. }
  569. err = cygx.MinutesSummaryPublishAndCancel(item)
  570. if err != nil {
  571. br.Msg = "操作失败"
  572. br.ErrMsg = "操作失败,Err:" + err.Error()
  573. return
  574. }
  575. br.Ret = 200
  576. br.Success = true
  577. br.Msg = "操作成功"
  578. br.IsAddLog = true
  579. }
  580. // 批量修改已生成的音频文件
  581. func init123() {
  582. var pars []interface{}
  583. list, err := cygx.GetMinutesSummaryList("", pars, 0, 1000)
  584. if err != nil {
  585. fmt.Println(err)
  586. return
  587. }
  588. for _, v := range list {
  589. //生成音频文件
  590. articleId := v.ArticleId
  591. var contentVideo string
  592. contentVideo = "摘要" + v.Abstract
  593. listFirst, err := cygx.GetMinutesSummarylogListAll(articleId)
  594. if err != nil {
  595. fmt.Println(err)
  596. return
  597. }
  598. for k, v := range listFirst {
  599. if v.Type == "CYDYJY" {
  600. contentVideo += "产业调研纪要"
  601. } else if v.Type == "SSGS" {
  602. contentVideo += "上市公司调研纪要篇"
  603. } else if v.Type == "YANX" {
  604. contentVideo += utils.CHART_PERMISSION_NAME_MF_YANXUAN + "纪要"
  605. }
  606. listSecond, err := cygx.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  607. if err != nil && err.Error() != utils.ErrNoRow() {
  608. fmt.Println(err)
  609. return
  610. }
  611. for k2, v2 := range listSecond {
  612. contentVideo += v2.PermissionName
  613. listThird, err := cygx.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  614. if err != nil && err.Error() != utils.ErrNoRow() {
  615. fmt.Println(err)
  616. return
  617. }
  618. if len(listThird) > 0 {
  619. listSecond[k2].List = listThird
  620. for _, v3 := range listThird {
  621. contentVideo += v3.Body
  622. }
  623. }
  624. }
  625. if len(listSecond) > 0 {
  626. listFirst[k].List = listSecond
  627. }
  628. }
  629. go services.CreateVideoWhithContent(articleId, v.Title, contentVideo, "cygx_minutes_summary")
  630. }
  631. }
  632. // @Title 上周研究汇总邮件发送
  633. // @Description 上周研究汇总邮件发送接口
  634. // @Param ArticleId query int true "报告Id"
  635. // @router /minutesSummary/sendMail [get]
  636. func (this *MinutesSummaryController) MinutesSummarySendMail() {
  637. br := new(models.BaseResponse).Init()
  638. defer func() {
  639. this.Data["json"] = br
  640. this.ServeJSON()
  641. }()
  642. AdminUser := this.SysUser
  643. if AdminUser == nil {
  644. br.Msg = "请登录"
  645. br.ErrMsg = "请登录,用户信息为空"
  646. br.Ret = 408
  647. return
  648. }
  649. articleId, _ := this.GetInt("ArticleId")
  650. detail, err := cygx.GetCygxMinutesSummaryInfoById(articleId)
  651. if err != nil {
  652. br.Msg = "内容不存在"
  653. br.ErrMsg = "操作失败,Err:" + err.Error()
  654. return
  655. }
  656. resp := new(cygx.DetailCygxMinutesSummaryRep)
  657. resp.ArticleId = detail.ArticleId
  658. resp.Title = detail.Title
  659. resp.Department = detail.Department
  660. resp.Abstract = detail.Abstract
  661. resp.PublishStatus = detail.PublishStatus
  662. resp.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  663. var condition string
  664. condition = ` AND chart_permission_id IN (19,20,21,22) `
  665. listLess, err := cygx.GetChartPermissionIcoDetail(condition)
  666. if err != nil {
  667. br.Msg = "获取失败"
  668. br.ErrMsg = "获取失败,Err:" + err.Error()
  669. return
  670. }
  671. listCydyjy, err := cygx.GetCygxMinutesSummaryLogRepList(articleId, "CYDYJY")
  672. if err != nil {
  673. br.Msg = "获取失败"
  674. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  675. return
  676. }
  677. for _, v := range listCydyjy {
  678. listSon, err := cygx.GetCygxMinutesSummaryLogRepListSon(articleId, v.ChartPermissionId, "CYDYJY")
  679. if err != nil {
  680. br.Msg = "获取失败"
  681. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  682. return
  683. }
  684. for k2, v2 := range listLess {
  685. if v2.ChartPermissionId == v.ChartPermissionId {
  686. listLess[k2].List = listSon
  687. listLess[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
  688. }
  689. }
  690. resp.SortCydyjy = v.Sort
  691. }
  692. resp.ListCydyjy = listLess
  693. //产业调研纪要
  694. listLess, err = cygx.GetChartPermissionIcoDetail(condition)
  695. if err != nil {
  696. br.Msg = "获取失败"
  697. br.ErrMsg = "获取失败,Err:" + err.Error()
  698. return
  699. }
  700. listSsgs, err := cygx.GetCygxMinutesSummaryLogRepList(articleId, "SSGS")
  701. if err != nil {
  702. br.Msg = "获取失败"
  703. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  704. return
  705. }
  706. for _, v := range listSsgs {
  707. listSon, err := cygx.GetCygxMinutesSummaryLogRepListSon(articleId, v.ChartPermissionId, "SSGS")
  708. if err != nil {
  709. br.Msg = "获取失败"
  710. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  711. return
  712. }
  713. for k2, v2 := range listLess {
  714. if v2.ChartPermissionId == v.ChartPermissionId {
  715. listLess[k2].List = listSon
  716. listLess[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
  717. }
  718. }
  719. resp.SortSsgs = v.Sort
  720. }
  721. resp.ListSsgs = listLess
  722. //事件点评
  723. listYanx, err := cygx.GetCygxMinutesSummaryYanxList(articleId, "YANX")
  724. if err != nil {
  725. br.Msg = "获取失败"
  726. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  727. return
  728. }
  729. var itemsYanx []*cygx.AddCygxMinutesSummaryLog
  730. for _, v := range listYanx {
  731. item := new(cygx.AddCygxMinutesSummaryLog)
  732. item.Body = v.Body
  733. item.ReportLink = v.ReportLink
  734. itemsYanx = append(itemsYanx, item)
  735. resp.SortYanx = v.Sort
  736. }
  737. resp.ListYanx = itemsYanx
  738. var list []string
  739. //添加测试环境的过滤
  740. if utils.RunMode == "release" {
  741. list, err = cygx.GetAllOverseasRaiEmail()
  742. if err != nil {
  743. br.Msg = "获取失败"
  744. br.ErrMsg = "获取邮箱列表失败,Err:" + err.Error()
  745. return
  746. }
  747. }
  748. go cygxService.SendMinutesSummaryEmail(resp, list)
  749. br.Success = true
  750. br.Msg = "发送成功"
  751. br.Ret = 200
  752. }
  753. // @Title 上周纪要汇总的可见范围修改
  754. // @Description 上周纪要汇总的可见范围修改接口
  755. // @Param request body cygx.ResearchSummaryId true "type json string"
  756. // @Success 200 操作成功
  757. // @router /minutesSummary/visibleRange [post]
  758. func (this *MinutesSummaryController) VisibleRange() {
  759. br := new(models.BaseResponse).Init()
  760. defer func() {
  761. this.Data["json"] = br
  762. this.ServeJSON()
  763. }()
  764. AdminUser := this.SysUser
  765. if AdminUser == nil {
  766. br.Msg = "请登录"
  767. br.ErrMsg = "请登录,用户信息为空"
  768. br.Ret = 408
  769. return
  770. }
  771. var req cygx.ResearchSummaryId
  772. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  773. if err != nil {
  774. br.Msg = "参数解析异常!"
  775. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  776. return
  777. }
  778. articleId := req.ArticleId
  779. detail, err := cygx.GetCygxMinutesSummaryInfoById(articleId)
  780. if err != nil {
  781. br.Msg = "内容不存在"
  782. br.ErrMsg = "操作失败,Err:" + err.Error()
  783. return
  784. }
  785. item := new(cygx.CygxMinutesSummaryRep)
  786. item.ArticleId = articleId
  787. if detail.VisibleRange == 0 {
  788. item.VisibleRange = 1
  789. item.AdminId = AdminUser.AdminId
  790. item.AdminName = AdminUser.RealName
  791. if detail.IsSendWxMsg == 0 {
  792. cygxService.DoThisWeekLastWeekWxTemplateMsg(detail.Title, detail.PublishDate, detail.Abstract, req.ArticleId, 3)
  793. }
  794. //go cygxService.UpdateResourceData(articleId, "minutessummary", "add", time.Now().Format(utils.FormatDateTime))
  795. } else {
  796. item.AdminId = detail.AdminId
  797. item.AdminName = detail.AdminName
  798. item.VisibleRange = 0
  799. //go cygxService.UpdateResourceData(articleId, "minutessummary", "delete", time.Now().Format(utils.FormatDateTime))
  800. }
  801. err = cygx.MinutesSummaryVisibleRange(item)
  802. if err != nil {
  803. br.Msg = "操作失败"
  804. br.ErrMsg = "操作失败,Err:" + err.Error()
  805. return
  806. }
  807. go cygxService.UpdateMinutesSummaryResourceData(articleId) //写入首页最新 cygx_resource_data 表
  808. br.Ret = 200
  809. br.Success = true
  810. br.Msg = "操作成功"
  811. br.IsAddLog = true
  812. }