1:删除无用的数据库连接
2:修改pom中使用的hive版本为2.1.1 3:添加IP地址日志查询服务
This commit is contained in:
@@ -40,6 +40,7 @@ public abstract class BaseLogService {
|
||||
protected final Logger logger = Logger.getLogger(this.getClass());
|
||||
@Autowired
|
||||
protected ElasticsearchSqlDao elasticsearchSqlDao;
|
||||
|
||||
/**
|
||||
* wx checkCloumnIsExist(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选)
|
||||
*
|
||||
@@ -126,34 +127,58 @@ public abstract class BaseLogService {
|
||||
}
|
||||
}
|
||||
|
||||
public void queryConditionCheck(SaveRequestLogThread thread,long start,LogEntity<?> entity,Class clazz,Page page) {
|
||||
logger.info("请求参数校验开始----"+System.currentTimeMillis());
|
||||
/**
|
||||
* 验证日志查询条件格式是否正确
|
||||
* @param thread
|
||||
* @param start
|
||||
* @param entity
|
||||
* @param clazz
|
||||
* @param page
|
||||
*/
|
||||
public void queryConditionCheck(SaveRequestLogThread thread, long start, LogEntity<?> entity, Class clazz,
|
||||
Page page) {
|
||||
logger.info("请求参数校验开始----" + System.currentTimeMillis());
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchCfgId())) {
|
||||
Long.parseLong(entity.getSearchCfgId());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchCfgId参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchCfgId参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchDirection())) {
|
||||
Integer.parseInt(entity.getSearchDirection());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "getSearchDirection参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "getSearchDirection参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchEntranceId())) {
|
||||
Long.parseLong(entity.getSearchEntranceId());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchEntranceId参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchEntranceId参数错误");
|
||||
}
|
||||
@@ -163,12 +188,12 @@ public abstract class BaseLogService {
|
||||
sdf.parse(entity.getSearchFoundEndTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchFoundEndTime参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchFoundEndTime参数格式格式");
|
||||
}
|
||||
@@ -178,41 +203,41 @@ public abstract class BaseLogService {
|
||||
sdf.parse(entity.getSearchFoundStartTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchFoundStartTime参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchFoundStartTime参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchServiceType())) {
|
||||
Integer.parseInt(entity.getSearchServiceType());
|
||||
if (!StringUtil.isBlank(entity.getSearchService())) {
|
||||
Integer.parseInt(entity.getSearchService());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchServiceType参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchServiceType参数错误");
|
||||
}
|
||||
try {
|
||||
checkCloumnIsExist(thread,start,clazz, page);
|
||||
checkCloumnIsExist(thread, start, clazz, page);
|
||||
} catch (RestServiceException e) {
|
||||
logger.error(e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请求参数错误");
|
||||
}
|
||||
logger.info("请求参数校验结束----"+System.currentTimeMillis());
|
||||
logger.info("请求参数校验结束----" + System.currentTimeMillis());
|
||||
|
||||
}
|
||||
|
||||
@@ -232,12 +257,12 @@ public abstract class BaseLogService {
|
||||
sdf.parse(entity.getSearchStatStartTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchStatStartTime参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchStatStartTime参数格式错误");
|
||||
}
|
||||
@@ -247,12 +272,12 @@ public abstract class BaseLogService {
|
||||
sdf.parse(entity.getSearchStatEndTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchStatEndTime参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchStatEndTime参数错误");
|
||||
}
|
||||
@@ -261,30 +286,29 @@ public abstract class BaseLogService {
|
||||
Integer.parseInt(entity.getSearchService());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchService参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchService参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
checkCloumnIsExist(thread,start,clazz, page);
|
||||
checkCloumnIsExist(thread, start, clazz, page);
|
||||
} catch (RestServiceException e) {
|
||||
logger.error(e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请求参数错误");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 管控实时统计公共查询字段验证
|
||||
*
|
||||
@@ -297,11 +321,11 @@ public abstract class BaseLogService {
|
||||
sdf.parse(entity.getSearchReportEndTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchReportEndTime参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchReportEndTime参数格式格式");
|
||||
}
|
||||
try {
|
||||
@@ -309,11 +333,11 @@ public abstract class BaseLogService {
|
||||
sdf.parse(entity.getSearchReportStartTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchReportStartTime参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchReportStartTime参数错误");
|
||||
}
|
||||
|
||||
@@ -322,11 +346,11 @@ public abstract class BaseLogService {
|
||||
Integer.parseInt(entity.getSearchService());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchService参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchService参数错误");
|
||||
}
|
||||
|
||||
@@ -336,12 +360,12 @@ public abstract class BaseLogService {
|
||||
Integer.parseInt(searchAttrType);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,start,"searchAttrType参数格式错误",
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, start, "searchAttrType参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,start,"searchAttrType参数错误");
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, start, "searchAttrType参数错误");
|
||||
}
|
||||
try {
|
||||
String searchLwhh = getSearchField(clazz, entity, "searchLwhh");
|
||||
@@ -349,21 +373,21 @@ public abstract class BaseLogService {
|
||||
Integer.parseInt(searchLwhh);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,start,"searchLwhh参数格式错误",
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, start, "searchLwhh参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,start,"searchLwhh参数错误");
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, start, "searchLwhh参数错误");
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
checkCloumnIsExist(thread,start,clazz, page);
|
||||
checkCloumnIsExist(thread, start, clazz, page);
|
||||
} catch (RestServiceException e) {
|
||||
logger.error(e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请求参数错误");
|
||||
}
|
||||
@@ -375,31 +399,32 @@ public abstract class BaseLogService {
|
||||
*
|
||||
* @param entity
|
||||
*/
|
||||
public void queryConditionCheck(SaveRequestLogThread thread, long start,DfReportEntity entity, Class clazz, Page page) {
|
||||
public void queryConditionCheck(SaveRequestLogThread thread, long start, DfReportEntity entity, Class clazz,
|
||||
Page page) {
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchReportEndTime())) {
|
||||
sdf.parse(entity.getSearchReportEndTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,start,"searchReportEndTime参数格式错误",
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, start, "searchReportEndTime参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,start,"searchReportEndTime参数格式格式");
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, start, "searchReportEndTime参数格式格式");
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchReportStartTime())) {
|
||||
sdf.parse(entity.getSearchReportStartTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,start,"searchReportStartTime参数格式错误",
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, start, "searchReportStartTime参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,start,"searchReportStartTime参数错误");
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, start, "searchReportStartTime参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -408,12 +433,12 @@ public abstract class BaseLogService {
|
||||
Integer.parseInt(searchAttrType);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,start,"searchAttrType参数格式错误",
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, start, "searchAttrType参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,start,"searchAttrType参数错误");
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, start, "searchAttrType参数错误");
|
||||
}
|
||||
try {
|
||||
String searchLwhh = getSearchField(clazz, entity, "searchLwhh");
|
||||
@@ -421,12 +446,12 @@ public abstract class BaseLogService {
|
||||
Integer.parseInt(searchLwhh);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,start,"searchLwhh参数格式错误",
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, start, "searchLwhh参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,start,"searchLwhh参数错误");
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, start, "searchLwhh参数错误");
|
||||
}
|
||||
try {
|
||||
String searchId = getSearchField(clazz, entity, "searchId");
|
||||
@@ -434,42 +459,41 @@ public abstract class BaseLogService {
|
||||
Integer.parseInt(searchId);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,start,"searchId参数格式错误",
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, start, "searchId参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,start,"searchId参数错误");
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, start, "searchId参数错误");
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
String searchService = getSearchField(clazz, entity, "searchService");
|
||||
if (!StringUtil.isBlank(searchService)) {
|
||||
Integer.parseInt(searchService);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,start,"searchService参数格式错误",
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, start, "searchService参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,start,"searchService参数错误");
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
throw new RestServiceException(thread, start, "searchService参数错误");
|
||||
}
|
||||
|
||||
|
||||
|
||||
try {
|
||||
checkCloumnIsExist(thread,start,clazz, page);
|
||||
checkCloumnIsExist(thread, start, clazz, page);
|
||||
} catch (RestServiceException e) {
|
||||
logger.error(e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread,start,"请求参数错误");
|
||||
throw new RestServiceException(thread, start, "请求参数错误");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @Title: getJedisKey
|
||||
@@ -510,7 +534,7 @@ public abstract class BaseLogService {
|
||||
String[] strArr = { "30" };
|
||||
parapeterMapNew.put("pageSize", strArr);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
if (parapeterMapNew.get("pageNo") != null) {
|
||||
parapeterMapNew.remove("pageNo");
|
||||
}
|
||||
@@ -538,8 +562,7 @@ public abstract class BaseLogService {
|
||||
return key;
|
||||
}
|
||||
|
||||
protected String getSearchField(Class<?> clazz,
|
||||
Serializable entity, String fieldName) {
|
||||
protected String getSearchField(Class<?> clazz, Serializable entity, String fieldName) {
|
||||
try {
|
||||
Field field = clazz.getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
|
||||
@@ -14,7 +14,8 @@ import java.util.Map;
|
||||
import org.apache.ibatis.mapping.ResultMap;
|
||||
import org.apache.ibatis.mapping.ResultMapping;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.util.Configurations;
|
||||
@@ -25,13 +26,12 @@ import com.nis.util.StringUtil;
|
||||
import com.nis.util.redis.SaveRedisThread;
|
||||
|
||||
public class HiveSqlService {
|
||||
private final static Logger logger = Logger.getLogger(HiveJDBC.class);
|
||||
private final static Logger logger = LoggerFactory.getLogger(HiveSqlService.class);
|
||||
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
public static ResultSet getResultSet(Page page, Object bean, String tableName,
|
||||
Map<String, Map<String, String>> col2col, String orderBy, String searchActiveSys) throws Exception {
|
||||
tableName = tableName.toLowerCase();
|
||||
tableName = Configurations.getStringProperty(tableName, "t_" + tableName).trim();
|
||||
String showColmun = getFiledsSql(bean.getClass().getSimpleName(), page.getFields());
|
||||
StringBuffer sql = new StringBuffer();
|
||||
Map<String, String> filedAndColumnMap = getFiledAndColumnMap(bean.getClass());
|
||||
@@ -59,8 +59,10 @@ public class HiveSqlService {
|
||||
Long foundTimePartStart = null;
|
||||
Long foundTimePartEnd = null;
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
// 现在gwall日志表结构中只有数值和字符串两种类型,数值都是int类型没有bigint所以不需要加L,
|
||||
Field f = fields[i];
|
||||
String key = f.getName();// 获取字段名
|
||||
String typeName = f.getType().getName();
|
||||
if (f.getType().getName().equals("java.lang.String") && key.startsWith("search")) {
|
||||
Object value = getFieldValue(bean, key);
|
||||
if (value != null) {
|
||||
@@ -81,7 +83,7 @@ public class HiveSqlService {
|
||||
// value.toString().trim()
|
||||
// + "','yyyy-mm-dd HH24:mi:ss')");
|
||||
sql.append(" and " + filedAndColumnMap.get(col2col.get(key).get("start")) + ">="
|
||||
+ value + "L");
|
||||
+ value);
|
||||
} else {
|
||||
// sql.append(" and " +
|
||||
// filedAndColumnMap.get(col2col.get(key).get("end"))
|
||||
@@ -89,7 +91,7 @@ public class HiveSqlService {
|
||||
// value.toString().trim()
|
||||
// + "','yyyy-mm-dd HH24:mi:ss')");
|
||||
sql.append(" and " + filedAndColumnMap.get(col2col.get(key).get("end")) + "<"
|
||||
+ value + "L");
|
||||
+ value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -98,39 +100,29 @@ public class HiveSqlService {
|
||||
key = key.substring(0, 1).toLowerCase() + key.substring(1);
|
||||
}
|
||||
|
||||
if (!value.toString().trim().equals("") && filedAndColumnMap.containsKey(key)
|
||||
&& (key.toLowerCase().equals("cfgid")
|
||||
|| key.toLowerCase().equals("entranceid"))) {
|
||||
sql.append(
|
||||
" and " + filedAndColumnMap.get(key) + "=" + value.toString().trim() + "L");
|
||||
} else if (!value.toString().trim().equals("") && filedAndColumnMap.containsKey(key)
|
||||
&& (key.toLowerCase().equals("protocol") || key.toLowerCase().equals("serverip")
|
||||
|| key.toLowerCase().equals("clientip")
|
||||
|| key.toLowerCase().equals("url")
|
||||
|| key.toLowerCase().equals("mailfrom")
|
||||
|| key.toLowerCase().equals("mailto")
|
||||
|| key.toLowerCase().equals("encryptmode")
|
||||
|| key.toLowerCase().equals("exprotocol")
|
||||
|| key.toLowerCase().equals("cljip"))) {
|
||||
if (typeName.equals("java.lang.String")) {
|
||||
sql.append(" and " + filedAndColumnMap.get(key) + "='" + value.toString().trim()
|
||||
+ "'");
|
||||
} else if (!value.toString().trim().equals("") && filedAndColumnMap.containsKey(key)
|
||||
&& key.toLowerCase().equals("servicetype")) {
|
||||
} else if (typeName.equals("java.lang.Integer") || typeName.equals("int")) {
|
||||
sql.append(" and " + filedAndColumnMap.get(key) + "=" + value.toString().trim());
|
||||
|
||||
} else if (typeName.equals("java.lang.Long") || typeName.equals("long")) {
|
||||
sql.append(
|
||||
" and " + filedAndColumnMap.get(key) + "=" + value.toString().trim() + "L");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//if (null != searchActiveSys && !searchActiveSys.equals(Constants.ACTIVESYS_A)) {// B版数据库才有found_time_partition字段,A版毛衣found_time_partition分区字段
|
||||
if (null != searchActiveSys){//为A版日志库添加分区字段
|
||||
if (null != searchActiveSys) {// 添加分区字段
|
||||
if (null != foundTimePartStart) {
|
||||
sql.append(" and found_time_partition>=" + foundTimePartStart + "L");
|
||||
// sql.append(" and found_time_partition>=" + foundTimePartStart + "L");
|
||||
sql.append(" and found_time_partition>=" + foundTimePartStart);
|
||||
}
|
||||
if (null != foundTimePartEnd) {
|
||||
sql.append(" and found_time_partition<" + foundTimePartEnd + "L");
|
||||
// sql.append(" and found_time_partition<" + foundTimePartEnd + "L");
|
||||
sql.append(" and found_time_partition<" + foundTimePartEnd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,9 +133,9 @@ public class HiveSqlService {
|
||||
// sql.append(" order by " + orderBy + " limit 10000) t1) t2 where
|
||||
// row_Num between " + startNum + " and " + endNum);
|
||||
sql.append(" limit " + Constants.EVERY_GETHIVEDATANUM);
|
||||
logger.info("获取数据中心日志sql===================" + sql);
|
||||
logger.info("获取数据中心日志sql==================={}", sql);
|
||||
// ResultSet query = HiveJDBC.query(sql.toString());
|
||||
ResultSet query = HiveDataSource.query(sql.toString(), searchActiveSys);
|
||||
ResultSet query = HiveDataSource.query(sql.toString());
|
||||
logger.info("获取数据中心日志成功");
|
||||
return query;
|
||||
}
|
||||
@@ -219,8 +211,10 @@ public class HiveSqlService {
|
||||
|
||||
}
|
||||
}
|
||||
//if (null != searchActiveSys && !searchActiveSys.equals(Constants.ACTIVESYS_A)) {// B版数据库才有found_time_partition字段,A版毛衣found_time_partition分区字段
|
||||
if (null != searchActiveSys){
|
||||
// if (null != searchActiveSys &&
|
||||
// !searchActiveSys.equals(Constants.ACTIVESYS_A)) {//
|
||||
// B版数据库才有found_time_partition字段,A版毛衣found_time_partition分区字段
|
||||
if (null != searchActiveSys) {
|
||||
if (null != foundTimePartStart) {
|
||||
countSql.append(" and found_time_partition>=" + foundTimePartStart + "L");
|
||||
}
|
||||
@@ -232,7 +226,7 @@ public class HiveSqlService {
|
||||
}
|
||||
logger.info("获取数据中心日志总条数sql==================" + countSql.toString());
|
||||
// ResultSet countRs = HiveJDBC.query(countSql.toString());
|
||||
ResultSet countRs = HiveDataSource.query(countSql.toString(), searchActiveSys);
|
||||
ResultSet countRs = HiveDataSource.query(countSql.toString());
|
||||
String countStr = null;
|
||||
while (countRs.next()) {
|
||||
countStr = countRs.getObject(1).toString();
|
||||
|
||||
@@ -51,7 +51,7 @@ public class SaveRequestLogThread implements Runnable {
|
||||
public void run() {
|
||||
logger.info("线程开始执行!");
|
||||
//新开线程切换数据源,不影响action中的数据源
|
||||
CustomerContextHolder.setCustomerType(CustomerContextHolder.DATA_SOURCE_C);//开启数据源C
|
||||
CustomerContextHolder.setCustomerType(CustomerContextHolder.DATA_SOURCE_B);//开启数据源B
|
||||
// TODO Auto-generated method stub
|
||||
if(service!=null){
|
||||
service.saveRequestLog(remoteAddr,requestURI,queryString,contextPath, operator, version, opAction, opTime, content, requestTime, consumerTime,businessCode,exceptionInfo,traceCode);
|
||||
|
||||
Reference in New Issue
Block a user