summary_manage.go 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743
  1. package cygx
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "github.com/tealeg/xlsx"
  7. "hongze/hz_crm_api/controllers"
  8. "hongze/hz_crm_api/models"
  9. "hongze/hz_crm_api/models/company"
  10. "hongze/hz_crm_api/models/cygx"
  11. "hongze/hz_crm_api/models/system"
  12. "hongze/hz_crm_api/services"
  13. cygxService "hongze/hz_crm_api/services/cygx"
  14. "hongze/hz_crm_api/services/elastic"
  15. "hongze/hz_crm_api/utils"
  16. "os"
  17. "path/filepath"
  18. "strconv"
  19. "strings"
  20. "time"
  21. )
  22. // 纪要管理
  23. type SummaryManage struct {
  24. controllers.BaseAuthController
  25. }
  26. // @Title 文章内容的保存与发布
  27. // @Description 文章内容的保存与发布接口
  28. // @Param request body cygx.SummaryManageAddRep true "type json string"
  29. // @Success 200 操作成功
  30. // @router /summaryManage/PreserveAndPublish [post]
  31. func (this *SummaryManage) PreserveAndPublish() {
  32. br := new(models.BaseResponse).Init()
  33. defer func() {
  34. this.Data["json"] = br
  35. this.ServeJSON()
  36. }()
  37. AdminUser := this.SysUser
  38. if AdminUser == nil {
  39. br.Msg = "请登录"
  40. br.ErrMsg = "请登录,用户信息为空"
  41. br.Ret = 408
  42. return
  43. }
  44. var req cygx.SummaryManageAddRep
  45. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  46. if err != nil {
  47. br.Msg = "参数解析异常!"
  48. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  49. return
  50. }
  51. if req.Title == "" {
  52. br.Msg = "标题不可为空"
  53. br.ErrMsg = "标题不可为空"
  54. return
  55. }
  56. if req.Abstract == "" {
  57. br.Msg = "摘要不可为空"
  58. br.ErrMsg = "摘要不可为空"
  59. return
  60. }
  61. if req.PublishDate == "" {
  62. br.Msg = "发布时间不可为空"
  63. return
  64. }
  65. var articleIdNew int //最新的文章id
  66. var haveResearch bool
  67. var permissionName string
  68. industryName := req.IndustryName
  69. subjectName := req.SubjectName
  70. publishDate := req.PublishDate
  71. reportLink := req.ReportLink
  72. chartPermissionIds := "31" //31研选
  73. industrialManagementIds := req.IndustrialManagementIds
  74. industrialSubjectIds := req.IndustrialSubjectIds
  75. articleId := req.ArticleId
  76. articleTypeId := req.ArticleTypeId
  77. detailIndustryNameList, err := cygx.GetIndustrialManagemenDetailByAaticleID(articleId)
  78. if err != nil {
  79. br.Msg = "分类失败"
  80. br.ErrMsg = "获取报告原有分类失败,Err:" + err.Error()
  81. return
  82. }
  83. var industryId []string
  84. for _, v := range detailIndustryNameList {
  85. industryId = append(industryId, strconv.Itoa(v.IndustrialManagementId))
  86. }
  87. // 产业ID校验
  88. industryIds := make([]int, 0)
  89. industrialManagementIdList := strings.Split(industrialManagementIds, ",")
  90. for _, v := range industrialManagementIdList {
  91. i, err := strconv.Atoi(v)
  92. if err != nil {
  93. br.Msg = "参数解析异常!"
  94. br.ErrMsg = "产业ID不规范,Err:" + err.Error() + industrialManagementIds
  95. return
  96. }
  97. industryIds = append(industryIds, i)
  98. industryId = append(industryId, v)
  99. }
  100. if industrialSubjectIds != "" {
  101. industrialSubjectIdList := strings.Split(industrialSubjectIds, ",")
  102. for _, v := range industrialSubjectIdList {
  103. _, err := strconv.Atoi(v)
  104. if err != nil {
  105. br.Msg = "参数解析异常!"
  106. br.ErrMsg = "标的ID不规范,Err:" + err.Error() + industrialSubjectIds
  107. return
  108. }
  109. }
  110. }
  111. chartPermissionIdsList := strings.Split(chartPermissionIds, ",")
  112. for _, v := range chartPermissionIdsList {
  113. chartPermissionId, err := strconv.Atoi(v)
  114. if err != nil {
  115. br.Msg = "发布失败"
  116. br.ErrMsg = "发布失败,Err:" + err.Error()
  117. return
  118. }
  119. charInfo, errCategory := cygx.GetCategoryInfoById(chartPermissionId)
  120. if errCategory != nil {
  121. br.Msg = "获取品种信息失败"
  122. br.ErrMsg = "获取品种信息失败,Err:" + errCategory.Error()
  123. return
  124. }
  125. if strings.Contains(charInfo.PermissionName, "研选") {
  126. haveResearch = true
  127. }
  128. permissionName += charInfo.PermissionName + ","
  129. }
  130. permissionName = strings.TrimRight(permissionName, ",")
  131. if articleId == 0 {
  132. maxArticleIdArticleInfo, errMax := cygx.GetMaxArticleIdInfo()
  133. if errMax != nil {
  134. br.Msg = "发布失败"
  135. br.ErrMsg = "发布失败,Err:" + errMax.Error()
  136. return
  137. }
  138. if maxArticleIdArticleInfo.ArticleId < utils.SummaryArticleId {
  139. articleIdNew = utils.SummaryArticleId
  140. } else {
  141. articleIdNew = maxArticleIdArticleInfo.ArticleId + 1
  142. }
  143. }
  144. //处理文章类型信息
  145. articleTypeInfo, err := cygx.GetCygxArticleTypeDetailById(articleTypeId)
  146. if err != nil {
  147. br.Msg = "请选择报告类型"
  148. br.ErrMsg = "获取报告类型信息失败,Err:" + err.Error()
  149. return
  150. }
  151. //处理作者内容的格式信息
  152. department := req.SellerAndMobile
  153. itemDepartment := new(cygx.CygxArticleDepartment)
  154. if !strings.Contains(department, "-") {
  155. br.Msg = "作者格式错误"
  156. return
  157. }
  158. slice := strings.Split(department, "-")
  159. if len(slice) < 2 {
  160. br.Msg = "作者格式错误"
  161. return
  162. }
  163. strnum := strings.Index(department, "-")
  164. itemDepartment.NickName = department[0:strnum]
  165. itemDepartment.CreateTime = time.Now()
  166. itemDepartment.Remark = department[strnum+1:]
  167. itemDepartment.Content = req.SellerAndMobile
  168. remarks := itemDepartment.Remark
  169. remarks = strings.Replace(remarks, ",", "", -1)
  170. remarks = strings.Replace(remarks, ",", "", -1)
  171. remarks = strings.Replace(remarks, " ", "", -1)
  172. itemDepartment.Remarks = remarks
  173. total, _ := cygx.GetArticleDepartmentCount(itemDepartment.NickName, itemDepartment.Remarks)
  174. var newDepartmentId int64
  175. if total == 0 {
  176. detail, err := cygx.GetCygxConfigDetailByCode("department_img_url")
  177. if err != nil {
  178. br.Msg = "获取失败"
  179. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  180. return
  181. }
  182. sliceDepart := strings.Split(detail.ConfigValue, "{|}")
  183. totalDepart, err := cygx.GetArticleDepartmentCountAll()
  184. if err != nil {
  185. br.Msg = "获取失败"
  186. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  187. return
  188. }
  189. itemDepartment.ImgUrl = sliceDepart[totalDepart%10]
  190. //避免代码冗余,放弃插入事务处理
  191. newDepartmentId, err = cygx.AddCygxArticleDepartment(itemDepartment)
  192. if err != nil {
  193. br.Msg = "发布失败"
  194. br.ErrMsg = "发布失败作者信息查询错误,Err:" + err.Error()
  195. return
  196. }
  197. } else {
  198. departmentDetail, err := cygx.GetArticleDepartmentDateil(itemDepartment.NickName, itemDepartment.Remarks)
  199. if err != nil {
  200. br.Msg = "发布失败"
  201. br.ErrMsg = "发布失败作者信息查询错误,Err:" + err.Error()
  202. return
  203. }
  204. newDepartmentId = int64(departmentDetail.DepartmentId)
  205. }
  206. expertNumStr, expertContentStr, interviewDateStr, fileLink := cygx.BodyAnalysis(req.Body)
  207. item := new(cygx.CygxArticle)
  208. item.AdminId = AdminUser.AdminId
  209. item.AdminName = AdminUser.RealName
  210. item.Title = req.Title
  211. item.Body = req.Body
  212. item.BodyText, _ = cygxService.GetReportContentTextSubNew(req.Body)
  213. item.Abstract = req.Abstract
  214. item.CategoryName = permissionName
  215. item.ArticleId = articleId
  216. item.CreateDate = time.Now()
  217. item.LastUpdatedTime = time.Now()
  218. if articleTypeInfo.IsSendEs == 1 {
  219. item.IsSummary = 1
  220. } else {
  221. item.IsReport = 1
  222. }
  223. item.Source = 1
  224. item.ArticleIdMd5 = utils.MD5(strconv.Itoa(articleIdNew))
  225. item.UpdateFrequency = "unknow"
  226. item.SellerAndMobile = req.SellerAndMobile
  227. item.ExpertBackground = expertContentStr
  228. item.ExpertNumber = expertNumStr
  229. item.InterviewDate = interviewDateStr
  230. item.FileLink = fileLink
  231. item.ChartPermissionIds = chartPermissionIds
  232. item.DepartmentId = int(newDepartmentId)
  233. item.ArticleTypeId = articleTypeId
  234. item.ArticleTypeName = articleTypeInfo.ArticleTypeName
  235. publishDateSlice := strings.Split(publishDate, " ") //过滤前端传过来的时分秒
  236. item.PublishDate = utils.StrTimeToTime(publishDateSlice[0] + " 00:00:00")
  237. item.ReportLink = reportLink
  238. if haveResearch {
  239. item.Department = "机构投资者"
  240. } else {
  241. item.Department = "弘则权益研究"
  242. br.Msg = "请选择研选行业"
  243. return
  244. }
  245. //买方研选自定义
  246. item.ChartPermissionId = 31
  247. item.ChartPermissionName = utils.CHART_PERMISSION_NAME_MAI_FANG_YANXUAN
  248. charInfo, err := cygx.GetCategoryInfoByName(utils.CHART_PERMISSION_NAME_MF_YANXUAN)
  249. if err != nil {
  250. br.Msg = "操作失败"
  251. br.ErrMsg = "获取所属行业信息失败,Err:" + err.Error()
  252. return
  253. }
  254. if req.DoType == 1 {
  255. item.PublishStatus = 1
  256. }
  257. //industrialManagementId, _ := strconv.Atoi(industrialManagementIds)
  258. //industrialDetail, _ := cygx.GetIndustrialManagemenDetailById(industrialManagementId)
  259. var errArt error
  260. if articleId == 0 {
  261. item.ArticleId = articleIdNew
  262. //需求修改纪要的新增与修改与报告一致
  263. _, err := cygx.AddAReportrticle(item, charInfo.ChartPermissionId, industryName, subjectName, itemDepartment, industrialManagementIds, industrialSubjectIds)
  264. errArt = err
  265. if errArt == nil {
  266. //articleInfo, err := cygx.GetArticleIdInfoBySummaryManageIdEdit(int(artNewId))
  267. if err == nil && req.DoType == 1 {
  268. go cygxService.DoArticleOnenIdWxTemplateMsg(articleIdNew, 1)
  269. }
  270. }
  271. } else {
  272. articleInfo, errInfo := cygx.GetArticleIdInfoByArticleId(articleId)
  273. if articleInfo == nil {
  274. br.Msg = "文章不存在"
  275. return
  276. }
  277. if errInfo != nil {
  278. br.Msg = "发布失败"
  279. br.ErrMsg = "发布失败,Err:" + errInfo.Error()
  280. return
  281. }
  282. if item.PublishStatus == 0 {
  283. item.PublishStatus = articleInfo.PublishStatus
  284. }
  285. item.ArticleId = articleId
  286. err := cygx.EditReportrticle(item, charInfo.ChartPermissionId, industryName, subjectName, articleInfo.PublishStatus, itemDepartment, industrialManagementIds, industrialSubjectIds)
  287. errArt = err
  288. if errArt == nil && req.DoType == 1 {
  289. go cygxService.DoArticleOnenIdWxTemplateMsg(articleId, 1)
  290. }
  291. }
  292. if errArt != nil {
  293. br.Msg = "发布失败"
  294. br.ErrMsg = "发布失败,Err:" + errArt.Error()
  295. return
  296. }
  297. // 查研观向7.4-这里暂时注释掉, 目前article和industry有关联表处理, 此处应该是没有在用了
  298. //var subjectIds string
  299. //subjectIds, _ = cygx.GetSubjectIds(articleId)
  300. //{|1|}表示报告类型,{|2|}表示纪要类型
  301. //cygx.UpdateSubjecIds(subjectIds+"—"+strconv.Itoa(industrialDetail.IndustrialManagementId)+"{|2|}", industrialDetail.IndustrialManagementId, articleId)
  302. if item.PublishStatus == 1 && articleTypeInfo.IsSendEs == 1 {
  303. services.EsAddOrEditData(item)
  304. }
  305. ////同步数据到最新表
  306. //if req.ArticleId == 0 {
  307. // if item.PublishStatus == 1 {
  308. // go cygxService.UpdateResourceData(item.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime))
  309. // }
  310. //} else {
  311. // if item.PublishStatus == 1 {
  312. // go cygxService.UpdateResourceData(item.ArticleId, "article", "update", time.Now().Format(utils.FormatDateTime))
  313. // }
  314. // if req.DoType == 1 {
  315. // go cygxService.UpdateResourceData(item.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime))
  316. // }
  317. //}
  318. if len(industryIds) > 0 {
  319. go cygxService.UpdateIndustryLayoutTime(industryIds, false) // 查研观向7.4-更新产业布局时间
  320. go elastic.AddComprehensiveIndustrialSource("Yx", item.ArticleId) // 查研观向10.6 更新搜索引擎的产业资源包
  321. }
  322. go elastic.AddComprehensiveArticle(item.ArticleId) // ES添加文章:报告、纪要
  323. go cygxService.UpdateArticleResourceData(item.ArticleId) //写入首页最新 cygx_resource_data 表
  324. go cygxService.MakeArticleMomentsImg(item.ArticleId) //生成文章分享到朋友圈的图片
  325. go cygxService.UpdateIndustrialsourceHzResourceDataById(industryId, "Yx") //修改相关产业关联的报告信息
  326. br.Ret = 200
  327. br.Success = true
  328. br.Msg = "操作成功"
  329. br.IsAddLog = true
  330. }
  331. // @Title 文章的发布与取消发布
  332. // @Description 文章的发布与取消发布接口
  333. // @Param request body cygx.SummaryManageIdRep true "type json string"
  334. // @Success 200 操作成功
  335. // @router /summaryManage/PublishAndCancel [post]
  336. func (this *SummaryManage) PublishAndCancel() {
  337. br := new(models.BaseResponse).Init()
  338. defer func() {
  339. this.Data["json"] = br
  340. this.ServeJSON()
  341. }()
  342. AdminUser := this.SysUser
  343. indexName := utils.IndexName
  344. if AdminUser == nil {
  345. br.Msg = "请登录"
  346. br.ErrMsg = "请登录,用户信息为空"
  347. br.Ret = 408
  348. return
  349. }
  350. var req cygx.SummaryManageIdRep
  351. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  352. if err != nil {
  353. br.Msg = "参数解析异常!"
  354. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  355. return
  356. }
  357. articleId := req.ArticleId
  358. item := new(cygx.CygxArticle)
  359. articleInfo, errInfo := cygx.GetArticleInfoOtherByArticleId(articleId)
  360. if articleInfo == nil {
  361. br.Msg = "操作失败"
  362. br.ErrMsg = "纪要ID错误"
  363. return
  364. }
  365. if errInfo != nil {
  366. br.Msg = "操作失败"
  367. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  368. return
  369. }
  370. item.ArticleId = articleId
  371. item.Title = articleInfo.Title
  372. item.BodyText = articleInfo.BodyText
  373. item.Body = articleInfo.Body
  374. item.PublishDate = articleInfo.PublishDate
  375. item.ExpertBackground = articleInfo.ExpertBackground
  376. item.CategoryId = articleInfo.CategoryId
  377. //item.Annotation, _ = GetReportContentTextSubNew(v.Annotation)
  378. //item.Abstract, _ = GetReportContentTextSubNew(v.Abstract)
  379. if articleInfo.PublishStatus == 0 {
  380. item.PublishStatus = 1
  381. item.AdminId = AdminUser.AdminId
  382. item.AdminName = AdminUser.RealName
  383. services.EsAddOrEditData(item)
  384. //go cygxService.UpdateResourceData(item.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime))
  385. } else {
  386. item.AdminId = articleInfo.AdminId
  387. item.AdminName = articleInfo.AdminName
  388. item.PublishStatus = 0
  389. services.EsDeleteData(indexName, strconv.Itoa(articleInfo.ArticleId))
  390. //go cygxService.UpdateResourceData(item.ArticleId, "article", "delete", time.Now().Format(utils.FormatDateTime))
  391. }
  392. err = cygx.PublishAndCancel(item)
  393. if err != nil {
  394. br.Msg = "操作失败"
  395. br.ErrMsg = "操作失败,Err:" + err.Error()
  396. return
  397. }
  398. //专项调研类型的报告单独走发送
  399. if articleInfo.SubCategoryName == "专项调研" {
  400. if item.PublishStatus == 1 {
  401. cygxService.SendWxMsgWithCygxActivitySpecialArticle(item.ArticleId)
  402. }
  403. } else {
  404. if item.PublishStatus == 1 {
  405. articleIndustrial, _ := cygx.GetIndustrialManagemenDetailByAaticle(articleInfo.ArticleId)
  406. if articleIndustrial.ArticleId > 0 {
  407. go cygxService.DoArticleOnenIdWxTemplateMsg(articleId, 1)
  408. }
  409. go elastic.AddComprehensiveIndustrialSource("Yx", item.ArticleId) // 查研观向10.6 更新搜索引擎的产业资源包
  410. }
  411. }
  412. go elastic.AddComprehensiveArticle(articleId) // ES添加文章:报告、纪要
  413. go cygxService.UpdateArticleResourceData(item.ArticleId) //写入首页最新 cygx_resource_data 表
  414. br.Ret = 200
  415. br.Success = true
  416. br.Msg = "操作成功"
  417. br.IsAddLog = true
  418. }
  419. // @Title 文章详情
  420. // @Description 获取文章详情接口
  421. // @Param ArticleId query int true "文章ID"
  422. // @Success Ret=200 {object} cygx.SummaryManageEditDetail
  423. // @router /summaryManage/detail [get]
  424. func (this *SummaryManage) Detail() {
  425. br := new(models.BaseResponse).Init()
  426. defer func() {
  427. this.Data["json"] = br
  428. this.ServeJSON()
  429. }()
  430. AdminUser := this.SysUser
  431. if AdminUser == nil {
  432. br.Msg = "请登录"
  433. br.ErrMsg = "请登录,用户信息为空"
  434. br.Ret = 408
  435. return
  436. }
  437. articleId, _ := this.GetInt("ArticleId")
  438. if articleId < 1 {
  439. br.Msg = "请输入文章ID"
  440. return
  441. }
  442. articleInfo, err := cygx.GetArticleIdInfoByreportIdEdit(articleId)
  443. if err != nil {
  444. br.Msg = "文章内容不存在"
  445. br.ErrMsg = "纪要ID错误,Err:" + err.Error()
  446. return
  447. }
  448. detail, _ := cygx.GetArticleDepartmentDateilByDepartmentId(articleInfo.DepartmentId)
  449. industrialList, err := cygx.GetIndustrialArticleGroupManagementList(articleInfo.ArticleId)
  450. if err != nil && err.Error() != utils.ErrNoRow() {
  451. br.Msg = "获取信息失败"
  452. br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(articleInfo.ArticleId)
  453. return
  454. }
  455. subjectList, err := cygx.GetSubjectArticleGroupManagementList(articleInfo.ArticleId)
  456. if err != nil && err.Error() != utils.ErrNoRow() {
  457. br.Msg = "获取信息失败"
  458. br.ErrMsg = "获取活动关联的标的列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(articleInfo.ArticleId)
  459. return
  460. }
  461. articleInfo.ListIndustrial = industrialList
  462. articleInfo.ListSubject = subjectList
  463. resp := cygx.ArticleDetailResp{
  464. ArticleId: articleInfo.ArticleId,
  465. Title: articleInfo.Title,
  466. Abstract: articleInfo.Abstract,
  467. Body: articleInfo.Body,
  468. PublishStatus: articleInfo.PublishStatus,
  469. PublishDate: articleInfo.PublishDate,
  470. CreateDate: articleInfo.CreateDate,
  471. LastUpdatedTime: articleInfo.LastUpdatedTime,
  472. ArticleIdMd5: articleInfo.ArticleIdMd5,
  473. SellerAndMobile: articleInfo.SellerAndMobile,
  474. SubjectName: articleInfo.SubjectName,
  475. IndustryName: articleInfo.IndustryName,
  476. DepartmentId: articleInfo.DepartmentId,
  477. ChartPermissionIds: articleInfo.ChartPermissionIds,
  478. ArticleTypeId: articleInfo.ArticleTypeId,
  479. ArticleTypeName: articleInfo.ArticleTypeName,
  480. ListIndustrial: articleInfo.ListIndustrial,
  481. ListSubject: articleInfo.ListSubject,
  482. ReportLink: articleInfo.ReportLink,
  483. ImgUrl: detail.ImgUrl,
  484. NickName: detail.NickName,
  485. }
  486. br.Ret = 200
  487. br.Success = true
  488. br.Msg = "获取成功"
  489. br.Data = resp
  490. }
  491. // @Title 删除纪要
  492. // @Description 删除纪要接口
  493. // @Param request body cygx.SummaryManageIdRep true "type json string"
  494. // @Success Ret=200
  495. // @router /summaryManage/delete [post]
  496. func (this *SummaryManage) Delete() {
  497. br := new(models.BaseResponse).Init()
  498. defer func() {
  499. this.Data["json"] = br
  500. this.ServeJSON()
  501. }()
  502. sysUser := this.SysUser
  503. indexName := utils.IndexName
  504. if sysUser == nil {
  505. br.Msg = "请登录"
  506. br.ErrMsg = "请登录,SysUser Is Empty"
  507. br.Ret = 408
  508. return
  509. }
  510. var req cygx.SummaryManageIdRep
  511. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  512. if err != nil {
  513. br.Msg = "参数解析异常!"
  514. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  515. return
  516. }
  517. articleId := req.ArticleId
  518. if articleId < 1 {
  519. br.Msg = "请输入产业ID"
  520. return
  521. }
  522. articleInfo, errInfo := cygx.GetArticleInfoOtherByArticleId(articleId)
  523. if articleInfo == nil {
  524. br.Msg = "操作失败"
  525. br.ErrMsg = "纪要ID错误"
  526. return
  527. }
  528. if errInfo != nil {
  529. br.Msg = "操作失败"
  530. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  531. return
  532. }
  533. services.EsDeleteData(indexName, strconv.Itoa(articleInfo.ArticleId))
  534. err = cygx.DeleteArticleReport(articleInfo.ArticleId)
  535. if err != nil {
  536. br.Msg = "删除信息失败"
  537. br.ErrMsg = "删除信息失败,Err:" + err.Error()
  538. return
  539. }
  540. //go cygxService.UpdateResourceData(articleInfo.ArticleId, "article", "delete", time.Now().Format(utils.FormatDateTime))
  541. go cygxService.UpdateArticleResourceData(articleInfo.ArticleId) //写入首页最新 cygx_resource_data 表
  542. br.Ret = 200
  543. br.Success = true
  544. br.Msg = "已删除"
  545. br.IsAddLog = true
  546. }
  547. // @Title 纪要列表
  548. // @Description 获取纪要列表接口
  549. // @Param PageSize query int true "每页数据条数"
  550. // @Param CurrentIndex query int true "当前页页码,从1开始"
  551. // @Param PublishStatus query int true "发布状态 ,0未发布,1已发布,传2查询所有"
  552. // @Param CategoryName query string true "行业名称"
  553. // @Param StartDate query string true "开始时间 ,列如2021-03-06 "
  554. // @Param EndDate query string true "结束时间,列如2021-03-06 "
  555. // @Param KeyWord query string true "搜索关键词"
  556. // @Param Label query string true "搜索报告标签"
  557. // @Param NickName query string true "作者昵称"
  558. // @Param Departmentİd query int false "作者İd"
  559. // @Param ArticleTypeId query int false `"文章类型ID"
  560. // @Success 200 {object} cygx.GetSummaryManageListRep
  561. // @router /summaryManage/list [get]
  562. func (this *SummaryManage) SummaryManageList() {
  563. br := new(models.BaseResponse).Init()
  564. defer func() {
  565. this.Data["json"] = br
  566. this.ServeJSON()
  567. }()
  568. sysUser := this.SysUser
  569. if sysUser == nil {
  570. br.Msg = "请登录"
  571. br.ErrMsg = "请登录,SysUser Is Empty"
  572. return
  573. }
  574. pageSize, _ := this.GetInt("PageSize")
  575. currentIndex, _ := this.GetInt("CurrentIndex")
  576. publishStatus, _ := this.GetInt("PublishStatus")
  577. categoryName := this.GetString("CategoryName")
  578. startDate := this.GetString("StartDate")
  579. endDate := this.GetString("EndDate")
  580. keyWord := this.GetString("KeyWord")
  581. label := this.GetString("Label")
  582. nickName := this.GetString("NickName")
  583. departmentİd, _ := this.GetInt("Departmentİd")
  584. articleTypeId, _ := this.GetInt("ArticleTypeId")
  585. resp := new(cygx.GetSummaryManageListRep)
  586. var startSize int
  587. if pageSize <= 0 {
  588. pageSize = utils.PageSize20
  589. }
  590. if currentIndex <= 0 {
  591. currentIndex = 1
  592. }
  593. startSize = utils.StartIndex(currentIndex, pageSize)
  594. var condition string
  595. var pars []interface{}
  596. condition += ` WHERE art.article_type_id >0 `
  597. if articleTypeId > 0 {
  598. condition += ` AND art.article_type_id = ` + strconv.Itoa(articleTypeId)
  599. }
  600. if keyWord != "" {
  601. condition += ` AND (art.title LIKE '%` + keyWord + `%' ) `
  602. }
  603. if nickName != "" {
  604. condition += ` AND (art.seller_and_mobile LIKE '%` + nickName + `%' ) `
  605. }
  606. if departmentİd > 0 {
  607. condition += ` AND art.department_id = ` + strconv.Itoa(departmentİd)
  608. }
  609. //行业名称
  610. if categoryName != "" {
  611. condition += ` AND art.category_name LIKE '%` + categoryName + `%' `
  612. }
  613. if startDate != "" {
  614. condition += ` AND art.publish_date >= ` + "'" + startDate + " 00:00:00'"
  615. }
  616. if endDate != "" {
  617. condition += ` AND art.publish_date <= ` + "'" + endDate + " 23:59:59'"
  618. }
  619. if startDate != "" || endDate != "" {
  620. condition += ` AND art.publish_status =1 `
  621. }
  622. if publishStatus == 0 || publishStatus == 1 {
  623. condition += ` AND art.publish_status = ` + strconv.Itoa(publishStatus)
  624. }
  625. //如果标签列表不为空则作以下关联搜索
  626. if label != "" {
  627. managementIds, err := cygx.GetManagementIdsByNameLike(label)
  628. if err != nil {
  629. br.Msg = "获取信息失败"
  630. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  631. return
  632. }
  633. subjectIds, err := cygx.GetIndustrialSubjectIdsByNameLike(label)
  634. if err != nil {
  635. br.Msg = "获取信息失败"
  636. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  637. return
  638. }
  639. var articleIdmanagement string
  640. var articleIdsubject string
  641. var articleIds string
  642. if managementIds != "" {
  643. articleIdmanagement, err = cygx.GetArticleIdsByIndustrialManagementId(managementIds)
  644. if err != nil {
  645. br.Msg = "获取信息失败"
  646. br.ErrMsg = "获取活动ID信息失败,Err:" + err.Error()
  647. return
  648. }
  649. }
  650. if subjectIds != "" {
  651. articleIdsubject, err = cygx.GetArticleIdsBySubjectId(subjectIds)
  652. if err != nil {
  653. br.Msg = "获取信息失败"
  654. br.ErrMsg = "获取活动ID信息失败,Err:" + err.Error()
  655. return
  656. }
  657. }
  658. if articleIdmanagement != "" && articleIdsubject != "" {
  659. articleIds = articleIdmanagement + "," + articleIdsubject
  660. } else if articleIdmanagement != "" && articleIdsubject == "" {
  661. articleIds = articleIdmanagement
  662. } else if articleIdmanagement == "" && articleIdsubject != "" {
  663. articleIds = articleIdsubject
  664. }
  665. if articleIds != "" {
  666. condition += ` AND art.article_id IN (` + articleIds + `)`
  667. } else {
  668. // 如果标签关联的报告为空,那么就直接返回空
  669. page := paging.GetPaging(currentIndex, pageSize, 0)
  670. resp.List = make([]*cygx.CygxArticleList, 0)
  671. resp.Paging = page
  672. br.Ret = 200
  673. br.Success = true
  674. br.Msg = "获取成功"
  675. br.Data = resp
  676. return
  677. }
  678. }
  679. total, err := cygx.GetASummaryManageCount(condition, pars)
  680. if err != nil {
  681. br.Msg = "获取失败"
  682. br.ErrMsg = "获取失败,Err:" + err.Error()
  683. return
  684. }
  685. condition += ` GROUP BY art.article_id `
  686. condition += ` ORDER BY art.top_time DESC , art.publish_date DESC `
  687. list, errList := cygx.GetSummaryManageList(condition, pars, startSize, pageSize)
  688. if errList != nil {
  689. br.Msg = "获取失败"
  690. br.ErrMsg = "获取失败,Err:" + errList.Error()
  691. return
  692. }
  693. var articleIdStr string
  694. for _, v := range list {
  695. articleIdStr += strconv.Itoa(v.ArticleId) + ","
  696. }
  697. articleIdStr = strings.TrimRight(articleIdStr, ",")
  698. // 查研观向7.4-报告关联多个产业
  699. mapIndustrial := make(map[int]string)
  700. mapSubject := make(map[string]string)
  701. if articleIdStr != "" {
  702. industrialList, err := cygx.GetIndustrialArticleGroupListByarticleIds(articleIdStr)
  703. if err != nil {
  704. br.Msg = "获取失败"
  705. br.ErrMsg = "获取失败,GetIndustrialArticleGroupListByarticleIds Err:" + err.Error()
  706. return
  707. }
  708. subjectList, err := cygx.GetSubjectArticleGroupListByarticleIds(articleIdStr)
  709. if err != nil {
  710. br.Msg = "获取失败"
  711. br.ErrMsg = "获取失败,GetSubjectArticleGroupListByarticleIds Err:" + err.Error()
  712. return
  713. }
  714. //合并活动对应的多个标的
  715. for _, v := range subjectList {
  716. mapSubject[fmt.Sprint(v.ArticleId, "_", v.IndustrialManagementId)] += v.SubjectName + "/"
  717. }
  718. //活动对应的产业
  719. for _, v := range industrialList {
  720. var labelSubject string
  721. labelSubject = mapSubject[fmt.Sprint(v.ArticleId, "_", v.IndustrialManagementId)]
  722. if labelSubject != "" {
  723. mapIndustrial[v.ArticleId] += v.IndustryName + "--" + strings.TrimRight(labelSubject, "/") + ","
  724. } else {
  725. mapIndustrial[v.ArticleId] += v.IndustryName + ","
  726. }
  727. }
  728. }
  729. for k, v := range list {
  730. if v.PublishStatus == 0 {
  731. list[k].PublishDate = ""
  732. } else {
  733. list[k].PublishDate = utils.TimeRemoveHms2(v.PublishDate)
  734. }
  735. if mapIndustrial[v.ArticleId] != "" {
  736. list[k].IndustryName = strings.TrimRight(mapIndustrial[v.ArticleId], ",")
  737. }
  738. }
  739. page := paging.GetPaging(currentIndex, pageSize, total)
  740. resp.List = list
  741. resp.Paging = page
  742. br.Ret = 200
  743. br.Success = true
  744. br.Msg = "获取成功"
  745. br.Data = resp
  746. }
  747. // @Title 敏捷搜索关键词的列表
  748. // @Description 获取敏捷搜索关键词的列表接口
  749. // @Success 200 {object} cygx.SummaryFastsearchKeywordsListResp
  750. // @router /summaryManage/fastSearchKeWord [get]
  751. func (this *SummaryManage) FastSearch() {
  752. br := new(models.BaseResponse).Init()
  753. defer func() {
  754. this.Data["json"] = br
  755. this.ServeJSON()
  756. }()
  757. AdminUser := this.SysUser
  758. if AdminUser == nil {
  759. br.Msg = "请登录"
  760. br.ErrMsg = "请登录,用户信息为空"
  761. br.Ret = 408
  762. return
  763. }
  764. resp := new(cygx.SummaryFastsearchKeywordsListResp)
  765. list, err := cygx.GetSummaryFastsearchKeywordsList()
  766. if err != nil {
  767. br.Msg = "获取失败"
  768. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  769. return
  770. }
  771. resp.List = list
  772. br.Ret = 200
  773. br.Success = true
  774. br.Msg = "获取成功"
  775. br.Data = resp
  776. }
  777. // @Title 新增和修改敏捷搜索关键词的列表
  778. // @Description 新增和修改敏捷搜索关键词的列表接口
  779. // @Param request body cygx.SummaryFastsearchKeywordsResp true "type json string"
  780. // @Success Ret=200
  781. // @router /summaryManage/editFastSearchKeWord [post]
  782. func (this *SummaryManage) EditFastSearch() {
  783. br := new(models.BaseResponse).Init()
  784. defer func() {
  785. this.Data["json"] = br
  786. this.ServeJSON()
  787. }()
  788. AdminUser := this.SysUser
  789. if AdminUser == nil {
  790. br.Msg = "请登录"
  791. br.ErrMsg = "请登录,用户信息为空"
  792. br.Ret = 408
  793. return
  794. }
  795. req := new(cygx.SummaryFastsearchKeywordsResp)
  796. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  797. if err != nil {
  798. br.Msg = "参数解析异常!"
  799. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  800. return
  801. }
  802. keyWord := req.KeyWord
  803. slicekeyWord := strings.Split(keyWord, ",")
  804. var items []*cygx.CygxSummaryFastsearchKeywords
  805. for _, v := range slicekeyWord {
  806. var item = new(cygx.CygxSummaryFastsearchKeywords)
  807. item.CreateTime = time.Now()
  808. item.KeyWord = v
  809. items = append(items, item)
  810. fmt.Println(v)
  811. }
  812. _, err = cygx.AddSummaryFastsearchKeywords(items)
  813. if err != nil {
  814. br.Msg = "操作失败"
  815. br.ErrMsg = "操作失败,Err:" + err.Error()
  816. return
  817. }
  818. br.Ret = 200
  819. br.Success = true
  820. br.Msg = "操作成功"
  821. }
  822. // @Title 永续客户是否展示
  823. // @Description 获取永续客户是否展示详情接口
  824. // @Success 200 {object} cygx.SummaryFastsearchKeywordsListResp
  825. // @router /summaryManage/sustainableDetail [get]
  826. func (this *SummaryManage) Sustainable() {
  827. br := new(models.BaseResponse).Init()
  828. defer func() {
  829. this.Data["json"] = br
  830. this.ServeJSON()
  831. }()
  832. AdminUser := this.SysUser
  833. if AdminUser == nil {
  834. br.Msg = "请登录"
  835. br.ErrMsg = "请登录,用户信息为空"
  836. br.Ret = 408
  837. return
  838. }
  839. detail, err := cygx.GetCygxConfigDetail()
  840. if err != nil {
  841. br.Msg = "获取失败"
  842. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  843. return
  844. }
  845. if detail.ConfigValue == "1" {
  846. detail.OperationButton = true
  847. }
  848. br.Ret = 200
  849. br.Success = true
  850. br.Msg = "获取成功"
  851. br.Data = detail
  852. }
  853. // @Title 修改永续客户是否展示
  854. // @Description 修改永续客户是否展示接口
  855. // @Success Ret=200
  856. // @router /summaryManage/sustainableEdit [post]
  857. func (this *SummaryManage) EditSustainable() {
  858. br := new(models.BaseResponse).Init()
  859. defer func() {
  860. this.Data["json"] = br
  861. this.ServeJSON()
  862. }()
  863. AdminUser := this.SysUser
  864. if AdminUser == nil {
  865. br.Msg = "请登录"
  866. br.ErrMsg = "请登录,SysUser Is Empty"
  867. br.Ret = 408
  868. return
  869. }
  870. var newValue int
  871. detail, err := cygx.GetCygxConfigDetail()
  872. if err != nil {
  873. br.Msg = "获取失败"
  874. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  875. return
  876. }
  877. if detail.ConfigValue == "1" {
  878. newValue = 0
  879. } else {
  880. newValue = 1
  881. }
  882. err = cygx.CygxConfigUpdate(newValue)
  883. if err != nil {
  884. br.Msg = "操作失败"
  885. br.ErrMsg = "操作失败,Err:" + err.Error()
  886. return
  887. }
  888. br.Ret = 200
  889. br.Success = true
  890. br.Msg = "操作成功"
  891. }
  892. // @Title 提问列表详情
  893. // @Description 获取提问列表详情接口
  894. // @Param ArticleId query int true "文章ID"
  895. // @Success 200 {object} cygx.ActivityHelpAskListResp
  896. // @router /summaryManage/askList [get]
  897. func (this *SummaryManage) AskList() {
  898. br := new(models.BaseResponse).Init()
  899. defer func() {
  900. this.Data["json"] = br
  901. this.ServeJSON()
  902. }()
  903. sysUser := this.SysUser
  904. if sysUser == nil {
  905. br.Msg = "请登录"
  906. br.ErrMsg = "请登录,SysUser Is Empty"
  907. return
  908. }
  909. articleId, _ := this.GetInt("ArticleId")
  910. articleInfo, _ := cygx.GetArticleIdInfoByArticleId(articleId)
  911. if articleInfo == nil {
  912. br.Msg = "操作失败"
  913. br.ErrMsg = "报告ID错误"
  914. return
  915. }
  916. list, err := cygx.GetArticleAskList(articleInfo.ArticleId)
  917. resp := new(cygx.ArticleAskListResp)
  918. if err != nil {
  919. br.Msg = "获取失败"
  920. br.ErrMsg = "获取失败,Err:" + err.Error()
  921. return
  922. }
  923. resp.List = list
  924. br.Ret = 200
  925. br.Success = true
  926. br.Msg = "获取成功"
  927. br.Data = resp
  928. }
  929. // @Title 提问详情excel表格下载
  930. // @Description 提问详情excel表格下载接口
  931. // @Param SummaryManageId query int true "纪要ID"
  932. // @Success 200 导出成功
  933. // @router /summaryManage/askListExport [get]
  934. func (this *SummaryManage) AskListExport() {
  935. br := new(models.BaseResponse).Init()
  936. defer func() {
  937. this.Data["json"] = br
  938. this.ServeJSON()
  939. }()
  940. sysUser := this.SysUser
  941. if sysUser == nil {
  942. br.Msg = "请登录"
  943. br.ErrMsg = "请登录,SysUser Is Empty"
  944. return
  945. }
  946. articleId, _ := this.GetInt("ArticleId")
  947. articleInfo, _ := cygx.GetArticleIdInfoByArticleId(articleId)
  948. if articleInfo == nil {
  949. br.Msg = "操作失败"
  950. br.ErrMsg = "报告ID错误"
  951. return
  952. }
  953. list, err := cygx.GetArticleAskList(articleInfo.ArticleId)
  954. if err != nil {
  955. br.Msg = "获取失败"
  956. br.ErrMsg = "获取失败,Err:" + err.Error()
  957. return
  958. }
  959. //创建excel
  960. dir, err := os.Executable()
  961. exPath := filepath.Dir(dir)
  962. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  963. xlsxFile := xlsx.NewFile()
  964. if err != nil {
  965. br.Msg = "生成文件失败"
  966. br.ErrMsg = "生成文件失败"
  967. return
  968. }
  969. style := xlsx.NewStyle()
  970. alignment := xlsx.Alignment{
  971. Horizontal: "center",
  972. Vertical: "center",
  973. WrapText: true,
  974. }
  975. style.Alignment = alignment
  976. style.ApplyAlignment = true
  977. sheet, err := xlsxFile.AddSheet("名单")
  978. if err != nil {
  979. br.Msg = "新增Sheet失败"
  980. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  981. return
  982. }
  983. //标头
  984. rowTitle := sheet.AddRow()
  985. cellA := rowTitle.AddCell()
  986. cellA.Value = "姓名"
  987. cellB := rowTitle.AddCell()
  988. cellB.Value = "公司名称"
  989. cellC := rowTitle.AddCell()
  990. cellC.Value = "问题"
  991. cellD := rowTitle.AddCell()
  992. cellD.Value = "提交时间"
  993. for _, item := range list {
  994. row := sheet.AddRow()
  995. cellA := row.AddCell()
  996. cellA.Value = item.RealName
  997. cellB := row.AddCell()
  998. cellB.Value = item.CompanyName
  999. cellC := row.AddCell()
  1000. cellC.Value = item.Content
  1001. cellD := row.AddCell()
  1002. cellD.Value = item.CreateTime
  1003. }
  1004. err = xlsxFile.Save(downLoadnFilePath)
  1005. if err != nil {
  1006. br.Msg = "保存文件失败"
  1007. br.ErrMsg = "保存文件失败"
  1008. return
  1009. }
  1010. randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  1011. downloadFileName := "问题列表" + randStr + ".xlsx"
  1012. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  1013. defer func() {
  1014. os.Remove(downLoadnFilePath)
  1015. }()
  1016. br.Success = true
  1017. br.Ret = 200
  1018. br.Msg = "导出成功"
  1019. }
  1020. // @Title 作者关注详情
  1021. // @Description 获取作者关注详情列表接口
  1022. // @Param DepartmentId query int true "作者ID"
  1023. // @Success 200 {object} cygx.GetFailSignupListRep
  1024. // @router /summaryManage/department/followList [get]
  1025. func (this *SummaryManage) FepartmentfollowList() {
  1026. br := new(models.BaseResponse).Init()
  1027. defer func() {
  1028. this.Data["json"] = br
  1029. this.ServeJSON()
  1030. }()
  1031. sysUser := this.SysUser
  1032. if sysUser == nil {
  1033. br.Msg = "请登录"
  1034. br.ErrMsg = "请登录,SysUser Is Empty"
  1035. return
  1036. }
  1037. departmentId, _ := this.GetInt("DepartmentId")
  1038. detail, _ := cygx.GetArticleDepartmentDateilById(departmentId)
  1039. if detail == nil {
  1040. br.Msg = "作者不存在"
  1041. br.ErrMsg = "获取信息失败,Err:DepartmentId:" + strconv.Itoa(departmentId)
  1042. return
  1043. }
  1044. list, err := cygx.GetCygxDepartmentFllowList(departmentId)
  1045. resp := new(cygx.CygxDepartmentFllowRep)
  1046. if err != nil {
  1047. br.Msg = "获取失败"
  1048. br.ErrMsg = "获取列表失败,Err:" + err.Error()
  1049. return
  1050. }
  1051. resp.NickName = detail.Content
  1052. resp.FllowNum = len(list)
  1053. resp.List = list
  1054. br.Ret = 200
  1055. br.Success = true
  1056. br.Msg = "获取成功"
  1057. br.Data = resp
  1058. }
  1059. // @Title 文章收藏详情
  1060. // @Description 获取文章收藏详情列表接口
  1061. // @Param ArticleId query int true "文章ID"
  1062. // @Success 200 {object} cygx.GetFailSignupListRep
  1063. // @router /summaryManage/articleCollection [get]
  1064. func (this *SummaryManage) ArticleCollection() {
  1065. br := new(models.BaseResponse).Init()
  1066. defer func() {
  1067. this.Data["json"] = br
  1068. this.ServeJSON()
  1069. }()
  1070. sysUser := this.SysUser
  1071. if sysUser == nil {
  1072. br.Msg = "请登录"
  1073. br.ErrMsg = "请登录,SysUser Is Empty"
  1074. return
  1075. }
  1076. articleId, _ := this.GetInt("ArticleId")
  1077. _, err := cygx.GetArticleIdInfoByArticleId(articleId)
  1078. if err != nil {
  1079. br.Msg = "报告不存在"
  1080. br.ErrMsg = "查询失败,Err:" + err.Error() + strconv.Itoa(articleId)
  1081. return
  1082. }
  1083. list, err := cygx.GetCygxArticleCollectionList(articleId)
  1084. if err != nil {
  1085. br.Msg = "获取失败"
  1086. br.ErrMsg = "获取列表失败,Err:" + err.Error()
  1087. return
  1088. }
  1089. //获取对应销售名称
  1090. if len(list) > 0 {
  1091. var companyIds []int
  1092. for _, v := range list {
  1093. companyIds = append(companyIds, v.CompanyId)
  1094. }
  1095. listCompanyProduct, err := company.GetCompanyProductListByCompanyIds(companyIds, 2)
  1096. if err != nil {
  1097. br.Msg = "获取失败"
  1098. br.ErrMsg = "获取销售列表失败,Err:" + err.Error()
  1099. return
  1100. }
  1101. mapSellName := make(map[int]string)
  1102. for _, v := range listCompanyProduct {
  1103. mapSellName[v.CompanyId] = v.SellerName
  1104. }
  1105. for _, v := range list {
  1106. v.SellerName = mapSellName[v.CompanyId]
  1107. }
  1108. }
  1109. br.Ret = 200
  1110. br.Success = true
  1111. br.Msg = "获取成功"
  1112. br.Data = list
  1113. }
  1114. // @Title 阅读明细下载
  1115. // @Description 获取阅读明细下载接口
  1116. // @Param ArticleId query int true "文章ID"
  1117. // @Success 200 导出成功
  1118. // @router /summaryManage/articleHistoryExport [get]
  1119. func (this *SummaryManage) ArticleHistoryExport() {
  1120. br := new(models.BaseResponse).Init()
  1121. defer func() {
  1122. this.Data["json"] = br
  1123. this.ServeJSON()
  1124. }()
  1125. AdminUser := this.SysUser
  1126. if AdminUser == nil {
  1127. br.Msg = "请登录"
  1128. br.ErrMsg = "请登录,SysUser Is Empty"
  1129. return
  1130. }
  1131. articleId, _ := this.GetInt("ArticleId")
  1132. articleInfo, err := cygx.GetArticleIdInfoByArticleId(articleId)
  1133. if err != nil {
  1134. br.Msg = "报告不存在"
  1135. br.ErrMsg = "查询失败,Err:" + err.Error() + strconv.Itoa(articleId)
  1136. return
  1137. }
  1138. resp := new(cygx.CanDownload)
  1139. adminInfo, errAdmin := system.GetSysUserById(AdminUser.AdminId)
  1140. if errAdmin != nil {
  1141. br.Msg = "获取失败"
  1142. br.ErrMsg = "获取失败,Err:" + errAdmin.Error()
  1143. return
  1144. }
  1145. if adminInfo.Role == "admin" || adminInfo.Role == "researcher" || adminInfo.RealName == "汪洋" {
  1146. resp.IsCanDownload = true
  1147. }
  1148. var condition string
  1149. if resp.IsCanDownload == false {
  1150. //权益申请销售只能看到自己名下的客户的申请
  1151. companyIds, err := cygxService.GetAdminLookUserCompanyIds(AdminUser)
  1152. if err != nil {
  1153. br.Msg = "获取失败"
  1154. br.ErrMsg = "获取失败,GetAdminLookUserCompanyIds Err:" + err.Error()
  1155. return
  1156. }
  1157. var companyIdstr []string
  1158. for _, v := range companyIds {
  1159. companyIdstr = append(companyIdstr, strconv.Itoa(v))
  1160. }
  1161. condition = ` AND h.company_id IN (` + strings.Join(companyIdstr, ",") + `) `
  1162. }
  1163. mapMobileSellWithUser := make(map[string]string)
  1164. if condition != "" {
  1165. mobileList, err := cygx.GetSellerUserMobileList(condition)
  1166. if err != nil && err.Error() != utils.ErrNoRow() {
  1167. br.Msg = "获取失败"
  1168. br.ErrMsg = "获取策略品台数据失败,Err:" + err.Error()
  1169. return
  1170. }
  1171. if len(mobileList) > 0 {
  1172. for _, v := range mobileList {
  1173. mapMobileSellWithUser[v.Mobile] = v.Mobile
  1174. }
  1175. }
  1176. }
  1177. condition += ` AND h.company_id != ` + strconv.Itoa(utils.HZ_COMPANY_ID) // 过滤弘则
  1178. list, err := cygx.GetArticleHistoryList(articleId, condition)
  1179. if err != nil {
  1180. br.Msg = "获取失败"
  1181. br.ErrMsg = "获取失败,Err:" + err.Error()
  1182. return
  1183. }
  1184. listClPv, err := cygx.GetCygxCelueArticleHistoryRecordPvAll(strconv.Itoa(articleId))
  1185. if err != nil && err.Error() != utils.ErrNoRow() {
  1186. br.Msg = "获取失败"
  1187. br.ErrMsg = "获取策略品台数据失败,Err:" + err.Error()
  1188. return
  1189. }
  1190. var mobilesCl string
  1191. if len(listClPv) > 0 {
  1192. for _, v := range listClPv {
  1193. if v.Mobile != "" {
  1194. mobilesCl += v.Mobile + ","
  1195. }
  1196. }
  1197. }
  1198. mapMobileCompany := make(map[string]string)
  1199. mapMobileSellName := make(map[string]string)
  1200. mobilesCl = strings.TrimRight(mobilesCl, ",")
  1201. if mobilesCl != "" {
  1202. listClCompanyName, err := cygx.GetCygxCelueArticleComapnyName(mobilesCl)
  1203. if err != nil && err.Error() != utils.ErrNoRow() {
  1204. br.Msg = "获取失败"
  1205. br.ErrMsg = "获取策略品台关联查研观向的用户信息失败,Err:" + err.Error()
  1206. return
  1207. }
  1208. if len(listClCompanyName) > 0 {
  1209. for _, v := range listClCompanyName {
  1210. mapMobileCompany[v.Mobile] = v.CompanyName
  1211. mapMobileSellName[v.Mobile] = v.RealName
  1212. }
  1213. }
  1214. }
  1215. for k, v := range listClPv {
  1216. if v.Mobile != "" {
  1217. if mapMobileCompany[v.Mobile] != "" {
  1218. listClPv[k].CompanyName = mapMobileCompany[v.Mobile]
  1219. }
  1220. if mapMobileSellName[v.Mobile] != "" {
  1221. listClPv[k].SellerName = mapMobileSellName[v.Mobile]
  1222. }
  1223. }
  1224. }
  1225. var listClPvPower []*cygx.ArticleHistoryRep
  1226. if len(mapMobileSellWithUser) != 0 {
  1227. for _, v := range listClPv {
  1228. if mapMobileSellWithUser[v.Mobile] != "" {
  1229. listClPvPower = append(listClPvPower, v)
  1230. }
  1231. }
  1232. } else {
  1233. listClPvPower = listClPv
  1234. }
  1235. //创建excel
  1236. dir, err := os.Executable()
  1237. exPath := filepath.Dir(dir)
  1238. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  1239. xlsxFile := xlsx.NewFile()
  1240. if err != nil {
  1241. br.Msg = "生成文件失败"
  1242. br.ErrMsg = "生成文件失败"
  1243. return
  1244. }
  1245. style := xlsx.NewStyle()
  1246. alignment := xlsx.Alignment{
  1247. Horizontal: "center",
  1248. Vertical: "center",
  1249. WrapText: true,
  1250. }
  1251. style.Alignment = alignment
  1252. style.ApplyAlignment = true
  1253. for pidIndex := 0; pidIndex <= 1; pidIndex++ {
  1254. var sheetName string
  1255. var listDate []*cygx.ArticleHistoryRep
  1256. if pidIndex == 0 {
  1257. sheetName = "查研观向"
  1258. listDate = list
  1259. } else {
  1260. sheetName = "策略平台"
  1261. listDate = listClPvPower
  1262. }
  1263. sheet, err := xlsxFile.AddSheet(sheetName)
  1264. if err != nil {
  1265. br.Msg = "新增Sheet失败"
  1266. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  1267. return
  1268. }
  1269. //标头
  1270. rowTitle := sheet.AddRow()
  1271. cellA := rowTitle.AddCell()
  1272. cellA.Value = "姓名"
  1273. cellB := rowTitle.AddCell()
  1274. cellB.Value = "手机号"
  1275. cellC := rowTitle.AddCell()
  1276. cellC.Value = "公司名称"
  1277. cellD := rowTitle.AddCell()
  1278. cellD.Value = "所属权益销售"
  1279. cellE := rowTitle.AddCell()
  1280. cellE.Value = "阅读时长(秒)"
  1281. cellF := rowTitle.AddCell()
  1282. cellF.Value = "阅读时间"
  1283. for _, item := range listDate {
  1284. row := sheet.AddRow()
  1285. cellA := row.AddCell()
  1286. cellA.Value = item.RealName
  1287. cellB := row.AddCell()
  1288. cellB.Value = item.Mobile
  1289. cellC := row.AddCell()
  1290. cellC.Value = item.CompanyName
  1291. cellD := row.AddCell()
  1292. cellD.Value = item.SellerName
  1293. cellE := row.AddCell()
  1294. cellE.Value = item.StopTime
  1295. cellF := row.AddCell()
  1296. cellF.Value = item.CreateTime
  1297. }
  1298. }
  1299. err = xlsxFile.Save(downLoadnFilePath)
  1300. if err != nil {
  1301. br.Msg = "保存文件失败"
  1302. br.ErrMsg = "保存文件失败"
  1303. return
  1304. }
  1305. //randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  1306. downloadFileName := articleInfo.Title + ".xlsx"
  1307. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  1308. defer func() {
  1309. os.Remove(downLoadnFilePath)
  1310. }()
  1311. br.Success = true
  1312. br.Ret = 200
  1313. br.Msg = "导出成功"
  1314. }
  1315. // @Title 文章类型列表
  1316. // @Description 文章类型列表接口
  1317. // @Success 200 {object} cygx.ArticleTypeListResp
  1318. // @router /summaryManage/articleType/list [get]
  1319. func (this *ActivityTypeCoAntroller) ArticleTypeList() {
  1320. br := new(models.BaseResponse).Init()
  1321. defer func() {
  1322. this.Data["json"] = br
  1323. this.ServeJSON()
  1324. }()
  1325. sysUser := this.SysUser
  1326. if sysUser == nil {
  1327. br.Msg = "请登录"
  1328. br.ErrMsg = "请登录,SysUser Is Empty"
  1329. br.Ret = 408
  1330. return
  1331. }
  1332. resp := new(cygx.ArticleTypeListResp)
  1333. list, err := cygx.GetCygxArticleTypeList()
  1334. if err != nil {
  1335. br.Msg = "获取失败"
  1336. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1337. return
  1338. }
  1339. typelist, err := cygx.GetArticleTypeAndAbstract()
  1340. if err != nil {
  1341. br.Msg = "获取失败"
  1342. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1343. return
  1344. }
  1345. resp.AbstractList = typelist
  1346. resp.List = list
  1347. br.Ret = 200
  1348. br.Success = true
  1349. br.Msg = "获取成功"
  1350. br.Data = resp
  1351. }
  1352. // @Title 新增文章类型
  1353. // @Description 新增文章类型接口
  1354. // @Param request body cygx.CygxArticleReq true "type json string"
  1355. // @Success Ret=200
  1356. // @router /summaryManage/articleType/add [post]
  1357. func (this *SummaryManage) ArticleTypeListAdd() {
  1358. br := new(models.BaseResponse).Init()
  1359. defer func() {
  1360. this.Data["json"] = br
  1361. this.ServeJSON()
  1362. }()
  1363. AdminUser := this.SysUser
  1364. if AdminUser == nil {
  1365. br.Msg = "请登录"
  1366. br.ErrMsg = "请登录,用户信息为空"
  1367. br.Ret = 408
  1368. return
  1369. }
  1370. req := new(cygx.CygxArticleReq)
  1371. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1372. if err != nil {
  1373. br.Msg = "参数解析异常!"
  1374. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1375. return
  1376. }
  1377. name := req.ArticleTypeName
  1378. if name == "" {
  1379. br.Msg = "内容不能为空!"
  1380. return
  1381. }
  1382. var condition string
  1383. condition = ` AND article_type_name = '` + name + `'`
  1384. count, err := cygx.GetCygxArticleTypeCount(condition)
  1385. if err != nil {
  1386. br.Msg = "操作失败!"
  1387. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  1388. return
  1389. }
  1390. if count > 0 {
  1391. br.Msg = "该类型已存在,请重新填写!"
  1392. return
  1393. }
  1394. count, err = cygx.GetCygxArticleTypeCount("")
  1395. if err != nil {
  1396. br.Msg = "操作失败!"
  1397. br.ErrMsg = "获取已添加的数量失败,Err:" + err.Error()
  1398. return
  1399. }
  1400. item := new(cygx.CygxArticleType)
  1401. item.ArticleTypeName = name
  1402. item.YanxPermissionName = utils.CHART_PERMISSION_NAME_MF_YANXUAN + name
  1403. item.IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1404. item.IcoLinkM = "https://hzstatic.hzinsights.com/static/temp/20220707202207/20220707/FEvPxfalkGKllLIlBMKumm47zhEx.png"
  1405. item.YanxPermissionId = 1001 + count // id 数量从一千开始计算
  1406. item.CreateTime = time.Now()
  1407. item.ModifyTime = time.Now()
  1408. _, err = cygx.AddCygxArticleType(item)
  1409. if err != nil {
  1410. br.Msg = "操作失败"
  1411. br.ErrMsg = "操作失败,Err:" + err.Error()
  1412. return
  1413. }
  1414. br.Ret = 200
  1415. br.Success = true
  1416. br.Msg = "操作成功"
  1417. br.IsAddLog = true
  1418. }
  1419. // @Title 留言列表详情
  1420. // @Description 获取留言列表详情接口
  1421. // @Param ArticleId query int true "文章ID"
  1422. // @Success 200 {object} cygx.ArticleCommentListResp
  1423. // @router /summaryManage/commentList [get]
  1424. func (this *SummaryManage) CommentList() {
  1425. br := new(models.BaseResponse).Init()
  1426. defer func() {
  1427. this.Data["json"] = br
  1428. this.ServeJSON()
  1429. }()
  1430. sysUser := this.SysUser
  1431. if sysUser == nil {
  1432. br.Msg = "请登录"
  1433. br.ErrMsg = "请登录,SysUser Is Empty"
  1434. return
  1435. }
  1436. articleId, _ := this.GetInt("ArticleId")
  1437. articleInfo, _ := cygx.GetArticleIdInfoByArticleId(articleId)
  1438. if articleInfo == nil {
  1439. br.Msg = "操作失败"
  1440. br.ErrMsg = "报告ID错误"
  1441. return
  1442. }
  1443. list, err := cygx.GetArticleCommentList(articleInfo.ArticleId)
  1444. resp := new(cygx.ArticleCommentListResp)
  1445. if err != nil {
  1446. br.Msg = "获取留言失败"
  1447. br.ErrMsg = "获取留言失败,Err:" + err.Error()
  1448. return
  1449. }
  1450. resp.List = list
  1451. br.Ret = 200
  1452. br.Success = true
  1453. br.Msg = "获取成功"
  1454. br.Data = resp
  1455. }
  1456. // @Title 提问详情excel表格下载
  1457. // @Description 提问详情excel表格下载接口
  1458. // @Param SummaryManageId query int true "纪要ID"
  1459. // @Success 200 导出成功
  1460. // @router /summaryManage/commentListExport [get]
  1461. func (this *SummaryManage) CommentListExport() {
  1462. br := new(models.BaseResponse).Init()
  1463. defer func() {
  1464. this.Data["json"] = br
  1465. this.ServeJSON()
  1466. }()
  1467. sysUser := this.SysUser
  1468. if sysUser == nil {
  1469. br.Msg = "请登录"
  1470. br.ErrMsg = "请登录,SysUser Is Empty"
  1471. return
  1472. }
  1473. articleId, _ := this.GetInt("ArticleId")
  1474. articleInfo, _ := cygx.GetArticleIdInfoByArticleId(articleId)
  1475. if articleInfo == nil {
  1476. br.Msg = "操作失败"
  1477. br.ErrMsg = "报告ID错误"
  1478. return
  1479. }
  1480. list, err := cygx.GetArticleCommentList(articleInfo.ArticleId)
  1481. if err != nil {
  1482. br.Msg = "获取失败"
  1483. br.ErrMsg = "获取失败,Err:" + err.Error()
  1484. return
  1485. }
  1486. //创建excel
  1487. dir, err := os.Executable()
  1488. exPath := filepath.Dir(dir)
  1489. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  1490. xlsxFile := xlsx.NewFile()
  1491. if err != nil {
  1492. br.Msg = "生成文件失败"
  1493. br.ErrMsg = "生成文件失败"
  1494. return
  1495. }
  1496. style := xlsx.NewStyle()
  1497. alignment := xlsx.Alignment{
  1498. Horizontal: "center",
  1499. Vertical: "center",
  1500. WrapText: true,
  1501. }
  1502. style.Alignment = alignment
  1503. style.ApplyAlignment = true
  1504. sheet, err := xlsxFile.AddSheet("名单")
  1505. if err != nil {
  1506. br.Msg = "新增Sheet失败"
  1507. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  1508. return
  1509. }
  1510. //标头
  1511. rowTitle := sheet.AddRow()
  1512. cellA := rowTitle.AddCell()
  1513. cellA.Value = "姓名"
  1514. cellB := rowTitle.AddCell()
  1515. cellB.Value = "公司名称"
  1516. cellC := rowTitle.AddCell()
  1517. cellC.Value = "留言"
  1518. cellD := rowTitle.AddCell()
  1519. cellD.Value = "提交时间"
  1520. for _, item := range list {
  1521. row := sheet.AddRow()
  1522. cellA := row.AddCell()
  1523. cellA.Value = item.RealName
  1524. cellB := row.AddCell()
  1525. cellB.Value = item.CompanyName
  1526. cellC := row.AddCell()
  1527. cellC.Value = item.Content
  1528. cellD := row.AddCell()
  1529. cellD.Value = item.CreateTime
  1530. }
  1531. err = xlsxFile.Save(downLoadnFilePath)
  1532. if err != nil {
  1533. br.Msg = "保存文件失败"
  1534. br.ErrMsg = "保存文件失败"
  1535. return
  1536. }
  1537. randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  1538. downloadFileName := "留言列表" + randStr + ".xlsx"
  1539. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  1540. defer func() {
  1541. os.Remove(downLoadnFilePath)
  1542. }()
  1543. br.Success = true
  1544. br.Ret = 200
  1545. br.Msg = "导出成功"
  1546. }
  1547. // @Title 文章的见范围修改
  1548. // @Description 文章的见范围修改接口
  1549. // @Param request body cygx.SummaryManageIdRep true "type json string"
  1550. // @Success 200 操作成功
  1551. // @router /summaryManage/visibleRange [post]
  1552. func (this *SummaryManage) VisibleRange() {
  1553. br := new(models.BaseResponse).Init()
  1554. defer func() {
  1555. this.Data["json"] = br
  1556. this.ServeJSON()
  1557. }()
  1558. AdminUser := this.SysUser
  1559. indexName := utils.IndexName
  1560. if AdminUser == nil {
  1561. br.Msg = "请登录"
  1562. br.ErrMsg = "请登录,用户信息为空"
  1563. br.Ret = 408
  1564. return
  1565. }
  1566. var req cygx.SummaryManageIdRep
  1567. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1568. if err != nil {
  1569. br.Msg = "参数解析异常!"
  1570. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1571. return
  1572. }
  1573. articleId := req.ArticleId
  1574. item := new(cygx.CygxArticle)
  1575. articleInfo, errInfo := cygx.GetArticleInfoOtherByArticleId(articleId)
  1576. if articleInfo == nil {
  1577. br.Msg = "操作失败"
  1578. br.ErrMsg = "纪要ID错误"
  1579. return
  1580. }
  1581. if errInfo != nil {
  1582. br.Msg = "操作失败"
  1583. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1584. return
  1585. }
  1586. item.ArticleId = articleId
  1587. item.Title = articleInfo.Title
  1588. item.BodyText = articleInfo.BodyText
  1589. item.Body = articleInfo.Body
  1590. item.PublishDate = articleInfo.PublishDate
  1591. item.ExpertBackground = articleInfo.ExpertBackground
  1592. item.CategoryId = articleInfo.CategoryId
  1593. if articleInfo.VisibleRange == 0 {
  1594. item.VisibleRange = 1
  1595. item.AdminId = AdminUser.AdminId
  1596. item.AdminName = AdminUser.RealName
  1597. services.EsAddOrEditData(item)
  1598. //go cygxService.UpdateResourceData(item.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime))
  1599. } else {
  1600. item.AdminId = articleInfo.AdminId
  1601. item.AdminName = articleInfo.AdminName
  1602. item.PublishStatus = 0
  1603. services.EsDeleteData(indexName, strconv.Itoa(articleInfo.ArticleId))
  1604. //go cygxService.UpdateResourceData(item.ArticleId, "article", "delete", time.Now().Format(utils.FormatDateTime))
  1605. }
  1606. err = cygx.ArticleVisibleRange(item)
  1607. if err != nil {
  1608. br.Msg = "操作失败"
  1609. br.ErrMsg = "操作失败,Err:" + err.Error()
  1610. return
  1611. }
  1612. //专项调研类型的报告单独走发送
  1613. if articleInfo.SubCategoryName == "专项调研" {
  1614. if item.PublishStatus == 1 {
  1615. cygxService.SendWxMsgWithCygxActivitySpecialArticle(item.ArticleId)
  1616. }
  1617. } else {
  1618. if item.PublishStatus == 1 {
  1619. articleIndustrial, _ := cygx.GetIndustrialManagemenDetailByAaticle(articleInfo.ArticleId)
  1620. if articleIndustrial.ArticleId > 0 {
  1621. go cygxService.DoArticleOnenIdWxTemplateMsg(articleId, 1)
  1622. }
  1623. }
  1624. }
  1625. go cygxService.UpdateArticleResourceData(item.ArticleId) //写入首页最新 cygx_resource_data 表
  1626. br.Ret = 200
  1627. br.Success = true
  1628. br.Msg = "操作成功"
  1629. br.IsAddLog = true
  1630. }
  1631. // @Title 文章的置顶与取消置顶
  1632. // @Description 活动的发布与取消发布接口
  1633. // @Param request body cygx.ActivityIdRep true "type json string"
  1634. // @Success 200 操作成功
  1635. // @router /summaryManage/top_change [post]
  1636. func (this *SummaryManage) TopeChange() {
  1637. br := new(models.BaseResponse).Init()
  1638. defer func() {
  1639. this.Data["json"] = br
  1640. this.ServeJSON()
  1641. }()
  1642. AdminUser := this.SysUser
  1643. if AdminUser == nil {
  1644. br.Msg = "请登录"
  1645. br.ErrMsg = "请登录,用户信息为空"
  1646. br.Ret = 408
  1647. return
  1648. }
  1649. var req cygx.SummaryManageIdRep
  1650. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1651. if err != nil {
  1652. br.Msg = "参数解析异常!"
  1653. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1654. return
  1655. }
  1656. articleId := req.ArticleId
  1657. articleInfo, errInfo := cygx.GetArticleInfoOtherByArticleId(articleId)
  1658. if articleInfo == nil {
  1659. br.Msg = "操作失败"
  1660. br.ErrMsg = "纪要ID错误"
  1661. return
  1662. }
  1663. if errInfo != nil {
  1664. br.Msg = "操作失败"
  1665. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  1666. return
  1667. }
  1668. var topTime int
  1669. //如果有置顶时间就设为取消置顶,如果没有就写入当前置顶时间
  1670. if articleInfo.TopTime == 0 {
  1671. topTime = int(time.Now().Unix())
  1672. }
  1673. err = cygx.UpdateArticleTopTime(articleId, topTime)
  1674. if err != nil {
  1675. br.Msg = "操作失败"
  1676. br.ErrMsg = "操作失败,Err:" + err.Error()
  1677. return
  1678. }
  1679. br.Ret = 200
  1680. br.Success = true
  1681. br.Msg = "操作成功"
  1682. br.IsAddLog = true
  1683. }