123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833 |
- package cygx
- import (
- "encoding/json"
- "fmt"
- "github.com/rdlucklib/rdluck_tools/paging"
- "hongze/hz_crm_api/controllers"
- "hongze/hz_crm_api/models"
- "hongze/hz_crm_api/models/cygx"
- "hongze/hz_crm_api/services"
- cygxService "hongze/hz_crm_api/services/cygx"
- "hongze/hz_crm_api/utils"
- "regexp"
- "strconv"
- "strings"
- "time"
- )
- // 上周纪要汇总
- type MinutesSummaryController struct {
- controllers.BaseAuthController
- }
- // @Title 上周纪要汇总内容的保存与发布
- // @Description 上周纪要汇总内容的保存与发布接口
- // @Param request body cygx.AddCygxMinutesSummary true "type json string"
- // @Success 200 操作成功
- // @router /minutesSummary/PreserveAndPublish [post]
- func (this *MinutesSummaryController) PreserveAndPublish() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- AdminUser := this.SysUser
- if AdminUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- var req cygx.AddCygxMinutesSummary
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- var sortSdbgStr, msgErr string
- content := req.Content
- sortYanx := content.SortYanx
- if sortYanx != "" {
- match, _ := regexp.MatchString(`^[A-Za-z]+$`, sortYanx)
- if !match || len(sortYanx) > 1 {
- br.Msg = "研选排序有误"
- return
- }
- content.SortYanx = strings.ToUpper(content.SortYanx)
- if strings.Contains(sortSdbgStr, content.SortYanx) {
- br.Msg = "研选排序有误"
- return
- }
- }
- sortCydyjy := content.SortCydyjy
- if sortCydyjy != "" {
- match, _ := regexp.MatchString(`^[A-Za-z]+$`, sortCydyjy)
- if !match || len(sortCydyjy) > 1 {
- br.Msg = "产业调研纪要排序有误"
- return
- }
- content.SortCydyjy = strings.ToUpper(content.SortCydyjy)
- if strings.Contains(sortSdbgStr, content.SortCydyjy) {
- br.Msg = "产业调研纪要排序有误"
- return
- }
- sortSdbgStr += content.SortCydyjy
- }
- sortSsgs := content.SortSsgs
- if sortSsgs != "" {
- match, _ := regexp.MatchString(`^[A-Za-z]+$`, sortSsgs)
- if !match || len(sortSsgs) > 1 {
- br.Msg = "上市公司调研纪要篇排序有误"
- return
- }
- content.SortSsgs = strings.ToUpper(content.SortSsgs)
- if strings.Contains(sortSdbgStr, content.SortSsgs) {
- br.Msg = "上市公司调研纪要篇序有误"
- return
- }
- }
- var items []*cygx.CygxMinutesSummaryLog
- mapSort := make(map[string]int)
- if len(req.List) > 0 {
- for _, v := range req.List {
- for _, v2 := range v.List {
- item := new(cygx.CygxMinutesSummaryLog)
- chartPermissionSort := v.ChartPermissionSort
- match, _ := regexp.MatchString(`^[A-Za-z]+$`, chartPermissionSort)
- if !match || len(chartPermissionSort) > 1 {
- br.Msg = "排序有误"
- return
- }
- item.ChartPermissionSort = strings.ToUpper(chartPermissionSort)
- if mapSort[v.ChartPermissionSort] != 0 && mapSort[v.ChartPermissionSort] != v.ChartPermissionId {
- br.Msg = "排序有误,排序重复"
- return
- }
- mapSort[v.ChartPermissionSort] = v.ChartPermissionId
- item.ChartPermissionId = v.ChartPermissionId
- item.CreateTime = time.Now()
- item.Body = cygxService.GetRichtext(v2.Body)
- item.ReportLink = v2.ReportLink
- if item.ReportLink != "" {
- articleIdLink, err := cygxService.GetReportLinkToArticleid(item.ReportLink)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "解析报告链接ID失败,Err:" + err.Error()
- return
- }
- item.LinkArticleId = articleIdLink
- }
- items = append(items, item)
- }
- }
- }
- //产业调研纪要
- if len(content.ListCydyjy) > 0 {
- items, msgErr, err = cygxService.AppendMinutesItemsLog(items, content.ListCydyjy, "CYDYJY", strings.ToUpper(content.SortCydyjy))
- if msgErr != "" {
- br.Msg = msgErr
- return
- }
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- }
- //上市公司调研纪要篇
- if len(content.ListSsgs) > 0 {
- items, msgErr, err = cygxService.AppendMinutesItemsLog(items, content.ListSsgs, "SSGS", strings.ToUpper(content.SortSsgs))
- if msgErr != "" {
- br.Msg = msgErr
- return
- }
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- }
- //研选
- if len(content.ListYanx) > 0 {
- for _, v := range content.ListYanx {
- item := new(cygx.CygxMinutesSummaryLog)
- item.Type = "YANX"
- item.Sort = strings.ToUpper(content.SortYanx)
- item.CreateTime = time.Now()
- item.Body = cygxService.GetRichtext(v.Body)
- item.ReportLink = v.ReportLink
- if item.ReportLink != "" {
- articleIdLink, err := cygxService.GetReportLinkToArticleid(item.ReportLink)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "解析报告链接ID失败,Err:" + err.Error()
- return
- }
- item.LinkArticleId = articleIdLink
- }
- items = append(items, item)
- }
- }
- condition := ` AND have_publish = 1 `
- var pars []interface{}
- total, err := cygx.GetCygxMinutesSummary(condition, pars)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- itemCrs := new(cygx.CygxMinutesSummary)
- itemCrs.AdminId = AdminUser.AdminId
- itemCrs.AdminName = AdminUser.RealName
- itemCrs.Title = req.Title
- itemCrs.Department = req.Department
- itemCrs.Abstract = req.Abstract
- itemCrs.PublishStatus = req.DoType
- if req.DoType == 1 {
- itemCrs.HavePublish = 1
- itemCrs.Periods = strconv.Itoa(total + 1)
- }
- itemCrs.PublishDate = utils.StrTimeToTime(req.PublishDate + " 00:00:00")
- itemCrs.CreateTime = time.Now()
- itemCrs.LastUpdatedTime = time.Now()
- if req.ArticleId == 0 {
- articleId, err := cygx.AddCygxMinutesSummaryOrm(itemCrs, items)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "发布失败,Err:" + err.Error()
- return
- }
- req.ArticleId = int(articleId)
- } else {
- detail, err := cygx.GetCygxMinutesSummaryInfoById(req.ArticleId)
- if err != nil {
- br.Msg = "内容不存在"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- //如果点发布PublishStatus = 1 如果点保存,PublishStatus则为之前的状态 发布人还是之前的发布人
- if itemCrs.PublishStatus == 0 {
- itemCrs.PublishStatus = detail.PublishStatus
- itemCrs.AdminId = detail.AdminId
- itemCrs.AdminName = detail.AdminName
- }
- if detail.HavePublish == 1 {
- itemCrs.Periods = detail.Periods
- itemCrs.HavePublish = detail.HavePublish
- }
- itemCrs.ArticleId = req.ArticleId
- _, err = cygx.UpdateCygxMinutesSummaryOrm(itemCrs, items)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "发布失败,Err:" + err.Error()
- return
- }
- }
- //if req.DoType == 1 {
- // cygxService.DoThisWeekLastWeekWxTemplateMsg(itemCrs.Title, itemCrs.PublishDate.Format(utils.FormatDateTime), itemCrs.Abstract, req.ArticleId, 3)
- //}
- //生成音频文件
- articleId := req.ArticleId
- var contentVideo string
- contentVideo = "摘要" + req.Abstract
- listFirst, err := cygx.GetMinutesSummarylogListAll(articleId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
- return
- }
- for k, v := range listFirst {
- if v.Type == "CYDYJY" {
- contentVideo += "产业调研纪要"
- } else if v.Type == "SSGS" {
- contentVideo += "上市公司调研纪要篇"
- } else if v.Type == "YANX" {
- contentVideo += utils.CHART_PERMISSION_NAME_MF_YANXUAN + "纪要"
- }
- listSecond, err := cygx.GetMinutesSummarylogSonListSecond(articleId, v.Type)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range listSecond {
- contentVideo += v2.PermissionName
- listThird, err := cygx.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- if len(listThird) > 0 {
- listSecond[k2].List = listThird
- for _, v3 := range listThird {
- contentVideo += v3.Body
- }
- }
- }
- if len(listSecond) > 0 {
- listFirst[k].List = listSecond
- }
- }
- go services.CreateVideoWhithContent(articleId, req.Title, contentVideo, "cygx_minutes_summary")
- go cygxService.UpdateMinutesSummaryResourceData(articleId) //写入首页最新 cygx_resource_data 表
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.IsAddLog = true
- }
- // @Title 删除上周纪要汇总内容
- // @Description 删除上周纪要汇总内容接口
- // @Param request body cygx.MinutesSummaryId true "type json string"
- // @Success Ret=200
- // @router /minutesSummary/delete [post]
- func (this *MinutesSummaryController) Delete() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- AdminUser := this.SysUser
- if AdminUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req cygx.MinutesSummaryId
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- articleId := req.ArticleId
- detail, err := cygx.GetCygxMinutesSummaryInfoById(articleId)
- if err != nil {
- br.Msg = "内容不存在"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- if detail.HavePublish != 0 {
- br.Msg = "删除失败"
- br.ErrMsg = "已经存在期数无法删除"
- return
- }
- err = cygx.DeleteCygxMinutesSummary(articleId)
- if err != nil {
- br.Msg = "删除信息失败"
- br.ErrMsg = "删除信息失败,Err:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "已删除"
- br.IsAddLog = true
- }
- // @Title 上周纪要汇总内容详情
- // @Description 上周纪要汇总内容详情接口
- // @Param ArticleId query int true "报告Id"
- // @Success Ret=200 {object} cygx.DetailCygxMinutesSummaryRep
- // @router /minutesSummary/detail [get]
- func (this *MinutesSummaryController) Detail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- AdminUser := this.SysUser
- if AdminUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- articleId, _ := this.GetInt("ArticleId")
- detail, err := cygx.GetCygxMinutesSummaryInfoById(articleId)
- if err != nil {
- br.Msg = "内容不存在"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.DetailCygxMinutesSummaryRep)
- resp.ArticleId = detail.ArticleId
- resp.Title = detail.Title
- resp.Department = detail.Department
- resp.Abstract = detail.Abstract
- resp.PublishStatus = detail.PublishStatus
- resp.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
- var condition string
- condition = ` AND chart_permission_id IN (19,20,21,22) `
- listLess, err := cygx.GetChartPermissionIcoDetail(condition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- listCydyjy, err := cygx.GetCygxMinutesSummaryLogRepList(articleId, "CYDYJY")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for _, v := range listCydyjy {
- listSon, err := cygx.GetCygxMinutesSummaryLogRepListSon(articleId, v.ChartPermissionId, "CYDYJY")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range listLess {
- if v2.ChartPermissionId == v.ChartPermissionId {
- listLess[k2].List = listSon
- listLess[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
- }
- }
- resp.SortCydyjy = v.Sort
- }
- resp.ListCydyjy = listLess
- //产业调研纪要
- listLess, err = cygx.GetChartPermissionIcoDetail(condition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- listSsgs, err := cygx.GetCygxMinutesSummaryLogRepList(articleId, "SSGS")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for _, v := range listSsgs {
- listSon, err := cygx.GetCygxMinutesSummaryLogRepListSon(articleId, v.ChartPermissionId, "SSGS")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range listLess {
- if v2.ChartPermissionId == v.ChartPermissionId {
- listLess[k2].List = listSon
- listLess[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
- }
- }
- resp.SortSsgs = v.Sort
- }
- resp.ListSsgs = listLess
- //事件点评
- listYanx, err := cygx.GetCygxMinutesSummaryYanxList(articleId, "YANX")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- var itemsYanx []*cygx.AddCygxMinutesSummaryLog
- for _, v := range listYanx {
- item := new(cygx.AddCygxMinutesSummaryLog)
- item.Body = v.Body
- item.ReportLink = v.ReportLink
- itemsYanx = append(itemsYanx, item)
- resp.SortYanx = v.Sort
- }
- resp.ListYanx = itemsYanx
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 上周纪要汇总列表
- // @Description 获取上周纪要汇总列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param PublishStatus query int false "发布状态 ,1未发布,1已发布,传2查询所有"
- // @Param StartDate query string false "开始时间 ,列如2021-03-06 "
- // @Param EndDate query string false "结束时间,列如2021-03-06 "
- // @Success 200 {object} cygx.CygxMinutesSummaryListRep
- // @router /minutesSummary/list [get]
- func (this *MinutesSummaryController) List() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- AdminUser := this.SysUser
- if AdminUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- return
- }
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- publishStatus, _ := this.GetInt("PublishStatus")
- startDate := this.GetString("StartDate")
- endDate := this.GetString("EndDate")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = utils.StartIndex(currentIndex, pageSize)
- var condition string
- var pars []interface{}
- if startDate != "" {
- condition += ` AND rs.publish_date >= ` + "'" + startDate + " 00:00:00'"
- }
- if endDate != "" {
- condition += ` AND rs.publish_date <= ` + "'" + endDate + " 23:59:59'"
- }
- if publishStatus == 0 || publishStatus == 1 {
- condition += ` AND rs.publish_status = ` + strconv.Itoa(publishStatus)
- }
- total, err := cygx.GetCygxMinutesSummary(condition, pars)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- list, err := cygx.GetMinutesSummaryList(condition, pars, startSize, pageSize)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- if v.Periods != "" && v.Periods != "0" {
- list[k].Periods = "第" + v.Periods + "期"
- } else {
- list[k].Periods = ""
- }
- list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp := new(cygx.CygxMinutesSummaryListRep)
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 上周纪要汇总的发布与取消发布
- // @Description 上周纪要汇总的发布与取消发布接口
- // @Param request body cygx.ResearchSummaryId true "type json string"
- // @Success 200 操作成功
- // @router /minutesSummary/PublishAndCancel [post]
- func (this *MinutesSummaryController) PublishAndCancel() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- AdminUser := this.SysUser
- if AdminUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- var req cygx.ResearchSummaryId
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- articleId := req.ArticleId
- detail, err := cygx.GetCygxMinutesSummaryInfoById(articleId)
- if err != nil {
- br.Msg = "内容不存在"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- item := new(cygx.CygxMinutesSummaryRep)
- item.ArticleId = articleId
- if detail.PublishStatus == 0 {
- item.PublishStatus = 1
- item.AdminId = AdminUser.AdminId
- item.AdminName = AdminUser.RealName
- //cygxService.DoThisWeekLastWeekWxTemplateMsg(detail.Title, detail.PublishDate, detail.Abstract, req.ArticleId, 3)
- } else {
- item.AdminId = detail.AdminId
- item.AdminName = detail.AdminName
- item.PublishStatus = 0
- }
- if detail.HavePublish == 0 {
- condition := ` AND have_publish = 1 `
- var pars []interface{}
- total, err := cygx.GetCygxMinutesSummary(condition, pars)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- item.Periods = strconv.Itoa(total + 1)
- } else {
- item.Periods = detail.Periods
- }
- err = cygx.MinutesSummaryPublishAndCancel(item)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.IsAddLog = true
- }
- // 批量修改已生成的音频文件
- func init123() {
- var pars []interface{}
- list, err := cygx.GetMinutesSummaryList("", pars, 0, 1000)
- if err != nil {
- fmt.Println(err)
- return
- }
- for _, v := range list {
- //生成音频文件
- articleId := v.ArticleId
- var contentVideo string
- contentVideo = "摘要" + v.Abstract
- listFirst, err := cygx.GetMinutesSummarylogListAll(articleId)
- if err != nil {
- fmt.Println(err)
- return
- }
- for k, v := range listFirst {
- if v.Type == "CYDYJY" {
- contentVideo += "产业调研纪要"
- } else if v.Type == "SSGS" {
- contentVideo += "上市公司调研纪要篇"
- } else if v.Type == "YANX" {
- contentVideo += utils.CHART_PERMISSION_NAME_MF_YANXUAN + "纪要"
- }
- listSecond, err := cygx.GetMinutesSummarylogSonListSecond(articleId, v.Type)
- if err != nil && err.Error() != utils.ErrNoRow() {
- fmt.Println(err)
- return
- }
- for k2, v2 := range listSecond {
- contentVideo += v2.PermissionName
- listThird, err := cygx.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
- if err != nil && err.Error() != utils.ErrNoRow() {
- fmt.Println(err)
- return
- }
- if len(listThird) > 0 {
- listSecond[k2].List = listThird
- for _, v3 := range listThird {
- contentVideo += v3.Body
- }
- }
- }
- if len(listSecond) > 0 {
- listFirst[k].List = listSecond
- }
- }
- go services.CreateVideoWhithContent(articleId, v.Title, contentVideo, "cygx_minutes_summary")
- }
- }
- // @Title 上周研究汇总邮件发送
- // @Description 上周研究汇总邮件发送接口
- // @Param ArticleId query int true "报告Id"
- // @router /minutesSummary/sendMail [get]
- func (this *MinutesSummaryController) MinutesSummarySendMail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- AdminUser := this.SysUser
- if AdminUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- articleId, _ := this.GetInt("ArticleId")
- detail, err := cygx.GetCygxMinutesSummaryInfoById(articleId)
- if err != nil {
- br.Msg = "内容不存在"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.DetailCygxMinutesSummaryRep)
- resp.ArticleId = detail.ArticleId
- resp.Title = detail.Title
- resp.Department = detail.Department
- resp.Abstract = detail.Abstract
- resp.PublishStatus = detail.PublishStatus
- resp.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
- var condition string
- condition = ` AND chart_permission_id IN (19,20,21,22) `
- listLess, err := cygx.GetChartPermissionIcoDetail(condition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- listCydyjy, err := cygx.GetCygxMinutesSummaryLogRepList(articleId, "CYDYJY")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for _, v := range listCydyjy {
- listSon, err := cygx.GetCygxMinutesSummaryLogRepListSon(articleId, v.ChartPermissionId, "CYDYJY")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range listLess {
- if v2.ChartPermissionId == v.ChartPermissionId {
- listLess[k2].List = listSon
- listLess[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
- }
- }
- resp.SortCydyjy = v.Sort
- }
- resp.ListCydyjy = listLess
- //产业调研纪要
- listLess, err = cygx.GetChartPermissionIcoDetail(condition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- listSsgs, err := cygx.GetCygxMinutesSummaryLogRepList(articleId, "SSGS")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for _, v := range listSsgs {
- listSon, err := cygx.GetCygxMinutesSummaryLogRepListSon(articleId, v.ChartPermissionId, "SSGS")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range listLess {
- if v2.ChartPermissionId == v.ChartPermissionId {
- listLess[k2].List = listSon
- listLess[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
- }
- }
- resp.SortSsgs = v.Sort
- }
- resp.ListSsgs = listLess
- //事件点评
- listYanx, err := cygx.GetCygxMinutesSummaryYanxList(articleId, "YANX")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- var itemsYanx []*cygx.AddCygxMinutesSummaryLog
- for _, v := range listYanx {
- item := new(cygx.AddCygxMinutesSummaryLog)
- item.Body = v.Body
- item.ReportLink = v.ReportLink
- itemsYanx = append(itemsYanx, item)
- resp.SortYanx = v.Sort
- }
- resp.ListYanx = itemsYanx
- var list []string
- //添加测试环境的过滤
- if utils.RunMode == "release" {
- list, err = cygx.GetAllOverseasRaiEmail()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取邮箱列表失败,Err:" + err.Error()
- return
- }
- }
- go cygxService.SendMinutesSummaryEmail(resp, list)
- br.Success = true
- br.Msg = "发送成功"
- br.Ret = 200
- }
- // @Title 上周纪要汇总的可见范围修改
- // @Description 上周纪要汇总的可见范围修改接口
- // @Param request body cygx.ResearchSummaryId true "type json string"
- // @Success 200 操作成功
- // @router /minutesSummary/visibleRange [post]
- func (this *MinutesSummaryController) VisibleRange() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- AdminUser := this.SysUser
- if AdminUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- var req cygx.ResearchSummaryId
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- articleId := req.ArticleId
- detail, err := cygx.GetCygxMinutesSummaryInfoById(articleId)
- if err != nil {
- br.Msg = "内容不存在"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- item := new(cygx.CygxMinutesSummaryRep)
- item.ArticleId = articleId
- if detail.VisibleRange == 0 {
- item.VisibleRange = 1
- item.AdminId = AdminUser.AdminId
- item.AdminName = AdminUser.RealName
- if detail.IsSendWxMsg == 0 {
- cygxService.DoThisWeekLastWeekWxTemplateMsg(detail.Title, detail.PublishDate, detail.Abstract, req.ArticleId, 3)
- }
- //go cygxService.UpdateResourceData(articleId, "minutessummary", "add", time.Now().Format(utils.FormatDateTime))
- } else {
- item.AdminId = detail.AdminId
- item.AdminName = detail.AdminName
- item.VisibleRange = 0
- //go cygxService.UpdateResourceData(articleId, "minutessummary", "delete", time.Now().Format(utils.FormatDateTime))
- }
- err = cygx.MinutesSummaryVisibleRange(item)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- go cygxService.UpdateMinutesSummaryResourceData(articleId) //写入首页最新 cygx_resource_data 表
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.IsAddLog = true
- }
|