Commit 37c84e7e authored by 薛鹏飞's avatar 薛鹏飞

Merge branch 'zhaojianwei' into 'master'

add monitor function codes

See merge request !4
parents 7780663a 970ae981
...@@ -41,5 +41,7 @@ public class Constants { ...@@ -41,5 +41,7 @@ public class Constants {
public static final String REFER = "refer"; public static final String REFER = "refer";
public static final String VOLATILITY = "volatility"; public static final String VOLATILITY = "volatility";
public static final String SPECIAL = "special"; public static final String SPECIAL = "special";
// 日环比监控类型
public static final String MONITOR_TYPE = "day_chain";
} }
package com.gmei.data.dqmp.domain;
public class TblMonitorVolatilityRule {
private Integer id;
private String dbName;
private String tbName;
private String colName;
private String indicatorType;
private String monitorType;
private Double threshold;
private String checkTime;
private String comment;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getDbName() {
return dbName;
}
public void setDbName(String dbName) {
this.dbName = dbName == null ? null : dbName.trim();
}
public String getTbName() {
return tbName;
}
public void setTbName(String tbName) {
this.tbName = tbName == null ? null : tbName.trim();
}
public String getColName() {
return colName;
}
public void setColName(String colName) {
this.colName = colName == null ? null : colName.trim();
}
public String getIndicatorType() {
return indicatorType;
}
public void setIndicatorType(String indicatorType) {
this.indicatorType = indicatorType == null ? null : indicatorType.trim();
}
public String getMonitorType() {
return monitorType;
}
public void setMonitorType(String monitorType) {
this.monitorType = monitorType == null ? null : monitorType.trim();
}
public Double getThreshold() {
return threshold;
}
public void setThreshold(Double threshold) {
this.threshold = threshold;
}
public String getCheckTime() {
return checkTime;
}
public void setCheckTime(String checkTime) {
this.checkTime = checkTime == null ? null : checkTime.trim();
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment == null ? null : comment.trim();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", dbName=").append(dbName);
sb.append(", tbName=").append(tbName);
sb.append(", colName=").append(colName);
sb.append(", indicatorType=").append(indicatorType);
sb.append(", monitorType=").append(monitorType);
sb.append(", threshold=").append(threshold);
sb.append(", checkTime=").append(checkTime);
sb.append(", comment=").append(comment);
sb.append("]");
return sb.toString();
}
}
\ No newline at end of file
package com.gmei.data.dqmp.domain;
import java.util.ArrayList;
import java.util.List;
public class TblMonitorVolatilityRuleCriteria {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public TblMonitorVolatilityRuleCriteria() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Integer value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Integer value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Integer value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Integer value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Integer value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Integer> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Integer> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Integer value1, Integer value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Integer value1, Integer value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andDbNameIsNull() {
addCriterion("db_name is null");
return (Criteria) this;
}
public Criteria andDbNameIsNotNull() {
addCriterion("db_name is not null");
return (Criteria) this;
}
public Criteria andDbNameEqualTo(String value) {
addCriterion("db_name =", value, "dbName");
return (Criteria) this;
}
public Criteria andDbNameNotEqualTo(String value) {
addCriterion("db_name <>", value, "dbName");
return (Criteria) this;
}
public Criteria andDbNameGreaterThan(String value) {
addCriterion("db_name >", value, "dbName");
return (Criteria) this;
}
public Criteria andDbNameGreaterThanOrEqualTo(String value) {
addCriterion("db_name >=", value, "dbName");
return (Criteria) this;
}
public Criteria andDbNameLessThan(String value) {
addCriterion("db_name <", value, "dbName");
return (Criteria) this;
}
public Criteria andDbNameLessThanOrEqualTo(String value) {
addCriterion("db_name <=", value, "dbName");
return (Criteria) this;
}
public Criteria andDbNameLike(String value) {
addCriterion("db_name like", value, "dbName");
return (Criteria) this;
}
public Criteria andDbNameNotLike(String value) {
addCriterion("db_name not like", value, "dbName");
return (Criteria) this;
}
public Criteria andDbNameIn(List<String> values) {
addCriterion("db_name in", values, "dbName");
return (Criteria) this;
}
public Criteria andDbNameNotIn(List<String> values) {
addCriterion("db_name not in", values, "dbName");
return (Criteria) this;
}
public Criteria andDbNameBetween(String value1, String value2) {
addCriterion("db_name between", value1, value2, "dbName");
return (Criteria) this;
}
public Criteria andDbNameNotBetween(String value1, String value2) {
addCriterion("db_name not between", value1, value2, "dbName");
return (Criteria) this;
}
public Criteria andTbNameIsNull() {
addCriterion("tb_name is null");
return (Criteria) this;
}
public Criteria andTbNameIsNotNull() {
addCriterion("tb_name is not null");
return (Criteria) this;
}
public Criteria andTbNameEqualTo(String value) {
addCriterion("tb_name =", value, "tbName");
return (Criteria) this;
}
public Criteria andTbNameNotEqualTo(String value) {
addCriterion("tb_name <>", value, "tbName");
return (Criteria) this;
}
public Criteria andTbNameGreaterThan(String value) {
addCriterion("tb_name >", value, "tbName");
return (Criteria) this;
}
public Criteria andTbNameGreaterThanOrEqualTo(String value) {
addCriterion("tb_name >=", value, "tbName");
return (Criteria) this;
}
public Criteria andTbNameLessThan(String value) {
addCriterion("tb_name <", value, "tbName");
return (Criteria) this;
}
public Criteria andTbNameLessThanOrEqualTo(String value) {
addCriterion("tb_name <=", value, "tbName");
return (Criteria) this;
}
public Criteria andTbNameLike(String value) {
addCriterion("tb_name like", value, "tbName");
return (Criteria) this;
}
public Criteria andTbNameNotLike(String value) {
addCriterion("tb_name not like", value, "tbName");
return (Criteria) this;
}
public Criteria andTbNameIn(List<String> values) {
addCriterion("tb_name in", values, "tbName");
return (Criteria) this;
}
public Criteria andTbNameNotIn(List<String> values) {
addCriterion("tb_name not in", values, "tbName");
return (Criteria) this;
}
public Criteria andTbNameBetween(String value1, String value2) {
addCriterion("tb_name between", value1, value2, "tbName");
return (Criteria) this;
}
public Criteria andTbNameNotBetween(String value1, String value2) {
addCriterion("tb_name not between", value1, value2, "tbName");
return (Criteria) this;
}
public Criteria andColNameIsNull() {
addCriterion("col_name is null");
return (Criteria) this;
}
public Criteria andColNameIsNotNull() {
addCriterion("col_name is not null");
return (Criteria) this;
}
public Criteria andColNameEqualTo(String value) {
addCriterion("col_name =", value, "colName");
return (Criteria) this;
}
public Criteria andColNameNotEqualTo(String value) {
addCriterion("col_name <>", value, "colName");
return (Criteria) this;
}
public Criteria andColNameGreaterThan(String value) {
addCriterion("col_name >", value, "colName");
return (Criteria) this;
}
public Criteria andColNameGreaterThanOrEqualTo(String value) {
addCriterion("col_name >=", value, "colName");
return (Criteria) this;
}
public Criteria andColNameLessThan(String value) {
addCriterion("col_name <", value, "colName");
return (Criteria) this;
}
public Criteria andColNameLessThanOrEqualTo(String value) {
addCriterion("col_name <=", value, "colName");
return (Criteria) this;
}
public Criteria andColNameLike(String value) {
addCriterion("col_name like", value, "colName");
return (Criteria) this;
}
public Criteria andColNameNotLike(String value) {
addCriterion("col_name not like", value, "colName");
return (Criteria) this;
}
public Criteria andColNameIn(List<String> values) {
addCriterion("col_name in", values, "colName");
return (Criteria) this;
}
public Criteria andColNameNotIn(List<String> values) {
addCriterion("col_name not in", values, "colName");
return (Criteria) this;
}
public Criteria andColNameBetween(String value1, String value2) {
addCriterion("col_name between", value1, value2, "colName");
return (Criteria) this;
}
public Criteria andColNameNotBetween(String value1, String value2) {
addCriterion("col_name not between", value1, value2, "colName");
return (Criteria) this;
}
public Criteria andIndicatorTypeIsNull() {
addCriterion("indicator_type is null");
return (Criteria) this;
}
public Criteria andIndicatorTypeIsNotNull() {
addCriterion("indicator_type is not null");
return (Criteria) this;
}
public Criteria andIndicatorTypeEqualTo(String value) {
addCriterion("indicator_type =", value, "indicatorType");
return (Criteria) this;
}
public Criteria andIndicatorTypeNotEqualTo(String value) {
addCriterion("indicator_type <>", value, "indicatorType");
return (Criteria) this;
}
public Criteria andIndicatorTypeGreaterThan(String value) {
addCriterion("indicator_type >", value, "indicatorType");
return (Criteria) this;
}
public Criteria andIndicatorTypeGreaterThanOrEqualTo(String value) {
addCriterion("indicator_type >=", value, "indicatorType");
return (Criteria) this;
}
public Criteria andIndicatorTypeLessThan(String value) {
addCriterion("indicator_type <", value, "indicatorType");
return (Criteria) this;
}
public Criteria andIndicatorTypeLessThanOrEqualTo(String value) {
addCriterion("indicator_type <=", value, "indicatorType");
return (Criteria) this;
}
public Criteria andIndicatorTypeLike(String value) {
addCriterion("indicator_type like", value, "indicatorType");
return (Criteria) this;
}
public Criteria andIndicatorTypeNotLike(String value) {
addCriterion("indicator_type not like", value, "indicatorType");
return (Criteria) this;
}
public Criteria andIndicatorTypeIn(List<String> values) {
addCriterion("indicator_type in", values, "indicatorType");
return (Criteria) this;
}
public Criteria andIndicatorTypeNotIn(List<String> values) {
addCriterion("indicator_type not in", values, "indicatorType");
return (Criteria) this;
}
public Criteria andIndicatorTypeBetween(String value1, String value2) {
addCriterion("indicator_type between", value1, value2, "indicatorType");
return (Criteria) this;
}
public Criteria andIndicatorTypeNotBetween(String value1, String value2) {
addCriterion("indicator_type not between", value1, value2, "indicatorType");
return (Criteria) this;
}
public Criteria andMonitorTypeIsNull() {
addCriterion("monitor_type is null");
return (Criteria) this;
}
public Criteria andMonitorTypeIsNotNull() {
addCriterion("monitor_type is not null");
return (Criteria) this;
}
public Criteria andMonitorTypeEqualTo(String value) {
addCriterion("monitor_type =", value, "monitorType");
return (Criteria) this;
}
public Criteria andMonitorTypeNotEqualTo(String value) {
addCriterion("monitor_type <>", value, "monitorType");
return (Criteria) this;
}
public Criteria andMonitorTypeGreaterThan(String value) {
addCriterion("monitor_type >", value, "monitorType");
return (Criteria) this;
}
public Criteria andMonitorTypeGreaterThanOrEqualTo(String value) {
addCriterion("monitor_type >=", value, "monitorType");
return (Criteria) this;
}
public Criteria andMonitorTypeLessThan(String value) {
addCriterion("monitor_type <", value, "monitorType");
return (Criteria) this;
}
public Criteria andMonitorTypeLessThanOrEqualTo(String value) {
addCriterion("monitor_type <=", value, "monitorType");
return (Criteria) this;
}
public Criteria andMonitorTypeLike(String value) {
addCriterion("monitor_type like", value, "monitorType");
return (Criteria) this;
}
public Criteria andMonitorTypeNotLike(String value) {
addCriterion("monitor_type not like", value, "monitorType");
return (Criteria) this;
}
public Criteria andMonitorTypeIn(List<String> values) {
addCriterion("monitor_type in", values, "monitorType");
return (Criteria) this;
}
public Criteria andMonitorTypeNotIn(List<String> values) {
addCriterion("monitor_type not in", values, "monitorType");
return (Criteria) this;
}
public Criteria andMonitorTypeBetween(String value1, String value2) {
addCriterion("monitor_type between", value1, value2, "monitorType");
return (Criteria) this;
}
public Criteria andMonitorTypeNotBetween(String value1, String value2) {
addCriterion("monitor_type not between", value1, value2, "monitorType");
return (Criteria) this;
}
public Criteria andThresholdIsNull() {
addCriterion("threshold is null");
return (Criteria) this;
}
public Criteria andThresholdIsNotNull() {
addCriterion("threshold is not null");
return (Criteria) this;
}
public Criteria andThresholdEqualTo(Double value) {
addCriterion("threshold =", value, "threshold");
return (Criteria) this;
}
public Criteria andThresholdNotEqualTo(Double value) {
addCriterion("threshold <>", value, "threshold");
return (Criteria) this;
}
public Criteria andThresholdGreaterThan(Double value) {
addCriterion("threshold >", value, "threshold");
return (Criteria) this;
}
public Criteria andThresholdGreaterThanOrEqualTo(Double value) {
addCriterion("threshold >=", value, "threshold");
return (Criteria) this;
}
public Criteria andThresholdLessThan(Double value) {
addCriterion("threshold <", value, "threshold");
return (Criteria) this;
}
public Criteria andThresholdLessThanOrEqualTo(Double value) {
addCriterion("threshold <=", value, "threshold");
return (Criteria) this;
}
public Criteria andThresholdIn(List<Double> values) {
addCriterion("threshold in", values, "threshold");
return (Criteria) this;
}
public Criteria andThresholdNotIn(List<Double> values) {
addCriterion("threshold not in", values, "threshold");
return (Criteria) this;
}
public Criteria andThresholdBetween(Double value1, Double value2) {
addCriterion("threshold between", value1, value2, "threshold");
return (Criteria) this;
}
public Criteria andThresholdNotBetween(Double value1, Double value2) {
addCriterion("threshold not between", value1, value2, "threshold");
return (Criteria) this;
}
public Criteria andCheckTimeIsNull() {
addCriterion("check_time is null");
return (Criteria) this;
}
public Criteria andCheckTimeIsNotNull() {
addCriterion("check_time is not null");
return (Criteria) this;
}
public Criteria andCheckTimeEqualTo(String value) {
addCriterion("check_time =", value, "checkTime");
return (Criteria) this;
}
public Criteria andCheckTimeNotEqualTo(String value) {
addCriterion("check_time <>", value, "checkTime");
return (Criteria) this;
}
public Criteria andCheckTimeGreaterThan(String value) {
addCriterion("check_time >", value, "checkTime");
return (Criteria) this;
}
public Criteria andCheckTimeGreaterThanOrEqualTo(String value) {
addCriterion("check_time >=", value, "checkTime");
return (Criteria) this;
}
public Criteria andCheckTimeLessThan(String value) {
addCriterion("check_time <", value, "checkTime");
return (Criteria) this;
}
public Criteria andCheckTimeLessThanOrEqualTo(String value) {
addCriterion("check_time <=", value, "checkTime");
return (Criteria) this;
}
public Criteria andCheckTimeLike(String value) {
addCriterion("check_time like", value, "checkTime");
return (Criteria) this;
}
public Criteria andCheckTimeNotLike(String value) {
addCriterion("check_time not like", value, "checkTime");
return (Criteria) this;
}
public Criteria andCheckTimeIn(List<String> values) {
addCriterion("check_time in", values, "checkTime");
return (Criteria) this;
}
public Criteria andCheckTimeNotIn(List<String> values) {
addCriterion("check_time not in", values, "checkTime");
return (Criteria) this;
}
public Criteria andCheckTimeBetween(String value1, String value2) {
addCriterion("check_time between", value1, value2, "checkTime");
return (Criteria) this;
}
public Criteria andCheckTimeNotBetween(String value1, String value2) {
addCriterion("check_time not between", value1, value2, "checkTime");
return (Criteria) this;
}
public Criteria andCommentIsNull() {
addCriterion("comment is null");
return (Criteria) this;
}
public Criteria andCommentIsNotNull() {
addCriterion("comment is not null");
return (Criteria) this;
}
public Criteria andCommentEqualTo(String value) {
addCriterion("comment =", value, "comment");
return (Criteria) this;
}
public Criteria andCommentNotEqualTo(String value) {
addCriterion("comment <>", value, "comment");
return (Criteria) this;
}
public Criteria andCommentGreaterThan(String value) {
addCriterion("comment >", value, "comment");
return (Criteria) this;
}
public Criteria andCommentGreaterThanOrEqualTo(String value) {
addCriterion("comment >=", value, "comment");
return (Criteria) this;
}
public Criteria andCommentLessThan(String value) {
addCriterion("comment <", value, "comment");
return (Criteria) this;
}
public Criteria andCommentLessThanOrEqualTo(String value) {
addCriterion("comment <=", value, "comment");
return (Criteria) this;
}
public Criteria andCommentLike(String value) {
addCriterion("comment like", value, "comment");
return (Criteria) this;
}
public Criteria andCommentNotLike(String value) {
addCriterion("comment not like", value, "comment");
return (Criteria) this;
}
public Criteria andCommentIn(List<String> values) {
addCriterion("comment in", values, "comment");
return (Criteria) this;
}
public Criteria andCommentNotIn(List<String> values) {
addCriterion("comment not in", values, "comment");
return (Criteria) this;
}
public Criteria andCommentBetween(String value1, String value2) {
addCriterion("comment between", value1, value2, "comment");
return (Criteria) this;
}
public Criteria andCommentNotBetween(String value1, String value2) {
addCriterion("comment not between", value1, value2, "comment");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}
\ No newline at end of file
package com.gmei.data.dqmp.mapper;
import com.gmei.data.dqmp.domain.TblMonitorVolatilityRule;
import com.gmei.data.dqmp.domain.TblMonitorVolatilityRuleCriteria;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TblMonitorVolatilityRuleMapper {
int countByExample(TblMonitorVolatilityRuleCriteria example);
int deleteByExample(TblMonitorVolatilityRuleCriteria example);
int deleteByPrimaryKey(Integer id);
int insert(TblMonitorVolatilityRule record);
int insertSelective(TblMonitorVolatilityRule record);
List<TblMonitorVolatilityRule> selectByExample(TblMonitorVolatilityRuleCriteria example);
TblMonitorVolatilityRule selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") TblMonitorVolatilityRule record, @Param("example") TblMonitorVolatilityRuleCriteria example);
int updateByExample(@Param("record") TblMonitorVolatilityRule record, @Param("example") TblMonitorVolatilityRuleCriteria example);
int updateByPrimaryKeySelective(TblMonitorVolatilityRule record);
int updateByPrimaryKey(TblMonitorVolatilityRule record);
}
\ No newline at end of file
package com.gmei.data.dqmp.scheduler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.gmei.data.dqmp.service.WarningService;
@Component
public class MonitorScheduler {
@Autowired
private WarningService warningService;
@Scheduled(cron="*/60 * * * * ?")
private void uniqueProcess(){
warningService.checkAndWarning();
}
}
package com.gmei.data.dqmp.service;
public interface WarningService {
void checkAndWarning();
}
...@@ -176,7 +176,8 @@ public class CheckServiceImpl implements CheckService { ...@@ -176,7 +176,8 @@ public class CheckServiceImpl implements CheckService {
* @return * @return
*/ */
private TblResultCheckUnique getUniqueCheckResult(String sql) { private TblResultCheckUnique getUniqueCheckResult(String sql) {
sql = sql.replaceAll("#partition_date", String.format("'%s'", DateUtils.getYesterdayDateStr())); sql = sql.replaceAll("#partition_date", String.format("'%s'", DateUtils.getYesterdayDateStr()))
.replaceAll("#partition_day", String.format("'%s'", DateUtils.getYesterdayDateStr()));
logger.info("Sql content : {}", sql); logger.info("Sql content : {}", sql);
TblResultCheckUnique tblResultCheckUnique = null; TblResultCheckUnique tblResultCheckUnique = null;
if (StringUtils.isBlank(sql)) { if (StringUtils.isBlank(sql)) {
...@@ -212,7 +213,8 @@ public class CheckServiceImpl implements CheckService { ...@@ -212,7 +213,8 @@ public class CheckServiceImpl implements CheckService {
* @return * @return
*/ */
private TblResultCheckUnblank getUnblankCheckResult(String sql) { private TblResultCheckUnblank getUnblankCheckResult(String sql) {
sql = sql.replaceAll("#partition_date", String.format("'%s'", DateUtils.getYesterdayDateStr())); sql = sql.replaceAll("#partition_date", String.format("'%s'", DateUtils.getYesterdayDateStr()))
.replaceAll("#partition_day", String.format("'%s'", DateUtils.getYesterdayDateStr()));
logger.info("Sql content : {}", sql); logger.info("Sql content : {}", sql);
TblResultCheckUnblank tblResultCheckUnblank = null; TblResultCheckUnblank tblResultCheckUnblank = null;
if (StringUtils.isBlank(sql)) { if (StringUtils.isBlank(sql)) {
...@@ -248,7 +250,8 @@ public class CheckServiceImpl implements CheckService { ...@@ -248,7 +250,8 @@ public class CheckServiceImpl implements CheckService {
* @return * @return
*/ */
private TblResultCheckRefer getReferCheckResult(String sql) { private TblResultCheckRefer getReferCheckResult(String sql) {
sql = sql.replaceAll("#partition_date", String.format("'%s'", DateUtils.getYesterdayDateStr())); sql = sql.replaceAll("#partition_date", String.format("'%s'", DateUtils.getYesterdayDateStr()))
.replaceAll("#partition_day", String.format("'%s'", DateUtils.getYesterdayDateStr()));
logger.info("Sql content : {}", sql); logger.info("Sql content : {}", sql);
TblResultCheckRefer tblResultCheckRefer = null; TblResultCheckRefer tblResultCheckRefer = null;
if (StringUtils.isBlank(sql)) { if (StringUtils.isBlank(sql)) {
...@@ -280,8 +283,4 @@ public class CheckServiceImpl implements CheckService { ...@@ -280,8 +283,4 @@ public class CheckServiceImpl implements CheckService {
} }
return tblResultCheckRefer; return tblResultCheckRefer;
} }
public static void main(String[] args) {
String sql = "";
}
} }
...@@ -139,7 +139,8 @@ public class MonitorServiceImpl implements MonitorService { ...@@ -139,7 +139,8 @@ public class MonitorServiceImpl implements MonitorService {
* @return * @return
*/ */
private TblResultMonitorVolatility getMonitorVolatilityResult(String sql, String indicatorType) { private TblResultMonitorVolatility getMonitorVolatilityResult(String sql, String indicatorType) {
sql = sql.replaceAll("#partition_date", String.format("'%s'", DateUtils.getYesterdayDateStr())); sql = sql.replaceAll("#partition_date", String.format("'%s'", DateUtils.getYesterdayDateStr()))
.replaceAll("#partition_day", String.format("'%s'", DateUtils.getYesterdayDateStr()));
logger.info("Sql content : {},indicatorType: {}", sql, indicatorType); logger.info("Sql content : {},indicatorType: {}", sql, indicatorType);
TblResultMonitorVolatility tblResultMonitorVolatility = null; TblResultMonitorVolatility tblResultMonitorVolatility = null;
if (StringUtils.isBlank(sql) || StringUtils.isBlank(indicatorType)) { if (StringUtils.isBlank(sql) || StringUtils.isBlank(indicatorType)) {
...@@ -176,6 +177,7 @@ public class MonitorServiceImpl implements MonitorService { ...@@ -176,6 +177,7 @@ public class MonitorServiceImpl implements MonitorService {
*/ */
private TblResultMonitorSpecial getMonitorSpecialResult(String sql,String startTime) { private TblResultMonitorSpecial getMonitorSpecialResult(String sql,String startTime) {
sql = sql.replaceAll("#partition_date", String.format("'%s'", DateUtils.getYesterdayDateStr())) sql = sql.replaceAll("#partition_date", String.format("'%s'", DateUtils.getYesterdayDateStr()))
.replaceAll("#partition_day", String.format("'%s'", DateUtils.getYesterdayDateStr()))
.replaceAll("#start_time", "'" + DateUtils.getZeroTimeStrsMap().get(startTime) + "'") .replaceAll("#start_time", "'" + DateUtils.getZeroTimeStrsMap().get(startTime) + "'")
.replaceAll("#end_time", "'" + DateUtils.getTodayZeroTimeStr() + "'"); .replaceAll("#end_time", "'" + DateUtils.getTodayZeroTimeStr() + "'");
logger.info("Sql content : {}", sql); logger.info("Sql content : {}", sql);
......
package com.gmei.data.dqmp.service.impl;
import java.util.Date;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gmei.data.dqmp.common.Constants;
import com.gmei.data.dqmp.domain.TblMonitorVolatilityRule;
import com.gmei.data.dqmp.domain.TblMonitorVolatilityRuleCriteria;
import com.gmei.data.dqmp.domain.TblResultMonitorVolatility;
import com.gmei.data.dqmp.domain.TblResultMonitorVolatilityCriteria;
import com.gmei.data.dqmp.domain.TblResultMonitorVolatilityCriteria.Criteria;
import com.gmei.data.dqmp.mapper.TblMonitorVolatilityRuleMapper;
import com.gmei.data.dqmp.mapper.TblResultMonitorVolatilityMapper;
import com.gmei.data.dqmp.service.DingdingService;
import com.gmei.data.dqmp.service.MailService;
import com.gmei.data.dqmp.service.WarningService;
import com.gmei.data.dqmp.utils.CrontabUtils;
import com.gmei.data.dqmp.utils.DateUtils;
@Service
public class WarningServiceImpl implements WarningService {
@Autowired
private DingdingService dingdingService;
@Autowired
private MailService mailService;
@Autowired
private TblMonitorVolatilityRuleMapper tblMonitorVolatilityRuleMapper;
@Autowired
private TblResultMonitorVolatilityMapper tblResultMonitorVolatilityMapper;
private static final Logger logger = LoggerFactory.getLogger(WarningServiceImpl.class);
@Override
public void checkAndWarning() {
List<TblMonitorVolatilityRule> tblMonitorVolatilityRuleList = tblMonitorVolatilityRuleMapper
.selectByExample(new TblMonitorVolatilityRuleCriteria());
Date currentDate = new Date();
String lastOneDayDateStr = DateUtils.getLastNumDaysDateStr(1);
String lastTwoDayDateStr = DateUtils.getLastNumDaysDateStr(2);
for (TblMonitorVolatilityRule tblMonitorVolatilityRule : tblMonitorVolatilityRuleList) {
if (Constants.MONITOR_TYPE.equals(tblMonitorVolatilityRule.getMonitorType())) {
String checkTime = tblMonitorVolatilityRule.getCheckTime();
String dbName = tblMonitorVolatilityRule.getDbName();
String tbName = tblMonitorVolatilityRule.getTbName();
if (!CrontabUtils.isToRunByMinites(currentDate, checkTime)) {
continue;
}
TblResultMonitorVolatilityCriteria tblResultMonitorVolatilityCriteria = new TblResultMonitorVolatilityCriteria();
Criteria criteria = tblResultMonitorVolatilityCriteria.createCriteria();
criteria.andDbNameEqualTo(dbName).andTbNameEqualTo(tbName)
.andColNameEqualTo(tblMonitorVolatilityRule.getColName())
.andIndicatorTypeEqualTo(tblMonitorVolatilityRule.getIndicatorType())
.andPartitionDateBetween(lastTwoDayDateStr, lastOneDayDateStr);
tblResultMonitorVolatilityCriteria.setOrderByClause("partition_date");
List<TblResultMonitorVolatility> tblResultMonitorVolatilityList = tblResultMonitorVolatilityMapper
.selectByExample(tblResultMonitorVolatilityCriteria);
Long lastOneDayIndicatorValue = null, lastTwoDayIndicatorValue = null;
for (TblResultMonitorVolatility tblResultMonitorVolatility : tblResultMonitorVolatilityList) {
String partitionDate = tblResultMonitorVolatility.getPartitionDate();
if (lastOneDayDateStr.equals(partitionDate)) {
lastOneDayIndicatorValue = tblResultMonitorVolatility.getIndicatorValue();
} else if (lastTwoDayDateStr.equals(partitionDate)) {
lastTwoDayIndicatorValue = tblResultMonitorVolatility.getIndicatorValue();
} else {
logger.error("PartitionDate value is error: {}", partitionDate);
continue;
}
}
if (lastOneDayIndicatorValue == null || lastTwoDayIndicatorValue == null) {
logger.error("The lastOneDayIndicatorValue or lastTwoDayIndicatorValue or all values of table {} is empty!", tblMonitorVolatilityRule.getTbName());
return;
}
Double rs = Math.abs((lastOneDayIndicatorValue - lastTwoDayIndicatorValue)
/ Double.valueOf(lastTwoDayIndicatorValue));
Double threshold = tblMonitorVolatilityRule.getThreshold();
if (rs > threshold) {
String warningMsg = String.format("表%s.%s中数据量变化超过%s,疑似异常,请核实!", dbName, tbName,threshold * 100 + "%");
mailService.sendSimpleMail(warningMsg);
dingdingService.sendMsgToDingding(warningMsg);
logger.error("表{}.{}中数据量变化超过{},疑似异常,请核实!", dbName, tbName,threshold * 100+"%");
}
}
}
}
}
...@@ -23,6 +23,17 @@ public class DateUtils { ...@@ -23,6 +23,17 @@ public class DateUtils {
return new SimpleDateFormat(DATE_FORMATE_YMD).format(new Date()); return new SimpleDateFormat(DATE_FORMATE_YMD).format(new Date());
} }
/**
* 获取上N天时间字符串
* @return
*/
public static String getLastNumDaysDateStr(int daysNum) {
Calendar cld = Calendar.getInstance();
cld.setTime(new Date());
cld.add(Calendar.DAY_OF_MONTH, -daysNum);
return new SimpleDateFormat(DATE_FORMATE_YMD).format(cld.getTime());
}
/** /**
* 获取当前时间字符串 * 获取当前时间字符串
* @return * @return
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
<generatedKey column="id" sqlStatement="MySql" identity="true"/> <generatedKey column="id" sqlStatement="MySql" identity="true"/>
</table> --> </table> -->
<!-- <table tableName="tbl_sys_param_info" domainObjectName="TblSysParamInfo"/> --> <!-- <table tableName="tbl_sys_param_info" domainObjectName="TblSysParamInfo"/> -->
<table tableName="tbl_threshold_exceed_all" domainObjectName="TblThresholdExceedAll"/> <!-- <table tableName="tbl_threshold_exceed_all" domainObjectName="TblThresholdExceedAll"/> -->
<table tableName="tbl_monitor_volatility_rule" domainObjectName="TblMonitorVolatilityRule"/>
</context> </context>
</generatorConfiguration> </generatorConfiguration>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.gmei.data.dqmp.mapper.TblMonitorVolatilityRuleMapper" >
<resultMap id="BaseResultMap" type="com.gmei.data.dqmp.domain.TblMonitorVolatilityRule" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="db_name" property="dbName" jdbcType="VARCHAR" />
<result column="tb_name" property="tbName" jdbcType="VARCHAR" />
<result column="col_name" property="colName" jdbcType="VARCHAR" />
<result column="indicator_type" property="indicatorType" jdbcType="VARCHAR" />
<result column="monitor_type" property="monitorType" jdbcType="VARCHAR" />
<result column="threshold" property="threshold" jdbcType="DOUBLE" />
<result column="check_time" property="checkTime" jdbcType="VARCHAR" />
<result column="comment" property="comment" jdbcType="VARCHAR" />
</resultMap>
<sql id="Example_Where_Clause" >
<where >
<foreach collection="oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid" >
<trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion" >
<choose >
<when test="criterion.noValue" >
and ${criterion.condition}
</when>
<when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue" >
and ${criterion.condition}
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause" >
<where >
<foreach collection="example.oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid" >
<trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion" >
<choose >
<when test="criterion.noValue" >
and ${criterion.condition}
</when>
<when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue" >
and ${criterion.condition}
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List" >
id, db_name, tb_name, col_name, indicator_type, monitor_type, threshold, check_time,
comment
</sql>
<select id="selectByExample" resultMap="BaseResultMap" parameterType="com.gmei.data.dqmp.domain.TblMonitorVolatilityRuleCriteria" >
select
<if test="distinct" >
distinct
</if>
<include refid="Base_Column_List" />
from tbl_monitor_volatility_rule
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null" >
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from tbl_monitor_volatility_rule
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from tbl_monitor_volatility_rule
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.gmei.data.dqmp.domain.TblMonitorVolatilityRuleCriteria" >
delete from tbl_monitor_volatility_rule
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.gmei.data.dqmp.domain.TblMonitorVolatilityRule" >
insert into tbl_monitor_volatility_rule (id, db_name, tb_name,
col_name, indicator_type, monitor_type,
threshold, check_time, comment
)
values (#{id,jdbcType=INTEGER}, #{dbName,jdbcType=VARCHAR}, #{tbName,jdbcType=VARCHAR},
#{colName,jdbcType=VARCHAR}, #{indicatorType,jdbcType=VARCHAR}, #{monitorType,jdbcType=VARCHAR},
#{threshold,jdbcType=DOUBLE}, #{checkTime,jdbcType=VARCHAR}, #{comment,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.gmei.data.dqmp.domain.TblMonitorVolatilityRule" >
insert into tbl_monitor_volatility_rule
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="dbName != null" >
db_name,
</if>
<if test="tbName != null" >
tb_name,
</if>
<if test="colName != null" >
col_name,
</if>
<if test="indicatorType != null" >
indicator_type,
</if>
<if test="monitorType != null" >
monitor_type,
</if>
<if test="threshold != null" >
threshold,
</if>
<if test="checkTime != null" >
check_time,
</if>
<if test="comment != null" >
comment,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="dbName != null" >
#{dbName,jdbcType=VARCHAR},
</if>
<if test="tbName != null" >
#{tbName,jdbcType=VARCHAR},
</if>
<if test="colName != null" >
#{colName,jdbcType=VARCHAR},
</if>
<if test="indicatorType != null" >
#{indicatorType,jdbcType=VARCHAR},
</if>
<if test="monitorType != null" >
#{monitorType,jdbcType=VARCHAR},
</if>
<if test="threshold != null" >
#{threshold,jdbcType=DOUBLE},
</if>
<if test="checkTime != null" >
#{checkTime,jdbcType=VARCHAR},
</if>
<if test="comment != null" >
#{comment,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.gmei.data.dqmp.domain.TblMonitorVolatilityRuleCriteria" resultType="java.lang.Integer" >
select count(*) from tbl_monitor_volatility_rule
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map" >
update tbl_monitor_volatility_rule
<set >
<if test="record.id != null" >
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.dbName != null" >
db_name = #{record.dbName,jdbcType=VARCHAR},
</if>
<if test="record.tbName != null" >
tb_name = #{record.tbName,jdbcType=VARCHAR},
</if>
<if test="record.colName != null" >
col_name = #{record.colName,jdbcType=VARCHAR},
</if>
<if test="record.indicatorType != null" >
indicator_type = #{record.indicatorType,jdbcType=VARCHAR},
</if>
<if test="record.monitorType != null" >
monitor_type = #{record.monitorType,jdbcType=VARCHAR},
</if>
<if test="record.threshold != null" >
threshold = #{record.threshold,jdbcType=DOUBLE},
</if>
<if test="record.checkTime != null" >
check_time = #{record.checkTime,jdbcType=VARCHAR},
</if>
<if test="record.comment != null" >
comment = #{record.comment,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map" >
update tbl_monitor_volatility_rule
set id = #{record.id,jdbcType=INTEGER},
db_name = #{record.dbName,jdbcType=VARCHAR},
tb_name = #{record.tbName,jdbcType=VARCHAR},
col_name = #{record.colName,jdbcType=VARCHAR},
indicator_type = #{record.indicatorType,jdbcType=VARCHAR},
monitor_type = #{record.monitorType,jdbcType=VARCHAR},
threshold = #{record.threshold,jdbcType=DOUBLE},
check_time = #{record.checkTime,jdbcType=VARCHAR},
comment = #{record.comment,jdbcType=VARCHAR}
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.gmei.data.dqmp.domain.TblMonitorVolatilityRule" >
update tbl_monitor_volatility_rule
<set >
<if test="dbName != null" >
db_name = #{dbName,jdbcType=VARCHAR},
</if>
<if test="tbName != null" >
tb_name = #{tbName,jdbcType=VARCHAR},
</if>
<if test="colName != null" >
col_name = #{colName,jdbcType=VARCHAR},
</if>
<if test="indicatorType != null" >
indicator_type = #{indicatorType,jdbcType=VARCHAR},
</if>
<if test="monitorType != null" >
monitor_type = #{monitorType,jdbcType=VARCHAR},
</if>
<if test="threshold != null" >
threshold = #{threshold,jdbcType=DOUBLE},
</if>
<if test="checkTime != null" >
check_time = #{checkTime,jdbcType=VARCHAR},
</if>
<if test="comment != null" >
comment = #{comment,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.gmei.data.dqmp.domain.TblMonitorVolatilityRule" >
update tbl_monitor_volatility_rule
set db_name = #{dbName,jdbcType=VARCHAR},
tb_name = #{tbName,jdbcType=VARCHAR},
col_name = #{colName,jdbcType=VARCHAR},
indicator_type = #{indicatorType,jdbcType=VARCHAR},
monitor_type = #{monitorType,jdbcType=VARCHAR},
threshold = #{threshold,jdbcType=DOUBLE},
check_time = #{checkTime,jdbcType=VARCHAR},
comment = #{comment,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
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