|
|
@@ -1757,35 +1757,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("<<<<CentralKitchenForSchoolDataStatisticsExport3>>>>>Error:::", err.Error()) |
|
|
|
panic(err) |
|
|
|
//查询当前学校下的班级升序 |
|
|
|
tmpEnterpriseDb := db.EnterpriseDb{} |
|
|
|
tmpEnterpriseDb.Set() |
|
|
|
tmpEnterprise, err11 := tmpEnterpriseDb.GetEnterpriseByName(k1) |
|
|
|
if err11 != nil { |
|
|
|
logx.Error(err11) |
|
|
|
println("<<<<CentralKitchenForSchoolDataStatisticsExport4>>>>>Error:::", err11.Error()) |
|
|
|
panic(err11) |
|
|
|
} |
|
|
|
tmpClassDb := db.ClassDb{} |
|
|
|
tmpClassDb.Set(0) |
|
|
|
classList, err := tmpClassDb.FindClassAscByEnterprise(tmpEnterprise.Id) |
|
|
|
if err != nil { |
|
|
|
logx.Error(err) |
|
|
|
println("<<<<CentralKitchenForSchoolDataStatisticsExport4>>>>>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("<<<<CentralKitchenForSchoolDataStatisticsExport3>>>>>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++ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|