From 9297bb602a63bcf77042e862b3d44b1bb80846f6 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 17 Nov 2021 16:00:58 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=9A=84sheet=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- routers/repo/user_data_analysis.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/routers/repo/user_data_analysis.go b/routers/repo/user_data_analysis.go index 8edecf836..666a3a342 100755 --- a/routers/repo/user_data_analysis.go +++ b/routers/repo/user_data_analysis.go @@ -68,8 +68,10 @@ func QueryUserStaticDataPage(ctx *context.Context) { if IsReturnFile { //writer exec file. xlsx := excelize.NewFile() + xlsx.DeleteSheet("Sheet1") sheetName := ctx.Tr("user.static.sheetname") index := xlsx.NewSheet(sheetName) + dataHeader := map[string]string{ "A1": ctx.Tr("user.static.id"), "B1": ctx.Tr("user.static.name"), From d10b78741c4f4fdf06a359d40f7f9f3e6f75194e Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 17 Nov 2021 17:07:08 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 61821f973..2dbd86747 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -142,6 +142,22 @@ func QueryUserStaticData(startTime int64, endTime int64) []*UserBusinessAnalysis return userBusinessAnalysisReturnList } +func getLastCountDate() int64 { + statictisSess := xStatistic.NewSession() + defer statictisSess.Close() + statictisSess.Limit(1, 0) + userBusinessAnalysisList := make([]*UserBusinessAnalysis, 0) + if err := statictisSess.Table("user_business_analysis").OrderBy("countdate desc").Limit(1, 0). + Find(&userBusinessAnalysisList); err == nil { + for _, userRecord := range userBusinessAnalysisList { + return userRecord.CountDate - 10000 + } + } + currentTimeNow := time.Now() + pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, currentTimeNow.Location()) + return pageStartTime.Unix() +} + func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBusinessAnalysis, int64) { log.Info("query startTime =" + fmt.Sprint(opts.StartTime) + " endTime=" + fmt.Sprint(opts.EndTime)) @@ -149,8 +165,8 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus defer statictisSess.Close() currentTimeNow := time.Now() - pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, currentTimeNow.Location()) - pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()) + pageStartTime := getLastCountDate() + pageEndTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 23, 59, 59, 0, currentTimeNow.Location()).Unix() var cond = builder.NewCond() if len(opts.UserName) > 0 { @@ -159,10 +175,10 @@ func QueryUserStaticDataPage(opts *UserBusinessAnalysisQueryOptions) ([]*UserBus ) } cond = cond.And( - builder.Gte{"count_date": pageStartTime.Unix()}, + builder.Gte{"count_date": pageStartTime}, ) cond = cond.And( - builder.Lte{"count_date": pageEndTime.Unix()}, + builder.Lte{"count_date": pageEndTime}, ) count, err := statictisSess.Where(cond).Count(new(UserBusinessAnalysis)) From c5e6c7e82f39d66a8513cca7aab4b959a8d146e5 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 17 Nov 2021 17:18:30 +0800 Subject: [PATCH 3/3] =?UTF-8?q?-m=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user_business_analysis.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/models/user_business_analysis.go b/models/user_business_analysis.go index 2dbd86747..2fe38c792 100644 --- a/models/user_business_analysis.go +++ b/models/user_business_analysis.go @@ -147,11 +147,13 @@ func getLastCountDate() int64 { defer statictisSess.Close() statictisSess.Limit(1, 0) userBusinessAnalysisList := make([]*UserBusinessAnalysis, 0) - if err := statictisSess.Table("user_business_analysis").OrderBy("countdate desc").Limit(1, 0). + if err := statictisSess.Table("user_business_analysis").OrderBy("count_date desc").Limit(1, 0). Find(&userBusinessAnalysisList); err == nil { for _, userRecord := range userBusinessAnalysisList { return userRecord.CountDate - 10000 } + } else { + log.Info("query error." + err.Error()) } currentTimeNow := time.Now() pageStartTime := time.Date(currentTimeNow.Year(), currentTimeNow.Month(), currentTimeNow.Day(), 0, 0, 0, 0, currentTimeNow.Location())