12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727 |
- package cygx
- import (
- "encoding/json"
- "fmt"
- "github.com/rdlucklib/rdluck_tools/paging"
- "github.com/tealeg/xlsx"
- "hongze/hz_crm_api/controllers"
- "hongze/hz_crm_api/models"
- "hongze/hz_crm_api/models/company"
- "hongze/hz_crm_api/models/cygx"
- "hongze/hz_crm_api/models/system"
- "hongze/hz_crm_api/services"
- cygxService "hongze/hz_crm_api/services/cygx"
- "hongze/hz_crm_api/services/elastic"
- "hongze/hz_crm_api/utils"
- "os"
- "path/filepath"
- "strconv"
- "strings"
- "time"
- )
- // 纪要管理
- type SummaryManage struct {
- controllers.BaseAuthController
- }
- // @Title 文章内容的保存与发布
- // @Description 文章内容的保存与发布接口
- // @Param request body cygx.SummaryManageAddRep true "type json string"
- // @Success 200 操作成功
- // @router /summaryManage/PreserveAndPublish [post]
- func (this *SummaryManage) 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.SummaryManageAddRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.Title == "" {
- br.Msg = "标题不可为空"
- br.ErrMsg = "标题不可为空"
- return
- }
- if req.Abstract == "" {
- br.Msg = "摘要不可为空"
- br.ErrMsg = "摘要不可为空"
- return
- }
- if req.PublishDate == "" {
- br.Msg = "发布时间不可为空"
- return
- }
- var articleIdNew int //最新的文章id
- var haveResearch bool
- var permissionName string
- industryName := req.IndustryName
- subjectName := req.SubjectName
- publishDate := req.PublishDate
- reportLink := req.ReportLink
- chartPermissionIds := "31" //31研选
- industrialManagementIds := req.IndustrialManagementIds
- industrialSubjectIds := req.IndustrialSubjectIds
- articleId := req.ArticleId
- articleTypeId := req.ArticleTypeId
- // 产业ID校验
- industryIds := make([]int, 0)
- industrialManagementIdList := strings.Split(industrialManagementIds, ",")
- for _, v := range industrialManagementIdList {
- i, err := strconv.Atoi(v)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "产业ID不规范,Err:" + err.Error() + industrialManagementIds
- return
- }
- industryIds = append(industryIds, i)
- }
- if industrialSubjectIds != "" {
- industrialSubjectIdList := strings.Split(industrialSubjectIds, ",")
- for _, v := range industrialSubjectIdList {
- _, err := strconv.Atoi(v)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "标的ID不规范,Err:" + err.Error() + industrialSubjectIds
- return
- }
- }
- }
- chartPermissionIdsList := strings.Split(chartPermissionIds, ",")
- for _, v := range chartPermissionIdsList {
- chartPermissionId, err := strconv.Atoi(v)
- if err != nil {
- br.Msg = "发布失败"
- br.ErrMsg = "发布失败,Err:" + err.Error()
- return
- }
- charInfo, errCategory := cygx.GetCategoryInfoById(chartPermissionId)
- if errCategory != nil {
- br.Msg = "获取品种信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + errCategory.Error()
- return
- }
- if strings.Contains(charInfo.PermissionName, "研选") {
- haveResearch = true
- }
- permissionName += charInfo.PermissionName + ","
- }
- permissionName = strings.TrimRight(permissionName, ",")
- if articleId == 0 {
- maxArticleIdArticleInfo, errMax := cygx.GetMaxArticleIdInfo()
- if errMax != nil {
- br.Msg = "发布失败"
- br.ErrMsg = "发布失败,Err:" + errMax.Error()
- return
- }
- if maxArticleIdArticleInfo.ArticleId < utils.SummaryArticleId {
- articleIdNew = utils.SummaryArticleId
- } else {
- articleIdNew = maxArticleIdArticleInfo.ArticleId + 1
- }
- }
- //处理文章类型信息
- articleTypeInfo, err := cygx.GetCygxArticleTypeDetailById(articleTypeId)
- if err != nil {
- br.Msg = "请选择报告类型"
- br.ErrMsg = "获取报告类型信息失败,Err:" + err.Error()
- return
- }
- //处理作者内容的格式信息
- department := req.SellerAndMobile
- itemDepartment := new(cygx.CygxArticleDepartment)
- if !strings.Contains(department, "-") {
- br.Msg = "作者格式错误"
- return
- }
- slice := strings.Split(department, "-")
- if len(slice) < 2 {
- br.Msg = "作者格式错误"
- return
- }
- strnum := strings.Index(department, "-")
- itemDepartment.NickName = department[0:strnum]
- itemDepartment.CreateTime = time.Now()
- itemDepartment.Remark = department[strnum+1:]
- itemDepartment.Content = req.SellerAndMobile
- remarks := itemDepartment.Remark
- remarks = strings.Replace(remarks, ",", "", -1)
- remarks = strings.Replace(remarks, ",", "", -1)
- remarks = strings.Replace(remarks, " ", "", -1)
- itemDepartment.Remarks = remarks
- total, _ := cygx.GetArticleDepartmentCount(itemDepartment.NickName, itemDepartment.Remarks)
- var newDepartmentId int64
- if total == 0 {
- detail, err := cygx.GetCygxConfigDetailByCode("department_img_url")
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- sliceDepart := strings.Split(detail.ConfigValue, "{|}")
- totalDepart, err := cygx.GetArticleDepartmentCountAll()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- itemDepartment.ImgUrl = sliceDepart[totalDepart%10]
- //避免代码冗余,放弃插入事务处理
- newDepartmentId, err = cygx.AddCygxArticleDepartment(itemDepartment)
- if err != nil {
- br.Msg = "发布失败"
- br.ErrMsg = "发布失败作者信息查询错误,Err:" + err.Error()
- return
- }
- } else {
- departmentDetail, err := cygx.GetArticleDepartmentDateil(itemDepartment.NickName, itemDepartment.Remarks)
- if err != nil {
- br.Msg = "发布失败"
- br.ErrMsg = "发布失败作者信息查询错误,Err:" + err.Error()
- return
- }
- newDepartmentId = int64(departmentDetail.DepartmentId)
- }
- expertNumStr, expertContentStr, interviewDateStr, fileLink := cygx.BodyAnalysis(req.Body)
- item := new(cygx.CygxArticle)
- item.AdminId = AdminUser.AdminId
- item.AdminName = AdminUser.RealName
- item.Title = req.Title
- item.Body = req.Body
- item.BodyText, _ = cygxService.GetReportContentTextSubNew(req.Body)
- item.Abstract = req.Abstract
- item.CategoryName = permissionName
- item.ArticleId = articleId
- item.CreateDate = time.Now()
- item.LastUpdatedTime = time.Now()
- if articleTypeInfo.IsSendEs == 1 {
- item.IsSummary = 1
- } else {
- item.IsReport = 1
- }
- item.Source = 1
- item.ArticleIdMd5 = utils.MD5(strconv.Itoa(articleIdNew))
- item.UpdateFrequency = "unknow"
- item.SellerAndMobile = req.SellerAndMobile
- item.ExpertBackground = expertContentStr
- item.ExpertNumber = expertNumStr
- item.InterviewDate = interviewDateStr
- item.FileLink = fileLink
- item.ChartPermissionIds = chartPermissionIds
- item.DepartmentId = int(newDepartmentId)
- item.ArticleTypeId = articleTypeId
- item.ArticleTypeName = articleTypeInfo.ArticleTypeName
- publishDateSlice := strings.Split(publishDate, " ") //过滤前端传过来的时分秒
- item.PublishDate = utils.StrTimeToTime(publishDateSlice[0] + " 00:00:00")
- item.ReportLink = reportLink
- if haveResearch {
- item.Department = "机构投资者"
- } else {
- item.Department = "弘则权益研究"
- br.Msg = "请选择研选行业"
- return
- }
- charInfo, err := cygx.GetCategoryInfoByName(utils.CHART_PERMISSION_NAME_MF_YANXUAN)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "获取所属行业信息失败,Err:" + err.Error()
- return
- }
- if req.DoType == 1 {
- item.PublishStatus = 1
- }
- //industrialManagementId, _ := strconv.Atoi(industrialManagementIds)
- //industrialDetail, _ := cygx.GetIndustrialManagemenDetailById(industrialManagementId)
- var errArt error
- if articleId == 0 {
- item.ArticleId = articleIdNew
- //需求修改纪要的新增与修改与报告一致
- _, err := cygx.AddAReportrticle(item, charInfo.ChartPermissionId, industryName, subjectName, itemDepartment, industrialManagementIds, industrialSubjectIds)
- errArt = err
- if errArt == nil {
- //articleInfo, err := cygx.GetArticleIdInfoBySummaryManageIdEdit(int(artNewId))
- if err == nil && req.DoType == 1 {
- go cygxService.DoArticleOnenIdWxTemplateMsg(articleIdNew, 1)
- }
- }
- } else {
- articleInfo, errInfo := cygx.GetArticleIdInfoByArticleId(articleId)
- if articleInfo == nil {
- br.Msg = "文章不存在"
- return
- }
- if errInfo != nil {
- br.Msg = "发布失败"
- br.ErrMsg = "发布失败,Err:" + errInfo.Error()
- return
- }
- if item.PublishStatus == 0 {
- item.PublishStatus = articleInfo.PublishStatus
- }
- item.ArticleId = articleId
- err := cygx.EditReportrticle(item, charInfo.ChartPermissionId, industryName, subjectName, articleInfo.PublishStatus, itemDepartment, industrialManagementIds, industrialSubjectIds)
- errArt = err
- if errArt == nil && req.DoType == 1 {
- go cygxService.DoArticleOnenIdWxTemplateMsg(articleId, 1)
- }
- }
- if errArt != nil {
- br.Msg = "发布失败"
- br.ErrMsg = "发布失败,Err:" + errArt.Error()
- return
- }
- // 查研观向7.4-这里暂时注释掉, 目前article和industry有关联表处理, 此处应该是没有在用了
- //var subjectIds string
- //subjectIds, _ = cygx.GetSubjectIds(articleId)
- //{|1|}表示报告类型,{|2|}表示纪要类型
- //cygx.UpdateSubjecIds(subjectIds+"—"+strconv.Itoa(industrialDetail.IndustrialManagementId)+"{|2|}", industrialDetail.IndustrialManagementId, articleId)
- if item.PublishStatus == 1 && articleTypeInfo.IsSendEs == 1 {
- services.EsAddOrEditData(item)
- }
- ////同步数据到最新表
- //if req.ArticleId == 0 {
- // if item.PublishStatus == 1 {
- // go cygxService.UpdateResourceData(item.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime))
- // }
- //} else {
- // if item.PublishStatus == 1 {
- // go cygxService.UpdateResourceData(item.ArticleId, "article", "update", time.Now().Format(utils.FormatDateTime))
- // }
- // if req.DoType == 1 {
- // go cygxService.UpdateResourceData(item.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime))
- // }
- //}
- if len(industryIds) > 0 {
- go cygxService.UpdateIndustryLayoutTime(industryIds, false) // 查研观向7.4-更新产业布局时间
- go elastic.AddComprehensiveIndustrialSource("Yx", item.ArticleId) // 查研观向10.6 更新搜索引擎的产业资源包
- }
- go elastic.AddComprehensiveArticle(item.ArticleId) // ES添加文章:报告、纪要
- go cygxService.UpdateArticleResourceData(item.ArticleId) //写入首页最新 cygx_resource_data 表
- go cygxService.MakeArticleMomentsImg(item.ArticleId) //生成文章分享到朋友圈的图片
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.IsAddLog = true
- }
- // @Title 文章的发布与取消发布
- // @Description 文章的发布与取消发布接口
- // @Param request body cygx.SummaryManageIdRep true "type json string"
- // @Success 200 操作成功
- // @router /summaryManage/PublishAndCancel [post]
- func (this *SummaryManage) PublishAndCancel() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- AdminUser := this.SysUser
- indexName := utils.IndexName
- if AdminUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- var req cygx.SummaryManageIdRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- articleId := req.ArticleId
- item := new(cygx.CygxArticle)
- articleInfo, errInfo := cygx.GetArticleInfoOtherByArticleId(articleId)
- if articleInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "纪要ID错误"
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- item.ArticleId = articleId
- item.Title = articleInfo.Title
- item.BodyText = articleInfo.BodyText
- item.Body = articleInfo.Body
- item.PublishDate = articleInfo.PublishDate
- item.ExpertBackground = articleInfo.ExpertBackground
- item.CategoryId = articleInfo.CategoryId
- //item.Annotation, _ = GetReportContentTextSubNew(v.Annotation)
- //item.Abstract, _ = GetReportContentTextSubNew(v.Abstract)
- if articleInfo.PublishStatus == 0 {
- item.PublishStatus = 1
- item.AdminId = AdminUser.AdminId
- item.AdminName = AdminUser.RealName
- services.EsAddOrEditData(item)
- //go cygxService.UpdateResourceData(item.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime))
- } else {
- item.AdminId = articleInfo.AdminId
- item.AdminName = articleInfo.AdminName
- item.PublishStatus = 0
- services.EsDeleteData(indexName, strconv.Itoa(articleInfo.ArticleId))
- //go cygxService.UpdateResourceData(item.ArticleId, "article", "delete", time.Now().Format(utils.FormatDateTime))
- }
- err = cygx.PublishAndCancel(item)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- //专项调研类型的报告单独走发送
- if articleInfo.SubCategoryName == "专项调研" {
- if item.PublishStatus == 1 {
- cygxService.SendWxMsgWithCygxActivitySpecialArticle(item.ArticleId)
- }
- } else {
- if item.PublishStatus == 1 {
- articleIndustrial, _ := cygx.GetIndustrialManagemenDetailByAaticle(articleInfo.ArticleId)
- if articleIndustrial.ArticleId > 0 {
- go cygxService.DoArticleOnenIdWxTemplateMsg(articleId, 1)
- }
- go elastic.AddComprehensiveIndustrialSource("Yx", item.ArticleId) // 查研观向10.6 更新搜索引擎的产业资源包
- }
- }
- go elastic.AddComprehensiveArticle(articleId) // ES添加文章:报告、纪要
- go cygxService.UpdateArticleResourceData(item.ArticleId) //写入首页最新 cygx_resource_data 表
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.IsAddLog = true
- }
- // @Title 文章详情
- // @Description 获取文章详情接口
- // @Param ArticleId query int true "文章ID"
- // @Success Ret=200 {object} cygx.SummaryManageEditDetail
- // @router /summaryManage/detail [get]
- func (this *SummaryManage) 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")
- if articleId < 1 {
- br.Msg = "请输入文章ID"
- return
- }
- articleInfo, err := cygx.GetArticleIdInfoByreportIdEdit(articleId)
- if err != nil {
- br.Msg = "文章内容不存在"
- br.ErrMsg = "纪要ID错误,Err:" + err.Error()
- return
- }
- detail, _ := cygx.GetArticleDepartmentDateilByDepartmentId(articleInfo.DepartmentId)
- industrialList, err := cygx.GetIndustrialArticleGroupManagementList(articleInfo.ArticleId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(articleInfo.ArticleId)
- return
- }
- subjectList, err := cygx.GetSubjectArticleGroupManagementList(articleInfo.ArticleId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取活动关联的标的列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(articleInfo.ArticleId)
- return
- }
- articleInfo.ListIndustrial = industrialList
- articleInfo.ListSubject = subjectList
- resp := cygx.ArticleDetailResp{
- ArticleId: articleInfo.ArticleId,
- Title: articleInfo.Title,
- Abstract: articleInfo.Abstract,
- Body: articleInfo.Body,
- PublishStatus: articleInfo.PublishStatus,
- PublishDate: articleInfo.PublishDate,
- CreateDate: articleInfo.CreateDate,
- LastUpdatedTime: articleInfo.LastUpdatedTime,
- ArticleIdMd5: articleInfo.ArticleIdMd5,
- SellerAndMobile: articleInfo.SellerAndMobile,
- SubjectName: articleInfo.SubjectName,
- IndustryName: articleInfo.IndustryName,
- DepartmentId: articleInfo.DepartmentId,
- ChartPermissionIds: articleInfo.ChartPermissionIds,
- ArticleTypeId: articleInfo.ArticleTypeId,
- ArticleTypeName: articleInfo.ArticleTypeName,
- ListIndustrial: articleInfo.ListIndustrial,
- ListSubject: articleInfo.ListSubject,
- ReportLink: articleInfo.ReportLink,
- ImgUrl: detail.ImgUrl,
- NickName: detail.NickName,
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 删除纪要
- // @Description 删除纪要接口
- // @Param request body cygx.SummaryManageIdRep true "type json string"
- // @Success Ret=200
- // @router /summaryManage/delete [post]
- func (this *SummaryManage) Delete() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- indexName := utils.IndexName
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- var req cygx.SummaryManageIdRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- articleId := req.ArticleId
- if articleId < 1 {
- br.Msg = "请输入产业ID"
- return
- }
- articleInfo, errInfo := cygx.GetArticleInfoOtherByArticleId(articleId)
- if articleInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "纪要ID错误"
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- services.EsDeleteData(indexName, strconv.Itoa(articleInfo.ArticleId))
- err = cygx.DeleteArticleReport(articleInfo.ArticleId)
- if err != nil {
- br.Msg = "删除信息失败"
- br.ErrMsg = "删除信息失败,Err:" + err.Error()
- return
- }
- //go cygxService.UpdateResourceData(articleInfo.ArticleId, "article", "delete", time.Now().Format(utils.FormatDateTime))
- go cygxService.UpdateArticleResourceData(articleInfo.ArticleId) //写入首页最新 cygx_resource_data 表
- br.Ret = 200
- br.Success = true
- br.Msg = "已删除"
- br.IsAddLog = true
- }
- // @Title 纪要列表
- // @Description 获取纪要列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param PublishStatus query int true "发布状态 ,0未发布,1已发布,传2查询所有"
- // @Param CategoryName query string true "行业名称"
- // @Param StartDate query string true "开始时间 ,列如2021-03-06 "
- // @Param EndDate query string true "结束时间,列如2021-03-06 "
- // @Param KeyWord query string true "搜索关键词"
- // @Param Label query string true "搜索报告标签"
- // @Param NickName query string true "作者昵称"
- // @Param Departmentİd query int false "作者İd"
- // @Param ArticleTypeId query int false `"文章类型ID"
- // @Success 200 {object} cygx.GetSummaryManageListRep
- // @router /summaryManage/list [get]
- func (this *SummaryManage) SummaryManageList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- return
- }
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- publishStatus, _ := this.GetInt("PublishStatus")
- categoryName := this.GetString("CategoryName")
- startDate := this.GetString("StartDate")
- endDate := this.GetString("EndDate")
- keyWord := this.GetString("KeyWord")
- label := this.GetString("Label")
- nickName := this.GetString("NickName")
- departmentİd, _ := this.GetInt("Departmentİd")
- articleTypeId, _ := this.GetInt("ArticleTypeId")
- resp := new(cygx.GetSummaryManageListRep)
- 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{}
- condition += ` WHERE art.article_type_id >0 `
- if articleTypeId > 0 {
- condition += ` AND art.article_type_id = ` + strconv.Itoa(articleTypeId)
- }
- if keyWord != "" {
- condition += ` AND (art.title LIKE '%` + keyWord + `%' ) `
- }
- if nickName != "" {
- condition += ` AND (art.seller_and_mobile LIKE '%` + nickName + `%' ) `
- }
- if departmentİd > 0 {
- condition += ` AND art.department_id = ` + strconv.Itoa(departmentİd)
- }
- //行业名称
- if categoryName != "" {
- condition += ` AND art.category_name LIKE '%` + categoryName + `%' `
- }
- if startDate != "" {
- condition += ` AND art.publish_date >= ` + "'" + startDate + " 00:00:00'"
- }
- if endDate != "" {
- condition += ` AND art.publish_date <= ` + "'" + endDate + " 23:59:59'"
- }
- if startDate != "" || endDate != "" {
- condition += ` AND art.publish_status =1 `
- }
- if publishStatus == 0 || publishStatus == 1 {
- condition += ` AND art.publish_status = ` + strconv.Itoa(publishStatus)
- }
- //如果标签列表不为空则作以下关联搜索
- if label != "" {
- managementIds, err := cygx.GetManagementIdsByNameLike(label)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
- return
- }
- subjectIds, err := cygx.GetIndustrialSubjectIdsByNameLike(label)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
- return
- }
- var articleIdmanagement string
- var articleIdsubject string
- var articleIds string
- if managementIds != "" {
- articleIdmanagement, err = cygx.GetArticleIdsByIndustrialManagementId(managementIds)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取活动ID信息失败,Err:" + err.Error()
- return
- }
- }
- if subjectIds != "" {
- articleIdsubject, err = cygx.GetArticleIdsBySubjectId(subjectIds)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取活动ID信息失败,Err:" + err.Error()
- return
- }
- }
- if articleIdmanagement != "" && articleIdsubject != "" {
- articleIds = articleIdmanagement + "," + articleIdsubject
- } else if articleIdmanagement != "" && articleIdsubject == "" {
- articleIds = articleIdmanagement
- } else if articleIdmanagement == "" && articleIdsubject != "" {
- articleIds = articleIdsubject
- }
- if articleIds != "" {
- condition += ` AND art.article_id IN (` + articleIds + `)`
- } else {
- // 如果标签关联的报告为空,那么就直接返回空
- page := paging.GetPaging(currentIndex, pageSize, 0)
- resp.List = make([]*cygx.CygxArticleList, 0)
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- }
- total, err := cygx.GetASummaryManageCount(condition, pars)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- condition += ` GROUP BY art.article_id `
- condition += ` ORDER BY art.top_time DESC , art.publish_date DESC `
- list, errList := cygx.GetSummaryManageList(condition, pars, startSize, pageSize)
- if errList != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + errList.Error()
- return
- }
- var articleIdStr string
- for _, v := range list {
- articleIdStr += strconv.Itoa(v.ArticleId) + ","
- }
- articleIdStr = strings.TrimRight(articleIdStr, ",")
- // 查研观向7.4-报告关联多个产业
- mapIndustrial := make(map[int]string)
- mapSubject := make(map[string]string)
- if articleIdStr != "" {
- industrialList, err := cygx.GetIndustrialArticleGroupListByarticleIds(articleIdStr)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,GetIndustrialArticleGroupListByarticleIds Err:" + err.Error()
- return
- }
- subjectList, err := cygx.GetSubjectArticleGroupListByarticleIds(articleIdStr)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,GetSubjectArticleGroupListByarticleIds Err:" + err.Error()
- return
- }
- //合并活动对应的多个标的
- for _, v := range subjectList {
- mapSubject[fmt.Sprint(v.ArticleId, "_", v.IndustrialManagementId)] += v.SubjectName + "/"
- }
- //活动对应的产业
- for _, v := range industrialList {
- var labelSubject string
- labelSubject = mapSubject[fmt.Sprint(v.ArticleId, "_", v.IndustrialManagementId)]
- if labelSubject != "" {
- mapIndustrial[v.ArticleId] += v.IndustryName + "--" + strings.TrimRight(labelSubject, "/") + ","
- } else {
- mapIndustrial[v.ArticleId] += v.IndustryName + ","
- }
- }
- }
- for k, v := range list {
- if v.PublishStatus == 0 {
- list[k].PublishDate = ""
- } else {
- list[k].PublishDate = utils.TimeRemoveHms2(v.PublishDate)
- }
- if mapIndustrial[v.ArticleId] != "" {
- list[k].IndustryName = strings.TrimRight(mapIndustrial[v.ArticleId], ",")
- }
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 敏捷搜索关键词的列表
- // @Description 获取敏捷搜索关键词的列表接口
- // @Success 200 {object} cygx.SummaryFastsearchKeywordsListResp
- // @router /summaryManage/fastSearchKeWord [get]
- func (this *SummaryManage) FastSearch() {
- 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.SummaryFastsearchKeywordsListResp)
- list, err := cygx.GetSummaryFastsearchKeywordsList()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 新增和修改敏捷搜索关键词的列表
- // @Description 新增和修改敏捷搜索关键词的列表接口
- // @Param request body cygx.SummaryFastsearchKeywordsResp true "type json string"
- // @Success Ret=200
- // @router /summaryManage/editFastSearchKeWord [post]
- func (this *SummaryManage) EditFastSearch() {
- 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
- }
- req := new(cygx.SummaryFastsearchKeywordsResp)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- keyWord := req.KeyWord
- slicekeyWord := strings.Split(keyWord, ",")
- var items []*cygx.CygxSummaryFastsearchKeywords
- for _, v := range slicekeyWord {
- var item = new(cygx.CygxSummaryFastsearchKeywords)
- item.CreateTime = time.Now()
- item.KeyWord = v
- items = append(items, item)
- fmt.Println(v)
- }
- _, err = cygx.AddSummaryFastsearchKeywords(items)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- }
- // @Title 永续客户是否展示
- // @Description 获取永续客户是否展示详情接口
- // @Success 200 {object} cygx.SummaryFastsearchKeywordsListResp
- // @router /summaryManage/sustainableDetail [get]
- func (this *SummaryManage) Sustainable() {
- 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
- }
- detail, err := cygx.GetCygxConfigDetail()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- if detail.ConfigValue == "1" {
- detail.OperationButton = true
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = detail
- }
- // @Title 修改永续客户是否展示
- // @Description 修改永续客户是否展示接口
- // @Success Ret=200
- // @router /summaryManage/sustainableEdit [post]
- func (this *SummaryManage) EditSustainable() {
- 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 newValue int
- detail, err := cygx.GetCygxConfigDetail()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- if detail.ConfigValue == "1" {
- newValue = 0
- } else {
- newValue = 1
- }
- err = cygx.CygxConfigUpdate(newValue)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- }
- // @Title 提问列表详情
- // @Description 获取提问列表详情接口
- // @Param ArticleId query int true "文章ID"
- // @Success 200 {object} cygx.ActivityHelpAskListResp
- // @router /summaryManage/askList [get]
- func (this *SummaryManage) AskList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- return
- }
- articleId, _ := this.GetInt("ArticleId")
- articleInfo, _ := cygx.GetArticleIdInfoByArticleId(articleId)
- if articleInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "报告ID错误"
- return
- }
- list, err := cygx.GetArticleAskList(articleInfo.ArticleId)
- resp := new(cygx.ArticleAskListResp)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 提问详情excel表格下载
- // @Description 提问详情excel表格下载接口
- // @Param SummaryManageId query int true "纪要ID"
- // @Success 200 导出成功
- // @router /summaryManage/askListExport [get]
- func (this *SummaryManage) AskListExport() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- return
- }
- articleId, _ := this.GetInt("ArticleId")
- articleInfo, _ := cygx.GetArticleIdInfoByArticleId(articleId)
- if articleInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "报告ID错误"
- return
- }
- list, err := cygx.GetArticleAskList(articleInfo.ArticleId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- br.Msg = "生成文件失败"
- br.ErrMsg = "生成文件失败"
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- sheet, err := xlsxFile.AddSheet("名单")
- if err != nil {
- br.Msg = "新增Sheet失败"
- br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "姓名"
- cellB := rowTitle.AddCell()
- cellB.Value = "公司名称"
- cellC := rowTitle.AddCell()
- cellC.Value = "问题"
- cellD := rowTitle.AddCell()
- cellD.Value = "提交时间"
- for _, item := range list {
- row := sheet.AddRow()
- cellA := row.AddCell()
- cellA.Value = item.RealName
- cellB := row.AddCell()
- cellB.Value = item.CompanyName
- cellC := row.AddCell()
- cellC.Value = item.Content
- cellD := row.AddCell()
- cellD.Value = item.CreateTime
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- br.Msg = "保存文件失败"
- br.ErrMsg = "保存文件失败"
- return
- }
- randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
- downloadFileName := "问题列表" + randStr + ".xlsx"
- this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
- defer func() {
- os.Remove(downLoadnFilePath)
- }()
- br.Success = true
- br.Ret = 200
- br.Msg = "导出成功"
- }
- // @Title 作者关注详情
- // @Description 获取作者关注详情列表接口
- // @Param DepartmentId query int true "作者ID"
- // @Success 200 {object} cygx.GetFailSignupListRep
- // @router /summaryManage/department/followList [get]
- func (this *SummaryManage) FepartmentfollowList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- return
- }
- departmentId, _ := this.GetInt("DepartmentId")
- detail, _ := cygx.GetArticleDepartmentDateilById(departmentId)
- if detail == nil {
- br.Msg = "作者不存在"
- br.ErrMsg = "获取信息失败,Err:DepartmentId:" + strconv.Itoa(departmentId)
- return
- }
- list, err := cygx.GetCygxDepartmentFllowList(departmentId)
- resp := new(cygx.CygxDepartmentFllowRep)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取列表失败,Err:" + err.Error()
- return
- }
- resp.NickName = detail.Content
- resp.FllowNum = len(list)
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 文章收藏详情
- // @Description 获取文章收藏详情列表接口
- // @Param ArticleId query int true "文章ID"
- // @Success 200 {object} cygx.GetFailSignupListRep
- // @router /summaryManage/articleCollection [get]
- func (this *SummaryManage) ArticleCollection() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- return
- }
- articleId, _ := this.GetInt("ArticleId")
- _, err := cygx.GetArticleIdInfoByArticleId(articleId)
- if err != nil {
- br.Msg = "报告不存在"
- br.ErrMsg = "查询失败,Err:" + err.Error() + strconv.Itoa(articleId)
- return
- }
- list, err := cygx.GetCygxArticleCollectionList(articleId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取列表失败,Err:" + err.Error()
- return
- }
- //获取对应销售名称
- if len(list) > 0 {
- var companyIds []int
- for _, v := range list {
- companyIds = append(companyIds, v.CompanyId)
- }
- listCompanyProduct, err := company.GetCompanyProductListByCompanyIds(companyIds, 2)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取销售列表失败,Err:" + err.Error()
- return
- }
- mapSellName := make(map[int]string)
- for _, v := range listCompanyProduct {
- mapSellName[v.CompanyId] = v.SellerName
- }
- for _, v := range list {
- v.SellerName = mapSellName[v.CompanyId]
- }
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = list
- }
- // @Title 阅读明细下载
- // @Description 获取阅读明细下载接口
- // @Param ArticleId query int true "文章ID"
- // @Success 200 导出成功
- // @router /summaryManage/articleHistoryExport [get]
- func (this *SummaryManage) ArticleHistoryExport() {
- 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
- }
- articleId, _ := this.GetInt("ArticleId")
- articleInfo, err := cygx.GetArticleIdInfoByArticleId(articleId)
- if err != nil {
- br.Msg = "报告不存在"
- br.ErrMsg = "查询失败,Err:" + err.Error() + strconv.Itoa(articleId)
- return
- }
- resp := new(cygx.CanDownload)
- adminInfo, errAdmin := system.GetSysUserById(AdminUser.AdminId)
- if errAdmin != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + errAdmin.Error()
- return
- }
- if adminInfo.Role == "admin" || adminInfo.Role == "researcher" || adminInfo.RealName == "汪洋" {
- resp.IsCanDownload = true
- }
- var condition string
- if resp.IsCanDownload == false {
- //权益申请销售只能看到自己名下的客户的申请
- companyIds, err := cygxService.GetAdminLookUserCompanyIds(AdminUser)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,GetAdminLookUserCompanyIds Err:" + err.Error()
- return
- }
- var companyIdstr []string
- for _, v := range companyIds {
- companyIdstr = append(companyIdstr, strconv.Itoa(v))
- }
- condition = ` AND h.company_id IN (` + strings.Join(companyIdstr, ",") + `) `
- }
- mapMobileSellWithUser := make(map[string]string)
- if condition != "" {
- mobileList, err := cygx.GetSellerUserMobileList(condition)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取策略品台数据失败,Err:" + err.Error()
- return
- }
- if len(mobileList) > 0 {
- for _, v := range mobileList {
- mapMobileSellWithUser[v.Mobile] = v.Mobile
- }
- }
- }
- condition += ` AND h.company_id != ` + strconv.Itoa(utils.HZ_COMPANY_ID) // 过滤弘则
- list, err := cygx.GetArticleHistoryList(articleId, condition)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- listClPv, err := cygx.GetCygxCelueArticleHistoryRecordPvAll(strconv.Itoa(articleId))
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取策略品台数据失败,Err:" + err.Error()
- return
- }
- var mobilesCl string
- if len(listClPv) > 0 {
- for _, v := range listClPv {
- if v.Mobile != "" {
- mobilesCl += v.Mobile + ","
- }
- }
- }
- mapMobileCompany := make(map[string]string)
- mapMobileSellName := make(map[string]string)
- mobilesCl = strings.TrimRight(mobilesCl, ",")
- if mobilesCl != "" {
- listClCompanyName, err := cygx.GetCygxCelueArticleComapnyName(mobilesCl)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败"
- br.ErrMsg = "获取策略品台关联查研观向的用户信息失败,Err:" + err.Error()
- return
- }
- if len(listClCompanyName) > 0 {
- for _, v := range listClCompanyName {
- mapMobileCompany[v.Mobile] = v.CompanyName
- mapMobileSellName[v.Mobile] = v.RealName
- }
- }
- }
- for k, v := range listClPv {
- if v.Mobile != "" {
- if mapMobileCompany[v.Mobile] != "" {
- listClPv[k].CompanyName = mapMobileCompany[v.Mobile]
- }
- if mapMobileSellName[v.Mobile] != "" {
- listClPv[k].SellerName = mapMobileSellName[v.Mobile]
- }
- }
- }
- var listClPvPower []*cygx.ArticleHistoryRep
- if len(mapMobileSellWithUser) != 0 {
- for _, v := range listClPv {
- if mapMobileSellWithUser[v.Mobile] != "" {
- listClPvPower = append(listClPvPower, v)
- }
- }
- } else {
- listClPvPower = listClPv
- }
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- br.Msg = "生成文件失败"
- br.ErrMsg = "生成文件失败"
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- for pidIndex := 0; pidIndex <= 1; pidIndex++ {
- var sheetName string
- var listDate []*cygx.ArticleHistoryRep
- if pidIndex == 0 {
- sheetName = "查研观向"
- listDate = list
- } else {
- sheetName = "策略平台"
- listDate = listClPvPower
- }
- sheet, err := xlsxFile.AddSheet(sheetName)
- if err != nil {
- br.Msg = "新增Sheet失败"
- br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "姓名"
- cellB := rowTitle.AddCell()
- cellB.Value = "手机号"
- cellC := rowTitle.AddCell()
- cellC.Value = "公司名称"
- cellD := rowTitle.AddCell()
- cellD.Value = "所属权益销售"
- cellE := rowTitle.AddCell()
- cellE.Value = "阅读时长(秒)"
- cellF := rowTitle.AddCell()
- cellF.Value = "阅读时间"
- for _, item := range listDate {
- row := sheet.AddRow()
- cellA := row.AddCell()
- cellA.Value = item.RealName
- cellB := row.AddCell()
- cellB.Value = item.Mobile
- cellC := row.AddCell()
- cellC.Value = item.CompanyName
- cellD := row.AddCell()
- cellD.Value = item.SellerName
- cellE := row.AddCell()
- cellE.Value = item.StopTime
- cellF := row.AddCell()
- cellF.Value = item.CreateTime
- }
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- br.Msg = "保存文件失败"
- br.ErrMsg = "保存文件失败"
- return
- }
- //randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
- downloadFileName := articleInfo.Title + ".xlsx"
- this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
- defer func() {
- os.Remove(downLoadnFilePath)
- }()
- br.Success = true
- br.Ret = 200
- br.Msg = "导出成功"
- }
- // @Title 文章类型列表
- // @Description 文章类型列表接口
- // @Success 200 {object} cygx.ArticleTypeListResp
- // @router /summaryManage/articleType/list [get]
- func (this *ActivityTypeCoAntroller) ArticleTypeList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- resp := new(cygx.ArticleTypeListResp)
- list, err := cygx.GetCygxArticleTypeList()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- typelist, err := cygx.GetArticleTypeAndAbstract()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp.AbstractList = typelist
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 新增文章类型
- // @Description 新增文章类型接口
- // @Param request body cygx.CygxArticleReq true "type json string"
- // @Success Ret=200
- // @router /summaryManage/articleType/add [post]
- func (this *SummaryManage) ArticleTypeListAdd() {
- 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
- }
- req := new(cygx.CygxArticleReq)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- name := req.ArticleTypeName
- if name == "" {
- br.Msg = "内容不能为空!"
- return
- }
- var condition string
- condition = ` AND article_type_name = '` + name + `'`
- count, err := cygx.GetCygxArticleTypeCount(condition)
- if err != nil {
- br.Msg = "操作失败!"
- br.ErrMsg = "获取数量失败,Err:" + err.Error()
- return
- }
- if count > 0 {
- br.Msg = "该类型已存在,请重新填写!"
- return
- }
- count, err = cygx.GetCygxArticleTypeCount("")
- if err != nil {
- br.Msg = "操作失败!"
- br.ErrMsg = "获取已添加的数量失败,Err:" + err.Error()
- return
- }
- item := new(cygx.CygxArticleType)
- item.ArticleTypeName = name
- item.YanxPermissionName = utils.CHART_PERMISSION_NAME_MF_YANXUAN + name
- item.IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
- item.IcoLinkM = "https://hzstatic.hzinsights.com/static/temp/20220707202207/20220707/FEvPxfalkGKllLIlBMKumm47zhEx.png"
- item.YanxPermissionId = 1001 + count // id 数量从一千开始计算
- item.CreateTime = time.Now()
- item.ModifyTime = time.Now()
- _, err = cygx.AddCygxArticleType(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 获取留言列表详情接口
- // @Param ArticleId query int true "文章ID"
- // @Success 200 {object} cygx.ArticleCommentListResp
- // @router /summaryManage/commentList [get]
- func (this *SummaryManage) CommentList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- return
- }
- articleId, _ := this.GetInt("ArticleId")
- articleInfo, _ := cygx.GetArticleIdInfoByArticleId(articleId)
- if articleInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "报告ID错误"
- return
- }
- list, err := cygx.GetArticleCommentList(articleInfo.ArticleId)
- resp := new(cygx.ArticleCommentListResp)
- if err != nil {
- br.Msg = "获取留言失败"
- br.ErrMsg = "获取留言失败,Err:" + err.Error()
- return
- }
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 提问详情excel表格下载
- // @Description 提问详情excel表格下载接口
- // @Param SummaryManageId query int true "纪要ID"
- // @Success 200 导出成功
- // @router /summaryManage/commentListExport [get]
- func (this *SummaryManage) CommentListExport() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- return
- }
- articleId, _ := this.GetInt("ArticleId")
- articleInfo, _ := cygx.GetArticleIdInfoByArticleId(articleId)
- if articleInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "报告ID错误"
- return
- }
- list, err := cygx.GetArticleCommentList(articleInfo.ArticleId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- //创建excel
- dir, err := os.Executable()
- exPath := filepath.Dir(dir)
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
- xlsxFile := xlsx.NewFile()
- if err != nil {
- br.Msg = "生成文件失败"
- br.ErrMsg = "生成文件失败"
- return
- }
- style := xlsx.NewStyle()
- alignment := xlsx.Alignment{
- Horizontal: "center",
- Vertical: "center",
- WrapText: true,
- }
- style.Alignment = alignment
- style.ApplyAlignment = true
- sheet, err := xlsxFile.AddSheet("名单")
- if err != nil {
- br.Msg = "新增Sheet失败"
- br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
- return
- }
- //标头
- rowTitle := sheet.AddRow()
- cellA := rowTitle.AddCell()
- cellA.Value = "姓名"
- cellB := rowTitle.AddCell()
- cellB.Value = "公司名称"
- cellC := rowTitle.AddCell()
- cellC.Value = "留言"
- cellD := rowTitle.AddCell()
- cellD.Value = "提交时间"
- for _, item := range list {
- row := sheet.AddRow()
- cellA := row.AddCell()
- cellA.Value = item.RealName
- cellB := row.AddCell()
- cellB.Value = item.CompanyName
- cellC := row.AddCell()
- cellC.Value = item.Content
- cellD := row.AddCell()
- cellD.Value = item.CreateTime
- }
- err = xlsxFile.Save(downLoadnFilePath)
- if err != nil {
- br.Msg = "保存文件失败"
- br.ErrMsg = "保存文件失败"
- return
- }
- randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
- downloadFileName := "留言列表" + randStr + ".xlsx"
- this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
- defer func() {
- os.Remove(downLoadnFilePath)
- }()
- br.Success = true
- br.Ret = 200
- br.Msg = "导出成功"
- }
- // @Title 文章的见范围修改
- // @Description 文章的见范围修改接口
- // @Param request body cygx.SummaryManageIdRep true "type json string"
- // @Success 200 操作成功
- // @router /summaryManage/visibleRange [post]
- func (this *SummaryManage) VisibleRange() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- AdminUser := this.SysUser
- indexName := utils.IndexName
- if AdminUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- var req cygx.SummaryManageIdRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- articleId := req.ArticleId
- item := new(cygx.CygxArticle)
- articleInfo, errInfo := cygx.GetArticleInfoOtherByArticleId(articleId)
- if articleInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "纪要ID错误"
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- item.ArticleId = articleId
- item.Title = articleInfo.Title
- item.BodyText = articleInfo.BodyText
- item.Body = articleInfo.Body
- item.PublishDate = articleInfo.PublishDate
- item.ExpertBackground = articleInfo.ExpertBackground
- item.CategoryId = articleInfo.CategoryId
- if articleInfo.VisibleRange == 0 {
- item.VisibleRange = 1
- item.AdminId = AdminUser.AdminId
- item.AdminName = AdminUser.RealName
- services.EsAddOrEditData(item)
- //go cygxService.UpdateResourceData(item.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime))
- } else {
- item.AdminId = articleInfo.AdminId
- item.AdminName = articleInfo.AdminName
- item.PublishStatus = 0
- services.EsDeleteData(indexName, strconv.Itoa(articleInfo.ArticleId))
- //go cygxService.UpdateResourceData(item.ArticleId, "article", "delete", time.Now().Format(utils.FormatDateTime))
- }
- err = cygx.ArticleVisibleRange(item)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- //专项调研类型的报告单独走发送
- if articleInfo.SubCategoryName == "专项调研" {
- if item.PublishStatus == 1 {
- cygxService.SendWxMsgWithCygxActivitySpecialArticle(item.ArticleId)
- }
- } else {
- if item.PublishStatus == 1 {
- articleIndustrial, _ := cygx.GetIndustrialManagemenDetailByAaticle(articleInfo.ArticleId)
- if articleIndustrial.ArticleId > 0 {
- go cygxService.DoArticleOnenIdWxTemplateMsg(articleId, 1)
- }
- }
- }
- go cygxService.UpdateArticleResourceData(item.ArticleId) //写入首页最新 cygx_resource_data 表
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.IsAddLog = true
- }
- // @Title 文章的置顶与取消置顶
- // @Description 活动的发布与取消发布接口
- // @Param request body cygx.ActivityIdRep true "type json string"
- // @Success 200 操作成功
- // @router /summaryManage/top_change [post]
- func (this *SummaryManage) TopeChange() {
- 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.SummaryManageIdRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- articleId := req.ArticleId
- articleInfo, errInfo := cygx.GetArticleInfoOtherByArticleId(articleId)
- if articleInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "纪要ID错误"
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- var topTime int
- //如果有置顶时间就设为取消置顶,如果没有就写入当前置顶时间
- if articleInfo.TopTime == 0 {
- topTime = int(time.Now().Unix())
- }
- err = cygx.UpdateArticleTopTime(articleId, topTime)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.IsAddLog = true
- }
|