12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235 |
- 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 ResearchSummaryController struct {
- controllers.BaseAuthController
- }
- // @Title 本周研究汇总内容的保存与发布
- // @Description 本周研究汇总内容的保存与发布接口
- // @Param request body cygx.AddCygxResearchSummary true "type json string"
- // @Success 200 操作成功
- // @router /researchSummary/PreserveAndPublish [post]
- func (this *ResearchSummaryController) 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.AddCygxResearchSummary
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- //`description:"类型'SDBG:深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP:事件点评,’BZCHJH:本周晨会精华’,’SSGS:上市公司调研纪要篇’"`
- content := req.Content
- sortSdbg := content.SortSdbg
- var sortSdbgStr string
- var msgErr string
- if sortSdbg != "" {
- match, _ := regexp.MatchString(`^[A-Za-z]+$`, sortSdbg)
- if !match || len(sortSdbg) > 1 {
- br.Msg = "深度报告篇排序有误"
- return
- }
- content.SortSdbg = strings.ToUpper(content.SortSdbg)
- sortSdbgStr += content.SortSdbg
- }
- 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
- }
- sortSjdp := content.SortSjdp
- if sortSjdp != "" {
- match, _ := regexp.MatchString(`^[A-Za-z]+$`, sortSjdp)
- if !match || len(sortSjdp) > 1 {
- br.Msg = "事件点评排序有误"
- return
- }
- content.SortSjdp = strings.ToUpper(content.SortSjdp)
- if strings.Contains(sortSdbgStr, content.SortSjdp) {
- br.Msg = "事件点评排序有误"
- return
- }
- sortSdbgStr += content.SortSjdp
- }
- sortBzchjh := content.SortBzchjh
- if sortBzchjh != "" {
- match, _ := regexp.MatchString(`^[A-Za-z]+$`, sortBzchjh)
- if !match || len(sortBzchjh) > 1 {
- br.Msg = "本周晨会精华排序有误"
- return
- }
- content.SortBzchjh = strings.ToUpper(content.SortBzchjh)
- if strings.Contains(sortSdbgStr, content.SortBzchjh) {
- br.Msg = "本周晨会精华排序有误"
- return
- }
- }
- 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
- }
- }
- 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.CygxResearchSummaryLog
- //合并深度报告片篇
- if len(content.ListSdbg) > 0 {
- items, msgErr, err = cygxService.AppendItemsLog(items, content.ListSdbg, "SDBG", strings.ToUpper(content.SortSdbg))
- if msgErr != "" {
- br.Msg = msgErr
- return
- }
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- }
- //产业调研纪要
- if len(content.ListCydyjy) > 0 {
- items, msgErr, err = cygxService.AppendItemsLog(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.AppendItemsLog(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.ListSjdp) > 0 {
- for _, v := range content.ListSjdp {
- item := new(cygx.CygxResearchSummaryLog)
- item.Type = "SJDP"
- item.Sort = strings.ToUpper(content.SortSjdp)
- 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)
- }
- }
- //本周晨会精华
- if len(content.ListBzchjh) > 0 {
- items, msgErr, err = cygxService.AppendItemsLog(items, content.ListBzchjh, "BZCHJH", strings.ToUpper(content.SortBzchjh))
- if msgErr != "" {
- br.Msg = msgErr
- return
- }
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- }
- //研选
- if len(content.ListYanx) > 0 {
- items, msgErr, err = cygxService.AppendItemsLog(items, content.ListYanx, "YANX", strings.ToUpper(content.SortYanx))
- if msgErr != "" {
- br.Msg = msgErr
- return
- }
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- }
- condition := ` AND have_publish = 1 `
- var pars []interface{}
- total, err := cygx.GetCygxResearchSummary(condition, pars)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- itemCrs := new(cygx.CygxResearchSummary)
- 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.AddCygxResearchSummaryOrm(itemCrs, items)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "发布失败,Err:" + err.Error()
- return
- }
- req.ArticleId = int(articleId)
- } else {
- detail, err := cygx.GetCygxResearchSummaryInfoById(req.ArticleId)
- if err != nil {
- br.Msg = "内容不存在"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- 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.UpdateCygxResearchSummaryOrm(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, 2)
- //}
- //生成音频文件
- articleId := req.ArticleId
- var contentVideo string
- contentVideo = "摘要" + req.Abstract
- listFirst, err := cygx.GetResearchSummarylogListFirst(articleId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
- return
- }
- listArticleType, err := cygx.GetCygxArticleTypeList()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
- return
- }
- for k, v := range listFirst {
- if v.Type == "SDBG" {
- contentVideo += "深度报告篇"
- } else if v.Type == "BZCHJH" {
- contentVideo += "本周晨会精华"
- } else if v.Type == "CYDYJY" {
- contentVideo += "产业调研纪要篇"
- } else if v.Type == "SSGS" {
- contentVideo += "上市公司调研纪要篇"
- } else if v.Type == "YANX" {
- contentVideo += utils.CHART_PERMISSION_NAME_MF_YANXUAN
- } else {
- contentVideo += "事件点评"
- }
- listSecond, err := cygx.GetResearchSummarylogSonListSecond(articleId, v.Type)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range listSecond {
- if v.Type == "YANX" {
- for _, vType := range listArticleType {
- if v2.ChartPermissionId == vType.YanxPermissionId {
- contentVideo += vType.YanxPermissionName
- }
- }
- } else {
- contentVideo += v2.PermissionName
- }
- //if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
- // contentVideo += utils.CHART_PERMISSION_NAME_MF_YANXUAN + "纪要"
- //} else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
- // contentVideo += utils.CHART_PERMISSION_NAME_MF_YANXUAN + "观点"
- //} else {
- // contentVideo += v2.PermissionName
- //}
- listThird, err := cygx.GetResearchSummarylogSonListThird(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_research_summary")
- go cygxService.UpdateResearchSummaryResourceData(articleId) //写入首页最新 cygx_resource_data 表
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.IsAddLog = true
- }
- // @Title 删除本周研究汇总内容
- // @Description 删除本周研究汇总内容接口
- // @Param request body cygx.ResearchSummaryId true "type json string"
- // @Success Ret=200
- // @router /researchSummary/delete [post]
- func (this *ResearchSummaryController) 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.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.GetCygxResearchSummaryInfoById(articleId)
- if err != nil {
- br.Msg = "内容不存在"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- if detail.HavePublish != 0 {
- br.Msg = "删除失败"
- br.ErrMsg = "已经存在期数无法删除"
- return
- }
- err = cygx.DeleteCygxResearchSummary(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.DetailCygxResearchSummaryRep
- // @router /researchSummary/detail [get]
- func (this *ResearchSummaryController) 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.GetCygxResearchSummaryInfoById(articleId)
- if err != nil {
- br.Msg = "内容不存在"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.DetailCygxResearchSummaryRep)
- 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 items []*cygx.CygxRSlChartPermissionIco
- //`description:"类型'SDBG:深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP:事件点评,’BZCHJH:本周晨会精华’,’SSGS:本周晨会精华’"`
- 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
- }
- condition = ` AND chart_permission_id IN (19,20,21,22,23) `
- listMore, err := cygx.GetChartPermissionIcoDetail(condition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- listSdbg, err := cygx.GetCygxResearchSummaryLogRepList(articleId, "SDBG")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for _, v := range listSdbg {
- listSon, err := cygx.GetCygxResearchSummaryLogRepListSon(articleId, v.ChartPermissionId, "SDBG")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range listMore {
- if v2.ChartPermissionId == v.ChartPermissionId {
- listMore[k2].List = listSon
- listMore[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
- }
- }
- resp.SortSdbg = v.Sort
- }
- resp.ListSdbg = listMore
- //产业调研纪要
- //items = make([]*cygx.CygxRSlChartPermissionIco, 0)
- listCydyjy, err := cygx.GetCygxResearchSummaryLogRepList(articleId, "CYDYJY")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for _, v := range listCydyjy {
- listSon, err := cygx.GetCygxResearchSummaryLogRepListSon(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
- //上市公司
- 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
- }
- listSsgs, err := cygx.GetCygxResearchSummaryLogRepList(articleId, "SSGS")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for _, v := range listSsgs {
- listSon, err := cygx.GetCygxResearchSummaryLogRepListSon(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
- //研选
- var listYanxItem []*cygx.CygxRSlChartPermissionIco
- listType, err := cygx.GetCygxArticleTypeList()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for _, v := range listType {
- item := new(cygx.CygxRSlChartPermissionIco)
- item.ChartPermissionId = v.YanxPermissionId
- item.ChartPermissionName = v.YanxPermissionName
- item.IcoLink = v.IcoLink
- item.List = make([]*cygx.AddCygxResearchSummaryLog, 0)
- listYanxItem = append(listYanxItem, item)
- }
- itemList := listYanxItem
- condition = ` AND chart_permission_id IN (19,20,21,22,31) `
- listLess, err = cygx.GetChartPermissionIcoDetail(condition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- listYanx, err := cygx.GetCygxResearchSummaryLogRepList(articleId, "YANX")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for _, v := range listYanx {
- listSon, err := cygx.GetCygxResearchSummaryLogRepListSon(articleId, v.ChartPermissionId, "YANX")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range itemList {
- if v2.ChartPermissionId == v.ChartPermissionId {
- itemList[k2].List = listSon
- itemList[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
- }
- }
- resp.SortYanx = v.Sort
- }
- resp.ListYanx = itemList
- //事件点评
- listSjdp, err := cygx.GetCygxResearchSummarySjdpList(articleId, "SJDP")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- var itemsSjdp []*cygx.AddCygxResearchSummaryLog
- for _, v := range listSjdp {
- item := new(cygx.AddCygxResearchSummaryLog)
- item.Body = v.Body
- item.ReportLink = v.ReportLink
- itemsSjdp = append(itemsSjdp, item)
- resp.SortSjdp = v.Sort
- }
- resp.ListSjdp = itemsSjdp
- //items = make([]*cygx.CygxRSlChartPermissionIco, 0)
- condition = ` AND chart_permission_id IN (19,20,21,22,23) `
- listMore, err = cygx.GetChartPermissionIcoDetail(condition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- listBzchjh, err := cygx.GetCygxResearchSummaryLogRepList(articleId, "BZCHJH")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for _, v := range listBzchjh {
- listSon, err := cygx.GetCygxResearchSummaryLogRepListSon(articleId, v.ChartPermissionId, "BZCHJH")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range listMore {
- if v2.ChartPermissionId == v.ChartPermissionId {
- listMore[k2].List = listSon
- listMore[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
- }
- }
- resp.SortBzchjh = v.Sort
- }
- resp.ListBzchjh = listMore
- 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.CygxResearchSummaryListRep
- // @router /researchSummary/list [get]
- func (this *ResearchSummaryController) 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.GetCygxResearchSummary(condition, pars)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- list, err := cygx.GetResearchSummaryList(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.CygxResearchSummaryListRep)
- 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 /researchSummary/PublishAndCancel [post]
- func (this *ResearchSummaryController) 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.GetCygxResearchSummaryInfoById(articleId)
- if err != nil {
- br.Msg = "内容不存在"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- item := new(cygx.CygxResearchSummaryRep)
- 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, 2)
- } 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.GetCygxResearchSummary(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.ResearchSummaryPublishAndCancel(item)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.IsAddLog = true
- }
- // @Title 本周研究汇总初始模板
- // @Description 本周研究汇总初始模板接口
- // @Success Ret=200 {object} cygx.DetailCygxResearchSummaryRep
- // @router /researchSummary/detailTemplate [get]
- func (this *ResearchSummaryController) DetailTemplate() {
- 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
- }
- resp := new(cygx.DetailCygxResearchSummaryTmpRep)
- //`description:"类型'SDBG:深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP:事件点评,’BZCHJH:本周晨会精华’,'YANX:研选'"`
- var condition string
- condition = ` AND chart_permission_id IN (19,20,21,22,23) `
- listMore, err := cygx.GetChartPermissionIcoNew(condition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- condition = ` AND chart_permission_id IN (19,20,21,22) `
- listLess, err := cygx.GetChartPermissionIcoNew(condition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for k := range listMore {
- listMore[k].List = make([]string, 0)
- }
- for k := range listLess {
- listLess[k].List = make([]string, 0)
- }
- listType, err := cygx.GetCygxArticleTypeList()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- var listYanx []*cygx.CygxRSlChartPermissionIcoTmp
- for _, v := range listType {
- item := new(cygx.CygxRSlChartPermissionIcoTmp)
- item.ChartPermissionId = v.YanxPermissionId
- item.ChartPermissionName = v.YanxPermissionName
- item.IcoLink = v.IcoLink
- item.List = make([]string, 0)
- listYanx = append(listYanx, item)
- }
- //listYanx := []*cygx.CygxRSlChartPermissionIcoTmp{{ChartPermissionId: utils.YanxSummaryPermissionId, ChartPermissionName: "研选纪要", ChartPermissionSort: "", IcoLink: "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png", List: make([]string, 0)}, {ChartPermissionId: utils.YanxViewpointPermissionId, ChartPermissionName: "研选观点", ChartPermissionSort: "", IcoLink: "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png", List: make([]string, 0)}}
- resp.ListBzchjh = listMore
- resp.ListSdbg = listMore
- resp.ListCydyjy = listLess
- resp.ListSsgs = listLess
- resp.ListYanx = listYanx
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // 批量修改已生成的音频文件
- func init111() {
- var pars []interface{}
- list, err := cygx.GetResearchSummaryList("", pars, 0, 1000)
- if err != nil {
- fmt.Println(err)
- return
- }
- for k, v := range list {
- fmt.Println(k)
- //生成音频文件
- articleId := v.ArticleId
- var contentVideo string
- contentVideo = "摘要" + v.Abstract
- listFirst, err := cygx.GetResearchSummarylogListFirst(articleId)
- if err != nil {
- fmt.Println(err)
- return
- }
- listArticleType, err := cygx.GetCygxArticleTypeList()
- if err != nil {
- fmt.Println(err)
- return
- }
- for k, v := range listFirst {
- if v.Type == "SDBG" {
- contentVideo += "深度报告"
- } else if v.Type == "BZCHJH" {
- contentVideo += "本周晨会精华"
- } else if v.Type == "CYDYJY" {
- contentVideo += "产业调研纪要"
- } else if v.Type == "SSGS" {
- contentVideo += "上市公司调研纪要"
- } else if v.Type == "YANX" {
- contentVideo += utils.CHART_PERMISSION_NAME_MF_YANXUAN
- } else {
- contentVideo += "事件点评"
- }
- listSecond, err := cygx.GetResearchSummarylogSonListSecond(articleId, v.Type)
- if err != nil && err.Error() != utils.ErrNoRow() {
- fmt.Println(err)
- return
- }
- for k2, v2 := range listSecond {
- if v.Type == "YANX" {
- for _, vType := range listArticleType {
- if v2.ChartPermissionId == vType.YanxPermissionId {
- contentVideo += vType.YanxPermissionName
- }
- }
- } else {
- contentVideo += v2.PermissionName
- }
- //if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
- // contentVideo += utils.CHART_PERMISSION_NAME_MF_YANXUAN + "纪要"
- //} else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
- // contentVideo += utils.CHART_PERMISSION_NAME_MF_YANXUAN + "观点"
- //} else {
- // contentVideo += v2.PermissionName
- //}
- listThird, err := cygx.GetResearchSummarylogSonListThird(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_research_summary")
- }
- }
- // @Title 本周研究汇总邮件发送
- // @Description 本周研究汇总邮件发送接口
- // @Param ArticleId query int true "报告Id"
- // @router /researchSummary/sendMail [get]
- func (this *ResearchSummaryController) ResearchSummarySendMail() {
- 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.GetCygxResearchSummaryInfoById(articleId)
- if err != nil {
- br.Msg = "内容不存在"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- resp := new(cygx.DetailCygxResearchSummaryRep)
- 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 items []*cygx.CygxRSlChartPermissionIco
- //`description:"类型'SDBG:深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP:事件点评,’BZCHJH:本周晨会精华’,’SSGS:本周晨会精华’"`
- 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
- }
- condition = ` AND chart_permission_id IN (19,20,21,22,23) `
- listMore, err := cygx.GetChartPermissionIcoDetail(condition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- listSdbg, err := cygx.GetCygxResearchSummaryLogRepList(articleId, "SDBG")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for _, v := range listSdbg {
- listSon, err := cygx.GetCygxResearchSummaryLogRepListSon(articleId, v.ChartPermissionId, "SDBG")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range listMore {
- if v2.ChartPermissionId == v.ChartPermissionId {
- listMore[k2].List = listSon
- listMore[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
- }
- }
- resp.SortSdbg = v.Sort
- }
- resp.ListSdbg = listMore
- //产业调研纪要
- //items = make([]*cygx.CygxRSlChartPermissionIco, 0)
- listCydyjy, err := cygx.GetCygxResearchSummaryLogRepList(articleId, "CYDYJY")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for _, v := range listCydyjy {
- listSon, err := cygx.GetCygxResearchSummaryLogRepListSon(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
- //上市公司
- 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
- }
- listSsgs, err := cygx.GetCygxResearchSummaryLogRepList(articleId, "SSGS")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for _, v := range listSsgs {
- listSon, err := cygx.GetCygxResearchSummaryLogRepListSon(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
- //研选
- var listYanxItem []*cygx.CygxRSlChartPermissionIco
- listType, err := cygx.GetCygxArticleTypeList()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for _, v := range listType {
- item := new(cygx.CygxRSlChartPermissionIco)
- item.ChartPermissionId = v.YanxPermissionId
- item.ChartPermissionName = v.YanxPermissionName
- item.IcoLink = v.IcoLink
- item.List = make([]*cygx.AddCygxResearchSummaryLog, 0)
- listYanxItem = append(listYanxItem, item)
- }
- itemList := listYanxItem
- condition = ` AND chart_permission_id IN (19,20,21,22,31) `
- listLess, err = cygx.GetChartPermissionIcoDetail(condition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- listYanx, err := cygx.GetCygxResearchSummaryLogRepList(articleId, "YANX")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for _, v := range listYanx {
- listSon, err := cygx.GetCygxResearchSummaryLogRepListSon(articleId, v.ChartPermissionId, "YANX")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range itemList {
- if v2.ChartPermissionId == v.ChartPermissionId {
- itemList[k2].List = listSon
- itemList[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
- }
- }
- resp.SortYanx = v.Sort
- }
- resp.ListYanx = itemList
- //事件点评
- listSjdp, err := cygx.GetCygxResearchSummarySjdpList(articleId, "SJDP")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- var itemsSjdp []*cygx.AddCygxResearchSummaryLog
- for _, v := range listSjdp {
- item := new(cygx.AddCygxResearchSummaryLog)
- item.Body = v.Body
- item.ReportLink = v.ReportLink
- itemsSjdp = append(itemsSjdp, item)
- resp.SortSjdp = v.Sort
- }
- resp.ListSjdp = itemsSjdp
- //items = make([]*cygx.CygxRSlChartPermissionIco, 0)
- condition = ` AND chart_permission_id IN (19,20,21,22,23) `
- listMore, err = cygx.GetChartPermissionIcoDetail(condition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- listBzchjh, err := cygx.GetCygxResearchSummaryLogRepList(articleId, "BZCHJH")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for _, v := range listBzchjh {
- listSon, err := cygx.GetCygxResearchSummaryLogRepListSon(articleId, v.ChartPermissionId, "BZCHJH")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range listMore {
- if v2.ChartPermissionId == v.ChartPermissionId {
- listMore[k2].List = listSon
- listMore[k2].ChartPermissionSort = listSon[0].ChartPermissionSort
- }
- }
- resp.SortBzchjh = v.Sort
- }
- resp.ListBzchjh = listMore
- var list []string
- //添加测试环境的过滤
- if utils.RunMode == "release" {
- list, err = cygx.GetAllOverseasRaiEmail()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取邮箱列表失败,Err:" + err.Error()
- return
- }
- }
- go cygxService.SendResearchSummaryEmail(resp, list)
- br.Success = true
- br.Msg = "发送成功"
- br.Ret = 200
- //br.Data = resp
- }
- // @Title 本周研究汇总的可见范围修改
- // @Description 本周研究汇总的可见范围修改接口
- // @Param request body cygx.ResearchSummaryId true "type json string"
- // @Success 200 操作成功
- // @router /researchSummary/visibleRange [post]
- func (this *ResearchSummaryController) 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.GetCygxResearchSummaryInfoById(articleId)
- if err != nil {
- br.Msg = "内容不存在"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- item := new(cygx.CygxResearchSummaryRep)
- 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, 2)
- }
- //go cygxService.UpdateResourceData(articleId, "researchsummary", "add", time.Now().Format(utils.FormatDateTime))
- } else {
- item.AdminId = detail.AdminId
- item.AdminName = detail.AdminName
- item.VisibleRange = 0
- //go cygxService.UpdateResourceData(articleId, "researchsummary", "delete", time.Now().Format(utils.FormatDateTime))
- }
- err = cygx.ResearchSummaryVisibleRange(item)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- go cygxService.UpdateResearchSummaryResourceData(articleId) //写入首页最新 cygx_resource_data 表
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.IsAddLog = true
- }
|