Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
searchhotcrawler
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
zhiwei
searchhotcrawler
Commits
15c8f6d1
Commit
15c8f6d1
authored
May 04, 2018
by
zhiwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
推送时间修改
parent
58bf7554
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
20 deletions
+26
-20
src/main/java/com/zhiwei/searchhotcrawler/run/HotSearchRun.java
+1
-1
src/main/java/com/zhiwei/searchhotcrawler/timer/SendWeiboHotSearchRun.java
+11
-9
src/main/java/com/zhiwei/searchhotcrawler/timer/SendZhihuHotSearchRun.java
+14
-10
No files found.
src/main/java/com/zhiwei/searchhotcrawler/run/HotSearchRun.java
View file @
15c8f6d1
...
@@ -16,7 +16,7 @@ public class HotSearchRun {
...
@@ -16,7 +16,7 @@ public class HotSearchRun {
private
ScheduledExecutorService
scheduExec
;
private
ScheduledExecutorService
scheduExec
;
public
HotSearchRun
()
{
public
HotSearchRun
()
{
this
.
scheduExec
=
Executors
.
newScheduledThreadPool
(
1
);
this
.
scheduExec
=
Executors
.
newScheduledThreadPool
(
4
);
}
}
public
void
showTimer
()
{
public
void
showTimer
()
{
...
...
src/main/java/com/zhiwei/searchhotcrawler/timer/SendWeiboHotSearchRun.java
View file @
15c8f6d1
...
@@ -20,19 +20,21 @@ public class SendWeiboHotSearchRun extends Thread{
...
@@ -20,19 +20,21 @@ public class SendWeiboHotSearchRun extends Thread{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
List
<
DBObject
>
list
=
weiboHotSearchDAO
.
getWeiboHotOneHour
();
Calendar
calendar
=
Calendar
.
getInstance
();
Calendar
calendar
=
Calendar
.
getInstance
();
if
(
list
!=
null
&&
list
.
size
()>
0
){
int
hour
=
calendar
.
get
(
Calendar
.
HOUR_OF_DAY
);
for
(
DBObject
weibo
:
list
){
System
.
out
.
println
(
"微博推送,当前系统时间为:"
+
hour
);
String
title
=
weibo
.
get
(
"name"
).
toString
();
if
(
hour
>
6
&&
hour
<
23
){
String
time
=
TimeParse
.
dateFormartString
((
Date
)
weibo
.
get
(
"time"
),
"yyyy-MM-dd HH:mm:ss"
);
List
<
DBObject
>
list
=
weiboHotSearchDAO
.
getWeiboHotOneHour
();
String
url
=
weibo
.
get
(
"url"
).
toString
();
if
(
list
!=
null
&&
list
.
size
()>
0
){
if
(
calendar
.
get
(
Calendar
.
HOUR_OF_DAY
)
>
6
&&
calendar
.
get
(
Calendar
.
HOUR_OF_DAY
)
<
23
){
for
(
DBObject
weibo
:
list
){
String
title
=
weibo
.
get
(
"name"
).
toString
();
String
time
=
TimeParse
.
dateFormartString
((
Date
)
weibo
.
get
(
"time"
),
"yyyy-MM-dd HH:mm:ss"
);
String
url
=
weibo
.
get
(
"url"
).
toString
();
sendTemplateByUserIds
(
title
,
time
,
url
);
sendTemplateByUserIds
(
title
,
time
,
url
);
}
}
}
else
{
sendTemplateByUserIds
(
"最近一小时无数据"
,
TimeParse
.
dateFormartString
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
),
null
);
}
}
}
else
{
sendTemplateByUserIds
(
"最近一小时无数据"
,
TimeParse
.
dateFormartString
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
),
null
);
}
}
}
}
...
...
src/main/java/com/zhiwei/searchhotcrawler/timer/SendZhihuHotSearchRun.java
View file @
15c8f6d1
...
@@ -19,19 +19,23 @@ public class SendZhihuHotSearchRun extends Thread{
...
@@ -19,19 +19,23 @@ public class SendZhihuHotSearchRun extends Thread{
private
ZhihuHotSearchDAO
zhihuHotSearchDAO
=
new
ZhihuHotSearchDAO
();
private
ZhihuHotSearchDAO
zhihuHotSearchDAO
=
new
ZhihuHotSearchDAO
();
@Override
@Override
public
void
run
()
{
public
void
run
()
{
List
<
DBObject
>
list
=
zhihuHotSearchDAO
.
getZhiHuHotSearch
();
Calendar
calendar
=
Calendar
.
getInstance
();
Calendar
calendar
=
Calendar
.
getInstance
();
if
(
list
!=
null
&&
list
.
size
()>
0
){
int
hour
=
calendar
.
get
(
Calendar
.
HOUR_OF_DAY
);
for
(
DBObject
zhihu
:
list
){
System
.
out
.
println
(
"知乎推送,当前系统时间为:"
+
hour
);
String
title
=
zhihu
.
get
(
"display_query"
).
toString
();
if
(
hour
>
6
&&
hour
<
23
){
String
time
=
TimeParse
.
dateFormartString
((
Date
)
zhihu
.
get
(
"time"
),
"yyyy-MM-dd HH:mm:ss"
);
List
<
DBObject
>
list
=
zhihuHotSearchDAO
.
getZhiHuHotSearch
();
String
url
=
zhihu
.
get
(
"_id"
).
toString
();
if
(
list
!=
null
&&
list
.
size
()>
0
){
if
(
calendar
.
get
(
Calendar
.
HOUR_OF_DAY
)
>
6
&&
calendar
.
get
(
Calendar
.
HOUR_OF_DAY
)
<
23
){
for
(
DBObject
zhihu
:
list
){
sendTemplateByUserIds
(
title
,
time
,
url
);
String
title
=
zhihu
.
get
(
"display_query"
).
toString
();
String
time
=
TimeParse
.
dateFormartString
((
Date
)
zhihu
.
get
(
"time"
),
"yyyy-MM-dd HH:mm:ss"
);
String
url
=
zhihu
.
get
(
"_id"
).
toString
();
if
(
calendar
.
get
(
Calendar
.
HOUR_OF_DAY
)
>
6
&&
calendar
.
get
(
Calendar
.
HOUR_OF_DAY
)
<
23
){
sendTemplateByUserIds
(
title
,
time
,
url
);
}
}
}
}
else
{
sendTemplateByUserIds
(
"最近一小时无数据"
,
TimeParse
.
dateFormartString
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
),
null
);
}
}
}
else
{
sendTemplateByUserIds
(
"最近一小时无数据"
,
TimeParse
.
dateFormartString
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
),
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