DengBiao преди 1 година
родител
ревизия
e74dd2810a
променени са 2 файла, в които са добавени 52 реда и са изтрити 6 реда
  1. +46
    -6
      app/admin/svc/svc_data_statisstics.go
  2. +6
    -0
      app/db/db_central_kitchen_for_school_user_with_day.go

+ 46
- 6
app/admin/svc/svc_data_statisstics.go Целия файл

@@ -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


+ 6
- 0
app/db/db_central_kitchen_for_school_user_with_day.go Целия файл

@@ -70,6 +70,12 @@ func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb
return count, nil
}

func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb) CountCentralKitchenForSchoolUserWithDayByOrdNoAndKind(ordNo string, kind, state int) (count int64, err error) {
var m model.CentralKitchenForSchoolUserWithDay
count, err = centralKitchenForSchoolUserWithDayDb.Db.Where("ord_no =?", ordNo).And("kind =?", kind).And("state !=?", state).Count(&m)
return count, nil
}

func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb) FindCentralKitchenForSchoolUserWithDayByOrdNoAndState(ordNo string, state int) (*[]model.CentralKitchenForSchoolUserWithDay, error) {
var m []model.CentralKitchenForSchoolUserWithDay
if err := centralKitchenForSchoolUserWithDayDb.Db.Where("ord_no =?", ordNo).And("state =?", state).Desc("id").Find(&m); err != nil {


Зареждане…
Отказ
Запис