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
515b4bc9
Commit
515b4bc9
authored
May 28, 2018
by
admin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加注释
parent
22d33948
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
977 additions
and
428 deletions
+977
-428
src/main/java/com/zhiwei/manage/bean/Channel.java
+18
-4
src/main/java/com/zhiwei/manage/bean/CrawTemplate.java
+4
-6
src/main/java/com/zhiwei/manage/bean/Data.java
+29
-11
src/main/java/com/zhiwei/manage/bean/EasyNews.java
+5
-1
src/main/java/com/zhiwei/manage/bean/FieldIntegerity.java
+43
-13
src/main/java/com/zhiwei/manage/bean/Message.java
+31
-2
src/main/java/com/zhiwei/manage/bean/News.java
+31
-6
src/main/java/com/zhiwei/manage/bean/PageEty.java
+20
-7
src/main/java/com/zhiwei/manage/bean/Person.java
+6
-1
src/main/java/com/zhiwei/manage/bean/PingUrl.java
+6
-0
src/main/java/com/zhiwei/manage/bean/RunMsg.java
+7
-3
src/main/java/com/zhiwei/manage/bean/Template.java
+6
-3
src/main/java/com/zhiwei/manage/bean/Weibo.java
+56
-7
src/main/java/com/zhiwei/manage/dao/MessageDao.java
+14
-14
src/main/java/com/zhiwei/manage/handle/DbDepot.java
+8
-1
src/main/java/com/zhiwei/manage/handle/DelayedThread.java
+12
-6
src/main/java/com/zhiwei/manage/handle/FieldThread.java
+8
-2
src/main/java/com/zhiwei/manage/handle/MainThread.java
+28
-9
src/main/java/com/zhiwei/manage/handle/PingThread.java
+6
-0
src/main/java/com/zhiwei/manage/handle/QueueTask.java
+10
-4
src/main/java/com/zhiwei/manage/handle/Task.java
+2
-2
src/main/java/com/zhiwei/manage/service/MessageService.java
+8
-8
src/main/java/com/zhiwei/manage/servlet/DataController.java
+51
-2
src/main/java/com/zhiwei/manage/servlet/FieldController.java
+32
-2
src/main/java/com/zhiwei/manage/servlet/MessageConteoller.java
+30
-0
src/main/java/com/zhiwei/manage/servlet/PersonController.java
+57
-3
src/main/java/com/zhiwei/manage/servlet/ServerController.java
+104
-47
src/main/java/com/zhiwei/manage/servlet/TemplateController.java
+65
-8
src/main/java/com/zhiwei/manage/util/AESUtils.java
+108
-101
src/main/java/com/zhiwei/manage/util/Config.java
+12
-5
src/main/java/com/zhiwei/manage/util/MysqlConnection.java
+14
-7
src/main/java/com/zhiwei/manage/util/ThreadPool.java
+138
-134
src/main/java/com/zhiwei/manage/util/WechatPush.java
+8
-9
No files found.
src/main/java/com/zhiwei/manage/bean/Channel.java
View file @
515b4bc9
...
@@ -8,8 +8,14 @@ import org.springframework.data.annotation.Transient;
...
@@ -8,8 +8,14 @@ import org.springframework.data.annotation.Transient;
import
org.springframework.data.mongodb.core.index.Indexed
;
import
org.springframework.data.mongodb.core.index.Indexed
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.data.mongodb.core.mapping.Document
;
@Document
(
collection
=
"Channel"
)
/**
public
class
Channel
implements
Serializable
{
* 渠道字段对应
*
* @author admin
*
*/
@Document
(
collection
=
"Channel"
)
public
class
Channel
implements
Serializable
{
@Indexed
@Indexed
@Id
@Id
...
@@ -18,34 +24,42 @@ public class Channel implements Serializable{
...
@@ -18,34 +24,42 @@ public class Channel implements Serializable{
private
String
value
;
private
String
value
;
@Transient
@Transient
private
List
<
Data
>
list
;
private
List
<
Data
>
list
;
public
List
<
Data
>
getList
()
{
public
List
<
Data
>
getList
()
{
return
list
;
return
list
;
}
}
public
void
setList
(
List
<
Data
>
list
)
{
public
void
setList
(
List
<
Data
>
list
)
{
this
.
list
=
list
;
this
.
list
=
list
;
}
}
public
String
getId
()
{
public
String
getId
()
{
return
id
;
return
id
;
}
}
public
void
setId
(
String
id
)
{
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
this
.
id
=
id
;
}
}
public
String
getPt
()
{
public
String
getPt
()
{
return
pt
;
return
pt
;
}
}
public
void
setPt
(
String
pt
)
{
public
void
setPt
(
String
pt
)
{
this
.
pt
=
pt
;
this
.
pt
=
pt
;
}
}
public
String
getValue
()
{
public
String
getValue
()
{
return
value
;
return
value
;
}
}
public
void
setValue
(
String
value
)
{
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
this
.
value
=
value
;
}
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"Channel [id="
+
id
+
", pt="
+
pt
+
", value="
+
value
+
"]"
;
return
"Channel [id="
+
id
+
", pt="
+
pt
+
", value="
+
value
+
"]"
;
}
}
}
}
src/main/java/com/zhiwei/manage/bean/CrawTemplate.java
View file @
515b4bc9
...
@@ -6,7 +6,6 @@ import java.util.Map;
...
@@ -6,7 +6,6 @@ import java.util.Map;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.data.mongodb.core.mapping.Field
;
import
org.springframework.data.mongodb.core.mapping.Field
;
@Document
(
collection
=
"spyderInfo"
)
@Document
(
collection
=
"spyderInfo"
)
public
class
CrawTemplate
{
public
class
CrawTemplate
{
...
@@ -14,13 +13,13 @@ public class CrawTemplate {
...
@@ -14,13 +13,13 @@ public class CrawTemplate {
private
String
configName
;
private
String
configName
;
@Field
(
"staticFieldList"
)
@Field
(
"staticFieldList"
)
private
List
<
Map
<
String
,
Object
>>
staticFieldList
;
private
List
<
Map
<
String
,
Object
>>
staticFieldList
;
@Field
(
"_id"
)
@Field
(
"_id"
)
private
String
id
;
private
String
id
;
private
String
pt
;
private
String
pt
;
public
List
<
Map
<
String
,
Object
>>
getStaticFieldList
()
{
public
List
<
Map
<
String
,
Object
>>
getStaticFieldList
()
{
return
staticFieldList
;
return
staticFieldList
;
}
}
...
@@ -59,5 +58,4 @@ public class CrawTemplate {
...
@@ -59,5 +58,4 @@ public class CrawTemplate {
+
", pt="
+
pt
+
"]"
;
+
", pt="
+
pt
+
"]"
;
}
}
}
}
src/main/java/com/zhiwei/manage/bean/Data.java
View file @
515b4bc9
...
@@ -8,72 +8,90 @@ import org.springframework.data.mongodb.core.index.Indexed;
...
@@ -8,72 +8,90 @@ import org.springframework.data.mongodb.core.index.Indexed;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
/**
* 数据量
*
* @author admin
*
*/
@Component
@Component
@Document
(
collection
=
"Data"
)
@Document
(
collection
=
"Data"
)
public
class
Data
implements
Serializable
{
public
class
Data
implements
Serializable
{
@Id
@Id
@Indexed
(
unique
=
true
)
@Indexed
(
unique
=
true
)
private
String
dataId
;
private
String
dataId
;
private
String
pt
;
private
String
pt
;
@Indexed
(
background
=
true
)
@Indexed
(
background
=
true
)
private
String
tempName
;
private
String
tempName
;
@Indexed
(
background
=
true
)
@Indexed
(
background
=
true
)
private
String
source
;
private
String
source
;
private
long
count
;
private
long
count
;
@Indexed
(
background
=
true
)
@Indexed
(
background
=
true
)
private
Date
time
;
private
Date
time
;
@Indexed
(
background
=
true
)
@Indexed
(
background
=
true
)
private
String
spyderInfoId
;
private
String
spyderInfoId
;
public
String
getDataId
()
{
public
String
getDataId
()
{
return
dataId
;
return
dataId
;
}
}
public
void
setDataId
(
String
dataId
)
{
public
void
setDataId
(
String
dataId
)
{
this
.
dataId
=
dataId
;
this
.
dataId
=
dataId
;
}
}
public
String
getPt
()
{
public
String
getPt
()
{
return
pt
;
return
pt
;
}
}
public
void
setPt
(
String
pt
)
{
public
void
setPt
(
String
pt
)
{
this
.
pt
=
pt
;
this
.
pt
=
pt
;
}
}
public
String
getTempName
()
{
public
String
getTempName
()
{
return
tempName
;
return
tempName
;
}
}
public
void
setTempName
(
String
tempName
)
{
public
void
setTempName
(
String
tempName
)
{
this
.
tempName
=
tempName
;
this
.
tempName
=
tempName
;
}
}
public
String
getSource
()
{
public
String
getSource
()
{
return
source
;
return
source
;
}
}
public
void
setSource
(
String
source
)
{
public
void
setSource
(
String
source
)
{
this
.
source
=
source
;
this
.
source
=
source
;
}
}
public
long
getCount
()
{
public
long
getCount
()
{
return
count
;
return
count
;
}
}
public
void
setCount
(
long
count
)
{
public
void
setCount
(
long
count
)
{
this
.
count
=
count
;
this
.
count
=
count
;
}
}
public
Date
getTime
()
{
public
Date
getTime
()
{
return
time
;
return
time
;
}
}
public
void
setTime
(
Date
time
)
{
public
void
setTime
(
Date
time
)
{
this
.
time
=
time
;
this
.
time
=
time
;
}
}
public
String
getSpyderInfoId
()
{
public
String
getSpyderInfoId
()
{
return
spyderInfoId
;
return
spyderInfoId
;
}
}
public
void
setSpyderInfoId
(
String
spyderInfoId
)
{
public
void
setSpyderInfoId
(
String
spyderInfoId
)
{
this
.
spyderInfoId
=
spyderInfoId
;
this
.
spyderInfoId
=
spyderInfoId
;
}
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"Data [dataId="
+
dataId
+
", pt="
+
pt
+
", tempName="
+
tempName
+
", source="
+
source
+
", count="
return
"Data [dataId="
+
dataId
+
", pt="
+
pt
+
", tempName="
+
tempName
+
", source="
+
source
+
", count="
+
count
+
", time="
+
time
+
"]"
;
+
count
+
", time="
+
time
+
"]"
;
}
}
}
}
src/main/java/com/zhiwei/manage/bean/EasyNews.java
View file @
515b4bc9
...
@@ -5,6 +5,11 @@ import java.util.Date;
...
@@ -5,6 +5,11 @@ import java.util.Date;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
/**
*
* @author admin
*
*/
@Component
@Component
public
class
EasyNews
implements
Serializable
{
public
class
EasyNews
implements
Serializable
{
...
@@ -54,7 +59,6 @@ public class EasyNews implements Serializable {
...
@@ -54,7 +59,6 @@ public class EasyNews implements Serializable {
this
.
pt
=
pt
;
this
.
pt
=
pt
;
}
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"EasyNews [title="
+
title
+
", source="
+
source
+
", time="
+
time
+
", pt="
+
pt
+
"]"
;
return
"EasyNews [title="
+
title
+
", source="
+
source
+
", time="
+
time
+
", pt="
+
pt
+
"]"
;
...
...
src/main/java/com/zhiwei/manage/bean/FieldIntegerity.java
View file @
515b4bc9
...
@@ -2,113 +2,145 @@ package com.zhiwei.manage.bean;
...
@@ -2,113 +2,145 @@ package com.zhiwei.manage.bean;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
/**
* 字段缺失类
*
* @author admin
*
*/
@Component
@Component
public
class
FieldIntegerity
implements
Serializable
{
public
class
FieldIntegerity
implements
Serializable
{
private
String
templateId
;
private
String
templateId
;
private
String
tempName
;
// 模板名
private
String
tempName
;
// 模板名
private
String
field
;
//检测的字段
private
String
field
;
//
检测的字段
private
double
fieldIntegrityRate
;
// 字段缺失率
private
double
fieldIntegrityRate
;
// 字段缺失率
private
int
fieldInterval
;
// 字段缺失率统计间隔
private
int
fieldInterval
;
// 字段缺失率统计间隔
private
int
testCount
;
// 测试需要多少条数据
private
int
testCount
;
// 测试需要多少条数据
private
String
pt
;
//渠道
private
String
pt
;
//
渠道
private
String
host
;
//地址
private
String
host
;
//
地址
private
int
port
;
//端口
private
int
port
;
//
端口
private
String
collection
;
//表名
private
String
collection
;
//
表名
private
String
dBName
;
//数据库名
private
String
dBName
;
//
数据库名
private
boolean
startNow
;
private
boolean
startNow
;
private
Date
nextRun
;
private
Date
nextRun
;
private
String
spyderInfoId
;
private
String
spyderInfoId
;
public
String
getSpyderInfoId
()
{
public
String
getSpyderInfoId
()
{
return
spyderInfoId
;
return
spyderInfoId
;
}
}
public
void
setSpyderInfoId
(
String
spyderInfoId
)
{
public
void
setSpyderInfoId
(
String
spyderInfoId
)
{
this
.
spyderInfoId
=
spyderInfoId
;
this
.
spyderInfoId
=
spyderInfoId
;
}
}
public
String
getTemplateId
()
{
public
String
getTemplateId
()
{
return
templateId
;
return
templateId
;
}
}
public
void
setTemplateId
(
String
templateId
)
{
public
void
setTemplateId
(
String
templateId
)
{
this
.
templateId
=
templateId
;
this
.
templateId
=
templateId
;
}
}
public
String
getTempName
()
{
public
String
getTempName
()
{
return
tempName
;
return
tempName
;
}
}
public
void
setTempName
(
String
tempName
)
{
public
void
setTempName
(
String
tempName
)
{
this
.
tempName
=
tempName
;
this
.
tempName
=
tempName
;
}
}
public
String
getField
()
{
public
String
getField
()
{
return
field
;
return
field
;
}
}
public
void
setField
(
String
field
)
{
public
void
setField
(
String
field
)
{
this
.
field
=
field
;
this
.
field
=
field
;
}
}
public
double
getFieldIntegrityRate
()
{
public
double
getFieldIntegrityRate
()
{
return
fieldIntegrityRate
;
return
fieldIntegrityRate
;
}
}
public
void
setFieldIntegrityRate
(
double
fieldIntegrityRate
)
{
public
void
setFieldIntegrityRate
(
double
fieldIntegrityRate
)
{
this
.
fieldIntegrityRate
=
fieldIntegrityRate
;
this
.
fieldIntegrityRate
=
fieldIntegrityRate
;
}
}
public
int
getFieldInterval
()
{
public
int
getFieldInterval
()
{
return
fieldInterval
;
return
fieldInterval
;
}
}
public
void
setFieldInterval
(
int
fieldInterval
)
{
public
void
setFieldInterval
(
int
fieldInterval
)
{
this
.
fieldInterval
=
fieldInterval
;
this
.
fieldInterval
=
fieldInterval
;
}
}
public
String
getPt
()
{
public
String
getPt
()
{
return
pt
;
return
pt
;
}
}
public
void
setPt
(
String
pt
)
{
public
void
setPt
(
String
pt
)
{
this
.
pt
=
pt
;
this
.
pt
=
pt
;
}
}
public
String
getHost
()
{
public
String
getHost
()
{
return
host
;
return
host
;
}
}
public
void
setHost
(
String
host
)
{
public
void
setHost
(
String
host
)
{
this
.
host
=
host
;
this
.
host
=
host
;
}
}
public
int
getPort
()
{
public
int
getPort
()
{
return
port
;
return
port
;
}
}
public
void
setPort
(
int
port
)
{
public
void
setPort
(
int
port
)
{
this
.
port
=
port
;
this
.
port
=
port
;
}
}
public
String
getCollection
()
{
public
String
getCollection
()
{
return
collection
;
return
collection
;
}
}
public
void
setCollection
(
String
collection
)
{
public
void
setCollection
(
String
collection
)
{
this
.
collection
=
collection
;
this
.
collection
=
collection
;
}
}
public
String
getdBName
()
{
public
String
getdBName
()
{
return
dBName
;
return
dBName
;
}
}
public
void
setdBName
(
String
dBName
)
{
public
void
setdBName
(
String
dBName
)
{
this
.
dBName
=
dBName
;
this
.
dBName
=
dBName
;
}
}
public
boolean
isStartNow
()
{
public
boolean
isStartNow
()
{
return
startNow
;
return
startNow
;
}
}
public
void
setStartNow
(
boolean
startNow
)
{
public
void
setStartNow
(
boolean
startNow
)
{
this
.
startNow
=
startNow
;
this
.
startNow
=
startNow
;
}
}
public
Date
getNextRun
()
{
public
Date
getNextRun
()
{
return
nextRun
;
return
nextRun
;
}
}
public
void
setNextRun
(
Date
nextRun
)
{
public
void
setNextRun
(
Date
nextRun
)
{
this
.
nextRun
=
nextRun
;
this
.
nextRun
=
nextRun
;
}
}
public
int
getTestCount
()
{
public
int
getTestCount
()
{
return
testCount
;
return
testCount
;
}
}
public
void
setTestCount
(
int
testCount
)
{
public
void
setTestCount
(
int
testCount
)
{
this
.
testCount
=
testCount
;
this
.
testCount
=
testCount
;
}
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"FieldIntegerity [templateId="
+
templateId
+
", tempName="
+
tempName
+
", field="
+
field
return
"FieldIntegerity [templateId="
+
templateId
+
", tempName="
+
tempName
+
", field="
+
field
...
@@ -116,7 +148,5 @@ public class FieldIntegerity implements Serializable{
...
@@ -116,7 +148,5 @@ public class FieldIntegerity implements Serializable{
+
testCount
+
", pt="
+
pt
+
", host="
+
host
+
", port="
+
port
+
", collection="
+
collection
+
testCount
+
", pt="
+
pt
+
", host="
+
host
+
", port="
+
port
+
", collection="
+
collection
+
", dBName="
+
dBName
+
", startNow="
+
startNow
+
", nextRun="
+
nextRun
+
"]"
;
+
", dBName="
+
dBName
+
", startNow="
+
startNow
+
", nextRun="
+
nextRun
+
"]"
;
}
}
}
}
src/main/java/com/zhiwei/manage/bean/Message.java
View file @
515b4bc9
...
@@ -8,10 +8,15 @@ import org.springframework.data.mongodb.core.index.Indexed;
...
@@ -8,10 +8,15 @@ import org.springframework.data.mongodb.core.index.Indexed;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.data.mongodb.core.mapping.Field
;
import
org.springframework.data.mongodb.core.mapping.Field
;
/**
* 反馈信息类
*
* @author admin
*
*/
@Document
(
collection
=
"Message"
)
@Document
(
collection
=
"Message"
)
public
class
Message
implements
Serializable
{
public
class
Message
implements
Serializable
{
@Indexed
@Indexed
@Id
@Id
private
String
messageId
;
private
String
messageId
;
...
@@ -27,79 +32,103 @@ public class Message implements Serializable {
...
@@ -27,79 +32,103 @@ public class Message implements Serializable {
private
String
pt
;
private
String
pt
;
private
String
handleMsg
;
private
String
handleMsg
;
private
String
errorType
;
private
String
errorType
;
public
String
getErrorType
()
{
public
String
getErrorType
()
{
return
errorType
;
return
errorType
;
}
}
public
void
setErrorType
(
String
errorType
)
{
public
void
setErrorType
(
String
errorType
)
{
this
.
errorType
=
errorType
;
this
.
errorType
=
errorType
;
}
}
public
String
getHandleMsg
()
{
public
String
getHandleMsg
()
{
return
handleMsg
;
return
handleMsg
;
}
}
public
void
setHandleMsg
(
String
handleMsg
)
{
public
void
setHandleMsg
(
String
handleMsg
)
{
this
.
handleMsg
=
handleMsg
;
this
.
handleMsg
=
handleMsg
;
}
}
public
String
getPt
()
{
public
String
getPt
()
{
return
pt
;
return
pt
;
}
}
public
void
setPt
(
String
pt
)
{
public
void
setPt
(
String
pt
)
{
this
.
pt
=
pt
;
this
.
pt
=
pt
;
}
}
public
String
getMessageId
()
{
public
String
getMessageId
()
{
return
messageId
;
return
messageId
;
}
}
public
void
setMessageId
(
String
messageId
)
{
public
void
setMessageId
(
String
messageId
)
{
this
.
messageId
=
messageId
;
this
.
messageId
=
messageId
;
}
}
public
String
getTempName
()
{
public
String
getTempName
()
{
return
tempName
;
return
tempName
;
}
}
public
void
setTempName
(
String
tempName
)
{
public
void
setTempName
(
String
tempName
)
{
this
.
tempName
=
tempName
;
this
.
tempName
=
tempName
;
}
}
public
Date
getCreateDate
()
{
public
Date
getCreateDate
()
{
return
createDate
;
return
createDate
;
}
}
public
void
setCreateDate
(
Date
createDate
)
{
public
void
setCreateDate
(
Date
createDate
)
{
this
.
createDate
=
createDate
;
this
.
createDate
=
createDate
;
}
}
public
String
getErrorMsg
()
{
public
String
getErrorMsg
()
{
return
errorMsg
;
return
errorMsg
;
}
}
public
void
setErrorMsg
(
String
errorMsg
)
{
public
void
setErrorMsg
(
String
errorMsg
)
{
this
.
errorMsg
=
errorMsg
;
this
.
errorMsg
=
errorMsg
;
}
}
public
int
getTemplateLv
()
{
public
int
getTemplateLv
()
{
return
templateLv
;
return
templateLv
;
}
}
public
void
setTemplateLv
(
int
templateLv
)
{
public
void
setTemplateLv
(
int
templateLv
)
{
this
.
templateLv
=
templateLv
;
this
.
templateLv
=
templateLv
;
}
}
public
String
getTemplateCreator
()
{
public
String
getTemplateCreator
()
{
return
templateCreator
;
return
templateCreator
;
}
}
public
void
setTemplateCreator
(
String
templateCreator
)
{
public
void
setTemplateCreator
(
String
templateCreator
)
{
this
.
templateCreator
=
templateCreator
;
this
.
templateCreator
=
templateCreator
;
}
}
public
boolean
isHandle
()
{
public
boolean
isHandle
()
{
return
handle
;
return
handle
;
}
}
public
void
setHandle
(
boolean
handle
)
{
public
void
setHandle
(
boolean
handle
)
{
this
.
handle
=
handle
;
this
.
handle
=
handle
;
}
}
public
Date
getHandleDate
()
{
public
Date
getHandleDate
()
{
return
handleDate
;
return
handleDate
;
}
}
public
void
setHandleDate
(
Date
handleDate
)
{
public
void
setHandleDate
(
Date
handleDate
)
{
this
.
handleDate
=
handleDate
;
this
.
handleDate
=
handleDate
;
}
}
public
String
getHandler
()
{
public
String
getHandler
()
{
return
handler
;
return
handler
;
}
}
public
void
setHandler
(
String
handler
)
{
public
void
setHandler
(
String
handler
)
{
this
.
handler
=
handler
;
this
.
handler
=
handler
;
}
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"Message [messageId="
+
messageId
+
", tempName="
+
tempName
+
", createDate="
+
createDate
return
"Message [messageId="
+
messageId
+
", tempName="
+
tempName
+
", createDate="
+
createDate
...
...
src/main/java/com/zhiwei/manage/bean/News.java
View file @
515b4bc9
...
@@ -4,11 +4,16 @@ import java.io.Serializable;
...
@@ -4,11 +4,16 @@ import java.io.Serializable;
import
java.util.Date
;
import
java.util.Date
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
/**
* 新闻类
*
* @author admin
*
*/
@Component
@Component
public
class
News
implements
Serializable
{
public
class
News
implements
Serializable
{
@Id
@Id
private
String
id
;
private
String
id
;
...
@@ -22,80 +27,100 @@ public class News implements Serializable{
...
@@ -22,80 +27,100 @@ public class News implements Serializable{
private
long
savetime
;
private
long
savetime
;
private
String
spyderInfoId
;
private
String
spyderInfoId
;
private
String
rsid
;
private
String
rsid
;
public
String
getId
()
{
public
String
getId
()
{
return
id
;
return
id
;
}
}
public
void
setId
(
String
id
)
{
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
this
.
id
=
id
;
}
}
public
String
getUrl
()
{
public
String
getUrl
()
{
return
url
;
return
url
;
}
}
public
void
setUrl
(
String
url
)
{
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
this
.
url
=
url
;
}
}
public
String
getTitle
()
{
public
String
getTitle
()
{
return
title
;
return
title
;
}
}
public
void
setTitle
(
String
title
)
{
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
this
.
title
=
title
;
}
}
public
String
getContent
()
{
public
String
getContent
()
{
return
content
;
return
content
;
}
}
public
void
setContent
(
String
content
)
{
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
this
.
content
=
content
;
}
}
public
Date
getTime
()
{
public
Date
getTime
()
{
return
time
;
return
time
;
}
}
public
void
setTime
(
Date
time
)
{
public
void
setTime
(
Date
time
)
{
this
.
time
=
time
;
this
.
time
=
time
;
}
}
public
String
getSource
()
{
public
String
getSource
()
{
return
source
;
return
source
;
}
}
public
void
setSource
(
String
source
)
{
public
void
setSource
(
String
source
)
{
this
.
source
=
source
;
this
.
source
=
source
;
}
}
public
String
getType
()
{
public
String
getType
()
{
return
type
;
return
type
;
}
}
public
void
setType
(
String
type
)
{
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
this
.
type
=
type
;
}
}
public
String
getPt
()
{
public
String
getPt
()
{
return
pt
;
return
pt
;
}
}
public
void
setPt
(
String
pt
)
{
public
void
setPt
(
String
pt
)
{
this
.
pt
=
pt
;
this
.
pt
=
pt
;
}
}
public
long
getSavetime
()
{
public
long
getSavetime
()
{
return
savetime
;
return
savetime
;
}
}
public
void
setSavetime
(
long
savetime
)
{
public
void
setSavetime
(
long
savetime
)
{
this
.
savetime
=
savetime
;
this
.
savetime
=
savetime
;
}
}
public
String
getSpyderInfoId
()
{
public
String
getSpyderInfoId
()
{
return
spyderInfoId
;
return
spyderInfoId
;
}
}
public
void
setSpyderInfoId
(
String
spyderInfoId
)
{
public
void
setSpyderInfoId
(
String
spyderInfoId
)
{
this
.
spyderInfoId
=
spyderInfoId
;
this
.
spyderInfoId
=
spyderInfoId
;
}
}
public
String
getRsid
()
{
public
String
getRsid
()
{
return
rsid
;
return
rsid
;
}
}
public
void
setRsid
(
String
rsid
)
{
public
void
setRsid
(
String
rsid
)
{
this
.
rsid
=
rsid
;
this
.
rsid
=
rsid
;
}
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"News [id="
+
id
+
", url="
+
url
+
", title="
+
title
+
", content="
+
content
+
", time="
+
time
return
"News [id="
+
id
+
", url="
+
url
+
", title="
+
title
+
", content="
+
content
+
", time="
+
time
+
", source="
+
source
+
", type="
+
type
+
", pt="
+
pt
+
", savetime="
+
savetime
+
", spyderInfoId="
+
", source="
+
source
+
", type="
+
type
+
", pt="
+
pt
+
", savetime="
+
savetime
+
", spyderInfoId="
+
spyderInfoId
+
", rsid="
+
rsid
+
"]"
;
+
spyderInfoId
+
", rsid="
+
rsid
+
"]"
;
}
}
}
}
src/main/java/com/zhiwei/manage/bean/PageEty.java
View file @
515b4bc9
...
@@ -3,48 +3,63 @@ package com.zhiwei.manage.bean;
...
@@ -3,48 +3,63 @@ package com.zhiwei.manage.bean;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.List
;
import
org.apache.poi.ss.formula.functions.T
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
/**
* 分页类
*
* @author admin
*
*/
@Component
@Component
public
class
PageEty
implements
Serializable
{
public
class
PageEty
implements
Serializable
{
private
int
pageNo
;
private
int
pageNo
;
private
int
pageSize
;
private
int
pageSize
;
private
List
data
;
private
List
data
;
private
int
dataCount
;
private
int
dataCount
;
private
int
pageCount
;
private
int
pageCount
;
public
int
getPageCount
()
{
public
int
getPageCount
()
{
return
pageCount
;
return
pageCount
;
}
}
public
void
setPageCount
(
int
pageCount
)
{
public
void
setPageCount
(
int
pageCount
)
{
this
.
pageCount
=
pageCount
;
this
.
pageCount
=
pageCount
;
}
}
public
int
getPageNo
()
{
public
int
getPageNo
()
{
return
pageNo
;
return
pageNo
;
}
}
public
void
setPageNo
(
int
pageNo
)
{
public
void
setPageNo
(
int
pageNo
)
{
this
.
pageNo
=
pageNo
;
this
.
pageNo
=
pageNo
;
}
}
public
int
getPageSize
()
{
public
int
getPageSize
()
{
return
pageSize
;
return
pageSize
;
}
}
public
void
setPageSize
(
int
pageSize
)
{
public
void
setPageSize
(
int
pageSize
)
{
this
.
pageSize
=
pageSize
;
this
.
pageSize
=
pageSize
;
}
}
public
List
getData
()
{
public
List
getData
()
{
return
data
;
return
data
;
}
}
public
void
setData
(
List
data
)
{
public
void
setData
(
List
data
)
{
this
.
data
=
data
;
this
.
data
=
data
;
}
}
public
int
getDataCount
()
{
public
int
getDataCount
()
{
return
dataCount
;
return
dataCount
;
}
}
public
void
setDataCount
(
int
dataCount
)
{
public
void
setDataCount
(
int
dataCount
)
{
this
.
dataCount
=
dataCount
;
this
.
dataCount
=
dataCount
;
}
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"PageEty [pageNo="
+
pageNo
+
", pageSize="
+
pageSize
+
", data="
+
data
+
", dataCount="
+
dataCount
return
"PageEty [pageNo="
+
pageNo
+
", pageSize="
+
pageSize
+
", data="
+
data
+
", dataCount="
+
dataCount
...
@@ -53,7 +68,5 @@ public class PageEty implements Serializable{
...
@@ -53,7 +68,5 @@ public class PageEty implements Serializable{
+
", getClass()="
+
getClass
()
+
", hashCode()="
+
hashCode
()
+
", toString()="
+
super
.
toString
()
+
", getClass()="
+
getClass
()
+
", hashCode()="
+
hashCode
()
+
", toString()="
+
super
.
toString
()
+
"]"
;
+
"]"
;
}
}
}
}
src/main/java/com/zhiwei/manage/bean/Person.java
View file @
515b4bc9
...
@@ -8,10 +8,15 @@ import org.springframework.data.mongodb.core.index.Indexed;
...
@@ -8,10 +8,15 @@ import org.springframework.data.mongodb.core.index.Indexed;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.data.mongodb.core.mapping.Field
;
import
org.springframework.data.mongodb.core.mapping.Field
;
/**
* 用户类
*
* @author admin
*
*/
@Document
(
collection
=
"Person"
)
@Document
(
collection
=
"Person"
)
public
class
Person
implements
Serializable
{
public
class
Person
implements
Serializable
{
@Indexed
@Indexed
@Id
@Id
private
String
personId
;
private
String
personId
;
...
...
src/main/java/com/zhiwei/manage/bean/PingUrl.java
View file @
515b4bc9
...
@@ -5,6 +5,12 @@ import java.util.Date;
...
@@ -5,6 +5,12 @@ import java.util.Date;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
/**
* 网站连通测试
*
* @author admin
*
*/
@Component
@Component
public
class
PingUrl
implements
Serializable
{
public
class
PingUrl
implements
Serializable
{
...
...
src/main/java/com/zhiwei/manage/bean/RunMsg.java
View file @
515b4bc9
...
@@ -6,10 +6,15 @@ import java.util.List;
...
@@ -6,10 +6,15 @@ import java.util.List;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
/**
* 运行信息
*
* @author admin
*
*/
@Component
@Component
public
class
RunMsg
implements
Serializable
{
public
class
RunMsg
implements
Serializable
{
private
String
templateId
;
private
String
templateId
;
private
String
templateName
;
private
String
templateName
;
private
String
runType
;
// 运行类型
private
String
runType
;
// 运行类型
...
@@ -17,7 +22,7 @@ public class RunMsg implements Serializable {
...
@@ -17,7 +22,7 @@ public class RunMsg implements Serializable {
private
String
errorMsg
;
private
String
errorMsg
;
private
Date
nextRun
;
private
Date
nextRun
;
private
boolean
runNow
;
private
boolean
runNow
;
private
String
field
;
//查询字段
private
String
field
;
//
查询字段
private
String
value
;
private
String
value
;
private
double
rate
;
private
double
rate
;
private
List
<
String
>
fields
;
private
List
<
String
>
fields
;
...
@@ -117,5 +122,4 @@ public class RunMsg implements Serializable {
...
@@ -117,5 +122,4 @@ public class RunMsg implements Serializable {
+
", field="
+
field
+
", value="
+
value
+
", rate="
+
rate
+
", fields="
+
fields
+
"]"
;
+
", field="
+
field
+
", value="
+
value
+
", rate="
+
rate
+
", fields="
+
fields
+
"]"
;
}
}
}
}
src/main/java/com/zhiwei/manage/bean/Template.java
View file @
515b4bc9
...
@@ -2,15 +2,18 @@ package com.zhiwei.manage.bean;
...
@@ -2,15 +2,18 @@ package com.zhiwei.manage.bean;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
org.springframework.context.annotation.ComponentScan.Filter
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.index.Indexed
;
import
org.springframework.data.mongodb.core.index.Indexed
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.data.mongodb.core.mapping.Field
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
/**
* 检测模板
*
* @author admin
*
*/
@Component
@Component
@Document
(
collection
=
"Template"
)
@Document
(
collection
=
"Template"
)
public
class
Template
implements
Serializable
{
public
class
Template
implements
Serializable
{
...
...
src/main/java/com/zhiwei/manage/bean/Weibo.java
View file @
515b4bc9
...
@@ -6,8 +6,15 @@ import java.util.Date;
...
@@ -6,8 +6,15 @@ import java.util.Date;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Field
;
import
org.springframework.data.mongodb.core.mapping.Field
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
/**
* 微博类
*
* @author admin
*
*/
@Component
@Component
public
class
Weibo
implements
Serializable
{
public
class
Weibo
implements
Serializable
{
@Id
@Id
private
String
id
;
private
String
id
;
...
@@ -26,7 +33,7 @@ public class Weibo implements Serializable{
...
@@ -26,7 +33,7 @@ public class Weibo implements Serializable{
@Field
(
"weibo_img"
)
@Field
(
"weibo_img"
)
private
String
weiboImg
;
private
String
weiboImg
;
private
int
vtype
;
private
int
vtype
;
private
int
fensi
;
private
int
fensi
;
private
int
guanzhu
;
private
int
guanzhu
;
private
int
weibo
;
private
int
weibo
;
private
String
description
;
private
String
description
;
...
@@ -37,147 +44,189 @@ public class Weibo implements Serializable{
...
@@ -37,147 +44,189 @@ public class Weibo implements Serializable{
private
Date
ins
;
private
Date
ins
;
private
int
isForward
;
private
int
isForward
;
private
int
rstime
;
private
int
rstime
;
public
String
getId
()
{
public
String
getId
()
{
return
id
;
return
id
;
}
}
public
void
setId
(
String
id
)
{
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
this
.
id
=
id
;
}
}
public
String
getTime
()
{
public
String
getTime
()
{
return
time
;
return
time
;
}
}
public
void
setTime
(
String
time
)
{
public
void
setTime
(
String
time
)
{
this
.
time
=
time
;
this
.
time
=
time
;
}
}
public
int
getMonth
()
{
public
int
getMonth
()
{
return
month
;
return
month
;
}
}
public
void
setMonth
(
int
month
)
{
public
void
setMonth
(
int
month
)
{
this
.
month
=
month
;
this
.
month
=
month
;
}
}
public
String
getText
()
{
public
String
getText
()
{
return
text
;
return
text
;
}
}
public
void
setText
(
String
text
)
{
public
void
setText
(
String
text
)
{
this
.
text
=
text
;
this
.
text
=
text
;
}
}
public
String
getUserId
()
{
public
String
getUserId
()
{
return
userId
;
return
userId
;
}
}
public
void
setUserId
(
String
userId
)
{
public
void
setUserId
(
String
userId
)
{
this
.
userId
=
userId
;
this
.
userId
=
userId
;
}
}
public
String
getUsername
()
{
public
String
getUsername
()
{
return
username
;
return
username
;
}
}
public
void
setUsername
(
String
username
)
{
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
this
.
username
=
username
;
}
}
public
String
getSource
()
{
public
String
getSource
()
{
return
source
;
return
source
;
}
}
public
void
setSource
(
String
source
)
{
public
void
setSource
(
String
source
)
{
this
.
source
=
source
;
this
.
source
=
source
;
}
}
public
int
getRetweet_count
()
{
public
int
getRetweet_count
()
{
return
retweet_count
;
return
retweet_count
;
}
}
public
void
setRetweet_count
(
int
retweet_count
)
{
public
void
setRetweet_count
(
int
retweet_count
)
{
this
.
retweet_count
=
retweet_count
;
this
.
retweet_count
=
retweet_count
;
}
}
public
int
getReply_count
()
{
public
int
getReply_count
()
{
return
reply_count
;
return
reply_count
;
}
}
public
void
setReply_count
(
int
reply_count
)
{
public
void
setReply_count
(
int
reply_count
)
{
this
.
reply_count
=
reply_count
;
this
.
reply_count
=
reply_count
;
}
}
public
String
getUrl
()
{
public
String
getUrl
()
{
return
url
;
return
url
;
}
}
public
void
setUrl
(
String
url
)
{
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
this
.
url
=
url
;
}
}
public
String
getImageUrl
()
{
public
String
getImageUrl
()
{
return
imageUrl
;
return
imageUrl
;
}
}
public
void
setImageUrl
(
String
imageUrl
)
{
public
void
setImageUrl
(
String
imageUrl
)
{
this
.
imageUrl
=
imageUrl
;
this
.
imageUrl
=
imageUrl
;
}
}
public
String
getWeiboImg
()
{
public
String
getWeiboImg
()
{
return
weiboImg
;
return
weiboImg
;
}
}
public
void
setWeiboImg
(
String
weiboImg
)
{
public
void
setWeiboImg
(
String
weiboImg
)
{
this
.
weiboImg
=
weiboImg
;
this
.
weiboImg
=
weiboImg
;
}
}
public
int
getVtype
()
{
public
int
getVtype
()
{
return
vtype
;
return
vtype
;
}
}
public
void
setVtype
(
int
vtype
)
{
public
void
setVtype
(
int
vtype
)
{
this
.
vtype
=
vtype
;
this
.
vtype
=
vtype
;
}
}
public
int
getFensi
()
{
public
int
getFensi
()
{
return
fensi
;
return
fensi
;
}
}
public
void
setFensi
(
int
fensi
)
{
public
void
setFensi
(
int
fensi
)
{
this
.
fensi
=
fensi
;
this
.
fensi
=
fensi
;
}
}
public
int
getGuanzhu
()
{
public
int
getGuanzhu
()
{
return
guanzhu
;
return
guanzhu
;
}
}
public
void
setGuanzhu
(
int
guanzhu
)
{
public
void
setGuanzhu
(
int
guanzhu
)
{
this
.
guanzhu
=
guanzhu
;
this
.
guanzhu
=
guanzhu
;
}
}
public
int
getWeibo
()
{
public
int
getWeibo
()
{
return
weibo
;
return
weibo
;
}
}
public
void
setWeibo
(
int
weibo
)
{
public
void
setWeibo
(
int
weibo
)
{
this
.
weibo
=
weibo
;
this
.
weibo
=
weibo
;
}
}
public
String
getDescription
()
{
public
String
getDescription
()
{
return
description
;
return
description
;
}
}
public
void
setDescription
(
String
description
)
{
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
this
.
description
=
description
;
}
}
public
String
getPicUrls
()
{
public
String
getPicUrls
()
{
return
picUrls
;
return
picUrls
;
}
}
public
void
setPicUrls
(
String
picUrls
)
{
public
void
setPicUrls
(
String
picUrls
)
{
this
.
picUrls
=
picUrls
;
this
.
picUrls
=
picUrls
;
}
}
public
String
getSex
()
{
public
String
getSex
()
{
return
sex
;
return
sex
;
}
}
public
void
setSex
(
String
sex
)
{
public
void
setSex
(
String
sex
)
{
this
.
sex
=
sex
;
this
.
sex
=
sex
;
}
}
public
String
getLocation
()
{
public
String
getLocation
()
{
return
location
;
return
location
;
}
}
public
void
setLocation
(
String
location
)
{
public
void
setLocation
(
String
location
)
{
this
.
location
=
location
;
this
.
location
=
location
;
}
}
public
Date
getIns
()
{
public
Date
getIns
()
{
return
ins
;
return
ins
;
}
}
public
void
setIns
(
Date
ins
)
{
public
void
setIns
(
Date
ins
)
{
this
.
ins
=
ins
;
this
.
ins
=
ins
;
}
}
public
int
getIsForward
()
{
public
int
getIsForward
()
{
return
isForward
;
return
isForward
;
}
}
public
void
setIsForward
(
int
isForward
)
{
public
void
setIsForward
(
int
isForward
)
{
this
.
isForward
=
isForward
;
this
.
isForward
=
isForward
;
}
}
public
int
getRstime
()
{
public
int
getRstime
()
{
return
rstime
;
return
rstime
;
}
}
public
void
setRstime
(
int
rstime
)
{
public
void
setRstime
(
int
rstime
)
{
this
.
rstime
=
rstime
;
this
.
rstime
=
rstime
;
}
}
}
}
src/main/java/com/zhiwei/manage/dao/MessageDao.java
View file @
515b4bc9
...
@@ -8,22 +8,22 @@ public interface MessageDao {
...
@@ -8,22 +8,22 @@ public interface MessageDao {
public
String
insert
(
Message
message
);
public
String
insert
(
Message
message
);
public
String
update
(
Message
message
,
String
pt
);
public
String
update
(
Message
message
,
String
pt
);
public
List
<
Message
>
findAll
(
int
pageNo
,
int
pageSize
,
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
List
<
Message
>
findByTmpName
(
String
templateName
,
int
pageNo
,
int
pageSize
,
String
pt
);
public
boolean
delete
(
List
<
String
>
MessageId
,
String
pt
);
public
boolean
delete
(
List
<
String
>
MessageId
,
String
pt
);
public
int
allCount
(
String
pt
);
public
int
allCount
(
String
pt
);
public
int
findByTmpCount
(
String
templateName
,
String
pt
);
public
int
findByTmpCount
(
String
templateName
,
String
pt
);
public
List
<
Message
>
findByHandle
(
int
pageNo
,
int
pageSize
,
boolean
handle
,
String
tempName
,
String
pt
);
public
List
<
Message
>
findByHandle
(
int
pageNo
,
int
pageSize
,
boolean
handle
,
String
tempName
,
String
pt
);
public
int
findByHandleCount
(
int
pageNo
,
int
pageSize
,
boolean
handle
,
String
tempName
,
String
pt
);
public
int
findByHandleCount
(
int
pageNo
,
int
pageSize
,
boolean
handle
,
String
tempName
,
String
pt
);
public
Message
findMsg
(
String
tempName
,
String
errorType
);
public
Message
findMsg
(
String
tempName
,
String
errorType
);
}
}
src/main/java/com/zhiwei/manage/handle/DbDepot.java
View file @
515b4bc9
...
@@ -2,7 +2,9 @@ package com.zhiwei.manage.handle;
...
@@ -2,7 +2,9 @@ package com.zhiwei.manage.handle;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentMap
;
import
java.util.concurrent.ConcurrentMap
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
...
@@ -10,6 +12,12 @@ import org.springframework.stereotype.Service;
...
@@ -10,6 +12,12 @@ import org.springframework.stereotype.Service;
import
com.zhiwei.manage.bean.ServerBean
;
import
com.zhiwei.manage.bean.ServerBean
;
/**
* 初始化
*
* @author admin
*
*/
@Service
(
"firstRun"
)
@Service
(
"firstRun"
)
public
class
DbDepot
{
public
class
DbDepot
{
...
@@ -24,6 +32,5 @@ public class DbDepot {
...
@@ -24,6 +32,5 @@ public class DbDepot {
log
.
info
(
"数据连接map初始化"
);
log
.
info
(
"数据连接map初始化"
);
esClients
=
new
ConcurrentHashMap
<
String
,
Object
>();
esClients
=
new
ConcurrentHashMap
<
String
,
Object
>();
serverBeans
=
new
ConcurrentHashMap
<
String
,
ServerBean
>();
serverBeans
=
new
ConcurrentHashMap
<
String
,
ServerBean
>();
System
.
out
.
println
(
"连接初始化成功"
);
}
}
}
}
src/main/java/com/zhiwei/manage/handle/DelayedThread.java
View file @
515b4bc9
...
@@ -15,19 +15,25 @@ import org.springframework.stereotype.Component;
...
@@ -15,19 +15,25 @@ import org.springframework.stereotype.Component;
import
com.zhiwei.manage.bean.NewsDelayed
;
import
com.zhiwei.manage.bean.NewsDelayed
;
import
com.zhiwei.manage.util.Tools
;
import
com.zhiwei.manage.util.Tools
;
/**
* 延时检测线程
*
* @author admin
*
*/
@Component
@Component
public
class
DelayedThread
extends
Thread
{
public
class
DelayedThread
extends
Thread
{
private
static
final
Log
log
=
LogFactory
.
getLog
(
DelayedThread
.
class
);
private
static
final
Log
log
=
LogFactory
.
getLog
(
DelayedThread
.
class
);
private
static
boolean
isrun
=
true
;
private
static
boolean
isrun
=
true
;
public
static
Map
<
String
,
NewsDelayed
>
runMap
=
new
ConcurrentHashMap
<
String
,
NewsDelayed
>();
public
static
Map
<
String
,
NewsDelayed
>
runMap
=
new
ConcurrentHashMap
<
String
,
NewsDelayed
>();
public
static
Queue
<
NewsDelayed
>
queue
=
new
LinkedBlockingQueue
<
NewsDelayed
>(
500
);
public
static
Queue
<
NewsDelayed
>
queue
=
new
LinkedBlockingQueue
<
NewsDelayed
>(
500
);
public
DelayedThread
(){
public
DelayedThread
()
{
this
.
start
();
this
.
start
();
}
}
public
void
stopMe
()
{
public
void
stopMe
()
{
isrun
=
false
;
isrun
=
false
;
}
}
...
@@ -41,7 +47,7 @@ public class DelayedThread extends Thread {
...
@@ -41,7 +47,7 @@ public class DelayedThread extends Thread {
String
key
=
it
.
next
();
String
key
=
it
.
next
();
NewsDelayed
run
=
runMap
.
get
(
key
);
NewsDelayed
run
=
runMap
.
get
(
key
);
Calendar
cal
=
Calendar
.
getInstance
();
Calendar
cal
=
Calendar
.
getInstance
();
if
(
run
.
getNextRun
().
before
(
cal
.
getTime
())
&&
!
run
.
isStartNow
())
{
if
(
run
.
getNextRun
().
before
(
cal
.
getTime
())
&&
!
run
.
isStartNow
())
{
queue
.
offer
(
run
);
queue
.
offer
(
run
);
cal
.
add
(
Calendar
.
HOUR
,
run
.
getDelayedInterval
());
cal
.
add
(
Calendar
.
HOUR
,
run
.
getDelayedInterval
());
run
.
setNextRun
(
cal
.
getTime
());
run
.
setNextRun
(
cal
.
getTime
());
...
...
src/main/java/com/zhiwei/manage/handle/FieldThread.java
View file @
515b4bc9
...
@@ -17,6 +17,12 @@ import org.springframework.stereotype.Component;
...
@@ -17,6 +17,12 @@ import org.springframework.stereotype.Component;
import
com.zhiwei.manage.bean.FieldIntegerity
;
import
com.zhiwei.manage.bean.FieldIntegerity
;
import
com.zhiwei.manage.util.Tools
;
import
com.zhiwei.manage.util.Tools
;
/**
* 字段检测线程
*
* @author admin
*
*/
@Component
@Component
public
class
FieldThread
extends
Thread
{
public
class
FieldThread
extends
Thread
{
...
@@ -26,10 +32,10 @@ public class FieldThread extends Thread {
...
@@ -26,10 +32,10 @@ public class FieldThread extends Thread {
private
static
final
Log
log
=
LogFactory
.
getLog
(
FieldThread
.
class
);
private
static
final
Log
log
=
LogFactory
.
getLog
(
FieldThread
.
class
);
private
static
Lock
fieldLock
=
new
ReentrantLock
();
private
static
Lock
fieldLock
=
new
ReentrantLock
();
public
FieldThread
(){
public
FieldThread
()
{
this
.
start
();
this
.
start
();
}
}
public
void
stopMe
()
{
public
void
stopMe
()
{
isrun
=
false
;
isrun
=
false
;
}
}
...
...
src/main/java/com/zhiwei/manage/handle/MainThread.java
View file @
515b4bc9
package
com
.
zhiwei
.
manage
.
handle
;
package
com
.
zhiwei
.
manage
.
handle
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -34,6 +35,12 @@ import com.zhiwei.manage.util.ESUtil;
...
@@ -34,6 +35,12 @@ import com.zhiwei.manage.util.ESUtil;
import
com.zhiwei.manage.util.SendMailUtil
;
import
com.zhiwei.manage.util.SendMailUtil
;
import
com.zhiwei.manage.util.TimeUtil
;
import
com.zhiwei.manage.util.TimeUtil
;
/**
* 主要执行线程
*
* @author admin
*
*/
@Component
@Component
public
class
MainThread
extends
Thread
{
public
class
MainThread
extends
Thread
{
...
@@ -197,21 +204,24 @@ public class MainThread extends Thread {
...
@@ -197,21 +204,24 @@ public class MainThread extends Thread {
dataService
.
insert
(
data
);
dataService
.
insert
(
data
);
log
.
info
(
sdf
.
format
(
start
.
getTime
())
+
"|"
+
chan
.
getPt
()
+
"|入库"
);
log
.
info
(
sdf
.
format
(
start
.
getTime
())
+
"|"
+
chan
.
getPt
()
+
"|入库"
);
count
=
es
.
getCountByPt
(
inTime
.
getTime
(),
end
.
getTime
(),
chan
.
getPt
(),
chan
.
getValue
(),
ser
);
// 小时的数据量
count
=
es
.
getCountByPt
(
inTime
.
getTime
(),
end
.
getTime
(),
chan
.
getPt
(),
chan
.
getValue
(),
ser
);
// 小时的数据量
if
(
counts
.
get
(
chan
.
getPt
())
!=
null
)
if
(
start
.
get
(
Calendar
.
HOUR_OF_DAY
)
>
6
)
if
(
count
<
counts
.
get
(
chan
.
getPt
()))
{
if
(
counts
.
get
(
chan
.
getPt
())
!=
null
)
Messages
m
=
new
Messages
();
if
(
count
<
counts
.
get
(
chan
.
getPt
()))
{
m
.
setTitle
(
"渠道低数据量预警{"
+
chan
.
getPt
()
+
"}"
);
Messages
m
=
new
Messages
();
m
.
setContent
(
"1小时内的数据量为:"
+
count
);
m
.
setTitle
(
"渠道低数据量预警{"
+
chan
.
getPt
()
+
"}"
);
m
.
setDate
(
sdf
.
format
(
start
.
getTime
()));
m
.
setContent
(
"1小时内的数据量为:"
+
count
);
for
(
String
mail
:
Config
.
getVal
(
"count_mail"
).
split
(
","
))
{
m
.
setDate
(
sdf
.
format
(
start
.
getTime
()));
SendMailUtil
.
sendMessage
(
mail
,
m
);
for
(
String
mail
:
Config
.
getVal
(
"count_mail"
).
split
(
","
))
{
SendMailUtil
.
sendMessage
(
mail
,
m
);
}
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
chan
.
getPt
()
+
"入库出错,错误信息{}"
,
e
);
log
.
error
(
chan
.
getPt
()
+
"入库出错,错误信息{}"
,
e
);
}
}
}
}
Set
<
String
>
keys
=
allTmp
.
keySet
();
Set
<
String
>
keys
=
allTmp
.
keySet
();
List
<
Message
>
needRemoveWm
=
new
ArrayList
<>();
List
<
Message
>
needRemovePm
=
new
ArrayList
<>();
for
(
Iterator
<
String
>
it
=
keys
.
iterator
();
it
.
hasNext
();)
{
for
(
Iterator
<
String
>
it
=
keys
.
iterator
();
it
.
hasNext
();)
{
String
key
=
it
.
next
();
String
key
=
it
.
next
();
Template
tmp
=
allTmp
.
get
(
key
);
Template
tmp
=
allTmp
.
get
(
key
);
...
@@ -239,6 +249,15 @@ public class MainThread extends Thread {
...
@@ -239,6 +249,15 @@ public class MainThread extends Thread {
msg
.
setPt
(
pt
);
msg
.
setPt
(
pt
);
msg
.
setTemplateLv
(
1
);
msg
.
setTemplateLv
(
1
);
messageService
.
insert
(
msg
);
messageService
.
insert
(
msg
);
}
else
{
Message
msg
=
messageService
.
findMsg
(
tmp
.
getTempName
(),
null
);
if
(
msg
!=
null
)
{
if
(
msg
.
getPt
().
equals
(
"网媒"
))
{
needRemoveWm
.
add
(
msg
);
}
else
{
needRemovePm
.
add
(
msg
);
}
}
}
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
src/main/java/com/zhiwei/manage/handle/PingThread.java
View file @
515b4bc9
...
@@ -17,6 +17,12 @@ import org.springframework.stereotype.Component;
...
@@ -17,6 +17,12 @@ import org.springframework.stereotype.Component;
import
com.zhiwei.manage.bean.PingUrl
;
import
com.zhiwei.manage.bean.PingUrl
;
import
com.zhiwei.manage.util.Tools
;
import
com.zhiwei.manage.util.Tools
;
/**
* 连通性线程
*
* @author admin
*
*/
@Component
@Component
public
class
PingThread
extends
Thread
{
public
class
PingThread
extends
Thread
{
...
...
src/main/java/com/zhiwei/manage/handle/QueueTask.java
View file @
515b4bc9
...
@@ -7,10 +7,16 @@ import org.springframework.stereotype.Component;
...
@@ -7,10 +7,16 @@ import org.springframework.stereotype.Component;
import
com.zhiwei.manage.util.ThreadPool
;
import
com.zhiwei.manage.util.ThreadPool
;
import
com.zhiwei.manage.util.Tools
;
import
com.zhiwei.manage.util.Tools
;
/**
* 队列线程
*
* @author admin
*
*/
@Component
@Component
public
class
QueueTask
extends
Thread
{
public
class
QueueTask
extends
Thread
{
private
static
final
Log
log
=
LogFactory
.
getLog
(
QueueTask
.
class
);
private
static
final
Log
log
=
LogFactory
.
getLog
(
QueueTask
.
class
);
private
ThreadPool
t
=
ThreadPool
.
getThreadPool
(
30
);
private
ThreadPool
t
=
ThreadPool
.
getThreadPool
(
30
);
private
static
boolean
isRun
=
true
;
private
static
boolean
isRun
=
true
;
...
@@ -26,17 +32,17 @@ public class QueueTask extends Thread {
...
@@ -26,17 +32,17 @@ public class QueueTask extends Thread {
public
void
run
()
{
public
void
run
()
{
log
.
info
(
"队列线程启动"
);
log
.
info
(
"队列线程启动"
);
while
(
isRun
)
{
while
(
isRun
)
{
if
(
FieldThread
.
queue
.
size
()
>
0
)
{
if
(
FieldThread
.
queue
.
size
()
>
0
)
{
t
.
execute
(
new
Task
(
FieldThread
.
queue
.
poll
()));
t
.
execute
(
new
Task
(
FieldThread
.
queue
.
poll
()));
}
else
{
}
else
{
Tools
.
sleep
(
1000
);
Tools
.
sleep
(
1000
);
}
}
if
(
PingThread
.
queue
.
size
()
>
0
)
{
if
(
PingThread
.
queue
.
size
()
>
0
)
{
t
.
execute
(
new
Task
(
PingThread
.
queue
.
poll
()));
t
.
execute
(
new
Task
(
PingThread
.
queue
.
poll
()));
}
else
{
}
else
{
Tools
.
sleep
(
1000
);
Tools
.
sleep
(
1000
);
}
}
if
(
DelayedThread
.
queue
.
size
()
>
0
)
{
if
(
DelayedThread
.
queue
.
size
()
>
0
)
{
t
.
execute
(
new
Task
(
DelayedThread
.
queue
.
poll
()));
t
.
execute
(
new
Task
(
DelayedThread
.
queue
.
poll
()));
}
else
{
}
else
{
Tools
.
sleep
(
1000
);
Tools
.
sleep
(
1000
);
...
...
src/main/java/com/zhiwei/manage/handle/Task.java
View file @
515b4bc9
...
@@ -23,7 +23,7 @@ import com.zhiwei.manage.service.MessageService;
...
@@ -23,7 +23,7 @@ import com.zhiwei.manage.service.MessageService;
import
com.zhiwei.manage.service.NewsService
;
import
com.zhiwei.manage.service.NewsService
;
/**
/**
* 任务执行
* 任务执行
线程
*
*
* @author admin
* @author admin
*
*
...
@@ -207,7 +207,7 @@ public class Task implements Runnable {
...
@@ -207,7 +207,7 @@ public class Task implements Runnable {
List
<
Map
<
String
,
Object
>>
list
=
newsService
.
findNews
(
delayed
.
getHost
(),
delayed
.
getPort
(),
List
<
Map
<
String
,
Object
>>
list
=
newsService
.
findNews
(
delayed
.
getHost
(),
delayed
.
getPort
(),
delayed
.
getdBName
(),
delayed
.
getCollection
(),
delayed
.
getTestCount
(),
delayed
.
getSpyderInfoId
(),
delayed
.
getdBName
(),
delayed
.
getCollection
(),
delayed
.
getTestCount
(),
delayed
.
getSpyderInfoId
(),
delayed
.
getPt
());
delayed
.
getPt
());
log
.
info
(
"size"
+
list
.
size
());
log
.
info
(
"size"
+
list
.
size
());
long
sum
=
0
;
long
sum
=
0
;
if
(
list
.
size
()
==
0
)
{
if
(
list
.
size
()
==
0
)
{
Template
tp
=
MainThread
.
mainMap
.
get
(
delayed
.
getTemplateId
());
Template
tp
=
MainThread
.
mainMap
.
get
(
delayed
.
getTemplateId
());
...
...
src/main/java/com/zhiwei/manage/service/MessageService.java
View file @
515b4bc9
...
@@ -9,15 +9,15 @@ public interface MessageService {
...
@@ -9,15 +9,15 @@ public interface MessageService {
public
void
insert
(
Message
message
);
public
void
insert
(
Message
message
);
public
String
update
(
Message
message
,
String
pt
);
public
String
update
(
Message
message
,
String
pt
);
public
PageEty
findAll
(
int
pageNo
,
int
pageSize
,
String
pt
);
public
PageEty
findAll
(
int
pageNo
,
int
pageSize
,
String
pt
);
public
PageEty
findByTmpName
(
String
templateName
,
int
pageNo
,
int
pageSize
,
String
pt
);
public
PageEty
findByTmpName
(
String
templateName
,
int
pageNo
,
int
pageSize
,
String
pt
);
public
boolean
delete
(
List
<
String
>
MessageId
,
String
pt
);
public
boolean
delete
(
List
<
String
>
MessageId
,
String
pt
);
public
PageEty
findByHandle
(
int
pageNo
,
int
pageSize
,
boolean
handle
,
String
tempName
,
String
pt
);
public
PageEty
findByHandle
(
int
pageNo
,
int
pageSize
,
boolean
handle
,
String
tempName
,
String
pt
);
public
Message
findMsg
(
String
tempName
,
String
errorType
);
public
Message
findMsg
(
String
tempName
,
String
errorType
);
}
}
src/main/java/com/zhiwei/manage/servlet/DataController.java
View file @
515b4bc9
...
@@ -27,6 +27,12 @@ import com.zhiwei.manage.service.DataService;
...
@@ -27,6 +27,12 @@ import com.zhiwei.manage.service.DataService;
import
com.zhiwei.manage.service.ServerService
;
import
com.zhiwei.manage.service.ServerService
;
import
com.zhiwei.manage.util.Tools
;
import
com.zhiwei.manage.util.Tools
;
/**
* 数据控制
*
* @author admin
*
*/
@Controller
@Controller
public
class
DataController
{
public
class
DataController
{
...
@@ -37,6 +43,13 @@ public class DataController {
...
@@ -37,6 +43,13 @@ public class DataController {
@Autowired
@Autowired
private
ServerService
serverService
;
private
ServerService
serverService
;
/**
* 获取数据
*
* @param request
* @param response
* @return
*/
@RequestMapping
(
value
=
"/getData"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/getData"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
getData
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
String
getData
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
...
@@ -46,6 +59,14 @@ public class DataController {
...
@@ -46,6 +59,14 @@ public class DataController {
return
JSON
.
toJSONString
(
list
);
return
JSON
.
toJSONString
(
list
);
}
}
/**
* 根据;来源获取数据
*
* @param request
* @param response
* @param map
* @return
*/
@RequestMapping
(
value
=
"/getDataBySource"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/getDataBySource"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
getDataBySource
(
HttpServletRequest
request
,
HttpServletResponse
response
,
public
String
getDataBySource
(
HttpServletRequest
request
,
HttpServletResponse
response
,
...
@@ -61,6 +82,15 @@ public class DataController {
...
@@ -61,6 +82,15 @@ public class DataController {
return
JSON
.
toJSONString
(
list
);
return
JSON
.
toJSONString
(
list
);
}
}
/**
* 根据对应字段获取数据
*
* @param request
* @param response
* @param map
* @return
* @throws UnsupportedEncodingException
*/
@RequestMapping
(
value
=
"/getDataByTempName"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/getDataByTempName"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
getDataByTempName
(
HttpServletRequest
request
,
HttpServletResponse
response
,
public
String
getDataByTempName
(
HttpServletRequest
request
,
HttpServletResponse
response
,
...
@@ -114,6 +144,12 @@ public class DataController {
...
@@ -114,6 +144,12 @@ public class DataController {
}
}
}
}
/**
* 获取所有的数据
*
* @param map
* @return
*/
@RequestMapping
(
value
=
"/getDataAll"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/getDataAll"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
getAllData
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
getAllData
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
...
@@ -153,12 +189,18 @@ public class DataController {
...
@@ -153,12 +189,18 @@ public class DataController {
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"处理错误,错误信息{}"
,
e
);
log
.
error
(
"处理错误,错误信息{}"
,
e
);
JsonResult
result
=
new
JsonResult
(
false
,
500
,
e
.
getMessage
(),
""
);
JsonResult
result
=
new
JsonResult
(
false
,
500
,
e
.
getMessage
(),
""
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
}
}
/**
* 根据来源获取数据
*
* @param map
* @return
*/
@RequestMapping
(
value
=
"/getDayDataByChannel"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/getDayDataByChannel"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
getDayDataByChannel
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
getDayDataByChannel
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
...
@@ -179,12 +221,19 @@ public class DataController {
...
@@ -179,12 +221,19 @@ public class DataController {
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"请求成功"
,
datas
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"请求成功"
,
datas
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"处理错误,错误信息{}"
,
e
);
log
.
error
(
"处理错误,错误信息{}"
,
e
);
JsonResult
result
=
new
JsonResult
(
false
,
500
,
e
.
getMessage
(),
""
);
JsonResult
result
=
new
JsonResult
(
false
,
500
,
e
.
getMessage
(),
""
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
}
}
/**
* 根据来源名获取
*
* @param map
* @param req
* @return
*/
@RequestMapping
(
value
=
"/getSource"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/getSource"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
getSource
(
@RequestBody
Map
<
String
,
Object
>
map
,
HttpServletRequest
req
)
{
public
String
getSource
(
@RequestBody
Map
<
String
,
Object
>
map
,
HttpServletRequest
req
)
{
...
...
src/main/java/com/zhiwei/manage/servlet/FieldController.java
View file @
515b4bc9
...
@@ -15,6 +15,12 @@ import com.zhiwei.manage.bean.JsonResult;
...
@@ -15,6 +15,12 @@ import com.zhiwei.manage.bean.JsonResult;
import
com.zhiwei.manage.bean.PageEty
;
import
com.zhiwei.manage.bean.PageEty
;
import
com.zhiwei.manage.service.FieldBeanService
;
import
com.zhiwei.manage.service.FieldBeanService
;
/**
* 字段
*
* @author admin
*
*/
@Controller
@Controller
public
class
FieldController
{
public
class
FieldController
{
...
@@ -37,6 +43,12 @@ public class FieldController {
...
@@ -37,6 +43,12 @@ public class FieldController {
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 更新字段表信息
*
* @param fieldBean
* @return
*/
@RequestMapping
(
value
=
"/updateFields"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/updateFields"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
updateField
(
@RequestBody
FieldBean
fieldBean
)
{
public
String
updateField
(
@RequestBody
FieldBean
fieldBean
)
{
...
@@ -45,16 +57,28 @@ public class FieldController {
...
@@ -45,16 +57,28 @@ public class FieldController {
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 删除字段表
*
* @param map
* @return
*/
@RequestMapping
(
value
=
"/deleteFields"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/deleteFields"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
deleteFields
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
deleteFields
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
List
<
String
>
id
=
(
List
<
String
>)
map
.
get
(
"id"
);
List
<
String
>
id
=
(
List
<
String
>)
map
.
get
(
"id"
);
System
.
out
.
println
(
id
);
System
.
out
.
println
(
id
);
boolean
b
=
fs
.
delete
(
id
);
boolean
b
=
fs
.
delete
(
id
);
JsonResult
result
=
new
JsonResult
(
b
,
200
,
b
?
"删除成功"
:
"删除失败"
);
JsonResult
result
=
new
JsonResult
(
b
,
200
,
b
?
"删除成功"
:
"删除失败"
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 新增字段信息
*
* @param fieldbean
* @return
*/
@RequestMapping
(
value
=
"/insertFields"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/insertFields"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
insertField
(
@RequestBody
FieldBean
fieldbean
)
{
public
String
insertField
(
@RequestBody
FieldBean
fieldbean
)
{
...
@@ -63,10 +87,16 @@ public class FieldController {
...
@@ -63,10 +87,16 @@ public class FieldController {
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 获取所有的字段信息
*
* @param map
* @return
*/
@RequestMapping
(
value
=
"/getAllFields"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/getAllFields"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
getAllFields
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
getAllFields
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
String
pt
=
(
String
)
map
.
get
(
"pt"
);
String
pt
=
(
String
)
map
.
get
(
"pt"
);
FieldBean
field
=
fs
.
getFieldsByPt
(
pt
);
FieldBean
field
=
fs
.
getFieldsByPt
(
pt
);
String
fields
[]
=
null
;
String
fields
[]
=
null
;
if
(
field
!=
null
)
{
if
(
field
!=
null
)
{
...
...
src/main/java/com/zhiwei/manage/servlet/MessageConteoller.java
View file @
515b4bc9
...
@@ -16,12 +16,24 @@ import com.zhiwei.manage.bean.Message;
...
@@ -16,12 +16,24 @@ import com.zhiwei.manage.bean.Message;
import
com.zhiwei.manage.bean.PageEty
;
import
com.zhiwei.manage.bean.PageEty
;
import
com.zhiwei.manage.service.MessageService
;
import
com.zhiwei.manage.service.MessageService
;
/**
* 信息处理器
*
* @author admin
*
*/
@Controller
@Controller
public
class
MessageConteoller
{
public
class
MessageConteoller
{
@Autowired
@Autowired
private
MessageService
msgService
;
private
MessageService
msgService
;
/**
* 获取所有的信息
*
* @param map
* @return
*/
@RequestMapping
(
value
=
"/findAllMsg"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/findAllMsg"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
getAllMessage
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
getAllMessage
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
...
@@ -40,6 +52,12 @@ public class MessageConteoller {
...
@@ -40,6 +52,12 @@ public class MessageConteoller {
}
}
}
}
/**
* 处理信息
*
* @param map
* @return
*/
@RequestMapping
(
value
=
"/handle"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/handle"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
handle
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
handle
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
...
@@ -55,6 +73,12 @@ public class MessageConteoller {
...
@@ -55,6 +73,12 @@ public class MessageConteoller {
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 删除信息
*
* @param map
* @return
*/
@RequestMapping
(
value
=
"/deleteMsg"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/deleteMsg"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
delete
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
delete
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
...
@@ -65,6 +89,12 @@ public class MessageConteoller {
...
@@ -65,6 +89,12 @@ public class MessageConteoller {
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 获取处理过的信息
*
* @param map
* @return
*/
@RequestMapping
(
value
=
"/findHandleMsg"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/findHandleMsg"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
getNewMsg
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
getNewMsg
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
...
...
src/main/java/com/zhiwei/manage/servlet/PersonController.java
View file @
515b4bc9
...
@@ -2,7 +2,6 @@ package com.zhiwei.manage.servlet;
...
@@ -2,7 +2,6 @@ package com.zhiwei.manage.servlet;
import
java.io.UnsupportedEncodingException
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -14,7 +13,6 @@ import javax.servlet.http.HttpServletResponse;
...
@@ -14,7 +13,6 @@ import javax.servlet.http.HttpServletResponse;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
...
@@ -23,12 +21,26 @@ import com.zhiwei.manage.bean.PageEty;
...
@@ -23,12 +21,26 @@ import com.zhiwei.manage.bean.PageEty;
import
com.zhiwei.manage.bean.Person
;
import
com.zhiwei.manage.bean.Person
;
import
com.zhiwei.manage.service.PersonService
;
import
com.zhiwei.manage.service.PersonService
;
/**
* 个人控制
*
* @author admin
*
*/
@Controller
@Controller
public
class
PersonController
{
public
class
PersonController
{
@Resource
@Resource
private
PersonService
personService
;
private
PersonService
personService
;
/**
* 登录
*
* @param req
* @param res
* @param map
* @return
*/
@RequestMapping
(
value
=
"/login"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/login"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
login
(
HttpServletRequest
req
,
HttpServletResponse
res
,
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
login
(
HttpServletRequest
req
,
HttpServletResponse
res
,
@RequestBody
Map
<
String
,
Object
>
map
)
{
...
@@ -38,7 +50,7 @@ public class PersonController {
...
@@ -38,7 +50,7 @@ public class PersonController {
if
(
p
!=
null
)
{
if
(
p
!=
null
)
{
Cookie
cookie
;
Cookie
cookie
;
try
{
try
{
username
=
URLEncoder
.
encode
(
username
,
"utf-8"
);
username
=
URLEncoder
.
encode
(
username
,
"utf-8"
);
cookie
=
new
Cookie
(
"username"
,
username
);
cookie
=
new
Cookie
(
"username"
,
username
);
res
.
addCookie
(
cookie
);
res
.
addCookie
(
cookie
);
cookie
.
setMaxAge
(
1000
*
60
*
60
);
cookie
.
setMaxAge
(
1000
*
60
*
60
);
...
@@ -59,6 +71,14 @@ public class PersonController {
...
@@ -59,6 +71,14 @@ public class PersonController {
}
}
}
}
/**
* 登出
*
* @param req
* @param res
* @param map
* @return
*/
@RequestMapping
(
value
=
"/leave"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/leave"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
leave
(
HttpServletRequest
req
,
HttpServletResponse
res
,
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
leave
(
HttpServletRequest
req
,
HttpServletResponse
res
,
@RequestBody
Map
<
String
,
Object
>
map
)
{
...
@@ -74,6 +94,13 @@ public class PersonController {
...
@@ -74,6 +94,13 @@ public class PersonController {
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* cookie获取
*
* @param req
* @param res
* @return
*/
@RequestMapping
(
value
=
"/getcookie"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/getcookie"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
getCookie
(
HttpServletRequest
req
,
HttpServletResponse
res
)
{
public
String
getCookie
(
HttpServletRequest
req
,
HttpServletResponse
res
)
{
...
@@ -85,6 +112,14 @@ public class PersonController {
...
@@ -85,6 +112,14 @@ public class PersonController {
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 获取用户信息
*
* @param res
* @param req
* @param map
* @return
*/
@RequestMapping
(
value
=
"/getPerson"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/getPerson"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
getPersonByUser
(
HttpServletResponse
res
,
HttpServletRequest
req
,
public
String
getPersonByUser
(
HttpServletResponse
res
,
HttpServletRequest
req
,
...
@@ -104,6 +139,12 @@ public class PersonController {
...
@@ -104,6 +139,12 @@ public class PersonController {
}
}
}
}
/**
* 更新用户信息
*
* @param person
* @return
*/
@RequestMapping
(
value
=
"/updatePerson"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/updatePerson"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
updatePerson
(
@RequestBody
Person
person
)
{
public
String
updatePerson
(
@RequestBody
Person
person
)
{
...
@@ -112,6 +153,12 @@ public class PersonController {
...
@@ -112,6 +153,12 @@ public class PersonController {
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 删除用户信息
*
* @param map
* @return
*/
@RequestMapping
(
value
=
"/deletePerson"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/deletePerson"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
deletePerson
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
deletePerson
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
...
@@ -121,6 +168,13 @@ public class PersonController {
...
@@ -121,6 +168,13 @@ public class PersonController {
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 存储用户信息
*
* @param req
* @param person
* @return
*/
@RequestMapping
(
value
=
"/savePerson"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/savePerson"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
savePerson
(
HttpServletRequest
req
,
@RequestBody
Person
person
)
{
public
String
savePerson
(
HttpServletRequest
req
,
@RequestBody
Person
person
)
{
...
...
src/main/java/com/zhiwei/manage/servlet/ServerController.java
View file @
515b4bc9
...
@@ -8,7 +8,6 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -8,7 +8,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
...
@@ -18,23 +17,41 @@ import com.zhiwei.manage.bean.PageEty;
...
@@ -18,23 +17,41 @@ import com.zhiwei.manage.bean.PageEty;
import
com.zhiwei.manage.bean.ServerBean
;
import
com.zhiwei.manage.bean.ServerBean
;
import
com.zhiwei.manage.service.ServerService
;
import
com.zhiwei.manage.service.ServerService
;
/**
* 数据库等参数
*
* @author admin
*
*/
@Controller
@Controller
public
class
ServerController
{
public
class
ServerController
{
@Autowired
@Autowired
private
ServerService
ss
;
private
ServerService
ss
;
/**
* 分页获取所有库信息
*
* @param map
* @return
*/
@RequestMapping
(
value
=
"/getServer"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/getServer"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
getServer
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
getServer
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
int
pageNo
=
(
int
)
map
.
get
(
"pageNo"
);
int
pageNo
=
(
int
)
map
.
get
(
"pageNo"
);
int
pageSize
=
(
int
)
map
.
get
(
"pageSize"
);
int
pageSize
=
(
int
)
map
.
get
(
"pageSize"
);
String
dbName
=
(
String
)
map
.
get
(
"dbName"
);
String
dbName
=
(
String
)
map
.
get
(
"dbName"
);
PageEty
page
=
ss
.
findDb
(
pageNo
,
pageSize
,
dbName
);
PageEty
page
=
ss
.
findDb
(
pageNo
,
pageSize
,
dbName
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"获取成功"
,
page
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"获取成功"
,
page
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 更新库信息
*
* @param serverBean
* @return
*/
@RequestMapping
(
value
=
"/updateServer"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/updateServer"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
updateServer
(
@RequestBody
ServerBean
serverBean
)
{
public
String
updateServer
(
@RequestBody
ServerBean
serverBean
)
{
...
@@ -43,16 +60,27 @@ public class ServerController {
...
@@ -43,16 +60,27 @@ public class ServerController {
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 删除库信息
*
* @param map
* @return
*/
@RequestMapping
(
value
=
"/deleteServer"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/deleteServer"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
deleteServer
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
deleteServer
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
List
<
String
>
serverid
=
(
List
<
String
>)
map
.
get
(
"serverid"
);
List
<
String
>
serverid
=
(
List
<
String
>)
map
.
get
(
"serverid"
);
boolean
b
=
ss
.
delete
(
serverid
);
boolean
b
=
ss
.
delete
(
serverid
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
serverid
+
(
b
?
"删除成功"
:
"删除失败"
));
JsonResult
result
=
new
JsonResult
(
true
,
200
,
serverid
+
(
b
?
"删除成功"
:
"删除失败"
));
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 插入库信息
*
* @param serverBean
* @return
*/
@RequestMapping
(
value
=
"/insertServer"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/insertServer"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
insertServer
(
@RequestBody
ServerBean
serverBean
)
{
public
String
insertServer
(
@RequestBody
ServerBean
serverBean
)
{
...
@@ -63,96 +91,125 @@ public class ServerController {
...
@@ -63,96 +91,125 @@ public class ServerController {
/**
/**
* 获取所有的渠道信息
* 获取所有的渠道信息
*
* @return
* @return
*/
*/
@RequestMapping
(
value
=
"/getChannel"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/getChannel"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
getChannel
(
@RequestBody
Map
<
String
,
Object
>
map
){
public
String
getChannel
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
int
pageNo
=
(
int
)
map
.
get
(
"pageNo"
);
int
pageNo
=
(
int
)
map
.
get
(
"pageNo"
);
int
pageSize
=
(
int
)
map
.
get
(
"pageSize"
);
int
pageSize
=
(
int
)
map
.
get
(
"pageSize"
);
PageEty
page
=
ss
.
findChannel
(
pageNo
,
pageSize
);
PageEty
page
=
ss
.
findChannel
(
pageNo
,
pageSize
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"获取成功"
,
page
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"获取成功"
,
page
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 更改平台
*
* @param map
* @return
*/
@RequestMapping
(
value
=
"/changePt"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/changePt"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
changePt
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
changePt
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
String
pt
=
(
String
)
map
.
get
(
"pt"
);
String
pt
=
(
String
)
map
.
get
(
"pt"
);
ss
.
findPt
(
pt
);
ss
.
findPt
(
pt
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"源改变成功"
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"源改变成功"
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 插入渠道信息
*
* @param channel
* @return
*/
@RequestMapping
(
value
=
"/insertChannel"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/insertChannel"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
insertChannel
(
@RequestBody
Channel
channel
){
public
String
insertChannel
(
@RequestBody
Channel
channel
)
{
ss
.
insertChannels
(
channel
);
ss
.
insertChannels
(
channel
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"添加成功"
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"添加成功"
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 更新渠道信息
*
* @param channel
* @return
*/
@RequestMapping
(
value
=
"/updateChannel"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/updateChannel"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
updateChannel
(
@RequestBody
Channel
channel
){
public
String
updateChannel
(
@RequestBody
Channel
channel
)
{
boolean
b
=
ss
.
updateChannel
(
channel
);
boolean
b
=
ss
.
updateChannel
(
channel
);
JsonResult
result
=
new
JsonResult
(
b
,
200
,
b
?
"修改成功"
:
"修改失败"
);
JsonResult
result
=
new
JsonResult
(
b
,
200
,
b
?
"修改成功"
:
"修改失败"
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 删除渠道信息
*
* @param map
* @return
*/
@RequestMapping
(
value
=
"/deleteChannel"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/deleteChannel"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
deleteChannel
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
deleteChannel
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
List
<
String
>
id
=
(
List
<
String
>)
map
.
get
(
"id"
);
List
<
String
>
id
=
(
List
<
String
>)
map
.
get
(
"id"
);
boolean
b
=
ss
.
deleteChannel
(
id
);
boolean
b
=
ss
.
deleteChannel
(
id
);
JsonResult
result
=
new
JsonResult
(
b
,
200
,
id
+(
b
?
"删除成功"
:
"删除失败"
));
JsonResult
result
=
new
JsonResult
(
b
,
200
,
id
+
(
b
?
"删除成功"
:
"删除失败"
));
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
/**
* 用于展示渠道
* 用于展示渠道
*
* @return
* @return
*/
*/
@RequestMapping
(
value
=
"/getShowChannel"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/getShowChannel"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
findAllChannel
(){
public
String
findAllChannel
()
{
List
<
Channel
>
list
=
ss
.
findDisChannel
();
List
<
Channel
>
list
=
ss
.
findDisChannel
();
if
(
list
==
null
||
list
.
size
()==
0
)
{
if
(
list
==
null
||
list
.
size
()
==
0
)
{
Channel
c
=
new
Channel
();
Channel
c
=
new
Channel
();
c
.
setId
(
"1"
);
c
.
setId
(
"1"
);
c
.
setPt
(
"网媒"
);
c
.
setPt
(
"网媒"
);
c
.
setValue
(
"wangmei"
);
c
.
setValue
(
"wangmei"
);
list
.
add
(
c
);
list
.
add
(
c
);
}
}
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"获取成功"
,
list
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"获取成功"
,
list
);
System
.
out
.
println
(
result
);
System
.
out
.
println
(
result
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
/**
* 用于给用户选择渠道
* 用于给用户选择渠道
*
* @return
* @return
*/
*/
@RequestMapping
(
value
=
"/getDisChannel"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/getDisChannel"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
findDisChannel
(){
public
String
findDisChannel
()
{
List
<
String
>
list
=
ss
.
findDisChan
();
List
<
String
>
list
=
ss
.
findDisChan
();
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"获取成功"
,
list
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"获取成功"
,
list
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
@RequestMapping
(
value
=
"/getParam"
,
produces
=
"application/json;charset=utf-8"
)
/**
* 获取参数
*
* @return
*/
@RequestMapping
(
value
=
"/getParam"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
getParam
(){
public
String
getParam
()
{
List
<
String
>
list
=
new
ArrayList
<>();
List
<
String
>
list
=
new
ArrayList
<>();
list
.
add
(
"msg"
);
list
.
add
(
"msg"
);
list
.
add
(
"temp"
);
list
.
add
(
"temp"
);
list
.
add
(
"data"
);
list
.
add
(
"data"
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"获取成功"
,
list
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"获取成功"
,
list
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
}
}
src/main/java/com/zhiwei/manage/servlet/TemplateController.java
View file @
515b4bc9
...
@@ -2,7 +2,6 @@ package com.zhiwei.manage.servlet;
...
@@ -2,7 +2,6 @@ package com.zhiwei.manage.servlet;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -11,11 +10,9 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -11,11 +10,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.mysql.jdbc.log.LogFactory
;
import
com.zhiwei.manage.bean.FieldBean
;
import
com.zhiwei.manage.bean.FieldBean
;
import
com.zhiwei.manage.bean.JsonResult
;
import
com.zhiwei.manage.bean.JsonResult
;
import
com.zhiwei.manage.bean.PageEty
;
import
com.zhiwei.manage.bean.PageEty
;
...
@@ -24,25 +21,42 @@ import com.zhiwei.manage.handle.MainThread;
...
@@ -24,25 +21,42 @@ import com.zhiwei.manage.handle.MainThread;
import
com.zhiwei.manage.service.FieldBeanService
;
import
com.zhiwei.manage.service.FieldBeanService
;
import
com.zhiwei.manage.service.TemplateService
;
import
com.zhiwei.manage.service.TemplateService
;
/**
* 模板控制
*
* @author admin
*
*/
@Controller
@Controller
public
class
TemplateController
{
public
class
TemplateController
{
private
static
final
Log
log
=
org
.
apache
.
commons
.
logging
.
LogFactory
.
getLog
(
TemplateController
.
class
);
private
static
final
Log
log
=
org
.
apache
.
commons
.
logging
.
LogFactory
.
getLog
(
TemplateController
.
class
);
@Autowired
@Autowired
private
TemplateService
ts
;
private
TemplateService
ts
;
@Autowired
@Autowired
private
FieldBeanService
fb
;
private
FieldBeanService
fb
;
/**
* 一键启动
*
* @return
*/
@RequestMapping
(
value
=
"/startAll"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/startAll"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
startAll
()
{
public
String
startAll
()
{
List
<
Template
>
tpList
=
ts
.
findAll
();
List
<
Template
>
tpList
=
ts
.
findAll
();
for
(
Template
t:
tpList
)
{
for
(
Template
t
:
tpList
)
{
MainThread
.
pushMap
(
t
.
getTemplateId
());
MainThread
.
pushMap
(
t
.
getTemplateId
());
}
}
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"启动成功"
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"启动成功"
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 一键停止
*
* @return
*/
@RequestMapping
(
value
=
"/stopAll"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/stopAll"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
stopAll
()
{
public
String
stopAll
()
{
...
@@ -50,7 +64,13 @@ public class TemplateController {
...
@@ -50,7 +64,13 @@ public class TemplateController {
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"停止成功"
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"停止成功"
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 保存模板
*
* @param template
* @return
*/
@RequestMapping
(
value
=
"/saveTmp"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/saveTmp"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
saveTmp
(
@RequestBody
Template
template
)
{
public
String
saveTmp
(
@RequestBody
Template
template
)
{
...
@@ -64,12 +84,19 @@ public class TemplateController {
...
@@ -64,12 +84,19 @@ public class TemplateController {
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 更新模板
*
* @param template
* @param request
* @return
*/
@RequestMapping
(
value
=
"/updateTmp"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/updateTmp"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
updateTmp
(
@RequestBody
Template
template
,
HttpServletRequest
request
)
{
public
String
updateTmp
(
@RequestBody
Template
template
,
HttpServletRequest
request
)
{
JsonResult
result
=
null
;
JsonResult
result
=
null
;
if
(
MainThread
.
mainMap
.
get
(
template
.
getTemplateId
())
!=
null
)
{
if
(
MainThread
.
mainMap
.
get
(
template
.
getTemplateId
())
!=
null
)
{
result
=
new
JsonResult
(
true
,
200
,
"修改失败"
);
result
=
new
JsonResult
(
true
,
200
,
"修改失败"
);
}
else
{
}
else
{
if
(
ts
.
update
(
template
))
{
if
(
ts
.
update
(
template
))
{
result
=
new
JsonResult
(
true
,
200
,
"修改成功"
);
result
=
new
JsonResult
(
true
,
200
,
"修改成功"
);
...
@@ -80,6 +107,12 @@ public class TemplateController {
...
@@ -80,6 +107,12 @@ public class TemplateController {
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 删除模板
*
* @param map
* @return
*/
@RequestMapping
(
value
=
"/deleteTmp"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/deleteTmp"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
deleteTmp
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
deleteTmp
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
...
@@ -96,6 +129,12 @@ public class TemplateController {
...
@@ -96,6 +129,12 @@ public class TemplateController {
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
/**
* 获取所有的模板信息
*
* @param map
* @return
*/
@RequestMapping
(
value
=
"/findAllTmp"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/findAllTmp"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
findAll
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
findAll
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
...
@@ -119,6 +158,12 @@ public class TemplateController {
...
@@ -119,6 +158,12 @@ public class TemplateController {
}
}
}
}
/**
* 开启模板根据id
*
* @param map
* @return
*/
@RequestMapping
(
value
=
"/startTmp"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/startTmp"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
startTmp
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
startTmp
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
...
@@ -133,6 +178,12 @@ public class TemplateController {
...
@@ -133,6 +178,12 @@ public class TemplateController {
}
}
}
}
/**
* 停止模板
*
* @param map
* @return
*/
@RequestMapping
(
value
=
"/stopTmp"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/stopTmp"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
stopTmp
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
stopTmp
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
...
@@ -147,6 +198,12 @@ public class TemplateController {
...
@@ -147,6 +198,12 @@ public class TemplateController {
}
}
}
}
/**
* 获取字段信息
*
* @param map
* @return
*/
@RequestMapping
(
value
=
"/getField"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/getField"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
getField
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
getField
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
...
...
src/main/java/com/zhiwei/manage/util/AESUtils.java
View file @
515b4bc9
package
com
.
zhiwei
.
manage
.
util
;
package
com
.
zhiwei
.
manage
.
util
;
import
java.io.UnsupportedEncodingException
;
import
java.util.Arrays
;
import
javax.crypto.Cipher
;
import
javax.crypto.Cipher
;
import
javax.crypto.spec.IvParameterSpec
;
import
javax.crypto.spec.IvParameterSpec
;
import
javax.crypto.spec.SecretKeySpec
;
import
javax.crypto.spec.SecretKeySpec
;
import
java.io.UnsupportedEncodingException
;
import
java.util.Arrays
;
/**
/**
* aes加密解析
*
* @author
* @author
* @version V1.0
* @version V1.0
* @Description
* @Description
* @date 2017-12-28 14:26
* @date 2017-12-28 14:26
**/
**/
public
class
AESUtils
{
public
class
AESUtils
{
private
AESUtils
()
{
private
AESUtils
()
{
}
}
/**
/**
* 加密
* 加密
*
*
* @param secret 密钥
* @param secret
* @param value 待加密的字符串
* 密钥
* @return 加密后的字符串
* @param value
*/
* 待加密的字符串
public
static
String
encrypt
(
String
secret
,
String
value
)
{
* @return 加密后的字符串
SecretKeySpec
keySpec
=
getKey
(
secret
);
*/
IvParameterSpec
iv
=
new
IvParameterSpec
(
"0102030405060708"
.
getBytes
());
public
static
String
encrypt
(
String
secret
,
String
value
)
{
try
{
SecretKeySpec
keySpec
=
getKey
(
secret
);
Cipher
cipher
=
Cipher
.
getInstance
(
"AES/CBC/PKCS5Padding"
);
IvParameterSpec
iv
=
new
IvParameterSpec
(
"0102030405060708"
.
getBytes
());
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
keySpec
,
iv
);
try
{
byte
[]
encrypted
=
cipher
.
doFinal
(
value
.
getBytes
(
"UTF-8"
));
Cipher
cipher
=
Cipher
.
getInstance
(
"AES/CBC/PKCS5Padding"
);
return
parseByte2HexStr
(
encrypted
);
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
keySpec
,
iv
);
}
catch
(
Exception
e
)
{
byte
[]
encrypted
=
cipher
.
doFinal
(
value
.
getBytes
(
"UTF-8"
));
throw
new
RuntimeException
(
e
);
return
parseByte2HexStr
(
encrypted
);
}
}
catch
(
Exception
e
)
{
}
throw
new
RuntimeException
(
e
);
}
}
public
static
void
main
(
String
[]
args
)
{
AESUtils
ac
=
new
AESUtils
();
String
jsm
=
AESUtils
.
encrypt
(
"wechat"
,
"shenjinzhu"
);
System
.
out
.
println
(
jsm
);
String
jm
=
AESUtils
.
decrypt
(
"wechat"
,
jsm
);
System
.
out
.
println
(
jm
);
}
public
static
void
main
(
String
[]
args
)
{
/**
AESUtils
ac
=
new
AESUtils
();
* 解密
String
jsm
=
AESUtils
.
encrypt
(
"wechat"
,
"shenjinzhu"
);
*
System
.
out
.
println
(
jsm
);
* @param secret
String
jm
=
AESUtils
.
decrypt
(
"wechat"
,
jsm
);
* 密钥
System
.
out
.
println
(
jm
);
* @param value
* 待解密字符串
* @return 解密后的字符串
*/
public
static
String
decrypt
(
String
secret
,
String
value
)
{
SecretKeySpec
keySpec
=
getKey
(
secret
);
IvParameterSpec
iv
=
new
IvParameterSpec
(
"0102030405060708"
.
getBytes
());
try
{
Cipher
cipher
=
Cipher
.
getInstance
(
"AES/CBC/PKCS5Padding"
);
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
keySpec
,
iv
);
byte
[]
encrypted1
=
parseHexStr2Byte
(
value
);
byte
[]
original
=
cipher
.
doFinal
(
encrypted1
);
return
new
String
(
original
,
"UTF-8"
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
/**
* 解密
*
* @param secret 密钥
* @param value 待解密字符串
* @return 解密后的字符串
*/
public
static
String
decrypt
(
String
secret
,
String
value
)
{
SecretKeySpec
keySpec
=
getKey
(
secret
);
IvParameterSpec
iv
=
new
IvParameterSpec
(
"0102030405060708"
.
getBytes
());
try
{
Cipher
cipher
=
Cipher
.
getInstance
(
"AES/CBC/PKCS5Padding"
);
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
keySpec
,
iv
);
byte
[]
encrypted1
=
parseHexStr2Byte
(
value
);
byte
[]
original
=
cipher
.
doFinal
(
encrypted1
);
return
new
String
(
original
,
"UTF-8"
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
/**
/**
* 生成加密的密钥,保证长度为16位
* 生成加密的密钥,保证长度为16位
*
*
* @param secret 用户的密钥
* @param secret
* @return 生成的密钥
* 用户的密钥
*/
* @return 生成的密钥
private
static
SecretKeySpec
getKey
(
String
secret
)
{
*/
byte
[]
bytes
;
private
static
SecretKeySpec
getKey
(
String
secret
)
{
try
{
byte
[]
bytes
;
bytes
=
secret
.
getBytes
(
"UTF-8"
);
try
{
return
new
SecretKeySpec
(
Arrays
.
copyOf
(
bytes
,
16
),
"AES"
);
bytes
=
secret
.
getBytes
(
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
return
new
SecretKeySpec
(
Arrays
.
copyOf
(
bytes
,
16
),
"AES"
);
e
.
printStackTrace
();
}
catch
(
UnsupportedEncodingException
e
)
{
}
e
.
printStackTrace
();
return
null
;
}
}
return
null
;
}
/**
/**
* 将二进制转换成16进制
* 将二进制转换成16进制
*
*
* @param buf
* @param buf
* @return
* @return
*/
*/
public
static
String
parseByte2HexStr
(
byte
buf
[])
{
public
static
String
parseByte2HexStr
(
byte
buf
[])
{
StringBuffer
sb
=
new
StringBuffer
();
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
buf
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
buf
.
length
;
i
++)
{
String
hex
=
Integer
.
toHexString
(
buf
[
i
]
&
0xFF
);
String
hex
=
Integer
.
toHexString
(
buf
[
i
]
&
0xFF
);
if
(
hex
.
length
()
==
1
)
{
if
(
hex
.
length
()
==
1
)
{
hex
=
'0'
+
hex
;
hex
=
'0'
+
hex
;
}
}
sb
.
append
(
hex
.
toUpperCase
());
sb
.
append
(
hex
.
toUpperCase
());
}
}
return
sb
.
toString
();
return
sb
.
toString
();
}
}
/**
/**
* 将16进制转换为二进制
* 将16进制转换为二进制
*
*
* @param hexStr
* @param hexStr
* @return
* @return
*/
*/
public
static
byte
[]
parseHexStr2Byte
(
String
hexStr
)
{
public
static
byte
[]
parseHexStr2Byte
(
String
hexStr
)
{
if
(
hexStr
.
length
()
<
1
)
if
(
hexStr
.
length
()
<
1
)
return
null
;
return
null
;
byte
[]
result
=
new
byte
[
hexStr
.
length
()
/
2
];
byte
[]
result
=
new
byte
[
hexStr
.
length
()
/
2
];
for
(
int
i
=
0
;
i
<
hexStr
.
length
()
/
2
;
i
++)
{
for
(
int
i
=
0
;
i
<
hexStr
.
length
()
/
2
;
i
++)
{
int
high
=
Integer
.
parseInt
(
hexStr
.
substring
(
i
*
2
,
i
*
2
+
1
),
16
);
int
high
=
Integer
.
parseInt
(
hexStr
.
substring
(
i
*
2
,
i
*
2
+
1
),
16
);
int
low
=
Integer
.
parseInt
(
hexStr
.
substring
(
i
*
2
+
1
,
i
*
2
+
2
),
int
low
=
Integer
.
parseInt
(
hexStr
.
substring
(
i
*
2
+
1
,
i
*
2
+
2
),
16
);
16
);
result
[
i
]
=
(
byte
)
(
high
*
16
+
low
);
result
[
i
]
=
(
byte
)
(
high
*
16
+
low
);
}
}
return
result
;
return
result
;
}
}
}
}
src/main/java/com/zhiwei/manage/util/Config.java
View file @
515b4bc9
...
@@ -4,20 +4,27 @@ import java.io.FileInputStream;
...
@@ -4,20 +4,27 @@ import java.io.FileInputStream;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.util.Properties
;
import
java.util.Properties
;
/**
* 配置读取
*
* @author admin
*
*/
public
class
Config
{
public
class
Config
{
public
static
Properties
p
=
new
Properties
();
public
static
Properties
p
=
new
Properties
();
static
{
static
{
String
fileurl
=
Config
.
class
.
getClassLoader
().
getResource
(
"mongo.properties"
).
getPath
();
String
fileurl
=
Config
.
class
.
getClassLoader
().
getResource
(
"mongo.properties"
).
getPath
();
p
=
new
Properties
();
p
=
new
Properties
();
try
{
try
{
InputStreamReader
in
=
new
InputStreamReader
(
new
FileInputStream
(
fileurl
),
"utf-8"
);
InputStreamReader
in
=
new
InputStreamReader
(
new
FileInputStream
(
fileurl
),
"utf-8"
);
p
.
load
(
in
);
/// 加载属性列表
p
.
load
(
in
);
/// 加载属性列表
in
.
close
();
in
.
close
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
}
}
}
}
public
static
String
getVal
(
String
key
){
public
static
String
getVal
(
String
key
)
{
return
p
.
getProperty
(
key
);
return
p
.
getProperty
(
key
);
}
}
}
}
src/main/java/com/zhiwei/manage/util/MysqlConnection.java
View file @
515b4bc9
...
@@ -8,19 +8,25 @@ import org.apache.commons.logging.LogFactory;
...
@@ -8,19 +8,25 @@ import org.apache.commons.logging.LogFactory;
import
com.mysql.jdbc.Connection
;
import
com.mysql.jdbc.Connection
;
/**
* mysql链接
*
* @author admin
*
*/
public
class
MysqlConnection
{
public
class
MysqlConnection
{
private
static
final
Log
log
=
LogFactory
.
getLog
(
MysqlConnection
.
class
);
private
static
final
Log
log
=
LogFactory
.
getLog
(
MysqlConnection
.
class
);
private
String
host
;
private
String
host
;
private
int
port
;
private
int
port
;
private
String
dbName
;
private
String
dbName
;
public
MysqlConnection
(
String
host
,
Integer
port
,
String
dbName
)
{
public
MysqlConnection
(
String
host
,
Integer
port
,
String
dbName
)
{
this
.
host
=
host
;
this
.
host
=
host
;
this
.
port
=
port
;
this
.
port
=
port
;
this
.
dbName
=
dbName
;
this
.
dbName
=
dbName
;
}
}
/**
/**
* 需要登录的mysql连接
* 需要登录的mysql连接
*
*
...
@@ -41,6 +47,7 @@ public class MysqlConnection {
...
@@ -41,6 +47,7 @@ public class MysqlConnection {
}
}
return
con
;
return
con
;
}
}
/**
/**
* 无需登录的mysql连接
* 无需登录的mysql连接
*
*
...
...
src/main/java/com/zhiwei/manage/util/ThreadPool.java
View file @
515b4bc9
...
@@ -3,139 +3,143 @@ package com.zhiwei.manage.util;
...
@@ -3,139 +3,143 @@ package com.zhiwei.manage.util;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.List
;
/**
* 自定义线程池
*
* @author admin
*
*/
public
class
ThreadPool
{
public
class
ThreadPool
{
// 线程池中默认线程的个数为30
// 线程池中默认线程的个数为30
private
static
int
worker_num
=
30
;
private
static
int
worker_num
=
30
;
private
WorkThread
[]
workThrads
;
private
WorkThread
[]
workThrads
;
private
static
volatile
int
finished_task
=
0
;
private
static
volatile
int
finished_task
=
0
;
private
List
<
Runnable
>
taskQueue
=
new
LinkedList
<
Runnable
>();
private
List
<
Runnable
>
taskQueue
=
new
LinkedList
<
Runnable
>();
private
static
ThreadPool
threadPool
;
private
static
ThreadPool
threadPool
;
// 创建具有默认线程个数的线程池
// 创建具有默认线程个数的线程池
private
ThreadPool
()
{
private
ThreadPool
()
{
this
(
30
);
this
(
30
);
}
}
private
ThreadPool
(
int
worker_num
)
{
private
ThreadPool
(
int
worker_num
)
{
ThreadPool
.
worker_num
=
worker_num
;
ThreadPool
.
worker_num
=
worker_num
;
workThrads
=
new
WorkThread
[
worker_num
];
workThrads
=
new
WorkThread
[
worker_num
];
for
(
int
i
=
0
;
i
<
worker_num
;
i
++)
{
for
(
int
i
=
0
;
i
<
worker_num
;
i
++)
{
workThrads
[
i
]
=
new
WorkThread
();
workThrads
[
i
]
=
new
WorkThread
();
workThrads
[
i
].
start
();
// 开启线程池中的线程
workThrads
[
i
].
start
();
// 开启线程池中的线程
}
}
}
}
//获得一个默认线程个数的线程池
// 获得一个默认线程个数的线程池
public
static
ThreadPool
getThreadPool
()
{
public
static
ThreadPool
getThreadPool
()
{
return
getThreadPool
(
ThreadPool
.
worker_num
);
return
getThreadPool
(
ThreadPool
.
worker_num
);
}
}
// worker_num<=0创建默认的工作线程个数
// worker_num<=0创建默认的工作线程个数
public
static
ThreadPool
getThreadPool
(
int
worker_num1
)
{
public
static
ThreadPool
getThreadPool
(
int
worker_num1
)
{
if
(
worker_num1
<=
0
)
if
(
worker_num1
<=
0
)
worker_num1
=
ThreadPool
.
worker_num
;
worker_num1
=
ThreadPool
.
worker_num
;
if
(
threadPool
==
null
)
if
(
threadPool
==
null
)
threadPool
=
new
ThreadPool
(
worker_num1
);
threadPool
=
new
ThreadPool
(
worker_num1
);
return
threadPool
;
return
threadPool
;
}
}
// 执行任务
// 执行任务
public
void
execute
(
Runnable
task
)
{
public
void
execute
(
Runnable
task
)
{
synchronized
(
taskQueue
)
{
synchronized
(
taskQueue
)
{
taskQueue
.
add
(
task
);
taskQueue
.
add
(
task
);
taskQueue
.
notify
();
taskQueue
.
notify
();
}
}
}
}
// 批量执行任务
// 批量执行任务
public
void
execute
(
List
<
Runnable
>
task
)
{
public
void
execute
(
List
<
Runnable
>
task
)
{
synchronized
(
taskQueue
)
{
synchronized
(
taskQueue
)
{
for
(
Runnable
t
:
task
)
for
(
Runnable
t
:
task
)
taskQueue
.
add
(
t
);
taskQueue
.
add
(
t
);
taskQueue
.
notify
();
taskQueue
.
notify
();
}
}
}
}
// 销毁线程池
// 销毁线程池
public
void
destroy
()
{
public
void
destroy
()
{
while
(!
taskQueue
.
isEmpty
())
{
// 如果还有任务没执行完成,就先睡会吧
while
(!
taskQueue
.
isEmpty
())
{
// 如果还有任务没执行完成,就先睡会吧
try
{
try
{
Thread
.
sleep
(
10
);
Thread
.
sleep
(
10
);
}
catch
(
InterruptedException
e
)
{
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
// 工作线程停止工作,且置为null
//工作线程停止工作,且置为null
for
(
int
i
=
0
;
i
<
worker_num
;
i
++)
{
for
(
int
i
=
0
;
i
<
worker_num
;
i
++)
{
workThrads
[
i
].
stopWorker
();
workThrads
[
i
].
stopWorker
();
workThrads
[
i
]
=
null
;
workThrads
[
i
]
=
null
;
}
}
threadPool
=
null
;
threadPool
=
null
;
taskQueue
.
clear
();
// 清空任务队列
taskQueue
.
clear
();
// 清空任务队列
}
}
// 返回工作线程的个数
// 返回工作线程的个数
public
int
getWorkThreadNumber
()
{
public
int
getWorkThreadNumber
()
{
return
worker_num
;
return
worker_num
;
}
}
// 返回已完成任务的个数,这里的已完成是只出了任务队列的任务个数,可能该任务并没有实际执行完成
// 返回已完成任务的个数,这里的已完成是只出了任务队列的任务个数,可能该任务并没有实际执行完成
public
int
getFinishedTasknumber
()
{
public
int
getFinishedTasknumber
()
{
return
finished_task
;
return
finished_task
;
}
}
// 返回任务队列的长度,即还没处理的任务个数
// 返回任务队列的长度,即还没处理的任务个数
public
int
getWaitTasknumber
()
{
public
int
getWaitTasknumber
()
{
return
taskQueue
.
size
();
return
taskQueue
.
size
();
}
}
// 覆盖toString方法,返回线程池信息:工作线程个数和已完成任务个数
// 覆盖toString方法,返回线程池信息:工作线程个数和已完成任务个数
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"WorkThread number:"
+
worker_num
+
" finished task number:"
+
finished_task
+
" wait task number:"
return
"WorkThread number:"
+
worker_num
+
" finished task number:"
+
getWaitTasknumber
();
+
finished_task
+
" wait task number:"
+
getWaitTasknumber
();
}
}
/**
/**
* 内部类,工作线程
* 内部类,工作线程
*/
*/
private
class
WorkThread
extends
Thread
{
private
class
WorkThread
extends
Thread
{
// 该工作线程是否有效,用于结束该工作线程
// 该工作线程是否有效,用于结束该工作线程
private
boolean
isRunning
=
true
;
private
boolean
isRunning
=
true
;
/*
/*
* 关键所在啊,如果任务队列不空,则取出任务执行,若任务队列空,则等待
* 关键所在啊,如果任务队列不空,则取出任务执行,若任务队列空,则等待
*/
*/
@Override
@Override
public
void
run
()
{
public
void
run
()
{
Runnable
r
=
null
;
Runnable
r
=
null
;
while
(
isRunning
)
{
// 注意,若线程无效则自然结束run方法,该线程就没用了
while
(
isRunning
)
{
// 注意,若线程无效则自然结束run方法,该线程就没用了
synchronized
(
taskQueue
)
{
synchronized
(
taskQueue
)
{
while
(
isRunning
&&
taskQueue
.
isEmpty
())
{
// 队列为空
while
(
isRunning
&&
taskQueue
.
isEmpty
())
{
// 队列为空
try
{
try
{
taskQueue
.
wait
(
20
);
taskQueue
.
wait
(
20
);
}
catch
(
InterruptedException
e
)
{
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
if
(!
taskQueue
.
isEmpty
())
if
(!
taskQueue
.
isEmpty
())
r
=
taskQueue
.
remove
(
0
);
// 取出任务
r
=
taskQueue
.
remove
(
0
);
// 取出任务
}
}
if
(
r
!=
null
)
{
if
(
r
!=
null
)
{
r
.
run
();
// 执行任务
r
.
run
();
// 执行任务
}
}
finished_task
++;
finished_task
++;
r
=
null
;
r
=
null
;
}
}
}
}
// 停止工作,让该线程自然执行完run方法,自然结束
// 停止工作,让该线程自然执行完run方法,自然结束
public
void
stopWorker
()
{
public
void
stopWorker
()
{
isRunning
=
false
;
isRunning
=
false
;
}
}
}
}
}
}
src/main/java/com/zhiwei/manage/util/WechatPush.java
View file @
515b4bc9
package
com
.
zhiwei
.
manage
.
util
;
package
com
.
zhiwei
.
manage
.
util
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.text.ParseException
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -21,11 +12,19 @@ import weixin.popular.bean.message.templatemessage.TemplateMessage;
...
@@ -21,11 +12,19 @@ import weixin.popular.bean.message.templatemessage.TemplateMessage;
import
weixin.popular.bean.message.templatemessage.TemplateMessageItem
;
import
weixin.popular.bean.message.templatemessage.TemplateMessageItem
;
import
weixin.popular.bean.message.templatemessage.TemplateMessageResult
;
import
weixin.popular.bean.message.templatemessage.TemplateMessageResult
;
/**
* 微信推送部分
*
* @author admin
*
*/
public
class
WechatPush
{
public
class
WechatPush
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
WechatPush
.
class
);
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
WechatPush
.
class
);
/**
/**
* 指定分组的的指定用户进行模板发送
* 指定分组的的指定用户进行模板发送
*
* @param idNum
* @param idNum
* 分组编号
* 分组编号
* @param temp_id
* @param temp_id
...
...
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