Commit ae3ea969 authored by 赵建伟's avatar 赵建伟

update codes

parent da291251
package com.gmei.data.dqmp.config;
import java.util.concurrent.Executors;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
@Configuration
public class ScheduleConfig implements SchedulingConfigurer {
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
taskRegistrar.setScheduler(Executors.newScheduledThreadPool(10));
}
}
...@@ -3,6 +3,7 @@ package com.gmei.data.dqmp.service.impl; ...@@ -3,6 +3,7 @@ package com.gmei.data.dqmp.service.impl;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -61,9 +62,10 @@ public class CheckServiceImpl implements CheckService { ...@@ -61,9 +62,10 @@ public class CheckServiceImpl implements CheckService {
.andCheckTypeEqualTo(checkType) .andCheckTypeEqualTo(checkType)
.andIsValidEqualTo(Constants.IS_VALID_ON); .andIsValidEqualTo(Constants.IS_VALID_ON);
List<TblSqlCheckSingle> sqlList = tblSqlCheckSingleMapper.selectByExampleWithBLOBs(tblCheckSingleSqlCriteria); List<TblSqlCheckSingle> sqlList = tblSqlCheckSingleMapper.selectByExampleWithBLOBs(tblCheckSingleSqlCriteria);
Date currentDate = new Date();
for (TblSqlCheckSingle tblCheckSql : sqlList) { for (TblSqlCheckSingle tblCheckSql : sqlList) {
String checkTime = tblCheckSql.getCheckTime(); String checkTime = tblCheckSql.getCheckTime();
if(!CrontabUtils.isToRunByMinites(checkTime)) { if(!CrontabUtils.isToRunByMinites(currentDate,checkTime)) {
continue; continue;
} }
String sql = tblCheckSql.getSqlContent(); String sql = tblCheckSql.getSqlContent();
...@@ -98,11 +100,14 @@ public class CheckServiceImpl implements CheckService { ...@@ -98,11 +100,14 @@ public class CheckServiceImpl implements CheckService {
} }
tblResultCheckUnblank.setSqlId(id); tblResultCheckUnblank.setSqlId(id);
rs = tblResultCheckUnblankMapper.insert(tblResultCheckUnblank); rs = tblResultCheckUnblankMapper.insert(tblResultCheckUnblank);
}else {
logger.error("Check type is error: {}",checkType);
continue;
} }
if (rs == 1) { if (rs == 1) {
logger.info("Run success: {}", sql); logger.info("Run success!");
} else { } else {
logger.error("Run failed: {}", sql); logger.error("Run failed!");
} }
} }
} }
...@@ -118,9 +123,10 @@ public class CheckServiceImpl implements CheckService { ...@@ -118,9 +123,10 @@ public class CheckServiceImpl implements CheckService {
.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);
Date currentDate = new Date();
for (TblSqlCheckDuplex tblCheckSql : sqlList) { for (TblSqlCheckDuplex tblCheckSql : sqlList) {
String checkTime = tblCheckSql.getCheckTime(); String checkTime = tblCheckSql.getCheckTime();
if(!CrontabUtils.isToRunByMinites(checkTime)) { if(!CrontabUtils.isToRunByMinites(currentDate,checkTime)) {
continue; continue;
} }
String sql = tblCheckSql.getSqlContent(); String sql = tblCheckSql.getSqlContent();
...@@ -143,9 +149,9 @@ public class CheckServiceImpl implements CheckService { ...@@ -143,9 +149,9 @@ public class CheckServiceImpl implements CheckService {
rs = tblResultCheckReferMapper.insert(referCheckResult); rs = tblResultCheckReferMapper.insert(referCheckResult);
} }
if (rs == 1) { if (rs == 1) {
logger.info("Run success: {}", sql); logger.info("Run success!");
} else { } else {
logger.error("Run failed: {}", sql); logger.error("Run failed!");
} }
} }
} }
...@@ -262,5 +268,6 @@ public class CheckServiceImpl implements CheckService { ...@@ -262,5 +268,6 @@ public class CheckServiceImpl implements CheckService {
} }
public static void main(String[] args) { public static void main(String[] args) {
String sql = "";
} }
} }
...@@ -33,6 +33,7 @@ public class DingdingServiceImpl implements DingdingService { ...@@ -33,6 +33,7 @@ public class DingdingServiceImpl implements DingdingService {
*/ */
@Override @Override
public Boolean sendMsgToDingding(String msg) { public Boolean sendMsgToDingding(String msg) {
msg = "数据质量监控预警触发,具体参数信息如下:\n" + msg;
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("msgtype", "text"); jsonObject.put("msgtype", "text");
JSONObject jo = new JSONObject(); JSONObject jo = new JSONObject();
......
...@@ -26,6 +26,7 @@ public class MailServiceImpl implements MailService{ ...@@ -26,6 +26,7 @@ public class MailServiceImpl implements MailService{
@Override @Override
public void sendSimpleMail(String content) { public void sendSimpleMail(String content) {
content = "数据质量监控预警触发,具体参数信息如下:\n" + content;
SimpleMailMessage message = new SimpleMailMessage(); SimpleMailMessage message = new SimpleMailMessage();
message.setFrom(from); message.setFrom(from);
message.setTo(to); message.setTo(to);
......
...@@ -3,6 +3,7 @@ package com.gmei.data.dqmp.service.impl; ...@@ -3,6 +3,7 @@ package com.gmei.data.dqmp.service.impl;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -58,9 +59,10 @@ public class MonitorServiceImpl implements MonitorService { ...@@ -58,9 +59,10 @@ public class MonitorServiceImpl implements MonitorService {
tblmonitorVolatilitySqlCriteria.createCriteria().andIndicatorTypeEqualTo(indicatorType).andIsValidEqualTo(Constants.IS_VALID_ON); tblmonitorVolatilitySqlCriteria.createCriteria().andIndicatorTypeEqualTo(indicatorType).andIsValidEqualTo(Constants.IS_VALID_ON);
List<TblSqlMonitorVolatility> sqlList = tblSqlMonitorVolatilityMapper List<TblSqlMonitorVolatility> sqlList = tblSqlMonitorVolatilityMapper
.selectByExampleWithBLOBs(tblmonitorVolatilitySqlCriteria); .selectByExampleWithBLOBs(tblmonitorVolatilitySqlCriteria);
Date currentDate = new Date();
for (TblSqlMonitorVolatility tblCheckSql : sqlList) { for (TblSqlMonitorVolatility tblCheckSql : sqlList) {
String checkTime = tblCheckSql.getCheckTime(); String checkTime = tblCheckSql.getCheckTime();
if(!CrontabUtils.isToRunByMinites(checkTime)) { if(!CrontabUtils.isToRunByMinites(currentDate,checkTime)) {
continue; continue;
} }
String sql = tblCheckSql.getSqlContent(); String sql = tblCheckSql.getSqlContent();
...@@ -81,9 +83,9 @@ public class MonitorServiceImpl implements MonitorService { ...@@ -81,9 +83,9 @@ public class MonitorServiceImpl implements MonitorService {
tblResultMonitorVolatility.setSqlId(id); tblResultMonitorVolatility.setSqlId(id);
rs = tblResultMonitorVolatilityMapper.insert(tblResultMonitorVolatility); rs = tblResultMonitorVolatilityMapper.insert(tblResultMonitorVolatility);
if (rs == 1) { if (rs == 1) {
logger.info("Run success: {}", sql); logger.info("Run success!");
} else { } else {
logger.error("Run failed: {}", sql); logger.error("Run failed!");
} }
} }
} }
...@@ -97,9 +99,10 @@ public class MonitorServiceImpl implements MonitorService { ...@@ -97,9 +99,10 @@ public class MonitorServiceImpl implements MonitorService {
TblSqlMonitorSpecialCriteria tblMonitorSpecialSqlCriteria = new TblSqlMonitorSpecialCriteria(); TblSqlMonitorSpecialCriteria tblMonitorSpecialSqlCriteria = new TblSqlMonitorSpecialCriteria();
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);
Date currentDate = new Date();
for (TblSqlMonitorSpecial tblCheckSql : sqlList) { for (TblSqlMonitorSpecial tblCheckSql : sqlList) {
String checkTime = tblCheckSql.getCheckTime(); String checkTime = tblCheckSql.getCheckTime();
if(!CrontabUtils.isToRunByMinites(checkTime)) { if(!CrontabUtils.isToRunByMinites(currentDate,checkTime)) {
continue; continue;
} }
String sql = tblCheckSql.getSqlContent(); String sql = tblCheckSql.getSqlContent();
...@@ -120,9 +123,9 @@ public class MonitorServiceImpl implements MonitorService { ...@@ -120,9 +123,9 @@ public class MonitorServiceImpl implements MonitorService {
tblResultMonitorSpecial.setSqlId(id); tblResultMonitorSpecial.setSqlId(id);
rs = tblResultMonitorSpecialMapper.insert(tblResultMonitorSpecial); rs = tblResultMonitorSpecialMapper.insert(tblResultMonitorSpecial);
if (rs == 1) { if (rs == 1) {
logger.info("Run success: {}", sql); logger.info("Run success!");
} else { } else {
logger.error("Run failed: {}", sql); logger.error("Run failed!");
} }
} }
} }
......
...@@ -16,9 +16,8 @@ public class CrontabUtils { ...@@ -16,9 +16,8 @@ public class CrontabUtils {
* @param crontabStr * @param crontabStr
* @return * @return
*/ */
public static boolean isToRunByTimeRange(String crontabStr) { public static boolean isToRunByTimeRange(Date currentDate,String crontabStr) {
boolean rs = false; boolean rs = false;
Date currentDate = new Date();
long currentDateMilliseconds = currentDate.getTime(); long currentDateMilliseconds = currentDate.getTime();
CronExpression expression = null; CronExpression expression = null;
try { try {
...@@ -42,11 +41,10 @@ public class CrontabUtils { ...@@ -42,11 +41,10 @@ public class CrontabUtils {
* @param crontabStr * @param crontabStr
* @return * @return
*/ */
public static boolean isToRunByMinites(String crontabStr) { public static boolean isToRunByMinites(Date currentDate,String crontabStr) {
boolean rs = false; boolean rs = false;
try { try {
CronExpression expression = new CronExpression(crontabStr); CronExpression expression = new CronExpression(crontabStr);
Date currentDate = new Date();
rs = expression.isSatisfiedBy(currentDate); rs = expression.isSatisfiedBy(currentDate);
} catch (ParseException e) { } catch (ParseException e) {
logger.error("Fail to parse cron express", e); logger.error("Fail to parse cron express", e);
...@@ -57,7 +55,9 @@ public class CrontabUtils { ...@@ -57,7 +55,9 @@ public class CrontabUtils {
} }
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(isToRunByTimeRange("0 0 12 25 * ?")); Date currentDate = new Date();
System.out.println(isToRunByMinites("* 57 10 25 * ?")); System.out.println(isToRunByTimeRange(currentDate,"0 0 12 25 * ?"));
System.out.println(isToRunByMinites(currentDate,"* 57 10 25 * ?"));
System.out.println(isToRunByMinites(currentDate,"* 50 11 ? * WED"));
} }
} }
#base #base
driverClassName=org.apache.hive.jdbc.HiveDriver driverClassName=org.apache.hive.jdbc.HiveDriver
url=jdbc:hive2://152.136.57.57:10010 #url=jdbc:hive2://152.136.57.57:10010
url=jdbc:hive2://bj-gm-prod-cos-datacenter007:10010
username=data username=data
password= password=
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ECharts</title>
<!-- 引入 echarts.js -->
<script src="echarts.min.js"></script>
</head>
<body>
123
<!-- 为ECharts准备一个具备大小(宽高)的Dom -->
<div id="main" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('main'));
// 指定图表的配置项和数据
var option = {
title: {
text: 'ECharts 入门示例'
},
tooltip: {},
legend: {
data:['销量']
},
xAxis: {
data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
},
yAxis: {},
series: [{
name: '销量',
type: 'bar',
data: [5, 20, 36, 10, 10, 20]
}]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
</script>
</body>
</html>
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment