diff --git a/app/admin/svc/svc_data_statisstics.go b/app/admin/svc/svc_data_statisstics.go index 4be7a9e..bf080f4 100644 --- a/app/admin/svc/svc_data_statisstics.go +++ b/app/admin/svc/svc_data_statisstics.go @@ -1832,8 +1832,8 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD //sheetIndex := 2 //第一个表是模板表 //xls.NewSheet("sheet1") //1、新建表格 //xls.CopySheet(1, sheetIndex) - j := 4 //表头前三行被占用了,只能从第四行开始 - + j := 4 //表头前三"早餐"行被占用了,只能从第四行开始 + var totalMap = map[string]float64{} for _, date := range dates { for kk, v := range list { if date == kk { @@ -1843,18 +1843,26 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD v["晚餐"]["count"], v["晚餐"]["sum"], v["合计"]["count"], v["合计"]["sum"], }) + totalMap["breakfast_count"] += v["早餐"]["count"] + totalMap["breakfast_sum"] += v["早餐"]["sum"] + totalMap["lunch_count"] += v["早餐"]["count"] + totalMap["lunch_sum"] += v["早餐"]["sum"] + totalMap["dinner_count"] += v["早餐"]["count"] + totalMap["dinner_sum"] += v["早餐"]["sum"] + totalMap["total_count"] += v["合计"]["count"] + totalMap["total_sum"] += v["合计"]["sum"] j++ } } } //xls.DeleteSheet("template") //删除模板表 - //xls.SetSheetRow("template", "A"+strconv.Itoa(j), &[]interface{}{"总计", - // v["早餐"]["count"], v["早餐"]["sum"], - // v["午餐"]["count"], v["午餐"]["sum"], - // v["晚餐"]["count"], v["晚餐"]["sum"], - // v["合计"]["count"], v["合计"]["sum"], - //}) + xls.SetSheetRow("template", "A"+strconv.Itoa(j), &[]interface{}{"总计", + totalMap["breakfast_count"], totalMap["breakfast_sum"], + totalMap["lunch_count"], totalMap["lunch_sum"], + totalMap["dinner_count"], totalMap["dinner_sum"], + totalMap["total_count"], totalMap["total_sum"], + }) //将文件保存至服务器 xls.SaveAs("./static" + downloadPath) break