Browse Source

no message

xingzai 1 year ago
parent
commit
c5abc1ed28
2 changed files with 95 additions and 2 deletions
  1. 20 2
      controllers/cygx/activity_video.go
  2. 75 0
      controllers/cygx/askserie_video.go

+ 20 - 2
controllers/cygx/activity_video.go

@@ -531,11 +531,28 @@ func (this *ActivityVideoCoAntroller) ActivityVoiceAndVideoList() {
 			}
 		}
 	}
+
+	//处理音视文件标识
+	mapVoice := make(map[int]bool)
+	var conditionVoice string
+	var parsVoice []interface{}
+	conditionVoice = " AND activity_id IN (" + activityIds + ")  "
+	listVoice, err := cygx.GetActivityVoiceList(conditionVoice, parsVoice)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	if len(listVoice) > 0 {
+		for _, v := range listVoice {
+			mapVoice[v.ActivityId] = true
+		}
+	}
 	for k, v := range list {
 		if mapIndustrial[v.ActivityId] != "" && v.TemporaryLabel == "" {
 			list[k].Label = strings.TrimRight(mapIndustrial[v.ActivityId], ",")
 		}
-		if strings.Contains(v.VideoUrl, ".mp3") {
+		if mapVoice[v.ActivityId] {
 			v.FileName = "音频"
 		} else {
 			v.FileName = "视频"
@@ -544,6 +561,7 @@ func (this *ActivityVideoCoAntroller) ActivityVoiceAndVideoList() {
 	if len(list) == 0 {
 		list = make([]*cygx.CygxActivityVideoListResp, 0)
 	}
+
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	resp := new(cygx.CygxActivityVideoListRep)
 	resp.List = list
@@ -612,7 +630,7 @@ func (this *ActivityVideoCoAntroller) VoiceAndVideoCommentList() {
 	br.Data = resp
 }
 
-// MorningMeetingHistoryListExport 导出Excel
+// VoiceAndVideoCommentListExport 导出Excel
 func VoiceAndVideoCommentListExport(this *ActivityVideoCoAntroller, resp *cygx.ArticleCommentListResp, br *models.BaseResponse) {
 	//创建excel
 	dir, err := os.Executable()

+ 75 - 0
controllers/cygx/askserie_video.go

@@ -3,12 +3,15 @@ package cygx
 import (
 	"encoding/json"
 	"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/cygx"
 	cygxService "hongze/hz_crm_api/services/cygx"
 	"hongze/hz_crm_api/services/elastic"
 	"hongze/hz_crm_api/utils"
+	"os"
+	"path/filepath"
 	"strconv"
 	"strings"
 	"time"
@@ -292,6 +295,7 @@ func (this *AskserieVideoController) HistoryList() {
 // @Title  留言记录详情
 // @Description 留言记录详情接口
 // @Param   AskserieVideoId   query   int  true       "ID"
+// @Param   IsExport   query   bool  false       "是否导出excel,默认是false"
 // @Success Ret=200 {object} cygx.GetCygxProductInteriorDetailResp
 // @router /askserie_video/collection_list [get]
 func (this *AskserieVideoController) CollectionList() {
@@ -313,6 +317,8 @@ func (this *AskserieVideoController) CollectionList() {
 		br.Msg = "请输入详情ID"
 		return
 	}
+	//是否导出报表
+	isExport, _ := this.GetBool("IsExport")
 	_, err := cygx.GetCygxAskserieVideoDetail(askserieVideoId)
 	if err != nil {
 		br.Msg = "详情不存在"
@@ -330,12 +336,81 @@ func (this *AskserieVideoController) CollectionList() {
 		return
 	}
 	resp.List = list
+	//导出excel
+	if isExport {
+		CollectionListExport(this, resp, br)
+		return
+	}
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"
 	br.Data = resp
 }
 
+// VoiceAndVideoCommentListExport 导出Excel
+func CollectionListExport(this *AskserieVideoController, resp *cygx.CygxAskserieVideoCollectionListResp, br *models.BaseResponse) {
+	//创建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 resp.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
+	}
+	downloadFileName := time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
+	this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
+	defer func() {
+		os.Remove(downLoadnFilePath)
+	}()
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "导出成功"
+}
+
 // @Title 发布/取消发布
 // @Description 发布/取消发布接口
 // @Param	request	body cygx.ProductInteriorIdReq true "type json string"