From f95a8b79afaadba281a9527bc683322316ecbef9 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Mon, 23 Oct 2023 10:45:58 +0800 Subject: [PATCH] update --- app/admin/svc/svc_data_statisstics.go | 75 +++++++++++++++++---------- go.mod | 2 +- 2 files changed, 49 insertions(+), 28 deletions(-) diff --git a/app/admin/svc/svc_data_statisstics.go b/app/admin/svc/svc_data_statisstics.go index cf47035..427f982 100644 --- a/app/admin/svc/svc_data_statisstics.go +++ b/app/admin/svc/svc_data_statisstics.go @@ -1722,35 +1722,56 @@ func CentralKitchenForSchoolDataStatisticsContrast(req md.CentralKitchenForSchoo startDate, _ := time.ParseInLocation("2006-01-02 15:04:05", req.Date1[0], time.Local) endDate, _ := time.ParseInLocation("2006-01-02 15:04:05", req.Date2[0], time.Local) - for k2, v2 := range v1 { - if k2 == "" { - //若年级为空,则为教师 - continue - } - - for k3, v3 := range v2 { - xlsx.NewSheet(k3) - titleList = []string{startDate.Format("2006-01") + "~~" + endDate.Format("2006-01") + " [" + k1 + ", " + k3 + "] 订餐数据对比"} - xlsx.SetSheetRow(k3, "A1", &titleList) - titleList = []string{"姓名", "家长联系电话"} - xlsx.SetSheetRow(k3, "A2", &titleList) - xlsx.MergeCell(k3, "A1", "B1") //合并单元格 - style, err := xlsx.NewStyle(`{"fill":{"type":"pattern","color":["FFFF00"],"pattern":1}, "alignment":{"horizontal":"center"}}`) - if err != nil { - logx.Error(err) - println("<<<>>>>Error:::", err.Error()) - panic(err) + //查询当前学校下的班级升序 + tmpEnterpriseDb := db.EnterpriseDb{} + tmpEnterpriseDb.Set() + tmpEnterprise, err11 := tmpEnterpriseDb.GetEnterpriseByName(k1) + if err11 != nil { + logx.Error(err11) + println("<<<>>>>Error:::", err11.Error()) + panic(err11) + } + 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 == "" { + //若年级为空,则为教师 + continue } - xlsx.SetCellStyle(k3, "A1", "B1", style) - xlsx.SetColWidth(k3, "A", "B", 40) + for k3, v3 := range v2 { + if class.Name != k3 { + continue + } + xlsx.NewSheet(k3) + titleList = []string{startDate.Format("2006-01") + "~~" + endDate.Format("2006-01") + " [" + k1 + ", " + k3 + "] 订餐数据对比"} + xlsx.SetSheetRow(k3, "A1", &titleList) + titleList = []string{"姓名", "家长联系电话"} + xlsx.SetSheetRow(k3, "A2", &titleList) + xlsx.MergeCell(k3, "A1", "B1") //合并单元格 + style, err := xlsx.NewStyle(`{"fill":{"type":"pattern","color":["FFFF00"],"pattern":1}, "alignment":{"horizontal":"center"}}`) + if err != nil { + logx.Error(err) + println("<<<>>>>Error:::", err.Error()) + panic(err) + } + xlsx.SetCellStyle(k3, "A1", "B1", style) + xlsx.SetColWidth(k3, "A", "B", 40) - j := 2 //表头被第一行用了,只能从第二行开始 - for k4, v4 := range v3 { - //TODO::判断当前用户是否在新的月份里面 - if list1[k1] == nil || list1[k1][k2] == nil || list1[k1][k2][k3] == nil || list1[k1][k2][k3][k4] == "" { - xlsx.SetSheetRow(k3, "A"+strconv.Itoa(j), &[]interface{}{ - k4, v4}) - j++ + j := 2 //表头被第一行用了,只能从第二行开始 + for k4, v4 := range v3 { + //TODO::判断当前用户是否在新的月份里面 + if list1[k1] == nil || list1[k1][k2] == nil || list1[k1][k2][k3] == nil || list1[k1][k2][k3][k4] == "" { + xlsx.SetSheetRow(k3, "A"+strconv.Itoa(j), &[]interface{}{ + k4, v4}) + j++ + } } } } diff --git a/go.mod b/go.mod index 94aeb9d..7e37f2b 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,7 @@ require ( github.com/gomodule/redigo v2.0.0+incompatible github.com/makiuchi-d/gozxing v0.0.0-20210324052758-57132e828831 github.com/mcuadros/go-defaults v1.2.0 + github.com/medivhzhan/weapp/v2 v2.5.0 github.com/qiniu/api.v7/v7 v7.8.2 github.com/robfig/cron/v3 v3.0.1 github.com/sony/sonyflake v1.0.0 @@ -45,7 +46,6 @@ require ( github.com/leodido/go-urn v1.2.1 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-isatty v0.0.19 // indirect - github.com/medivhzhan/weapp/v2 v2.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect