1:为日志查询cfgid查询条件添加最大输入10个id的判断

2:删除系统中的System.out.print
This commit is contained in:
renkaige
2018-12-19 13:03:32 +06:00
parent 5002f939a7
commit dc23300ac7
13 changed files with 116 additions and 159 deletions

View File

@@ -3,6 +3,8 @@
*/ */
package com.nis.persistence.dialect; package com.nis.persistence.dialect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Cluster方言的实现[神通数据库] * Cluster方言的实现[神通数据库]
@@ -13,6 +15,7 @@ package com.nis.persistence.dialect;
*/ */
public class ClusterDialect implements Dialect { public class ClusterDialect implements Dialect {
protected Logger logger = LoggerFactory.getLogger(ClusterDialect.class);
@Override @Override
public String getLimitString(String sql, int offset, int limit) { public String getLimitString(String sql, int offset, int limit) {
@@ -46,7 +49,7 @@ public class ClusterDialect implements Dialect {
stringBuilder.append(" offset "); stringBuilder.append(" offset ");
stringBuilder.append(offsetPlaceholder); stringBuilder.append(offsetPlaceholder);
} }
System.out.println("cluster分页sql"+stringBuilder.toString()); logger.info("cluster分页sql"+stringBuilder.toString());
return stringBuilder.toString(); return stringBuilder.toString();
} }

View File

@@ -1,5 +1,13 @@
package com.nis.persistence.interceptor; package com.nis.persistence.interceptor;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.ibatis.executor.ErrorContext; import org.apache.ibatis.executor.ErrorContext;
import org.apache.ibatis.executor.ExecutorException; import org.apache.ibatis.executor.ExecutorException;
import org.apache.ibatis.logging.Log; import org.apache.ibatis.logging.Log;
@@ -13,7 +21,8 @@ import org.apache.ibatis.scripting.xmltags.ForEachSqlNode;
import org.apache.ibatis.session.Configuration; import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.type.TypeHandler; import org.apache.ibatis.type.TypeHandler;
import org.apache.ibatis.type.TypeHandlerRegistry; import org.apache.ibatis.type.TypeHandlerRegistry;
import org.apache.log4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.nis.datasource.CustomerContextHolder; import com.nis.datasource.CustomerContextHolder;
import com.nis.domain.Page; import com.nis.domain.Page;
@@ -28,19 +37,9 @@ import com.nis.persistence.dialect.OracleDialect;
import com.nis.persistence.dialect.PostgreSQLDialect; import com.nis.persistence.dialect.PostgreSQLDialect;
import com.nis.persistence.dialect.SQLServer2005Dialect; import com.nis.persistence.dialect.SQLServer2005Dialect;
import com.nis.persistence.dialect.SybaseDialect; import com.nis.persistence.dialect.SybaseDialect;
import com.nis.util.Configurations;
import com.nis.util.Reflections; import com.nis.util.Reflections;
import com.nis.util.StringUtils; import com.nis.util.StringUtils;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* SQL工具类 * SQL工具类
* *
@@ -48,7 +47,7 @@ import java.util.regex.Pattern;
* @version 2013-8-28 * @version 2013-8-28
*/ */
public class SQLHelper { public class SQLHelper {
static final Logger logger = Logger.getLogger(SQLHelper.class); protected static Logger logger = LoggerFactory.getLogger(SQLHelper.class);
/** /**
* 对SQL参数(?)设值,参考org.apache.ibatis.executor.parameter.DefaultParameterHandler * 对SQL参数(?)设值,参考org.apache.ibatis.executor.parameter.DefaultParameterHandler
* *
@@ -165,7 +164,7 @@ public class SQLHelper {
countSql = "select count(*) from (" + removeOrders(sql) + ") tmp_count"; countSql = "select count(*) from (" + removeOrders(sql) + ") tmp_count";
} }
} }
System.out.println("countSql:"+countSql); logger.info("countSql:"+countSql);
Connection conn = connection; Connection conn = connection;
PreparedStatement ps = null; PreparedStatement ps = null;
ResultSet rs = null; ResultSet rs = null;

View File

@@ -11,12 +11,6 @@ import java.util.List;
*/ */
public class AsciiJudge { public class AsciiJudge {
public static void main(String[] args) {
String str = "fdsf你说说你发的是佛山东方啥的飞sdf 啥打法是否(\\&)";
boolean bool = asciiControlChar(str);
System.out.println(bool);
}
/** /**
* 判断字符串是否包含控制字符 * 判断字符串是否包含控制字符
* *

View File

@@ -7,12 +7,6 @@ import java.net.UnknownHostException;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public class BasicProvingUtil { public class BasicProvingUtil {
public static void main(String[] args) {
// String ip = "::";
String ip = " fe80::d025:864c:3151:daa0";
System.out.println(ip + "=" + isIpv6(ip));
}
/** /**
* 判断是否是Integer类型 * 判断是否是Integer类型

View File

@@ -1020,26 +1020,4 @@ public class CompileVal {
} }
public static void main(String[] args) {
long x = 2;
int count = 0;
for (int i = 1; i < 32; i++) {
count++;
x = x * 2;
}
System.out.println(count + " " + x);
long maxValue = Long.MAX_VALUE;
System.out.println(maxValue);
String key = "\\&国\\&人&民共和&国中央&中央人民政府";
String[] split = key.split("(?<=[^\\\\])&");
for (String str : split) {
System.out.println(str);
}
}
} }

View File

@@ -261,18 +261,5 @@ public class ElasticsearchSqlDao {
} }
} }
/**
* main(这里用一句话描述这个方法的作用)
* (这里描述这个方法适用条件 可选)
* @param args
*void
* @exception
* @since 1.0.0
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
StringBuffer sf=new StringBuffer(" AND 1=1");
System.out.println(sf.delete(0, " AND".length()).toString());
}
} }

View File

@@ -183,7 +183,7 @@ public class LoginController extends BaseController {
try { try {
if (StringUtils.isNotBlank(roleId)){ if (StringUtils.isNotBlank(roleId)){
System.out.println("*****************"); logger.info("*****************");
} }
} catch (Exception e) { } catch (Exception e) {

View File

@@ -46,10 +46,8 @@ public abstract class BaseLogService {
* *
* @param clazz * @param clazz
* @param page * @param page
* @throws Exception * @throws Exception void
* void * @exception @since 1.0.0
* @exception @since
* 1.0.0
*/ */
public void checkCloumnIsExist(AuditLogThread thread, long start, Class clazz, Page page) throws Exception { public void checkCloumnIsExist(AuditLogThread thread, long start, Class clazz, Page page) throws Exception {
String[] fieldsColoumn = null; String[] fieldsColoumn = null;
@@ -100,7 +98,8 @@ public abstract class BaseLogService {
} }
if (!StringUtil.isBlank(notExistColumn)) { if (!StringUtil.isBlank(notExistColumn)) {
notExistColumn = notExistColumn.substring(1); notExistColumn = notExistColumn.substring(1);
throw new RestServiceException("fields中" + notExistColumn + "的字段不存在!", RestBusinessCode.param_formate_error.getValue()); throw new RestServiceException("fields中" + notExistColumn + "的字段不存在!",
RestBusinessCode.param_formate_error.getValue());
} }
} }
if (orderByColoumn != null) { if (orderByColoumn != null) {
@@ -118,7 +117,8 @@ public abstract class BaseLogService {
} }
if (!StringUtil.isBlank(notExistColumn)) { if (!StringUtil.isBlank(notExistColumn)) {
notExistColumn = notExistColumn.substring(1); notExistColumn = notExistColumn.substring(1);
throw new RestServiceException("orderBy中" + notExistColumn + "的字段不存在!", RestBusinessCode.param_formate_error.getValue()); throw new RestServiceException("orderBy中" + notExistColumn + "的字段不存在!",
RestBusinessCode.param_formate_error.getValue());
} }
} }
@@ -127,24 +127,30 @@ public abstract class BaseLogService {
/** /**
* 验证日志查询条件格式是否正确 * 验证日志查询条件格式是否正确
*
* @param thread * @param thread
* @param start * @param start
* @param entity * @param entity
* @param clazz * @param clazz
* @param page * @param page
*/ */
public void queryConditionCheck(AuditLogThread thread, long start, LogEntity<?> entity, Class clazz, public void queryConditionCheck(AuditLogThread thread, long start, LogEntity<?> entity, Class clazz, Page page) {
Page page) {
logger.info("请求参数校验开始----" + System.currentTimeMillis()); logger.info("请求参数校验开始----" + System.currentTimeMillis());
try {
if (!StringUtil.isBlank(entity.getSearchCfgId())) { if (!StringUtil.isBlank(entity.getSearchCfgId())) {
Long.parseLong(entity.getSearchCfgId()); String[] split = org.apache.commons.lang.StringUtils.split(entity.getSearchCfgId(), ",");
if (split.length > 10) {
throw new RestServiceException("searchCfgId参数个数不能超过10个",
RestBusinessCode.param_formate_error.getValue());
}
for (String cfgId : split) {
try {
Long.parseLong(cfgId);
} catch (Exception e) {
throw new RestServiceException("searchCfgId参数错误", RestBusinessCode.param_formate_error.getValue());
}
} }
} catch (NumberFormatException e) {
throw new RestServiceException("searchCfgId参数格式错误",
RestBusinessCode.param_formate_error.getValue());
} catch (Exception e) {
throw new RestServiceException("searchCfgId参数错误",RestBusinessCode.param_formate_error.getValue());
} }
try { try {
@@ -152,10 +158,9 @@ public abstract class BaseLogService {
Integer.parseInt(entity.getSearchDirection()); Integer.parseInt(entity.getSearchDirection());
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new RestServiceException("getSearchDirection参数格式错误", throw new RestServiceException("getSearchDirection参数格式错误", RestBusinessCode.param_formate_error.getValue());
RestBusinessCode.param_formate_error.getValue());
} catch (Exception e) { } catch (Exception e) {
throw new RestServiceException("getSearchDirection参数错误",RestBusinessCode.param_formate_error.getValue()); throw new RestServiceException("getSearchDirection参数错误", RestBusinessCode.param_formate_error.getValue());
} }
try { try {
@@ -163,10 +168,9 @@ public abstract class BaseLogService {
Long.parseLong(entity.getSearchEntranceId()); Long.parseLong(entity.getSearchEntranceId());
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new RestServiceException("searchEntranceId参数格式错误", throw new RestServiceException("searchEntranceId参数格式错误", RestBusinessCode.param_formate_error.getValue());
RestBusinessCode.param_formate_error.getValue());
} catch (Exception e) { } catch (Exception e) {
throw new RestServiceException("searchEntranceId参数错误",RestBusinessCode.param_formate_error.getValue()); throw new RestServiceException("searchEntranceId参数错误", RestBusinessCode.param_formate_error.getValue());
} }
try { try {
@@ -175,10 +179,9 @@ public abstract class BaseLogService {
sdf.parse(entity.getSearchFoundEndTime()); sdf.parse(entity.getSearchFoundEndTime());
} }
} catch (ParseException e) { } catch (ParseException e) {
throw new RestServiceException("searchFoundEndTime参数格式错误", throw new RestServiceException("searchFoundEndTime参数格式错误", RestBusinessCode.param_formate_error.getValue());
RestBusinessCode.param_formate_error.getValue());
} catch (Exception e) { } catch (Exception e) {
throw new RestServiceException("searchFoundEndTime参数错误",RestBusinessCode.param_formate_error.getValue()); throw new RestServiceException("searchFoundEndTime参数错误", RestBusinessCode.param_formate_error.getValue());
} }
try { try {
@@ -190,7 +193,7 @@ public abstract class BaseLogService {
throw new RestServiceException("searchFoundStartTime参数格式错误", throw new RestServiceException("searchFoundStartTime参数格式错误",
RestBusinessCode.param_formate_error.getValue()); RestBusinessCode.param_formate_error.getValue());
} catch (Exception e) { } catch (Exception e) {
throw new RestServiceException("searchFoundStartTime参数错误",RestBusinessCode.param_formate_error.getValue()); throw new RestServiceException("searchFoundStartTime参数错误", RestBusinessCode.param_formate_error.getValue());
} }
try { try {
@@ -198,23 +201,25 @@ public abstract class BaseLogService {
Integer.parseInt(entity.getSearchService()); Integer.parseInt(entity.getSearchService());
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new RestServiceException("searchService参数格式错误", throw new RestServiceException("searchService参数格式错误", RestBusinessCode.param_formate_error.getValue());
RestBusinessCode.param_formate_error.getValue());
} catch (Exception e) { } catch (Exception e) {
throw new RestServiceException("searchService参数错误",RestBusinessCode.param_formate_error.getValue()); throw new RestServiceException("searchService参数错误", RestBusinessCode.param_formate_error.getValue());
} }
try { try {
checkCloumnIsExist(thread, start, clazz, page); checkCloumnIsExist(thread, start, clazz, page);
} catch (RestServiceException e) { } catch (RestServiceException e) {
throw e; throw e;
} catch (Exception e) { } catch (Exception e) {
throw new ServiceRuntimeException(ExceptionUtil.getExceptionMsg(e),RestBusinessCode.service_runtime_error.getValue()); throw new ServiceRuntimeException(ExceptionUtil.getExceptionMsg(e),
RestBusinessCode.service_runtime_error.getValue());
} }
logger.info("请求参数校验结束----" + System.currentTimeMillis()); logger.info("请求参数校验结束----" + System.currentTimeMillis());
} }
/** /**
* 验证日志查询条件格式是否正确 * 验证日志查询条件格式是否正确
*
* @param thread * @param thread
* @param start * @param start
* @param entity * @param entity
@@ -222,7 +227,7 @@ public abstract class BaseLogService {
* @param page * @param page
*/ */
public void collectConditionCheck(AuditLogThread thread, long start, NtcCollectVoipLog entity, Class clazz, public void collectConditionCheck(AuditLogThread thread, long start, NtcCollectVoipLog entity, Class clazz,
Page page) { Page page) {
logger.info("请求参数校验开始----" + System.currentTimeMillis()); logger.info("请求参数校验开始----" + System.currentTimeMillis());
try { try {
if (!StringUtil.isBlank(entity.getSearchFoundEndTime())) { if (!StringUtil.isBlank(entity.getSearchFoundEndTime())) {
@@ -230,10 +235,9 @@ public abstract class BaseLogService {
sdf.parse(entity.getSearchFoundEndTime()); sdf.parse(entity.getSearchFoundEndTime());
} }
} catch (ParseException e) { } catch (ParseException e) {
throw new RestServiceException("searchFoundEndTime参数格式错误", throw new RestServiceException("searchFoundEndTime参数格式错误", RestBusinessCode.param_formate_error.getValue());
RestBusinessCode.param_formate_error.getValue());
} catch (Exception e) { } catch (Exception e) {
throw new RestServiceException("searchFoundEndTime参数格式格式",RestBusinessCode.param_formate_error.getValue()); throw new RestServiceException("searchFoundEndTime参数格式格式", RestBusinessCode.param_formate_error.getValue());
} }
try { try {
@@ -245,7 +249,7 @@ public abstract class BaseLogService {
throw new RestServiceException("searchFoundStartTime参数格式错误", throw new RestServiceException("searchFoundStartTime参数格式错误",
RestBusinessCode.param_formate_error.getValue()); RestBusinessCode.param_formate_error.getValue());
} catch (Exception e) { } catch (Exception e) {
throw new RestServiceException("searchFoundStartTime参数错误",RestBusinessCode.param_formate_error.getValue()); throw new RestServiceException("searchFoundStartTime参数错误", RestBusinessCode.param_formate_error.getValue());
} }
try { try {
@@ -253,11 +257,13 @@ public abstract class BaseLogService {
} catch (RestServiceException e) { } catch (RestServiceException e) {
throw e; throw e;
} catch (Exception e) { } catch (Exception e) {
throw new ServiceRuntimeException(ExceptionUtil.getExceptionMsg(e),RestBusinessCode.service_runtime_error.getValue()); throw new ServiceRuntimeException(ExceptionUtil.getExceptionMsg(e),
RestBusinessCode.service_runtime_error.getValue());
} }
logger.info("请求参数校验结束----" + System.currentTimeMillis()); logger.info("请求参数校验结束----" + System.currentTimeMillis());
} }
/** /**
* *
* @Description: * @Description:
@@ -270,12 +276,13 @@ public abstract class BaseLogService {
* @param page * @param page
*/ */
public void queryReportConditionCheck(AuditLogThread thread, long start, NtcReportEntity<?> entity, Class clazz, public void queryReportConditionCheck(AuditLogThread thread, long start, NtcReportEntity<?> entity, Class clazz,
Page page) { Page page) {
logger.info("实时报表统计查询参数校验开始----" + System.currentTimeMillis()); logger.info("实时报表统计查询参数校验开始----" + System.currentTimeMillis());
if (!StringUtil.isBlank(entity.getSearchBusinessType())&&!StringUtil.isNumeric(entity.getSearchBusinessType())) { if (!StringUtil.isBlank(entity.getSearchBusinessType())
throw new RestServiceException("searchBusinessType参数格式错误",RestBusinessCode.param_formate_error.getValue()); && !StringUtil.isNumeric(entity.getSearchBusinessType())) {
throw new RestServiceException("searchBusinessType参数格式错误", RestBusinessCode.param_formate_error.getValue());
} }
//searchService // searchService
checkNumericCondition(thread, start, entity.getSearchService(), "searchService"); checkNumericCondition(thread, start, entity.getSearchService(), "searchService");
try { try {
@@ -283,9 +290,11 @@ public abstract class BaseLogService {
sdf.parse(entity.getSearchReportStartTime()); sdf.parse(entity.getSearchReportStartTime());
} }
} catch (ParseException e) { } catch (ParseException e) {
throw new RestServiceException("searchReportStartTime参数格式错误",RestBusinessCode.param_formate_error.getValue()); throw new RestServiceException("searchReportStartTime参数格式错误",
RestBusinessCode.param_formate_error.getValue());
} catch (Exception e) { } catch (Exception e) {
throw new RestServiceException("searchReportStartTime参数错误",RestBusinessCode.param_formate_error.getValue()); throw new RestServiceException("searchReportStartTime参数错误",
RestBusinessCode.param_formate_error.getValue());
} }
try { try {
@@ -293,18 +302,20 @@ public abstract class BaseLogService {
sdf.parse(entity.getSearchReportEndTime()); sdf.parse(entity.getSearchReportEndTime());
} }
} catch (ParseException e) { } catch (ParseException e) {
throw new RestServiceException("searchReportEndTime参数格式错误",RestBusinessCode.param_formate_error.getValue()); throw new RestServiceException("searchReportEndTime参数格式错误",
} catch (Exception e) {
throw new RestServiceException("searchReportEndTime参数错误",RestBusinessCode.param_formate_error.getValue());
}
if (!StringUtil.isBlank(entity.getSearchBusinessType())&&!StringUtil.isNumeric(entity.getSearchBusinessType())) {
throw new RestServiceException("searchBusinessType参数格式错误",
RestBusinessCode.param_formate_error.getValue()); RestBusinessCode.param_formate_error.getValue());
} catch (Exception e) {
throw new RestServiceException("searchReportEndTime参数错误", RestBusinessCode.param_formate_error.getValue());
}
if (!StringUtil.isBlank(entity.getSearchBusinessType())
&& !StringUtil.isNumeric(entity.getSearchBusinessType())) {
throw new RestServiceException("searchBusinessType参数格式错误", RestBusinessCode.param_formate_error.getValue());
} }
logger.info("实时报表统计查询参数校验结束----" + System.currentTimeMillis()); logger.info("实时报表统计查询参数校验结束----" + System.currentTimeMillis());
} }
/** /**
* @Description:用于验证数值类型格式,多个值以","分隔 * @Description:用于验证数值类型格式,多个值以","分隔
* @author (zdx) * @author (zdx)
@@ -315,38 +326,37 @@ public abstract class BaseLogService {
* @param condName * @param condName
*/ */
public void checkNumericCondition(AuditLogThread thread, long start, String condition, String condName) { public void checkNumericCondition(AuditLogThread thread, long start, String condition, String condName) {
if (!StringUtil.isEmpty(condition)){ if (!StringUtil.isEmpty(condition)) {
Boolean flag = false; Boolean flag = false;
if (condition.contains(",")) { if (condition.contains(",")) {
String services[] =condition.split(","); String services[] = condition.split(",");
for (String service : services) { for (String service : services) {
if(!StringUtil.isNumeric(service)) { if (!StringUtil.isNumeric(service)) {
flag = true; flag = true;
break; break;
} }
} }
}else if(!StringUtil.isNumeric(condition)) { } else if (!StringUtil.isNumeric(condition)) {
flag = true; flag = true;
} }
if (flag) { if (flag) {
throw new RestServiceException(condName+"参数格式错误", throw new RestServiceException(condName + "参数格式错误", RestBusinessCode.param_formate_error.getValue());
RestBusinessCode.param_formate_error.getValue());
} }
} }
} }
/** /**
* @Description:验证用户行为日志统计查询条件 * @Description:验证用户行为日志统计查询条件
* @author(zdx) * @author(zdx) @date 2018年10月31日 下午4:53:27
* @date 2018年10月31日 下午4:53:27
* @param thread * @param thread
* @param start * @param start
* @param entity * @param entity
*/ */
public void checkNtcRadiusReportCondition(AuditLogThread thread, long start, NtcRadiusReport entity) { public void checkNtcRadiusReportCondition(AuditLogThread thread, long start, NtcRadiusReport entity) {
logger.info("用户行为日志统计参数校验开始----" + System.currentTimeMillis()); logger.info("用户行为日志统计参数校验开始----" + System.currentTimeMillis());
if (!StringUtil.isBlank(entity.getSearchBusinessType())&&!StringUtil.isNumeric(entity.getSearchBusinessType())) { if (!StringUtil.isBlank(entity.getSearchBusinessType())
throw new RestServiceException("searchBusinessType参数格式错误", && !StringUtil.isNumeric(entity.getSearchBusinessType())) {
RestBusinessCode.param_formate_error.getValue()); throw new RestServiceException("searchBusinessType参数格式错误", RestBusinessCode.param_formate_error.getValue());
} }
int timeCount = 0; int timeCount = 0;
@@ -359,7 +369,8 @@ public abstract class BaseLogService {
throw new RestServiceException("searchReportStartTime参数格式错误", throw new RestServiceException("searchReportStartTime参数格式错误",
RestBusinessCode.param_formate_error.getValue()); RestBusinessCode.param_formate_error.getValue());
} catch (Exception e) { } catch (Exception e) {
throw new RestServiceException("searchReportStartTime参数错误",RestBusinessCode.param_formate_error.getValue()); throw new RestServiceException("searchReportStartTime参数错误",
RestBusinessCode.param_formate_error.getValue());
} }
try { try {
@@ -371,22 +382,21 @@ public abstract class BaseLogService {
throw new RestServiceException("searchReportEndTime参数格式错误", throw new RestServiceException("searchReportEndTime参数格式错误",
RestBusinessCode.param_formate_error.getValue()); RestBusinessCode.param_formate_error.getValue());
} catch (Exception e) { } catch (Exception e) {
throw new RestServiceException("searchReportEndTime参数错误",RestBusinessCode.param_formate_error.getValue()); throw new RestServiceException("searchReportEndTime参数错误", RestBusinessCode.param_formate_error.getValue());
} }
if (timeCount==1) { if (timeCount == 1) {
throw new RestServiceException("searchReportStartTime和searchReportEndTime参数必须同时填写", throw new RestServiceException("searchReportStartTime和searchReportEndTime参数必须同时填写",
RestBusinessCode.config_integrity_error.getValue()); RestBusinessCode.config_integrity_error.getValue());
} }
// 根据用户查看IP趋势时(searchBusinessType=2),用户名必需填写
//根据用户查看IP趋势时(searchBusinessType=2),用户名必需填写 if ("2".equals(entity.getSearchBusinessType()) && StringUtil.isEmpty(entity.getSearchAccount())) {
if ("2".equals(entity.getSearchBusinessType())&&StringUtil.isEmpty(entity.getSearchAccount())) {
throw new RestServiceException("searchBusinessType=2时searchAccount参数必须填写", throw new RestServiceException("searchBusinessType=2时searchAccount参数必须填写",
RestBusinessCode.config_integrity_error.getValue()); RestBusinessCode.config_integrity_error.getValue());
} }
//根据用户查看IP趋势时(searchBusinessType=3),用户名必需填写 // 根据用户查看IP趋势时(searchBusinessType=3),用户名必需填写
if ("3".equals(entity.getSearchBusinessType())&&StringUtil.isEmpty(entity.getSearchNasIp())) { if ("3".equals(entity.getSearchBusinessType()) && StringUtil.isEmpty(entity.getSearchNasIp())) {
throw new RestServiceException("searchBusinessType=3时searchNasIp参数必须填写", throw new RestServiceException("searchBusinessType=3时searchNasIp参数必须填写",
RestBusinessCode.config_integrity_error.getValue()); RestBusinessCode.config_integrity_error.getValue());
} }
@@ -399,10 +409,8 @@ public abstract class BaseLogService {
* *
* @Title: getJedisKey * @Title: getJedisKey
* @Description: (日志查询/报表记录,"接口名称+查询条件"作为key将结果存入redis中) * @Description: (日志查询/报表记录,"接口名称+查询条件"作为key将结果存入redis中)
* @param @param * @param @param request
* request * @param @param bool 查询数据中心缓存还是oracle缓存,false是oracle缓存
* @param @param
* bool 查询数据中心缓存还是oracle缓存,false是oracle缓存
* @param @return * @param @return
* @return Map 返回类型 * @return Map 返回类型
* @author DDM * @author DDM

View File

@@ -2,7 +2,6 @@ package com.nis.web.service;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@@ -248,8 +247,8 @@ public class LogDataService {
} }
// clickhouse写法 // clickhouse写法
String type = filedsType.get(key).trim(); String type = filedsType.get(key).trim();
String field = filedAndColumnMap.get(key).toLowerCase();
if (type.equals("java.lang.String")) { if (type.equals("java.lang.String")) {
String field = filedAndColumnMap.get(key).toLowerCase();
if (field.equals("url") || field.equals("website")) { if (field.equals("url") || field.equals("website")) {
whereSB.append(" and " + field + " like '" + value.toString().trim() + "%'"); whereSB.append(" and " + field + " like '" + value.toString().trim() + "%'");
} else { } else {
@@ -258,8 +257,15 @@ public class LogDataService {
} }
} else if (type.equals("java.lang.Integer") || type.equals("int") } else if (type.equals("java.lang.Integer") || type.equals("int")
|| type.equals("java.lang.Long") || type.equals("long")) { || type.equals("java.lang.Long") || type.equals("long")) {
whereSB.append(" and " + filedAndColumnMap.get(key).toLowerCase() + "=" if(field.equals("cfg_id")) {
+ value.toString().trim()); whereSB.append(" and " + filedAndColumnMap.get(key).toLowerCase() + " in("
+ value.toString().trim()+")");
}else {
whereSB.append(" and " + filedAndColumnMap.get(key).toLowerCase() + "="
+ value.toString().trim());
}
} }
} }

View File

@@ -11,14 +11,9 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import net.sf.json.JSONObject;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -45,9 +40,11 @@ import com.nis.util.GroupReuseVal;
import com.nis.util.JsonMapper; import com.nis.util.JsonMapper;
import com.nis.util.ReadCommSourceXmlUtil; import com.nis.util.ReadCommSourceXmlUtil;
import com.nis.util.ServiceAndRDBIndexReal; import com.nis.util.ServiceAndRDBIndexReal;
import com.zdjizhi.utils.StringUtil;
import com.nis.web.service.AuditLogThread; import com.nis.web.service.AuditLogThread;
import com.nis.web.service.BaseService; import com.nis.web.service.BaseService;
import com.zdjizhi.utils.StringUtil;
import net.sf.json.JSONObject;
/** /**
* @ClassName: ControlService * @ClassName: ControlService

View File

@@ -141,9 +141,6 @@ public class GetIpRangeTask {
String[] ipAddr = str.split("-"); String[] ipAddr = str.split("-");
if (ipAddr.length > 1) { if (ipAddr.length > 1) {
String startIp = ipAddr[0]; String startIp = ipAddr[0];
if(startIp.toString().length()>11) {
System.out.println("1");
}
String endIp = ipAddr[1]; String endIp = ipAddr[1];
NtcIpRangeReport ntcIpRangeReport = new NtcIpRangeReport(); NtcIpRangeReport ntcIpRangeReport = new NtcIpRangeReport();
String startIpStr = map.get(Long.parseLong(startIp)); String startIpStr = map.get(Long.parseLong(startIp));
@@ -165,11 +162,6 @@ public class GetIpRangeTask {
System.out.print(list.get(i) + "[" + map.get(list.get(i)) + "]"); System.out.print(list.get(i) + "[" + map.get(list.get(i)) + "]");
if (i < list.size() - 1) { if (i < list.size() - 1) {
Long startIp = list.get(i); Long startIp = list.get(i);
if(startIp.toString().length()>11) {
System.out.println("1");
}
Long endIp = list.get(i + 1); Long endIp = list.get(i + 1);
NtcIpRangeReport ntcIpRangeReport = new NtcIpRangeReport(); NtcIpRangeReport ntcIpRangeReport = new NtcIpRangeReport();
String startIpStr = map.get(startIp); String startIpStr = map.get(startIp);

View File

@@ -75,7 +75,6 @@ public class SyncRedisToCluster {
@Scheduled(cron = "${syncRedisToClusterCron}") @Scheduled(cron = "${syncRedisToClusterCron}")
public void syncRedisToCluster() { public void syncRedisToCluster() {
JedisCluster jedisCluster = getResource(); JedisCluster jedisCluster = getResource();
System.out.println(jedisCluster);
String requestId = UUID.randomUUID().toString(); String requestId = UUID.randomUUID().toString();
try { try {
if (lock(jedisCluster, requestId)) {// 避免集群环境下同一秒钟所有的机器都执行这个定时任务 if (lock(jedisCluster, requestId)) {// 避免集群环境下同一秒钟所有的机器都执行这个定时任务
@@ -180,7 +179,7 @@ public class SyncRedisToCluster {
} }
} }
for (String string : keys) { for (String string : keys) {
System.out.println(string); // System.out.println(string);
} }
logger.debug("Keys gotten!"); logger.debug("Keys gotten!");
return keys; return keys;

View File

@@ -69,7 +69,7 @@ public class HelloWorldController extends BaseController{
@RequestMapping("/testPathVariable/{id}") @RequestMapping("/testPathVariable/{id}")
public String testPathVariable(@PathVariable("id") int id){ public String testPathVariable(@PathVariable("id") int id){
System.out.println(id); logger.info(id);
return "success"; return "success";
} }
@@ -82,7 +82,7 @@ public class HelloWorldController extends BaseController{
*/ */
@RequestMapping(value="/testRequestParam") @RequestMapping(value="/testRequestParam")
public String testRequestParam(@RequestParam(value="username",required=true) String username,@RequestParam(required=false,defaultValue="0") int age){ public String testRequestParam(@RequestParam(value="username",required=true) String username,@RequestParam(required=false,defaultValue="0") int age){
System.out.println(username+":"+age); logger.info(username+":"+age);
return "success"; return "success";
} }