From a3c37506840dc5346b51eb27cece0e67c3fbf4c6 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Tue, 3 Oct 2023 23:34:37 +0800 Subject: [PATCH] update --- app/admin/svc/svc_data_statisstics.go | 47 +++++++++++++++++---------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/app/admin/svc/svc_data_statisstics.go b/app/admin/svc/svc_data_statisstics.go index 8fec11e..f5d1ee6 100644 --- a/app/admin/svc/svc_data_statisstics.go +++ b/app/admin/svc/svc_data_statisstics.go @@ -725,25 +725,38 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD j := 3 //表头前两行用了,只能从第三行开始 var sumClassNum, sumBreakfast, sumLunch, sumDinner = int64(0), int64(0), int64(0), int64(0) - for k2, v2 := range v1 { - if k2 == "" { - //若年级为空,则为教师餐 - k2 = "教师餐" - } - - for k3, v3 := range v2 { - if k3 == "" { - //若班级为空,则为教师餐 - k3 = "教师餐" + tmpClassDb := db.ClassDb{} + tmpClassDb.Set(0) + classList, err := tmpClassDb.FindClassAscByEnterprise(tmpEnterprise.Id) + if err != nil { + logx.Error(err) + println("<<<>>>>Error:::", err.Error()) + panic(err) + } + for _, class := range *classList { + for k2, v2 := range v1 { + if k2 == "" { + //若年级为空,则为教师餐 + k2 = "教师餐" } - xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{ - k2, k3, v3["breakfast"], v3["lunch"], v3["dinner"]}) - sumClassNum++ - sumBreakfast += v3["breakfast"] - sumLunch += v3["lunch"] - sumDinner += v3["dinner"] - j++ + for k3, v3 := range v2 { + if class.Name != k3 { + continue + } + if k3 == "" { + //若班级为空,则为教师餐 + k3 = "教师餐" + } + + xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{ + k2, k3, v3["breakfast"], v3["lunch"], v3["dinner"]}) + sumClassNum++ + sumBreakfast += v3["breakfast"] + sumLunch += v3["lunch"] + sumDinner += v3["dinner"] + j++ + } } } xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{