Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
DQMP
Project
Project
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
data
DQMP
Commits
da291251
Commit
da291251
authored
Dec 25, 2019
by
赵建伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update codes
parent
8ec00e0c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
18 deletions
+61
-18
IndexController.java
...n/java/com/gmei/data/dqmp/controller/IndexController.java
+5
-0
DqScheduler.java
src/main/java/com/gmei/data/dqmp/scheduler/DqScheduler.java
+6
-6
CheckService.java
src/main/java/com/gmei/data/dqmp/service/CheckService.java
+1
-1
CheckServiceImpl.java
...ava/com/gmei/data/dqmp/service/impl/CheckServiceImpl.java
+13
-4
MonitorServiceImpl.java
...a/com/gmei/data/dqmp/service/impl/MonitorServiceImpl.java
+11
-2
CrontabUtils.java
src/main/java/com/gmei/data/dqmp/utils/CrontabUtils.java
+25
-5
No files found.
src/main/java/com/gmei/data/dqmp/controller/IndexController.java
View file @
da291251
...
...
@@ -39,4 +39,9 @@ public class IndexController {
return
"index"
;
}
@GetMapping
(
"/demo"
)
public
String
demo
(
Model
model
)
{
return
"static/demo"
;
}
}
src/main/java/com/gmei/data/dqmp/scheduler/DqScheduler.java
View file @
da291251
...
...
@@ -16,27 +16,27 @@ public class DqScheduler {
@Autowired
private
MonitorService
monitorService
;
@Scheduled
(
cron
=
"
0 10 15
* * ?"
)
@Scheduled
(
cron
=
"
*/60 * *
* * ?"
)
private
void
uniqueCheckProcess
(){
checkService
.
checkAndPersistSimpleResult
(
Constants
.
CHECK_UNIQUE
);
}
@Scheduled
(
cron
=
"
0 20 15
* * ?"
)
@Scheduled
(
cron
=
"
*/60 * *
* * ?"
)
private
void
unblankCheckProcess
(){
checkService
.
checkAndPersistSimpleResult
(
Constants
.
CHECK_UNBLANK
);
}
@Scheduled
(
cron
=
"
0 30 15
* * ?"
)
@Scheduled
(
cron
=
"
*/60 * *
* * ?"
)
private
void
referCheckProcess
(){
checkService
.
checkAndPersist
Multiple
Result
(
Constants
.
CHECK_REFER
);
checkService
.
checkAndPersist
Deplex
Result
(
Constants
.
CHECK_REFER
);
}
@Scheduled
(
cron
=
"
0 40 15
* * ?"
)
@Scheduled
(
cron
=
"
*/60 * *
* * ?"
)
private
void
volatilityMonitorProcess
(){
monitorService
.
monitorAndPersistVolatilityResult
(
Constants
.
MONITOR_PV
);
}
@Scheduled
(
cron
=
"
0 50 15
* * ?"
)
@Scheduled
(
cron
=
"
*/60 * *
* * ?"
)
private
void
specialMonitorProcess
(){
monitorService
.
monitorAndPersistSpecialResult
();
}
...
...
src/main/java/com/gmei/data/dqmp/service/CheckService.java
View file @
da291251
...
...
@@ -12,6 +12,6 @@ public interface CheckService {
* 校验并持久化复杂型校验结果
* @param checkType
*/
void
checkAndPersist
Multiple
Result
(
String
checkType
);
void
checkAndPersist
Deplex
Result
(
String
checkType
);
}
src/main/java/com/gmei/data/dqmp/service/impl/CheckServiceImpl.java
View file @
da291251
...
...
@@ -28,6 +28,7 @@ import com.gmei.data.dqmp.pool.JdbcConnectPool;
import
com.gmei.data.dqmp.service.CheckService
;
import
com.gmei.data.dqmp.service.DingdingService
;
import
com.gmei.data.dqmp.service.MailService
;
import
com.gmei.data.dqmp.utils.CrontabUtils
;
import
com.gmei.data.dqmp.utils.DateUtils
;
@Service
...
...
@@ -61,6 +62,10 @@ public class CheckServiceImpl implements CheckService {
.
andIsValidEqualTo
(
Constants
.
IS_VALID_ON
);
List
<
TblSqlCheckSingle
>
sqlList
=
tblSqlCheckSingleMapper
.
selectByExampleWithBLOBs
(
tblCheckSingleSqlCriteria
);
for
(
TblSqlCheckSingle
tblCheckSql
:
sqlList
)
{
String
checkTime
=
tblCheckSql
.
getCheckTime
();
if
(!
CrontabUtils
.
isToRunByMinites
(
checkTime
))
{
continue
;
}
String
sql
=
tblCheckSql
.
getSqlContent
();
Integer
id
=
tblCheckSql
.
getId
();
Double
threshold
=
tblCheckSql
.
getThreshold
();
...
...
@@ -69,7 +74,7 @@ public class CheckServiceImpl implements CheckService {
TblResultCheckUnique
uniqueCheckResult
=
getUniqueCheckResult
(
sql
);
if
(
uniqueCheckResult
==
null
)
{
logger
.
error
(
"Find result is empty!"
);
return
;
continue
;
}
else
{
Double
uniqueRate
=
uniqueCheckResult
.
getUniqueRate
();
if
(
null
!=
uniqueRate
&&
uniqueRate
<
threshold
)
{
...
...
@@ -83,7 +88,7 @@ public class CheckServiceImpl implements CheckService {
TblResultCheckUnblank
tblResultCheckUnblank
=
getUnblankCheckResult
(
sql
);
if
(
tblResultCheckUnblank
==
null
)
{
logger
.
error
(
"Find result is empty!"
);
return
;
continue
;
}
else
{
Double
unblankRate
=
tblResultCheckUnblank
.
getUnblankRate
();
if
(
null
!=
unblankRate
&&
unblankRate
<
threshold
)
{
...
...
@@ -107,13 +112,17 @@ public class CheckServiceImpl implements CheckService {
* @param checkType
*/
@Override
public
void
checkAndPersist
Multiple
Result
(
String
checkType
)
{
public
void
checkAndPersist
Deplex
Result
(
String
checkType
)
{
TblSqlCheckDuplexCriteria
tblCheckMultipleSqlCriteria
=
new
TblSqlCheckDuplexCriteria
();
tblCheckMultipleSqlCriteria
.
createCriteria
()
.
andCheckTypeEqualTo
(
checkType
)
.
andIsValidEqualTo
(
Constants
.
IS_VALID_ON
);
List
<
TblSqlCheckDuplex
>
sqlList
=
tblSqlCheckDuplexMapper
.
selectByExampleWithBLOBs
(
tblCheckMultipleSqlCriteria
);
for
(
TblSqlCheckDuplex
tblCheckSql
:
sqlList
)
{
String
checkTime
=
tblCheckSql
.
getCheckTime
();
if
(!
CrontabUtils
.
isToRunByMinites
(
checkTime
))
{
continue
;
}
String
sql
=
tblCheckSql
.
getSqlContent
();
Integer
id
=
tblCheckSql
.
getId
();
Double
threshold
=
tblCheckSql
.
getThreshold
();
...
...
@@ -122,7 +131,7 @@ public class CheckServiceImpl implements CheckService {
TblResultCheckRefer
referCheckResult
=
getReferCheckResult
(
sql
);
if
(
referCheckResult
==
null
)
{
logger
.
error
(
"Find result is empty!"
);
return
;
continue
;
}
else
{
Double
matchedRate
=
referCheckResult
.
getMatchedRate
();
if
(
null
!=
matchedRate
&&
matchedRate
<
threshold
)
{
...
...
src/main/java/com/gmei/data/dqmp/service/impl/MonitorServiceImpl.java
View file @
da291251
...
...
@@ -26,6 +26,7 @@ import com.gmei.data.dqmp.pool.JdbcConnectPool;
import
com.gmei.data.dqmp.service.DingdingService
;
import
com.gmei.data.dqmp.service.MailService
;
import
com.gmei.data.dqmp.service.MonitorService
;
import
com.gmei.data.dqmp.utils.CrontabUtils
;
import
com.gmei.data.dqmp.utils.DateUtils
;
@Service
...
...
@@ -58,6 +59,10 @@ public class MonitorServiceImpl implements MonitorService {
List
<
TblSqlMonitorVolatility
>
sqlList
=
tblSqlMonitorVolatilityMapper
.
selectByExampleWithBLOBs
(
tblmonitorVolatilitySqlCriteria
);
for
(
TblSqlMonitorVolatility
tblCheckSql
:
sqlList
)
{
String
checkTime
=
tblCheckSql
.
getCheckTime
();
if
(!
CrontabUtils
.
isToRunByMinites
(
checkTime
))
{
continue
;
}
String
sql
=
tblCheckSql
.
getSqlContent
();
Integer
id
=
tblCheckSql
.
getId
();
Double
threshold
=
tblCheckSql
.
getThreshold
();
...
...
@@ -65,7 +70,7 @@ public class MonitorServiceImpl implements MonitorService {
TblResultMonitorVolatility
tblResultMonitorVolatility
=
getMonitorVolatilityResult
(
sql
,
indicatorType
);
if
(
tblResultMonitorVolatility
==
null
)
{
logger
.
error
(
"Find result is empty!"
);
return
;
continue
;
}
else
{
Long
indicatorValue
=
tblResultMonitorVolatility
.
getIndicatorValue
();
if
(
null
!=
indicatorValue
&&
indicatorValue
<
threshold
)
{
...
...
@@ -93,6 +98,10 @@ public class MonitorServiceImpl implements MonitorService {
tblMonitorSpecialSqlCriteria
.
createCriteria
().
andIsValidEqualTo
(
Constants
.
IS_VALID_ON
);
List
<
TblSqlMonitorSpecial
>
sqlList
=
tblSqlMonitorSpecialMapper
.
selectByExampleWithBLOBs
(
tblMonitorSpecialSqlCriteria
);
for
(
TblSqlMonitorSpecial
tblCheckSql
:
sqlList
)
{
String
checkTime
=
tblCheckSql
.
getCheckTime
();
if
(!
CrontabUtils
.
isToRunByMinites
(
checkTime
))
{
continue
;
}
String
sql
=
tblCheckSql
.
getSqlContent
();
Integer
id
=
tblCheckSql
.
getId
();
Double
threshold
=
tblCheckSql
.
getThreshold
();
...
...
@@ -100,7 +109,7 @@ public class MonitorServiceImpl implements MonitorService {
TblResultMonitorSpecial
tblResultMonitorSpecial
=
getMonitorSpecialResult
(
sql
);
if
(
tblResultMonitorSpecial
==
null
)
{
logger
.
error
(
"Find result is empty!"
);
return
;
continue
;
}
else
{
Long
indicatorValue
=
tblResultMonitorSpecial
.
getIndicatorValue
();
if
(
null
!=
indicatorValue
&&
indicatorValue
<
threshold
)
{
...
...
src/main/java/com/gmei/data/dqmp/utils/CrontabUtils.java
View file @
da291251
...
...
@@ -12,21 +12,21 @@ public class CrontabUtils {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CrontabUtils
.
class
);
/**
* 根据crontab表达式判断当前任务是否应该执行【未来
一分钟
以内】
* 根据crontab表达式判断当前任务是否应该执行【未来
1小时
以内】
* @param crontabStr
* @return
*/
public
static
boolean
isToRun
(
String
crontabStr
)
{
public
static
boolean
isToRun
ByTimeRange
(
String
crontabStr
)
{
boolean
rs
=
false
;
Date
currentDate
=
new
Date
();
long
currentDateMilliseconds
=
currentDate
.
getTime
();
CronExpression
expression
=
null
;
try
{
expression
=
new
CronExpression
(
"0 14 20 * * ?"
);
expression
=
new
CronExpression
(
crontabStr
);
Date
newDate
=
expression
.
getNextValidTimeAfter
(
currentDate
);
long
newDateMilliseconds
=
newDate
.
getTime
();
long
diffSeconds
=
(
newDateMilliseconds
-
currentDateMilliseconds
)/
1000
;
if
(
diffSeconds
<
60
)
{
if
(
diffSeconds
<
60
*
60
)
{
rs
=
true
;
}
}
catch
(
ParseException
e
)
{
...
...
@@ -37,7 +37,27 @@ public class CrontabUtils {
return
rs
;
}
/**
* 根据crontab表达式判断当前任务是否应该执行【是否跟当前年月日时分一致】
* @param crontabStr
* @return
*/
public
static
boolean
isToRunByMinites
(
String
crontabStr
)
{
boolean
rs
=
false
;
try
{
CronExpression
expression
=
new
CronExpression
(
crontabStr
);
Date
currentDate
=
new
Date
();
rs
=
expression
.
isSatisfiedBy
(
currentDate
);
}
catch
(
ParseException
e
)
{
logger
.
error
(
"Fail to parse cron express"
,
e
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"Fail to update rule nextTime"
,
e
);
}
return
rs
;
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
isToRun
(
""
));
System
.
out
.
println
(
isToRunByTimeRange
(
"0 0 12 25 * ?"
));
System
.
out
.
println
(
isToRunByMinites
(
"* 57 10 25 * ?"
));
}
}
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