1、历史汇总查询接口导出excel优化;
This commit is contained in:
parent
9cb7995515
commit
e8e51ffed8
|
@ -3232,6 +3232,20 @@ func (e MiGuDeployService) HistoricalSummaryListNewByCatch(c *gin.Context) {
|
||||||
return summaries[i].Date > summaries[j].Date
|
return summaries[i].Date > summaries[j].Date
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 判断是否导出Excel
|
||||||
|
if req.IsExport == 1 {
|
||||||
|
// 调用导出Excel函数
|
||||||
|
url, err := models.ExportHistoricalSummaryToExcel(summaries, e.Orm)
|
||||||
|
if err != nil {
|
||||||
|
response.Error(c, http.StatusInternalServerError, err, "导出失败")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回导出文件的URL地址
|
||||||
|
response.OK(c, map[string]string{"export_url": url}, "导出成功")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 4. 分页
|
// 4. 分页
|
||||||
total := len(summaries)
|
total := len(summaries)
|
||||||
start := (req.PageNum - 1) * req.PageSize
|
start := (req.PageNum - 1) * req.PageSize
|
||||||
|
|
|
@ -1449,7 +1449,7 @@ func ExportHistoricalSummaryToExcel(data []MgHistoricalSummary, db *gorm.DB) (st
|
||||||
for i, record := range data {
|
for i, record := range data {
|
||||||
row := i + 2
|
row := i + 2
|
||||||
productName := productMap[record.ProductID] // 获取产品名称
|
productName := productMap[record.ProductID] // 获取产品名称
|
||||||
file.SetCellValue(sheet, "A"+strconv.Itoa(row), record.Date)
|
file.SetCellValue(sheet, "A"+strconv.Itoa(row), record.Date[:10])
|
||||||
file.SetCellValue(sheet, "B"+strconv.Itoa(row), productName)
|
file.SetCellValue(sheet, "B"+strconv.Itoa(row), productName)
|
||||||
file.SetCellValue(sheet, "C"+strconv.Itoa(row), record.ChannelCode)
|
file.SetCellValue(sheet, "C"+strconv.Itoa(row), record.ChannelCode)
|
||||||
file.SetCellValue(sheet, "D"+strconv.Itoa(row), record.SubmissionCount)
|
file.SetCellValue(sheet, "D"+strconv.Itoa(row), record.SubmissionCount)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user