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
Show 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 {
...
@@ -39,4 +39,9 @@ public class IndexController {
return
"index"
;
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 {
...
@@ -16,27 +16,27 @@ public class DqScheduler {
@Autowired
@Autowired
private
MonitorService
monitorService
;
private
MonitorService
monitorService
;
@Scheduled
(
cron
=
"
0 10 15
* * ?"
)
@Scheduled
(
cron
=
"
*/60 * *
* * ?"
)
private
void
uniqueCheckProcess
(){
private
void
uniqueCheckProcess
(){
checkService
.
checkAndPersistSimpleResult
(
Constants
.
CHECK_UNIQUE
);
checkService
.
checkAndPersistSimpleResult
(
Constants
.
CHECK_UNIQUE
);
}
}
@Scheduled
(
cron
=
"
0 20 15
* * ?"
)
@Scheduled
(
cron
=
"
*/60 * *
* * ?"
)
private
void
unblankCheckProcess
(){
private
void
unblankCheckProcess
(){
checkService
.
checkAndPersistSimpleResult
(
Constants
.
CHECK_UNBLANK
);
checkService
.
checkAndPersistSimpleResult
(
Constants
.
CHECK_UNBLANK
);
}
}
@Scheduled
(
cron
=
"
0 30 15
* * ?"
)
@Scheduled
(
cron
=
"
*/60 * *
* * ?"
)
private
void
referCheckProcess
(){
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
(){
private
void
volatilityMonitorProcess
(){
monitorService
.
monitorAndPersistVolatilityResult
(
Constants
.
MONITOR_PV
);
monitorService
.
monitorAndPersistVolatilityResult
(
Constants
.
MONITOR_PV
);
}
}
@Scheduled
(
cron
=
"
0 50 15
* * ?"
)
@Scheduled
(
cron
=
"
*/60 * *
* * ?"
)
private
void
specialMonitorProcess
(){
private
void
specialMonitorProcess
(){
monitorService
.
monitorAndPersistSpecialResult
();
monitorService
.
monitorAndPersistSpecialResult
();
}
}
...
...
src/main/java/com/gmei/data/dqmp/service/CheckService.java
View file @
da291251
...
@@ -12,6 +12,6 @@ public interface CheckService {
...
@@ -12,6 +12,6 @@ public interface CheckService {
* 校验并持久化复杂型校验结果
* 校验并持久化复杂型校验结果
* @param checkType
* @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;
...
@@ -28,6 +28,7 @@ import com.gmei.data.dqmp.pool.JdbcConnectPool;
import
com.gmei.data.dqmp.service.CheckService
;
import
com.gmei.data.dqmp.service.CheckService
;
import
com.gmei.data.dqmp.service.DingdingService
;
import
com.gmei.data.dqmp.service.DingdingService
;
import
com.gmei.data.dqmp.service.MailService
;
import
com.gmei.data.dqmp.service.MailService
;
import
com.gmei.data.dqmp.utils.CrontabUtils
;
import
com.gmei.data.dqmp.utils.DateUtils
;
import
com.gmei.data.dqmp.utils.DateUtils
;
@Service
@Service
...
@@ -61,6 +62,10 @@ public class CheckServiceImpl implements CheckService {
...
@@ -61,6 +62,10 @@ public class CheckServiceImpl implements CheckService {
.
andIsValidEqualTo
(
Constants
.
IS_VALID_ON
);
.
andIsValidEqualTo
(
Constants
.
IS_VALID_ON
);
List
<
TblSqlCheckSingle
>
sqlList
=
tblSqlCheckSingleMapper
.
selectByExampleWithBLOBs
(
tblCheckSingleSqlCriteria
);
List
<
TblSqlCheckSingle
>
sqlList
=
tblSqlCheckSingleMapper
.
selectByExampleWithBLOBs
(
tblCheckSingleSqlCriteria
);
for
(
TblSqlCheckSingle
tblCheckSql
:
sqlList
)
{
for
(
TblSqlCheckSingle
tblCheckSql
:
sqlList
)
{
String
checkTime
=
tblCheckSql
.
getCheckTime
();
if
(!
CrontabUtils
.
isToRunByMinites
(
checkTime
))
{
continue
;
}
String
sql
=
tblCheckSql
.
getSqlContent
();
String
sql
=
tblCheckSql
.
getSqlContent
();
Integer
id
=
tblCheckSql
.
getId
();
Integer
id
=
tblCheckSql
.
getId
();
Double
threshold
=
tblCheckSql
.
getThreshold
();
Double
threshold
=
tblCheckSql
.
getThreshold
();
...
@@ -69,7 +74,7 @@ public class CheckServiceImpl implements CheckService {
...
@@ -69,7 +74,7 @@ public class CheckServiceImpl implements CheckService {
TblResultCheckUnique
uniqueCheckResult
=
getUniqueCheckResult
(
sql
);
TblResultCheckUnique
uniqueCheckResult
=
getUniqueCheckResult
(
sql
);
if
(
uniqueCheckResult
==
null
)
{
if
(
uniqueCheckResult
==
null
)
{
logger
.
error
(
"Find result is empty!"
);
logger
.
error
(
"Find result is empty!"
);
return
;
continue
;
}
else
{
}
else
{
Double
uniqueRate
=
uniqueCheckResult
.
getUniqueRate
();
Double
uniqueRate
=
uniqueCheckResult
.
getUniqueRate
();
if
(
null
!=
uniqueRate
&&
uniqueRate
<
threshold
)
{
if
(
null
!=
uniqueRate
&&
uniqueRate
<
threshold
)
{
...
@@ -83,7 +88,7 @@ public class CheckServiceImpl implements CheckService {
...
@@ -83,7 +88,7 @@ public class CheckServiceImpl implements CheckService {
TblResultCheckUnblank
tblResultCheckUnblank
=
getUnblankCheckResult
(
sql
);
TblResultCheckUnblank
tblResultCheckUnblank
=
getUnblankCheckResult
(
sql
);
if
(
tblResultCheckUnblank
==
null
)
{
if
(
tblResultCheckUnblank
==
null
)
{
logger
.
error
(
"Find result is empty!"
);
logger
.
error
(
"Find result is empty!"
);
return
;
continue
;
}
else
{
}
else
{
Double
unblankRate
=
tblResultCheckUnblank
.
getUnblankRate
();
Double
unblankRate
=
tblResultCheckUnblank
.
getUnblankRate
();
if
(
null
!=
unblankRate
&&
unblankRate
<
threshold
)
{
if
(
null
!=
unblankRate
&&
unblankRate
<
threshold
)
{
...
@@ -107,13 +112,17 @@ public class CheckServiceImpl implements CheckService {
...
@@ -107,13 +112,17 @@ public class CheckServiceImpl implements CheckService {
* @param checkType
* @param checkType
*/
*/
@Override
@Override
public
void
checkAndPersist
Multiple
Result
(
String
checkType
)
{
public
void
checkAndPersist
Deplex
Result
(
String
checkType
)
{
TblSqlCheckDuplexCriteria
tblCheckMultipleSqlCriteria
=
new
TblSqlCheckDuplexCriteria
();
TblSqlCheckDuplexCriteria
tblCheckMultipleSqlCriteria
=
new
TblSqlCheckDuplexCriteria
();
tblCheckMultipleSqlCriteria
.
createCriteria
()
tblCheckMultipleSqlCriteria
.
createCriteria
()
.
andCheckTypeEqualTo
(
checkType
)
.
andCheckTypeEqualTo
(
checkType
)
.
andIsValidEqualTo
(
Constants
.
IS_VALID_ON
);
.
andIsValidEqualTo
(
Constants
.
IS_VALID_ON
);
List
<
TblSqlCheckDuplex
>
sqlList
=
tblSqlCheckDuplexMapper
.
selectByExampleWithBLOBs
(
tblCheckMultipleSqlCriteria
);
List
<
TblSqlCheckDuplex
>
sqlList
=
tblSqlCheckDuplexMapper
.
selectByExampleWithBLOBs
(
tblCheckMultipleSqlCriteria
);
for
(
TblSqlCheckDuplex
tblCheckSql
:
sqlList
)
{
for
(
TblSqlCheckDuplex
tblCheckSql
:
sqlList
)
{
String
checkTime
=
tblCheckSql
.
getCheckTime
();
if
(!
CrontabUtils
.
isToRunByMinites
(
checkTime
))
{
continue
;
}
String
sql
=
tblCheckSql
.
getSqlContent
();
String
sql
=
tblCheckSql
.
getSqlContent
();
Integer
id
=
tblCheckSql
.
getId
();
Integer
id
=
tblCheckSql
.
getId
();
Double
threshold
=
tblCheckSql
.
getThreshold
();
Double
threshold
=
tblCheckSql
.
getThreshold
();
...
@@ -122,7 +131,7 @@ public class CheckServiceImpl implements CheckService {
...
@@ -122,7 +131,7 @@ public class CheckServiceImpl implements CheckService {
TblResultCheckRefer
referCheckResult
=
getReferCheckResult
(
sql
);
TblResultCheckRefer
referCheckResult
=
getReferCheckResult
(
sql
);
if
(
referCheckResult
==
null
)
{
if
(
referCheckResult
==
null
)
{
logger
.
error
(
"Find result is empty!"
);
logger
.
error
(
"Find result is empty!"
);
return
;
continue
;
}
else
{
}
else
{
Double
matchedRate
=
referCheckResult
.
getMatchedRate
();
Double
matchedRate
=
referCheckResult
.
getMatchedRate
();
if
(
null
!=
matchedRate
&&
matchedRate
<
threshold
)
{
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;
...
@@ -26,6 +26,7 @@ import com.gmei.data.dqmp.pool.JdbcConnectPool;
import
com.gmei.data.dqmp.service.DingdingService
;
import
com.gmei.data.dqmp.service.DingdingService
;
import
com.gmei.data.dqmp.service.MailService
;
import
com.gmei.data.dqmp.service.MailService
;
import
com.gmei.data.dqmp.service.MonitorService
;
import
com.gmei.data.dqmp.service.MonitorService
;
import
com.gmei.data.dqmp.utils.CrontabUtils
;
import
com.gmei.data.dqmp.utils.DateUtils
;
import
com.gmei.data.dqmp.utils.DateUtils
;
@Service
@Service
...
@@ -58,6 +59,10 @@ public class MonitorServiceImpl implements MonitorService {
...
@@ -58,6 +59,10 @@ public class MonitorServiceImpl implements MonitorService {
List
<
TblSqlMonitorVolatility
>
sqlList
=
tblSqlMonitorVolatilityMapper
List
<
TblSqlMonitorVolatility
>
sqlList
=
tblSqlMonitorVolatilityMapper
.
selectByExampleWithBLOBs
(
tblmonitorVolatilitySqlCriteria
);
.
selectByExampleWithBLOBs
(
tblmonitorVolatilitySqlCriteria
);
for
(
TblSqlMonitorVolatility
tblCheckSql
:
sqlList
)
{
for
(
TblSqlMonitorVolatility
tblCheckSql
:
sqlList
)
{
String
checkTime
=
tblCheckSql
.
getCheckTime
();
if
(!
CrontabUtils
.
isToRunByMinites
(
checkTime
))
{
continue
;
}
String
sql
=
tblCheckSql
.
getSqlContent
();
String
sql
=
tblCheckSql
.
getSqlContent
();
Integer
id
=
tblCheckSql
.
getId
();
Integer
id
=
tblCheckSql
.
getId
();
Double
threshold
=
tblCheckSql
.
getThreshold
();
Double
threshold
=
tblCheckSql
.
getThreshold
();
...
@@ -65,7 +70,7 @@ public class MonitorServiceImpl implements MonitorService {
...
@@ -65,7 +70,7 @@ public class MonitorServiceImpl implements MonitorService {
TblResultMonitorVolatility
tblResultMonitorVolatility
=
getMonitorVolatilityResult
(
sql
,
indicatorType
);
TblResultMonitorVolatility
tblResultMonitorVolatility
=
getMonitorVolatilityResult
(
sql
,
indicatorType
);
if
(
tblResultMonitorVolatility
==
null
)
{
if
(
tblResultMonitorVolatility
==
null
)
{
logger
.
error
(
"Find result is empty!"
);
logger
.
error
(
"Find result is empty!"
);
return
;
continue
;
}
else
{
}
else
{
Long
indicatorValue
=
tblResultMonitorVolatility
.
getIndicatorValue
();
Long
indicatorValue
=
tblResultMonitorVolatility
.
getIndicatorValue
();
if
(
null
!=
indicatorValue
&&
indicatorValue
<
threshold
)
{
if
(
null
!=
indicatorValue
&&
indicatorValue
<
threshold
)
{
...
@@ -93,6 +98,10 @@ public class MonitorServiceImpl implements MonitorService {
...
@@ -93,6 +98,10 @@ public class MonitorServiceImpl implements MonitorService {
tblMonitorSpecialSqlCriteria
.
createCriteria
().
andIsValidEqualTo
(
Constants
.
IS_VALID_ON
);
tblMonitorSpecialSqlCriteria
.
createCriteria
().
andIsValidEqualTo
(
Constants
.
IS_VALID_ON
);
List
<
TblSqlMonitorSpecial
>
sqlList
=
tblSqlMonitorSpecialMapper
.
selectByExampleWithBLOBs
(
tblMonitorSpecialSqlCriteria
);
List
<
TblSqlMonitorSpecial
>
sqlList
=
tblSqlMonitorSpecialMapper
.
selectByExampleWithBLOBs
(
tblMonitorSpecialSqlCriteria
);
for
(
TblSqlMonitorSpecial
tblCheckSql
:
sqlList
)
{
for
(
TblSqlMonitorSpecial
tblCheckSql
:
sqlList
)
{
String
checkTime
=
tblCheckSql
.
getCheckTime
();
if
(!
CrontabUtils
.
isToRunByMinites
(
checkTime
))
{
continue
;
}
String
sql
=
tblCheckSql
.
getSqlContent
();
String
sql
=
tblCheckSql
.
getSqlContent
();
Integer
id
=
tblCheckSql
.
getId
();
Integer
id
=
tblCheckSql
.
getId
();
Double
threshold
=
tblCheckSql
.
getThreshold
();
Double
threshold
=
tblCheckSql
.
getThreshold
();
...
@@ -100,7 +109,7 @@ public class MonitorServiceImpl implements MonitorService {
...
@@ -100,7 +109,7 @@ public class MonitorServiceImpl implements MonitorService {
TblResultMonitorSpecial
tblResultMonitorSpecial
=
getMonitorSpecialResult
(
sql
);
TblResultMonitorSpecial
tblResultMonitorSpecial
=
getMonitorSpecialResult
(
sql
);
if
(
tblResultMonitorSpecial
==
null
)
{
if
(
tblResultMonitorSpecial
==
null
)
{
logger
.
error
(
"Find result is empty!"
);
logger
.
error
(
"Find result is empty!"
);
return
;
continue
;
}
else
{
}
else
{
Long
indicatorValue
=
tblResultMonitorSpecial
.
getIndicatorValue
();
Long
indicatorValue
=
tblResultMonitorSpecial
.
getIndicatorValue
();
if
(
null
!=
indicatorValue
&&
indicatorValue
<
threshold
)
{
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 {
...
@@ -12,21 +12,21 @@ public class CrontabUtils {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CrontabUtils
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CrontabUtils
.
class
);
/**
/**
* 根据crontab表达式判断当前任务是否应该执行【未来
一分钟
以内】
* 根据crontab表达式判断当前任务是否应该执行【未来
1小时
以内】
* @param crontabStr
* @param crontabStr
* @return
* @return
*/
*/
public
static
boolean
isToRun
(
String
crontabStr
)
{
public
static
boolean
isToRun
ByTimeRange
(
String
crontabStr
)
{
boolean
rs
=
false
;
boolean
rs
=
false
;
Date
currentDate
=
new
Date
();
Date
currentDate
=
new
Date
();
long
currentDateMilliseconds
=
currentDate
.
getTime
();
long
currentDateMilliseconds
=
currentDate
.
getTime
();
CronExpression
expression
=
null
;
CronExpression
expression
=
null
;
try
{
try
{
expression
=
new
CronExpression
(
"0 14 20 * * ?"
);
expression
=
new
CronExpression
(
crontabStr
);
Date
newDate
=
expression
.
getNextValidTimeAfter
(
currentDate
);
Date
newDate
=
expression
.
getNextValidTimeAfter
(
currentDate
);
long
newDateMilliseconds
=
newDate
.
getTime
();
long
newDateMilliseconds
=
newDate
.
getTime
();
long
diffSeconds
=
(
newDateMilliseconds
-
currentDateMilliseconds
)/
1000
;
long
diffSeconds
=
(
newDateMilliseconds
-
currentDateMilliseconds
)/
1000
;
if
(
diffSeconds
<
60
)
{
if
(
diffSeconds
<
60
*
60
)
{
rs
=
true
;
rs
=
true
;
}
}
}
catch
(
ParseException
e
)
{
}
catch
(
ParseException
e
)
{
...
@@ -37,7 +37,27 @@ public class CrontabUtils {
...
@@ -37,7 +37,27 @@ public class CrontabUtils {
return
rs
;
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
)
{
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