|
|
@@ -1778,6 +1778,77 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD |
|
|
|
//将文件保存至服务器 |
|
|
|
xlsx.SaveAs("./static" + downloadPath) |
|
|
|
break |
|
|
|
case 10: |
|
|
|
//就餐数据统计表 |
|
|
|
xlsx, _ := excelize.OpenFile("./static/template/央厨学校(就餐数据统计表).xlsx") |
|
|
|
fileName = "就餐数据统计表_" + utils.Int64ToStr(now.UnixMilli()) + ".xlsx" |
|
|
|
downloadPath = "/export/central_kitchen_for_school/" + fileName |
|
|
|
|
|
|
|
var list = map[string]map[string]map[string]float64{} |
|
|
|
var dates []string |
|
|
|
|
|
|
|
if req.StartDate != "" { |
|
|
|
centralKitchenForSchoolUserWithDayDb := db.CentralKitchenForSchoolUserWithDayDb{} |
|
|
|
centralKitchenForSchoolUserWithDayDb.Set(0) |
|
|
|
sTime, _ := time.ParseInLocation("2006-01-02 15:04:05", req.StartDate, time.Local) |
|
|
|
eTime, _ := time.ParseInLocation("2006-01-02 15:04:05", req.EndDate, time.Local) |
|
|
|
diffDays := int(eTime.Sub(sTime).Hours() / 24) |
|
|
|
for i := 0; i <= diffDays; i++ { |
|
|
|
date := sTime.AddDate(0, 0, i) |
|
|
|
dateName := date.Format("2006-01-02") |
|
|
|
dates = append(dates, dateName) |
|
|
|
for _, vv := range req.MealKindList { |
|
|
|
tmpSum, err := centralKitchenForSchoolUserWithDayDb.SumCentralKitchenForSchoolUserWithDayByKind(req.EnterpriseId, dateName, dateName, vv, enum.CentralKitchenForSchoolUserWithDayStateForCancel) |
|
|
|
if err != nil { |
|
|
|
logx.Error(err) |
|
|
|
println("<<<<CentralKitchenForSchoolDataStatisticsExport9>>>>>Error:::", err.Error()) |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
tmpCount, err := centralKitchenForSchoolUserWithDayDb.CountCentralKitchenForSchoolUserWithDayByKind(req.EnterpriseId, dateName, dateName, vv, enum.CentralKitchenForSchoolUserWithDayStateForCancel) |
|
|
|
if err != nil { |
|
|
|
logx.Error(err) |
|
|
|
println("<<<<CentralKitchenForSchoolDataStatisticsExport9>>>>>Error:::", err.Error()) |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
if list[dateName] == nil { |
|
|
|
list[dateName] = map[string]map[string]float64{} |
|
|
|
} |
|
|
|
if list[dateName][enum.CentralKitchenForSchoolUserWithDayKind(vv).String()] == nil { |
|
|
|
list[dateName][enum.CentralKitchenForSchoolUserWithDayKind(vv).String()] = map[string]float64{} |
|
|
|
} |
|
|
|
|
|
|
|
list[dateName][enum.CentralKitchenForSchoolUserWithDayKind(vv).String()]["sum"] = tmpSum |
|
|
|
list[dateName][enum.CentralKitchenForSchoolUserWithDayKind(vv).String()]["count"] = float64(tmpCount) |
|
|
|
list[dateName]["合计"]["sum"] += tmpSum |
|
|
|
list[dateName]["合计"]["count"] += float64(tmpCount) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
xlsx.SetSheetRow("", "A1", &titleList) |
|
|
|
sheetIndex := 2 //第一个表是模板表 |
|
|
|
xlsx.NewSheet("sheet1") //1、新建表格 |
|
|
|
xlsx.CopySheet(1, sheetIndex) |
|
|
|
j := 4 //表头前三行被占用了,只能从第四行开始 |
|
|
|
|
|
|
|
for _, date := range dates { |
|
|
|
for kk, v := range list { |
|
|
|
if date == kk { |
|
|
|
xlsx.SetSheetRow("sheet1", "A"+strconv.Itoa(j), &[]interface{}{kk, |
|
|
|
v["早餐"]["count"], v["早餐"]["sum"], |
|
|
|
v["午餐"]["count"], v["午餐"]["sum"], |
|
|
|
v["晚餐"]["count"], v["晚餐"]["sum"], |
|
|
|
v["合计"]["count"], v["合计"]["sum"], |
|
|
|
}) |
|
|
|
j++ |
|
|
|
} |
|
|
|
sheetIndex++ |
|
|
|
} |
|
|
|
} |
|
|
|
xlsx.DeleteSheet("template") //删除模板表 |
|
|
|
//将文件保存至服务器 |
|
|
|
xlsx.SaveAs("./static" + downloadPath) |
|
|
|
break |
|
|
|
} |
|
|
|
|
|
|
|
//新增数据 |
|
|
|