DengBiao преди 1 година
родител
ревизия
27a991e2db
променени са 1 файла, в които са добавени 28 реда и са изтрити 1 реда
  1. +28
    -1
      app/admin/svc/svc_data_statisstics.go

+ 28
- 1
app/admin/svc/svc_data_statisstics.go Целия файл

@@ -618,9 +618,10 @@ func SelfSupportForSchoolDataStatisticsExport(req md.SelfSupportForSchoolDataSta
tmpFileName := k1 + "设备就餐数据统计表_" + utils.Int64ToStr(now.UnixMilli()) + ".xlsx"
tmpDownloadPath := "./static/export/self_support_for_school/" + tmpFileName
xlsx := excelize.NewFile()
var sumNum, sumAmount = float64(0), float64(0)

var totalData = map[string]map[string]float64{}
for k2, vv := range v {
var sumNum, sumAmount = float64(0), float64(0)
xlsx.NewSheet(k2)
titleList = []string{" 设 备 分 餐 数 据 统 计 表 "}
xlsx.SetSheetRow(k2, "A1", &titleList)
@@ -651,6 +652,11 @@ func SelfSupportForSchoolDataStatisticsExport(req md.SelfSupportForSchoolDataSta

xlsx.SetSheetRow(k2, "A"+strconv.Itoa(j), &[]interface{}{
"合计", sumNum, sumAmount})
if totalData[k2] == nil {
totalData[k2] = map[string]float64{}
}
totalData[k2]["num"] = sumNum
totalData[k2]["amount"] = sumAmount

xlsx.DeleteSheet("Sheet1") //TODO::只能放这里删除
//将文件保存至服务器
@@ -661,6 +667,27 @@ func SelfSupportForSchoolDataStatisticsExport(req md.SelfSupportForSchoolDataSta
panic(err1)
}
}

xlsx.NewSheet("Sheet1")
titleList = []string{" 设 备 分 餐 数 据 统 计 表 "}
xlsx.SetSheetRow("Sheet1", "A1", &titleList)
titleList = []string{"日 期", "消费笔数", "消费金额"}
xlsx.SetSheetRow("Sheet1", "A2", &titleList)
style, err := xlsx.NewStyle(`{"fill":{"type":"pattern","color":["FFFF00"],"pattern":1}, "alignment":{"horizontal":"center"}}`)
if err != nil {
logx.Error(err)
println("<<<<SelfSupportForSchoolDataStatisticsExport4>>>>>Error:::", err.Error())
panic(err)
}
xlsx.MergeCell("Sheet1", "A1", "C1") //合并单元格
xlsx.SetCellStyle("Sheet1", "A1", "C1", style)
xlsx.SetColWidth("Sheet1", "A", "C", 20)
j := 3 //表头前两行用了,只能从第三行开始
for key, val := range totalData {
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{key, val["num"], val["amount"]})
j++
}

xlsDownloadPath = append(xlsDownloadPath, tmpDownloadPath)
xlsFileName = append(xlsFileName, tmpFileName)
}


Зареждане…
Отказ
Запис