Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
datamanage
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
shenjinzhu
datamanage
Commits
f96b6266
Commit
f96b6266
authored
Dec 26, 2017
by
shenjinzhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交最新
parent
ddcd0fc0
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
138 additions
and
125 deletions
+138
-125
src/main/java/com/zhiwei/manage/dao/MessageDao.java
+4
-4
src/main/java/com/zhiwei/manage/dao/MessageDaoImpl.java
+31
-30
src/main/java/com/zhiwei/manage/dao/TemplateDao.java
+3
-3
src/main/java/com/zhiwei/manage/dao/TemplateDaoImpl.java
+29
-47
src/main/java/com/zhiwei/manage/handle/DbDepot.java
+6
-7
src/main/java/com/zhiwei/manage/handle/MainThread.java
+40
-7
src/main/java/com/zhiwei/manage/service/MessageService.java
+2
-2
src/main/java/com/zhiwei/manage/service/MessageServiceImpl.java
+6
-6
src/main/java/com/zhiwei/manage/service/TemplateService.java
+2
-2
src/main/java/com/zhiwei/manage/service/TemplateServiceImpl.java
+5
-10
src/main/java/com/zhiwei/manage/servlet/MessageConteoller.java
+7
-5
src/main/java/com/zhiwei/manage/servlet/TemplateController.java
+3
-2
No files found.
src/main/java/com/zhiwei/manage/dao/MessageDao.java
View file @
f96b6266
...
...
@@ -8,17 +8,17 @@ public interface MessageDao {
public
String
insert
(
Message
message
);
public
String
update
(
Message
message
);
public
String
update
(
Message
message
,
String
pt
);
public
List
<
Message
>
findAll
(
int
pageNo
,
int
pageSize
,
String
pt
);
public
List
<
Message
>
findByTmpName
(
String
templateName
,
int
pageNo
,
int
pageSize
,
String
pt
);
public
boolean
delete
(
List
<
String
>
MessageId
);
public
boolean
delete
(
List
<
String
>
MessageId
,
String
pt
);
public
int
allCount
();
public
int
allCount
(
String
pt
);
public
int
findByTmpCount
(
String
templateName
);
public
int
findByTmpCount
(
String
templateName
,
String
pt
);
public
List
<
Message
>
findByHandle
(
int
pageNo
,
int
pageSize
,
boolean
handle
,
String
tempName
,
String
pt
);
...
...
src/main/java/com/zhiwei/manage/dao/MessageDaoImpl.java
View file @
f96b6266
...
...
@@ -37,12 +37,12 @@ public class MessageDaoImpl implements MessageDao {
}
@Override
public
String
update
(
Message
message
)
{
public
String
update
(
Message
message
,
String
pt
)
{
DBCollection
con
=
null
;
if
(
DbDepot
.
dbCons
.
get
(
"msg"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
"msg"
);
if
(
DbDepot
.
dbCons
.
get
(
pt
+
"msg"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
pt
+
"msg"
);
}
else
{
con
=
dbDepot
.
getDBCollection
(
"msg"
);
con
=
dbDepot
.
getDBCollection
(
"msg"
,
pt
);
}
if
(
con
==
null
)
{
return
null
;
...
...
@@ -66,14 +66,15 @@ public class MessageDaoImpl implements MessageDao {
public
List
<
Message
>
findAll
(
int
pageNo
,
int
pageSize
,
String
pt
)
{
List
<
Message
>
msgList
=
new
ArrayList
<
Message
>();
DBCollection
con
=
null
;
if
(
DbDepot
.
dbCons
.
get
(
"msg"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
"msg"
);
if
(
DbDepot
.
dbCons
.
get
(
pt
+
"msg"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
pt
+
"msg"
);
}
else
{
con
=
dbDepot
.
getDBCollection
(
"msg"
);
con
=
dbDepot
.
getDBCollection
(
"msg"
,
pt
);
}
if
(
con
==
null
)
{
return
null
;
}
System
.
out
.
println
(
pt
);
DBCursor
cursor
=
con
.
find
(
new
BasicDBObject
(
"pt"
,
pt
).
append
(
"handle"
,
false
))
.
skip
((
pageNo
-
1
)
*
pageSize
).
limit
(
pageSize
).
sort
(
new
BasicDBObject
(
"createDate"
,
-
1
));
while
(
cursor
.
hasNext
())
{
...
...
@@ -89,10 +90,10 @@ public class MessageDaoImpl implements MessageDao {
public
List
<
Message
>
findByTmpName
(
String
templateName
,
int
pageNo
,
int
pageSize
,
String
pt
)
{
List
<
Message
>
msgList
=
new
ArrayList
<
Message
>();
DBCollection
con
=
null
;
if
(
DbDepot
.
dbCons
.
get
(
"msg"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
"msg"
);
if
(
DbDepot
.
dbCons
.
get
(
pt
+
"msg"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
pt
+
"msg"
);
}
else
{
con
=
dbDepot
.
getDBCollection
(
"msg"
);
con
=
dbDepot
.
getDBCollection
(
"msg"
,
pt
);
}
if
(
con
==
null
)
{
return
null
;
...
...
@@ -116,12 +117,12 @@ public class MessageDaoImpl implements MessageDao {
}
@Override
public
boolean
delete
(
List
<
String
>
messageId
)
{
public
boolean
delete
(
List
<
String
>
messageId
,
String
pt
)
{
DBCollection
con
=
null
;
if
(
DbDepot
.
dbCons
.
get
(
"msg"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
"msg"
);
if
(
DbDepot
.
dbCons
.
get
(
pt
+
"msg"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
pt
+
"msg"
);
}
else
{
con
=
dbDepot
.
getDBCollection
(
"msg"
);
con
=
dbDepot
.
getDBCollection
(
"msg"
,
pt
);
}
if
(
con
==
null
)
{
return
false
;
...
...
@@ -133,34 +134,34 @@ public class MessageDaoImpl implements MessageDao {
}
@Override
public
int
allCount
()
{
public
int
allCount
(
String
pt
)
{
DBCollection
con
=
null
;
if
(
DbDepot
.
dbCons
.
get
(
"msg"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
"msg"
);
if
(
DbDepot
.
dbCons
.
get
(
pt
+
"msg"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
pt
+
"msg"
);
}
else
{
con
=
dbDepot
.
getDBCollection
(
"msg"
);
con
=
dbDepot
.
getDBCollection
(
"msg"
,
pt
);
}
if
(
con
==
null
)
{
return
0
;
}
return
(
int
)
con
.
count
(
new
BasicDBObject
(
"handle"
,
false
).
append
(
"pt"
,
DbDepot
.
nowP
t
));
return
(
int
)
con
.
count
(
new
BasicDBObject
(
"handle"
,
false
).
append
(
"pt"
,
p
t
));
// return (int)
// mongo.count(Query.query(Criteria.where("handle").is(false)),
// Message.class);
}
@Override
public
int
findByTmpCount
(
String
templateName
)
{
public
int
findByTmpCount
(
String
templateName
,
String
pt
)
{
DBCollection
con
=
null
;
if
(
DbDepot
.
dbCons
.
get
(
"msg"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
"msg"
);
if
(
DbDepot
.
dbCons
.
get
(
pt
+
"msg"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
pt
+
"msg"
);
}
else
{
con
=
dbDepot
.
getDBCollection
(
"msg"
);
con
=
dbDepot
.
getDBCollection
(
"msg"
,
pt
);
}
if
(
con
==
null
)
{
return
0
;
}
return
(
int
)
con
.
count
(
new
BasicDBObject
(
"templateName"
,
new
BasicDBObject
(
"$regex"
,
templateName
)).
append
(
"pt"
,
DbDepot
.
nowP
t
));
return
(
int
)
con
.
count
(
new
BasicDBObject
(
"templateName"
,
new
BasicDBObject
(
"$regex"
,
templateName
)).
append
(
"pt"
,
p
t
));
// return (int)
// mongo.count(Query.query(Criteria.where("templateName").regex(templateName)),
// Message.class);
...
...
@@ -169,10 +170,10 @@ public class MessageDaoImpl implements MessageDao {
@Override
public
List
<
Message
>
findByHandle
(
int
pageNo
,
int
pageSize
,
boolean
handle
,
String
tempName
,
String
pt
)
{
DBCollection
con
=
null
;
if
(
DbDepot
.
dbCons
.
get
(
"msg"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
"msg"
);
if
(
DbDepot
.
dbCons
.
get
(
pt
+
"msg"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
pt
+
"msg"
);
}
else
{
con
=
dbDepot
.
getDBCollection
(
"msg"
);
con
=
dbDepot
.
getDBCollection
(
"msg"
,
pt
);
}
if
(
con
==
null
)
{
return
null
;
...
...
@@ -207,10 +208,10 @@ public class MessageDaoImpl implements MessageDao {
@Override
public
int
findByHandleCount
(
int
pageNo
,
int
pageSize
,
boolean
handle
,
String
tempName
,
String
pt
)
{
DBCollection
con
=
null
;
if
(
DbDepot
.
dbCons
.
get
(
"msg"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
"msg"
);
if
(
DbDepot
.
dbCons
.
get
(
pt
+
"msg"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
pt
+
"msg"
);
}
else
{
con
=
dbDepot
.
getDBCollection
(
"msg"
);
con
=
dbDepot
.
getDBCollection
(
"msg"
,
pt
);
}
if
(
con
==
null
)
{
return
0
;
...
...
src/main/java/com/zhiwei/manage/dao/TemplateDao.java
View file @
f96b6266
...
...
@@ -14,13 +14,13 @@ public interface TemplateDao {
public
List
<
Template
>
findAll
(
int
pageNo
,
int
pageSize
,
String
pt
);
public
Template
findById
(
String
templateId
);
public
Template
findById
(
String
templateId
,
String
pt
);
public
List
<
Template
>
findByTmpName
(
String
templateName
,
int
pageNo
,
int
pageSize
,
String
pt
);
public
boolean
delete
(
String
templateId
);
public
boolean
delete
(
String
templateId
,
String
pt
);
public
int
allCount
();
public
int
allCount
(
String
pt
);
public
int
findByUserCount
(
String
templateName
,
String
pt
);
...
...
src/main/java/com/zhiwei/manage/dao/TemplateDaoImpl.java
View file @
f96b6266
...
...
@@ -37,10 +37,10 @@ public class TemplateDaoImpl implements TemplateDao {
@Override
public
boolean
insert
(
Template
template
)
{
DBCollection
con
=
null
;
if
(
DbDepot
.
dbCons
.
get
(
"temp
"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
"temp
"
);
if
(
DbDepot
.
dbCons
.
get
(
template
.
getPt
()+
"msg
"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
template
.
getPt
()+
"msg
"
);
}
else
{
con
=
dbDepot
.
getDBCollection
(
"
temp"
);
con
=
dbDepot
.
getDBCollection
(
"
msg"
,
template
.
getPt
()
);
}
if
(
con
==
null
)
{
return
false
;
...
...
@@ -61,17 +61,16 @@ public class TemplateDaoImpl implements TemplateDao {
}
}
con
.
insert
(
obj
);
// mongo.insert(template);
return
true
;
}
@Override
public
boolean
update
(
Template
template
)
{
DBCollection
con
=
null
;
if
(
DbDepot
.
dbCons
.
get
(
"temp"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
"temp"
);
if
(
DbDepot
.
dbCons
.
get
(
template
.
getPt
()+
"temp"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
template
.
getPt
()+
"temp"
);
}
else
{
con
=
dbDepot
.
getDBCollection
(
"temp"
);
con
=
dbDepot
.
getDBCollection
(
"temp"
,
template
.
getPt
()
);
}
if
(
con
==
null
)
{
return
false
;
...
...
@@ -101,17 +100,17 @@ public class TemplateDaoImpl implements TemplateDao {
}
@Override
public
Template
findById
(
String
templateId
)
{
public
Template
findById
(
String
templateId
,
String
pt
)
{
DBCollection
con
=
null
;
if
(
DbDepot
.
dbCons
.
get
(
"temp"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
"temp"
);
if
(
DbDepot
.
dbCons
.
get
(
pt
+
"temp"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
pt
+
"temp"
);
}
else
{
con
=
dbDepot
.
getDBCollection
(
"temp"
);
con
=
dbDepot
.
getDBCollection
(
"temp"
,
pt
);
}
if
(
con
==
null
)
{
return
null
;
}
Map
<
String
,
Object
>
map
=(
Map
<
String
,
Object
>)
con
.
findOne
(
new
BasicDBObject
(
"_id"
,
new
ObjectId
(
templateId
)).
append
(
"pt"
,
DbDepot
.
nowP
t
));
Map
<
String
,
Object
>
map
=(
Map
<
String
,
Object
>)
con
.
findOne
(
new
BasicDBObject
(
"_id"
,
new
ObjectId
(
templateId
)).
append
(
"pt"
,
p
t
));
Template
temp
=
new
Template
();
temp
=
Change
.
toBean
(
Template
.
class
,
map
);
temp
.
setTemplateId
(
String
.
valueOf
(
map
.
get
(
"_id"
)));
...
...
@@ -125,10 +124,10 @@ public class TemplateDaoImpl implements TemplateDao {
public
List
<
Template
>
findByTmpName
(
String
templateName
,
int
pageNo
,
int
pageSize
,
String
pt
)
{
List
<
Template
>
list
=
new
ArrayList
<
Template
>();
DBCollection
con
=
null
;
if
(
DbDepot
.
dbCons
.
get
(
"temp"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
"temp"
);
if
(
DbDepot
.
dbCons
.
get
(
pt
+
"temp"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
pt
+
"temp"
);
}
else
{
con
=
dbDepot
.
getDBCollection
(
"temp"
);
con
=
dbDepot
.
getDBCollection
(
"temp"
,
pt
);
}
if
(
con
==
null
)
{
return
null
;
...
...
@@ -145,26 +144,20 @@ public class TemplateDaoImpl implements TemplateDao {
list
.
add
(
temp
);
}
return
list
;
// return mongo.find(Query
// .query(Criteria.where("templateName").is(templateName)
// .orOperator(Criteria.where("pt").is(DbDepot.nowPt)))
// .skip(pageNo).limit(pageSize).with(new Sort(new Order(Direction.ASC, "createDate"))), Template.class);
}
@Override
public
boolean
delete
(
String
templateId
)
{
public
boolean
delete
(
String
templateId
,
String
pt
)
{
DBCollection
con
=
null
;
if
(
DbDepot
.
dbCons
.
get
(
"temp"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
"temp"
);
if
(
DbDepot
.
dbCons
.
get
(
pt
+
"temp"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
pt
+
"temp"
);
}
else
{
con
=
dbDepot
.
getDBCollection
(
"temp"
);
con
=
dbDepot
.
getDBCollection
(
"temp"
,
pt
);
}
if
(
con
==
null
)
{
return
false
;
}
WriteResult
result
=
con
.
remove
(
new
BasicDBObject
(
"_id"
,
new
ObjectId
(
templateId
)));
// WriteResult wr = mongo.remove(Query.query(Criteria.where("_id").is(templateId)), Template.class);
return
result
.
getN
()
==
0
?
true
:
false
;
}
...
...
@@ -172,10 +165,10 @@ public class TemplateDaoImpl implements TemplateDao {
public
List
<
Template
>
findAll
(
int
pageNo
,
int
pageSize
,
String
pt
)
{
List
<
Template
>
list
=
new
ArrayList
<
Template
>();
DBCollection
con
=
null
;
if
(
DbDepot
.
dbCons
.
get
(
"temp"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
"temp"
);
if
(
DbDepot
.
dbCons
.
get
(
pt
+
"temp"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
pt
+
"temp"
);
}
else
{
con
=
dbDepot
.
getDBCollection
(
"temp"
);
con
=
dbDepot
.
getDBCollection
(
"temp"
,
pt
);
}
if
(
con
==
null
)
{
return
null
;
...
...
@@ -188,43 +181,32 @@ public class TemplateDaoImpl implements TemplateDao {
Template
temp
=
new
Template
();
temp
=
Change
.
toBean
(
Template
.
class
,
map
);
temp
.
setTemplateId
(
String
.
valueOf
(
map
.
get
(
"_id"
)));
// temp.setNeedPing((boolean)(map.get("isNeedPing")));
// temp.setNeedField((boolean)(map.get("isNeedField")));
// temp.setNeedDelayed((boolean)(map.get("isNeedDelayed")));
System
.
out
.
println
(
temp
);
list
.
add
(
temp
);
}
return
list
;
// return mongo.find(
// Query.query(Criteria.where("pt").is(DbDepot.nowPt))
// .with(new Sort(new Order(Direction.ASC, "createDate"))).skip((pageNo - 1) * 10).limit(pageSize),
// Template.class);
}
@Override
public
int
allCount
()
{
public
int
allCount
(
String
pt
)
{
DBCollection
con
=
null
;
if
(
DbDepot
.
dbCons
.
get
(
"temp"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
"temp"
);
if
(
DbDepot
.
dbCons
.
get
(
pt
+
"temp"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
pt
+
"temp"
);
}
else
{
con
=
dbDepot
.
getDBCollection
(
"temp"
);
con
=
dbDepot
.
getDBCollection
(
"temp"
,
pt
);
}
if
(
con
==
null
)
{
return
0
;
}
return
(
int
)
con
.
count
(
new
BasicDBObject
(
"pt"
,
DbDepot
.
nowPt
));
// return (int) mongo.count(Query.query(Criteria.where("pt").is(DbDepot.nowPt)), Template.class);
return
(
int
)
con
.
count
(
new
BasicDBObject
(
"pt"
,
pt
));
}
@Override
public
int
findByUserCount
(
String
templateName
,
String
pt
)
{
DBCollection
con
=
null
;
if
(
DbDepot
.
dbCons
.
get
(
"temp"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
"temp"
);
if
(
DbDepot
.
dbCons
.
get
(
pt
+
"temp"
)
!=
null
)
{
con
=
(
DBCollection
)
DbDepot
.
dbCons
.
get
(
pt
+
"temp"
);
}
else
{
con
=
dbDepot
.
getDBCollection
(
"temp"
);
con
=
dbDepot
.
getDBCollection
(
"temp"
,
pt
);
}
if
(
con
==
null
)
{
return
0
;
...
...
src/main/java/com/zhiwei/manage/handle/DbDepot.java
View file @
f96b6266
...
...
@@ -53,26 +53,25 @@ public class DbDepot {
if
(
sb
.
getDbUsername
()
!=
null
&&
!
sb
.
getDbUsername
().
trim
().
equals
(
""
))
{
DBCollection
con
=
new
MongoConnect
(
sb
.
getDbHost
(),
sb
.
getDbPort
(),
sb
.
getDbUsername
(),
sb
.
getDbPassword
(),
sb
.
getDbName
()).
getCollection
(
sb
.
getCollection
()
+
end
);
dbCons
.
put
(
sb
.
getOther
(),
con
);
dbCons
.
put
(
sb
.
get
Pt
()+
sb
.
get
Other
(),
con
);
}
else
{
DBCollection
con
=
new
MongoConnect
(
sb
.
getDbHost
(),
sb
.
getDbPort
(),
sb
.
getDbName
())
.
getCollection
(
sb
.
getCollection
()
+
end
);
dbCons
.
put
(
sb
.
getOther
(),
con
);
dbCons
.
put
(
sb
.
get
Pt
()+
sb
.
get
Other
(),
con
);
}
}
}
System
.
out
.
println
(
"连接初始化成功"
);
}
public
DBCollection
getDBCollection
(
String
other
)
{
public
DBCollection
getDBCollection
(
String
other
,
String
pt
)
{
DBCollection
con
=
null
;
ServerBean
sb
=
mongo
.
findOne
(
Query
.
query
(
Criteria
.
where
(
"pt"
).
is
(
nowP
t
).
orOperator
(
Criteria
.
where
(
"other"
).
is
(
other
))),
Query
.
query
(
Criteria
.
where
(
"pt"
).
is
(
p
t
).
orOperator
(
Criteria
.
where
(
"other"
).
is
(
other
))),
ServerBean
.
class
);
Calendar
cal
=
Calendar
.
getInstance
();
month
=
cal
.
get
(
Calendar
.
MONTH
+
1
);
if
(
sb
!=
null
)
{
if
(
sb
.
getDbType
().
equals
(
"mongo"
))
{
String
end
=
""
;
...
...
@@ -86,11 +85,11 @@ public class DbDepot {
if
(
sb
.
getDbUsername
()
!=
null
&&
!
sb
.
getDbUsername
().
equals
(
""
))
{
con
=
new
MongoConnect
(
sb
.
getDbHost
(),
sb
.
getDbPort
(),
sb
.
getDbUsername
(),
sb
.
getDbPassword
(),
sb
.
getDbName
()).
getCollection
(
sb
.
getCollection
()+
end
);
dbCons
.
put
(
sb
.
getOther
(),
con
);
dbCons
.
put
(
pt
+
sb
.
getOther
(),
con
);
}
else
{
con
=
new
MongoConnect
(
sb
.
getDbHost
(),
sb
.
getDbPort
(),
sb
.
getDbName
())
.
getCollection
(
sb
.
getCollection
()+
end
);
dbCons
.
put
(
sb
.
getOther
(),
con
);
dbCons
.
put
(
pt
+
sb
.
getOther
(),
con
);
}
}
}
...
...
src/main/java/com/zhiwei/manage/handle/MainThread.java
View file @
f96b6266
package
com
.
zhiwei
.
manage
.
handle
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -17,6 +19,7 @@ import com.zhiwei.manage.bean.CrawTemplate;
import
com.zhiwei.manage.bean.Data
;
import
com.zhiwei.manage.bean.FieldBean
;
import
com.zhiwei.manage.bean.FieldIntegerity
;
import
com.zhiwei.manage.bean.Message
;
import
com.zhiwei.manage.bean.NewsDelayed
;
import
com.zhiwei.manage.bean.PingUrl
;
import
com.zhiwei.manage.bean.RunMsg
;
...
...
@@ -24,6 +27,7 @@ import com.zhiwei.manage.bean.Template;
import
com.zhiwei.manage.orm.BeanFactory
;
import
com.zhiwei.manage.service.CrawTemplateServiceImpl
;
import
com.zhiwei.manage.service.DataServiceImpl
;
import
com.zhiwei.manage.service.MessageServiceImpl
;
import
com.zhiwei.manage.service.NewsServiceImpl
;
import
com.zhiwei.manage.service.ServerServiceImpl
;
import
com.zhiwei.manage.util.TimeUtil
;
...
...
@@ -141,14 +145,26 @@ public class MainThread extends Thread {
CrawTemplateServiceImpl
crawService
=
BeanFactory
.
getBean
(
CrawTemplateServiceImpl
.
class
);
DataServiceImpl
dataService
=
BeanFactory
.
getBean
(
DataServiceImpl
.
class
);
ServerServiceImpl
serverService
=
BeanFactory
.
getBean
(
ServerServiceImpl
.
class
);
// while (true) {
MessageServiceImpl
msgService
=
BeanFactory
.
getBean
(
MessageServiceImpl
.
class
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
int
num
=
1
;
while
(
true
)
{
Calendar
countTest
=
Calendar
.
getInstance
();
Calendar
start
=
Calendar
.
getInstance
();
start
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
Calendar
end
=
Calendar
.
getInstance
();
end
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
if
(
start
.
get
(
Calendar
.
HOUR_OF_DAY
)
<=
1
)
for
(
int
i
=
0
;
i
<
19
;
i
++)
{
// start.set(Calendar.HOUR_OF_DAY, 0);
// end.set(Calendar.HOUR_OF_DAY, 0);
if
(
start
.
get
(
Calendar
.
HOUR_OF_DAY
)
<
1
)
{
try
{
countTest
.
setTime
(
sdf
.
parse
(
sdf
.
format
(
countTest
.
getTime
())));
start
.
setTime
(
sdf
.
parse
(
sdf
.
format
(
countTest
.
getTime
())));
end
.
setTime
(
sdf
.
parse
(
sdf
.
format
(
countTest
.
getTime
())));
}
catch
(
ParseException
e1
)
{
e1
.
printStackTrace
();
}
// for (int i = 0; i < 19; i++) {
start
.
add
(
Calendar
.
DATE
,
-
1
);
countTest
.
add
(
Calendar
.
DATE
,
-
3
);
try
{
mainLock
.
lock
();
int
count
=
0
;
...
...
@@ -167,6 +183,20 @@ public class MainThread extends Thread {
data
.
setTime
(
start
.
getTime
());
data
.
setSpyderInfoId
(
cr
.
getId
());
dataService
.
insert
(
data
);
if
(
count
==
0
)
{
int
testCount
=
(
int
)
dataService
.
finCountByDayData
(
countTest
.
getTime
(),
end
.
getTime
(),
chan
.
getPt
(),
cr
.
getId
());
if
(
testCount
==
0
)
{
Message
m
=
new
Message
();
m
.
setHandle
(
false
);
m
.
setCreateDate
(
start
.
getTime
());
m
.
setTemplateLv
(
1
);
m
.
setTemplateName
(
"未定义"
);
m
.
setPt
(
"网媒"
);
m
.
setErrorMsg
(
"未定义,"
+
cr
.
getConfigName
()
+
","
+
chan
.
getId
()
+
"数据为0"
);
msgService
.
insert
(
m
);
}
}
log
.
info
(
TimeUtil
.
yearToDay
(
start
.
getTime
())
+
"|"
+
data
.
getTempName
()
+
"|入库"
);
}
count
=
(
int
)
dataService
.
finCountByDayData
(
start
.
getTime
(),
end
.
getTime
(),
chan
.
getPt
(),
...
...
@@ -192,8 +222,11 @@ public class MainThread extends Thread {
}
finally
{
mainLock
.
unlock
();
}
Tools
.
sleep
(
1000
*
3
);
end
.
add
(
Calendar
.
DATE
,
-
1
);
// end.add(Calendar.DATE, -1);
// }
Tools
.
sleep
(
1000
*
60
*
60
);
}
Tools
.
sleep
(
1000
*
30
);
}
}
...
...
src/main/java/com/zhiwei/manage/service/MessageService.java
View file @
f96b6266
...
...
@@ -9,13 +9,13 @@ public interface MessageService {
public
void
insert
(
Message
message
);
public
String
update
(
Message
message
);
public
String
update
(
Message
message
,
String
pt
);
public
PageEty
findAll
(
int
pageNo
,
int
pageSize
,
String
pt
);
public
PageEty
findByTmpName
(
String
templateName
,
int
pageNo
,
int
pageSize
,
String
pt
);
public
boolean
delete
(
List
<
String
>
MessageId
);
public
boolean
delete
(
List
<
String
>
MessageId
,
String
pt
);
public
PageEty
findByHandle
(
int
pageNo
,
int
pageSize
,
boolean
handle
,
String
tempName
,
String
pt
);
}
src/main/java/com/zhiwei/manage/service/MessageServiceImpl.java
View file @
f96b6266
...
...
@@ -24,9 +24,9 @@ public class MessageServiceImpl implements MessageService {
}
@Override
public
String
update
(
Message
message
)
{
public
String
update
(
Message
message
,
String
pt
)
{
try
{
String
str
=
messageDao
.
update
(
message
);
String
str
=
messageDao
.
update
(
message
,
pt
);
return
str
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -38,7 +38,7 @@ public class MessageServiceImpl implements MessageService {
public
PageEty
findAll
(
int
pageNo
,
int
pageSize
,
String
pt
)
{
PageEty
page
=
new
PageEty
();
List
<
Message
>
data
=
messageDao
.
findAll
(
pageNo
,
pageSize
,
pt
);
int
count
=
messageDao
.
allCount
();
int
count
=
messageDao
.
allCount
(
pt
);
if
(
count
%
pageSize
==
0
)
{
page
.
setPageCount
(
count
/
pageSize
);
}
else
...
...
@@ -54,7 +54,7 @@ public class MessageServiceImpl implements MessageService {
public
PageEty
findByTmpName
(
String
templateName
,
int
pageNo
,
int
pageSize
,
String
pt
)
{
PageEty
page
=
new
PageEty
();
List
<
Message
>
data
=
messageDao
.
findByTmpName
(
templateName
,
pageNo
,
pageSize
,
pt
);
int
count
=
messageDao
.
findByTmpCount
(
templateName
);
int
count
=
messageDao
.
findByTmpCount
(
templateName
,
pt
);
if
(
data
.
size
()==
0
){
page
.
setData
(
new
ArrayList
<>());
page
.
setDataCount
(
1
);
...
...
@@ -72,8 +72,8 @@ public class MessageServiceImpl implements MessageService {
}
@Override
public
boolean
delete
(
List
<
String
>
MessageId
)
{
return
messageDao
.
delete
(
MessageId
);
public
boolean
delete
(
List
<
String
>
MessageId
,
String
pt
)
{
return
messageDao
.
delete
(
MessageId
,
pt
);
}
@Override
...
...
src/main/java/com/zhiwei/manage/service/TemplateService.java
View file @
f96b6266
...
...
@@ -11,10 +11,10 @@ public interface TemplateService {
public
PageEty
findAll
(
int
pageNo
,
int
pageSize
,
String
pt
);
public
Template
findById
(
String
templateId
);
public
Template
findById
(
String
templateId
,
String
pt
);
public
PageEty
findByTmpName
(
String
templateName
,
int
pageNo
,
int
pageSize
,
String
pt
);
public
boolean
delete
(
String
templateId
);
public
boolean
delete
(
String
templateId
,
String
pt
);
}
src/main/java/com/zhiwei/manage/service/TemplateServiceImpl.java
View file @
f96b6266
...
...
@@ -46,7 +46,7 @@ public class TemplateServiceImpl implements TemplateService {
@Override
public
PageEty
findAll
(
int
pageNo
,
int
pageSize
,
String
pt
)
{
int
count
=
tempDao
.
allCount
();
int
count
=
tempDao
.
allCount
(
pt
);
List
<
Template
>
data
=
tempDao
.
findAll
(
pageNo
,
pageSize
,
pt
);
for
(
Template
tp:
data
){
if
(
MainThread
.
allTmp
.
get
(
tp
.
getTemplateId
())==
null
){
...
...
@@ -69,8 +69,8 @@ public class TemplateServiceImpl implements TemplateService {
}
@Override
public
Template
findById
(
String
templateId
)
{
return
tempDao
.
findById
(
templateId
);
public
Template
findById
(
String
templateId
,
String
pt
)
{
return
tempDao
.
findById
(
templateId
,
pt
);
}
@Override
...
...
@@ -99,14 +99,9 @@ public class TemplateServiceImpl implements TemplateService {
}
@Override
public
boolean
delete
(
String
templateId
)
{
public
boolean
delete
(
String
templateId
,
String
pt
)
{
try
{
// Template tp = MainThread.mainMap.get(templateId);
// PingThread.runMap.remove(tp.getTempName());
// FieldThread.runMap.remove(tp.getTempName());
// DelayedThread.runMap.remove(tp.getTempName());
// MainThread.mainMap.remove(templateId);
return
tempDao
.
delete
(
templateId
);
return
tempDao
.
delete
(
templateId
,
pt
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
...
...
src/main/java/com/zhiwei/manage/servlet/MessageConteoller.java
View file @
f96b6266
...
...
@@ -23,7 +23,8 @@ public class MessageConteoller {
@RequestMapping
(
value
=
"/findAllMsg"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
public
String
getAllMessage
(
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"1"
)
int
pageNo
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"10"
)
int
pageSize
,
String
tempName
,
String
pt
)
{
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"10"
)
int
pageSize
,
String
tempName
,
@RequestParam
(
value
=
"pt"
,
defaultValue
=
"网媒"
)
String
pt
)
{
if
(
tempName
==
null
||
tempName
.
equals
(
""
))
{
PageEty
page
=
msgService
.
findAll
(
pageNo
,
pageSize
,
pt
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"请求成功"
,
page
);
...
...
@@ -37,16 +38,17 @@ public class MessageConteoller {
@RequestMapping
(
value
=
"/handle"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
public
String
handle
(
Message
message
)
{
String
str
=
msgService
.
update
(
message
);
public
String
handle
(
Message
message
,
@RequestParam
(
value
=
"pt"
,
defaultValue
=
"网媒"
)
String
pt
)
{
String
str
=
msgService
.
update
(
message
,
pt
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
str
,
""
);
return
JSON
.
toJSONString
(
result
);
}
@RequestMapping
(
value
=
"/deleteMsg"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
public
String
delete
(
@RequestParam
(
value
=
"messageId[]"
)
List
<
String
>
messageId
)
{
msgService
.
delete
(
messageId
);
public
String
delete
(
@RequestParam
(
value
=
"messageId[]"
)
List
<
String
>
messageId
,
@RequestParam
(
value
=
"pt"
,
defaultValue
=
"网媒"
)
String
pt
)
{
msgService
.
delete
(
messageId
,
pt
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"删除成功"
,
""
);
return
JSON
.
toJSONString
(
result
);
}
...
...
src/main/java/com/zhiwei/manage/servlet/TemplateController.java
View file @
f96b6266
...
...
@@ -55,12 +55,13 @@ public class TemplateController {
@RequestMapping
(
value
=
"/deleteTmp"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
public
String
deleteTmp
(
@RequestParam
(
value
=
"templateId[]"
)
String
[]
templateId
)
{
public
String
deleteTmp
(
@RequestParam
(
value
=
"templateId[]"
)
String
[]
templateId
,
@RequestParam
(
value
=
"pt"
,
defaultValue
=
"网媒"
)
String
pt
)
{
boolean
isDelete
=
false
;
String
results
=
""
;
for
(
String
l
:
templateId
)
{
System
.
out
.
println
(
l
);
isDelete
=
ts
.
delete
(
l
);
isDelete
=
ts
.
delete
(
l
,
pt
);
MainThread
.
delete
(
l
);
results
+=
l
+
"\n"
;
}
...
...
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