Browse Source

update

tmp
DengBiao 9 months ago
parent
commit
42ab2738b3
1 changed files with 42 additions and 3 deletions
  1. +42
    -3
      app/admin/svc/svc_data_statisstics.go

+ 42
- 3
app/admin/svc/svc_data_statisstics.go View File

@@ -291,17 +291,56 @@ func SelfSupportForSchoolDataStatisticsExport(req md.SelfSupportForSchoolDataSta
for k, v := range data {
xlsx.NewSheet(k) //1、新建表格
xlsx.CopySheet(1, sheetIndex)
var userTotal, breakFastTotal, lunchTotal, dinnerTotal, supperTotal, totalTotal int64
var breakFastAmountTotal, lunchAmountTotal, dinnerAmountTotal, supperAmountTotal, totalAmountTotal float64
for kk, vv := range v {
xlsx.SetSheetRow(k, "A"+strconv.Itoa(j), &[]interface{}{vv["编号"]["id"], kk,
vv["早餐"]["num"], vv["早餐"]["amount"],
vv["午餐"]["num"], vv["午餐"]["amount"],
vv["晚餐"]["num"], vv["晚餐"]["amount"],
vv["夜宵"]["num"], vv["夜宵"]["amount"],
vv["未知"]["num"], vv["未知"]["amount"],
vv["合计"]["num"], vv["合计"]["amount"],
})
userTotal++
if vv["早餐"]["num"] != nil {
breakFastTotal += vv["早餐"]["num"].(int64)
}
if vv["午餐"]["num"] != nil {
lunchTotal += vv["午餐"]["num"].(int64)
}
if vv["晚餐"]["num"] != nil {
dinnerTotal += vv["晚餐"]["num"].(int64)
}
if vv["夜宵"]["num"] != nil {
supperTotal += vv["夜宵"]["num"].(int64)
}
if vv["合计"]["num"] != nil {
totalTotal += vv["合计"]["num"].(int64)
}
if vv["早餐"]["amount"] != nil {
breakFastAmountTotal += vv["早餐"]["amount"].(float64)
}
if vv["午餐"]["amount"] != nil {
lunchAmountTotal += vv["午餐"]["amount"].(float64)
}
if vv["晚餐"]["amount"] != nil {
dinnerAmountTotal += vv["晚餐"]["amount"].(float64)
}
if vv["夜宵"]["amount"] != nil {
supperAmountTotal += vv["夜宵"]["amount"].(float64)
}
if vv["合计"]["amount"] != nil {
totalAmountTotal += vv["合计"]["amount"].(float64)
}
j++
}
xlsx.SetSheetRow(k, "A"+strconv.Itoa(j), &[]interface{}{"总计", userTotal,
breakFastTotal, breakFastAmountTotal,
lunchTotal, lunchAmountTotal,
dinnerTotal, dinnerAmountTotal,
supperTotal, supperAmountTotal,
totalTotal, totalAmountTotal,
})
sheetIndex++
}
xlsx.DeleteSheet("template") //删除模板表
@@ -381,12 +420,12 @@ func SelfSupportForSchoolDataStatisticsExport(req md.SelfSupportForSchoolDataSta
xlsx.SetSheetRow("", "A1", &titleList)
sheetIndex := 2 //第一个表是模板表
for k, v := range data {
xlsx.SetSheetRow(k, "A1"+strconv.Itoa(1), &[]interface{}{"商 家 分 餐 数 据 统 计 表 " + "(" + req.StartDate + "至" + req.EndDate + ")"})
if k == "" {
k = "未知"
}
xlsx.NewSheet(k) //1、新建表格
xlsx.CopySheet(1, sheetIndex)
xlsx.SetSheetRow(k, "A1", &[]interface{}{"商 家 分 餐 数 据 统 计 表 " + "(" + req.StartDate + "至" + req.EndDate + ")"})
j := 4 //表头前三行被占用了,只能从第四行开始
for kk, vv := range v {
if kk == "" {
@@ -542,7 +581,7 @@ func SelfSupportForSchoolDataStatisticsExport(req md.SelfSupportForSchoolDataSta
//查询出所有的设备
var deviceList []*model.Device
if req.EnterpriseId == 0 {
err := db.Db.Where("enterprise_id != 0").Find(&deviceList)
err := db.Db.Where("enterprise_id != 0").Asc("id").Find(&deviceList)
if err != nil {
logx.Error(err)
println("<<<<SelfSupportForSchoolDataStatisticsExport4>>>>>1111Error:::", err.Error())


Loading…
Cancel
Save