|
@@ -4,9 +4,12 @@ import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
+ "github.com/tealeg/xlsx"
|
|
|
"hongze/hz_crm_api/models"
|
|
|
"hongze/hz_crm_api/models/roadshow"
|
|
|
"hongze/hz_crm_api/utils"
|
|
|
+ "os"
|
|
|
+ "path/filepath"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
@@ -107,12 +110,12 @@ func (this *CalendarController) QuestionList() {
|
|
|
var pars []interface{}
|
|
|
|
|
|
if rsCalendarId > 0 {
|
|
|
- condition += ` AND rs_calendar_id = ? `
|
|
|
+ condition += ` AND a.rs_calendar_id = ? `
|
|
|
pars = append(pars, rsCalendarId)
|
|
|
}
|
|
|
|
|
|
if rsCalendarResearcherId > 0 {
|
|
|
- condition += ` AND rs_calendar_researcher_id = ? `
|
|
|
+ condition += ` AND a.rs_calendar_researcher_id = ? `
|
|
|
pars = append(pars, rsCalendarResearcherId)
|
|
|
}
|
|
|
|
|
@@ -134,7 +137,7 @@ func (this *CalendarController) QuestionList() {
|
|
|
// @Param CurrentIndex query int true "当前页页码,从1开始"
|
|
|
// @Param StartDate query string true "开始日期"
|
|
|
// @Param EndDate query string true "结束日期"
|
|
|
-// @Param ResearcherId query int true "研究员id"
|
|
|
+// @Param ResearcherId query string true "研究员id"
|
|
|
// @Param CompanyId query int true "客户ID"
|
|
|
// @Param CompanyIndustry query string false "客户行业"
|
|
|
// @Param CompanyClassify query string false "客户分类"
|
|
@@ -160,7 +163,7 @@ func (this *CalendarController) CalendarSummaryList() {
|
|
|
currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
startDate := this.GetString("StartDate")
|
|
|
endDate := this.GetString("EndDate")
|
|
|
- researcherId, _ := this.GetInt("ResearcherId")
|
|
|
+ researcherId := this.GetString("ResearcherId")
|
|
|
companyIndustry := this.GetString("CompanyIndustry")
|
|
|
companyClassify := this.GetString("CompanyClassify")
|
|
|
keyword := this.GetString("Keyword")
|
|
@@ -192,9 +195,8 @@ func (this *CalendarController) CalendarSummaryList() {
|
|
|
pars = append(pars, endDate)
|
|
|
}
|
|
|
|
|
|
- if researcherId > 0 {
|
|
|
- condition += ` AND b.researcher_id = ?`
|
|
|
- pars = append(pars, researcherId)
|
|
|
+ if researcherId != "" {
|
|
|
+ condition += ` AND b.researcher_id IN(` + researcherId + `)`
|
|
|
}
|
|
|
|
|
|
if companyIndustry != "" {
|
|
@@ -240,3 +242,175 @@ func (this *CalendarController) CalendarSummaryList() {
|
|
|
br.Msg = "获取成功"
|
|
|
br.Data = resp
|
|
|
}
|
|
|
+
|
|
|
+// @Title 导出客户路演问题汇总
|
|
|
+// @Description 导出客户路演问题汇总
|
|
|
+// @Param StartDate query string true "开始日期"
|
|
|
+// @Param EndDate query string true "结束日期"
|
|
|
+// @Param ResearcherId query string true "研究员id"
|
|
|
+// @Param CompanyId query int true "客户ID"
|
|
|
+// @Param CompanyIndustry query string false "客户行业"
|
|
|
+// @Param CompanyClassify query string false "客户分类"
|
|
|
+// @Param Keyword query string false "关键词: 客户名称/社会信用码"
|
|
|
+// @Success 200 {object} roadshow.QuestionSummaryListResp
|
|
|
+// @router /question/summary/export [get]
|
|
|
+func (this *CalendarController) CalendarSummaryExport() {
|
|
|
+ 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
|
|
|
+ }
|
|
|
+
|
|
|
+ startDate := this.GetString("StartDate")
|
|
|
+ endDate := this.GetString("EndDate")
|
|
|
+ researcherId := this.GetString("ResearcherId")
|
|
|
+ companyIndustry := this.GetString("CompanyIndustry")
|
|
|
+ companyClassify := this.GetString("CompanyClassify")
|
|
|
+ keyword := this.GetString("Keyword")
|
|
|
+
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+
|
|
|
+ condition += ` AND b.question_status = 1 `
|
|
|
+
|
|
|
+ if startDate != "" {
|
|
|
+ condition += ` AND b.start_date >= ?`
|
|
|
+ pars = append(pars, startDate)
|
|
|
+ }
|
|
|
+
|
|
|
+ if endDate != "" {
|
|
|
+ condition += ` AND b.start_date <= ?`
|
|
|
+ pars = append(pars, endDate)
|
|
|
+ }
|
|
|
+
|
|
|
+ if researcherId != "" {
|
|
|
+ condition += ` AND b.researcher_id IN(` + researcherId + `)`
|
|
|
+ }
|
|
|
+
|
|
|
+ if companyIndustry != "" {
|
|
|
+ condition += ` AND b.company_industry = ?`
|
|
|
+ pars = append(pars, companyIndustry)
|
|
|
+ }
|
|
|
+
|
|
|
+ if companyClassify != "" {
|
|
|
+ condition += ` AND b.company_classify = ?`
|
|
|
+ pars = append(pars, companyClassify)
|
|
|
+ }
|
|
|
+
|
|
|
+ keyword = strings.TrimSpace(keyword)
|
|
|
+ if keyword != "" {
|
|
|
+ kw := fmt.Sprint("%", keyword, "%")
|
|
|
+ condition += ` AND a.company_name LIKE ? `
|
|
|
+ pars = append(pars, kw)
|
|
|
+ }
|
|
|
+
|
|
|
+ dataList, err := roadshow.GetQuestionSummaryExport(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取指标信息失败"
|
|
|
+ br.ErrMsg = "获取数据失败,GetQuestionSummaryList,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var rsCalendarIdArr []string
|
|
|
+
|
|
|
+ for _, v := range dataList {
|
|
|
+ rsCalendarIdArr = append(rsCalendarIdArr, strconv.Itoa(v.RsCalendarId))
|
|
|
+ }
|
|
|
+
|
|
|
+ questionMap := make(map[int][]*roadshow.RsCalendarResearcherQuestionView)
|
|
|
+ var questionMax int
|
|
|
+
|
|
|
+ if len(rsCalendarIdArr) > 0 {
|
|
|
+ var questionCondition string
|
|
|
+ var questionPars []interface{}
|
|
|
+
|
|
|
+ condition += ` AND a.rs_calendar_id IN (` + strings.Join(rsCalendarIdArr, ",") + `) `
|
|
|
+
|
|
|
+ questionList, err := roadshow.GetRoadShowQuestionList(questionCondition, questionPars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取指标信息失败"
|
|
|
+ br.ErrMsg = "获取数据失败,GetRoadShowQuestionList,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, qv := range questionList {
|
|
|
+ if items, ok := questionMap[qv.RsCalendarId]; ok {
|
|
|
+ items = append(items, qv)
|
|
|
+ questionMap[qv.RsCalendarId] = items
|
|
|
+
|
|
|
+ if len(items) > questionMax {
|
|
|
+ questionMax = len(items)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ items = make([]*roadshow.RsCalendarResearcherQuestionView, 0)
|
|
|
+ items = append(items, qv)
|
|
|
+ questionMap[qv.RsCalendarId] = items
|
|
|
+ if len(items) > questionMax {
|
|
|
+ questionMax = len(items)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ dir, _ := os.Executable()
|
|
|
+ exPath := filepath.Dir(dir)
|
|
|
+ downloadPath := exPath + "/" + time.Now().Format(utils.FormatDateUnSpace) + "客户路演汇总" + ".xlsx"
|
|
|
+ xlsxFile := xlsx.NewFile()
|
|
|
+ sheet, e := xlsxFile.AddSheet("客户路演汇总")
|
|
|
+ if e != nil {
|
|
|
+ br.Msg = "新增Sheet失败"
|
|
|
+ br.ErrMsg = "新增Sheet失败, Err: " + e.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ titleRow := sheet.AddRow()
|
|
|
+ titleRow.AddCell().SetString("路演时间")
|
|
|
+ titleRow.AddCell().SetString("客户名称")
|
|
|
+ titleRow.AddCell().SetString("发起人")
|
|
|
+ titleRow.AddCell().SetString("研究员")
|
|
|
+ titleRow.AddCell().SetString("客户行业")
|
|
|
+ titleRow.AddCell().SetString("客户分类")
|
|
|
+
|
|
|
+ for i := 1; i <= questionMax; i++ {
|
|
|
+ titleRow.AddCell().SetString("Q" + strconv.Itoa(i))
|
|
|
+ titleRow.AddCell().SetString("A" + strconv.Itoa(i))
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range dataList {
|
|
|
+ dataRow := sheet.AddRow()
|
|
|
+ dataRow.AddCell().SetString(v.StartDate + " " + v.StartTime)
|
|
|
+ dataRow.AddCell().SetString(v.CompanyName)
|
|
|
+ dataRow.AddCell().SetString(v.SysUserRealName)
|
|
|
+ dataRow.AddCell().SetString(v.ResearcherName)
|
|
|
+ dataRow.AddCell().SetString(v.CompanyIndustry)
|
|
|
+ dataRow.AddCell().SetString(v.CompanyClassify)
|
|
|
+ questionList := questionMap[v.RsCalendarId]
|
|
|
+ for _, qv := range questionList {
|
|
|
+ titleRow.AddCell().SetString(qv.QuestionContent)
|
|
|
+ titleRow.AddCell().SetString(qv.ReplyContent)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if e = xlsxFile.Save(downloadPath); e != nil {
|
|
|
+ br.Msg = "导出失败"
|
|
|
+ br.ErrMsg = "保存文件失败"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fileName := time.Now().Format(utils.FormatDateUnSpace) + "客户路演汇总" + ".xlsx"
|
|
|
+ this.Ctx.Output.Download(downloadPath, fileName)
|
|
|
+ defer func() {
|
|
|
+ _ = os.Remove(downloadPath)
|
|
|
+ }()
|
|
|
+
|
|
|
+ br.Ret = 200
|
|
|
+ br.Success = true
|
|
|
+ br.Msg = "获取成功"
|
|
|
+}
|