Browse Source

update

add_mode
DengBiao 1 year ago
parent
commit
6a7e4cdd5c
1 changed files with 18 additions and 13 deletions
  1. +18
    -13
      app/admin/svc/svc_data_statisstics.go

+ 18
- 13
app/admin/svc/svc_data_statisstics.go View File

@@ -467,11 +467,12 @@ func SelfSupportForSchoolDataStatisticsExport(req md.SelfSupportForSchoolDataSta
println("<<<<SelfSupportForSchoolDataStatisticsExport3>>>>>Error:::", err.Error())
return
}
diffDays := int(date1.Sub(date2).Hours() / 24)
diffDays := int(date2.Sub(date1).Hours() / 24)
var dates []string
for i := 0; i <= diffDays; i++ {
date := date1.AddDate(0, 0, i)
shopName := date.Format("2006-01-02")
dates = append(dates, shopName)
for _, vv := range m {
tmpDate, err1 := time.ParseInLocation("2006-01-02 15:04:05", vv.SelfSupportForSchoolOrd.FaceTime, time.Local)
if err1 != nil {
@@ -479,7 +480,7 @@ func SelfSupportForSchoolDataStatisticsExport(req md.SelfSupportForSchoolDataSta
println("<<<<SelfSupportForSchoolDataStatisticsExport3>>>>>Error:::", err1.Error())
return
}
fmt.Println(tmpDate.Format("2006-01-02"))
if shopName == tmpDate.Format("2006-01-02") {
if data[vv.Enterprise.Name] == nil {
data[vv.Enterprise.Name] = make(map[string]map[string]map[string]float64)
@@ -511,17 +512,21 @@ func SelfSupportForSchoolDataStatisticsExport(req md.SelfSupportForSchoolDataSta
xlsx.NewSheet(k) //1、新建表格
xlsx.CopySheet(1, sheetIndex)
j := 4 //表头前三行被占用了,只能从第四行开始
for kk, vv := range v {
xlsx.SetSheetRow(k, "A"+strconv.Itoa(j), &[]interface{}{kk,
vv["早餐"]["num"], vv["早餐"]["amount"],
vv["午餐"]["num"], vv["午餐"]["amount"],
vv["晚餐"]["num"], vv["晚餐"]["amount"],
vv["夜宵"]["num"], vv["夜宵"]["amount"],
vv["合计"]["num"], vv["合计"]["amount"],
})
j++
for _, date := range dates {
for kk, vv := range v {
if date == kk {
xlsx.SetSheetRow(k, "A"+strconv.Itoa(j), &[]interface{}{kk,
vv["早餐"]["num"], vv["早餐"]["amount"],
vv["午餐"]["num"], vv["午餐"]["amount"],
vv["晚餐"]["num"], vv["晚餐"]["amount"],
vv["夜宵"]["num"], vv["夜宵"]["amount"],
vv["合计"]["num"], vv["合计"]["amount"],
})
j++
}
sheetIndex++
}
}
sheetIndex++
}
xlsx.DeleteSheet("template") //删除模板表
//将文件保存至服务器


Loading…
Cancel
Save