Commit 8a57f4b4 authored by 赵建伟's avatar 赵建伟

add rule analysis、insert、struct codes

parent 56b3294d
......@@ -40,6 +40,10 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!-- 集成mysql驱动 -->
<dependency>
<groupId>mysql</groupId>
......@@ -216,7 +220,7 @@
</executions>
</plugin>
<!--集成mybatis自动生成工具 -->
<!-- <plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
......@@ -240,7 +244,7 @@
<version>1.3.2</version>
</dependency>
</dependencies>
</plugin> -->
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
......@@ -26,4 +26,19 @@ public class Constants {
// 无效
public static final Integer IS_VALID_OFF = 0;
// ***************校验规则映射******************
// 校验规则映射
public static final String CHECK_RULE_MAPPING = "check_rule_mapping";
// ***************规则类型映射******************
// 单表规则类型
public static final String TABLE_SIMPLE = "simple";
// 双表规则类型
public static final String TABLE_DUPLEX = "duplex";
// public static final String CHECK_SIMPLE = "check_single";
// public static final String CHECK_MULTIPLE = "check_multiple";
// public static final String MONITOR_VOLATILITY = "monitor_volatility";
// public static final String MONITOR_SPECIAL = "monitor_special";
}
package com.gmei.data.dqmp.controller;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.gmei.data.dqmp.service.DqRuleService;
import com.gmei.data.dqmp.vo.DqRuleVo;
@RestController
@RequestMapping(value = "/dqrule")
public class DqRuleController {
@Autowired
private DqRuleService dqRuleService;
/**
* 校验规则新增
* @param dqRuleVo
* @param bindingResult
* @return
*/
@ResponseBody
@RequestMapping(value = "/add", method = RequestMethod.POST)
public DqRuleVo addDqRule(@RequestBody @Valid DqRuleVo dqRuleVo,BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return new DqRuleVo(-1,bindingResult.getFieldError().getDefaultMessage());
}
Boolean isAddSuc = dqRuleService.addDqRule(dqRuleVo);
if(isAddSuc) {
return new DqRuleVo();
}else {
return new DqRuleVo(-1,"Rule add error!");
}
}
}
package com.gmei.data.dqmp.domain;
public class TblSysParamInfo {
private Integer id;
private String paramType;
private String paramKey;
private String paramValue;
private String comment;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getParamType() {
return paramType;
}
public void setParamType(String paramType) {
this.paramType = paramType == null ? null : paramType.trim();
}
public String getParamKey() {
return paramKey;
}
public void setParamKey(String paramKey) {
this.paramKey = paramKey == null ? null : paramKey.trim();
}
public String getParamValue() {
return paramValue;
}
public void setParamValue(String paramValue) {
this.paramValue = paramValue == null ? null : paramValue.trim();
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment == null ? null : comment.trim();
}
}
\ No newline at end of file
package com.gmei.data.dqmp.mapper;
import com.gmei.data.dqmp.domain.TblSysParamInfo;
import com.gmei.data.dqmp.domain.TblSysParamInfoCriteria;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TblSysParamInfoMapper {
int countByExample(TblSysParamInfoCriteria example);
int deleteByExample(TblSysParamInfoCriteria example);
int deleteByPrimaryKey(Integer id);
int insert(TblSysParamInfo record);
int insertSelective(TblSysParamInfo record);
List<TblSysParamInfo> selectByExample(TblSysParamInfoCriteria example);
TblSysParamInfo selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") TblSysParamInfo record, @Param("example") TblSysParamInfoCriteria example);
int updateByExample(@Param("record") TblSysParamInfo record, @Param("example") TblSysParamInfoCriteria example);
int updateByPrimaryKeySelective(TblSysParamInfo record);
int updateByPrimaryKey(TblSysParamInfo record);
}
\ No newline at end of file
......@@ -16,28 +16,28 @@ public class DqScheduler {
@Autowired
private MonitorService monitorService;
@Scheduled(cron="0 */100 * * * ?")
private void uniqueCheckProcess(){
executeService.checkAndPersistSimpleResult(Constants.CHECK_UNIQUE);
}
@Scheduled(cron="10 */100 * * * ?")
private void unblankCheckProcess(){
executeService.checkAndPersistSimpleResult(Constants.CHECK_UNBLANK);
}
@Scheduled(cron="0 */100 * * * ?")
private void referCheckProcess(){
executeService.checkAndPersistMultipleResult(Constants.CHECK_REFER);
}
@Scheduled(cron="0 */100 * * * ?")
private void volatilityMonitorProcess(){
monitorService.monitorAndPersistVolatilityResult(Constants.MONITOR_PV);
}
@Scheduled(cron="0 */1 * * * ?")
private void specialMonitorProcess(){
monitorService.monitorAndPersistSpecialResult();
}
// @Scheduled(cron="0 */100 * * * ?")
// private void uniqueCheckProcess(){
// executeService.checkAndPersistSimpleResult(Constants.CHECK_UNIQUE);
// }
//
// @Scheduled(cron="10 */100 * * * ?")
// private void unblankCheckProcess(){
// executeService.checkAndPersistSimpleResult(Constants.CHECK_UNBLANK);
// }
//
// @Scheduled(cron="0 */100 * * * ?")
// private void referCheckProcess(){
// executeService.checkAndPersistMultipleResult(Constants.CHECK_REFER);
// }
//
// @Scheduled(cron="0 */100 * * * ?")
// private void volatilityMonitorProcess(){
// monitorService.monitorAndPersistVolatilityResult(Constants.MONITOR_PV);
// }
//
// @Scheduled(cron="0 */100 * * * ?")
// private void specialMonitorProcess(){
// monitorService.monitorAndPersistSpecialResult();
// }
}
package com.gmei.data.dqmp.service;
import com.gmei.data.dqmp.vo.DqRuleVo;
public interface DqRuleService {
Boolean addDqRule(DqRuleVo dqRuleVo);
}
package com.gmei.data.dqmp.service;
import java.util.Map;
public interface TblSysParamInfoService {
Map<String,String> getSysParamMap(String paramType);
}
......@@ -26,6 +26,7 @@ import com.gmei.data.dqmp.mapper.TblResultCheckUnblankMapper;
import com.gmei.data.dqmp.mapper.TblResultCheckUniqueMapper;
import com.gmei.data.dqmp.pool.JdbcConnectPool;
import com.gmei.data.dqmp.service.CheckService;
import com.gmei.data.dqmp.utils.DateUtils;
@Service
public class CheckServiceImpl implements CheckService {
......@@ -116,6 +117,7 @@ public class CheckServiceImpl implements CheckService {
* @return
*/
private TblResultCheckUnique getUniqueCheckResult(String sql) {
sql = sql.replaceAll("#partation_date", String.format("'%s'", DateUtils.getYesterdayDateStr()));
logger.info("Sql content : {}", sql);
TblResultCheckUnique tblResultCheckUnique = null;
if (StringUtils.isBlank(sql)) {
......@@ -151,6 +153,7 @@ public class CheckServiceImpl implements CheckService {
* @return
*/
private TblResultCheckUnblank getUnblankCheckResult(String sql) {
sql = sql.replaceAll("#partation_date", String.format("'%s'", DateUtils.getYesterdayDateStr()));
logger.info("Sql content : {}", sql);
TblResultCheckUnblank tblResultCheckUnblank = null;
if (StringUtils.isBlank(sql)) {
......@@ -186,6 +189,7 @@ public class CheckServiceImpl implements CheckService {
* @return
*/
private TblResultCheckRefer getReferCheckResult(String sql) {
sql = sql.replaceAll("#partation_date", String.format("'%s'", DateUtils.getYesterdayDateStr()));
logger.info("Sql content : {}", sql);
TblResultCheckRefer tblResultCheckRefer = null;
if (StringUtils.isBlank(sql)) {
......@@ -217,4 +221,7 @@ public class CheckServiceImpl implements CheckService {
}
return tblResultCheckRefer;
}
public static void main(String[] args) {
}
}
package com.gmei.data.dqmp.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.gmei.data.dqmp.common.Constants;
import com.gmei.data.dqmp.domain.TblCheckMultipleSql;
import com.gmei.data.dqmp.domain.TblCheckSingleSql;
import com.gmei.data.dqmp.domain.TblIndicatorOperatorInfo;
import com.gmei.data.dqmp.domain.TblIndicatorOperatorInfoCriteria;
import com.gmei.data.dqmp.domain.TblMonitorSpecialSql;
import com.gmei.data.dqmp.domain.TblMonitorVolatilitySql;
import com.gmei.data.dqmp.domain.TblRuleDuplexInfoWithBLOBs;
import com.gmei.data.dqmp.domain.TblRuleSimpleInfo;
import com.gmei.data.dqmp.domain.TblRuleTemplate;
import com.gmei.data.dqmp.domain.TblRuleTemplateCriteria;
import com.gmei.data.dqmp.mapper.TblCheckMultipleSqlMapper;
import com.gmei.data.dqmp.mapper.TblCheckSingleSqlMapper;
import com.gmei.data.dqmp.mapper.TblIndicatorOperatorInfoMapper;
import com.gmei.data.dqmp.mapper.TblMonitorSpecialSqlMapper;
import com.gmei.data.dqmp.mapper.TblMonitorVolatilitySqlMapper;
import com.gmei.data.dqmp.mapper.TblRuleDuplexInfoMapper;
import com.gmei.data.dqmp.mapper.TblRuleSimpleInfoMapper;
import com.gmei.data.dqmp.mapper.TblRuleTemplateMapper;
import com.gmei.data.dqmp.service.DqRuleService;
import com.gmei.data.dqmp.utils.BeanUtils;
import com.gmei.data.dqmp.utils.DateUtils;
import com.gmei.data.dqmp.vo.DqRuleVo;
@Service
public class DqRuleServiceImpl implements DqRuleService {
@Autowired
private TblRuleSimpleInfoMapper tblRuleSimpleInfoMapper;
@Autowired
private TblRuleDuplexInfoMapper tblRuleDuplexInfoMapper;
@Autowired
private TblCheckSingleSqlMapper tblCheckSingleSqlMapper;
@Autowired
private TblCheckMultipleSqlMapper tblCheckMultipleSqlMapper;
@Autowired
private TblMonitorVolatilitySqlMapper tblMonitorVolatilitySqlMapper;
@Autowired
private TblMonitorSpecialSqlMapper tblMonitorSpecialSqlMapper;
@Autowired
private TblRuleTemplateMapper tblRuleTemplateMapper;
@Autowired
private TblIndicatorOperatorInfoMapper tblIndicatorOperatorInfoMapper;
private static final Logger logger = LoggerFactory.getLogger(DqRuleServiceImpl.class);
@Override
@Transactional
public Boolean addDqRule(DqRuleVo dqRuleVo) {
Boolean rs = false;
String checkType = dqRuleVo.getCheckType();
if (Constants.CHECK_UNIQUE.equals(checkType) || Constants.CHECK_UNBLANK.equals(checkType)
|| Constants.CHECK_VOLATILITY.equals(checkType) || Constants.CHECK_SPECIAL.equals(checkType)) {
rs = simpleRuleInfoInsert(dqRuleVo);
} else if (Constants.CHECK_REFER.equals(checkType)) {
rs = duplexRuleInfoInsert(dqRuleVo);
} else {
logger.error("checkType is illegal! {}", checkType);
return rs;
}
return rs;
}
/**
* 简单校验规则新增
* @param dqRuleVo
* @return
*/
private Boolean simpleRuleInfoInsert(DqRuleVo dqRuleVo) {
if(!simpleRuleInfoCheck(dqRuleVo)) {
logger.error("Param is illegal! {}",dqRuleVo);
return false;
}
TblRuleSimpleInfo record = BeanUtils.map(dqRuleVo, TblRuleSimpleInfo.class);
int rs = tblRuleSimpleInfoMapper.insertSelective(record);
if (rs == 1) {
String checkType = dqRuleVo.getCheckType();
switch (checkType) {
case Constants.CHECK_UNIQUE:
TblCheckSingleSql tblCheckSingleSql = BeanUtils.map(dqRuleVo, TblCheckSingleSql.class);
tblCheckSingleSql.setSqlContent(genSqlByTemplate(dqRuleVo));
tblCheckSingleSqlMapper.insertSelective(tblCheckSingleSql);
break;
case Constants.CHECK_UNBLANK:
TblCheckSingleSql tcss = BeanUtils.map(dqRuleVo, TblCheckSingleSql.class);
tcss.setSqlContent(genSqlByTemplate(dqRuleVo));
tblCheckSingleSqlMapper.insertSelective(tcss);
break;
case Constants.CHECK_VOLATILITY:
if(!volatilityRuleParamsCheck(dqRuleVo)) {
logger.error("Param is illegal! {}",dqRuleVo);
return false;
}
TblMonitorVolatilitySql tblMonitorVolatilitySql = BeanUtils.map(dqRuleVo,
TblMonitorVolatilitySql.class);
tblMonitorVolatilitySql.setSqlContent(genSqlByTemplate(dqRuleVo));
tblMonitorVolatilitySqlMapper.insertSelective(tblMonitorVolatilitySql);
break;
case Constants.CHECK_SPECIAL:
if(!specialRuleParamsCheck(dqRuleVo)) {
logger.error("Param is illegal! {}",dqRuleVo);
return false;
}
TblMonitorSpecialSql tblMonitorSpecialSql = BeanUtils.map(dqRuleVo, TblMonitorSpecialSql.class);
tblMonitorSpecialSql.setSqlContent(genSqlByTemplate(dqRuleVo));
tblMonitorSpecialSqlMapper.insertSelective(tblMonitorSpecialSql);
break;
default:
logger.error("checkType value is error! {}", checkType);
return false;
}
}
return true;
}
/**
* 双表校验规则录入
* @param dqRuleVo
* @return
*/
private Boolean duplexRuleInfoInsert(DqRuleVo dqRuleVo) {
if(!duplexRuleInfoCheck(dqRuleVo)) {
logger.error("Param is illegal! {}",dqRuleVo);
return false;
}
TblRuleDuplexInfoWithBLOBs record = BeanUtils.map(dqRuleVo, TblRuleDuplexInfoWithBLOBs.class);
int rs = tblRuleDuplexInfoMapper.insertSelective(record);
if (rs == 1) {
String checkType = dqRuleVo.getCheckType();
if (Constants.CHECK_REFER.equals(checkType)) {
TblCheckMultipleSql tblCheckMultipleSql = BeanUtils.map(dqRuleVo, TblCheckMultipleSql.class);
String sqlContent = genSqlByTemplate(dqRuleVo);
tblCheckMultipleSql.setSqlContent(sqlContent);
tblCheckMultipleSqlMapper.insertSelective(tblCheckMultipleSql);
} else {
logger.error("checkType value is error! {}", checkType);
return false;
}
}
return true;
}
private boolean simpleRuleInfoCheck(DqRuleVo dqRuleVo) {
if(StringUtils.isBlank(dqRuleVo.getDbName()) || StringUtils.isBlank(dqRuleVo.getTbName())
//|| StringUtils.isBlank(dqRuleVo.getFilters())
) {
return false;
}
if(Constants.CHECK_SPECIAL.equals(dqRuleVo.getCheckType())){
if(StringUtils.isBlank(dqRuleVo.getTimeColName())) {
return false;
}
}else {
if(StringUtils.isBlank(dqRuleVo.getColName())) {
return false;
}
}
return true;
}
private boolean volatilityRuleParamsCheck(DqRuleVo dqRuleVo) {
if(StringUtils.isBlank(dqRuleVo.getIndicatorType())) {
return false;
}
return true;
}
private boolean specialRuleParamsCheck(DqRuleVo dqRuleVo) {
if(StringUtils.isBlank(dqRuleVo.getTimeColName()) || StringUtils.isBlank(dqRuleVo.getStartTime())
//|| StringUtils.isBlank(dqRuleVo.getEndTime())
) {
return false;
}
return true;
}
private boolean duplexRuleInfoCheck(DqRuleVo dqRuleVo) {
if(StringUtils.isBlank(dqRuleVo.getCheckDbName()) || StringUtils.isBlank(dqRuleVo.getCheckTbName())
|| StringUtils.isBlank(dqRuleVo.getCheckColName()) || StringUtils.isBlank(dqRuleVo.getReferColName())
|| StringUtils.isBlank(dqRuleVo.getReferDbName()) || StringUtils.isBlank(dqRuleVo.getReferTbName())
//|| StringUtils.isBlank(dqRuleVo.getCheckFilters()) || StringUtils.isBlank(dqRuleVo.getReferfilters())
) {
return false;
}
return true;
}
private String genSqlByTemplate(DqRuleVo dqRuleVo) {
TblRuleTemplateCriteria example = new TblRuleTemplateCriteria();
example.createCriteria().andCheckTypeEqualTo(dqRuleVo.getCheckType());
TblRuleTemplate tblRuleTemplate = tblRuleTemplateMapper.selectByExampleWithBLOBs(example).get(0);
String tpltContent = tblRuleTemplate.getTpltContent();
Map<String,String> indicatorMap = new HashMap<String, String>();
TblIndicatorOperatorInfoCriteria tblIndicatorOperatorInfoCriteria = new TblIndicatorOperatorInfoCriteria();
List<TblIndicatorOperatorInfo> tblIndicatorOperatorInfos = tblIndicatorOperatorInfoMapper.selectByExample(tblIndicatorOperatorInfoCriteria);
for(TblIndicatorOperatorInfo tblIndicatorOperatorInfo : tblIndicatorOperatorInfos) {
indicatorMap.put(tblIndicatorOperatorInfo.getIndicatorName(), tblIndicatorOperatorInfo.getOperatorExpr());
}
String indicatorType = dqRuleVo.getIndicatorType();
String rs = tpltContent
.replaceAll("#db_name", dqRuleVo.getDbName())
.replaceAll("#tb_name", dqRuleVo.getTbName())
.replaceAll("#indicator_type", indicatorType)
.replaceAll("#indicator_expre", indicatorMap.get(indicatorType))
.replaceAll("#col_name", dqRuleVo.getColName())
.replaceAll("#start_time", "'"+dqRuleVo.getStartTime()+"'")
.replaceAll("#end_time", "'"+DateUtils.getTodayZeroTimeStr()+"'")
.replaceAll("#check_db_name", dqRuleVo.getCheckDbName())
.replaceAll("#check_tb_name", dqRuleVo.getCheckTbName())
.replaceAll("#check_col_name", dqRuleVo.getCheckColName())
.replaceAll("#refer_db_name", dqRuleVo.getReferDbName())
.replaceAll("#refer_tb_name", dqRuleVo.getReferTbName())
.replaceAll("#refer_col_name", dqRuleVo.getReferColName())
.replaceAll("#time_col_name", dqRuleVo.getTimeColName());
if(null != dqRuleVo.getFilters()) {
rs = rs.replaceAll("#filters", dqRuleVo.getFilters());
}
if(null != dqRuleVo.getCheckFilters()) {
rs = rs.replaceAll("#check_filters", dqRuleVo.getCheckFilters());
}
if(null != dqRuleVo.getReferFilters()) {
rs = rs.replaceAll("#refer_filters", dqRuleVo.getReferFilters());
}
return rs;
}
}
......@@ -24,6 +24,7 @@ import com.gmei.data.dqmp.mapper.TblResultMonitorSpecialMapper;
import com.gmei.data.dqmp.mapper.TblResultMonitorVolatilityMapper;
import com.gmei.data.dqmp.pool.JdbcConnectPool;
import com.gmei.data.dqmp.service.MonitorService;
import com.gmei.data.dqmp.utils.DateUtils;
@Service
public class MonitorServiceImpl implements MonitorService {
......@@ -101,6 +102,7 @@ public class MonitorServiceImpl implements MonitorService {
* @return
*/
private TblResultMonitorVolatility getMonitorVolatilityResult(String sql, String indicatorType) {
sql = sql.replaceAll("#partation_date", String.format("'%s'", DateUtils.getYesterdayDateStr()));
logger.info("Sql content : {},indicatorType: {}", sql, indicatorType);
TblResultMonitorVolatility tblResultMonitorVolatility = null;
if (StringUtils.isBlank(sql) || StringUtils.isBlank(indicatorType)) {
......@@ -136,6 +138,7 @@ public class MonitorServiceImpl implements MonitorService {
* @return
*/
private TblResultMonitorSpecial getMonitorSpecialResult(String sql) {
sql = sql.replaceAll("#partation_date", String.format("'%s'", DateUtils.getYesterdayDateStr()));
logger.info("Sql content : {}", sql);
TblResultMonitorSpecial tblResultMonitorSpecial = null;
if (StringUtils.isBlank(sql)) {
......
package com.gmei.data.dqmp.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import com.gmei.data.dqmp.domain.TblSysParamInfo;
import com.gmei.data.dqmp.domain.TblSysParamInfoCriteria;
import com.gmei.data.dqmp.mapper.TblSysParamInfoMapper;
import com.gmei.data.dqmp.service.TblSysParamInfoService;
public class TblSysParamInfoServiceImpl implements TblSysParamInfoService {
@Autowired
private TblSysParamInfoMapper tblSysParamInfoMapper;
@Override
public Map<String,String> getSysParamMap(String paramType){
Map<String,String> rsMap = new HashMap<String, String>();
TblSysParamInfoCriteria example = new TblSysParamInfoCriteria();
example.createCriteria().andParamTypeEqualTo(paramType);
List<TblSysParamInfo> rsList = tblSysParamInfoMapper.selectByExample(example);
for(TblSysParamInfo tblSysParamInfo : rsList) {
rsMap.put(tblSysParamInfo.getParamKey(), tblSysParamInfo.getParamValue());
}
return rsMap;
}
}
package com.gmei.data.dqmp.utils;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class DateUtils {
private static final String DATE_FORMATE_YMD = "yyyy-MM-dd";
private static final String PARTITION_DATE_FORMAT = "yyyyMMdd";
private static final String DATE_FORMATE_YMDHMS = "yyyy-MM-dd HH:mm:ss";
private static final String DATE_FORMATE_YMDHMSS = "yyyy-MM-dd HH:mm:ss.S";
/**
* 获取当前时间字符串
......@@ -23,4 +26,33 @@ public class DateUtils {
public static String getCurrentTimeStr() {
return new SimpleDateFormat(DATE_FORMATE_YMDHMS).format(new Date());
}
/**
* 获取昨天时间字符串
* @return
*/
public static String getYesterdayDateStr() {
Calendar cld = Calendar.getInstance();
cld.setTime(new Date());
cld.add(Calendar.DAY_OF_MONTH, -1);
return new SimpleDateFormat(PARTITION_DATE_FORMAT).format(cld.getTime());
}
/**
* 获取今天0时0分0秒0毫秒时间字符串
* @return
*/
public static String getTodayZeroTimeStr() {
Calendar cld = Calendar.getInstance();
cld.setTime(new Date());
cld.set(Calendar.HOUR_OF_DAY, 0);
cld.set(Calendar.MINUTE, 0);
cld.set(Calendar.SECOND, 0);
cld.set(Calendar.MILLISECOND, 0);
return new SimpleDateFormat(DATE_FORMATE_YMDHMSS).format(cld.getTime());
}
public static void main(String[] args) {
System.out.println(getTodayZeroTimeStr());
}
}
package com.gmei.data.dqmp.vo;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.NotBlank;
public class DqRuleVo extends BaseVo{
//common
@NotBlank(message = "校验类型字段不能为空")
private String checkType;
@NotNull(message = "状态字段不能为NULL")
private Integer isValid;
@NotBlank(message = "校验时间字段不能为空")
private String checkTime;
//simple
private String dbName;
private String tbName;
private String colName;
private String timeColName;
private String filters;
private String indicatorType;
private String startTime;
//private String endTime;
//duplex
private String checkDbName;
private String checkTbName;
private String checkColName;
private String referDbName;
private String referTbName;
private String referColName;
private String checkFilters;
private String referFilters;
public DqRuleVo() {
super();
}
public DqRuleVo(Integer status,String msg) {
super(status,msg);
}
public Integer getIsValid() {
return isValid;
}
public void setIsValid(Integer isValid) {
this.isValid = isValid;
}
public String getCheckTime() {
return checkTime;
}
public void setCheckTime(String checkTime) {
this.checkTime = checkTime;
}
public String getCheckType() {
return checkType;
}
public void setCheckType(String checkType) {
this.checkType = checkType;
}
public String getDbName() {
return dbName;
}
public void setDbName(String dbName) {
this.dbName = dbName;
}
public String getTbName() {
return tbName;
}
public void setTbName(String tbName) {
this.tbName = tbName;
}
public String getColName() {
return colName;
}
public void setColName(String colName) {
this.colName = colName;
}
public String getTimeColName() {
return timeColName;
}
public void setTimeColName(String timeColName) {
this.timeColName = timeColName;
}
public String getFilters() {
return filters;
}
public void setFilters(String filters) {
this.filters = filters;
}
public String getIndicatorType() {
return indicatorType;
}
public void setIndicatorType(String indicatorType) {
this.indicatorType = indicatorType;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
// public String getEndTime() {
// return endTime;
// }
// public void setEndTime(String endTime) {
// this.endTime = endTime;
// }
public String getCheckDbName() {
return checkDbName;
}
public void setCheckDbName(String checkDbName) {
this.checkDbName = checkDbName;
}
public String getCheckTbName() {
return checkTbName;
}
public void setCheckTbName(String checkTbName) {
this.checkTbName = checkTbName;
}
public String getCheckColName() {
return checkColName;
}
public void setCheckColName(String checkColName) {
this.checkColName = checkColName;
}
public String getReferDbName() {
return referDbName;
}
public void setReferDbName(String referDbName) {
this.referDbName = referDbName;
}
public String getReferTbName() {
return referTbName;
}
public void setReferTbName(String referTbName) {
this.referTbName = referTbName;
}
public String getReferColName() {
return referColName;
}
public void setReferColName(String referColName) {
this.referColName = referColName;
}
public String getCheckFilters() {
return checkFilters;
}
public void setCheckFilters(String checkFilters) {
this.checkFilters = checkFilters;
}
public String getReferFilters() {
return referFilters;
}
public void setReferFilters(String referFilters) {
this.referFilters = referFilters;
}
@Override
public String toString() {
return "DqRuleVo [checkType=" + checkType + ", isValid=" + isValid + ", checkTime=" + checkTime + ", dbName="
+ dbName + ", tbName=" + tbName + ", colName=" + colName + ", timeColName=" + timeColName + ", filters="
+ filters + ", indicatorType=" + indicatorType + ", startTime=" + startTime + ", checkDbName="
+ checkDbName + ", checkTbName=" + checkTbName + ", checkColName=" + checkColName + ", referDbName="
+ referDbName + ", referTbName=" + referTbName + ", referColName=" + referColName + ", checkFilters="
+ checkFilters + ", referfilters=" + referFilters + "]";
}
}
......@@ -46,7 +46,8 @@
<!-- <table tableName="tbl_result_monitor_special" domainObjectName="TblResultMonitorSpecial"/> -->
<!-- <table tableName="tbl_indicator_operator_info" domainObjectName="TblIndicatorOperatorInfo"/> -->
<!-- <table tableName="tbl_rule_template" domainObjectName="TblRuleTemplate"/> -->
<table tableName="tbl_rule_simple_info" domainObjectName="TblRuleSimpleInfo"/>
<table tableName="tbl_rule_duplex_info" domainObjectName="TblRuleDuplexInfo"/>
<!-- <table tableName="tbl_rule_simple_info" domainObjectName="TblRuleSimpleInfo"/> -->
<!-- <table tableName="tbl_rule_duplex_info" domainObjectName="TblRuleDuplexInfo"/> -->
<table tableName="tbl_sys_param_info" domainObjectName="TblSysParamInfo"/>
</context>
</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.TblSysParamInfoMapper" >
<resultMap id="BaseResultMap" type="com.gmei.data.dqmp.domain.TblSysParamInfo" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="param_type" property="paramType" jdbcType="VARCHAR" />
<result column="param_key" property="paramKey" jdbcType="VARCHAR" />
<result column="param_value" property="paramValue" 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, param_type, param_key, param_value, comment
</sql>
<select id="selectByExample" resultMap="BaseResultMap" parameterType="com.gmei.data.dqmp.domain.TblSysParamInfoCriteria" >
select
<if test="distinct" >
distinct
</if>
<include refid="Base_Column_List" />
from tbl_sys_param_info
<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_sys_param_info
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from tbl_sys_param_info
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.gmei.data.dqmp.domain.TblSysParamInfoCriteria" >
delete from tbl_sys_param_info
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.gmei.data.dqmp.domain.TblSysParamInfo" >
insert into tbl_sys_param_info (id, param_type, param_key,
param_value, comment)
values (#{id,jdbcType=INTEGER}, #{paramType,jdbcType=VARCHAR}, #{paramKey,jdbcType=VARCHAR},
#{paramValue,jdbcType=VARCHAR}, #{comment,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.gmei.data.dqmp.domain.TblSysParamInfo" >
insert into tbl_sys_param_info
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="paramType != null" >
param_type,
</if>
<if test="paramKey != null" >
param_key,
</if>
<if test="paramValue != null" >
param_value,
</if>
<if test="comment != null" >
comment,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="paramType != null" >
#{paramType,jdbcType=VARCHAR},
</if>
<if test="paramKey != null" >
#{paramKey,jdbcType=VARCHAR},
</if>
<if test="paramValue != null" >
#{paramValue,jdbcType=VARCHAR},
</if>
<if test="comment != null" >
#{comment,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.gmei.data.dqmp.domain.TblSysParamInfoCriteria" resultType="java.lang.Integer" >
select count(*) from tbl_sys_param_info
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map" >
update tbl_sys_param_info
<set >
<if test="record.id != null" >
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.paramType != null" >
param_type = #{record.paramType,jdbcType=VARCHAR},
</if>
<if test="record.paramKey != null" >
param_key = #{record.paramKey,jdbcType=VARCHAR},
</if>
<if test="record.paramValue != null" >
param_value = #{record.paramValue,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_sys_param_info
set id = #{record.id,jdbcType=INTEGER},
param_type = #{record.paramType,jdbcType=VARCHAR},
param_key = #{record.paramKey,jdbcType=VARCHAR},
param_value = #{record.paramValue,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.TblSysParamInfo" >
update tbl_sys_param_info
<set >
<if test="paramType != null" >
param_type = #{paramType,jdbcType=VARCHAR},
</if>
<if test="paramKey != null" >
param_key = #{paramKey,jdbcType=VARCHAR},
</if>
<if test="paramValue != null" >
param_value = #{paramValue,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.TblSysParamInfo" >
update tbl_sys_param_info
set param_type = #{paramType,jdbcType=VARCHAR},
param_key = #{paramKey,jdbcType=VARCHAR},
param_value = #{paramValue,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