|
|
@@ -1424,23 +1424,54 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
var list = map[string]int64{} |
|
|
|
var list = map[string]map[string]int64{} |
|
|
|
centralKitchenForSchoolUserWithDayDb := db.CentralKitchenForSchoolUserWithDayDb{} |
|
|
|
centralKitchenForSchoolUserWithDayDb.Set(0) |
|
|
|
for _, v := range m { |
|
|
|
if list[v.Enterprise.Name] == nil { |
|
|
|
list[v.Enterprise.Name] = map[string]int64{} |
|
|
|
} |
|
|
|
count, err2 := centralKitchenForSchoolUserWithDayDb.CountCentralKitchenForSchoolUserWithDayByOrdNo(v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo, enum.CentralKitchenForSchoolUserWithDayStateForCancel) |
|
|
|
if err2 != nil { |
|
|
|
logx.Error(err) |
|
|
|
println("<<<<SelfSupportForSchoolDataStatisticsExport3>>>>>Error:::", err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
count1, err2 := centralKitchenForSchoolUserWithDayDb.CountCentralKitchenForSchoolUserWithDayByOrdNoAndKind(v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo, enum.CentralKitchenForSchoolUserWithDayKindForBreakfast, enum.CentralKitchenForSchoolUserWithDayStateForCancel) |
|
|
|
if err2 != nil { |
|
|
|
logx.Error(err) |
|
|
|
println("<<<<SelfSupportForSchoolDataStatisticsExport3>>>>>Error:::", err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
count2, err2 := centralKitchenForSchoolUserWithDayDb.CountCentralKitchenForSchoolUserWithDayByOrdNoAndKind(v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo, enum.CentralKitchenForSchoolUserWithDayKindForLunch, enum.CentralKitchenForSchoolUserWithDayStateForCancel) |
|
|
|
if err2 != nil { |
|
|
|
logx.Error(err) |
|
|
|
println("<<<<SelfSupportForSchoolDataStatisticsExport3>>>>>Error:::", err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
count3, err2 := centralKitchenForSchoolUserWithDayDb.CountCentralKitchenForSchoolUserWithDayByOrdNoAndKind(v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo, enum.CentralKitchenForSchoolUserWithDayKindForDinner, enum.CentralKitchenForSchoolUserWithDayStateForCancel) |
|
|
|
if err2 != nil { |
|
|
|
logx.Error(err) |
|
|
|
println("<<<<SelfSupportForSchoolDataStatisticsExport3>>>>>Error:::", err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
list[v.Enterprise.Name]["count"] += count |
|
|
|
list[v.Enterprise.Name][enum.CentralKitchenForSchoolUserWithDayKind(enum.CentralKitchenForSchoolUserWithDayKindForBreakfast).String()] += count1 |
|
|
|
list[v.Enterprise.Name][enum.CentralKitchenForSchoolUserWithDayKind(enum.CentralKitchenForSchoolUserWithDayKindForLunch).String()] += count2 |
|
|
|
list[v.Enterprise.Name][enum.CentralKitchenForSchoolUserWithDayKind(enum.CentralKitchenForSchoolUserWithDayKindForDinner).String()] += count3 |
|
|
|
time.Sleep(50 * time.Millisecond) // 50毫秒 |
|
|
|
list[v.Enterprise.Name] += count |
|
|
|
} |
|
|
|
|
|
|
|
titleList = []string{startDate.Format("2006-01-02") + "~~" + endDate.Format("2006-01-02") + " 预定数量统计表"} |
|
|
|
xlsx.SetSheetRow("Sheet1", "A1", &titleList) |
|
|
|
titleList = []string{"学校名称", "预定总数"} |
|
|
|
|
|
|
|
titleList = []string{"学校名称", "预定总数", |
|
|
|
enum.CentralKitchenForSchoolUserWithDayKind(enum.CentralKitchenForSchoolUserWithDayKindForBreakfast).String(), |
|
|
|
enum.CentralKitchenForSchoolUserWithDayKind(enum.CentralKitchenForSchoolUserWithDayKindForLunch).String(), |
|
|
|
enum.CentralKitchenForSchoolUserWithDayKind(enum.CentralKitchenForSchoolUserWithDayKindForDinner).String(), |
|
|
|
} |
|
|
|
xlsx.SetSheetRow("Sheet1", "A2", &titleList) |
|
|
|
|
|
|
|
xlsx.MergeCell("Sheet1", "A1", "B1") //合并单元格 |
|
|
@@ -1455,13 +1486,22 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD |
|
|
|
|
|
|
|
j := 3 //表头前两行用了,只能从第三行开始 |
|
|
|
total := int64(0) |
|
|
|
total1 := int64(0) |
|
|
|
total2 := int64(0) |
|
|
|
total3 := int64(0) |
|
|
|
for k, v := range list { |
|
|
|
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{k, v}) |
|
|
|
total += v |
|
|
|
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{k, v["count"], |
|
|
|
v[enum.CentralKitchenForSchoolUserWithDayKind(enum.CentralKitchenForSchoolUserWithDayKindForBreakfast).String()], |
|
|
|
v[enum.CentralKitchenForSchoolUserWithDayKind(enum.CentralKitchenForSchoolUserWithDayKindForLunch).String()], |
|
|
|
v[enum.CentralKitchenForSchoolUserWithDayKind(enum.CentralKitchenForSchoolUserWithDayKindForDinner).String()]}) |
|
|
|
total += v["count"] |
|
|
|
total1 += v[enum.CentralKitchenForSchoolUserWithDayKind(enum.CentralKitchenForSchoolUserWithDayKindForBreakfast).String()] |
|
|
|
total2 += v[enum.CentralKitchenForSchoolUserWithDayKind(enum.CentralKitchenForSchoolUserWithDayKindForLunch).String()] |
|
|
|
total3 += v[enum.CentralKitchenForSchoolUserWithDayKind(enum.CentralKitchenForSchoolUserWithDayKindForDinner).String()] |
|
|
|
j++ |
|
|
|
} |
|
|
|
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{ |
|
|
|
"合计", total}) |
|
|
|
"合计", total, total1, total2, total3}) |
|
|
|
//将文件保存至服务器 |
|
|
|
xlsx.SaveAs("./static" + downloadPath) |
|
|
|
break |
|
|
|