|
|
@@ -676,6 +676,7 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD |
|
|
|
titleList = []string{startDate.Format("2006-01-02") + "~~" + endDate.Format("2006-01-02") + " (" + k1 + ") "} |
|
|
|
xlsx.SetSheetRow("Sheet1", "A1", &titleList) |
|
|
|
titleList = []string{"年级", "班级", "早餐", "午餐", "晚餐"} |
|
|
|
|
|
|
|
xlsx.SetSheetRow("Sheet1", "A2", &titleList) |
|
|
|
xlsx.MergeCell("Sheet1", "A1", "E1") //合并单元格 |
|
|
|
style, err := xlsx.NewStyle(`{"fill":{"type":"pattern","color":["FFFF00"],"pattern":1}, "alignment":{"horizontal":"center"}}`) |
|
|
@@ -685,7 +686,6 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
xlsx.SetCellStyle("Sheet1", "A1", "E1", style) |
|
|
|
|
|
|
|
xlsx.SetColWidth("Sheet1", "A", "E", 20) |
|
|
|
|
|
|
|
j := 3 //表头前两行用了,只能从第三行开始 |
|
|
@@ -1001,6 +1001,9 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD |
|
|
|
for k1, v1 := range list { |
|
|
|
tmpFileName := k1 + "退款明细_" + utils.Int64ToStr(now.UnixMilli()) + ".xlsx" |
|
|
|
tmpDownloadPath := "./static/export/central_kitchen_for_school/" + tmpFileName |
|
|
|
startDate, _ := time.ParseInLocation("2006-01-02 15:04:05", req.StartDate, time.Local) |
|
|
|
endDate, _ := time.ParseInLocation("2006-01-02 15:04:05", req.EndDate, time.Local) |
|
|
|
|
|
|
|
for k2, v2 := range v1 { |
|
|
|
if k2 == "" { |
|
|
|
//若年级为空,则为教师餐 |
|
|
@@ -1008,15 +1011,33 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD |
|
|
|
} |
|
|
|
|
|
|
|
for k3, v3 := range v2 { |
|
|
|
titleList = []string{"姓名", "早餐", "午餐", "晚餐"} |
|
|
|
xlsx.NewSheet(k3) |
|
|
|
titleList = []string{startDate.Format("2006-01-02") + "~~" + endDate.Format("2006-01-02") + " [" + k1 + ", " + k3 + "] 退款明细"} |
|
|
|
xlsx.SetSheetRow(k3, "A1", &titleList) |
|
|
|
j := 2 //表头被第一行用了,只能从第二行开始 |
|
|
|
titleList = []string{"姓名", "早餐", "午餐", "晚餐"} |
|
|
|
xlsx.SetSheetRow(k3, "A2", &titleList) |
|
|
|
xlsx.MergeCell(k3, "A1", "D1") //合并单元格 |
|
|
|
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", "D1", style) |
|
|
|
xlsx.SetColWidth(k3, "A", "D", 20) |
|
|
|
|
|
|
|
var sumBreakfast, sumLunch, sumDinner = 0, 0, 0 |
|
|
|
j := 3 //表头前两行用了,只能从第三行开始 |
|
|
|
for k4, v4 := range v3 { |
|
|
|
xlsx.SetSheetRow(k3, "A"+strconv.Itoa(j), &[]interface{}{ |
|
|
|
k4, v4["breakfast"], v4["lunch"], v4["dinner"]}) |
|
|
|
sumBreakfast += v4["breakfast"] |
|
|
|
sumLunch += v4["lunch"] |
|
|
|
sumDinner += v4["dinner"] |
|
|
|
j++ |
|
|
|
} |
|
|
|
xlsx.SetSheetRow(k3, "A"+strconv.Itoa(j), &[]interface{}{ |
|
|
|
"合计", sumBreakfast, sumLunch, sumDinner}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -1232,9 +1253,27 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD |
|
|
|
for k1, v1 := range list { |
|
|
|
tmpFileName := k1 + "班级收款明细_" + utils.Int64ToStr(now.UnixMilli()) + ".xlsx" |
|
|
|
tmpDownloadPath := "./static/export/central_kitchen_for_school/" + tmpFileName |
|
|
|
startDate, _ := time.ParseInLocation("2006-01-02 15:04:05", req.StartDate, time.Local) |
|
|
|
endDate, _ := time.ParseInLocation("2006-01-02 15:04:05", req.EndDate, time.Local) |
|
|
|
titleList = []string{startDate.Format("2006-01-02") + "~~" + endDate.Format("2006-01-02") + " (" + k1 + ") 班级收款明细"} |
|
|
|
xlsx.SetSheetRow("Sheet1", "A1", &titleList) |
|
|
|
titleList = []string{"年级", "班级", "预定总费用", "退款总计"} |
|
|
|
xlsx.SetSheetRow("Sheet1", "A1", &titleList) |
|
|
|
j := 2 //表头被第一行用了,只能从第二行开始 |
|
|
|
|
|
|
|
xlsx.SetSheetRow("Sheet1", "A2", &titleList) |
|
|
|
xlsx.MergeCell("Sheet1", "A1", "D1") //合并单元格 |
|
|
|
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("Sheet1", "A1", "D1", style) |
|
|
|
xlsx.SetColWidth("Sheet1", "A", "D", 20) |
|
|
|
|
|
|
|
j := 3 //表头前两行用了,只能从第三行开始 |
|
|
|
var sumClassNum = int64(0) |
|
|
|
var sumIncome, sumRefund = float64(0), float64(0) |
|
|
|
for k2, v2 := range v1 { |
|
|
|
if k2 == "" { |
|
|
|
//若年级为空,则为教师餐 |
|
|
@@ -1242,10 +1281,15 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD |
|
|
|
} |
|
|
|
for k3, v3 := range v2 { |
|
|
|
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{k2, k3, utils.Float64ToStr(v3["income"]), utils.Float64ToStr(v3["refund"])}) |
|
|
|
sumClassNum++ |
|
|
|
sumIncome += v3["income"] |
|
|
|
sumRefund += v3["income"] |
|
|
|
j++ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{ |
|
|
|
"合计", sumClassNum, sumIncome, sumRefund}) |
|
|
|
//将文件保存至服务器 |
|
|
|
err1 := xlsx.SaveAs(tmpDownloadPath) |
|
|
|
if err1 != nil { |
|
|
|