|
@@ -396,7 +396,7 @@ func (this *BaseFromLyIndexController) LyIndexDataExport() {
|
|
dir, _ := os.Executable()
|
|
dir, _ := os.Executable()
|
|
exPath := filepath.Dir(dir)
|
|
exPath := filepath.Dir(dir)
|
|
|
|
|
|
- downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
|
|
|
|
|
|
+ downLoadFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
|
|
xlsxFile := xlsx.NewFile()
|
|
xlsxFile := xlsx.NewFile()
|
|
frequencies, err := data_manage.GetLyIndexFrequency(classifyId)
|
|
frequencies, err := data_manage.GetLyIndexFrequency(classifyId)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -406,6 +406,13 @@ func (this *BaseFromLyIndexController) LyIndexDataExport() {
|
|
}
|
|
}
|
|
|
|
|
|
fileName := `粮油商务网`
|
|
fileName := `粮油商务网`
|
|
|
|
+ if classifyId >= 0 && indexCode == "" {
|
|
|
|
+ lyClassify, err := data_manage.GetLyClassifyById(classifyId)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ fileName = lyClassify.ClassifyName
|
|
|
|
+ }
|
|
if frequencies == nil {
|
|
if frequencies == nil {
|
|
sheet, err := xlsxFile.AddSheet("无数据")
|
|
sheet, err := xlsxFile.AddSheet("无数据")
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -419,12 +426,12 @@ func (this *BaseFromLyIndexController) LyIndexDataExport() {
|
|
}
|
|
}
|
|
|
|
|
|
for _, frequency := range frequencies {
|
|
for _, frequency := range frequencies {
|
|
- lyIndices, err := data_manage.GetLyIndexByCodeAndClassify(indexCode, classifyId)
|
|
|
|
|
|
+ lyIndices, err := data_manage.GetLyIndexByCodeAndClassify(indexCode, classifyId, frequency)
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- if indexCode == "" {
|
|
|
|
|
|
+ if indexCode != "" {
|
|
fileName = lyIndices[0].IndexName
|
|
fileName = lyIndices[0].IndexName
|
|
}
|
|
}
|
|
|
|
|
|
@@ -496,8 +503,6 @@ func (this *BaseFromLyIndexController) LyIndexDataExport() {
|
|
|
|
|
|
for _, m := range lyIndices {
|
|
for _, m := range lyIndices {
|
|
celData := rowData.AddCell()
|
|
celData := rowData.AddCell()
|
|
- fmt.Println(m.IndexCode)
|
|
|
|
- fmt.Println(dataTime)
|
|
|
|
if dataMap[m.IndexCode][dataTime] != nil {
|
|
if dataMap[m.IndexCode][dataTime] != nil {
|
|
celData.SetValue(dataMap[m.IndexCode][dataTime].Value)
|
|
celData.SetValue(dataMap[m.IndexCode][dataTime].Value)
|
|
}
|
|
}
|
|
@@ -505,7 +510,7 @@ func (this *BaseFromLyIndexController) LyIndexDataExport() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- err = xlsxFile.Save(downLoadnFilePath)
|
|
|
|
|
|
+ err = xlsxFile.Save(downLoadFilePath)
|
|
if err != nil {
|
|
if err != nil {
|
|
//有指标无数据时先导出一遍空表
|
|
//有指标无数据时先导出一遍空表
|
|
sheet, err := xlsxFile.AddSheet("无数据")
|
|
sheet, err := xlsxFile.AddSheet("无数据")
|
|
@@ -517,7 +522,7 @@ func (this *BaseFromLyIndexController) LyIndexDataExport() {
|
|
rowSecName := sheet.AddRow()
|
|
rowSecName := sheet.AddRow()
|
|
celSecName := rowSecName.AddCell()
|
|
celSecName := rowSecName.AddCell()
|
|
celSecName.SetValue("")
|
|
celSecName.SetValue("")
|
|
- err = xlsxFile.Save(downLoadnFilePath)
|
|
|
|
|
|
+ err = xlsxFile.Save(downLoadFilePath)
|
|
if err != nil {
|
|
if err != nil {
|
|
br.Msg = "保存文件失败"
|
|
br.Msg = "保存文件失败"
|
|
br.ErrMsg = "保存文件失败"
|
|
br.ErrMsg = "保存文件失败"
|
|
@@ -526,9 +531,9 @@ func (this *BaseFromLyIndexController) LyIndexDataExport() {
|
|
}
|
|
}
|
|
|
|
|
|
fileName += time.Now().Format("06.01.02") + `.xlsx` //文件名称
|
|
fileName += time.Now().Format("06.01.02") + `.xlsx` //文件名称
|
|
- this.Ctx.Output.Download(downLoadnFilePath, fileName)
|
|
|
|
|
|
+ this.Ctx.Output.Download(downLoadFilePath, fileName)
|
|
defer func() {
|
|
defer func() {
|
|
- os.Remove(downLoadnFilePath)
|
|
|
|
|
|
+ os.Remove(downLoadFilePath)
|
|
}()
|
|
}()
|
|
br.Ret = 200
|
|
br.Ret = 200
|
|
br.Success = true
|
|
br.Success = true
|