Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
indicators
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhangkb
indicators
Commits
263a7b93
Commit
263a7b93
authored
Jul 29, 2020
by
hzc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改了返回集合,插入了为零的结果
parent
ac9e1ecc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
4 deletions
+44
-4
LoggingEventServiceImpl.java
...bile/indicators/service/impl/LoggingEventServiceImpl.java
+44
-4
No files found.
src/main/java/com/keymobile/indicators/service/impl/LoggingEventServiceImpl.java
View file @
263a7b93
...
...
@@ -46,11 +46,15 @@ public class LoggingEventServiceImpl implements LoggingEventService {
calendar
.
add
(
calendar
.
DATE
,-
30
);
startDateTime
=
calendar
.
getTimeInMillis
();
}
endDateTime
=
endDateTime
+
60
*
60
*
24
*
1000
;
//加一天
logQuery
.
setStartTime
(
startDateTime
);
logQuery
.
setEndTime
(
endDateTime
);
//查出符合条件的数据然后再判断具体天数的数量
List
<
LogStatistics
>
logStatisticsList
=
loggingEventMapper
.
findVisitCount
(
logQuery
);
return
logStatisticsList
;
return
this
.
trimResults
(
logStatisticsList
,
startDateTime
,
endDateTime
);
}
@Override
...
...
@@ -69,12 +73,17 @@ public class LoggingEventServiceImpl implements LoggingEventService {
Calendar
calendar
=
new
GregorianCalendar
();
calendar
.
setTimeInMillis
(
endDateTime
);
calendar
.
add
(
calendar
.
DATE
,-
30
);
startDateTime
=
calendar
.
getTimeInMillis
();
}
endDateTime
=
endDateTime
+
60
*
60
*
24
*
1000
;
//加一天
logQuery
.
setStartTime
(
startDateTime
);
logQuery
.
setEndTime
(
endDateTime
);
List
<
LogStatistics
>
LogStatisticsList
=
loggingEventMapper
.
findVisitUserCount
(
logQuery
);
return
LogStatisticsList
;
List
<
LogStatistics
>
logStatisticsList
=
loggingEventMapper
.
findVisitUserCount
(
logQuery
);
return
this
.
trimResults
(
logStatisticsList
,
startDateTime
,
endDateTime
);
}
@Override
...
...
@@ -95,6 +104,37 @@ public class LoggingEventServiceImpl implements LoggingEventService {
return
loggingEventMapper
.
findVisitMsg
(
logQuery
);
}
private
List
<
LogStatistics
>
trimResults
(
List
<
LogStatistics
>
logStatisticsList
,
Long
startTime
,
Long
endTime
){
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
Map
<
String
,
Long
>
map
=
new
HashMap
<>();
for
(
int
i
=
0
;
i
<
logStatisticsList
.
size
();
i
++){
String
dateTimeStr
=
logStatisticsList
.
get
(
i
).
getDateTime
();
map
.
put
(
dateTimeStr
,
logStatisticsList
.
get
(
i
).
getCount
());
}
Calendar
calendar1
=
new
GregorianCalendar
();
calendar1
.
setTimeInMillis
(
startTime
);
Calendar
calendar2
=
new
GregorianCalendar
();
calendar2
.
setTimeInMillis
(
endTime
);
List
<
LogStatistics
>
values
=
new
ArrayList
<>();
while
(
calendar1
.
getTimeInMillis
()<
calendar2
.
getTimeInMillis
()){
String
dateStr
=
simpleDateFormat
.
format
(
calendar1
.
getTime
());
LogStatistics
logStatistics
=
new
LogStatistics
();
logStatistics
.
setDateTime
(
dateStr
);
Long
count
=
map
.
get
(
dateStr
);
if
(
count
==
null
){
logStatistics
.
setCount
(
0
l
);
}
else
{
logStatistics
.
setCount
(
count
);
}
values
.
add
(
logStatistics
);
calendar1
.
add
(
calendar1
.
DATE
,
1
);
}
return
values
;
}
private
Long
getDateTime
(
String
dateStr
){
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
Long
dateTime
=
null
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment