Browse Source

Merge remote-tracking branch 'origin/eta/2.0.0' into debug

Roc 7 months ago
parent
commit
6d13d114d2
2 changed files with 21 additions and 9 deletions
  1. 19 7
      controllers/target.go
  2. 2 2
      models/target.go

+ 19 - 7
controllers/target.go

@@ -1059,21 +1059,32 @@ func (this *TargetController) ExportDataList() {
 		br.ErrMsg = "生成文件失败"
 		return
 	}
-	var frequencies []*string
-	if keyWord == "" {
+	var frequencies []string
+	if len(childClassifyIdList) > 0 {
 		frequencies, err = models.GetEdbDataFrequencyByClassifyIdList(childClassifyIdList)
 		if err != nil {
 			br.Msg = "查询频度失败"
 			br.ErrMsg = "查询频度失败"
 			return
 		}
-	} else {
+	} else if tradeCode != `` {
+		manualEdb, err := models.GetEdbinfoByTradeCode(tradeCode)
+		if err != nil {
+			br.Msg = "查询指标信息失败"
+			br.ErrMsg = "查询指标信息失败,err:" + err.Error()
+			return
+		}
+		frequencies = append(frequencies, manualEdb.Frequency)
+	} else if keyWord != `` {
 		frequencies, err = models.GetEdbDataFrequencyByKeyord(keyWord)
 		if err != nil {
 			br.Msg = "查询频度失败"
 			br.ErrMsg = "查询频度失败"
 			return
 		}
+	} else {
+		// 啥也没选的情况下
+		frequencies = append(frequencies, `日度`, `周度`, `月度`, `季度`, `半年度`, `年度`)
 	}
 
 	fileName := `手工数据`
@@ -1105,7 +1116,7 @@ func (this *TargetController) ExportDataList() {
 		}
 		var sheet *xlsx.Sheet
 		if len(secNameList) > 0 {
-			sheet, err = xlsxFile.AddSheet(*frequency)
+			sheet, err = xlsxFile.AddSheet(frequency)
 			if err != nil {
 				br.Msg = "新增Sheet失败"
 				br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
@@ -1201,12 +1212,13 @@ func (this *TargetController) ExportDataList() {
 			return
 		}
 	}
-
-	fileName += time.Now().Format("06.01.02") + `.xlsx` //文件名称
-	this.Ctx.Output.Download(downloadFilePath, fileName)
 	defer func() {
 		os.Remove(downloadFilePath)
 	}()
+
+	fileName += time.Now().Format("06.01.02") + `.xlsx` //文件名称
+	this.Ctx.Output.Download(downloadFilePath, fileName)
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "success"

+ 2 - 2
models/target.go

@@ -1064,7 +1064,7 @@ func GetEdbDataFrequency(classifyId int) (items []*string, err error) {
 // @param classifyIdList []int
 // @return items []*string
 // @return err error
-func GetEdbDataFrequencyByClassifyIdList(classifyIdList []int) (items []*string, err error) {
+func GetEdbDataFrequencyByClassifyIdList(classifyIdList []int) (items []string, err error) {
 	num := len(classifyIdList)
 	if num <= 0 {
 		return
@@ -1075,7 +1075,7 @@ func GetEdbDataFrequencyByClassifyIdList(classifyIdList []int) (items []*string,
 	return
 }
 
-func GetEdbDataFrequencyByKeyord(keyword string) (items []*string, err error) {
+func GetEdbDataFrequencyByKeyord(keyword string) (items []string, err error) {
 	sql := `SELECT DISTINCT frequency FROM edbinfo where SEC_NAME=? ORDER BY FIELD(frequency,'日度','周度','月度','季度','半年度','年度') `
 	o := orm.NewOrmUsingDB("edb")
 	_, err = o.Raw(sql, keyword).QueryRows(&items)