DengBiao пре 1 година
родитељ
комит
9bee0ca5c7
2 измењених фајлова са 23 додато и 6 уклоњено
  1. +14
    -6
      app/admin/svc/svc_data_statisstics.go
  2. +9
    -0
      app/db/db_self_support_for_school_ord.go

+ 14
- 6
app/admin/svc/svc_data_statisstics.go Прегледај датотеку

@@ -534,6 +534,8 @@ func SelfSupportForSchoolDataStatisticsExport(req md.SelfSupportForSchoolDataSta
break
case 4:
//设备就餐数据统计表
fileName = "设备就餐数据统计_" + utils.Int64ToStr(now.UnixMilli()) + ".zip"
downloadPath = "/export/self_support_for_school/" + fileName

//查询出所有的设备
var deviceList []*model.Device
@@ -573,7 +575,7 @@ func SelfSupportForSchoolDataStatisticsExport(req md.SelfSupportForSchoolDataSta
var xlsFileName, xlsDownloadPath []string
for _, v := range deviceList {
deviceListMapping[v.DeviceSn] = *v
var m []*db.SelfSupportForSchoolOrdWithUserIdentity
var m []*db.SelfSupportForSchoolOrdWithUserIdentityV2
sess := db.Db.Where("device_sn = ?", v.DeviceSn).Desc("self_support_for_school_ord.id")
if req.EnterpriseId != 0 {
sess.And("self_support_for_school_ord.enterprise_id =?", req.EnterpriseId)
@@ -584,7 +586,7 @@ func SelfSupportForSchoolDataStatisticsExport(req md.SelfSupportForSchoolDataSta
if req.EndDate != "" {
sess.And("self_support_for_school_ord.face_time <= ?", req.EndDate)
}
_, err = sess.Join("LEFT", "enterprise", "enterprise.id = self_support_for_school_ord.enterprise_id").FindAndCount(&m)
_, err = sess.Join("LEFT", "enterprise", "self_support_for_school_ord.enterprise_id = enterprise.id").FindAndCount(&m)
if err != nil {
logx.Error(err)
println("<<<<SelfSupportForSchoolDataStatisticsExport4>>>>>Error:::", err.Error())
@@ -630,21 +632,27 @@ func SelfSupportForSchoolDataStatisticsExport(req md.SelfSupportForSchoolDataSta
println("<<<<SelfSupportForSchoolDataStatisticsExport4>>>>>Error:::", err.Error())
panic(err)
}
xlsx.MergeCell(k2, "A1", "C1") //合并单元格
xlsx.SetCellStyle(k2, "A1", "C1", style)
xlsx.SetColWidth(k2, "A", "C", 20)
j := 3 //表头前两行用了,只能从第三行开始

for i := 0; i <= diffDays; i++ {
date := date1.AddDate(0, 0, i).Format("2006-01-02")
if vv[date] == nil {
if vv[date] != nil {
xlsx.SetSheetRow(k2, "A"+strconv.Itoa(j), &[]interface{}{date, vv[date]["num"], vv[date]["amount"]})
sumNum += vv[date]["num"]
sumAmount += vv[date]["amount"]
j++
} else {
xlsx.SetSheetRow(k2, "A"+strconv.Itoa(j), &[]interface{}{date, 0, 0})
}
j++
}

xlsx.SetSheetRow(k2, "A"+strconv.Itoa(j), &[]interface{}{
"合计", sumNum, sumAmount})

xlsx.DeleteSheet("Sheet1") //TODO::只能放这里删除
//将文件保存至服务器
err1 := xlsx.SaveAs(tmpDownloadPath)
if err1 != nil {
@@ -652,9 +660,9 @@ func SelfSupportForSchoolDataStatisticsExport(req md.SelfSupportForSchoolDataSta
println("<<<<SelfSupportForSchoolDataStatisticsExport4>>>>>Error:::", err1.Error())
panic(err1)
}
xlsDownloadPath = append(xlsDownloadPath, tmpDownloadPath)
xlsFileName = append(xlsFileName, tmpFileName)
}
xlsDownloadPath = append(xlsDownloadPath, tmpDownloadPath)
xlsFileName = append(xlsFileName, tmpFileName)
}

archive, err := os.Create("./static" + downloadPath) //第一步,创建 zip 文件


+ 9
- 0
app/db/db_self_support_for_school_ord.go Прегледај датотеку

@@ -106,3 +106,12 @@ type SelfSupportForSchoolOrdWithUserIdentity struct {
func (SelfSupportForSchoolOrdWithUserIdentity) TableName() string {
return "self_support_for_school_ord"
}

type SelfSupportForSchoolOrdWithUserIdentityV2 struct {
model.SelfSupportForSchoolOrd `xorm:"extends"`
model.Enterprise `xorm:"extends"`
}

func (SelfSupportForSchoolOrdWithUserIdentityV2) TableName() string {
return "self_support_for_school_ord"
}

Loading…
Откажи
Сачувај