上传代码
This commit is contained in:
8
src/main/java/com/nis/web/service/ArchiveServcie.java
Normal file
8
src/main/java/com/nis/web/service/ArchiveServcie.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.nis.web.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ArchiveServcie extends BaseService{
|
||||
|
||||
}
|
||||
44
src/main/java/com/nis/web/service/AreaService.java
Normal file
44
src/main/java/com/nis/web/service/AreaService.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.nis.web.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.nis.domain.SysArea;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.SysAreaDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
|
||||
@Service
|
||||
public class AreaService extends TreeService<SysAreaDao, SysArea> {
|
||||
@Autowired
|
||||
private SysAreaDao areaDao;
|
||||
|
||||
public List<SysArea> findAll() {
|
||||
return UserUtils.getAreaList();
|
||||
}
|
||||
|
||||
|
||||
public List<SysArea> findAllAreaList(SysArea area) {
|
||||
if (!StringUtil.isEmpty(area.getId())) {
|
||||
area.setParentIds(area.getParentIds()+area.getId()+","+"%");
|
||||
} else {
|
||||
//area.setParentIds(area.getParentIds()+"%");
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
|
||||
return areaDao.findByParentIdsLike(area);
|
||||
}
|
||||
|
||||
|
||||
public void saveOrUpdate(SysArea sysArea) {
|
||||
if (StringUtil.isEmpty(sysArea.getId())) {
|
||||
sysArea.setDelFlag(1);
|
||||
}
|
||||
this.save(sysArea);
|
||||
UserUtils.removeCache(UserUtils.CACHE_AREA_LIST);
|
||||
}
|
||||
|
||||
}
|
||||
551
src/main/java/com/nis/web/service/BaseLogService.java
Normal file
551
src/main/java/com/nis/web/service/BaseLogService.java
Normal file
@@ -0,0 +1,551 @@
|
||||
package com.nis.web.service;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
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.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.nis.domain.DfJitLogEntity;
|
||||
import com.nis.domain.DfReportEntity;
|
||||
import com.nis.domain.LogEntity;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.StatLogEntity;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.elasticsearch.ElasticsearchSqlDao;
|
||||
|
||||
/**
|
||||
* 基础日志Service基类
|
||||
*
|
||||
* @author zbc
|
||||
* @version 2016-09-10
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
public abstract class BaseLogService {
|
||||
|
||||
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
protected final Logger logger = Logger.getLogger(this.getClass());
|
||||
@Autowired
|
||||
protected ElasticsearchSqlDao elasticsearchSqlDao;
|
||||
/**
|
||||
* wx checkCloumnIsExist(这里用一句话描述这个方法的作用) (这里描述这个方法适用条件 – 可选)
|
||||
*
|
||||
* @param clazz
|
||||
* @param page
|
||||
* @throws Exception
|
||||
* void
|
||||
* @exception @since
|
||||
* 1.0.0
|
||||
*/
|
||||
public void checkCloumnIsExist(SaveRequestLogThread thread, long start, Class clazz, Page page) throws Exception {
|
||||
String[] fieldsColoumn = null;
|
||||
String[] orderByColoumn = null;
|
||||
String notExistColumn = "";
|
||||
String orderByStr = "";
|
||||
// 所有字段名
|
||||
List<String> columnList = new ArrayList<String>();
|
||||
// 所有属性名
|
||||
List<String> propertyList = new ArrayList<String>();
|
||||
// Map<String, String> columnMap=new HashMap<String, String>();
|
||||
|
||||
if (page != null) {
|
||||
// 解析Fileds的字段/属性名称
|
||||
if (!StringUtil.isBlank(page.getFields())) {
|
||||
fieldsColoumn = page.getFields().split(",");
|
||||
}
|
||||
// 解析orderBy的字段/属性名称
|
||||
if (!StringUtil.isBlank(page.getOrderBy())) {
|
||||
orderByStr = page.getOrderBy().replace(" asc", "");
|
||||
orderByStr = orderByStr.replace(" ASC", "");
|
||||
orderByStr = orderByStr.replace(" DESC", "");
|
||||
orderByStr = orderByStr.replace(" desc", "");
|
||||
orderByColoumn = orderByStr.split(",");
|
||||
}
|
||||
// 从resultMap中获取字段名称和属性名称
|
||||
if (fieldsColoumn != null || orderByColoumn != null) {
|
||||
SqlSessionFactory sqlSessionFactory = SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
ResultMap map = sqlSessionFactory.getConfiguration().getResultMap(clazz.getSimpleName() + "Map");
|
||||
List<ResultMapping> mapping = map.getResultMappings();
|
||||
for (ResultMapping mapp : mapping) {
|
||||
columnList.add(mapp.getColumn().toLowerCase());
|
||||
propertyList.add(mapp.getProperty());
|
||||
}
|
||||
}
|
||||
if (fieldsColoumn != null) {
|
||||
notExistColumn = "";
|
||||
for (String column : fieldsColoumn) {
|
||||
if (!StringUtil.isBlank(column)) {
|
||||
column = column.trim();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
// 数据库字段不区分大小写,属性区分大小写
|
||||
if (!columnList.contains(column.toLowerCase()) && !propertyList.contains(column)) {
|
||||
notExistColumn += "," + column;
|
||||
}
|
||||
}
|
||||
if (!StringUtil.isBlank(notExistColumn)) {
|
||||
notExistColumn = notExistColumn.substring(1);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
||||
"fields中" + notExistColumn + "的字段不存在!", RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
}
|
||||
if (orderByColoumn != null) {
|
||||
notExistColumn = "";
|
||||
for (String column : orderByColoumn) {
|
||||
if (!StringUtil.isBlank(column)) {
|
||||
column = column.trim();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
// 数据库字段不区分大小写,属性区分大小写
|
||||
if (!columnList.contains(column.toLowerCase()) && !propertyList.contains(column)) {
|
||||
notExistColumn += "," + column;
|
||||
}
|
||||
}
|
||||
if (!StringUtil.isBlank(notExistColumn)) {
|
||||
notExistColumn = notExistColumn.substring(1);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
||||
"orderBy中" + notExistColumn + "的字段不存在!", RestBusinessCode.param_formate_error.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
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());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchCfgId参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchEntranceId())) {
|
||||
Long.parseLong(entity.getSearchEntranceId());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
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());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchEntranceId参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchFoundEndTime())) {
|
||||
sdf.parse(entity.getSearchFoundEndTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
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());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchFoundEndTime参数格式格式");
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchFoundStartTime())) {
|
||||
sdf.parse(entity.getSearchFoundStartTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
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());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchFoundStartTime参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchServiceType())) {
|
||||
Integer.parseInt(entity.getSearchServiceType());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
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());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchServiceType参数错误");
|
||||
}
|
||||
try {
|
||||
checkCloumnIsExist(thread,start,clazz, page);
|
||||
} catch (RestServiceException e) {
|
||||
logger.error(e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请求参数错误");
|
||||
}
|
||||
logger.info("请求参数校验结束----"+System.currentTimeMillis());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* wx 报表查询条件检查
|
||||
*
|
||||
* @param className
|
||||
* 需要检验的实体名称[需要保证resultMap的id命名方式为[className]Map]
|
||||
* @param page
|
||||
* 需要校验的page对象
|
||||
*/
|
||||
public void queryConditionCheck(SaveRequestLogThread thread, long start, StatLogEntity entity, Class clazz,
|
||||
Page page) {
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchStatStartTime())) {
|
||||
sdf.parse(entity.getSearchStatStartTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
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());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchStatStartTime参数格式错误");
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchStatEndTime())) {
|
||||
sdf.parse(entity.getSearchStatEndTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
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());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchStatEndTime参数错误");
|
||||
}
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchService())) {
|
||||
Integer.parseInt(entity.getSearchService());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
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());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchService参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
checkCloumnIsExist(thread,start,clazz, page);
|
||||
} catch (RestServiceException e) {
|
||||
logger.error(e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请求参数错误");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 管控实时统计公共查询字段验证
|
||||
*
|
||||
* @param entity
|
||||
*/
|
||||
public void queryConditionCheck(SaveRequestLogThread thread, long start, DfJitLogEntity<?> 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, System.currentTimeMillis() - start, "searchReportEndTime参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - 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, System.currentTimeMillis() - start, "searchReportStartTime参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchReportStartTime参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchService())) {
|
||||
Integer.parseInt(entity.getSearchService());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
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());
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchService参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
String searchAttrType = getSearchField(clazz, entity, "searchAttrType");
|
||||
if (!StringUtil.isBlank(searchAttrType)) {
|
||||
Integer.parseInt(searchAttrType);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
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参数错误");
|
||||
}
|
||||
try {
|
||||
String searchLwhh = getSearchField(clazz, entity, "searchLwhh");
|
||||
if (!StringUtil.isBlank(searchLwhh)) {
|
||||
Integer.parseInt(searchLwhh);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
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参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
checkCloumnIsExist(thread,start,clazz, page);
|
||||
} catch (RestServiceException e) {
|
||||
logger.error(e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请求参数错误");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 实时统计公共查询字段验证
|
||||
*
|
||||
* @param entity
|
||||
*/
|
||||
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参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
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参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,start,"searchReportStartTime参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
String searchAttrType = getSearchField(clazz, entity, "searchAttrType");
|
||||
if (!StringUtil.isBlank(searchAttrType)) {
|
||||
Integer.parseInt(searchAttrType);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
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参数错误");
|
||||
}
|
||||
try {
|
||||
String searchLwhh = getSearchField(clazz, entity, "searchLwhh");
|
||||
if (!StringUtil.isBlank(searchLwhh)) {
|
||||
Integer.parseInt(searchLwhh);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
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参数错误");
|
||||
}
|
||||
try {
|
||||
String searchId = getSearchField(clazz, entity, "searchId");
|
||||
if (!StringUtil.isBlank(searchId)) {
|
||||
Integer.parseInt(searchId);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
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参数错误");
|
||||
}
|
||||
|
||||
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参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,start,"searchService参数错误");
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
checkCloumnIsExist(thread,start,clazz, page);
|
||||
} catch (RestServiceException e) {
|
||||
logger.error(e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread,start,"请求参数错误");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @Title: getJedisKey
|
||||
* @Description: (日志查询/报表记录,"接口名称+查询条件"作为key,将结果存入redis中)
|
||||
* @param @param
|
||||
* request
|
||||
* @param @param
|
||||
* bool 查询数据中心缓存还是oracle缓存,false是oracle缓存
|
||||
* @param @return
|
||||
* @return Map 返回类型
|
||||
* @author (DDM)
|
||||
* @version V1.0
|
||||
*/
|
||||
public String getJedisKey(HttpServletRequest request, boolean bool) {
|
||||
String key = "";
|
||||
String serviceName = "";
|
||||
// 获取访问url
|
||||
String uri = request.getRequestURI();
|
||||
serviceName = uri.substring(uri.lastIndexOf("/") + 1, uri.length());
|
||||
Map<String, String[]> parapeterMapNew = new HashMap<String, String[]>();
|
||||
// 获取传入参数
|
||||
Map<String, String[]> parapeterMap = request.getParameterMap();
|
||||
if (parapeterMap == null) {
|
||||
parapeterMap = new HashMap<String, String[]>();
|
||||
}
|
||||
// 将patameterMap内容克隆到一个新的map中
|
||||
for (String keyStr : parapeterMap.keySet()) {
|
||||
parapeterMapNew.put(keyStr, parapeterMap.get(keyStr));
|
||||
}
|
||||
|
||||
if (!bool) {
|
||||
// 判断是否存在pageNo、pageSize,不存在则添加默认的pageNum和pageSize
|
||||
if (parapeterMapNew.get("pageNo") == null) {
|
||||
String[] strArr = { "1" };
|
||||
parapeterMapNew.put("pageNo", strArr);
|
||||
}
|
||||
if (parapeterMapNew.get("pageSize") == null) {
|
||||
String[] strArr = { "30" };
|
||||
parapeterMapNew.put("pageSize", strArr);
|
||||
}
|
||||
}else{
|
||||
if (parapeterMapNew.get("pageNo") != null) {
|
||||
parapeterMapNew.remove("pageNo");
|
||||
}
|
||||
if (parapeterMapNew.get("pageSize") != null) {
|
||||
parapeterMapNew.remove("pageSize");
|
||||
}
|
||||
}
|
||||
// mapKey排序
|
||||
parapeterMapNew.entrySet();
|
||||
|
||||
// 拼凑查询条件
|
||||
for (String keyStr : parapeterMapNew.keySet()) {
|
||||
if (parapeterMapNew.get(keyStr) != null) {
|
||||
key += "&" + keyStr + "=" + parapeterMapNew.get(keyStr)[0];
|
||||
} else {
|
||||
key += "&" + keyStr + "=";
|
||||
}
|
||||
}
|
||||
if (!StringUtil.isBlank(key)) {
|
||||
key = key.substring(1);
|
||||
}
|
||||
// 返回serviceName+查询条件
|
||||
key = serviceName + "?" + key;
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
protected String getSearchField(Class<?> clazz,
|
||||
Serializable entity, String fieldName) {
|
||||
try {
|
||||
Field field = clazz.getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
return (String) field.get(entity);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
153
src/main/java/com/nis/web/service/BaseService.java
Normal file
153
src/main/java/com/nis/web/service/BaseService.java
Normal file
@@ -0,0 +1,153 @@
|
||||
package com.nis.web.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.nis.domain.SysRole;
|
||||
import com.nis.domain.SysUser;
|
||||
import com.nis.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Service基类
|
||||
* @author ThinkGem
|
||||
* @version 2014-05-16
|
||||
*/
|
||||
public abstract class BaseService {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 日志对象
|
||||
*/
|
||||
protected Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 数据范围过滤
|
||||
* @param user 当前用户对象,通过“entity.getCurrentUser()”获取
|
||||
* @param officeAlias 机构表别名,多个用“,”逗号隔开。
|
||||
* @param userAlias 用户表别名,多个用“,”逗号隔开,传递空,忽略此参数
|
||||
* @return 标准连接条件对象
|
||||
*/
|
||||
public static String dataScopeFilter(SysUser user, String officeAlias, String userAlias) {
|
||||
|
||||
|
||||
StringBuilder sqlString = new StringBuilder();
|
||||
|
||||
// 进行权限过滤,多个角色权限范围之间为或者关系。
|
||||
List<Integer> dataScope = Lists.newArrayList();
|
||||
|
||||
if (StringUtils.isBlank(user.getLoginId())){
|
||||
return "";
|
||||
}
|
||||
|
||||
// 超级管理员,跳过权限过滤
|
||||
if (user.isAdmin()){
|
||||
boolean isDataScopeAll = isContainsDataScopeAll(user.getUserRoleList());
|
||||
|
||||
|
||||
|
||||
for (SysRole r : user.getUserRoleList()) {
|
||||
for (String oa : StringUtils.split(officeAlias, ",")){
|
||||
if (!dataScope.contains(r.getDataScope()) && StringUtils.isNotBlank(oa)){
|
||||
|
||||
sqlString.append(createScopeSql(r.getDataScope(),oa,user));
|
||||
dataScope.add(r.getDataScope());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 如果没有全部数据权限,并设置了用户别名,则当前权限为本人;如果未设置别名,当前无权限为已植入权限
|
||||
if (!isDataScopeAll){
|
||||
if (StringUtils.isNotBlank(userAlias)){
|
||||
for (String ua : StringUtils.split(userAlias, ",")){
|
||||
sqlString.append(" OR " + ua + ".id = '" + user.getId() + "'");
|
||||
}
|
||||
}else {
|
||||
for (String oa : StringUtils.split(officeAlias, ",")){
|
||||
//sqlString.append(" OR " + oa + ".id = " + user.getOffice().getId());
|
||||
sqlString.append(" OR " + oa + ".id IS NULL");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
// 如果包含全部权限,则去掉之前添加的所有条件,并跳出循环。
|
||||
sqlString = new StringBuilder();
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(sqlString.toString())){
|
||||
return " AND (" + sqlString.substring(4) + ")";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 测试数据是否包含全集
|
||||
* @return
|
||||
*/
|
||||
private static boolean isContainsDataScopeAll(List<SysRole> roleList) {
|
||||
boolean isDataScopeAll = false;
|
||||
|
||||
for(SysRole role : roleList) {
|
||||
if(SysRole.DATA_SCOPE_ALL.equals(role.getDataScope())){
|
||||
isDataScopeAll = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return isDataScopeAll;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 过滤机构信息
|
||||
* @param dataScope 数据范围(1:所有数据;2:所在公司及以下数据;3:所在公司数据;4:所在部门及以下数据;5:所在部门数据;6:所在单位及以下数据;7:所在单位数据)
|
||||
* @return
|
||||
*/
|
||||
private static String createScopeSql(int dataScope,String officeAlias,SysUser user) {
|
||||
StringBuilder scopeSql = new StringBuilder(1024);
|
||||
|
||||
if (SysRole.DATA_SCOPE_COMPANY_AND_CHILD.equals(dataScope)){
|
||||
scopeSql.append(" OR " + officeAlias + ".id = " + user.getCompany().getId());
|
||||
scopeSql.append(" OR " + officeAlias + ".parent_ids LIKE '" + user.getCompany().getParentIds() + user.getCompany().getId() + ",%'");
|
||||
}
|
||||
else if (SysRole.DATA_SCOPE_COMPANY.equals(dataScope)){
|
||||
scopeSql.append(" OR " + officeAlias + ".id = " + user.getCompany().getId());
|
||||
// 包括本公司下的部门 (type=1:公司;type=2:单位 3.部门)
|
||||
scopeSql.append(" OR (" + officeAlias + ".parent_id = '" + user.getCompany().getId() + "' AND " + officeAlias + ".type>1)");
|
||||
}
|
||||
else if (SysRole.DATA_SCOPE_OFFICE_AND_CHILD.equals(dataScope)){
|
||||
scopeSql.append(" OR " + officeAlias + ".id = " + user.getOffice().getId());
|
||||
scopeSql.append(" OR " + officeAlias + ".parent_ids LIKE '" + user.getOffice().getParentIds() + user.getOffice().getId() + ",%'");
|
||||
}
|
||||
else if (SysRole.DATA_SCOPE_OFFICE.equals(dataScope)){
|
||||
scopeSql.append(" OR " + officeAlias + ".id = " + user.getOffice().getId());
|
||||
}
|
||||
else if (SysRole.DATA_SCOPE_ENTITY_AND_CHILD.equals(dataScope)){
|
||||
scopeSql.append(" OR " + officeAlias + ".id = " + user.getEntity().getId());
|
||||
scopeSql.append(" OR " + officeAlias + ".parent_ids LIKE '" + user.getEntity().getParentIds() + user.getEntity().getId() + ",%'");
|
||||
|
||||
} else if (SysRole.DATA_SCOPE_ENTITY.equals(dataScope)){
|
||||
scopeSql.append(" OR " + officeAlias + ".id = " + user.getEntity().getId());
|
||||
// 包括本公司下的部门 (type=1:公司;type=2:单位 3.部门)
|
||||
scopeSql.append(" OR (" + officeAlias + ".parent_id = '" + user.getEntity().getId() + "' AND " + officeAlias + ".type>1)");
|
||||
|
||||
}
|
||||
|
||||
return scopeSql.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
6
src/main/java/com/nis/web/service/CommonService.java
Normal file
6
src/main/java/com/nis/web/service/CommonService.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package com.nis.web.service;
|
||||
|
||||
|
||||
public interface CommonService {
|
||||
|
||||
}
|
||||
180
src/main/java/com/nis/web/service/CrudService.java
Normal file
180
src/main/java/com/nis/web/service/CrudService.java
Normal file
@@ -0,0 +1,180 @@
|
||||
/**
|
||||
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
|
||||
*/
|
||||
package com.nis.web.service;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.nis.domain.BaseEntity;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.web.dao.CrudDao;
|
||||
|
||||
/**
|
||||
* Service基类
|
||||
* @author ThinkGem
|
||||
* @version 2014-05-16
|
||||
*/
|
||||
public abstract class CrudService<D extends CrudDao<T>, T extends BaseEntity<T>> extends BaseService {
|
||||
|
||||
/**
|
||||
* 持久层对象
|
||||
*/
|
||||
@Autowired
|
||||
protected D dao;
|
||||
|
||||
/**
|
||||
* 获取单条数据
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public T get(Long id) {
|
||||
return dao.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单条数据
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public T get(T entity) {
|
||||
return dao.get(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询列表数据
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public List<T> findList(T entity) {
|
||||
return dao.findList(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<T> findPage(Page<T> page, T entity) {
|
||||
entity.setPage(page);
|
||||
page.setList(dao.findList(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据(插入或更新)
|
||||
* @param entity
|
||||
*/
|
||||
public void save(T entity) {
|
||||
if (entity.getIsNewRecord()){
|
||||
dao.insert(entity);
|
||||
}else{
|
||||
dao.update(entity);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
* @param entity
|
||||
*/
|
||||
public void delete(T entity) {
|
||||
dao.delete(entity);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* saveBatch(批量全部保存数据)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param data 数据集合
|
||||
* @param mClass 传入的dao.xml里的mapper
|
||||
* @author wx
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void saveBatch(List<T> data,@SuppressWarnings("rawtypes")Class mClass) {
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try{
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for(int index = 0; index < data.size();index++){
|
||||
T t = data.get(index);
|
||||
((CrudDao<T>) batchSqlSession.getMapper(mClass)).insert(t);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
// }catch (Exception e){
|
||||
// batchSqlSession.rollback();
|
||||
// throw e;
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* updateBatch(批量更新全部数据)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param data 数据集合
|
||||
* @param mClass 传入的dao.xml里的mapper
|
||||
* @author wx
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void updateBatch(List<T> data,@SuppressWarnings("rawtypes") Class mClass) {
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try{
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for(int index = 0; index < data.size();index++){
|
||||
T t = data.get(index);
|
||||
((CrudDao<T>) batchSqlSession.getMapper(mClass)).update(t);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
// }catch (Exception e){
|
||||
// batchSqlSession.rollback();
|
||||
// throw e;
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* deleteBatch(批量删除全部数据)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param data 数据集合
|
||||
* @param mClass 传入的dao.xml里的mapper
|
||||
* @author wx
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void deleteBatch(List<T> data,@SuppressWarnings("rawtypes") Class mClass) {
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try{
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for(int index = 0; index < data.size();index++){
|
||||
T t = data.get(index);
|
||||
((CrudDao<T>) batchSqlSession.getMapper(mClass)).delete(t);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
// }catch (Exception e){
|
||||
// batchSqlSession.rollback();
|
||||
// throw e;
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
108
src/main/java/com/nis/web/service/DictService.java
Normal file
108
src/main/java/com/nis/web/service/DictService.java
Normal file
@@ -0,0 +1,108 @@
|
||||
package com.nis.web.service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.SysDataDictionaryItem;
|
||||
import com.nis.domain.SysDataDictionaryName;
|
||||
import com.nis.util.DateUtil;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.SysDictDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
|
||||
@Service
|
||||
public class DictService extends BaseService {
|
||||
/**@Resource**/
|
||||
@Autowired
|
||||
private SysDictDao dictDao;
|
||||
|
||||
|
||||
public Page<SysDataDictionaryName> findDictList(Page<SysDataDictionaryName> page, SysDataDictionaryName sysDictName) {
|
||||
// 设置分页参数
|
||||
sysDictName.setPage(page);
|
||||
// 执行分页查询
|
||||
page.setList(dictDao.findDictList(sysDictName));
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
public void saveOrUpdate(SysDataDictionaryName sysDictName) {
|
||||
|
||||
|
||||
|
||||
if(StringUtil.isEmpty(sysDictName.getId())) {//新增
|
||||
|
||||
sysDictName.setCreateTime(new Date());
|
||||
sysDictName.setModifyTime(new Date());
|
||||
sysDictName.setStatus(1);
|
||||
dictDao.insertDictName(sysDictName);
|
||||
|
||||
List<SysDataDictionaryItem> dictItemList = sysDictName.getDictItemList();
|
||||
if(!StringUtil.isEmpty(dictItemList) && dictItemList.size()>0) {
|
||||
for (SysDataDictionaryItem dictItem : dictItemList) {
|
||||
dictItem.setDictionaryId(sysDictName.getId().intValue());
|
||||
dictDao.insertDictItem(dictItem);
|
||||
}
|
||||
}
|
||||
|
||||
}else {//修改
|
||||
|
||||
//累加修改记录
|
||||
String newRevision = "用户"+UserUtils.getUser().getName()+",在"+DateUtil.getCurrentDate(DateUtil.YYYY_MM_DD_HH24_MM_SS)+"修改!";
|
||||
StringBuilder revisionBuilder = new StringBuilder(newRevision);
|
||||
String oldRevision = sysDictName.getRevision();
|
||||
if(!StringUtil.isBlank(oldRevision)){
|
||||
if(oldRevision.split("\\|").length<10){
|
||||
revisionBuilder.append("|").append(oldRevision);
|
||||
}else {
|
||||
revisionBuilder.append("|").append(oldRevision.substring(0,oldRevision.lastIndexOf("|")));
|
||||
}
|
||||
|
||||
}
|
||||
sysDictName.setRevision(revisionBuilder.toString());
|
||||
sysDictName.setModifyTime(new Date());
|
||||
sysDictName.setStatus(1);
|
||||
dictDao.updateDictName(sysDictName);
|
||||
|
||||
|
||||
dictDao.deleteDictItem(sysDictName.getId().intValue());//删除所有词条项信息
|
||||
|
||||
List<SysDataDictionaryItem> dictItemList = sysDictName.getDictItemList();
|
||||
if(!StringUtil.isEmpty(dictItemList) && dictItemList.size()>0) {
|
||||
for (SysDataDictionaryItem dictItem : dictItemList) {
|
||||
dictItem.setDictionaryId(sysDictName.getId().intValue());
|
||||
dictDao.insertDictItem(dictItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void deleteDict(Integer dictId) {
|
||||
|
||||
//删除词典项
|
||||
dictDao.deleteDictItem(dictId);
|
||||
//删除词典标识
|
||||
dictDao.deleteDictName(dictId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public SysDataDictionaryName getDictByIdWithRelation(Integer id) {
|
||||
|
||||
return dictDao.getDictById(1,id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
628
src/main/java/com/nis/web/service/HiveSqlService.java
Normal file
628
src/main/java/com/nis/web/service/HiveSqlService.java
Normal file
@@ -0,0 +1,628 @@
|
||||
package com.nis.web.service;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.sql.ResultSet;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
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 com.nis.domain.Page;
|
||||
import com.nis.util.Configurations;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.HiveDataSource;
|
||||
import com.nis.util.HiveJDBC;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.redis.SaveRedisThread;
|
||||
|
||||
public class HiveSqlService {
|
||||
private final static Logger logger = Logger.getLogger(HiveJDBC.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());
|
||||
if (null == showColmun || showColmun.equals("")) {
|
||||
for (String key : filedAndColumnMap.keySet()) {
|
||||
if (!filedAndColumnMap.get(key).toLowerCase().equals("id")) {
|
||||
sql.append(filedAndColumnMap.get(key) + ",");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sql.append(showColmun);
|
||||
}
|
||||
String sqlTrim = sql.toString().trim();
|
||||
if (sqlTrim.endsWith(",")) {
|
||||
sqlTrim = sqlTrim.substring(0, sqlTrim.length() - 1);
|
||||
}
|
||||
sql.setLength(0);
|
||||
sql.append(" select " + sqlTrim + " from " + tableName + " t where 1=1 ");
|
||||
if (bean != null) {
|
||||
Class<?> clazz = bean.getClass();
|
||||
for (; clazz != Object.class; clazz = clazz.getSuperclass()) {
|
||||
// 获取所有的字段包括public,private,protected,private
|
||||
// Field[] fields = bean.getClass().getDeclaredFields();
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
Long foundTimePartStart = null;
|
||||
Long foundTimePartEnd = null;
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
Field f = fields[i];
|
||||
String key = f.getName();// 获取字段名
|
||||
if (f.getType().getName().equals("java.lang.String") && key.startsWith("search")) {
|
||||
Object value = getFieldValue(bean, key);
|
||||
if (value != null) {
|
||||
setFieldValue(bean, key, value.toString().trim());
|
||||
if (key.endsWith("Time")) {// 日期开始或结束的字段
|
||||
if (col2col.containsKey(key)) {
|
||||
value = sdf.parse(value.toString().trim()).getTime() / 1000;
|
||||
if (key.toLowerCase().equals("searchfoundstarttime")) {
|
||||
foundTimePartStart = Long.parseLong(value.toString()) / 3600;
|
||||
}
|
||||
if (key.toLowerCase().equals("searchfoundendtime")) {
|
||||
foundTimePartEnd = Long.parseLong(value.toString()) / 3600;
|
||||
}
|
||||
if (col2col.get(key).get("start") != null) {
|
||||
// sql.append(" and " +
|
||||
// filedAndColumnMap.get(col2col.get(key).get("start"))
|
||||
// + ">=to_date('" +
|
||||
// value.toString().trim()
|
||||
// + "','yyyy-mm-dd HH24:mi:ss')");
|
||||
sql.append(" and " + filedAndColumnMap.get(col2col.get(key).get("start")) + ">="
|
||||
+ value + "L");
|
||||
} else {
|
||||
// sql.append(" and " +
|
||||
// filedAndColumnMap.get(col2col.get(key).get("end"))
|
||||
// + "<=to_date('" +
|
||||
// value.toString().trim()
|
||||
// + "','yyyy-mm-dd HH24:mi:ss')");
|
||||
sql.append(" and " + filedAndColumnMap.get(col2col.get(key).get("end")) + "<"
|
||||
+ value + "L");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (key.toLowerCase().startsWith("search")) {
|
||||
key = key.replace("search", "");
|
||||
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"))) {
|
||||
sql.append(" and " + filedAndColumnMap.get(key) + "='" + value.toString().trim()
|
||||
+ "'");
|
||||
} else if (!value.toString().trim().equals("") && filedAndColumnMap.containsKey(key)
|
||||
&& key.toLowerCase().equals("servicetype")) {
|
||||
sql.append(" and " + filedAndColumnMap.get(key) + "=" + value.toString().trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//if (null != searchActiveSys && !searchActiveSys.equals(Constants.ACTIVESYS_A)) {// B版数据库才有found_time_partition字段,A版毛衣found_time_partition分区字段
|
||||
if (null != searchActiveSys){//为A版日志库添加分区字段
|
||||
if (null != foundTimePartStart) {
|
||||
sql.append(" and found_time_partition>=" + foundTimePartStart + "L");
|
||||
}
|
||||
if (null != foundTimePartEnd) {
|
||||
sql.append(" and found_time_partition<" + foundTimePartEnd + "L");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Integer startNum = (page.getPageNo() - 1) * page.getPageSize() + 1;
|
||||
Integer endNum = startNum - 1 + page.getPageSize();
|
||||
// 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);
|
||||
// ResultSet query = HiveJDBC.query(sql.toString());
|
||||
ResultSet query = HiveDataSource.query(sql.toString(), searchActiveSys);
|
||||
logger.info("获取数据中心日志成功");
|
||||
return query;
|
||||
}
|
||||
|
||||
public static Long getHivePageCount(Object bean, String countKey, String tableName,
|
||||
Map<String, Map<String, String>> col2col, String searchActiveSys) throws Exception {
|
||||
tableName = tableName.toLowerCase();
|
||||
tableName = Configurations.getStringProperty(tableName, "t_" + tableName).trim();
|
||||
StringBuffer countSql = new StringBuffer();
|
||||
Map<String, String> filedAndColumnMap = getFiledAndColumnMap(bean.getClass());
|
||||
countSql.append("select count(1) from " + tableName + " where 1=1 ");
|
||||
if (bean != null) {
|
||||
Class<?> clazz = bean.getClass();
|
||||
for (; clazz != Object.class; clazz = clazz.getSuperclass()) {
|
||||
// 获取所有的字段包括public,private,protected,private
|
||||
// Field[] fields = bean.getClass().getDeclaredFields();
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
Long foundTimePartStart = null;
|
||||
Long foundTimePartEnd = null;
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
Field f = fields[i];
|
||||
String key = f.getName();// 获取字段名
|
||||
if (f.getType().getName().equals("java.lang.String") && key.startsWith("search")) {
|
||||
Object value = getFieldValue(bean, key);
|
||||
if (value != null) {
|
||||
setFieldValue(bean, key, value.toString().trim());
|
||||
if (key.endsWith("Time")) {// 日期开始或结束的字段
|
||||
if (col2col.containsKey(key)) {
|
||||
value = sdf.parse(value.toString().trim()).getTime() / 1000;
|
||||
if (key.toLowerCase().equals("searchfoundstarttime")) {
|
||||
foundTimePartStart = Long.parseLong(value.toString()) / 3600;
|
||||
}
|
||||
if (key.toLowerCase().equals("searchfoundendtime")) {
|
||||
foundTimePartEnd = Long.parseLong(value.toString()) / 3600;
|
||||
}
|
||||
if (col2col.get(key).get("start") != null) {
|
||||
countSql.append(" and " + filedAndColumnMap.get(col2col.get(key).get("start"))
|
||||
+ ">=" + value + "L");
|
||||
} else {
|
||||
countSql.append(" and " + filedAndColumnMap.get(col2col.get(key).get("end"))
|
||||
+ "<" + value + "L");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (key.toLowerCase().startsWith("search")) {
|
||||
key = key.replace("search", "");
|
||||
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"))) {
|
||||
countSql.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"))) {
|
||||
countSql.append(" and " + filedAndColumnMap.get(key) + "='"
|
||||
+ value.toString().trim() + "'");
|
||||
} else if (!value.toString().trim().equals("") && filedAndColumnMap.containsKey(key)
|
||||
&& key.toLowerCase().equals("servicetype")) {
|
||||
countSql.append(
|
||||
" and " + filedAndColumnMap.get(key) + "=" + value.toString().trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//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");
|
||||
}
|
||||
if (null != foundTimePartEnd) {
|
||||
countSql.append(" and found_time_partition<" + foundTimePartEnd + "L");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.info("获取数据中心日志总条数sql==================" + countSql.toString());
|
||||
// ResultSet countRs = HiveJDBC.query(countSql.toString());
|
||||
ResultSet countRs = HiveDataSource.query(countSql.toString(), searchActiveSys);
|
||||
String countStr = null;
|
||||
while (countRs.next()) {
|
||||
countStr = countRs.getObject(1).toString();
|
||||
break;
|
||||
}
|
||||
if (countStr == null || countStr.equals("")) {
|
||||
logger.info("获取数据中心日志总条数成功总共===================0条配置");
|
||||
return 0l;
|
||||
}
|
||||
Long count = Long.valueOf(countStr);
|
||||
logger.info("获取数据中心日志总条数成功总共===================" + count + "条配置");
|
||||
// HiveJDBC.closeConn();
|
||||
if (Constants.IS_OPEN_REDIS && Constants.DATACENTER_OPEN_REDIS) {
|
||||
new SaveRedisThread(countKey, count, Constants.HIVE_EXPIRE).start();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public static ResultSet getResultSet2(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());
|
||||
if (null == showColmun || showColmun.equals("")) {
|
||||
for (String key : filedAndColumnMap.keySet()) {
|
||||
if (!filedAndColumnMap.get(key).toLowerCase().equals("id")) {
|
||||
sql.append(filedAndColumnMap.get(key) + ",");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sql.append(showColmun);
|
||||
}
|
||||
String sqlTrim = sql.toString().trim();
|
||||
if (sqlTrim.endsWith(",")) {
|
||||
sqlTrim = sqlTrim.substring(0, sqlTrim.length() - 1);
|
||||
}
|
||||
sql.setLength(0);
|
||||
sql.append("select " + sqlTrim + " from(select " + sqlTrim + ",row_Num from(select " + sqlTrim
|
||||
+ ",row_number() over() as row_Num from " + tableName + " t where 1=1 ");
|
||||
if (bean != null) {
|
||||
Class<?> clazz = bean.getClass();
|
||||
for (; clazz != Object.class; clazz = clazz.getSuperclass()) {
|
||||
// 获取所有的字段包括public,private,protected,private
|
||||
// Field[] fields = bean.getClass().getDeclaredFields();
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
Long foundTimePartStart = null;
|
||||
Long foundTimePartEnd = null;
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
Field f = fields[i];
|
||||
String key = f.getName();// 获取字段名
|
||||
if (f.getType().getName().equals("java.lang.String") && key.startsWith("search")) {
|
||||
Object value = getFieldValue(bean, key);
|
||||
if (value != null) {
|
||||
setFieldValue(bean, key, value.toString().trim());
|
||||
if (key.endsWith("Time")) {// 日期开始或结束的字段
|
||||
if (col2col.containsKey(key)) {
|
||||
value = sdf.parse(value.toString().trim()).getTime() / 1000;
|
||||
if (key.toLowerCase().equals("searchfoundstarttime")) {
|
||||
foundTimePartStart = Long.parseLong(value.toString()) / 3600;
|
||||
}
|
||||
if (key.toLowerCase().equals("searchfoundendtime")) {
|
||||
foundTimePartEnd = Long.parseLong(value.toString()) / 3600;
|
||||
}
|
||||
if (col2col.get(key).get("start") != null) {
|
||||
// sql.append(" and " +
|
||||
// filedAndColumnMap.get(col2col.get(key).get("start"))
|
||||
// + ">=to_date('" +
|
||||
// value.toString().trim()
|
||||
// + "','yyyy-mm-dd HH24:mi:ss')");
|
||||
sql.append(" and " + filedAndColumnMap.get(col2col.get(key).get("start")) + ">="
|
||||
+ value + "L");
|
||||
} else {
|
||||
// sql.append(" and " +
|
||||
// filedAndColumnMap.get(col2col.get(key).get("end"))
|
||||
// + "<=to_date('" +
|
||||
// value.toString().trim()
|
||||
// + "','yyyy-mm-dd HH24:mi:ss')");
|
||||
sql.append(" and " + filedAndColumnMap.get(col2col.get(key).get("end")) + "<"
|
||||
+ value + "L");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (key.toLowerCase().startsWith("search")) {
|
||||
key = key.replace("search", "");
|
||||
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("cljip"))) {
|
||||
sql.append(" and " + filedAndColumnMap.get(key) + "='" + value.toString().trim()
|
||||
+ "'");
|
||||
} else if (!value.toString().trim().equals("") && filedAndColumnMap.containsKey(key)
|
||||
&& key.toLowerCase().equals("servicetype")) {
|
||||
sql.append(" and " + filedAndColumnMap.get(key) + "=" + value.toString().trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (null != searchActiveSys && !searchActiveSys.equals(Constants.ACTIVESYS_A)) {// B版数据库才有found_time_partition字段,A版毛衣found_time_partition分区字段
|
||||
if (null != foundTimePartStart) {
|
||||
sql.append(" and found_time_partition>=" + foundTimePartStart + "L");
|
||||
}
|
||||
if (null != foundTimePartEnd) {
|
||||
sql.append(" and found_time_partition<" + foundTimePartEnd + "L");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Integer startNum = (page.getPageNo() - 1) * page.getPageSize() + 1;
|
||||
Integer endNum = startNum - 1 + page.getPageSize();
|
||||
sql.append(
|
||||
" order by " + orderBy + " limit 10000) t1) t2 where row_Num between " + startNum + " and " + endNum);
|
||||
logger.info("获取数据中心日志sql===================" + sql);
|
||||
ResultSet query = HiveJDBC.query(sql.toString(), searchActiveSys);
|
||||
logger.info("获取数据中心日志成功");
|
||||
return query;
|
||||
}
|
||||
|
||||
public static Long getHivePageCount2(Object bean, String tableName, Map<String, Map<String, String>> col2col,
|
||||
String searchActiveSys) throws Exception {
|
||||
tableName = tableName.toLowerCase();
|
||||
tableName = Configurations.getStringProperty(tableName, "t_" + tableName).trim();
|
||||
StringBuffer countSql = new StringBuffer();
|
||||
Map<String, String> filedAndColumnMap = getFiledAndColumnMap(bean.getClass());
|
||||
countSql.append("select count(1) from " + tableName + " where 1=1 ");
|
||||
if (bean != null) {
|
||||
Class<?> clazz = bean.getClass();
|
||||
for (; clazz != Object.class; clazz = clazz.getSuperclass()) {
|
||||
// 获取所有的字段包括public,private,protected,private
|
||||
// Field[] fields = bean.getClass().getDeclaredFields();
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
Long foundTimePartStart = null;
|
||||
Long foundTimePartEnd = null;
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
Field f = fields[i];
|
||||
String key = f.getName();// 获取字段名
|
||||
if (f.getType().getName().equals("java.lang.String") && key.startsWith("search")) {
|
||||
Object value = getFieldValue(bean, key);
|
||||
if (value != null) {
|
||||
setFieldValue(bean, key, value.toString().trim());
|
||||
if (key.endsWith("Time")) {// 日期开始或结束的字段
|
||||
if (col2col.containsKey(key)) {
|
||||
value = sdf.parse(value.toString().trim()).getTime() / 1000;
|
||||
if (key.toLowerCase().equals("searchfoundstarttime")) {
|
||||
foundTimePartStart = Long.parseLong(value.toString()) / 3600;
|
||||
}
|
||||
if (key.toLowerCase().equals("searchfoundendtime")) {
|
||||
foundTimePartEnd = Long.parseLong(value.toString()) / 3600;
|
||||
}
|
||||
if (col2col.get(key).get("start") != null) {
|
||||
countSql.append(" and " + filedAndColumnMap.get(col2col.get(key).get("start"))
|
||||
+ ">=" + value + "L");
|
||||
} else {
|
||||
countSql.append(" and " + filedAndColumnMap.get(col2col.get(key).get("end"))
|
||||
+ "<" + value + "L");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (key.toLowerCase().startsWith("search")) {
|
||||
key = key.replace("search", "");
|
||||
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"))) {
|
||||
countSql.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("cljip"))) {
|
||||
countSql.append(" and " + filedAndColumnMap.get(key) + "='"
|
||||
+ value.toString().trim() + "'");
|
||||
} else if (!value.toString().trim().equals("") && filedAndColumnMap.containsKey(key)
|
||||
&& key.toLowerCase().equals("servicetype")) {
|
||||
countSql.append(
|
||||
" and " + filedAndColumnMap.get(key) + "=" + value.toString().trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (null != searchActiveSys && !searchActiveSys.equals(Constants.ACTIVESYS_A)) {// B版数据库才有found_time_partition字段,A版毛衣found_time_partition分区字段
|
||||
if (null != foundTimePartStart) {
|
||||
countSql.append(" and found_time_partition>=" + foundTimePartStart + "L");
|
||||
}
|
||||
if (null != foundTimePartEnd) {
|
||||
countSql.append(" and found_time_partition<" + foundTimePartEnd + "L");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.info("获取数据中心日志总条数sql==================" + countSql.toString());
|
||||
ResultSet countRs = HiveJDBC.query(countSql.toString(), searchActiveSys);
|
||||
String countStr = null;
|
||||
while (countRs.next()) {
|
||||
countStr = countRs.getObject(1).toString();
|
||||
break;
|
||||
}
|
||||
if (countStr == null || countStr.equals("")) {
|
||||
logger.info("获取数据中心日志总条数成功总共===================0条配置");
|
||||
return 0l;
|
||||
}
|
||||
Long count = Long.valueOf(countStr);
|
||||
logger.info("获取数据中心日志总条数成功总共===================" + count + "条配置");
|
||||
HiveJDBC.closeConn();
|
||||
return count;
|
||||
}
|
||||
|
||||
public static String getFiledsSql(String mapName, String fileds) throws Exception {
|
||||
String[] fieldsColoumn = null;
|
||||
String orderByStr = "";
|
||||
// 所有字段名
|
||||
List<String> columnList = new ArrayList<String>();
|
||||
// 所有属性名
|
||||
List<String> propertyList = new ArrayList<String>();
|
||||
// 属性名称为key,字段名称为value
|
||||
Map<String, String> columnMap = new HashMap<String, String>();
|
||||
|
||||
if (!StringUtil.isBlank(fileds)) {
|
||||
// 解析Fileds的字段/属性名称
|
||||
fieldsColoumn = fileds.split(",");
|
||||
|
||||
// 从resultMap中获取字段名称和属性名称
|
||||
if (fieldsColoumn != null) {
|
||||
SqlSessionFactory sqlSessionFactory = SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
ResultMap map = sqlSessionFactory.getConfiguration().getResultMap(mapName + "Map");
|
||||
List<ResultMapping> mapping = map.getResultMappings();
|
||||
for (ResultMapping mapp : mapping) {
|
||||
columnList.add(mapp.getColumn().toLowerCase());
|
||||
propertyList.add(mapp.getProperty());
|
||||
columnMap.put(mapp.getProperty(), mapp.getColumn());
|
||||
}
|
||||
}
|
||||
if (fieldsColoumn != null) {
|
||||
fileds = "";
|
||||
for (String column : fieldsColoumn) {
|
||||
if (!StringUtil.isBlank(column)) {
|
||||
column = column.trim();
|
||||
if (columnList.contains(column)) {
|
||||
fileds += "," + column;
|
||||
} else if (propertyList.contains(column)) {
|
||||
fileds += "," + columnMap.get(column).toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!StringUtil.isBlank(fileds)) {
|
||||
fileds = fileds.substring(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return fileds;
|
||||
}
|
||||
|
||||
public static Map<String, String> getFiledAndColumnMap(Class clazz) {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
SqlSessionFactory sqlSessionFactory = SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
ResultMap resultMap = sqlSessionFactory.getConfiguration().getResultMap(clazz.getSimpleName() + "Map");
|
||||
List<ResultMapping> mapping = resultMap.getResultMappings();
|
||||
for (ResultMapping mapp : mapping) {
|
||||
map.put(mapp.getProperty(), mapp.getColumn().toLowerCase());
|
||||
}
|
||||
return map;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 利用反射通过get方法获取bean中字段fieldName的值
|
||||
*
|
||||
* @param bean
|
||||
* @param fieldName
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private static Object getFieldValue(Object bean, String fieldName) throws Exception {
|
||||
StringBuffer result = new StringBuffer();
|
||||
String methodName = result.append("get").append(fieldName.substring(0, 1).toUpperCase())
|
||||
.append(fieldName.substring(1)).toString();
|
||||
|
||||
Object rObject = null;
|
||||
Method method = null;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
Class[] classArr = new Class[0];
|
||||
method = bean.getClass().getMethod(methodName, classArr);
|
||||
rObject = method.invoke(bean, new Object[0]);
|
||||
|
||||
return rObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 利用发射调用bean.set方法将value设置到字段
|
||||
*
|
||||
* @param bean
|
||||
* @param fieldName
|
||||
* @param value
|
||||
* @throws Exception
|
||||
*/
|
||||
private static void setFieldValue(Object bean, String fieldName, Object value) throws Exception {
|
||||
StringBuffer result = new StringBuffer();
|
||||
String methodName = result.append("set").append(fieldName.substring(0, 1).toUpperCase())
|
||||
.append(fieldName.substring(1)).toString();
|
||||
/**
|
||||
* 利用发射调用bean.set方法将value设置到字段
|
||||
*/
|
||||
Class[] classArr = new Class[1];
|
||||
classArr[0] = "java.lang.String".getClass();
|
||||
Method method = bean.getClass().getMethod(methodName, classArr);
|
||||
method.invoke(bean, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 比较开始时间或者结束时间是否比当前系统时间早48小时
|
||||
*
|
||||
* @param startTime
|
||||
* 开始时间
|
||||
* @param endTime
|
||||
* 结束时间
|
||||
* @return
|
||||
* @throws ParseException
|
||||
*/
|
||||
public static boolean ifTimeGreaterThan48(String startTime, String endTime) throws Exception {
|
||||
logger.info("ifTimeGreaterThan48方法开始" + System.currentTimeMillis());
|
||||
if (null != startTime && !startTime.equals("") && null != endTime && !endTime.equals("")) {// 开始和结束时间都不为空
|
||||
Date startDate = sdf.parse(startTime);
|
||||
Date endDate = sdf.parse(endTime);
|
||||
if (startDate.getTime() < endDate.getTime()) {// 开始时间比结束时间早
|
||||
logger.info("ifTimeGreaterThan48方法结束" + System.currentTimeMillis());
|
||||
return gt48(endTime);
|
||||
} else {// 开始时间比结束时间晚,不符合一般情况
|
||||
logger.info("ifTimeGreaterThan48方法结束" + System.currentTimeMillis());
|
||||
return false;
|
||||
}
|
||||
} else if (null != endTime && !endTime.equals("")) {// 开始时间为空,结束时间不为空
|
||||
logger.info("ifTimeGreaterThan48方法结束" + System.currentTimeMillis());
|
||||
return gt48(endTime);
|
||||
} else if (null != startTime && !startTime.equals("")) {// 结束时间为空,开始时间不为空
|
||||
logger.info("ifTimeGreaterThan48方法结束" + System.currentTimeMillis());
|
||||
return gt48(startTime);
|
||||
} else {// 开始和结束时间都为空
|
||||
logger.info("ifTimeGreaterThan48方法结束" + System.currentTimeMillis());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean gt48(String eqTime) throws ParseException {
|
||||
logger.info("gt48方法开始" + System.currentTimeMillis());
|
||||
Date eqDate = sdf.parse(eqTime);
|
||||
Long dateNum = eqDate.getTime();
|
||||
Long currentDate = new Date().getTime();
|
||||
Long time = 0l;
|
||||
if (dateNum < currentDate) {
|
||||
time = currentDate - dateNum;// 获取结束时间与当前系统时间的时间差毫秒数
|
||||
} else {
|
||||
logger.info("gt48方法结束" + System.currentTimeMillis());
|
||||
return false;// 结束时间比当前系统时间晚,不符合从数据中心查询数据要求(当前日期48小时前数据从数据中心查询)
|
||||
}
|
||||
double hours = time.doubleValue() / (1000 * 60 * 60);
|
||||
Long datacenterTime = Constants.DATACENTER_TIME;
|
||||
double doubleValue = datacenterTime.doubleValue();
|
||||
if (hours > doubleValue) {
|
||||
logger.info("gt48方法结束" + System.currentTimeMillis());
|
||||
return true;// 符合要求
|
||||
} else {
|
||||
logger.info("gt48方法结束" + System.currentTimeMillis());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Long datacenterTime = Constants.DATACENTER_TIME;
|
||||
double doubleValue = datacenterTime.doubleValue();
|
||||
System.out.println(doubleValue);
|
||||
}
|
||||
}
|
||||
27
src/main/java/com/nis/web/service/LogService.java
Normal file
27
src/main/java/com/nis/web/service/LogService.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.nis.web.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.SysLog;
|
||||
import com.nis.util.DateUtils;
|
||||
import com.nis.web.dao.SysLogDao;
|
||||
|
||||
@Service
|
||||
public class LogService extends CrudService<SysLogDao, SysLog> {
|
||||
|
||||
public Page<SysLog> findPage(Page<SysLog> page, SysLog sysLog) {
|
||||
|
||||
// 设置默认时间范围,默认当前月
|
||||
if (sysLog.getBeginDate() == null){
|
||||
sysLog.setBeginDate(DateUtils.setDays(DateUtils.parseDate(DateUtils.getDate()), 1));
|
||||
}
|
||||
if (sysLog.getEndDate() == null){
|
||||
sysLog.setEndDate(DateUtils.addMonths(sysLog.getBeginDate(), 1));
|
||||
}
|
||||
|
||||
return super.findPage(page, sysLog);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
97
src/main/java/com/nis/web/service/MenuService.java
Normal file
97
src/main/java/com/nis/web/service/MenuService.java
Normal file
@@ -0,0 +1,97 @@
|
||||
package com.nis.web.service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.SysMenu;
|
||||
import com.nis.domain.SysUser;
|
||||
import com.nis.util.CacheUtils;
|
||||
import com.nis.util.LogUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.SysMenuDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
|
||||
@Service
|
||||
public class MenuService extends BaseService {
|
||||
@Autowired
|
||||
private SysMenuDao menuDao;
|
||||
|
||||
public List<SysMenu> findAllMenu() {
|
||||
return UserUtils.getMenuList();
|
||||
}
|
||||
|
||||
public SysMenu getMenu(Long id) {
|
||||
|
||||
return menuDao.get(id);
|
||||
}
|
||||
|
||||
|
||||
public void saveOrUpdateMenu(SysMenu menu) {
|
||||
|
||||
// 获取父节点实体
|
||||
menu.setParent(this.getMenu(menu.getParent().getId()));
|
||||
|
||||
// 获取修改前的parentIds,用于更新子节点的parentIds
|
||||
String oldParentIds = menu.getParentIds();
|
||||
|
||||
// 设置新的父节点串
|
||||
menu.setParentIds(menu.getParent().getParentIds()+menu.getParent().getId()+",");
|
||||
SysUser user = UserUtils.getUser();
|
||||
|
||||
// 保存或更新实体
|
||||
if (StringUtil.isEmpty(menu.getId())){
|
||||
|
||||
menu.setUpdateBy(user);
|
||||
menu.setCreateBy(user);
|
||||
menu.setCreateDate(new Date());
|
||||
menu.setUpdateDate(menu.getCreateDate());
|
||||
menu.setDelFlag(1);
|
||||
menuDao.insert(menu);
|
||||
}else{
|
||||
menu.setUpdateBy(user);
|
||||
menu.setUpdateDate(new Date());
|
||||
menuDao.update(menu);
|
||||
}
|
||||
|
||||
// 更新子节点 parentIds
|
||||
SysMenu m = new SysMenu();
|
||||
m.setParentIds("%,"+menu.getId()+",%");
|
||||
List<SysMenu> list = menuDao.findByParentIdsLike(m);
|
||||
for (SysMenu e : list){
|
||||
e.setParentIds(e.getParentIds().replace(oldParentIds, menu.getParentIds()));
|
||||
menuDao.updateParentIds(e);
|
||||
}
|
||||
// 清除用户菜单缓存
|
||||
UserUtils.removeCache(UserUtils.CACHE_MENU_LIST);
|
||||
// // 清除权限缓存
|
||||
// systemRealm.clearAllCachedAuthorizationInfo();
|
||||
// 清除日志相关缓存
|
||||
CacheUtils.remove(LogUtils.CACHE_MENU_NAME_PATH_MAP);
|
||||
}
|
||||
|
||||
public void deleteMenu(SysMenu menu) {
|
||||
|
||||
menuDao.delete(menu);
|
||||
// 清除用户菜单缓存
|
||||
UserUtils.removeCache(UserUtils.CACHE_MENU_LIST);
|
||||
// // 清除权限缓存
|
||||
// systemRealm.clearAllCachedAuthorizationInfo();
|
||||
// 清除日志相关缓存
|
||||
CacheUtils.remove(LogUtils.CACHE_MENU_NAME_PATH_MAP);
|
||||
|
||||
}
|
||||
|
||||
public void updateMenuSort(SysMenu menu) {
|
||||
menuDao.updateSort(menu);
|
||||
// 清除用户菜单缓存
|
||||
UserUtils.removeCache(UserUtils.CACHE_MENU_LIST);
|
||||
// // 清除权限缓存
|
||||
// systemRealm.clearAllCachedAuthorizationInfo();
|
||||
// 清除日志相关缓存
|
||||
CacheUtils.remove(LogUtils.CACHE_MENU_NAME_PATH_MAP);
|
||||
}
|
||||
|
||||
}
|
||||
108
src/main/java/com/nis/web/service/OfficeService.java
Normal file
108
src/main/java/com/nis/web/service/OfficeService.java
Normal file
@@ -0,0 +1,108 @@
|
||||
package com.nis.web.service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.SysOffice;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.SysOfficeDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
@Service
|
||||
public class OfficeService extends TreeService<SysOfficeDao, SysOffice>{
|
||||
|
||||
public List<SysOffice> findAll() {
|
||||
return UserUtils.getOfficeList();
|
||||
}
|
||||
|
||||
public List<SysOffice> findList(Boolean isAll){
|
||||
if (isAll != null && isAll){
|
||||
return UserUtils.getOfficeAllList();
|
||||
}else{
|
||||
return UserUtils.getOfficeList();
|
||||
}
|
||||
}
|
||||
public SysOffice selectByPrimaryKey(Integer id){
|
||||
if(id != null){
|
||||
|
||||
return dao.selectByPrimaryKey(id);
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<SysOffice> findAllOfficeList(SysOffice office){
|
||||
//office.getSqlMap().put("dsf", dataScopeFilter(UserUtils.getUser(), "a", ""));
|
||||
if (!StringUtil.isEmpty(office.getId()) && office.getId() != 1l) {
|
||||
office.setParentIds(office.getParentIds()+office.getId()+","+"%");
|
||||
} else {
|
||||
office.setParentIds(office.getParentIds()+"%");
|
||||
}
|
||||
|
||||
return dao.findByParentIdsLike(office);
|
||||
|
||||
}
|
||||
|
||||
public void saveOrUpdate(SysOffice office) {
|
||||
if (StringUtil.isEmpty(office.getId())) {
|
||||
office.setCreateTime(new Date());
|
||||
office.setDelFlag(1);
|
||||
}
|
||||
|
||||
this.save(office);
|
||||
|
||||
|
||||
if(office.getChildDeptList() != null) {
|
||||
SysOffice childOffice = null;
|
||||
for(String id : office.getChildDeptList()){
|
||||
childOffice = new SysOffice();
|
||||
childOffice.setName(DictUtils.getDictLabel("SYS_OFFICE_COMMON", id, "未知"));
|
||||
childOffice.setParent(office);
|
||||
childOffice.setArea(office.getArea());
|
||||
childOffice.setType(2);
|
||||
childOffice.setGrade(office.getGrade()+1);
|
||||
childOffice.setUseable(1);
|
||||
childOffice.setCreateTime(new Date());
|
||||
childOffice.setDelFlag(1);
|
||||
this.save(childOffice);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UserUtils.removeCache(UserUtils.CACHE_OFFICE_LIST);
|
||||
|
||||
}
|
||||
|
||||
public void delete(SysOffice office) {
|
||||
super.delete(office);
|
||||
UserUtils.removeCache(UserUtils.CACHE_OFFICE_LIST);
|
||||
}
|
||||
|
||||
public List<SysOffice> selectOfficeForDeptment(Map map) {
|
||||
List<SysOffice> sysOfficeList=dao.selectOfficeForDeptment(map);
|
||||
return sysOfficeList;
|
||||
}
|
||||
|
||||
public List<SysOffice> selectOfficeForLetter(Map<String, Object> hmap) {
|
||||
List<SysOffice> sysOfficeList=dao.selectOfficeForLetter(hmap);
|
||||
return sysOfficeList;
|
||||
|
||||
}
|
||||
public List<SysOffice> selectLowerDeptement(Map<String, Object> hmap) {
|
||||
List<SysOffice> sysOfficeList=dao.selectLowerDeptement(hmap);
|
||||
return sysOfficeList;
|
||||
|
||||
}
|
||||
|
||||
public List<SysOffice> selectSysOffice(SysOffice sysOffice) {
|
||||
|
||||
return dao.selectSysOffice(sysOffice);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
80
src/main/java/com/nis/web/service/RoleService.java
Normal file
80
src/main/java/com/nis/web/service/RoleService.java
Normal file
@@ -0,0 +1,80 @@
|
||||
package com.nis.web.service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.SysRole;
|
||||
import com.nis.domain.SysUser;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.SysRoleDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
|
||||
@Service
|
||||
public class RoleService extends BaseService {
|
||||
@Autowired
|
||||
private SysRoleDao roleDao;
|
||||
|
||||
public List<SysRole> findAllRole() {
|
||||
return UserUtils.getRoleList();
|
||||
}
|
||||
|
||||
public SysRole getRole(Long id) {
|
||||
|
||||
return roleDao.get(id);
|
||||
}
|
||||
|
||||
|
||||
public SysRole getRoleByName(String name) {
|
||||
SysRole r = new SysRole();
|
||||
r.setName(name);
|
||||
return roleDao.getByName(r);
|
||||
}
|
||||
|
||||
|
||||
public void saveOrUpdate(SysRole role) {
|
||||
if (StringUtil.isEmpty(role.getId())){
|
||||
role.setCreateTime(new Date());
|
||||
role.setStatus(1);
|
||||
roleDao.insert(role);
|
||||
// 同步到Activiti
|
||||
//saveActivitiGroup(role);
|
||||
}else{
|
||||
roleDao.update(role);
|
||||
// 更新角色与菜单关联
|
||||
roleDao.deleteRoleMenu(role);
|
||||
}
|
||||
|
||||
if (role.getMenuList().size() > 0){
|
||||
roleDao.insertRoleMenu(role);
|
||||
}
|
||||
|
||||
// 同步到Activiti
|
||||
//saveActivitiGroup(role);
|
||||
// 清除用户角色缓存
|
||||
UserUtils.removeCache(UserUtils.CACHE_ROLE_LIST);
|
||||
List<SysUser> userList = roleDao.findUserByRole(role);
|
||||
for (SysUser user : userList) {
|
||||
UserUtils.clearCache(user);
|
||||
}
|
||||
|
||||
// // 清除权限缓存
|
||||
// systemRealm.clearAllCachedAuthorizationInfo();
|
||||
}
|
||||
|
||||
public void deleteRole(SysRole role) {
|
||||
roleDao.delete(role);
|
||||
// 同步到Activiti
|
||||
//deleteActivitiGroup(role);
|
||||
// 清除用户角色缓存
|
||||
//UserUtils.removeCache(UserUtils.CACHE_ROLE_LIST);
|
||||
UserUtils.clearCache();
|
||||
// // 清除权限缓存
|
||||
// systemRealm.clearAllCachedAuthorizationInfo();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
365
src/main/java/com/nis/web/service/SaveRequestLogThread.java
Normal file
365
src/main/java/com/nis/web/service/SaveRequestLogThread.java
Normal file
@@ -0,0 +1,365 @@
|
||||
/**
|
||||
*@Title: SaveLogThread.java
|
||||
*@Package com.nis.web.service.logthread
|
||||
*@Description TODO
|
||||
*@author dell
|
||||
*@date 2016年10月14日 下午6:26:41
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.web.service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.nis.datasource.CustomerContextHolder;
|
||||
|
||||
/**
|
||||
* @ClassName: SaveLogThread.java
|
||||
* @Description: TODO
|
||||
* @author (dell)
|
||||
* @date 2016年10月14日 下午6:26:41
|
||||
* @version V1.0
|
||||
*/
|
||||
public class SaveRequestLogThread implements Runnable {
|
||||
private Logger logger=Logger.getLogger(SaveRequestLogThread.class);
|
||||
private ServicesRequestLogService service;
|
||||
private String remoteAddr;
|
||||
private String requestURI;
|
||||
private String queryString;
|
||||
private String contextPath;
|
||||
private String operator;
|
||||
private String version;
|
||||
private int opAction;
|
||||
private Date opTime;
|
||||
private Object content;
|
||||
private Date requestTime;
|
||||
private long consumerTime;
|
||||
private int businessCode;
|
||||
private String exceptionInfo;
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
logger.info("线程开始执行!");
|
||||
//新开线程切换数据源,不影响action中的数据源
|
||||
CustomerContextHolder.setCustomerType(CustomerContextHolder.DATA_SOURCE_C);//开启数据源C
|
||||
// TODO Auto-generated method stub
|
||||
if(service!=null){
|
||||
service.saveRequestLog(remoteAddr,requestURI,queryString,contextPath, operator, version, opAction, opTime, content, requestTime, consumerTime,businessCode,exceptionInfo);
|
||||
}else{
|
||||
logger.error("service 为空!");
|
||||
}
|
||||
CustomerContextHolder.clearCustomerType();
|
||||
}
|
||||
public SaveRequestLogThread(){
|
||||
super();
|
||||
}
|
||||
/**
|
||||
* 创建一个新的实例 SaveRequestLogThread.
|
||||
*
|
||||
* @param service
|
||||
* @param requestAddr
|
||||
* @param requestURI
|
||||
* @param queryString
|
||||
* @param contextPath
|
||||
* @param operator
|
||||
* @param version
|
||||
* @param opAction
|
||||
* @param opTime
|
||||
* @param content
|
||||
* @param requestTime
|
||||
* @param consumerTime
|
||||
*/
|
||||
public SaveRequestLogThread(ServicesRequestLogService service, String remoteAddr, String requestURI,
|
||||
String queryString, String contextPath, String operator, String version, int opAction, Date opTime,
|
||||
Object content, Date requestTime, long consumerTime,String exceptionInfo) {
|
||||
super();
|
||||
this.service = service;
|
||||
this.remoteAddr = remoteAddr;
|
||||
this.requestURI = requestURI;
|
||||
this.queryString = queryString;
|
||||
this.contextPath = contextPath;
|
||||
this.operator = operator;
|
||||
this.version = version;
|
||||
this.opAction = opAction;
|
||||
this.opTime = opTime;
|
||||
this.content = content;
|
||||
this.requestTime = requestTime;
|
||||
this.consumerTime = consumerTime;
|
||||
this.exceptionInfo=exceptionInfo;
|
||||
}
|
||||
public SaveRequestLogThread(ServicesRequestLogService service,String operator, String version, int opAction, Date opTime,
|
||||
Object content, Date requestTime, long consumerTime,String exceptionInfo) {
|
||||
super();
|
||||
this.service = service;
|
||||
this.operator = operator;
|
||||
this.version = version;
|
||||
this.opAction = opAction;
|
||||
this.opTime = opTime;
|
||||
this.content = content;
|
||||
this.requestTime = requestTime;
|
||||
this.consumerTime = consumerTime;
|
||||
this.exceptionInfo=exceptionInfo;
|
||||
}
|
||||
|
||||
public static SaveRequestLogThread getNewSaveRequestLogThread(HttpServletRequest request){
|
||||
SaveRequestLogThread thread=new SaveRequestLogThread();
|
||||
thread.setRemoteAddr(request.getRemoteAddr());
|
||||
thread.setRequestURI(request.getRequestURI());
|
||||
thread.setQueryString(request.getQueryString());
|
||||
thread.setContextPath(request.getContextPath());
|
||||
thread.setRequestTime(new Date());
|
||||
BufferedReader reader=null;
|
||||
String line=null;
|
||||
StringBuilder bulider=new StringBuilder();
|
||||
try {
|
||||
reader=request.getReader();
|
||||
while((line=reader.readLine())!=null){
|
||||
bulider.append(line);
|
||||
bulider.append("\n");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
if(reader!=null){
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(bulider.toString().length()>0){
|
||||
thread.setContent(bulider.toString());
|
||||
}
|
||||
return thread;
|
||||
}
|
||||
/**
|
||||
* service
|
||||
* @return service
|
||||
*/
|
||||
|
||||
public ServicesRequestLogService getService() {
|
||||
return service;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param service the service to set
|
||||
*/
|
||||
public void setService(ServicesRequestLogService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
/**
|
||||
* remoteAddr
|
||||
* @return remoteAddr
|
||||
*/
|
||||
|
||||
public String getRemoteAddr() {
|
||||
return remoteAddr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param remoteAddr the remoteAddr to set
|
||||
*/
|
||||
public void setRemoteAddr(String remoteAddr) {
|
||||
this.remoteAddr = remoteAddr;
|
||||
}
|
||||
|
||||
/**
|
||||
* requestURI
|
||||
* @return requestURI
|
||||
*/
|
||||
|
||||
public String getRequestURI() {
|
||||
return requestURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param requestURI the requestURI to set
|
||||
*/
|
||||
public void setRequestURI(String requestURI) {
|
||||
this.requestURI = requestURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* queryString
|
||||
* @return queryString
|
||||
*/
|
||||
|
||||
public String getQueryString() {
|
||||
return queryString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param queryString the queryString to set
|
||||
*/
|
||||
public void setQueryString(String queryString) {
|
||||
this.queryString = queryString;
|
||||
}
|
||||
|
||||
/**
|
||||
* contextPath
|
||||
* @return contextPath
|
||||
*/
|
||||
|
||||
public String getContextPath() {
|
||||
return contextPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param contextPath the contextPath to set
|
||||
*/
|
||||
public void setContextPath(String contextPath) {
|
||||
this.contextPath = contextPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* operator
|
||||
* @return operator
|
||||
*/
|
||||
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param operator the operator to set
|
||||
*/
|
||||
public void setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* version
|
||||
* @return version
|
||||
*/
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param version the version to set
|
||||
*/
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
/**
|
||||
* opAction
|
||||
* @return opAction
|
||||
*/
|
||||
|
||||
public int getOpAction() {
|
||||
return opAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param opAction the opAction to set
|
||||
*/
|
||||
public void setOpAction(int opAction) {
|
||||
this.opAction = opAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* opTime
|
||||
* @return opTime
|
||||
*/
|
||||
|
||||
public Date getOpTime() {
|
||||
return opTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param opTime the opTime to set
|
||||
*/
|
||||
public void setOpTime(Date opTime) {
|
||||
this.opTime = opTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* content
|
||||
* @return content
|
||||
*/
|
||||
|
||||
public Object getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param content the content to set
|
||||
*/
|
||||
public void setContent(Object content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
/**
|
||||
* requestTime
|
||||
* @return requestTime
|
||||
*/
|
||||
|
||||
public Date getRequestTime() {
|
||||
return requestTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param requestTime the requestTime to set
|
||||
*/
|
||||
public void setRequestTime(Date requestTime) {
|
||||
this.requestTime = requestTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* consumerTime
|
||||
* @return consumerTime
|
||||
*/
|
||||
|
||||
public long getConsumerTime() {
|
||||
return consumerTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param consumerTime the consumerTime to set
|
||||
*/
|
||||
public void setConsumerTime(long consumerTime) {
|
||||
this.consumerTime = consumerTime;
|
||||
}
|
||||
/**
|
||||
* businessCode
|
||||
* @return businessCode
|
||||
*/
|
||||
|
||||
public int getBusinessCode() {
|
||||
return businessCode;
|
||||
}
|
||||
/**
|
||||
* @param businessCode the businessCode to set
|
||||
*/
|
||||
public void setBusinessCode(int businessCode) {
|
||||
this.businessCode = businessCode;
|
||||
}
|
||||
/**
|
||||
* exceptionInfo
|
||||
* @return exceptionInfo
|
||||
*/
|
||||
|
||||
public String getExceptionInfo() {
|
||||
return exceptionInfo;
|
||||
}
|
||||
/**
|
||||
* @param exceptionInfo the exceptionInfo to set
|
||||
*/
|
||||
public void setExceptionInfo(String exceptionInfo) {
|
||||
this.exceptionInfo = exceptionInfo;
|
||||
}
|
||||
}
|
||||
323
src/main/java/com/nis/web/service/ServicesRequestLogService.java
Normal file
323
src/main/java/com/nis/web/service/ServicesRequestLogService.java
Normal file
@@ -0,0 +1,323 @@
|
||||
/**
|
||||
*@Title: ServicesRequestLogService.java
|
||||
*@Package com.nis.web.service.restful
|
||||
*@Description TODO
|
||||
*@author wx
|
||||
*@date 2016年9月7日 下午3:28:44
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.web.service;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.ibatis.mapping.ResultMapping;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.datasource.DynamicDataSource;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.ServicesRequestLog;
|
||||
import com.nis.domain.restful.ServicesRequestLogBean;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.web.dao.ServicesRequestLogDao;
|
||||
|
||||
/**
|
||||
* @ClassName: ServicesRequestLogService.java
|
||||
* @Description: TODO
|
||||
* @author (wx)
|
||||
* @date 2016年9月7日 下午3:28:44
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class ServicesRequestLogService {
|
||||
protected final Logger logger = Logger.getLogger(this.getClass());
|
||||
@Autowired
|
||||
public ServicesRequestLogDao servicesRequestLogDao;
|
||||
|
||||
private void saveLog(ServicesRequestLog log) {
|
||||
servicesRequestLogDao.insert(log);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* saveRequestLog(记录请求日志) (这里描述这个方法适用条件 – 可选)
|
||||
*
|
||||
* @param requestAddr
|
||||
* request中的参数
|
||||
* @param requestURI
|
||||
* request中的参数
|
||||
* @param queryString
|
||||
* request中的参数
|
||||
* @param contextPath
|
||||
* request中的参数
|
||||
* @param request
|
||||
* 请求
|
||||
* @param response
|
||||
* 响应
|
||||
* @param operator
|
||||
* 操作人
|
||||
* @param version
|
||||
* 版本
|
||||
* @param opAction
|
||||
* 操作行为
|
||||
* @param opTime
|
||||
* 操作时间
|
||||
* @param content
|
||||
* 请求体
|
||||
* @param requestTime
|
||||
* 请求到达服务器时间
|
||||
* @param consumerTime
|
||||
* 耗时 void
|
||||
* @throws UnknownHostException
|
||||
* @exception @since
|
||||
* 1.0.0
|
||||
*/
|
||||
public void saveRequestLog(String requestAddr, String requestURI, String queryString, String contextPath,
|
||||
String operator, String version, int opAction, Date opTime, Object content, Date requestTime,
|
||||
long consumerTime, int businessCode, String exceptionInfo) {
|
||||
logger.info("开始记录日志---");
|
||||
logger.info("请求IP---" + requestAddr);
|
||||
logger.info("请求路径---" + requestURI);
|
||||
logger.info("请求内容---" + queryString);
|
||||
ServicesRequestLog log = new ServicesRequestLog();
|
||||
log.setRequestIp(requestAddr);
|
||||
log.setOperator(operator);
|
||||
log.setVersion(version);
|
||||
log.setOpAction(opAction);
|
||||
log.setVersion(version);
|
||||
log.setOpTime(opTime);
|
||||
log.setRequestTime(requestTime);
|
||||
log.setConsumerTime(consumerTime);
|
||||
log.setBusinessCode(businessCode);
|
||||
log.setExceptionInfo(exceptionInfo);
|
||||
try {
|
||||
if(Constants.SERVCER_HOST!=null){
|
||||
log.setServerIp(Constants.SERVCER_HOST);
|
||||
}else if(isWindows()){
|
||||
Constants.SERVCER_HOST=InetAddress.getLocalHost().getHostAddress();
|
||||
log.setServerIp(Constants.SERVCER_HOST);
|
||||
}else{
|
||||
InetAddress ip=null;
|
||||
boolean bFindIP=false;
|
||||
Enumeration<NetworkInterface> netInterfaces=(Enumeration<NetworkInterface>)
|
||||
NetworkInterface.getNetworkInterfaces();
|
||||
while(netInterfaces.hasMoreElements()){
|
||||
if(bFindIP){
|
||||
break;
|
||||
}
|
||||
NetworkInterface ni=(NetworkInterface)netInterfaces.nextElement();
|
||||
Enumeration<InetAddress> ips=ni.getInetAddresses();
|
||||
while(ips.hasMoreElements()){
|
||||
ip=(InetAddress)ips.nextElement();
|
||||
if(ip.isSiteLocalAddress()&&!ip.isLoopbackAddress()&&ip.getHostAddress().indexOf(":")==-1){
|
||||
bFindIP=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(null !=ip){
|
||||
Constants.SERVCER_HOST=ip.getHostAddress();
|
||||
log.setServerIp(ip.getHostAddress());
|
||||
}
|
||||
}
|
||||
|
||||
} catch (UnknownHostException e) {
|
||||
logger.error("无法获取当前服务器ip");
|
||||
e.printStackTrace();
|
||||
} catch (SocketException e) {
|
||||
// TODO Auto-generated catch block
|
||||
logger.error("无法获取当前服务器ip");
|
||||
e.printStackTrace();
|
||||
}
|
||||
String type = null;
|
||||
Pattern p = Pattern.compile(contextPath + "/service/([^/]+)/([^/]+)/");
|
||||
Matcher m = p.matcher(requestURI);
|
||||
if (m.find()) {
|
||||
type = m.group(1);
|
||||
logger.info("请求类型:" + type);
|
||||
}
|
||||
if (log.getVersion() == null)
|
||||
log.setVersion(m.group(2));
|
||||
if (opAction == Constants.OPACTION_GET) {// get请求不会携带boby
|
||||
if ("file".equals(type)) {// 文件下载
|
||||
log.setRequestContent(content.toString());
|
||||
} else {
|
||||
if (!StringUtils.isBlank(queryString)) {
|
||||
log.setRequestContent(queryString);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ("file".equals(type)) {// 文件上传
|
||||
log.setRequestContent(content.toString());
|
||||
} else {
|
||||
if (content != null) {
|
||||
log.setRequestContent(content.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
this.saveLog(log);
|
||||
logger.info("记录日志完成---");
|
||||
}
|
||||
public boolean isWindows(){
|
||||
boolean isWindows=false;
|
||||
if(System.getProperty("os.name").toLowerCase().indexOf("windows")>-1){
|
||||
isWindows=true;
|
||||
}
|
||||
return isWindows;
|
||||
}
|
||||
/**
|
||||
* 直接从数据源获取connection保存日志的方法,用saveLog()方法就行 save(这里用一句话描述这个方法的作用)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
*
|
||||
* @param data
|
||||
* @throws IllegalArgumentException
|
||||
* @throws IllegalAccessException
|
||||
* void
|
||||
* @exception @since
|
||||
* 1.0.0
|
||||
*/
|
||||
public void save(ServicesRequestLog data) throws IllegalArgumentException, IllegalAccessException {
|
||||
SqlSessionFactory sqlSessionFactory = SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
// map由于无序,不能用 columnMap生成sql语句
|
||||
Map<String, String> columnMap = new HashMap<String, String>();
|
||||
for (ResultMapping mapp : sqlSessionFactory.getConfiguration()
|
||||
.getResultMap(data.getClass().getSimpleName() + "Map").getResultMappings()) {
|
||||
columnMap.put(mapp.getProperty(), mapp.getColumn());
|
||||
}
|
||||
//
|
||||
DynamicDataSource dataSource = SpringContextHolder.getBean(DynamicDataSource.class);
|
||||
StringBuffer sql = new StringBuffer();
|
||||
String table = StringUtils.toUnderScoreCase(data.getClass().getSimpleName()).toUpperCase();
|
||||
sql.append("INSERT INTO ");
|
||||
sql.append(table);
|
||||
sql.append("(ID,");
|
||||
Field[] fields = data.getClass().getDeclaredFields();
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
fields[i].setAccessible(true);
|
||||
String fieldName = fields[i].getName();
|
||||
if (!"id".equals(fieldName) && columnMap.containsKey(fieldName) && fields[i].get(data) != null) {
|
||||
sql.append(columnMap.get(fieldName));
|
||||
sql.append(",");
|
||||
}
|
||||
}
|
||||
if (sql.lastIndexOf(",") == sql.toString().length() - 1) {
|
||||
sql.deleteCharAt(sql.toString().length() - 1);
|
||||
}
|
||||
sql.append(") values(SEQ_SERVICES_REQUEST_LOG.Nextval,");
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
if (columnMap.containsKey(fields[i].getName()) && fields[i].get(data) != null) {
|
||||
sql.append("?");
|
||||
sql.append(",");
|
||||
}
|
||||
}
|
||||
if (sql.lastIndexOf(",") == sql.toString().length() - 1) {
|
||||
sql.deleteCharAt(sql.toString().length() - 1);
|
||||
}
|
||||
sql.append(")");
|
||||
logger.info("日志新增sql:" + sql.toString());
|
||||
Connection connection = null;
|
||||
PreparedStatement prepareStatement = null;
|
||||
StringReader reader = null;
|
||||
try {
|
||||
connection = dataSource.getConnection();
|
||||
prepareStatement = connection.prepareStatement(sql.toString());
|
||||
int i = 1;
|
||||
for (Field field : fields) {
|
||||
if (columnMap.containsKey(field.getName())) {
|
||||
String type = field.getType().getSimpleName();
|
||||
if (field.get(data) == null)
|
||||
continue;
|
||||
if (type.equals("String")) {
|
||||
if (field.getName().equals("requestContent")) {
|
||||
String content = (String) field.get(data);
|
||||
reader = new StringReader(content);
|
||||
prepareStatement.setCharacterStream(i, reader, content.length());
|
||||
} else
|
||||
prepareStatement.setString(i, (String) (field.get(data)));
|
||||
} else if (type.equals("Long")) {
|
||||
prepareStatement.setLong(i, (Long) (field.get(data)));
|
||||
} else if (type.equals("Integer")) {
|
||||
prepareStatement.setInt(i, (Integer) (field.get(data)));
|
||||
} else if (type.equals("Date")) {
|
||||
java.sql.Date sqlDate = new java.sql.Date(((Date) field.get(data)).getTime());
|
||||
prepareStatement.setDate(i, sqlDate);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
prepareStatement.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
||||
try {
|
||||
if (prepareStatement != null) {
|
||||
prepareStatement.close();
|
||||
}
|
||||
if (connection != null) {
|
||||
connection.close();
|
||||
}
|
||||
if (reader != null)
|
||||
reader.close();
|
||||
} catch (SQLException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
if (prepareStatement != null) {
|
||||
prepareStatement.close();
|
||||
}
|
||||
if (connection != null) {
|
||||
connection.close();
|
||||
}
|
||||
if (reader != null)
|
||||
reader.close();
|
||||
} catch (SQLException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteById(String id) {
|
||||
String[] split = id.split(",");
|
||||
for (String str : split) {
|
||||
if(!str.equals("")){
|
||||
servicesRequestLogDao.deleteById(Long.parseLong(str));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteAll() {
|
||||
servicesRequestLogDao.deleteAll();
|
||||
}
|
||||
|
||||
public Page<ServicesRequestLogBean> getAllLog(Page<ServicesRequestLogBean> page,
|
||||
ServicesRequestLogBean requestLog) {
|
||||
requestLog.setPage(page);
|
||||
page.setList(servicesRequestLogDao.getAllLog(requestLog));
|
||||
return page;
|
||||
}
|
||||
|
||||
}
|
||||
88
src/main/java/com/nis/web/service/SpringContextHolder.java
Normal file
88
src/main/java/com/nis/web/service/SpringContextHolder.java
Normal file
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* Copyright © 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
|
||||
*/
|
||||
package com.nis.web.service;
|
||||
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* 以静态变量保存Spring ApplicationContext, 可在任何代码任何地方任何时候取出ApplicaitonContext.
|
||||
*
|
||||
* @author Zaric
|
||||
* @date 2013-5-29 下午1:25:40
|
||||
*/
|
||||
@Service
|
||||
@Lazy(false)
|
||||
public class SpringContextHolder implements ApplicationContextAware, DisposableBean {
|
||||
|
||||
private static ApplicationContext applicationContext = null;
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(SpringContextHolder.class);
|
||||
|
||||
/**
|
||||
* 取得存储在静态变量中的ApplicationContext.
|
||||
*/
|
||||
public static ApplicationContext getApplicationContext() {
|
||||
assertContextInjected();
|
||||
return applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getBean(String name) {
|
||||
assertContextInjected();
|
||||
return (T) applicationContext.getBean(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型.
|
||||
*/
|
||||
public static <T> T getBean(Class<T> requiredType) {
|
||||
assertContextInjected();
|
||||
return applicationContext.getBean(requiredType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除SpringContextHolder中的ApplicationContext为Null.
|
||||
*/
|
||||
public static void clearHolder() {
|
||||
if (logger.isDebugEnabled()){
|
||||
logger.debug("清除SpringContextHolder中的ApplicationContext:" + applicationContext);
|
||||
}
|
||||
applicationContext = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现ApplicationContextAware接口, 注入Context到静态变量中.
|
||||
*/
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
SpringContextHolder.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现DisposableBean接口, 在Context关闭时清理静态变量.
|
||||
*/
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
SpringContextHolder.clearHolder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查ApplicationContext不为空.
|
||||
*/
|
||||
private static void assertContextInjected() {
|
||||
Validate.validState(applicationContext != null, "applicaitonContext属性未注入, 请在applicationContext.xml中定义SpringContextHolder.");
|
||||
}
|
||||
}
|
||||
355
src/main/java/com/nis/web/service/SystemService.java
Normal file
355
src/main/java/com/nis/web/service/SystemService.java
Normal file
@@ -0,0 +1,355 @@
|
||||
package com.nis.web.service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import org.apache.axiom.om.OMAbstractFactory;
|
||||
import org.apache.axiom.om.OMElement;
|
||||
import org.apache.axiom.om.OMFactory;
|
||||
import org.apache.axiom.om.OMNamespace;
|
||||
import org.apache.axiom.om.impl.OMNamespaceImpl;
|
||||
import org.apache.axis2.AxisFault;
|
||||
import org.apache.axis2.addressing.EndpointReference;
|
||||
import org.apache.axis2.client.Options;
|
||||
import org.apache.axis2.client.ServiceClient;
|
||||
import org.apache.axis2.rpc.client.RPCServiceClient;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.shiro.session.Session;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.SrcIp;
|
||||
import com.nis.domain.SysRole;
|
||||
import com.nis.domain.SysUser;
|
||||
import com.nis.domain.WebServiceClient;
|
||||
import com.nis.util.Configurations;
|
||||
import com.nis.util.DateUtils;
|
||||
import com.nis.util.IpUtil;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.TimeConstants;
|
||||
import com.nis.web.dao.SrcIpDao;
|
||||
import com.nis.web.dao.SysOfficeDao;
|
||||
import com.nis.web.dao.UserDao;
|
||||
import com.nis.web.security.Servlets;
|
||||
import com.nis.web.security.SessionDAO;
|
||||
import com.nis.web.security.UserUtils;
|
||||
|
||||
@Service
|
||||
public class SystemService extends BaseService{
|
||||
|
||||
@Autowired
|
||||
private SessionDAO sessionDao;
|
||||
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
|
||||
@Autowired
|
||||
private SysOfficeDao sysOfficeDao;
|
||||
|
||||
@Autowired
|
||||
private SrcIpDao srcIpDao;
|
||||
|
||||
|
||||
public Collection<Session> getActiveSessions(boolean includeLeave) {
|
||||
return sessionDao.getActiveSessions(includeLeave);
|
||||
}
|
||||
|
||||
|
||||
public Collection<Session> getActiveSessions(boolean includeLeave, Object principal, Session filterSession) {
|
||||
return sessionDao.getActiveSessions(includeLeave, principal, filterSession);
|
||||
}
|
||||
|
||||
public void deleteSession(Session session) {
|
||||
sessionDao.delete(session);
|
||||
}
|
||||
|
||||
|
||||
public SysUser getUserByLoginName(String loginName) {
|
||||
return UserUtils.getByLoginName(loginName);
|
||||
}
|
||||
|
||||
public List<SrcIp> ipLookUp(String ip) {
|
||||
return srcIpDao.getIpInfo(IpUtil.getIpHostDesimal(ip));
|
||||
}
|
||||
|
||||
|
||||
public SysUser assignUserToRole(SysRole role, SysUser user) {
|
||||
if (user == null){
|
||||
return null;
|
||||
}
|
||||
List<Long> roleIds = user.getRoleIdList();
|
||||
if (roleIds.contains(role.getId())) {
|
||||
return null;
|
||||
}
|
||||
user.getUserRoleList().clear();
|
||||
user.getUserRoleList().add(role);
|
||||
userDao.insertUserRole(user);
|
||||
UserUtils.clearCache(user);
|
||||
return user;
|
||||
}
|
||||
|
||||
public Boolean outUserInRole(SysRole role, SysUser user) {
|
||||
List<SysRole> roles = user.getUserRoleList();
|
||||
for (SysRole e : roles){
|
||||
if (e.getId().equals(role.getId())){
|
||||
roles.remove(e);
|
||||
userDao.removeUserInRole(user.getId(),role.getId());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean officeIsValid(Long officeId, Long companyId) {
|
||||
return userDao.officeIsExistOfCompany(officeId, companyId) >0 ? true : false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 用户机构
|
||||
* @param client
|
||||
* @return
|
||||
*/
|
||||
private String getOAServiceData(WebServiceClient client) {
|
||||
ServiceClient sender = null;
|
||||
String result = "";
|
||||
try {
|
||||
sender = new ServiceClient();
|
||||
EndpointReference endpointReference = new EndpointReference(client.getEndPoint());
|
||||
Options options = new Options();
|
||||
options.setAction(client.getNs()+"/"+client.getMethodName());
|
||||
options.setTo(endpointReference);
|
||||
sender.setOptions(options);
|
||||
//添加soapheader验证消息头
|
||||
sender.addHeader(setHeader(client.getNs(), client.getRid(), client.getSid()));
|
||||
OMFactory fac = OMAbstractFactory.getOMFactory();
|
||||
// 设置命名空间
|
||||
OMNamespace omNs = fac.createOMNamespace(client.getNs(), "");
|
||||
//OMElement data = fac.createOMElement("服务输入接口", omNs);
|
||||
OMElement data = fac.createOMElement(client.getMethodName(),client.getNs(),"");
|
||||
// 对应参数的节点
|
||||
//String[] strs = new String[] { "pageSize","currentPage","param" };
|
||||
String[] strs = client.getOpArgs();
|
||||
// 参数值
|
||||
String[] vals = client.getOpVals();
|
||||
for (int i = 0; i < strs.length; i++) {
|
||||
OMElement inner = fac.createOMElement(strs[i],"","");
|
||||
inner.setText(vals[i]);
|
||||
data.addChild(inner);
|
||||
}
|
||||
// 发送数据,返回结果
|
||||
OMElement resultE = sender.sendReceive(data);
|
||||
result = resultE.toString();
|
||||
result = result.replaceAll("<", "<");
|
||||
result = result.replaceAll(">", ">");
|
||||
result = result.substring( result.indexOf("<returnData>"), result.indexOf("</returnData>")+13);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
try {
|
||||
sender.cleanupTransport();
|
||||
} catch (AxisFault e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param client webservice 客户端对象
|
||||
* @return
|
||||
*/
|
||||
private String getOAServiceData_old(WebServiceClient client) throws Exception {
|
||||
String result = null;
|
||||
RPCServiceClient serviceClient = null;
|
||||
try {
|
||||
serviceClient = new RPCServiceClient();
|
||||
Options options = serviceClient.getOptions();
|
||||
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.CONNECTION_TIMEOUT, client.getConnectionTimeOut()*1000);
|
||||
EndpointReference targetEPR = new EndpointReference(client.getEndPoint());
|
||||
|
||||
// ====================新增 添加header ========================start
|
||||
serviceClient.addHeader(setHeader(client.getNs(), client.getRid(), client.getSid()));
|
||||
// ====================新增 添加header ========================end
|
||||
|
||||
// 原有业务逻辑不动
|
||||
options.setTo(targetEPR);
|
||||
QName opAddEntry = new QName(client.getNs(), client.getMethodName());
|
||||
|
||||
Class[] returnTypes = new Class[] { String.class };
|
||||
String[] opVals = new String[]{String.valueOf(client.getPageSize()),String.valueOf(client.getCurrentPage()),"", "MB_HR_CY_JSSF"};
|
||||
// 调用plus方法并输出该方法的返回值
|
||||
result =serviceClient.invokeBlocking(opAddEntry,client.getOpVals(), returnTypes)[0].toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("get OA data error :"+e);
|
||||
} finally {
|
||||
serviceClient.cleanupTransport();
|
||||
}
|
||||
|
||||
//result = getTestFormXml();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 结果信息存入文件
|
||||
* @param result
|
||||
* @throws IOException
|
||||
*/
|
||||
private void saveToFile(String prefixName, String result) throws IOException{
|
||||
String flieName = prefixName + DateUtils.formatDate(new Date(), TimeConstants.YYYYMMDDHH24MMSS);
|
||||
String filePath = Servlets.getRequest().getServletContext().getRealPath(Configurations.getStringProperty("userfiles.basedir", "")) + File.separator
|
||||
+ "upload" + File.separator + flieName + ".txt";
|
||||
FileUtils.writeStringToFile(new File(filePath), result, false);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设置header信息,需要修改里面rid、sid对应的值、sid为服务唯一标识、 rid为请求者唯一标识
|
||||
*/
|
||||
private static OMElement setHeader(String ns, String rid, String sid) {
|
||||
OMFactory fac = OMAbstractFactory.getOMFactory();
|
||||
// OMNamespace指定此SOAP文档名称空间。
|
||||
OMNamespaceImpl omNs = (OMNamespaceImpl) fac.createOMNamespace(ns, "ns1");
|
||||
// 创建header元素,并指定其在omNs指代的名称空间中,header名称固定为CyberpoliceSBReqHeader。
|
||||
OMElement method = fac.createOMElement("CyberpoliceSBReqHeader", omNs);
|
||||
|
||||
// 指定元素的文本内容。
|
||||
OMElement ridE = fac.createOMElement("rid", omNs);
|
||||
// TODO将下面的值修改为请求者在系统中的唯一标识
|
||||
ridE.setText(rid);
|
||||
method.addChild(ridE);
|
||||
|
||||
OMElement sidE = fac.createOMElement("sid", omNs);
|
||||
// TODO将下面的值修改要请求服务的唯一标识
|
||||
sidE.setText(sid);
|
||||
method.addChild(sidE);
|
||||
|
||||
OMElement timeoutE = fac.createOMElement("timeout", omNs);
|
||||
// TODO将下面的值修改为请求的超时时间,单位秒
|
||||
timeoutE.setText(Configurations.getStringProperty("webservice.request.timeout", "60"));
|
||||
method.addChild(timeoutE);
|
||||
|
||||
OMElement secE = fac.createOMElement("sec", omNs);
|
||||
// TODO将下面的值修改为请求密码,如果使用其他加密方式,则根据要求统一修改即可
|
||||
secE.setText("");
|
||||
method.addChild(secE);
|
||||
return method;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取数据字典信息
|
||||
* @param method
|
||||
* @param date
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public String syncDataDict(String method) throws Exception {
|
||||
|
||||
String methodName = null;
|
||||
String ns = Configurations.getStringProperty("webservice.data.dict.service.url", "");
|
||||
String rid = Configurations.getStringProperty("webservice.rid", "");
|
||||
String sid = Configurations.getStringProperty("webservice.data.dict.sid", "");
|
||||
if (method.equals("QL")) {
|
||||
methodName = Configurations.getStringProperty("webservice.method.name.ql", "");
|
||||
}
|
||||
WebServiceClient webServiceClient = new WebServiceClient(ns, methodName, rid, sid, null);
|
||||
|
||||
|
||||
Map<String, Integer> resultMap = new HashMap<String, Integer>();
|
||||
resultMap.put("dataCount", 0);
|
||||
resultMap.put("insertCount", 0);
|
||||
resultMap.put("updateCount", 0);
|
||||
resultMap.put("deleteCount", 0);
|
||||
resultMap.put("invalid", 0);
|
||||
Date syncTime = null;
|
||||
try{
|
||||
|
||||
while(true) {
|
||||
String result = getOAServiceData(webServiceClient);
|
||||
if (StringUtil.isBlank(result)) {
|
||||
break;
|
||||
}
|
||||
logger.info(result);
|
||||
webServiceClient.incrementPage();//next page
|
||||
}
|
||||
|
||||
logger.info("同步用户数据总计:"+resultMap.get("dataCount"));
|
||||
|
||||
//saveDataResult(resultMap.get("dataCount"),resultMap.get("insertCount"),
|
||||
//resultMap.get("updateCount"),resultMap.get("deleteCount"),resultMap.get("invalid"),Constants.SYNC_YH,methodName.equals("getData")?Constants.SYNC_QL:Constants.SYNC_ZL,syncTime);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
return "同步失败,获取数据异常!"+e;
|
||||
}
|
||||
|
||||
return "同步完成! 数据总数量:" + resultMap.get("dataCount") +"; 插入数量:" +resultMap.get("insertCount")+"; 更新数量:"
|
||||
+resultMap.get("updateCount") +"; 删除数量:" +resultMap.get("deleteCount")+"; 无效数量"+resultMap.get("invalid");
|
||||
|
||||
}
|
||||
|
||||
public String syncDataDictBM(String method) throws Exception{
|
||||
String methodName = null;
|
||||
String ns = Configurations.getStringProperty("webservice.data.dict.bm.url", "");
|
||||
String rid = Configurations.getStringProperty("webservice.rid", "");
|
||||
String sid = Configurations.getStringProperty("webservice.data.dict.bm.sid", "");
|
||||
if (method.equals("QL")) {
|
||||
methodName = Configurations.getStringProperty("webservice.method.name.ql", "");
|
||||
}
|
||||
WebServiceClient webServiceClient = new WebServiceClient(ns, methodName, rid, sid, null);
|
||||
String result = null;
|
||||
try {
|
||||
result = getOAServiceData(webServiceClient);
|
||||
} catch (Exception e) {
|
||||
return "同步失败,获取数据异常!"+e;
|
||||
}
|
||||
return result ;
|
||||
}
|
||||
|
||||
|
||||
public String syncDataDictCode(String method) throws Exception{
|
||||
String methodName = null;
|
||||
String ns = Configurations.getStringProperty("webservice.data.code.url", "");
|
||||
String rid = Configurations.getStringProperty("webservice.rid", "");
|
||||
String sid = Configurations.getStringProperty("webservice.data.dict.code.sid", "");
|
||||
if (method.equals("QL")) {
|
||||
methodName = Configurations.getStringProperty("webservice.method.name.ql", "");
|
||||
}
|
||||
WebServiceClient webServiceClient = new WebServiceClient(ns, methodName, rid, sid, null);
|
||||
String result = null;
|
||||
try {
|
||||
result = getOAServiceData(webServiceClient);
|
||||
saveToFile("DataDictCode", result);
|
||||
} catch (Exception e) {
|
||||
return "同步失败,获取数据异常!"+e;
|
||||
}
|
||||
return result ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
81
src/main/java/com/nis/web/service/TreeService.java
Normal file
81
src/main/java/com/nis/web/service/TreeService.java
Normal file
@@ -0,0 +1,81 @@
|
||||
|
||||
package com.nis.web.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.nis.domain.TreeEntity;
|
||||
import com.nis.exceptions.ServiceException;
|
||||
import com.nis.util.Reflections;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.web.dao.TreeDao;
|
||||
|
||||
/**
|
||||
* Service基类
|
||||
* @author ThinkGem
|
||||
* @version 2014-05-16
|
||||
*/
|
||||
public abstract class TreeService<D extends TreeDao<T>, T extends TreeEntity<T>> extends CrudService<D, T> {
|
||||
|
||||
public void save(T entity) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<T> entityClass = Reflections.getClassGenricType(getClass(), 1);
|
||||
|
||||
// 如果没有设置父节点,则代表为跟节点,有则获取父节点实体
|
||||
if (entity.getParent() == null || StringUtil.isEmpty(entity.getParentId())
|
||||
|| "0".equals(entity.getParentId())){
|
||||
entity.setParent(null);
|
||||
}else{
|
||||
entity.setParent(super.get(entity.getParentId()));
|
||||
}
|
||||
if (entity.getParent() == null){
|
||||
T parentEntity = null;
|
||||
try {
|
||||
parentEntity = entityClass.getConstructor(Long.class).newInstance(0l);
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException(e);
|
||||
}
|
||||
entity.setParent(parentEntity);
|
||||
entity.getParent().setParentIds(StringUtils.EMPTY);
|
||||
}
|
||||
|
||||
// 获取修改前的parentIds,用于更新子节点的parentIds
|
||||
String oldParentIds = entity.getParentIds();
|
||||
|
||||
// 设置新的父节点串
|
||||
entity.setParentIds(entity.getParent().getParentIds()+entity.getParent().getId()+",");
|
||||
|
||||
// 保存或更新实体
|
||||
super.save(entity);
|
||||
|
||||
// 更新子节点 parentIds
|
||||
T o = null;
|
||||
try {
|
||||
o = entityClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException(e);
|
||||
}
|
||||
o.setParentIds("%,"+entity.getId()+",%");
|
||||
List<T> list = dao.findByParentIdsLike(o);
|
||||
for (T e : list){
|
||||
if (e.getParentIds() != null && oldParentIds != null){
|
||||
e.setParentIds(e.getParentIds().replace(oldParentIds, entity.getParentIds()));
|
||||
preUpdateChild(entity, e);
|
||||
dao.updateParentIds(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 预留接口,用户更新子节前调用
|
||||
* @param childEntity
|
||||
*/
|
||||
protected void preUpdateChild(T entity, T childEntity) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
162
src/main/java/com/nis/web/service/UserService.java
Normal file
162
src/main/java/com/nis/web/service/UserService.java
Normal file
@@ -0,0 +1,162 @@
|
||||
package com.nis.web.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.SysUser;
|
||||
import com.nis.exceptions.ServiceException;
|
||||
import com.nis.util.CacheUtils;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.web.dao.UserDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
|
||||
@Service
|
||||
public class UserService extends BaseService {
|
||||
/**@Resource**/
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public SysUser getUser(String id) {
|
||||
return UserUtils.get(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Page<SysUser> findUser(Page<SysUser> page, SysUser user) {
|
||||
// 生成数据权限过滤条件(dsf为dataScopeFilter的简写,在xml中使用 ${sqlMap.dsf}调用权限SQL)
|
||||
user.getSqlMap().put("dsf", dataScopeFilter(user.getCurrentUser(), "o", "u"));
|
||||
// 设置分页参数
|
||||
user.setPage(page);
|
||||
// 执行分页查询
|
||||
page.setList(userDao.findList(user));
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public SysUser getUserById(Long id) {
|
||||
return userDao.getUserById(id);
|
||||
}
|
||||
|
||||
public SysUser getUserByLoginName(String loginName) {
|
||||
return userDao.getUserByLoginName(loginName);
|
||||
}
|
||||
|
||||
|
||||
public SysUser getUserByIdWithRelation(Long userId) {
|
||||
return userDao.getUserWithRelation(new SysUser(userId, null));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void saveOrUpdate(SysUser user) {
|
||||
|
||||
if (StringUtil.isEmpty(user.getId())) {
|
||||
user.setCreateTime(new Date());
|
||||
user.setStatus(1);
|
||||
userDao.insert(user);
|
||||
} else {
|
||||
SysUser oldUser = userDao.getUserWithRelation(user);
|
||||
// 清除原用户机构用户缓存
|
||||
if (!StringUtil.isEmpty(oldUser.getOffice())) {
|
||||
CacheUtils.remove(UserUtils.USER_CACHE, UserUtils.USER_CACHE_LIST_BY_OFFICE_ID_ + oldUser.getOffice().getId());
|
||||
}
|
||||
|
||||
userDao.update(user);
|
||||
userDao.deleteUserRole(user.getId());
|
||||
|
||||
//userDao.deleteUserOffice(user.getId());
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*if (!StringUtil.isEmpty(user.getOffice())) {
|
||||
user.addOffice(user.getOffice());
|
||||
userDao.insertUserOffice(user);
|
||||
}else {
|
||||
throw new ServiceException(user.getLoginId() + "没有设置部门!");
|
||||
}*/
|
||||
|
||||
if (!StringUtil.isEmpty(user.getUserRoleList())) {
|
||||
userDao.insertUserRole(user);
|
||||
} else {
|
||||
throw new ServiceException(user.getLoginId() + "没有设置角色!");
|
||||
}
|
||||
|
||||
// 将当前用户同步到Activiti
|
||||
//saveActivitiUser(user);
|
||||
UserUtils.clearCache(user);
|
||||
// 清除权限缓存
|
||||
//systemRealm.clearAllCachedAuthorizationInfo();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void deleteUser(SysUser user) {
|
||||
userDao.delete(user);
|
||||
// 同步到Activiti
|
||||
//deleteActivitiUser(user);
|
||||
// 清除用户缓存
|
||||
UserUtils.clearCache(user);
|
||||
// // 清除权限缓存
|
||||
// systemRealm.clearAllCachedAuthorizationInfo();
|
||||
}
|
||||
|
||||
|
||||
public void updatePasswordById(Long id, String loginId, String newPassword) {
|
||||
SysUser user = new SysUser(id,loginId);
|
||||
user.setPassword(StringUtils.entryptPassword(newPassword));
|
||||
userDao.updatePasswordById(user);
|
||||
UserUtils.clearCache(user);
|
||||
// // 清除权限缓存
|
||||
// systemRealm.clearAllCachedAuthorizationInfo();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public List<SysUser> findUserByRoleId(Long id) {
|
||||
return userDao.findUserByRoleId(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<SysUser> findUserByOfficeId(Long id) {
|
||||
return userDao.findUserByOfficeId(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void updateUserInfo(SysUser user) {
|
||||
userDao.updateUserInfo(user);
|
||||
// 清除用户缓存
|
||||
UserUtils.clearCache(user);
|
||||
// // 清除权限缓存
|
||||
// systemRealm.clearAllCachedAuthorizationInfo();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public List<Map> findDeptLeader(Integer DeptementId){
|
||||
return userDao.findDeptLeader(DeptementId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.restful.ConfigPzIdSource;
|
||||
import com.nis.web.dao.ConfigPzIdDao;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
|
||||
/**
|
||||
* @ClassName:ConfigPzIdService
|
||||
* @Description:TODO(这里用一句话描述这个类的作用)
|
||||
* @author (zdx)
|
||||
* @date 2017年9月20日 上午10:43:36
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class ConfigPzIdService extends BaseLogService {
|
||||
|
||||
protected final Logger logger = Logger.getLogger(this.getClass());
|
||||
/**
|
||||
* 持久层对象
|
||||
*/
|
||||
@Autowired
|
||||
protected ConfigPzIdDao dao;
|
||||
|
||||
public ConfigPzIdSource getConfigPzIdList(ConfigPzIdSource entity){
|
||||
List<Long> pzIdList = new ArrayList<Long>();
|
||||
entity.setSourceName(entity.getSourceName().toUpperCase());
|
||||
for (int i = 0; i < entity.getNum(); i++) {
|
||||
pzIdList.add(dao.getConfigPzIdList(entity));
|
||||
}
|
||||
entity.setPzIdList(pzIdList);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
2007
src/main/java/com/nis/web/service/restful/ConfigSourcesService.java
Normal file
2007
src/main/java/com/nis/web/service/restful/ConfigSourcesService.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @Title: ControlService.java
|
||||
* @Package com.nis.web.service.restful
|
||||
* @Description: TODO(用一句话描述该文件做什么)
|
||||
* @author (darnell)
|
||||
* @date 2016年8月15日 下午4:08:12
|
||||
* @version V1.0
|
||||
*/
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.ControlLog;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.web.dao.ControlLogDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
|
||||
/**
|
||||
* @ClassName: ControlService
|
||||
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||
* @author (darnell)
|
||||
* @date 2016年8月15日 下午4:08:12
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class ControlLogService extends CrudService<ControlLogDao, ControlLog>{
|
||||
|
||||
@Autowired
|
||||
public ControlLogDao logDao;
|
||||
|
||||
public Page<ControlLog> getLogInfo(Page<ControlLog> page, ControlLog log) {
|
||||
return findPage(page, log);
|
||||
}
|
||||
|
||||
public ControlLog findById(long id) {
|
||||
return get(id);
|
||||
}
|
||||
|
||||
public void createControlLog(ControlLog log) {
|
||||
logDao.saveControlLog(log);
|
||||
}
|
||||
|
||||
public void deleteControlLog(long id) {
|
||||
logDao.removeControlLog(id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DataDictionaryName;
|
||||
import com.nis.domain.restful.DataDictionaryValue;
|
||||
import com.nis.web.dao.DataDictionaryDao;
|
||||
|
||||
@Service
|
||||
public class DataDictionaryService {
|
||||
protected final Logger logger1 = Logger.getLogger(this.getClass());
|
||||
@Autowired
|
||||
private DataDictionaryDao dataDictionaryDao;
|
||||
|
||||
public Map<String, List<DataDictionaryValue>> getAllDataDict() {
|
||||
Map<String, List<DataDictionaryValue>> map = new HashMap<String, List<DataDictionaryValue>>();
|
||||
List<DataDictionaryValue> allDictName = dataDictionaryDao.getAllDictName(new DataDictionaryValue());
|
||||
for (DataDictionaryValue dictVal : allDictName) {
|
||||
if (map.containsKey(dictVal.getDataDictName())) {
|
||||
map.get(dictVal.getDataDictName()).add(dictVal);
|
||||
} else {
|
||||
List<DataDictionaryValue> list = new ArrayList<DataDictionaryValue>();
|
||||
list.add(dictVal);
|
||||
map.put(dictVal.getDataDictName(), list);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public Page<DataDictionaryValue> getDataDictList(Page<DataDictionaryValue> page, DataDictionaryValue entity) {
|
||||
entity.setPage(page);
|
||||
page.setList(dataDictionaryDao.getAllDictName(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public List<DataDictionaryName> getDataDictList() {
|
||||
return dataDictionaryDao.selAllDictName();
|
||||
}
|
||||
|
||||
public String saveDataDict(String dataDictId, String addDictName, String dictVal, String option) {
|
||||
if (null != option && option.equals("addName")) {
|
||||
DataDictionaryName dataDictionaryName = new DataDictionaryName(addDictName);
|
||||
dataDictionaryDao.addDictName(dataDictionaryName);
|
||||
return "ok";
|
||||
} else if (null != option && option.equals("addValue")) {
|
||||
String[] split = dictVal.split(",");
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
dataDictionaryDao.addDictValue(new DataDictionaryValue(Long.parseLong(dataDictId), split[i]));
|
||||
}
|
||||
return "ok";
|
||||
} else if (null != option && option.equals("addNameAndValue")) {
|
||||
DataDictionaryName dataDictionaryName = new DataDictionaryName(addDictName);
|
||||
dataDictionaryDao.addDictName(dataDictionaryName);
|
||||
Long dictNameId = dataDictionaryName.getDictNameId();
|
||||
String[] split = dictVal.split(",");
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
dataDictionaryDao.addDictValue(new DataDictionaryValue(dictNameId, split[i]));
|
||||
}
|
||||
return "ok";
|
||||
} else {
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
public String delDictVal(String id) {
|
||||
if (id.contains(",")) {
|
||||
id = id.replace("[", "").replace("]", "");
|
||||
String[] idArr = id.split(",");
|
||||
for (String str : idArr) {
|
||||
if (null != str && !str.equals("")) {
|
||||
dataDictionaryDao.updateDictValue(new DataDictionaryValue(Long.parseLong(str), 0l));
|
||||
}
|
||||
}
|
||||
return "ok";
|
||||
} else {
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
public String delDictName(String id) {
|
||||
if (id.contains(",")) {
|
||||
id = id.replace("[", "").replace("]", "");
|
||||
String[] idArr = id.split(",");
|
||||
for (String str : idArr) {
|
||||
if (null != str && !str.equals("")) {
|
||||
dataDictionaryDao.updateDictName(new DataDictionaryName(Long.parseLong(str), 0l));
|
||||
DataDictionaryValue dictVal = new DataDictionaryValue();
|
||||
dictVal.setDictNameId(Long.parseLong(str));
|
||||
dictVal.setIsValid(0l);
|
||||
dataDictionaryDao.updateDictValue(dictVal);
|
||||
}
|
||||
}
|
||||
return "ok";
|
||||
} else {
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
public DataDictionaryValue getDict(String id) {
|
||||
Long dictId = null;
|
||||
if (id.contains(",")) {
|
||||
id = id.replace("[", "").replace("]", "");
|
||||
String[] idArr = id.split(",");
|
||||
for (String str : idArr) {
|
||||
if (null != str && !str.equals("")) {
|
||||
dictId = Long.parseLong(str);
|
||||
}
|
||||
}
|
||||
if (null == dictId) {
|
||||
return null;
|
||||
}
|
||||
List<DataDictionaryValue> allDictName = dataDictionaryDao.getAllDictName(new DataDictionaryValue(dictId));
|
||||
return allDictName.get(0);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String updateDataDict(String dictVal, String dictId, String option) {
|
||||
if (null != option && option.equals("updateVal")) {// 修改值
|
||||
dataDictionaryDao.updateDictValue(new DataDictionaryValue(Long.parseLong(dictId), null, dictVal));
|
||||
return "ok";
|
||||
} else {
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DfDjNestLog;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.DfDjNestLogDao;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
import com.nis.web.service.SaveRequestLogThread;
|
||||
|
||||
/**
|
||||
* @ClassName: DfDjNestLogService
|
||||
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||
* @author (zbc)
|
||||
* @date 2016年11月11日 下午4:40:00
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DfDjNestLogService extends BaseLogService {
|
||||
protected final Logger logger = Logger.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
protected DfDjNestLogDao dao;
|
||||
|
||||
|
||||
public Page<DfDjNestLog> findDfDjNestLogPage(Page<DfDjNestLog> page, DfDjNestLog entity) {
|
||||
entity.setPage(page);
|
||||
page.setList(dao.findDfDjNestLogPage(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public void queryConditionCheck(SaveRequestLogThread thread, long start, DfDjNestLog entity, Class<DfDjNestLog> clazz, Page<?> page) {
|
||||
|
||||
if(StringUtil.isBlank(entity.getSearchLayerId())) {
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchLayerId查询参数不能为空",
|
||||
RestBusinessCode.missing_args.getValue());
|
||||
}
|
||||
|
||||
try {
|
||||
checkCloumnIsExist(thread,start,clazz, page);
|
||||
} catch (RestServiceException e) {
|
||||
logger.error(e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请求参数错误");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
*@Title: DfIpPortUdpService.java
|
||||
*@Package com.nis.web.service.restful
|
||||
*@Description TODO
|
||||
*@author wx
|
||||
*@date 2016年9月7日 下午3:28:44
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DfIpPortUdp;
|
||||
import com.nis.web.dao.DfIpPortUdpDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
|
||||
/**
|
||||
* @ClassName: DfIpPortUdpService.java
|
||||
* @Description: TODO
|
||||
* @author (wx)
|
||||
* @date 2016年9月7日 下午3:28:44
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DfIpPortUdpService extends CrudService<DfIpPortUdpDao, DfIpPortUdp> {
|
||||
@Autowired
|
||||
public DfIpPortUdpDao dfIpPortUdpDao;
|
||||
public void saveDfIpPortUdpBatch(List<DfIpPortUdp> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
super.saveBatch(entity,DfIpPortUdpDao.class);
|
||||
}
|
||||
public void updateDfIpPortUdpBatch(List<DfIpPortUdp> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
super.updateBatch(entity, DfIpPortUdpDao.class);
|
||||
}
|
||||
public void removeDfIpPortUdp(long id) {
|
||||
dfIpPortUdpDao.delete(id);
|
||||
}
|
||||
public void removeDfIpPortUdpBatch(List<DfIpPortUdp> entity) {
|
||||
super.deleteBatch(entity, DfIpPortUdpDao.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DfJitAffairDestReport;
|
||||
import com.nis.domain.restful.DfJitAffairSrcReport;
|
||||
import com.nis.domain.restful.DfJitFlDestReport;
|
||||
import com.nis.domain.restful.DfJitFlSrcReport;
|
||||
import com.nis.domain.restful.DfJitGuaranteeDestReport;
|
||||
import com.nis.domain.restful.DfJitGuaranteeSrcReport;
|
||||
import com.nis.domain.restful.DfJitIdDestReport;
|
||||
import com.nis.domain.restful.DfJitIdSrcReport;
|
||||
import com.nis.domain.restful.DfJitMissionDestReport;
|
||||
import com.nis.domain.restful.DfJitMissionSrcReport;
|
||||
import com.nis.domain.restful.DfJitTagDestReport;
|
||||
import com.nis.domain.restful.DfJitTagSrcReport;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.DfJitLogSearchDao;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
import com.nis.web.service.SaveRequestLogThread;
|
||||
|
||||
@Service
|
||||
public class DfJitLogSearchService extends BaseLogService {
|
||||
|
||||
@Autowired
|
||||
private DfJitLogSearchDao dfJitLogSearchDao;
|
||||
|
||||
public Page<DfJitFlSrcReport> findDfJitFlSrcReport(Page<DfJitFlSrcReport> page, DfJitFlSrcReport entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(dfJitLogSearchDao.findDfJitFlSrcReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfJitFlDestReport> findDfJitFlDestReport(Page<DfJitFlDestReport> page, DfJitFlDestReport entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(dfJitLogSearchDao.findDfJitFlDestReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfJitAffairSrcReport> findDfJitAffairSrcReport(Page<DfJitAffairSrcReport> page,
|
||||
DfJitAffairSrcReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(dfJitLogSearchDao.findDfJitAffairSrcReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfJitAffairDestReport> findDfJitAffairDestReport(Page<DfJitAffairDestReport> page,
|
||||
DfJitAffairDestReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(dfJitLogSearchDao.findDfJitAffairDestReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
public Page<DfJitMissionSrcReport> findDfJitMissionSrcReport(Page<DfJitMissionSrcReport> page,
|
||||
DfJitMissionSrcReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(dfJitLogSearchDao.findDfJitMissionSrcReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfJitMissionDestReport> findDfJitMissionDestReport(Page<DfJitMissionDestReport> page,
|
||||
DfJitMissionDestReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(dfJitLogSearchDao.findDfJitMissionDestReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfJitGuaranteeSrcReport> findDfJitGuaranteeSrcReport(Page<DfJitGuaranteeSrcReport> page,
|
||||
DfJitGuaranteeSrcReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(dfJitLogSearchDao.findDfJitGuaranteeSrcReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfJitGuaranteeDestReport> findDfJitGuaranteeDestReport(Page<DfJitGuaranteeDestReport> page,
|
||||
DfJitGuaranteeDestReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(dfJitLogSearchDao.findDfJitGuaranteeDestReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfJitTagSrcReport> findDfJitTagSrcReport(Page<DfJitTagSrcReport> page, DfJitTagSrcReport entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(dfJitLogSearchDao.findDfJitTagSrcReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfJitTagDestReport> findDfJitTagDestReport(Page<DfJitTagDestReport> page, DfJitTagDestReport entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(dfJitLogSearchDao.findDfJitTagDestReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfJitIdSrcReport> findDfJitIdSrcReport(Page<DfJitIdSrcReport> page, DfJitIdSrcReport entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(dfJitLogSearchDao.findDfJitIdSrcReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfJitIdDestReport> findDfJitIdDestReport(Page<DfJitIdDestReport> page, DfJitIdDestReport entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(dfJitLogSearchDao.findDfJitIdDestReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public void queryDfJitFlCheck(SaveRequestLogThread thread,long start,String searchFl, String searchXz) {
|
||||
try {
|
||||
if (!StringUtil.isBlank(searchFl)) {
|
||||
Integer.parseInt(searchFl);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,System.currentTimeMillis()-start,"searchFl参数格式错误", RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,System.currentTimeMillis()-start,"searchFl参数错误");
|
||||
}
|
||||
try {
|
||||
if (!StringUtil.isBlank(searchXz)) {
|
||||
Integer.parseInt(searchXz);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,System.currentTimeMillis()-start,"searchXz参数格式错误", RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,System.currentTimeMillis()-start,"searchXz参数错误");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DfKeyConvertUrl;
|
||||
import com.nis.domain.restful.DfKeyMailAdd;
|
||||
import com.nis.domain.restful.DjFlowControlStop;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.DfKeyConvertUrlDao;
|
||||
import com.nis.web.dao.IntervalTimeSearchDao;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
import com.nis.web.service.SaveRequestLogThread;
|
||||
|
||||
/**
|
||||
* @ClassName: DfKeyConvertUrlService
|
||||
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||
* @author (DDM)
|
||||
* @date 2016年9月27日上午10:12:58
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DfKeyConvertUrlService extends BaseLogService {
|
||||
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
protected final Logger logger = Logger.getLogger(this.getClass());
|
||||
/**
|
||||
* 持久层对象
|
||||
*/
|
||||
@Autowired
|
||||
protected DfKeyConvertUrlDao dao;
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DfKeyConvertUrl> findFlowControlStopPage(Page<DfKeyConvertUrl> page,
|
||||
DfKeyConvertUrl entity) {
|
||||
entity.setPage(page);
|
||||
page.setList(dao.findDfKeyConvertUrlPage(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关键字业务转换url查询条件检查
|
||||
* wx
|
||||
* @param entity
|
||||
*/
|
||||
public void queryConditionCheck(SaveRequestLogThread thread,long start,DfKeyConvertUrl entity,Page page) {
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchId())) {
|
||||
Long.parseLong(entity.getSearchId());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchId参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchId参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getOptStartTime())) {
|
||||
sdf.parse(entity.getOptStartTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread,System.currentTimeMillis()-start,"optStartTime参数格式错误", RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread,System.currentTimeMillis()-start,"optStartTime参数格式错误");
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getOptEndTime())) {
|
||||
sdf.parse(entity.getOptEndTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread,System.currentTimeMillis()-start,"optEndTime参数格式错误", RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread,System.currentTimeMillis()-start,"optEndTime参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
checkCloumnIsExist(thread,start,DfKeyConvertUrl.class, page);
|
||||
} catch (RestServiceException e) {
|
||||
logger.error(e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请求参数错误");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DfKeyMailAdd;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.DfKeyMailAddDao;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
import com.nis.web.service.SaveRequestLogThread;
|
||||
|
||||
/**
|
||||
* @ClassName: DfKeyMailAddService
|
||||
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||
* @author (ZBC)
|
||||
* @date 2016年11月09日 下午02:25:00
|
||||
* @version V1.0
|
||||
*/
|
||||
|
||||
@Service
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
public class DfKeyMailAddService extends BaseLogService {
|
||||
protected final Logger logger = Logger.getLogger(this.getClass());
|
||||
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@Autowired
|
||||
protected DfKeyMailAddDao dao;
|
||||
|
||||
public Page<DfKeyMailAdd> findDfKeyMailAddPage(Page<DfKeyMailAdd> page, DfKeyMailAdd entity) {
|
||||
entity.setPage(page);
|
||||
page.setList(dao.findDfKeyMailAddPage(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询条件检查
|
||||
*/
|
||||
public void queryConditionCheck(SaveRequestLogThread thread, long start, DfKeyMailAdd entity, Page page) {
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchId())) {
|
||||
Long.parseLong(entity.getSearchId());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchId参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchId参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getOptStartTime())) {
|
||||
sdf.parse(entity.getOptStartTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread,System.currentTimeMillis()-start,"optStartTime参数格式错误", RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread,System.currentTimeMillis()-start,"optStartTime参数格式错误");
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getOptEndTime())) {
|
||||
sdf.parse(entity.getOptEndTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread,System.currentTimeMillis()-start,"optEndTime参数格式错误", RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread,System.currentTimeMillis()-start,"optEndTime参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
checkCloumnIsExist(thread,start,DfKeyMailAdd.class, page);
|
||||
} catch (RestServiceException e) {
|
||||
logger.error(e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请求参数错误");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,556 @@
|
||||
/**
|
||||
* @Title: DfLogSearchService.java
|
||||
* @Package com.nis.web.service.restful
|
||||
* @Description: TODO(用一句话描述该文件做什么)
|
||||
* @author (ddm)
|
||||
* @date 2016年9月15日 下午2:08:12
|
||||
* @version V1.0
|
||||
*/
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.LogEntity;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DfDnsLog;
|
||||
import com.nis.domain.restful.DfFtpLog;
|
||||
import com.nis.domain.restful.DfHttpKeywordLog;
|
||||
import com.nis.domain.restful.DfHttpReqLog;
|
||||
import com.nis.domain.restful.DfHttpResLog;
|
||||
import com.nis.domain.restful.DfIpPortLog;
|
||||
import com.nis.domain.restful.DfIpsecLog;
|
||||
import com.nis.domain.restful.DfL2tpLog;
|
||||
import com.nis.domain.restful.DfMailLog;
|
||||
import com.nis.domain.restful.DfOpenvpnLog;
|
||||
import com.nis.domain.restful.DfPptpLog;
|
||||
import com.nis.domain.restful.DfSshLog;
|
||||
import com.nis.domain.restful.DfSslLog;
|
||||
import com.nis.domain.restful.DfTunnelRandomLog;
|
||||
//import com.nis.util.MysqlJDBC;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.web.dao.DfLogSearchDao;
|
||||
import com.nis.web.dao.DfLogSearchDaoCluster;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
|
||||
/**
|
||||
* @ClassName: DfLogSearchService
|
||||
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||
* @author (ddm)
|
||||
* @date 2016年9月5日 下午2:08:12
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DfLogSearchService extends BaseLogService{
|
||||
protected final Logger logger = Logger.getLogger(this.getClass());
|
||||
/**
|
||||
* 持久层对象
|
||||
*/
|
||||
@Autowired
|
||||
protected DfLogSearchDao dao;
|
||||
@Autowired
|
||||
protected DfLogSearchDaoCluster daoCluster;
|
||||
|
||||
/**
|
||||
* 获取单条数据
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public LogEntity get(Long id) {
|
||||
return dao.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单条数据
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public LogEntity get(LogEntity entity) {
|
||||
return dao.get(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询列表数据
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public List<LogEntity> findList(LogEntity entity) {
|
||||
return dao.findList(entity);
|
||||
}
|
||||
/**
|
||||
* 查询端口封堵分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfIpPortLog> findIpPortPage(Page<DfIpPortLog> page, DfIpPortLog entity,String activeSys) throws Exception{
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DfIpPortLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findIpPortLogs(entity));
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfHttpReqLog> findHttpReqPage(Page<DfHttpReqLog> page, DfHttpReqLog entity,String activeSys) throws Exception {
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DfHttpReqLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findHttpReqLogs(entity));
|
||||
}
|
||||
/*if(type.equals("jdbc")){
|
||||
logger.info("**********oralce JDBC数据查询开始时间"+System.currentTimeMillis());
|
||||
page.setList(MysqlJDBC.queryByCondition(page, entity));
|
||||
logger.info("**********oralce JDBC数据查询结束时间"+System.currentTimeMillis());
|
||||
}else if(type.equals("es")){
|
||||
logger.info("**********es数据查询开始时间"+System.currentTimeMillis());
|
||||
List<DfHttpReqLog> dfHttpReqLogs=new ArrayList<DfHttpReqLog>();
|
||||
elasticsearchSqlDao.findLogs(dfHttpReqLogs, entity);
|
||||
page.setList(dfHttpReqLogs);
|
||||
logger.info("**********es数据查询开始时间"+System.currentTimeMillis());
|
||||
}else{
|
||||
logger.info("**********oralce Mybatis数据查询开始时间"+System.currentTimeMillis());
|
||||
page.setList(dao.findHttpReqLogs(entity));
|
||||
logger.info("**********oralce Mybatis数据查询开始结束"+System.currentTimeMillis());
|
||||
}*/
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfHttpResLog> findHttpResPage(Page<DfHttpResLog> page, DfHttpResLog entity,String activeSys) throws Exception{
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DfHttpResLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findHttpResLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfHttpKeywordLog> findHttpKeywordPage(Page<DfHttpKeywordLog> page, DfHttpKeywordLog entity,String activeSys) throws Exception {
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DfHttpKeywordLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findHttpKeywordLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfHttpKeywordLog> findHttpMultiPartPage(Page<DfHttpKeywordLog> page, DfHttpKeywordLog entity,String activeSys) throws Exception {
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DfHttpKeywordLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findHttpKeywordLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfMailLog> findMailPage(Page<DfMailLog> page, DfMailLog entity,String activeSys) throws Exception{
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DfMailLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findMailLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfDnsLog> findDnsPage(Page<DfDnsLog> page, DfDnsLog entity,String activeSys) throws Exception{
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DfDnsLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findDnsLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfFtpLog> findFtpPage(Page<DfFtpLog> page, DfFtpLog entity,String activeSys) throws SQLException, IllegalArgumentException, IllegalAccessException, ClientProtocolException, ParseException, JSONException, IOException {
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DfFtpLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findFtpLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfPptpLog> findPptpPage(Page<DfPptpLog> page, DfPptpLog entity,String activeSys) throws Exception {
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DfPptpLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findPptpLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfL2tpLog> findL2tpPage(Page<DfL2tpLog> page, DfL2tpLog entity,String activeSys) throws Exception{
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DfL2tpLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findL2tpLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfIpsecLog> findIpsecPage(Page<DfIpsecLog> page, DfIpsecLog entity,String activeSys) throws Exception{
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DfIpsecLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findIpsecLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfOpenvpnLog> findOpenvpnPage(Page<DfOpenvpnLog> page, DfOpenvpnLog entity,String activeSys) throws Exception {
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DfOpenvpnLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findOpenvpnLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfSshLog> findSshPage(Page<DfSshLog> page, DfSshLog entity,String activeSys) throws Exception {
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DfSshLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findSshLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfSslLog> findSslPage(Page<DfSslLog> page, DfSslLog entity,String activeSys) throws Exception{
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DfSslLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findSslLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfTunnelRandomLog> findTunnelRandomPage(Page<DfTunnelRandomLog> page, DfTunnelRandomLog entity,String activeSys) throws Exception{
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DfTunnelRandomLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findTunnelRandomLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询端口封堵分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfIpPortLog> findIpPortPageCluster(Page<DfIpPortLog> page, DfIpPortLog entity,String activeSys) throws Exception{
|
||||
entity.setPage(page);
|
||||
page.setList(daoCluster.findIpPortLogsCluster(entity));
|
||||
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfHttpReqLog> findHttpReqPageCluster(Page<DfHttpReqLog> page, DfHttpReqLog entity,String activeSys) throws Exception {
|
||||
entity.setPage(page);
|
||||
page.setList(daoCluster.findHttpReqLogsCluster(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfHttpResLog> findHttpResPageCluster(Page<DfHttpResLog> page, DfHttpResLog entity,String activeSys) throws Exception{
|
||||
entity.setPage(page);
|
||||
page.setList(daoCluster.findHttpResLogsCluster(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfHttpKeywordLog> findHttpKeywordPageCluster(Page<DfHttpKeywordLog> page, DfHttpKeywordLog entity,String activeSys) throws Exception {
|
||||
entity.setPage(page);
|
||||
page.setList(daoCluster.findHttpKeywordLogsCluster(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfHttpKeywordLog> findHttpMultiPartPageCluster(Page<DfHttpKeywordLog> page, DfHttpKeywordLog entity,String activeSys) throws Exception {
|
||||
entity.setPage(page);
|
||||
page.setList(daoCluster.findHttpKeywordLogsCluster(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfMailLog> findMailPageCluster(Page<DfMailLog> page, DfMailLog entity,String activeSys) throws Exception{
|
||||
entity.setPage(page);
|
||||
page.setList(daoCluster.findMailLogsCluster(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfDnsLog> findDnsPageCluster(Page<DfDnsLog> page, DfDnsLog entity,String activeSys) throws Exception{
|
||||
entity.setPage(page);
|
||||
page.setList(daoCluster.findDnsLogsCluster(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfFtpLog> findFtpPageCluster(Page<DfFtpLog> page, DfFtpLog entity,String activeSys) throws SQLException, IllegalArgumentException, IllegalAccessException, ClientProtocolException, ParseException, JSONException, IOException {
|
||||
entity.setPage(page);
|
||||
page.setList(daoCluster.findFtpLogsCluster(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfPptpLog> findPptpPageCluster(Page<DfPptpLog> page, DfPptpLog entity,String activeSys) throws Exception {
|
||||
entity.setPage(page);
|
||||
page.setList(daoCluster.findPptpLogsCluster(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfL2tpLog> findL2tpPageCluster(Page<DfL2tpLog> page, DfL2tpLog entity,String activeSys) throws Exception{
|
||||
entity.setPage(page);
|
||||
page.setList(daoCluster.findL2tpLogsCluster(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfIpsecLog> findIpsecPageCluster(Page<DfIpsecLog> page, DfIpsecLog entity,String activeSys) throws Exception{
|
||||
entity.setPage(page);
|
||||
page.setList(daoCluster.findIpsecLogsCluster(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfOpenvpnLog> findOpenvpnPageCluster(Page<DfOpenvpnLog> page, DfOpenvpnLog entity,String activeSys) throws Exception {
|
||||
entity.setPage(page);
|
||||
page.setList(daoCluster.findOpenvpnLogsCluster(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfSshLog> findSshPageCluster(Page<DfSshLog> page, DfSshLog entity,String activeSys) throws Exception {
|
||||
entity.setPage(page);
|
||||
page.setList(daoCluster.findSshLogsCluster(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfSslLog> findSslPageCluster(Page<DfSslLog> page, DfSslLog entity,String activeSys) throws Exception{
|
||||
entity.setPage(page);
|
||||
page.setList(daoCluster.findSslLogsCluster(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Page<DfTunnelRandomLog> findTunnelRandomPageCluster(Page<DfTunnelRandomLog> page, DfTunnelRandomLog entity,String activeSys) throws Exception{
|
||||
entity.setPage(page);
|
||||
page.setList(daoCluster.findTunnelRandomLogsCluster(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DfAttrTypeReport;
|
||||
import com.nis.domain.restful.DfDestIpCountryReport;
|
||||
import com.nis.domain.restful.DfDestIpReport;
|
||||
import com.nis.domain.restful.DfEntranceReport;
|
||||
import com.nis.domain.restful.DfLwhhAttrReport;
|
||||
import com.nis.domain.restful.DfLwhhReport;
|
||||
import com.nis.domain.restful.DfLwhhTagReport;
|
||||
import com.nis.domain.restful.DfPzReport;
|
||||
import com.nis.domain.restful.DfPzReportStat;
|
||||
import com.nis.domain.restful.DfServiceReport;
|
||||
import com.nis.domain.restful.DfSrcIpAttrReport;
|
||||
import com.nis.domain.restful.DfSrcIpDomeSticReport;
|
||||
import com.nis.domain.restful.DfSrcIpReport;
|
||||
import com.nis.domain.restful.DfSrcIpTagReport;
|
||||
import com.nis.domain.restful.DfTagReport;
|
||||
import com.nis.web.dao.DfMultiDimensionalReportDao;
|
||||
import com.nis.web.dao.DfReportDao;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ClassName: DfMultiDimensionsReportService
|
||||
* @Description: TODO(df多维实时统计)
|
||||
* @author (DDM)
|
||||
* @date 2017年8月4日下午3:14:07
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DfMultiDimensionalReportService extends BaseLogService {
|
||||
/**
|
||||
* 持久层对象
|
||||
*/
|
||||
@Autowired
|
||||
protected DfMultiDimensionalReportDao dao;
|
||||
|
||||
|
||||
public Page<DfLwhhAttrReport> findDfLwhhAttrReportPage(Page<DfLwhhAttrReport> page, DfLwhhAttrReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DfLwhhAttrReport> dfLwhhAttrReports = dao.findDfLwhhAttrReport(entity);
|
||||
if (null != dfLwhhAttrReports && dfLwhhAttrReports.size() > 0) {
|
||||
for (DfLwhhAttrReport dfLwhhAttrReport : dfLwhhAttrReports) {
|
||||
if (null != dfLwhhAttrReport.getAsum() && dfLwhhAttrReport.getAsum() != 0) {
|
||||
dfLwhhAttrReport.setAbsum(dfLwhhAttrReport.getAsum());
|
||||
} else if ((null == dfLwhhAttrReport.getAsum() || dfLwhhAttrReport.getAsum() == 0)
|
||||
&& (null != dfLwhhAttrReport.getBsum() && dfLwhhAttrReport.getBsum() != 0)) {
|
||||
dfLwhhAttrReport.setAbsum(dfLwhhAttrReport.getBsum());
|
||||
} else {
|
||||
dfLwhhAttrReport.setAbsum(0l);
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setList(dfLwhhAttrReports);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfLwhhTagReport> findDfLwhhTagReportPage(Page<DfLwhhTagReport> page, DfLwhhTagReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DfLwhhTagReport> dfLwhhTagReports = dao.findDfLwhhTagReportPage(entity);
|
||||
if (null != dfLwhhTagReports && dfLwhhTagReports.size() > 0) {
|
||||
for (DfLwhhTagReport dfLwhhTagReport : dfLwhhTagReports) {
|
||||
if (null != dfLwhhTagReport.getAsum() && dfLwhhTagReport.getAsum() != 0) {
|
||||
dfLwhhTagReport.setAbsum(dfLwhhTagReport.getAsum());
|
||||
} else if ((null == dfLwhhTagReport.getAsum() || dfLwhhTagReport.getAsum() == 0)
|
||||
&& (null != dfLwhhTagReport.getBsum() && dfLwhhTagReport.getBsum() != 0)) {
|
||||
dfLwhhTagReport.setAbsum(dfLwhhTagReport.getBsum());
|
||||
} else {
|
||||
dfLwhhTagReport.setAbsum(0l);
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setList(dfLwhhTagReports);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfSrcIpAttrReport> findDfSrcIpAttrReportPage(Page<DfSrcIpAttrReport> page, DfSrcIpAttrReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DfSrcIpAttrReport> dfSrcIpAttrReports = dao.findDfSrcIpAttrReportPage(entity);
|
||||
if (null != dfSrcIpAttrReports && dfSrcIpAttrReports.size() > 0) {
|
||||
for (DfSrcIpAttrReport dfSrcIpAttrReport : dfSrcIpAttrReports) {
|
||||
if (null != dfSrcIpAttrReport.getAsum() && dfSrcIpAttrReport.getAsum() != 0) {
|
||||
dfSrcIpAttrReport.setAbsum(dfSrcIpAttrReport.getAsum());
|
||||
} else if ((null == dfSrcIpAttrReport.getAsum() || dfSrcIpAttrReport.getAsum() == 0)
|
||||
&& (null != dfSrcIpAttrReport.getBsum() && dfSrcIpAttrReport.getBsum() != 0)) {
|
||||
dfSrcIpAttrReport.setAbsum(dfSrcIpAttrReport.getBsum());
|
||||
} else {
|
||||
dfSrcIpAttrReport.setAbsum(0l);
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setList(dfSrcIpAttrReports);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfSrcIpTagReport> findDfSrcIpTagReportPage(Page<DfSrcIpTagReport> page, DfSrcIpTagReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DfSrcIpTagReport> dfSrcIpTagReports = dao.findDfSrcIpTagReportPage(entity);
|
||||
if (null != dfSrcIpTagReports && dfSrcIpTagReports.size() > 0) {
|
||||
for (DfSrcIpTagReport dfSrcIpTagReport : dfSrcIpTagReports) {
|
||||
if (null != dfSrcIpTagReport.getAsum() && dfSrcIpTagReport.getAsum() != 0) {
|
||||
dfSrcIpTagReport.setAbsum(dfSrcIpTagReport.getAsum());
|
||||
} else if ((null == dfSrcIpTagReport.getAsum() || dfSrcIpTagReport.getAsum() == 0)
|
||||
&& (null != dfSrcIpTagReport.getBsum() && dfSrcIpTagReport.getBsum() != 0)) {
|
||||
dfSrcIpTagReport.setAbsum(dfSrcIpTagReport.getBsum());
|
||||
} else {
|
||||
dfSrcIpTagReport.setAbsum(0l);
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setList(dfSrcIpTagReports);
|
||||
return page;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DfLwhhAttrDaily;
|
||||
import com.nis.domain.restful.DfLwhhAttrMonth;
|
||||
import com.nis.domain.restful.DfLwhhTagDaily;
|
||||
import com.nis.domain.restful.DfLwhhTagMonth;
|
||||
import com.nis.domain.restful.DfSrcIpAttrDaily;
|
||||
import com.nis.domain.restful.DfSrcIpAttrMonth;
|
||||
import com.nis.domain.restful.DfSrcIpTagDaily;
|
||||
import com.nis.domain.restful.DfSrcIpTagMonth;
|
||||
import com.nis.web.dao.DfMultiDimensionalStatLogDao;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ClassName: DfMultiDimensionsReportService
|
||||
* @Description: TODO(df多维实时统计)
|
||||
* @author (DDM)
|
||||
* @date 2017年8月4日下午3:14:07
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DfMultiDimensionalStatLogService extends BaseLogService {
|
||||
/**
|
||||
* 持久层对象
|
||||
*/
|
||||
@Autowired
|
||||
protected DfMultiDimensionalStatLogDao dao;
|
||||
|
||||
public Page<DfLwhhAttrDaily> dfLwhhAttrDaily(Page<DfLwhhAttrDaily> page, DfLwhhAttrDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfLwhhAttrDaily(entity));
|
||||
return page;
|
||||
}
|
||||
public Page<DfLwhhAttrMonth> dfLwhhAttrMonth(Page<DfLwhhAttrMonth> page, DfLwhhAttrMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfLwhhAttrMonth(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
public Page<DfLwhhTagDaily> dfLwhhTagDaily(Page<DfLwhhTagDaily> page, DfLwhhTagDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfLwhhTagDaily(entity));
|
||||
return page;
|
||||
}
|
||||
public Page<DfLwhhTagMonth> dfLwhhTagMonth(Page<DfLwhhTagMonth> page, DfLwhhTagMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfLwhhTagMonth(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
public Page<DfSrcIpAttrDaily> dfSrcIpAttrDaily(Page<DfSrcIpAttrDaily> page, DfSrcIpAttrDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfSrcIpAttrDaily(entity));
|
||||
return page;
|
||||
}
|
||||
public Page<DfSrcIpAttrMonth> dfSrcIpAttrMonth(Page<DfSrcIpAttrMonth> page, DfSrcIpAttrMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfSrcIpAttrMonth(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
public Page<DfSrcIpTagDaily> dfSrcIpTagDaily(Page<DfSrcIpTagDaily> page, DfSrcIpTagDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfSrcIpTagDaily(entity));
|
||||
return page;
|
||||
}
|
||||
public Page<DfSrcIpTagMonth> dfSrcIpTagMonth(Page<DfSrcIpTagMonth> page, DfSrcIpTagMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfSrcIpTagMonth(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
}
|
||||
277
src/main/java/com/nis/web/service/restful/DfReportService.java
Normal file
277
src/main/java/com/nis/web/service/restful/DfReportService.java
Normal file
@@ -0,0 +1,277 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DfAttrTypeReport;
|
||||
import com.nis.domain.restful.DfDestIpCountryReport;
|
||||
import com.nis.domain.restful.DfDestIpReport;
|
||||
import com.nis.domain.restful.DfEntranceReport;
|
||||
import com.nis.domain.restful.DfLwhhReport;
|
||||
import com.nis.domain.restful.DfPzReport;
|
||||
import com.nis.domain.restful.DfPzReportStat;
|
||||
import com.nis.domain.restful.DfServiceReport;
|
||||
import com.nis.domain.restful.DfSrcIpDomeSticReport;
|
||||
import com.nis.domain.restful.DfSrcIpReport;
|
||||
import com.nis.domain.restful.DfTagReport;
|
||||
import com.nis.web.dao.DfReportDao;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ClassName: DfReportService
|
||||
* @Description: TODO(一句话描述这个类)
|
||||
* @author (DDM)
|
||||
* @date 2016年10月31日上午11:54:46
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DfReportService extends BaseLogService {
|
||||
/**
|
||||
* 持久层对象
|
||||
*/
|
||||
@Autowired
|
||||
protected DfReportDao dao;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @Title: findDfPzReportPage
|
||||
* @Description: TODO(这里用一句话描述这个方法的作用)
|
||||
* @param @param
|
||||
* page
|
||||
* @param @param
|
||||
* entity
|
||||
* @param @return
|
||||
* @param @throws
|
||||
* SQLException
|
||||
* @return Map 返回类型
|
||||
* @author (DDM)
|
||||
* @version V1.0
|
||||
*/
|
||||
public Page<DfPzReport> findDfPzReportPage(Page<DfPzReport> page, DfPzReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(dao.findDfPzReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfAttrTypeReport> findAttrTypeReport(Page<DfAttrTypeReport> page, DfAttrTypeReport entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DfAttrTypeReport> findAttrTypeReport = dao.findAttrTypeReport(entity);
|
||||
page.setList(findAttrTypeReport);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfSrcIpDomeSticReport> findSrcIpDomeSticReport(Page<DfSrcIpDomeSticReport> page,
|
||||
DfSrcIpDomeSticReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DfSrcIpDomeSticReport> findSrcIpDomeSticReport = dao.findSrcIpDomeSticReport(entity);
|
||||
if (null != findSrcIpDomeSticReport && findSrcIpDomeSticReport.size() > 0) {
|
||||
for (DfSrcIpDomeSticReport dfSrcIpDomeSticReport : findSrcIpDomeSticReport) {
|
||||
if (null != dfSrcIpDomeSticReport.getAsum() && dfSrcIpDomeSticReport.getAsum() != 0) {
|
||||
dfSrcIpDomeSticReport.setAbsum(dfSrcIpDomeSticReport.getAsum());
|
||||
} else if ((null == dfSrcIpDomeSticReport.getAsum() || dfSrcIpDomeSticReport.getAsum() == 0)
|
||||
&& (null != dfSrcIpDomeSticReport.getBsum() && dfSrcIpDomeSticReport.getBsum() != 0)) {
|
||||
dfSrcIpDomeSticReport.setAbsum(dfSrcIpDomeSticReport.getBsum());
|
||||
} else {
|
||||
dfSrcIpDomeSticReport.setAbsum(0l);
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setList(findSrcIpDomeSticReport);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfDestIpCountryReport> findDestIpCountryReport(Page<DfDestIpCountryReport> page,
|
||||
DfDestIpCountryReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DfDestIpCountryReport> destIpCountryReport = dao.findDestIpCountryReport(entity);
|
||||
if (null != destIpCountryReport && destIpCountryReport.size() > 0) {
|
||||
for (DfDestIpCountryReport dfDestIpCountryReport : destIpCountryReport) {
|
||||
if (null != dfDestIpCountryReport.getAsum() && dfDestIpCountryReport.getAsum() != 0) {
|
||||
dfDestIpCountryReport.setAbsum(dfDestIpCountryReport.getAsum());
|
||||
} else if ((null == dfDestIpCountryReport.getAsum() || dfDestIpCountryReport.getAsum() == 0)
|
||||
&& (null != dfDestIpCountryReport.getBsum() && dfDestIpCountryReport.getBsum() != 0)) {
|
||||
dfDestIpCountryReport.setAbsum(dfDestIpCountryReport.getBsum());
|
||||
} else {
|
||||
dfDestIpCountryReport.setAbsum(0l);
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setList(destIpCountryReport);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfEntranceReport> findDfEntranceReport(Page<DfEntranceReport> page, DfEntranceReport entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DfEntranceReport> findDfEntranceReport = dao.findDfEntranceReport(entity);
|
||||
if (null != findDfEntranceReport && findDfEntranceReport.size() > 0) {
|
||||
for (DfEntranceReport dfEntranceReport : findDfEntranceReport) {
|
||||
if (null != dfEntranceReport.getAsum() && dfEntranceReport.getAsum() != 0) {
|
||||
dfEntranceReport.setAbsum(dfEntranceReport.getAsum());
|
||||
} else if ((null == dfEntranceReport.getAsum() || dfEntranceReport.getAsum() == 0)
|
||||
&& (null != dfEntranceReport.getBsum() && dfEntranceReport.getBsum() != 0)) {
|
||||
dfEntranceReport.setAbsum(dfEntranceReport.getBsum());
|
||||
} else {
|
||||
dfEntranceReport.setAbsum(0l);
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setList(findDfEntranceReport);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfLwhhReport> findDfLwhhReport(Page<DfLwhhReport> page, DfLwhhReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DfLwhhReport> findDfLwhhReport = dao.findDfLwhhReport(entity);
|
||||
if (null != findDfLwhhReport && findDfLwhhReport.size() > 0) {
|
||||
for (DfLwhhReport dfLwhhReport : findDfLwhhReport) {
|
||||
if (null != dfLwhhReport.getAsum() && dfLwhhReport.getAsum() != 0) {
|
||||
dfLwhhReport.setAbsum(dfLwhhReport.getAsum());
|
||||
} else if ((null == dfLwhhReport.getAsum() || dfLwhhReport.getAsum() == 0)
|
||||
&& (null != dfLwhhReport.getBsum() && dfLwhhReport.getBsum() != 0)) {
|
||||
dfLwhhReport.setAbsum(dfLwhhReport.getBsum());
|
||||
} else {
|
||||
dfLwhhReport.setAbsum(0l);
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setList(findDfLwhhReport);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfTagReport> findDfTagReport(Page<DfTagReport> page, DfTagReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DfTagReport> findDfTagReport = dao.findDfTagReport(entity);
|
||||
page.setList(findDfTagReport);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfPzReport> findDfPriTagReport(Page<DfPzReport> page, DfPzReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DfPzReport> findDfPzReport = dao.findDfPzReport(entity);
|
||||
if (null != findDfPzReport && findDfPzReport.size() > 0) {
|
||||
for (DfPzReport dfPzReport : findDfPzReport) {
|
||||
if (null != dfPzReport.getAsum() && dfPzReport.getAsum() != 0) {
|
||||
dfPzReport.setAbsum(dfPzReport.getAsum());
|
||||
} else if ((null == dfPzReport.getAsum() || dfPzReport.getAsum() == 0)
|
||||
&& (null != dfPzReport.getBsum() && dfPzReport.getBsum() != 0)) {
|
||||
dfPzReport.setAbsum(dfPzReport.getBsum());
|
||||
} else {
|
||||
dfPzReport.setAbsum(0l);
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setList(findDfPzReport);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DfPzReportStat> findDfPzReportStatPage(Page<DfPzReportStat> page, DfPzReportStat entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(dao.findDfPzReportStat(entity));
|
||||
return page;
|
||||
}
|
||||
public Page<DfPzReportStat> findDfPzReportStatMinutesPage(Page<DfPzReportStat> page, DfPzReportStat entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(dao.findDfPzReportStatMinutes(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Long findDfPzReportSumStat(Page<DfPzReportStat> page, DfPzReportStat entity) throws SQLException {
|
||||
return dao.findDfPzReportSum(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Title: findDfSrcIpReport
|
||||
* @Description: TODO(这里用一句话描述这个方法的作用)
|
||||
* @param @param
|
||||
* page
|
||||
* @param @param
|
||||
* entity
|
||||
* @param @return
|
||||
* @param @throws
|
||||
* SQLException
|
||||
* @return Map 返回类型
|
||||
* @author (DDM)
|
||||
* @version V1.0
|
||||
*/
|
||||
public Page<DfSrcIpReport> findDfSrcIpReport(Page<DfSrcIpReport> page, DfSrcIpReport entity) {
|
||||
entity.setPage(page);
|
||||
page.setList(dao.findDfSrcIpReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Title: findDfDestIpReport
|
||||
* @Description: TODO(这里用一句话描述这个方法的作用)
|
||||
* @param @param
|
||||
* page
|
||||
* @param @param
|
||||
* entity
|
||||
* @param @return
|
||||
* @param @throws
|
||||
* SQLException
|
||||
* @return Map 返回类型
|
||||
* @author (DDM)
|
||||
* @version V1.0
|
||||
*/
|
||||
public Page<DfDestIpReport> findDfDestIpReport(Page<DfDestIpReport> page, DfDestIpReport entity) {
|
||||
entity.setPage(page);
|
||||
page.setList(dao.findDfDestIpReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @Title: findDfServiceReportPage
|
||||
* @Description: TODO(这里用一句话描述这个方法的作用)
|
||||
* @param @param
|
||||
* page
|
||||
* @param @param
|
||||
* entity
|
||||
* @param @return
|
||||
* @param @throws
|
||||
* SQLException
|
||||
* @return Map 返回类型
|
||||
* @author (DDM)
|
||||
* @version V1.0
|
||||
*/
|
||||
public Page<DfServiceReport> findDfServiceReportPage(Page<DfServiceReport> page, DfServiceReport entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(dao.findDfServiceReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Title: findDfTagReportPage
|
||||
* @Description: TODO(这里用一句话描述这个方法的作用)
|
||||
* @param @param
|
||||
* page
|
||||
* @param @param
|
||||
* entity
|
||||
* @param @return
|
||||
* @param @throws
|
||||
* SQLException
|
||||
* @return Map 返回类型
|
||||
* @author (DDM)
|
||||
* @version V1.0
|
||||
*/
|
||||
public Page<DfTagReport> findDfTagReportPage(Page<DfTagReport> page, DfTagReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
|
||||
List<DfTagReport> findDfTagReportPage = dao.findDfTagReportPage(entity);
|
||||
page.setList(findDfTagReportPage);
|
||||
return page;
|
||||
}
|
||||
|
||||
}
|
||||
203
src/main/java/com/nis/web/service/restful/DfStatLogService.java
Normal file
203
src/main/java/com/nis/web/service/restful/DfStatLogService.java
Normal file
@@ -0,0 +1,203 @@
|
||||
/**
|
||||
* @Title: DfStatLogService.java
|
||||
* @Package com.nis.web.service.restful
|
||||
* @Description: TODO(用一句话描述该文件做什么)
|
||||
* @author (ddm)
|
||||
* @date 2016年9月13日 上午11:50:12
|
||||
* @version V1.0
|
||||
*/
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DfAttrStatLogDaily;
|
||||
import com.nis.domain.restful.DfAttrStatLogMonth;
|
||||
import com.nis.domain.restful.DfDestIpCounrtyStatLogDaily;
|
||||
import com.nis.domain.restful.DfDestIpCounrtyStatLogMonth;
|
||||
import com.nis.domain.restful.DfEntrStatLogDaily;
|
||||
import com.nis.domain.restful.DfEntrStatLogMonth;
|
||||
import com.nis.domain.restful.DfLwhhStatLogDaily;
|
||||
import com.nis.domain.restful.DfLwhhStatLogMonth;
|
||||
import com.nis.domain.restful.DfSrcIpDomesticStatLogDaily;
|
||||
import com.nis.domain.restful.DfSrcIpDomesticStatLogMonth;
|
||||
import com.nis.domain.restful.DfStatLogDaily;
|
||||
import com.nis.domain.restful.DfStatLogMonth;
|
||||
import com.nis.domain.restful.DfTagStatLogDaily;
|
||||
import com.nis.domain.restful.DfTagStatLogMonth;
|
||||
import com.nis.web.dao.DfStatLogDao;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
|
||||
/**
|
||||
* @ClassName: DfStatLogService
|
||||
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||
* @author (ddm)
|
||||
* @date 2016年9月13日 上午11:50:12
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DfStatLogService extends BaseLogService{
|
||||
/**
|
||||
* 持久层对象
|
||||
*/
|
||||
@Autowired
|
||||
protected DfStatLogDao dao;
|
||||
|
||||
/**
|
||||
* 查询端口封堵分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DfStatLogDaily> dfStatLogDaily(Page<DfStatLogDaily> page, DfStatLogDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfStatLogDaily(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询端口封堵分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DfStatLogMonth> dfStatLogMonth(Page<DfStatLogMonth> page, DfStatLogMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfStatLogMonth(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询标签日报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DfTagStatLogDaily> dfTagStatLogDaily(Page<DfTagStatLogDaily> page, DfTagStatLogDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfTagStatLogDaily(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询标签月报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DfTagStatLogMonth> dfTagStatLogMonth(Page<DfTagStatLogMonth> page, DfTagStatLogMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfTagStatLogMonth(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询性质日报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DfAttrStatLogDaily> dfAttrStatLogDaily(Page<DfAttrStatLogDaily> page, DfAttrStatLogDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfAttrStatLogDaily(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询性质月报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DfAttrStatLogMonth> dfAttrStatLogMonth(Page<DfAttrStatLogMonth> page, DfAttrStatLogMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfAttrStatLogMonth(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询局点日报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DfEntrStatLogDaily> dfEntrStatLogDaily(Page<DfEntrStatLogDaily> page, DfEntrStatLogDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfEntrStatLogDaily(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询局点月报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DfEntrStatLogMonth> dfEntrStatLogMonth(Page<DfEntrStatLogMonth> page, DfEntrStatLogMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfEntrStatLogMonth(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询来文函号日报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DfLwhhStatLogDaily> dfLwhhStatLogDaily(Page<DfLwhhStatLogDaily> page, DfLwhhStatLogDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfLwhhStatLogDaily(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询来文函号月报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DfLwhhStatLogMonth> dfLwhhStatLogMonth(Page<DfLwhhStatLogMonth> page, DfLwhhStatLogMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfLwhhStatLogMonth(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询境内源ip日报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DfSrcIpDomesticStatLogDaily> dfSrcIpDomesticStatLogDaily(Page<DfSrcIpDomesticStatLogDaily> page, DfSrcIpDomesticStatLogDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfSrcIpDomesticStatLogDaily(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询境内源ip月报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DfSrcIpDomesticStatLogMonth> dfSrcIpDomesticStatLogMonth(Page<DfSrcIpDomesticStatLogMonth> page, DfSrcIpDomesticStatLogMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfSrcIpDomesticStatLogMonth(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询国家目的ip日报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DfDestIpCounrtyStatLogDaily> dfDestIpCounrtyStatLogDaily(Page<DfDestIpCounrtyStatLogDaily> page, DfDestIpCounrtyStatLogDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfDestIpCounrtyStatLogDaily(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询国家目的ip月报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DfDestIpCounrtyStatLogMonth> dfDestIpCounrtyStatLogMonth(Page<DfDestIpCounrtyStatLogMonth> page, DfDestIpCounrtyStatLogMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.dfDestIpCounrtyStatLogMonth(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.StatLogEntity;
|
||||
import com.nis.domain.restful.DfDjLogStatistics;
|
||||
import com.nis.domain.restful.DfDjPzLogStatistics;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.DfDjLogStatDao;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
import com.nis.web.service.SaveRequestLogThread;
|
||||
|
||||
/**
|
||||
* @ClassName: DfdjLogStatService
|
||||
* @Description: 封堵/监测日志统计查询
|
||||
* @author (zbc)
|
||||
* @date 2016年11月14日 下午4:00:00
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
public class DfdjLogStatService extends BaseLogService {
|
||||
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@Autowired
|
||||
protected DfDjLogStatDao dao;
|
||||
|
||||
|
||||
public DfDjLogStatistics findDfLogStatistics(DfDjLogStatistics entity) {
|
||||
List<DfDjLogStatistics> list = dao.findDfLogStatistics(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public Page<DfDjPzLogStatistics> findDfPzLogStatistics(Page<DfDjPzLogStatistics> page, DfDjPzLogStatistics entity) {
|
||||
entity.setPage(page);
|
||||
page.setList(dao.findDfPzLogStatistics(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
public DfDjLogStatistics findDjLogStatistics(DfDjLogStatistics entity) {
|
||||
List<DfDjLogStatistics> list = dao.findDjLogStatistics(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public Page<DfDjPzLogStatistics> findDjPzLogStatistics(Page<DfDjPzLogStatistics> page, DfDjPzLogStatistics entity) {
|
||||
entity.setPage(page);
|
||||
page.setList(dao.findDjPzLogStatistics(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void queryConditionCheck(SaveRequestLogThread thread, long start, StatLogEntity entity, Class clazz, Page page) {
|
||||
/*
|
||||
* searchConfigId为多条件格式
|
||||
*/
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchStatStartTime())) {
|
||||
sdf.parse(entity.getSearchStatStartTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
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());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchStatStartTime参数格式错误");
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchStatEndTime())) {
|
||||
sdf.parse(entity.getSearchStatEndTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
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());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchStatEndTime参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getSearchService())) {
|
||||
Integer.parseInt(entity.getSearchService());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
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());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchService参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
checkCloumnIsExist(thread,start,clazz, page);
|
||||
} catch (RestServiceException e) {
|
||||
logger.error(e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请求参数错误");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DjCkStatLog;
|
||||
import com.nis.domain.restful.DjJitAffairDestReport;
|
||||
import com.nis.domain.restful.DjJitAffairSrcReport;
|
||||
import com.nis.domain.restful.DjJitFlDestReport;
|
||||
import com.nis.domain.restful.DjJitFlSrcReport;
|
||||
import com.nis.domain.restful.DjJitGuaranteeDestReport;
|
||||
import com.nis.domain.restful.DjJitGuaranteeSrcReport;
|
||||
import com.nis.domain.restful.DjJitIdDestReport;
|
||||
import com.nis.domain.restful.DjJitIdSrcReport;
|
||||
import com.nis.domain.restful.DjJitMissionDestReport;
|
||||
import com.nis.domain.restful.DjJitMissionSrcReport;
|
||||
import com.nis.domain.restful.DjJitTagDestReport;
|
||||
import com.nis.domain.restful.DjJitTagSrcReport;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.DjJitLogSearchDao;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
import com.nis.web.service.SaveRequestLogThread;
|
||||
|
||||
@Service
|
||||
public class DjJitLogSearchService extends BaseLogService {
|
||||
|
||||
@Autowired
|
||||
private DjJitLogSearchDao djJitLogSearchDao;
|
||||
|
||||
public Page<DjJitFlSrcReport> findDjJitFlSrcReport(Page<DjJitFlSrcReport> page, DjJitFlSrcReport entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(djJitLogSearchDao.findDjJitFlSrcReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DjJitFlDestReport> findDjJitFlDestReport(Page<DjJitFlDestReport> page, DjJitFlDestReport entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(djJitLogSearchDao.findDjJitFlDestReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DjJitAffairSrcReport> findDjJitAffairSrcReport(Page<DjJitAffairSrcReport> page,
|
||||
DjJitAffairSrcReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(djJitLogSearchDao.findDjJitAffairSrcReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DjJitAffairDestReport> findDjJitAffairDestReport(Page<DjJitAffairDestReport> page,
|
||||
DjJitAffairDestReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(djJitLogSearchDao.findDjJitAffairDestReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DjJitMissionSrcReport> findDjJitMissionSrcReport(Page<DjJitMissionSrcReport> page,
|
||||
DjJitMissionSrcReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(djJitLogSearchDao.findDjJitMissionSrcReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DjJitMissionDestReport> findDjJitMissionDestReport(Page<DjJitMissionDestReport> page,
|
||||
DjJitMissionDestReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(djJitLogSearchDao.findDjJitMissionDestReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DjJitGuaranteeSrcReport> findDjJitGuaranteeSrcReport(Page<DjJitGuaranteeSrcReport> page,
|
||||
DjJitGuaranteeSrcReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(djJitLogSearchDao.findDjJitGuaranteeSrcReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DjJitGuaranteeDestReport> findDjJitGuaranteeDestReport(Page<DjJitGuaranteeDestReport> page,
|
||||
DjJitGuaranteeDestReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(djJitLogSearchDao.findDjJitGuaranteeDestReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DjJitTagSrcReport> findDjJitTagSrcReport(Page<DjJitTagSrcReport> page, DjJitTagSrcReport entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(djJitLogSearchDao.findDjJitTagSrcReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DjJitTagDestReport> findDjJitTagDestReport(Page<DjJitTagDestReport> page, DjJitTagDestReport entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(djJitLogSearchDao.findDjJitTagDestReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DjJitIdSrcReport> findDjJitIdSrcReport(Page<DjJitIdSrcReport> page, DjJitIdSrcReport entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(djJitLogSearchDao.findDjJitIdSrcReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DjJitIdDestReport> findDjJitIdDestReport(Page<DjJitIdDestReport> page, DjJitIdDestReport entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(djJitLogSearchDao.findDjJitIdDestReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DjCkStatLog> findDjCkStatLog(Page<DjCkStatLog> page, DjCkStatLog entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(djJitLogSearchDao.findDjCkStatLog(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public void queryDjJitFlCheck(SaveRequestLogThread thread,long start,String searchFl, String searchXz) {
|
||||
try {
|
||||
if (!StringUtil.isBlank(searchFl)) {
|
||||
Integer.parseInt(searchFl);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,System.currentTimeMillis()-start,"searchFl参数格式错误", RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,System.currentTimeMillis()-start,"searchFl参数错误");
|
||||
}
|
||||
try {
|
||||
if (!StringUtil.isBlank(searchXz)) {
|
||||
Integer.parseInt(searchXz);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,System.currentTimeMillis()-start,"searchXz参数格式错误", RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
throw new RestServiceException(thread,System.currentTimeMillis()-start,"searchXz参数错误");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,379 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DjDnsLog;
|
||||
import com.nis.domain.restful.DjFtpLog;
|
||||
import com.nis.domain.restful.DjHttpKeywordLog;
|
||||
import com.nis.domain.restful.DjHttpReqLog;
|
||||
import com.nis.domain.restful.DjHttpResLog;
|
||||
import com.nis.domain.restful.DjIpPortLog;
|
||||
import com.nis.domain.restful.DjIpsecLog;
|
||||
import com.nis.domain.restful.DjL2tpLog;
|
||||
import com.nis.domain.restful.DjMailLog;
|
||||
import com.nis.domain.restful.DjOpenvpnLog;
|
||||
import com.nis.domain.restful.DjPptpLog;
|
||||
import com.nis.domain.restful.DjSshLog;
|
||||
import com.nis.domain.restful.DjSslLog;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.web.dao.DjLogSearchDao;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
|
||||
/**
|
||||
* @ClassName: DjLogSearchService
|
||||
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||
* @author (zbc)
|
||||
* @date 2016年9月7日 上午11:15:12
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DjLogSearchService extends BaseLogService {
|
||||
|
||||
/**
|
||||
* 持久层对象
|
||||
*/
|
||||
@Autowired
|
||||
protected DjLogSearchDao dao;
|
||||
|
||||
/**
|
||||
* 查询端口封堵分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws JSONException
|
||||
* @throws ParseException
|
||||
* @throws ClientProtocolException
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public Page<DjIpPortLog> findIpPortPage(Page<DjIpPortLog> page, DjIpPortLog entity,String activeSys) throws IllegalArgumentException, IllegalAccessException, ClientProtocolException, ParseException, JSONException, IOException {
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DjIpPortLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findIpPortLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws JSONException
|
||||
* @throws ParseException
|
||||
* @throws ClientProtocolException
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public Page<DjHttpResLog> findHttpResPage(Page<DjHttpResLog> page, DjHttpResLog entity,String activeSys) throws IllegalArgumentException, IllegalAccessException, ClientProtocolException, ParseException, JSONException, IOException {
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DjHttpResLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findHttpResLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param httpReqLog
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws JSONException
|
||||
* @throws ParseException
|
||||
* @throws ClientProtocolException
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public Page<DjHttpReqLog> findHttpReqPage(Page<DjHttpReqLog> page, DjHttpReqLog httpReqLog,String activeSys) throws IllegalArgumentException, IllegalAccessException, ClientProtocolException, ParseException, JSONException, IOException {
|
||||
httpReqLog.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DjHttpReqLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, httpReqLog,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findHttpReqLogs(httpReqLog));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws JSONException
|
||||
* @throws ParseException
|
||||
* @throws ClientProtocolException
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public Page<DjHttpKeywordLog> findHttpKeywordPage(Page<DjHttpKeywordLog> page, DjHttpKeywordLog entity,String activeSys) throws IllegalArgumentException, IllegalAccessException, ClientProtocolException, ParseException, JSONException, IOException {
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DjHttpKeywordLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findHttpKeywordLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @throws IOException
|
||||
* @throws JSONException
|
||||
* @throws ParseException
|
||||
* @throws ClientProtocolException
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public Page<DjHttpKeywordLog> findHttpMultiPartPage(Page<DjHttpKeywordLog> page, DjHttpKeywordLog entity,String activeSys) throws IllegalArgumentException, IllegalAccessException, ClientProtocolException, ParseException, JSONException, IOException {
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DjHttpKeywordLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findHttpKeywordLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws JSONException
|
||||
* @throws ParseException
|
||||
* @throws ClientProtocolException
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public Page<DjMailLog> findMailPage(Page<DjMailLog> page, DjMailLog entity,String activeSys) throws IllegalArgumentException, IllegalAccessException, ClientProtocolException, ParseException, JSONException, IOException {
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DjMailLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findMailLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws JSONException
|
||||
* @throws ParseException
|
||||
* @throws ClientProtocolException
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public Page<DjDnsLog> findDnsPage(Page<DjDnsLog> page, DjDnsLog entity,String activeSys) throws IllegalArgumentException, IllegalAccessException, ClientProtocolException, ParseException, JSONException, IOException {
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DjDnsLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findDnsLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws JSONException
|
||||
* @throws ParseException
|
||||
* @throws ClientProtocolException
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public Page<DjFtpLog> findFtpPage(Page<DjFtpLog> page, DjFtpLog entity,String activeSys) throws IllegalArgumentException, IllegalAccessException, ClientProtocolException, ParseException, JSONException, IOException {
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DjFtpLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findFtpLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws JSONException
|
||||
* @throws ParseException
|
||||
* @throws ClientProtocolException
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public Page<DjPptpLog> findPptpPage(Page<DjPptpLog> page, DjPptpLog entity,String activeSys) throws IllegalArgumentException, IllegalAccessException, ClientProtocolException, ParseException, JSONException, IOException {
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DjPptpLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findPptpLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws JSONException
|
||||
* @throws ParseException
|
||||
* @throws ClientProtocolException
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public Page<DjL2tpLog> findL2tpPage(Page<DjL2tpLog> page, DjL2tpLog entity,String activeSys) throws IllegalArgumentException, IllegalAccessException, ClientProtocolException, ParseException, JSONException, IOException {
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DjL2tpLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findL2tpLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws JSONException
|
||||
* @throws ParseException
|
||||
* @throws ClientProtocolException
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public Page<DjIpsecLog> findIpsecPage(Page<DjIpsecLog> page, DjIpsecLog entity,String activeSys) throws IllegalArgumentException, IllegalAccessException, ClientProtocolException, ParseException, JSONException, IOException {
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DjIpsecLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findIpsecLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws JSONException
|
||||
* @throws ParseException
|
||||
* @throws ClientProtocolException
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public Page<DjOpenvpnLog> findOpenvpnPage(Page<DjOpenvpnLog> page, DjOpenvpnLog entity,String activeSys) throws IllegalArgumentException, IllegalAccessException, ClientProtocolException, ParseException, JSONException, IOException {
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DjOpenvpnLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findOpenvpnLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws JSONException
|
||||
* @throws ParseException
|
||||
* @throws ClientProtocolException
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public Page<DjSshLog> findSshPage(Page<DjSshLog> page, DjSshLog entity,String activeSys) throws IllegalArgumentException, IllegalAccessException, ClientProtocolException, ParseException, JSONException, IOException {
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DjSshLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findSshLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws JSONException
|
||||
* @throws ParseException
|
||||
* @throws ClientProtocolException
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public Page<DjSslLog> findSslPage(Page<DjSslLog> page, DjSslLog entity,String activeSys) throws IllegalArgumentException, IllegalAccessException, ClientProtocolException, ParseException, JSONException, IOException {
|
||||
entity.setPage(page);
|
||||
if(Constants.IS_USE_ES){
|
||||
List<DjSslLog> resultList=new ArrayList<>();
|
||||
elasticsearchSqlDao.findLogs(resultList, entity,activeSys);
|
||||
page.setList(resultList);
|
||||
}else{
|
||||
page.setList(dao.findSslLogs(entity));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DjLwhhAttrReport;
|
||||
import com.nis.domain.restful.DjLwhhReport;
|
||||
import com.nis.domain.restful.DjLwhhTagReport;
|
||||
import com.nis.domain.restful.DjSrcIpAttrReport;
|
||||
import com.nis.domain.restful.DjSrcIpTagReport;
|
||||
import com.nis.web.dao.DjMultiDimensionalReportDao;
|
||||
import com.nis.web.dao.DjReportDao;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ClassName: DjMultiDimensionsReportService
|
||||
* @Description: TODO(dj多维实时统计)
|
||||
* @author (DDM)
|
||||
* @date 2017年8月4日下午3:14:07
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DjMultiDimensionalReportService extends BaseLogService {
|
||||
/**
|
||||
* 持久层对象
|
||||
*/
|
||||
@Autowired
|
||||
protected DjMultiDimensionalReportDao dao;
|
||||
|
||||
|
||||
public Page<DjLwhhAttrReport> findDjLwhhAttrReportPage(Page<DjLwhhAttrReport> page, DjLwhhAttrReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DjLwhhAttrReport> djLwhhAttrReports = dao.findDjLwhhAttrReport(entity);
|
||||
if (null != djLwhhAttrReports && djLwhhAttrReports.size() > 0) {
|
||||
for (DjLwhhAttrReport djLwhhAttrReport : djLwhhAttrReports) {
|
||||
if (null != djLwhhAttrReport.getAsum() && djLwhhAttrReport.getAsum() != 0) {
|
||||
djLwhhAttrReport.setAbsum(djLwhhAttrReport.getAsum());
|
||||
} else if ((null == djLwhhAttrReport.getAsum() || djLwhhAttrReport.getAsum() == 0)
|
||||
&& (null != djLwhhAttrReport.getBsum() && djLwhhAttrReport.getBsum() != 0)) {
|
||||
djLwhhAttrReport.setAbsum(djLwhhAttrReport.getBsum());
|
||||
} else {
|
||||
djLwhhAttrReport.setAbsum(0l);
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setList(djLwhhAttrReports);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DjLwhhTagReport> findDjLwhhTagReportPage(Page<DjLwhhTagReport> page, DjLwhhTagReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DjLwhhTagReport> djLwhhTagReports = dao.findDjLwhhTagReportPage(entity);
|
||||
if (null != djLwhhTagReports && djLwhhTagReports.size() > 0) {
|
||||
for (DjLwhhTagReport djLwhhTagReport : djLwhhTagReports) {
|
||||
if (null != djLwhhTagReport.getAsum() && djLwhhTagReport.getAsum() != 0) {
|
||||
djLwhhTagReport.setAbsum(djLwhhTagReport.getAsum());
|
||||
} else if ((null == djLwhhTagReport.getAsum() || djLwhhTagReport.getAsum() == 0)
|
||||
&& (null != djLwhhTagReport.getBsum() && djLwhhTagReport.getBsum() != 0)) {
|
||||
djLwhhTagReport.setAbsum(djLwhhTagReport.getBsum());
|
||||
} else {
|
||||
djLwhhTagReport.setAbsum(0l);
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setList(djLwhhTagReports);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DjSrcIpAttrReport> findDjSrcIpAttrReportPage(Page<DjSrcIpAttrReport> page, DjSrcIpAttrReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DjSrcIpAttrReport> djSrcIpAttrReports = dao.findDjSrcIpAttrReportPage(entity);
|
||||
if (null != djSrcIpAttrReports && djSrcIpAttrReports.size() > 0) {
|
||||
for (DjSrcIpAttrReport djSrcIpAttrReport : djSrcIpAttrReports) {
|
||||
if (null != djSrcIpAttrReport.getAsum() && djSrcIpAttrReport.getAsum() != 0) {
|
||||
djSrcIpAttrReport.setAbsum(djSrcIpAttrReport.getAsum());
|
||||
} else if ((null == djSrcIpAttrReport.getAsum() || djSrcIpAttrReport.getAsum() == 0)
|
||||
&& (null != djSrcIpAttrReport.getBsum() && djSrcIpAttrReport.getBsum() != 0)) {
|
||||
djSrcIpAttrReport.setAbsum(djSrcIpAttrReport.getBsum());
|
||||
} else {
|
||||
djSrcIpAttrReport.setAbsum(0l);
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setList(djSrcIpAttrReports);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DjSrcIpTagReport> findDjSrcIpTagReportPage(Page<DjSrcIpTagReport> page, DjSrcIpTagReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DjSrcIpTagReport> djSrcIpTagReports = dao.findDjSrcIpTagReportPage(entity);
|
||||
if (null != djSrcIpTagReports && djSrcIpTagReports.size() > 0) {
|
||||
for (DjSrcIpTagReport djSrcIpTagReport : djSrcIpTagReports) {
|
||||
if (null != djSrcIpTagReport.getAsum() && djSrcIpTagReport.getAsum() != 0) {
|
||||
djSrcIpTagReport.setAbsum(djSrcIpTagReport.getAsum());
|
||||
} else if ((null == djSrcIpTagReport.getAsum() || djSrcIpTagReport.getAsum() == 0)
|
||||
&& (null != djSrcIpTagReport.getBsum() && djSrcIpTagReport.getBsum() != 0)) {
|
||||
djSrcIpTagReport.setAbsum(djSrcIpTagReport.getBsum());
|
||||
} else {
|
||||
djSrcIpTagReport.setAbsum(0l);
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setList(djSrcIpTagReports);
|
||||
return page;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DjLwhhAttrDaily;
|
||||
import com.nis.domain.restful.DjLwhhAttrMonth;
|
||||
import com.nis.domain.restful.DjLwhhTagDaily;
|
||||
import com.nis.domain.restful.DjLwhhTagMonth;
|
||||
import com.nis.domain.restful.DjSrcIpAttrDaily;
|
||||
import com.nis.domain.restful.DjSrcIpAttrMonth;
|
||||
import com.nis.domain.restful.DjSrcIpTagDaily;
|
||||
import com.nis.domain.restful.DjSrcIpTagMonth;
|
||||
import com.nis.web.dao.DjMultiDimensionalStatLogDao;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ClassName: DjMultiDimensionsReportService
|
||||
* @Description: TODO(dj多维实时统计)
|
||||
* @author (DDM)
|
||||
* @date 2017年8月4日下午3:14:07
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DjMultiDimensionalStatLogService extends BaseLogService {
|
||||
/**
|
||||
* 持久层对象
|
||||
*/
|
||||
@Autowired
|
||||
protected DjMultiDimensionalStatLogDao dao;
|
||||
|
||||
public Page<DjLwhhAttrDaily> djLwhhAttrDaily(Page<DjLwhhAttrDaily> page, DjLwhhAttrDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djLwhhAttrDaily(entity));
|
||||
return page;
|
||||
}
|
||||
public Page<DjLwhhAttrMonth> djLwhhAttrMonth(Page<DjLwhhAttrMonth> page, DjLwhhAttrMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djLwhhAttrMonth(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
public Page<DjLwhhTagDaily> djLwhhTagDaily(Page<DjLwhhTagDaily> page, DjLwhhTagDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djLwhhTagDaily(entity));
|
||||
return page;
|
||||
}
|
||||
public Page<DjLwhhTagMonth> djLwhhTagMonth(Page<DjLwhhTagMonth> page, DjLwhhTagMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djLwhhTagMonth(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
public Page<DjSrcIpAttrDaily> djSrcIpAttrDaily(Page<DjSrcIpAttrDaily> page, DjSrcIpAttrDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djSrcIpAttrDaily(entity));
|
||||
return page;
|
||||
}
|
||||
public Page<DjSrcIpAttrMonth> djSrcIpAttrMonth(Page<DjSrcIpAttrMonth> page, DjSrcIpAttrMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djSrcIpAttrMonth(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
public Page<DjSrcIpTagDaily> djSrcIpTagDaily(Page<DjSrcIpTagDaily> page, DjSrcIpTagDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djSrcIpTagDaily(entity));
|
||||
return page;
|
||||
}
|
||||
public Page<DjSrcIpTagMonth> djSrcIpTagMonth(Page<DjSrcIpTagMonth> page, DjSrcIpTagMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djSrcIpTagMonth(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
}
|
||||
186
src/main/java/com/nis/web/service/restful/DjReportService.java
Normal file
186
src/main/java/com/nis/web/service/restful/DjReportService.java
Normal file
@@ -0,0 +1,186 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DjPzReportStat;
|
||||
import com.nis.domain.restful.DjAttrTypeReport;
|
||||
import com.nis.domain.restful.DjDestIpCountryReport;
|
||||
import com.nis.domain.restful.DjEntranceReport;
|
||||
import com.nis.domain.restful.DjLwhhReport;
|
||||
import com.nis.domain.restful.DjSrcIpDomeSticReport;
|
||||
import com.nis.domain.restful.DjTagReport;
|
||||
import com.nis.domain.restful.DjPzReport;
|
||||
import com.nis.web.dao.DjReportDao;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ClassName: DjReportService
|
||||
* @Description: TODO(一句话描述这个类)
|
||||
* @author (ZBC)
|
||||
* @date 2016年11月22日下午06:00:00
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DjReportService extends BaseLogService {
|
||||
/**
|
||||
* 持久层对象
|
||||
*/
|
||||
@Autowired
|
||||
protected DjReportDao dao;
|
||||
|
||||
/**
|
||||
* @Title: findDjPzReportPage
|
||||
* @param page
|
||||
* @param djPzReport
|
||||
* @return
|
||||
*/
|
||||
public Page<DjPzReport> findDjPzReportPage(Page<DjPzReport> page, DjPzReport entity) {
|
||||
entity.setPage(page);
|
||||
page.setList(dao.findDjPzReport(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DjPzReportStat> findDjPzReportStatPage(Page<DjPzReportStat> page, DjPzReportStat entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(dao.findDjPzReportStat(entity));
|
||||
return page;
|
||||
}
|
||||
public Page<DjPzReportStat> findDjPzReportStatMinutesPage(Page<DjPzReportStat> page, DjPzReportStat entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
page.setList(dao.findDjPzReportStatMinutes(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DjPzReport> findDjPzPrivPage(Page<DjPzReport> page, DjPzReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DjPzReport> findDjPzPrivPage = dao.findDjPzPrivPage(entity);
|
||||
if (null != findDjPzPrivPage && findDjPzPrivPage.size() > 0) {
|
||||
for (DjPzReport djPzReport : findDjPzPrivPage) {
|
||||
if (null != djPzReport.getAsum() && djPzReport.getAsum() != 0) {
|
||||
djPzReport.setAbsum(djPzReport.getAsum());
|
||||
} else if ((null == djPzReport.getAsum() || djPzReport.getAsum() == 0)
|
||||
&& (null != djPzReport.getBsum() && djPzReport.getBsum() != 0)) {
|
||||
djPzReport.setAbsum(djPzReport.getBsum());
|
||||
} else {
|
||||
djPzReport.setAbsum(0l);
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setList(findDjPzPrivPage);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Long findDjPzReportSumStat(Page<DjPzReportStat> page, DjPzReportStat entity) throws SQLException {
|
||||
return dao.findDjPzReportSum(entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Page<DjAttrTypeReport> findAttrTypeReport(Page<DjAttrTypeReport> page, DjAttrTypeReport entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DjAttrTypeReport> findAttrTypeReport = dao.findAttrTypeReport(entity);
|
||||
page.setList(findAttrTypeReport);
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
public Page<DjSrcIpDomeSticReport> findSrcIpDomeSticReport(Page<DjSrcIpDomeSticReport> page,
|
||||
DjSrcIpDomeSticReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DjSrcIpDomeSticReport> findSrcIpDomeSticReport = dao.findSrcIpDomeSticReport(entity);
|
||||
if (null != findSrcIpDomeSticReport && findSrcIpDomeSticReport.size() > 0) {
|
||||
for (DjSrcIpDomeSticReport djSrcIpDomeSticReport : findSrcIpDomeSticReport) {
|
||||
if (null != djSrcIpDomeSticReport.getAsum() && djSrcIpDomeSticReport.getAsum() != 0) {
|
||||
djSrcIpDomeSticReport.setAbsum(djSrcIpDomeSticReport.getAsum());
|
||||
} else if ((null == djSrcIpDomeSticReport.getAsum() || djSrcIpDomeSticReport.getAsum() == 0)
|
||||
&& (null != djSrcIpDomeSticReport.getBsum() && djSrcIpDomeSticReport.getBsum() != 0)) {
|
||||
djSrcIpDomeSticReport.setAbsum(djSrcIpDomeSticReport.getBsum());
|
||||
} else {
|
||||
djSrcIpDomeSticReport.setAbsum(0l);
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setList(findSrcIpDomeSticReport);
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
public Page<DjDestIpCountryReport> findDestIpCountryReport(Page<DjDestIpCountryReport> page,
|
||||
DjDestIpCountryReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DjDestIpCountryReport> destIpCountryReport = dao.findDestIpCountryReport(entity);
|
||||
if (null != destIpCountryReport && destIpCountryReport.size() > 0) {
|
||||
for (DjDestIpCountryReport djDestIpCountryReport : destIpCountryReport) {
|
||||
if (null != djDestIpCountryReport.getAsum() && djDestIpCountryReport.getAsum() != 0) {
|
||||
djDestIpCountryReport.setAbsum(djDestIpCountryReport.getAsum());
|
||||
} else if ((null == djDestIpCountryReport.getAsum() || djDestIpCountryReport.getAsum() == 0)
|
||||
&& (null != djDestIpCountryReport.getBsum() && djDestIpCountryReport.getBsum() != 0)) {
|
||||
djDestIpCountryReport.setAbsum(djDestIpCountryReport.getBsum());
|
||||
} else {
|
||||
djDestIpCountryReport.setAbsum(0l);
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setList(destIpCountryReport);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DjEntranceReport> findDjEntranceReport(Page<DjEntranceReport> page, DjEntranceReport entity)
|
||||
throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DjEntranceReport> findDjEntranceReport = dao.findDjEntranceReport(entity);
|
||||
if (null != findDjEntranceReport && findDjEntranceReport.size() > 0) {
|
||||
for (DjEntranceReport djEntranceReport : findDjEntranceReport) {
|
||||
if (null != djEntranceReport.getAsum() && djEntranceReport.getAsum() != 0) {
|
||||
djEntranceReport.setAbsum(djEntranceReport.getAsum());
|
||||
} else if ((null == djEntranceReport.getAsum() || djEntranceReport.getAsum() == 0)
|
||||
&& (null != djEntranceReport.getBsum() && djEntranceReport.getBsum() != 0)) {
|
||||
djEntranceReport.setAbsum(djEntranceReport.getBsum());
|
||||
} else {
|
||||
djEntranceReport.setAbsum(0l);
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setList(findDjEntranceReport);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DjLwhhReport> findDjLwhhReport(Page<DjLwhhReport> page, DjLwhhReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
List<DjLwhhReport> findDjLwhhReport = dao.findDjLwhhReport(entity);
|
||||
if (null != findDjLwhhReport && findDjLwhhReport.size() > 0) {
|
||||
for (DjLwhhReport djLwhhReport : findDjLwhhReport) {
|
||||
if (null != djLwhhReport.getAsum() && djLwhhReport.getAsum() != 0) {
|
||||
djLwhhReport.setAbsum(djLwhhReport.getAsum());
|
||||
} else if ((null == djLwhhReport.getAsum() || djLwhhReport.getAsum() == 0)
|
||||
&& (null != djLwhhReport.getBsum() && djLwhhReport.getBsum() != 0)) {
|
||||
djLwhhReport.setAbsum(djLwhhReport.getBsum());
|
||||
} else {
|
||||
djLwhhReport.setAbsum(0l);
|
||||
}
|
||||
}
|
||||
}
|
||||
page.setList(findDjLwhhReport);
|
||||
return page;
|
||||
}
|
||||
|
||||
public Page<DjTagReport> findDjTagReportPage(Page<DjTagReport> page, DjTagReport entity) throws SQLException {
|
||||
entity.setPage(page);
|
||||
|
||||
List<DjTagReport> findDjTagReportPage = dao.findDjTagReportPage(entity);
|
||||
page.setList(findDjTagReportPage);
|
||||
return page;
|
||||
}
|
||||
|
||||
}
|
||||
203
src/main/java/com/nis/web/service/restful/DjStatLogService.java
Normal file
203
src/main/java/com/nis/web/service/restful/DjStatLogService.java
Normal file
@@ -0,0 +1,203 @@
|
||||
/**
|
||||
* @Title: DjStatLogService.java
|
||||
* @Package com.nis.web.service.restful
|
||||
* @Description: TODO(用一句话描述该文件做什么)
|
||||
* @author (ddm)
|
||||
* @date 2016年9月13日 上午11:50:12
|
||||
* @version V1.0
|
||||
*/
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DjAttrStatLogDaily;
|
||||
import com.nis.domain.restful.DjAttrStatLogMonth;
|
||||
import com.nis.domain.restful.DjDestIpCounrtyStatLogDaily;
|
||||
import com.nis.domain.restful.DjDestIpCounrtyStatLogMonth;
|
||||
import com.nis.domain.restful.DjEntrStatLogDaily;
|
||||
import com.nis.domain.restful.DjEntrStatLogMonth;
|
||||
import com.nis.domain.restful.DjLwhhStatLogDaily;
|
||||
import com.nis.domain.restful.DjLwhhStatLogMonth;
|
||||
import com.nis.domain.restful.DjSrcIpDomesticStatLogDaily;
|
||||
import com.nis.domain.restful.DjSrcIpDomesticStatLogMonth;
|
||||
import com.nis.domain.restful.DjStatLogDaily;
|
||||
import com.nis.domain.restful.DjStatLogMonth;
|
||||
import com.nis.domain.restful.DjTagStatLogDaily;
|
||||
import com.nis.domain.restful.DjTagStatLogMonth;
|
||||
import com.nis.web.dao.DjStatLogDao;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
|
||||
/**
|
||||
* @ClassName: DjStatLogService
|
||||
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||
* @author (ddm)
|
||||
* @date 2016年9月13日 上午11:50:12
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DjStatLogService extends BaseLogService{
|
||||
/**
|
||||
* 持久层对象
|
||||
*/
|
||||
@Autowired
|
||||
protected DjStatLogDao dao;
|
||||
|
||||
/**
|
||||
* 查询端口封堵分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DjStatLogDaily> djStatLogDaily(Page<DjStatLogDaily> page, DjStatLogDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djStatLogDaily(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询端口封堵分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DjStatLogMonth> djStatLogMonth(Page<DjStatLogMonth> page, DjStatLogMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djStatLogMonth(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询标签日报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DjTagStatLogDaily> djTagStatLogDaily(Page<DjTagStatLogDaily> page, DjTagStatLogDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djTagStatLogDaily(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询标签月报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DjTagStatLogMonth> djTagStatLogMonth(Page<DjTagStatLogMonth> page, DjTagStatLogMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djTagStatLogMonth(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询性质日报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DjAttrStatLogDaily> djAttrStatLogDaily(Page<DjAttrStatLogDaily> page, DjAttrStatLogDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djAttrStatLogDaily(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询性质月报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DjAttrStatLogMonth> djAttrStatLogMonth(Page<DjAttrStatLogMonth> page, DjAttrStatLogMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djAttrStatLogMonth(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询局点日报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DjEntrStatLogDaily> djEntrStatLogDaily(Page<DjEntrStatLogDaily> page, DjEntrStatLogDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djEntrStatLogDaily(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询局点月报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DjEntrStatLogMonth> djEntrStatLogMonth(Page<DjEntrStatLogMonth> page, DjEntrStatLogMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djEntrStatLogMonth(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询来文函号日报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DjLwhhStatLogDaily> djLwhhStatLogDaily(Page<DjLwhhStatLogDaily> page, DjLwhhStatLogDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djLwhhStatLogDaily(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询来文函号月报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DjLwhhStatLogMonth> djLwhhStatLogMonth(Page<DjLwhhStatLogMonth> page, DjLwhhStatLogMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djLwhhStatLogMonth(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询境内源ip日报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DjSrcIpDomesticStatLogDaily> djSrcIpDomesticStatLogDaily(Page<DjSrcIpDomesticStatLogDaily> page, DjSrcIpDomesticStatLogDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djSrcIpDomesticStatLogDaily(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询境内源ip月报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DjSrcIpDomesticStatLogMonth> djSrcIpDomesticStatLogMonth(Page<DjSrcIpDomesticStatLogMonth> page, DjSrcIpDomesticStatLogMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djSrcIpDomesticStatLogMonth(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询国家目的ip日报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DjDestIpCounrtyStatLogDaily> djDestIpCounrtyStatLogDaily(Page<DjDestIpCounrtyStatLogDaily> page, DjDestIpCounrtyStatLogDaily entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djDestIpCounrtyStatLogDaily(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 查询国家目的ip月报表
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DjDestIpCounrtyStatLogMonth> djDestIpCounrtyStatLogMonth(Page<DjDestIpCounrtyStatLogMonth> page, DjDestIpCounrtyStatLogMonth entity) throws SQLException{
|
||||
entity.setPage(page);
|
||||
page.setList(dao.djDestIpCounrtyStatLogMonth(entity));
|
||||
return page;
|
||||
}
|
||||
|
||||
}
|
||||
53
src/main/java/com/nis/web/service/restful/DmbCkService.java
Normal file
53
src/main/java/com/nis/web/service/restful/DmbCkService.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
*@Title: DmbCkService.java
|
||||
*@Package com.nis.web.service.restful
|
||||
*@Description TODO
|
||||
*@author wx
|
||||
*@date 2016年9月7日 下午3:28:44
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DmbCk;
|
||||
import com.nis.web.dao.DmbCkDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
|
||||
/**
|
||||
* @ClassName: DmbCkService.java
|
||||
* @Description: TODO
|
||||
* @author (wx)
|
||||
* @date 2016年9月7日 下午3:28:44
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DmbCkService extends CrudService<DmbCkDao, DmbCk> {
|
||||
@Autowired
|
||||
public DmbCkDao dmbCkDao;
|
||||
public Page<DmbCk> getDmbCk(Page<DmbCk> page, DmbCk entity) {
|
||||
return findPage(page, entity);
|
||||
}
|
||||
|
||||
public DmbCk findById(long id) {
|
||||
return get(id);
|
||||
}
|
||||
public void saveDmbCkBatch(List<DmbCk> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
super.saveBatch(entity,DmbCkDao.class);
|
||||
}
|
||||
public void updateDmbCkBatch(List<DmbCk> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
super.updateBatch(entity, DmbCkDao.class);
|
||||
}
|
||||
public void removeDmbCk(long id) {
|
||||
dmbCkDao.delete(id);
|
||||
}
|
||||
public void removeDmbCkBatch(List<DmbCk> entity) {
|
||||
super.deleteBatch(entity, DmbCkDao.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
*@Title: DmbPortService.java
|
||||
*@Package com.nis.web.service.restful
|
||||
*@Description TODO
|
||||
*@author wx
|
||||
*@date 2016年9月7日 下午3:28:44
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DmbPort;
|
||||
import com.nis.web.dao.DmbPortDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
|
||||
/**
|
||||
* @ClassName: DmbPortService.java
|
||||
* @Description: TODO
|
||||
* @author (wx)
|
||||
* @date 2016年9月7日 下午3:28:44
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DmbPortService extends CrudService<DmbPortDao, DmbPort> {
|
||||
@Autowired
|
||||
public DmbPortDao dmbPortDao;
|
||||
public Page<DmbPort> getDmbPort(Page<DmbPort> page, DmbPort entity) {
|
||||
return findPage(page, entity);
|
||||
}
|
||||
|
||||
public DmbPort findById(long id) {
|
||||
return get(id);
|
||||
}
|
||||
public void saveDmbPortBatch(List<DmbPort> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
super.saveBatch(entity,DmbPortDao.class);
|
||||
}
|
||||
public void updateDmbPortBatch(List<DmbPort> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
super.updateBatch(entity, DmbPortDao.class);
|
||||
}
|
||||
public void removeDmbPort(long id) {
|
||||
dmbPortDao.delete(id);
|
||||
}
|
||||
public void removeDmbPortBatch(List<DmbPort> entity) {
|
||||
super.deleteBatch(entity, DmbPortDao.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
*@Title: DnsFakeInfoService.java
|
||||
*@Package com.nis.web.service.restful
|
||||
*@Description TODO
|
||||
*@author wx
|
||||
*@date 2016年9月7日 下午3:28:44
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DnsFakeInfo;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.web.dao.DnsFakeInfoDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
|
||||
/**
|
||||
* @ClassName: DnsFakeInfoService.java
|
||||
* @Description: TODO
|
||||
* @author (wx)
|
||||
* @date 2016年9月7日 下午3:28:44
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DnsFakeInfoService extends CrudService<DnsFakeInfoDao, DnsFakeInfo> {
|
||||
@Autowired
|
||||
public DnsFakeInfoDao dnsFakeInfoDao;
|
||||
public Page<DnsFakeInfo> getDnsFakeInfo(Page<DnsFakeInfo> page, DnsFakeInfo entity) {
|
||||
return findPage(page, entity);
|
||||
}
|
||||
|
||||
public DnsFakeInfo findById(long id) {
|
||||
return get(id);
|
||||
}
|
||||
public void saveDnsFakeInfoBatch(List<DnsFakeInfo> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
super.saveBatch(entity,DnsFakeInfoDao.class);
|
||||
}
|
||||
public void updateDnsFakeInfoBatch(List<DnsFakeInfo> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
super.updateBatch(entity, DnsFakeInfoDao.class);
|
||||
}
|
||||
public void removeDnsFakeInfo(long id) {
|
||||
dnsFakeInfoDao.delete(id);
|
||||
}
|
||||
public void removeDnsFakeInfoBatch(List<DnsFakeInfo> entity) {
|
||||
super.deleteBatch(entity, DnsFakeInfoDao.class);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* isValid(单条有效验证)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param id
|
||||
* @return
|
||||
*boolean
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public boolean isValid(long id){
|
||||
return dnsFakeInfoDao.isValid(id)==Integer.parseInt(Constants.YES);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* isValid(多条有效验证)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param entity
|
||||
* @return
|
||||
*boolean
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public boolean isValid(List<DnsFakeInfo> entity){
|
||||
boolean vaild=false;
|
||||
List<Long> idsList=new ArrayList<Long>();
|
||||
for(DnsFakeInfo DnsFakeInfo : entity){
|
||||
idsList.add(DnsFakeInfo.getId());
|
||||
if(idsList.size()%1000==0&&idsList.size()!=0){
|
||||
int count=dnsFakeInfoDao.isValidBatch(idsList,Integer.parseInt(Constants.YES));
|
||||
idsList.clear();
|
||||
if(count>0){
|
||||
vaild=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(idsList.size()>0){
|
||||
int count=dnsFakeInfoDao.isValidBatch(idsList,Integer.parseInt(Constants.YES));
|
||||
idsList.clear();
|
||||
if(count>0)vaild=true;
|
||||
}
|
||||
return vaild;
|
||||
}
|
||||
}
|
||||
163
src/main/java/com/nis/web/service/restful/DnsFakeIpService.java
Normal file
163
src/main/java/com/nis/web/service/restful/DnsFakeIpService.java
Normal file
@@ -0,0 +1,163 @@
|
||||
/**
|
||||
*@Title: DnsFakeIpService.java
|
||||
*@Package com.nis.web.service.restful
|
||||
*@Description TODO
|
||||
*@author wx
|
||||
*@date 2016年9月7日 下午3:28:44
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DnsFakeIp;
|
||||
import com.nis.domain.restful.FakeIpConfigCompile;
|
||||
import com.nis.domain.restful.FakeIpConfigGroup;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.web.dao.CrudDao;
|
||||
import com.nis.web.dao.DnsFakeIpDao;
|
||||
import com.nis.web.dao.FakeIpConfigCompileDao;
|
||||
import com.nis.web.dao.FakeIpConfigGroupDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
|
||||
/**
|
||||
* @ClassName: DnsFakeIpService.java
|
||||
* @Description: TODO
|
||||
* @author (wx)
|
||||
* @date 2016年9月7日 下午3:28:44
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DnsFakeIpService extends CrudService<DnsFakeIpDao, DnsFakeIp> {
|
||||
@Autowired
|
||||
public DnsFakeIpDao dnsFakeIpDao;
|
||||
@Autowired
|
||||
public FakeIpConfigCompileDao fakeIpConfigCompileDao;
|
||||
@Autowired
|
||||
public FakeIpConfigGroupDao fakeIpConfigGroupDao;
|
||||
public Page<DnsFakeIp> getDnsFakeIp(Page<DnsFakeIp> page, DnsFakeIp entity) {
|
||||
return findPage(page, entity);
|
||||
}
|
||||
|
||||
public DnsFakeIp findById(long id) {
|
||||
return get(id);
|
||||
}
|
||||
public void saveDnsFakeIpBatch(List<DnsFakeIp> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
this.saveBatch(entity,DnsFakeIpDao.class);
|
||||
}
|
||||
public void updateDnsFakeIpBatch(List<DnsFakeIp> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
super.updateBatch(entity, DnsFakeIpDao.class);
|
||||
}
|
||||
public void removeDnsFakeIp(long id) {
|
||||
dnsFakeIpDao.delete(id);
|
||||
}
|
||||
public void removeDnsFakeIpBatch(List<DnsFakeIp> entity) {
|
||||
super.deleteBatch(entity, DnsFakeIpDao.class);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* isValid(单条有效验证)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param id
|
||||
* @return
|
||||
*boolean
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public boolean isValid(long id){
|
||||
return dnsFakeIpDao.isValid(id)==Integer.parseInt(Constants.YES);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* isValid(多条有效验证)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param entity
|
||||
* @return
|
||||
*boolean
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public boolean isValid(List<DnsFakeIp> entity){
|
||||
boolean vaild=false;
|
||||
List<Long> idsList=new ArrayList<Long>();
|
||||
for(DnsFakeIp DnsFakeIp : entity){
|
||||
idsList.add(DnsFakeIp.getId());
|
||||
if(idsList.size()%1000==0&&idsList.size()!=0){
|
||||
int count=dnsFakeIpDao.isValidBatch(idsList,Integer.parseInt(Constants.YES));
|
||||
idsList.clear();
|
||||
if(count>0){
|
||||
vaild=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(idsList.size()>0){
|
||||
int count=dnsFakeIpDao.isValidBatch(idsList,Integer.parseInt(Constants.YES));
|
||||
idsList.clear();
|
||||
if(count>0)vaild=true;
|
||||
}
|
||||
return vaild;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.nis.web.service.CrudService#saveBatch(java.util.List, java.lang.Class)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void saveBatch(List<DnsFakeIp> data, @SuppressWarnings("rawtypes") Class mClass) {
|
||||
Date now=new Date();
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try{
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for(int index = 0; index < data.size();index++){
|
||||
DnsFakeIp t = data.get(index);
|
||||
((DnsFakeIpDao) batchSqlSession.getMapper(mClass)).insert(t);
|
||||
if(t.getGroupId()==0||t.getGroupId()==1){
|
||||
//先生成编译,获得编译号
|
||||
FakeIpConfigCompile fakeIpConfigCompile=new FakeIpConfigCompile();
|
||||
long compileId=fakeIpConfigCompileDao.getCompileId();
|
||||
fakeIpConfigCompile.setLastUpdate(now);
|
||||
System.out.println(compileId);
|
||||
fakeIpConfigCompile.setCompileId(compileId);
|
||||
if(t.getGroupId()==0){
|
||||
fakeIpConfigCompile.setAction(2);
|
||||
}else if(t.getGroupId()==1)
|
||||
fakeIpConfigCompile.setAction(1);
|
||||
fakeIpConfigCompile.setOpTime(t.getOpTime());
|
||||
fakeIpConfigCompile.setActiveSys(3);
|
||||
((FakeIpConfigCompileDao) batchSqlSession.getMapper(FakeIpConfigCompileDao.class)).insert(fakeIpConfigCompile);
|
||||
//生成分组
|
||||
FakeIpConfigGroup fakeIpConfigGroup=new FakeIpConfigGroup();
|
||||
fakeIpConfigGroup.setLastUpdate(now);
|
||||
fakeIpConfigGroup.setGroupId(t.getGroupId());
|
||||
fakeIpConfigGroup.setCompileId(compileId);
|
||||
fakeIpConfigGroup.setOpTime(t.getOpTime());
|
||||
((FakeIpConfigGroupDao) batchSqlSession.getMapper(FakeIpConfigGroupDao.class)).insert(fakeIpConfigGroup);
|
||||
}
|
||||
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
// }catch (Exception e){
|
||||
// batchSqlSession.rollback();
|
||||
// throw e;
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
/**
|
||||
*@Title: DnsGroupTypeService.java
|
||||
*@Package com.nis.web.service.restful
|
||||
*@Description TODO
|
||||
*@author dell
|
||||
*@date 2016年9月7日 下午3:28:44
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DnsGroupType;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.web.dao.DnsGroupTypeDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
import com.nis.web.service.SaveRequestLogThread;
|
||||
|
||||
/**
|
||||
* @ClassName: DnsGroupTypeService.java
|
||||
* @Description: TODO
|
||||
* @author (wx)
|
||||
* @date 2016年9月7日 下午3:28:44
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DnsGroupTypeService extends CrudService<DnsGroupTypeDao, DnsGroupType> {
|
||||
@Autowired
|
||||
public DnsGroupTypeDao dnsGroupTypeDao;
|
||||
public Page<DnsGroupType> getDnsGroupType(Page<DnsGroupType> page, DnsGroupType entity) {
|
||||
return findPage(page, entity);
|
||||
}
|
||||
|
||||
public DnsGroupType findById(long id) {
|
||||
return get(id);
|
||||
}
|
||||
public void saveDnsGroupTypeBatch(SaveRequestLogThread thread,long start,List<DnsGroupType> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
List<Integer> idsList=new ArrayList<>();
|
||||
for(DnsGroupType e:entity){
|
||||
if(e.getGroupId()!=null)
|
||||
idsList.add(e.getGroupId());
|
||||
}
|
||||
if(idsList.size()>0){
|
||||
boolean unique=this.groupIdValidation(idsList);
|
||||
if(!unique)
|
||||
throw new RestServiceException(thread, System.currentTimeMillis(), "分组号不唯一", RestBusinessCode.not_unique.getValue());
|
||||
}
|
||||
super.saveBatch(entity,DnsGroupTypeDao.class);
|
||||
}
|
||||
public void updateDnsGroupTypeBatch(SaveRequestLogThread thread,long start,List<DnsGroupType> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
// List<Integer> idsList=new ArrayList<>();
|
||||
// for(DnsGroupType e:entity){
|
||||
// if(e.getGroupId()!=null)
|
||||
// idsList.add(e.getGroupId());
|
||||
// }
|
||||
// if(idsList.size()>0){
|
||||
// boolean unique=this.groupIdValidation(idsList);
|
||||
// if(!unique)
|
||||
// throw new RestServiceException(thread, System.currentTimeMillis(), "分组号不唯一", RestBusinessCode.not_unique.getValue());
|
||||
//
|
||||
// }
|
||||
super.updateBatch(entity, DnsGroupTypeDao.class);
|
||||
}
|
||||
public void removeDnsGroupType(long id) {
|
||||
dnsGroupTypeDao.delete(id);
|
||||
}
|
||||
public void removeDnsGroupTypeBatch(List<DnsGroupType> entity) {
|
||||
super.deleteBatch(entity, DnsGroupTypeDao.class);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* isValid(单条有效验证)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param id
|
||||
* @return
|
||||
*boolean
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public boolean isValid(long id){
|
||||
return dnsGroupTypeDao.isValid(id)==Integer.parseInt(Constants.YES);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* isValid(多条有效验证)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param entity
|
||||
* @return
|
||||
*boolean
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public boolean isValid(List<DnsGroupType> entity){
|
||||
boolean vaild=false;
|
||||
List<Long> idsList=new ArrayList<Long>();
|
||||
for(DnsGroupType dnsGroupType : entity){
|
||||
idsList.add(dnsGroupType.getId());
|
||||
if(idsList.size()%1000==0&&idsList.size()!=0){
|
||||
int count=dnsGroupTypeDao.isValidBatch(idsList,Integer.parseInt(Constants.YES));
|
||||
idsList.clear();
|
||||
if(count>0){
|
||||
vaild=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(idsList.size()>0){
|
||||
int count=dnsGroupTypeDao.isValidBatch(idsList,Integer.parseInt(Constants.YES));
|
||||
idsList.clear();
|
||||
if(count>0)vaild=true;
|
||||
}
|
||||
return vaild;
|
||||
}
|
||||
/**
|
||||
* 验证字段唯一性
|
||||
* reqStrateIdValidation(这里用一句话描述这个方法的作用)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @return
|
||||
*boolean
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public boolean groupIdValidation(List<Integer> idsList){
|
||||
int count=0;
|
||||
if(idsList.size()>=1000){
|
||||
int i=0;
|
||||
for(;i<idsList.size()/1000;i++){
|
||||
List<Integer> subList=idsList.subList(i*1000,(i+1)*1000);
|
||||
count=dnsGroupTypeDao.isGroupIdUnique(subList);
|
||||
if(count>0){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(idsList.size()>(i*1000)){
|
||||
List<Integer> subList=idsList.subList(i*1000,idsList.size());
|
||||
count=dnsGroupTypeDao.isGroupIdUnique(subList);
|
||||
}
|
||||
}else{
|
||||
count=dnsGroupTypeDao.isGroupIdUnique(idsList);
|
||||
}
|
||||
return count==0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
/**
|
||||
*@Title: DnsResponseStrategy.java
|
||||
*@Package com.nis.web.controller.restful
|
||||
*@Description TODO
|
||||
*@author dell
|
||||
*@date 2016年9月5日 下午3:37:54
|
||||
*@version 1.0
|
||||
*/
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DnsResponseStrategy;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.web.dao.DnsResponseStrategyDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
import com.nis.web.service.SaveRequestLogThread;
|
||||
|
||||
/**
|
||||
* @ClassName: DnsResponseStrategy.java
|
||||
* @Description: TODO
|
||||
* @author (dell)
|
||||
* @date 2016年9月5日 下午3:37:54
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class DnsResponseStrategyService extends CrudService<DnsResponseStrategyDao, DnsResponseStrategy> {
|
||||
@Autowired
|
||||
public DnsResponseStrategyDao dnsResponseStrategyDao;
|
||||
public Page<DnsResponseStrategy> getDnsResponseStrategy(Page<DnsResponseStrategy> page, DnsResponseStrategy dnsResponseStrategy) {
|
||||
return findPage(page, dnsResponseStrategy);
|
||||
}
|
||||
|
||||
public DnsResponseStrategy findById(long id) {
|
||||
return get(id);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* saveDnsResponseStrategyBatch(多条插入)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param entity
|
||||
*void
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public void saveDnsResponseStrategyBatch(List<DnsResponseStrategy> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
super.saveBatch(entity,DnsResponseStrategyDao.class);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* saveDnsResponseStrategyBatch(多条插入)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param entity
|
||||
*void
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public void saveDnsResponseStrategyBatch(SaveRequestLogThread thread,long start,List<DnsResponseStrategy> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
List idsList=new ArrayList<>();
|
||||
for(DnsResponseStrategy e:entity){
|
||||
if(e.getReqStrateId()!=null)
|
||||
idsList.add(e.getReqStrateId());
|
||||
}
|
||||
if(idsList.size()>0){
|
||||
boolean uinque=this.reqStrateIdValidation(idsList);
|
||||
if(!uinque){
|
||||
throw new RestServiceException(thread, System.currentTimeMillis(), "请求策略号不唯一", RestBusinessCode.not_unique.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
super.saveBatch(entity,DnsResponseStrategyDao.class);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* updateDnsResponseStrategyBatch(多条更新)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param entity
|
||||
*void
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public void updateDnsResponseStrategyBatch(List<DnsResponseStrategy> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
super.updateBatch(entity, DnsResponseStrategyDao.class);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* updateDnsResponseStrategyBatch(多条更新)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param entity
|
||||
*void
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public void updateDnsResponseStrategyBatch(SaveRequestLogThread thread,long start,List<DnsResponseStrategy> entity) {
|
||||
// List idsList=new ArrayList<>();
|
||||
// for(DnsResponseStrategy e:entity){
|
||||
// if(e.getReqStrateId()!=null)
|
||||
// idsList.add(e.getReqStrateId());
|
||||
// }
|
||||
// if(idsList.size()>0){
|
||||
// boolean uinque=this.reqStrateIdValidation(idsList);
|
||||
// if(!uinque){
|
||||
// throw new RestServiceException(thread, System.currentTimeMillis(), "请求策略号不唯一", RestBusinessCode.not_unique.getValue());
|
||||
// }
|
||||
// }
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
super.updateBatch(entity, DnsResponseStrategyDao.class);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* removeDnsResponseStrategy(单条删除)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param id
|
||||
*void
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public void removeDnsResponseStrategy(long id) {
|
||||
dnsResponseStrategyDao.delete(id);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* removeDnsResponseStrategyBatch(多条删除)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param entity
|
||||
*void
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public void removeDnsResponseStrategyBatch(List<DnsResponseStrategy> entity) {
|
||||
super.deleteBatch(entity, DnsResponseStrategyDao.class);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* isValid(单条有效验证)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param id
|
||||
* @return
|
||||
*boolean
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public boolean isValid(long id){
|
||||
return dnsResponseStrategyDao.isValid(id)==Integer.parseInt(Constants.YES);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* isValid(多条有效验证)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @param entity
|
||||
* @return
|
||||
*boolean
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public boolean isValid(List<DnsResponseStrategy> entity){
|
||||
boolean vaild=false;
|
||||
List<Long> idsList=new ArrayList<Long>();
|
||||
for(DnsResponseStrategy dnsResponseStrategy : entity){
|
||||
idsList.add(dnsResponseStrategy.getId());
|
||||
if(idsList.size()%1000==0&&idsList.size()!=0){
|
||||
int count=dnsResponseStrategyDao.isValidBatch(idsList,Integer.parseInt(Constants.YES));
|
||||
idsList.clear();
|
||||
if(count>0){
|
||||
vaild=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(idsList.size()>0){
|
||||
int count=dnsResponseStrategyDao.isValidBatch(idsList,Integer.parseInt(Constants.YES));
|
||||
idsList.clear();
|
||||
if(count>0)vaild=true;
|
||||
}
|
||||
return vaild;
|
||||
}
|
||||
/**
|
||||
* 验证字段唯一性
|
||||
* reqStrateIdValidation(这里用一句话描述这个方法的作用)
|
||||
* (这里描述这个方法适用条件 – 可选)
|
||||
* @return
|
||||
*boolean
|
||||
* @exception
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public boolean reqStrateIdValidation(List<Integer> idsList){
|
||||
int count=0;
|
||||
if(idsList.size()>=1000){
|
||||
int i=0;
|
||||
for(;i<idsList.size()/1000;i++){
|
||||
List<Integer> subList=idsList.subList(i*1000,(i+1)*1000);
|
||||
count=dnsResponseStrategyDao.isReqStrateIdUnique(subList);
|
||||
if(count>0){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(idsList.size()>(i*1000)){
|
||||
List<Integer> subList=idsList.subList(i*1000,idsList.size());
|
||||
count=dnsResponseStrategyDao.isReqStrateIdUnique(subList);
|
||||
}
|
||||
}else{
|
||||
count=dnsResponseStrategyDao.isReqStrateIdUnique(idsList);
|
||||
}
|
||||
return count==0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
*@Title: EncryptProtoRandomService.java
|
||||
*@Package com.nis.web.service.restful
|
||||
*@Description TODO
|
||||
*@author wx
|
||||
*@date 2016年9月7日 下午3:28:44
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.EncryptProtoRandom;
|
||||
import com.nis.web.dao.EncryptProtoRandomDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
|
||||
/**
|
||||
* @ClassName: EncryptProtoRandomService.java
|
||||
* @Description: TODO
|
||||
* @author (wx)
|
||||
* @date 2016年9月7日 下午3:28:44
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class EncryptProtoRandomService extends CrudService<EncryptProtoRandomDao, EncryptProtoRandom> {
|
||||
@Autowired
|
||||
public EncryptProtoRandomDao encryptProtoRandomDao;
|
||||
public Page<EncryptProtoRandom> getEncryptProtoRandom(Page<EncryptProtoRandom> page, EncryptProtoRandom entity) {
|
||||
return findPage(page, entity);
|
||||
}
|
||||
|
||||
public EncryptProtoRandom findById(long id) {
|
||||
return get(id);
|
||||
}
|
||||
public void saveEncryptProtoRandomBatch(List<EncryptProtoRandom> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
super.saveBatch(entity,EncryptProtoRandomDao.class);
|
||||
}
|
||||
public void updateEncryptProtoRandomBatch(List<EncryptProtoRandom> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
super.updateBatch(entity, EncryptProtoRandomDao.class);
|
||||
}
|
||||
public void removeEncryptProtoRandom(Long id) {
|
||||
encryptProtoRandomDao.delete(id);
|
||||
}
|
||||
public void removeEncryptProtoRandomBatch(List<EncryptProtoRandom> entity) {
|
||||
super.deleteBatch(entity, EncryptProtoRandomDao.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
*@Title: DnsFakeIpService.java
|
||||
*@Package com.nis.web.service.restful
|
||||
*@Description TODO
|
||||
*@author wx
|
||||
*@date 2016年9月7日 下午3:28:44
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.restful.FakeIpConfigCompile;
|
||||
import com.nis.web.dao.FakeIpConfigCompileDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
|
||||
/**
|
||||
* @ClassName: DnsFakeIpService.java
|
||||
* @Description: TODO
|
||||
* @author (wx)
|
||||
* @date 2016年9月7日 下午3:28:44
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class FakeIpConfigCompileService extends CrudService<FakeIpConfigCompileDao, FakeIpConfigCompile> {
|
||||
@Autowired
|
||||
public FakeIpConfigCompileDao fakeIpConfigCompileDao;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
*@Title: DnsFakeIpService.java
|
||||
*@Package com.nis.web.service.restful
|
||||
*@Description TODO
|
||||
*@author wx
|
||||
*@date 2016年9月7日 下午3:28:44
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.restful.FakeIpConfigGroup;
|
||||
import com.nis.web.dao.FakeIpConfigGroupDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
|
||||
/**
|
||||
* @ClassName: DnsFakeIpService.java
|
||||
* @Description: TODO
|
||||
* @author (wx)
|
||||
* @date 2016年9月7日 下午3:28:44
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class FakeIpConfigGroupService extends CrudService<FakeIpConfigGroupDao, FakeIpConfigGroup> {
|
||||
@Autowired
|
||||
public FakeIpConfigGroupDao fakeIpConfigGroupDao;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
*@Title: FwqInfoService.java
|
||||
*@Package com.nis.web.service.restful
|
||||
*@Description TODO
|
||||
*@author wx
|
||||
*@date 2016年9月7日 下午3:28:44
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.FwqInfo;
|
||||
import com.nis.web.dao.FwqInfoDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
|
||||
/**
|
||||
* @ClassName: FwqInfoService.java
|
||||
* @Description: TODO
|
||||
* @author (wx)
|
||||
* @date 2016年9月7日 下午3:28:44
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class FwqInfoService extends CrudService<FwqInfoDao, FwqInfo> {
|
||||
@Autowired
|
||||
public FwqInfoDao fwqInfoDao;
|
||||
public Page<FwqInfo> getFwqInfo(Page<FwqInfo> page, FwqInfo entity) {
|
||||
return findPage(page, entity);
|
||||
}
|
||||
|
||||
public FwqInfo findById(long id) {
|
||||
return get(id);
|
||||
}
|
||||
public void saveFwqInfoBatch(List<FwqInfo> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
super.saveBatch(entity,FwqInfoDao.class);
|
||||
}
|
||||
public void updateFwqInfoBatch(List<FwqInfo> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
super.updateBatch(entity, FwqInfoDao.class);
|
||||
}
|
||||
public void removeFwqInfo(long id) {
|
||||
fwqInfoDao.delete(id);
|
||||
}
|
||||
public void removeFwqInfoBatch(List<FwqInfo> entity) {
|
||||
super.deleteBatch(entity, FwqInfoDao.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DfKeyConvertUrl;
|
||||
import com.nis.domain.restful.DjFlowControlStop;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.IntervalTimeSearchDao;
|
||||
import com.nis.web.service.BaseLogService;
|
||||
import com.nis.web.service.SaveRequestLogThread;
|
||||
|
||||
/**
|
||||
* @ClassName: IntervalTimeSearchService
|
||||
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||
* @author (zbc)
|
||||
* @date 2016年9月8日下午8:11:58
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class IntervalTimeSearchService extends BaseLogService {
|
||||
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
protected final Logger logger = Logger.getLogger(this.getClass());
|
||||
/**
|
||||
* 持久层对象
|
||||
*/
|
||||
@Autowired
|
||||
protected IntervalTimeSearchDao dao;
|
||||
|
||||
/**
|
||||
* 查询分页数据
|
||||
* @param page 分页对象
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public Page<DjFlowControlStop> findFlowControlStopPage(Page<DjFlowControlStop> page,
|
||||
DjFlowControlStop entity) {
|
||||
entity.setPage(page);
|
||||
page.setList(dao.findFlowControlStopPage(entity));
|
||||
return page;
|
||||
}
|
||||
/**
|
||||
* 流控日志查询条件检查
|
||||
* wx
|
||||
* @param entity
|
||||
*/
|
||||
public void queryConditionCheck(SaveRequestLogThread thread,long start,DjFlowControlStop entity,Page page) {
|
||||
/*try {
|
||||
if (!StringUtil.isBlank(entity.getSearchCfgId())) {
|
||||
Long.parseLong(entity.getSearchCfgId());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchCfgId参数格式错误",
|
||||
RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "searchCfgId参数错误");
|
||||
}*/
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getOptStartTime())) {
|
||||
sdf.parse(entity.getOptStartTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread,System.currentTimeMillis()-start,"optStartTime参数格式错误", RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread,System.currentTimeMillis()-start,"optStartTime参数格式错误");
|
||||
}
|
||||
|
||||
try {
|
||||
if (!StringUtil.isBlank(entity.getOptEndTime())) {
|
||||
sdf.parse(entity.getOptEndTime());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread,System.currentTimeMillis()-start,"optEndTime参数格式错误", RestBusinessCode.param_formate_error.getValue());
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread,System.currentTimeMillis()-start,"optEndTime参数错误");
|
||||
}
|
||||
|
||||
try {
|
||||
checkCloumnIsExist(thread,start,DjFlowControlStop.class, page);
|
||||
} catch (RestServiceException e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
logger.error(e);
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请求参数错误");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
221
src/main/java/com/nis/web/service/restful/JDBCTest.java
Normal file
221
src/main/java/com/nis/web/service/restful/JDBCTest.java
Normal file
@@ -0,0 +1,221 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.List;
|
||||
import com.nis.domain.restful.ConfigCompile;
|
||||
import com.nis.domain.restful.ConfigGroupRelation;
|
||||
import com.nis.domain.restful.IpRegion;
|
||||
import com.nis.domain.restful.NumRegion;
|
||||
import com.nis.domain.restful.StrRegion;
|
||||
|
||||
/**
|
||||
* jdbc测试批量插入
|
||||
*
|
||||
* @author RenKaiGe-Office
|
||||
*
|
||||
*/
|
||||
public class JDBCTest {
|
||||
public static java.sql.Timestamp utileDate2TimeStamp(java.util.Date udate) {
|
||||
java.sql.Timestamp sqlDate = null;
|
||||
long t = udate.getTime();
|
||||
sqlDate = new java.sql.Timestamp(t);
|
||||
return sqlDate;
|
||||
|
||||
}
|
||||
|
||||
public static void saveCompile(List<ConfigCompile> compileList, Connection conn, int batchSize) throws Exception {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(
|
||||
"insert into CONFIG_COMPILE (COMPILE_ID ,SERVICE ,ACTION , CONT_TYPE, ATTR_TYPE, CONT_LABEL, Task_id, Guarantee_ID, AFFAIR_ID, TOPIC_ID, DO_BLACKLIST ,DO_LOG ,EFFECTIVE_RANGE , ACTIVE_SYS, CONFIG_PERCENT ,CONFIG_OPTION ,START_TIME ,END_TIME , USER_REGION, IS_VALID,GROUP_NUM,FATHER_CFG_ID ,OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate)");
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
int count = 0;
|
||||
for (ConfigCompile compile : compileList) {
|
||||
count++;
|
||||
Object[] obj = new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
|
||||
compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
|
||||
compile.getGuaranteeId(), compile.getAffAirId(), compile.getTopIcId(), compile.getDoBlackList(),
|
||||
compile.getDoLog(), compile.getEffectiveRange(), compile.getActiveSys(), compile.getConfigPercent(),
|
||||
compile.getConfigOption(), compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(),
|
||||
compile.getIsValid(), compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() };
|
||||
|
||||
for (int x = 0; x < obj.length; x++) {
|
||||
if (x == 16) {
|
||||
ps.setTimestamp(x + 1, utileDate2TimeStamp(compile.getStartTime()));
|
||||
} else if (x == 17) {
|
||||
ps.setTimestamp(x + 1, utileDate2TimeStamp(compile.getEndTime()));
|
||||
} else if (x == 22) {
|
||||
ps.setTimestamp(x + 1, utileDate2TimeStamp(compile.getOpTime()));
|
||||
} else {
|
||||
ps.setObject(x + 1, obj[x]);
|
||||
}
|
||||
}
|
||||
ps.addBatch();
|
||||
if (count % batchSize == 0) {
|
||||
ps.executeBatch();
|
||||
////conn.commit();
|
||||
}
|
||||
}
|
||||
ps.executeBatch();
|
||||
//conn.commit();
|
||||
}
|
||||
|
||||
public static void saveGroup(List<ConfigGroupRelation> groupList, Connection conn, int batchSize) throws Exception {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(
|
||||
"insert into CONFIG_GROUP (ID,GROUP_ID, COMPILE_ID, IS_VALID, LAST_UPDATE, OP_TIME ) values ( seq_config_group.nextval, ?, ?, ?, sysdate, ?) ");
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
int count = 0;
|
||||
for (ConfigGroupRelation group : groupList) {
|
||||
count++;
|
||||
Object[] obj = new Object[] { group.getGroupId(), group.getCompileId(), group.getIsValid(),
|
||||
group.getOpTime() };
|
||||
for (int x = 0; x < obj.length; x++) {
|
||||
if (x == 3) {
|
||||
ps.setTimestamp(x + 1, utileDate2TimeStamp(group.getOpTime()));
|
||||
} else {
|
||||
ps.setObject(x + 1, obj[x]);
|
||||
}
|
||||
}
|
||||
ps.addBatch();
|
||||
if (count % batchSize == 0) {
|
||||
ps.executeBatch();
|
||||
//conn.commit();
|
||||
}
|
||||
}
|
||||
ps.executeBatch();
|
||||
//conn.commit();
|
||||
}
|
||||
|
||||
public static void saveIPRegion(String name, List<IpRegion> ipRegionList, Connection conn, int batchSize)
|
||||
throws Exception {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(name);
|
||||
sb.append(
|
||||
"(REGION_ID, GROUP_ID, ADDR_TYPE, SRC_IP, MASK_SRC_IP, SRC_PORT, MASK_SRC_PORT, DST_IP, MASK_DST_IP, DST_PORT, MASK_DST_PORT, PROTOCOL, DIRECTION, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
int count = 0;
|
||||
for (IpRegion ipRegion : ipRegionList) {
|
||||
count++;
|
||||
Object[] obj = new Object[] { ipRegion.getRegionId(), ipRegion.getGroupId(), ipRegion.getAddrType(),
|
||||
ipRegion.getSrcIp(), ipRegion.getMaskSrcIp(), ipRegion.getSrcPort(), ipRegion.getMaskSrcPort(),
|
||||
ipRegion.getDstIp(), ipRegion.getMaskDstIp(), ipRegion.getDstPort(), ipRegion.getMaskDstPort(),
|
||||
ipRegion.getProtocol(), ipRegion.getDirection(), ipRegion.getIsValid(), ipRegion.getOpTime()
|
||||
|
||||
};
|
||||
for (int x = 0; x < obj.length; x++) {
|
||||
if (x == 14) {
|
||||
ps.setTimestamp(x + 1, utileDate2TimeStamp(ipRegion.getOpTime()));
|
||||
} else {
|
||||
ps.setObject(x + 1, obj[x]);
|
||||
}
|
||||
}
|
||||
ps.addBatch();
|
||||
if (count % batchSize == 0) {
|
||||
ps.executeBatch();
|
||||
//conn.commit();
|
||||
}
|
||||
}
|
||||
ps.executeBatch();
|
||||
//conn.commit();
|
||||
}
|
||||
|
||||
public static void saveNumRegion(String name, List<NumRegion> numRegionList, Connection conn, int batchSize)
|
||||
throws Exception {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(name);
|
||||
sb.append(
|
||||
" (REGION_ID,GROUP_ID,LOW_BOUNDARY,UP_BOUNDARY,IS_VALID,OP_TIME,LAST_UPDATE) values(?, ?, ?, ?, ?, ?, sysdate)");
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
int count = 0;
|
||||
for (NumRegion numRegion : numRegionList) {
|
||||
count++;
|
||||
Object[] obj = new Object[] { numRegion.getRegionId(), numRegion.getGroupId(), numRegion.getLowBoundary(),
|
||||
numRegion.getUpBoundary(), numRegion.getIsValid(), numRegion.getOpTime() };
|
||||
for (int x = 0; x < obj.length; x++) {
|
||||
if (x == 5) {
|
||||
ps.setTimestamp(x + 1, utileDate2TimeStamp(numRegion.getOpTime()));
|
||||
} else {
|
||||
ps.setObject(x + 1, obj[x]);
|
||||
}
|
||||
}
|
||||
ps.addBatch();
|
||||
if (count % batchSize == 0) {
|
||||
ps.executeBatch();
|
||||
//conn.commit();
|
||||
}
|
||||
}
|
||||
ps.executeBatch();
|
||||
//conn.commit();
|
||||
}
|
||||
|
||||
public static void saveStrongStrRegion(String name, List<StrRegion> strRegionList, Connection conn, int batchSize)
|
||||
throws Exception {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(name);
|
||||
sb.append(
|
||||
"(REGION_ID, GROUP_ID, DISTRICT, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
int count = 0;
|
||||
for (StrRegion strRegion : strRegionList) {
|
||||
count++;
|
||||
Object[] obj = new Object[] { strRegion.getRegionId(), strRegion.getGroupId(), strRegion.getDistrict(),
|
||||
strRegion.getKeywords(), strRegion.getExprType(), strRegion.getMatchMethod(),
|
||||
strRegion.getIsHexbin(), strRegion.getIsValid(), strRegion.getOpTime() };
|
||||
for (int x = 0; x < obj.length; x++) {
|
||||
if (x == 8) {
|
||||
ps.setTimestamp(x + 1, utileDate2TimeStamp(strRegion.getOpTime()));
|
||||
} else {
|
||||
ps.setObject(x + 1, obj[x]);
|
||||
}
|
||||
}
|
||||
ps.addBatch();
|
||||
if (count % batchSize == 0) {
|
||||
ps.executeBatch();
|
||||
//conn.commit();
|
||||
}
|
||||
}
|
||||
ps.executeBatch();
|
||||
//conn.commit();
|
||||
}
|
||||
|
||||
public static void saveStrRegion(String name, List<StrRegion> strRegionList, Connection conn, int batchSize)
|
||||
throws Exception {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(name);
|
||||
sb.append(
|
||||
"(REGION_ID, GROUP_ID, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
int count = 0;
|
||||
for (StrRegion strRegion : strRegionList) {
|
||||
count++;
|
||||
Object[] obj = new Object[] { strRegion.getRegionId(), strRegion.getGroupId(), strRegion.getKeywords(),
|
||||
strRegion.getExprType(), strRegion.getMatchMethod(), strRegion.getIsHexbin(),
|
||||
strRegion.getIsValid(), strRegion.getOpTime() };
|
||||
for (int x = 0; x < obj.length; x++) {
|
||||
if (x == 7) {
|
||||
ps.setTimestamp(x + 1, utileDate2TimeStamp(strRegion.getOpTime()));
|
||||
} else {
|
||||
ps.setObject(x + 1, obj[x]);
|
||||
}
|
||||
}
|
||||
ps.addBatch();
|
||||
if (count % batchSize == 0) {
|
||||
ps.executeBatch();
|
||||
//conn.commit();
|
||||
}
|
||||
}
|
||||
ps.executeBatch();
|
||||
//conn.commit();
|
||||
}
|
||||
}
|
||||
472
src/main/java/com/nis/web/service/restful/JDBCThreadTest.java
Normal file
472
src/main/java/com/nis/web/service/restful/JDBCThreadTest.java
Normal file
@@ -0,0 +1,472 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import com.nis.domain.restful.ConfigCompile;
|
||||
import com.nis.domain.restful.ConfigGroupRelation;
|
||||
import com.nis.domain.restful.IpRegion;
|
||||
import com.nis.domain.restful.NumRegion;
|
||||
import com.nis.domain.restful.StrRegion;
|
||||
import com.nis.web.service.SaveRequestLogThread;
|
||||
|
||||
/**
|
||||
* jdbc测试批量插入
|
||||
*
|
||||
* @author RenKaiGe-Office
|
||||
*
|
||||
*/
|
||||
public class JDBCThreadTest implements Runnable {
|
||||
|
||||
private static SaveRequestLogThread thread;
|
||||
private static Long start;
|
||||
private CountDownLatch latch;
|
||||
private Boolean isStrongStr;
|
||||
private String tableName;
|
||||
private int batchSize;
|
||||
private Connection conn;
|
||||
private List<ConfigCompile> compileList;
|
||||
private List<ConfigGroupRelation> groupList;
|
||||
private List<IpRegion> ipRegionList;
|
||||
private List<NumRegion> numRegionList;
|
||||
private List<StrRegion> strRegionList;
|
||||
|
||||
public JDBCThreadTest() {
|
||||
super();
|
||||
}
|
||||
|
||||
public JDBCThreadTest(int batchSize, Connection conn, CountDownLatch latch, SaveRequestLogThread thread,
|
||||
Long start) {
|
||||
super();
|
||||
this.batchSize = batchSize;
|
||||
this.conn = conn;
|
||||
this.latch = latch;
|
||||
}
|
||||
|
||||
public JDBCThreadTest(String tableName, int batchSize, Connection conn, CountDownLatch latch,
|
||||
SaveRequestLogThread thread, Long start) {
|
||||
super();
|
||||
this.tableName = tableName;
|
||||
this.batchSize = batchSize;
|
||||
this.conn = conn;
|
||||
this.latch = latch;
|
||||
}
|
||||
|
||||
public JDBCThreadTest(boolean isStrongStr, String tableName, int batchSize, Connection conn, CountDownLatch latch,
|
||||
SaveRequestLogThread thread, Long start) {
|
||||
super();
|
||||
this.isStrongStr = isStrongStr;
|
||||
this.tableName = tableName;
|
||||
this.batchSize = batchSize;
|
||||
this.conn = conn;
|
||||
this.latch = latch;
|
||||
}
|
||||
|
||||
public SaveRequestLogThread getThread() {
|
||||
return thread;
|
||||
}
|
||||
|
||||
public void setThread(SaveRequestLogThread thread) {
|
||||
this.thread = thread;
|
||||
}
|
||||
|
||||
public Long getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public void setStart(Long start) {
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public int getBatchSize() {
|
||||
return batchSize;
|
||||
}
|
||||
|
||||
public void setBatchSize(int batchSize) {
|
||||
this.batchSize = batchSize;
|
||||
}
|
||||
|
||||
public CountDownLatch getLatch() {
|
||||
return latch;
|
||||
}
|
||||
|
||||
public void setLatch(CountDownLatch latch) {
|
||||
this.latch = latch;
|
||||
}
|
||||
|
||||
public Boolean getIsStrongStr() {
|
||||
return isStrongStr;
|
||||
}
|
||||
|
||||
public void setIsStrongStr(Boolean isStrongStr) {
|
||||
this.isStrongStr = isStrongStr;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public Connection getConn() {
|
||||
return conn;
|
||||
}
|
||||
|
||||
public void setConn(Connection conn) {
|
||||
this.conn = conn;
|
||||
}
|
||||
|
||||
public List<ConfigCompile> getCompileList() {
|
||||
return compileList;
|
||||
}
|
||||
|
||||
public void setCompileList(List<ConfigCompile> compileList) {
|
||||
this.compileList = compileList;
|
||||
}
|
||||
|
||||
public List<ConfigGroupRelation> getGroupList() {
|
||||
return groupList;
|
||||
}
|
||||
|
||||
public void setGroupList(List<ConfigGroupRelation> groupList) {
|
||||
this.groupList = groupList;
|
||||
}
|
||||
|
||||
public List<IpRegion> getIpRegionList() {
|
||||
return ipRegionList;
|
||||
}
|
||||
|
||||
public void setIpRegionList(List<IpRegion> ipRegionList) {
|
||||
this.ipRegionList = ipRegionList;
|
||||
}
|
||||
|
||||
public List<NumRegion> getNumRegionList() {
|
||||
return numRegionList;
|
||||
}
|
||||
|
||||
public void setNumRegionList(List<NumRegion> numRegionList) {
|
||||
this.numRegionList = numRegionList;
|
||||
}
|
||||
|
||||
public List<StrRegion> getStrRegionList() {
|
||||
return strRegionList;
|
||||
}
|
||||
|
||||
public void setStrRegionList(List<StrRegion> strRegionList) {
|
||||
this.strRegionList = strRegionList;
|
||||
}
|
||||
|
||||
public static java.sql.Timestamp utileDate2TimeStamp(java.util.Date udate) {
|
||||
java.sql.Timestamp sqlDate = null;
|
||||
long t = udate.getTime();
|
||||
sqlDate = new java.sql.Timestamp(t);
|
||||
return sqlDate;
|
||||
|
||||
}
|
||||
|
||||
public static void saveCompile(List<ConfigCompile> compileList, Connection conn, int batchSize) {
|
||||
if (null != conn) {
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(
|
||||
"insert into CONFIG_COMPILE (COMPILE_ID ,SERVICE ,ACTION , CONT_TYPE, ATTR_TYPE, CONT_LABEL, Task_id, Guarantee_ID, AFFAIR_ID, TOPIC_ID, DO_BLACKLIST ,DO_LOG ,EFFECTIVE_RANGE , ACTIVE_SYS, CONFIG_PERCENT ,CONFIG_OPTION ,START_TIME ,END_TIME , USER_REGION, IS_VALID,GROUP_NUM,FATHER_CFG_ID ,OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate)");
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
int count = 0;
|
||||
for (ConfigCompile compile : compileList) {
|
||||
count++;
|
||||
Object[] obj = new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
|
||||
compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
|
||||
compile.getGuaranteeId(), compile.getAffAirId(), compile.getTopIcId(),
|
||||
compile.getDoBlackList(), compile.getDoLog(), compile.getEffectiveRange(),
|
||||
compile.getActiveSys(), compile.getConfigPercent(), compile.getConfigOption(),
|
||||
compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(), compile.getIsValid(),
|
||||
compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() };
|
||||
|
||||
for (int x = 0; x < obj.length; x++) {
|
||||
if (x == 16) {
|
||||
ps.setTimestamp(x + 1, utileDate2TimeStamp(compile.getStartTime()));
|
||||
} else if (x == 17) {
|
||||
ps.setTimestamp(x + 1, utileDate2TimeStamp(compile.getEndTime()));
|
||||
} else if (x == 22) {
|
||||
ps.setTimestamp(x + 1, utileDate2TimeStamp(compile.getOpTime()));
|
||||
} else {
|
||||
ps.setObject(x + 1, obj[x]);
|
||||
}
|
||||
}
|
||||
ps.addBatch();
|
||||
// if (count % batchSize == 0) {
|
||||
// ps.executeBatch();
|
||||
// ps.clearBatch();
|
||||
// }
|
||||
}
|
||||
ps.executeBatch();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
conn.close();
|
||||
conn = null;
|
||||
} catch (SQLException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
// ps.close();
|
||||
// conn.commit();
|
||||
}
|
||||
|
||||
public static void saveGroup(List<ConfigGroupRelation> groupList, Connection conn, int batchSize) {
|
||||
if (null != conn) {
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(
|
||||
"insert into CONFIG_GROUP (ID,GROUP_ID, COMPILE_ID, IS_VALID, LAST_UPDATE, OP_TIME ) values ( seq_config_group.nextval, ?, ?, ?, sysdate, ?) ");
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
int count = 0;
|
||||
for (ConfigGroupRelation group : groupList) {
|
||||
count++;
|
||||
Object[] obj = new Object[] { group.getGroupId(), group.getCompileId(), group.getIsValid(),
|
||||
group.getOpTime() };
|
||||
for (int x = 0; x < obj.length; x++) {
|
||||
if (x == 3) {
|
||||
ps.setTimestamp(x + 1, utileDate2TimeStamp(group.getOpTime()));
|
||||
} else {
|
||||
ps.setObject(x + 1, obj[x]);
|
||||
}
|
||||
}
|
||||
ps.addBatch();
|
||||
// if (count % batchSize == 0) {
|
||||
// ps.executeBatch();
|
||||
// ps.clearBatch();
|
||||
// }
|
||||
}
|
||||
ps.executeBatch();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
conn.close();
|
||||
conn = null;
|
||||
} catch (SQLException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
// ps.close();
|
||||
// conn.commit();
|
||||
}
|
||||
|
||||
public static void saveIPRegion(String name, List<IpRegion> ipRegionList, Connection conn, int batchSize) {
|
||||
if (null != conn) {
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(name);
|
||||
sb.append(
|
||||
"(REGION_ID, GROUP_ID, ADDR_TYPE, SRC_IP, MASK_SRC_IP, SRC_PORT, MASK_SRC_PORT, DST_IP, MASK_DST_IP, DST_PORT, MASK_DST_PORT, PROTOCOL, DIRECTION, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
int count = 0;
|
||||
for (IpRegion ipRegion : ipRegionList) {
|
||||
count++;
|
||||
Object[] obj = new Object[] { ipRegion.getRegionId(), ipRegion.getGroupId(), ipRegion.getAddrType(),
|
||||
ipRegion.getSrcIp(), ipRegion.getMaskSrcIp(), ipRegion.getSrcPort(),
|
||||
ipRegion.getMaskSrcPort(), ipRegion.getDstIp(), ipRegion.getMaskDstIp(),
|
||||
ipRegion.getDstPort(), ipRegion.getMaskDstPort(), ipRegion.getProtocol(),
|
||||
ipRegion.getDirection(), ipRegion.getIsValid(), ipRegion.getOpTime()
|
||||
|
||||
};
|
||||
for (int x = 0; x < obj.length; x++) {
|
||||
if (x == 14) {
|
||||
ps.setTimestamp(x + 1, utileDate2TimeStamp(ipRegion.getOpTime()));
|
||||
} else {
|
||||
ps.setObject(x + 1, obj[x]);
|
||||
}
|
||||
}
|
||||
ps.addBatch();
|
||||
// if (count % batchSize == 0) {
|
||||
// ps.executeBatch();
|
||||
// ps.clearBatch();
|
||||
// }
|
||||
}
|
||||
ps.executeBatch();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
conn.close();
|
||||
conn = null;
|
||||
} catch (SQLException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
// ps.close();
|
||||
// conn.commit();
|
||||
}
|
||||
|
||||
public static void saveNumRegion(String name, List<NumRegion> numRegionList, Connection conn, int batchSize) {
|
||||
if (null != conn) {
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(name);
|
||||
sb.append(
|
||||
" (REGION_ID,GROUP_ID,LOW_BOUNDARY,UP_BOUNDARY,IS_VALID,OP_TIME,LAST_UPDATE) values(?, ?, ?, ?, ?, ?, sysdate)");
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
int count = 0;
|
||||
for (NumRegion numRegion : numRegionList) {
|
||||
count++;
|
||||
Object[] obj = new Object[] { numRegion.getRegionId(), numRegion.getGroupId(),
|
||||
numRegion.getLowBoundary(), numRegion.getUpBoundary(), numRegion.getIsValid(),
|
||||
numRegion.getOpTime() };
|
||||
for (int x = 0; x < obj.length; x++) {
|
||||
if (x == 5) {
|
||||
ps.setTimestamp(x + 1, utileDate2TimeStamp(numRegion.getOpTime()));
|
||||
} else {
|
||||
ps.setObject(x + 1, obj[x]);
|
||||
}
|
||||
}
|
||||
ps.addBatch();
|
||||
// if (count % batchSize == 0) {
|
||||
// ps.executeBatch();
|
||||
// ps.clearBatch();
|
||||
// }
|
||||
}
|
||||
ps.executeBatch();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
conn.close();
|
||||
conn = null;
|
||||
} catch (SQLException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
// ps.close();
|
||||
// conn.commit();
|
||||
}
|
||||
|
||||
public static void saveStrongStrRegion(String name, List<StrRegion> strRegionList, Connection conn, int batchSize) {
|
||||
if (null != conn) {
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(name);
|
||||
sb.append(
|
||||
"(REGION_ID, GROUP_ID, DISTRICT, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
|
||||
int count = 0;
|
||||
for (StrRegion strRegion : strRegionList) {
|
||||
count++;
|
||||
Object[] obj = new Object[] { strRegion.getRegionId(), strRegion.getGroupId(),
|
||||
strRegion.getDistrict(), strRegion.getKeywords(), strRegion.getExprType(),
|
||||
strRegion.getMatchMethod(), strRegion.getIsHexbin(), strRegion.getIsValid(),
|
||||
strRegion.getOpTime() };
|
||||
for (int x = 0; x < obj.length; x++) {
|
||||
if (x == 8) {
|
||||
ps.setTimestamp(x + 1, utileDate2TimeStamp(strRegion.getOpTime()));
|
||||
} else {
|
||||
ps.setObject(x + 1, obj[x]);
|
||||
}
|
||||
}
|
||||
ps.addBatch();
|
||||
// if (count % batchSize == 0) {
|
||||
// ps.executeBatch();
|
||||
// ps.clearBatch();
|
||||
// }
|
||||
}
|
||||
ps.executeBatch();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
conn.close();
|
||||
conn = null;
|
||||
} catch (SQLException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
// ps.close();
|
||||
// conn.commit();
|
||||
}
|
||||
|
||||
public static void saveStrRegion(String name, List<StrRegion> strRegionList, Connection conn, int batchSize) {
|
||||
if (null != conn) {
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(name);
|
||||
sb.append(
|
||||
"(REGION_ID, GROUP_ID, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
|
||||
int count = 0;
|
||||
for (StrRegion strRegion : strRegionList) {
|
||||
count++;
|
||||
Object[] obj = new Object[] { strRegion.getRegionId(), strRegion.getGroupId(),
|
||||
strRegion.getKeywords(), strRegion.getExprType(), strRegion.getMatchMethod(),
|
||||
strRegion.getIsHexbin(), strRegion.getIsValid(), strRegion.getOpTime() };
|
||||
for (int x = 0; x < obj.length; x++) {
|
||||
if (x == 7) {
|
||||
ps.setTimestamp(x + 1, utileDate2TimeStamp(strRegion.getOpTime()));
|
||||
} else {
|
||||
ps.setObject(x + 1, obj[x]);
|
||||
}
|
||||
}
|
||||
ps.addBatch();
|
||||
// if (count % batchSize == 0) {
|
||||
// ps.executeBatch();
|
||||
// ps.clearBatch();
|
||||
// }
|
||||
}
|
||||
ps.executeBatch();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
conn.close();
|
||||
conn = null;
|
||||
} catch (SQLException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
// ps.close();
|
||||
// conn.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (conn) {
|
||||
try {
|
||||
if (null != compileList && compileList.size() > 0) {
|
||||
saveCompile(compileList, conn, batchSize);
|
||||
} else if (null != groupList && groupList.size() > 0) {
|
||||
saveGroup(groupList, conn, batchSize);
|
||||
} else if (null != ipRegionList && ipRegionList.size() > 0) {
|
||||
saveIPRegion(tableName, ipRegionList, conn, batchSize);
|
||||
} else if (null != strRegionList && strRegionList.size() > 0) {
|
||||
if (null != isStrongStr && isStrongStr) {
|
||||
saveStrongStrRegion(tableName, strRegionList, conn, batchSize);
|
||||
} else {
|
||||
saveStrRegion(tableName, strRegionList, conn, batchSize);
|
||||
}
|
||||
}else if (null != numRegionList && numRegionList.size() > 0) {
|
||||
saveNumRegion(tableName, numRegionList, conn, batchSize);
|
||||
}
|
||||
latch.countDown();
|
||||
System.out.println("latchCount=======================" + latch.getCount());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
*@Title: JdjInfoService.java
|
||||
*@Package com.nis.web.service.restful
|
||||
*@Description TODO
|
||||
*@author wx
|
||||
*@date 2016年9月7日 下午3:28:44
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.JdjInfo;
|
||||
import com.nis.web.dao.JdjInfoDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
|
||||
/**
|
||||
* @ClassName: JdjInfoService.java
|
||||
* @Description: TODO
|
||||
* @author (wx)
|
||||
* @date 2016年9月7日 下午3:28:44
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class JdjInfoService extends CrudService<JdjInfoDao, JdjInfo> {
|
||||
@Autowired
|
||||
public JdjInfoDao jdjInfoDao;
|
||||
public Page<JdjInfo> getJdjInfo(Page<JdjInfo> page, JdjInfo entity) {
|
||||
return findPage(page, entity);
|
||||
}
|
||||
|
||||
public JdjInfo findById(long id) {
|
||||
return get(id);
|
||||
}
|
||||
public void saveJdjInfoBatch(List<JdjInfo> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
super.saveBatch(entity,JdjInfoDao.class);
|
||||
}
|
||||
public void updateJdjInfoBatch(List<JdjInfo> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
super.updateBatch(entity, JdjInfoDao.class);
|
||||
}
|
||||
public void removeJdjInfo(long id) {
|
||||
jdjInfoDao.delete(id);
|
||||
}
|
||||
public void removeJdjInfoBatch(List<JdjInfo> entity) {
|
||||
super.deleteBatch(entity, JdjInfoDao.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,637 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.nis.domain.restful.ConfigCompile;
|
||||
import com.nis.domain.restful.ConfigGroupRelation;
|
||||
import com.nis.domain.restful.IpRegion;
|
||||
import com.nis.domain.restful.NumRegion;
|
||||
import com.nis.domain.restful.StrRegion;
|
||||
import com.nis.util.Configurations;
|
||||
import com.thoughtworks.xstream.core.util.Fields;
|
||||
|
||||
/**
|
||||
* jdbc测试批量插入
|
||||
*
|
||||
* @author RenKaiGe-Office
|
||||
*
|
||||
*/
|
||||
public class SaveCompileByJDBCThread implements Runnable {
|
||||
private static Logger logger = Logger.getLogger(SaveCompileByJDBCThread.class);
|
||||
private static Long start;
|
||||
private CountDownLatch latch;
|
||||
private Boolean isStrongStr;
|
||||
private String tableName;
|
||||
private Connection conn;
|
||||
private List<ConfigCompile> compileList;
|
||||
private List<ConfigGroupRelation> groupList;
|
||||
private List<IpRegion> ipRegionList;
|
||||
private List<NumRegion> numRegionList;
|
||||
private List<StrRegion> strRegionList;
|
||||
|
||||
|
||||
private Method method = null;
|
||||
public SaveCompileByJDBCThread() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SaveCompileByJDBCThread(Connection conn, CountDownLatch latch, Long start) {
|
||||
super();
|
||||
this.conn = conn;
|
||||
this.latch = latch;
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public SaveCompileByJDBCThread(String tableName, Connection conn, CountDownLatch latch, Long start) {
|
||||
super();
|
||||
this.tableName = tableName;
|
||||
this.conn = conn;
|
||||
this.latch = latch;
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public SaveCompileByJDBCThread(boolean isStrongStr, String tableName, Connection conn, CountDownLatch latch,
|
||||
Long start) {
|
||||
super();
|
||||
this.isStrongStr = isStrongStr;
|
||||
this.tableName = tableName;
|
||||
this.conn = conn;
|
||||
this.latch = latch;
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public Long getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public void setStart(Long start) {
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public CountDownLatch getLatch() {
|
||||
return latch;
|
||||
}
|
||||
|
||||
public void setLatch(CountDownLatch latch) {
|
||||
this.latch = latch;
|
||||
}
|
||||
|
||||
public Boolean getIsStrongStr() {
|
||||
return isStrongStr;
|
||||
}
|
||||
|
||||
public void setIsStrongStr(Boolean isStrongStr) {
|
||||
this.isStrongStr = isStrongStr;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public Connection getConn() {
|
||||
return conn;
|
||||
}
|
||||
|
||||
public void setConn(Connection conn) {
|
||||
this.conn = conn;
|
||||
}
|
||||
|
||||
public List<ConfigCompile> getCompileList() {
|
||||
return compileList;
|
||||
}
|
||||
|
||||
public void setCompileList(List<ConfigCompile> compileList) {
|
||||
this.compileList = compileList;
|
||||
}
|
||||
|
||||
public List<ConfigGroupRelation> getGroupList() {
|
||||
return groupList;
|
||||
}
|
||||
|
||||
public void setGroupList(List<ConfigGroupRelation> groupList) {
|
||||
this.groupList = groupList;
|
||||
}
|
||||
|
||||
public List<IpRegion> getIpRegionList() {
|
||||
return ipRegionList;
|
||||
}
|
||||
|
||||
public void setIpRegionList(List<IpRegion> ipRegionList) {
|
||||
this.ipRegionList = ipRegionList;
|
||||
}
|
||||
|
||||
public List<NumRegion> getNumRegionList() {
|
||||
return numRegionList;
|
||||
}
|
||||
|
||||
public void setNumRegionList(List<NumRegion> numRegionList) {
|
||||
this.numRegionList = numRegionList;
|
||||
}
|
||||
|
||||
public List<StrRegion> getStrRegionList() {
|
||||
return strRegionList;
|
||||
}
|
||||
|
||||
public void setStrRegionList(List<StrRegion> strRegionList) {
|
||||
this.strRegionList = strRegionList;
|
||||
}
|
||||
|
||||
public static java.sql.Timestamp utileDate2TimeStamp(java.util.Date udate) {
|
||||
java.sql.Timestamp sqlDate = null;
|
||||
long t = udate.getTime();
|
||||
sqlDate = new java.sql.Timestamp(t);
|
||||
return sqlDate;
|
||||
|
||||
}
|
||||
|
||||
public static void saveCompile(List<ConfigCompile> compileList, Connection conn, List<Exception> msgList) {
|
||||
if (null != compileList && compileList.size() > 0) {
|
||||
try {
|
||||
String tabName = Configurations.getStringProperty("compileTabName", "CONFIG_COMPILE");
|
||||
String fieldName = Configurations.getStringProperty("compileFieldName", "COMPILE_ID");
|
||||
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(getSqlStr(tabName, fieldName));
|
||||
for (ConfigCompile compile : compileList) {
|
||||
setPsParams(fieldName.split(","),ps,compile);
|
||||
ps.addBatch();
|
||||
}
|
||||
|
||||
//zdx2017-10-25
|
||||
// sb.append(
|
||||
// "insert into CONFIG_COMPILE (COMPILE_ID ,SERVICE ,ACTION , CONT_TYPE, ATTR_TYPE, CONT_LABEL, Task_id, Guarantee_ID, AFFAIR_ID, TOPIC_ID, DO_BLACKLIST ,DO_LOG ,EFFECTIVE_RANGE , ACTIVE_SYS, CONFIG_PERCENT ,CONFIG_OPTION ,START_TIME ,END_TIME , USER_REGION, IS_VALID,GROUP_NUM,FATHER_CFG_ID ,OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate)");
|
||||
// conn.setAutoCommit(false);
|
||||
// PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
// for (ConfigCompile compile : compileList) {
|
||||
// Object[] obj = new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
|
||||
// compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
|
||||
// compile.getGuaranteeId(), compile.getAffAirId(), compile.getTopIcId(),
|
||||
// compile.getDoBlackList(), compile.getDoLog(), compile.getEffectiveRange(),
|
||||
// compile.getActiveSys(), compile.getConfigPercent(), compile.getConfigOption(),
|
||||
// compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(), compile.getIsValid(),
|
||||
// compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() };
|
||||
//
|
||||
// for (int x = 0; x < obj.length; x++) {
|
||||
// if (x == 16) {
|
||||
// ps.setTimestamp(x + 1, utileDate2TimeStamp(compile.getStartTime()));
|
||||
// } else if (x == 17) {
|
||||
// ps.setTimestamp(x + 1, utileDate2TimeStamp(compile.getEndTime()));
|
||||
// } else if (x == 22) {
|
||||
// ps.setTimestamp(x + 1, utileDate2TimeStamp(compile.getOpTime()));
|
||||
// } else {
|
||||
// ps.setObject(x + 1, obj[x]);
|
||||
// }
|
||||
// }
|
||||
// ps.addBatch();
|
||||
// }
|
||||
ps.executeBatch();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
msgList.add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveGroup(List<ConfigGroupRelation> groupList, Connection conn, List<Exception> msgList) {
|
||||
|
||||
if (null != groupList && groupList.size() > 0) {
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String tabName = Configurations.getStringProperty("groupTabName", "CONFIG_GROUP");
|
||||
String fieldName = Configurations.getStringProperty("groupFieldName", "ID");
|
||||
String groupSeqName = Configurations.getStringProperty("groupSeqName", "SEQ_CONFIG_GROUP");
|
||||
sb.append("insert into ").append(tabName);
|
||||
sb.append("(").append(fieldName);
|
||||
//是否包含更新时间字段 值为数据库当前时间
|
||||
if (Configurations.getBooleanProperty("hasLastUpdate", true)) {
|
||||
sb.append(", LAST_UPDATE");
|
||||
}
|
||||
sb.append(") values ( ");
|
||||
conn.setAutoCommit(false);
|
||||
String fieldNameObj [] = fieldName.split(",");
|
||||
for (int i = 0; i < fieldNameObj.length; i++) {
|
||||
//第一个字段必须是分组表主键
|
||||
if (i==0) {
|
||||
sb.append(groupSeqName).append(".nextval");
|
||||
}else{
|
||||
sb.append("?");
|
||||
}
|
||||
if (i+1<fieldNameObj.length) {
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
//是否包含更新时间字段 值为数据库当前时间
|
||||
if (Configurations.getBooleanProperty("hasLastUpdate", true)) {
|
||||
sb.append(", sysdate");
|
||||
}
|
||||
sb.append(")");
|
||||
conn.setAutoCommit(false);
|
||||
|
||||
PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
|
||||
for (ConfigGroupRelation group : groupList) {
|
||||
//setPsParams(fieldNameObj,ps,group);
|
||||
|
||||
Object[] obj = new Object[fieldNameObj.length] ;
|
||||
|
||||
for (int i = 1; i < fieldNameObj.length; i++) {
|
||||
String name = fieldNameObj[i].toLowerCase().trim();
|
||||
name = name.substring(0,1).toUpperCase()+name.substring(1);
|
||||
if (name.indexOf("_")>-1) {
|
||||
// name = name.substring(0, name.indexOf("_"))+name.substring(name.indexOf("_")+1,name.indexOf("_")+2).toUpperCase()+name.substring(name.indexOf("_")+2);
|
||||
// }
|
||||
|
||||
while (name.indexOf("_")>-1) {
|
||||
name = name.substring(0, name.indexOf("_"))+name.substring(name.indexOf("_")+1,name.indexOf("_")+2).toUpperCase()+name.substring(name.indexOf("_")+2);
|
||||
}
|
||||
}
|
||||
|
||||
Method method = group.getClass().getMethod("get"+name);
|
||||
obj[i]= method.invoke(group);
|
||||
}
|
||||
for (int x = 1; x < obj.length; x++) {
|
||||
|
||||
if (obj[x] instanceof Date) {
|
||||
ps.setObject(x, utileDate2TimeStamp((Date) obj[x]));
|
||||
}else {
|
||||
ps.setObject(x , obj[x]);
|
||||
}
|
||||
}
|
||||
ps.addBatch();
|
||||
}
|
||||
ps.executeBatch();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
e.printStackTrace();
|
||||
msgList.add(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//zdx2017-10-25
|
||||
// if (null != groupList && groupList.size() > 0) {
|
||||
// try {
|
||||
// StringBuffer sb = new StringBuffer();
|
||||
// sb.append(
|
||||
// "insert into CONFIG_GROUP (ID,GROUP_ID, COMPILE_ID, IS_VALID, LAST_UPDATE, OP_TIME ) values ( seq_config_group.nextval, ?, ?, ?, sysdate, ?) ");
|
||||
// conn.setAutoCommit(false);
|
||||
// PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
// for (ConfigGroupRelation group : groupList) {
|
||||
// Object[] obj = new Object[] { group.getGroupId(), group.getCompileId(), group.getIsValid(),
|
||||
// group.getOpTime() };
|
||||
// for (int x = 0; x < obj.length; x++) {
|
||||
// if (x == 3) {
|
||||
// ps.setTimestamp(x + 1, utileDate2TimeStamp(group.getOpTime()));
|
||||
// } else {
|
||||
// ps.setObject(x + 1, obj[x]);
|
||||
// }
|
||||
// }
|
||||
// ps.addBatch();
|
||||
// }
|
||||
// ps.executeBatch();
|
||||
// } catch (Exception e) {
|
||||
// logger.error(e);
|
||||
// msgList.add(e);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public static void saveIPRegion(String name, List<IpRegion> ipRegionList, Connection conn,
|
||||
List<Exception> msgList) {
|
||||
|
||||
if (null != ipRegionList && ipRegionList.size() > 0) {
|
||||
try {
|
||||
String fieldName = Configurations.getStringProperty("ipRegionFieldName", "REGION_ID");
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(getSqlStr(name, fieldName));
|
||||
for (IpRegion ipRegion : ipRegionList) {
|
||||
setPsParams(fieldName.split(","),ps,ipRegion);
|
||||
ps.addBatch();
|
||||
}
|
||||
ps.executeBatch();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
msgList.add(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//zdx2017-10-25
|
||||
// if (null != ipRegionList && ipRegionList.size() > 0) {
|
||||
// try {
|
||||
// StringBuffer sb = new StringBuffer();
|
||||
// sb.append("insert into ");
|
||||
// sb.append(name);
|
||||
// sb.append(
|
||||
// "(REGION_ID, GROUP_ID, ADDR_TYPE, SRC_IP, MASK_SRC_IP, SRC_PORT, MASK_SRC_PORT, DST_IP, MASK_DST_IP, DST_PORT, MASK_DST_PORT, PROTOCOL, DIRECTION, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
|
||||
// conn.setAutoCommit(false);
|
||||
// PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
// for (IpRegion ipRegion : ipRegionList) {
|
||||
// Object[] obj = new Object[] { ipRegion.getRegionId(), ipRegion.getGroupId(), ipRegion.getAddrType(),
|
||||
// ipRegion.getSrcIp(), ipRegion.getMaskSrcIp(), ipRegion.getSrcPort(),
|
||||
// ipRegion.getMaskSrcPort(), ipRegion.getDstIp(), ipRegion.getMaskDstIp(),
|
||||
// ipRegion.getDstPort(), ipRegion.getMaskDstPort(), ipRegion.getProtocol(),
|
||||
// ipRegion.getDirection(), ipRegion.getIsValid(), ipRegion.getOpTime()
|
||||
//
|
||||
// };
|
||||
// for (int x = 0; x < obj.length; x++) {
|
||||
// if (x == 14) {
|
||||
// ps.setTimestamp(x + 1, utileDate2TimeStamp(ipRegion.getOpTime()));
|
||||
// } else {
|
||||
// ps.setObject(x + 1, obj[x]);
|
||||
// }
|
||||
// }
|
||||
// ps.addBatch();
|
||||
// }
|
||||
// ps.executeBatch();
|
||||
// } catch (Exception e) {
|
||||
// logger.error(e);
|
||||
// msgList.add(e);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public static void saveNumRegion(String name, List<NumRegion> numRegionList, Connection conn,
|
||||
List<Exception> msgList) {
|
||||
if (null != numRegionList && numRegionList.size() > 0) {
|
||||
try {
|
||||
String fieldName = Configurations.getStringProperty("numRegionFieldName", "REGION_ID");
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(getSqlStr(name, fieldName));
|
||||
for (NumRegion numRegion : numRegionList) {
|
||||
setPsParams(fieldName.split(","),ps,numRegion);
|
||||
ps.addBatch();
|
||||
}
|
||||
|
||||
ps.executeBatch();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
msgList.add(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//zdx2017-10-25
|
||||
// if (null != numRegionList && numRegionList.size() > 0) {
|
||||
// try {
|
||||
// StringBuffer sb = new StringBuffer();
|
||||
// sb.append("insert into ");
|
||||
// sb.append(name);
|
||||
// sb.append(
|
||||
// " (REGION_ID,GROUP_ID,LOW_BOUNDARY,UP_BOUNDARY,IS_VALID,OP_TIME,LAST_UPDATE) values(?, ?, ?, ?, ?, ?, sysdate)");
|
||||
// conn.setAutoCommit(false);
|
||||
// PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
// for (NumRegion numRegion : numRegionList) {
|
||||
// Object[] obj = new Object[] { numRegion.getRegionId(), numRegion.getGroupId(),
|
||||
// numRegion.getLowBoundary(), numRegion.getUpBoundary(), numRegion.getIsValid(),
|
||||
// numRegion.getOpTime() };
|
||||
// for (int x = 0; x < obj.length; x++) {
|
||||
// if (x == 5) {
|
||||
// ps.setTimestamp(x + 1, utileDate2TimeStamp(numRegion.getOpTime()));
|
||||
// } else {
|
||||
// ps.setObject(x + 1, obj[x]);
|
||||
// }
|
||||
// }
|
||||
// ps.addBatch();
|
||||
// }
|
||||
// ps.executeBatch();
|
||||
// } catch (Exception e) {
|
||||
// logger.error(e);
|
||||
// msgList.add(e);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public static void saveStrongStrRegion(String name, List<StrRegion> strRegionList, Connection conn,
|
||||
List<Exception> msgList) {
|
||||
|
||||
if (null != strRegionList && strRegionList.size() > 0) {
|
||||
try {
|
||||
String fieldName = Configurations.getStringProperty("strongStrRegionFieldName", "REGION_ID");
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(getSqlStr(name, fieldName));
|
||||
for (StrRegion strRegion : strRegionList) {
|
||||
setPsParams(fieldName.split(","),ps,strRegion);
|
||||
ps.addBatch();
|
||||
}
|
||||
ps.executeBatch();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
msgList.add(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//zdx2017-10-25
|
||||
// if (null != strRegionList && strRegionList.size() > 0) {
|
||||
// try {
|
||||
// StringBuffer sb = new StringBuffer();
|
||||
// sb.append("insert into ");
|
||||
// sb.append(name);
|
||||
// sb.append(
|
||||
// "(REGION_ID, GROUP_ID, DISTRICT, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
|
||||
// conn.setAutoCommit(false);
|
||||
// PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
//
|
||||
// for (StrRegion strRegion : strRegionList) {
|
||||
// Object[] obj = new Object[] { strRegion.getRegionId(), strRegion.getGroupId(),
|
||||
// strRegion.getDistrict(), strRegion.getKeywords(), strRegion.getExprType(),
|
||||
// strRegion.getMatchMethod(), strRegion.getIsHexbin(), strRegion.getIsValid(),
|
||||
// strRegion.getOpTime() };
|
||||
// for (int x = 0; x < obj.length; x++) {
|
||||
// if (x == 8) {
|
||||
// ps.setTimestamp(x + 1, utileDate2TimeStamp(strRegion.getOpTime()));
|
||||
// } else {
|
||||
// ps.setObject(x + 1, obj[x]);
|
||||
// }
|
||||
// }
|
||||
// ps.addBatch();
|
||||
// }
|
||||
// ps.executeBatch();
|
||||
// } catch (Exception e) {
|
||||
// logger.error(e);
|
||||
// msgList.add(e);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public static void saveStrRegion(String name, List<StrRegion> strRegionList, Connection conn,
|
||||
List<Exception> msgList) {
|
||||
|
||||
if (null != strRegionList && strRegionList.size() > 0) {
|
||||
try {
|
||||
String fieldName = Configurations.getStringProperty("strRegionFieldName", "REGION_ID");
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(getSqlStr(name, fieldName));
|
||||
for (StrRegion strRegion : strRegionList) {
|
||||
setPsParams(fieldName.split(","),ps,strRegion);
|
||||
ps.addBatch();
|
||||
}
|
||||
ps.executeBatch();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
msgList.add(e);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//zdx2017-10-25
|
||||
// if (null != strRegionList && strRegionList.size() > 0) {
|
||||
// try {
|
||||
// StringBuffer sb = new StringBuffer();
|
||||
// sb.append("insert into ");
|
||||
// sb.append(name);
|
||||
// sb.append(
|
||||
// "(REGION_ID, GROUP_ID, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
|
||||
// conn.setAutoCommit(false);
|
||||
// PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
//
|
||||
// for (StrRegion strRegion : strRegionList) {
|
||||
// Object[] obj = new Object[] { strRegion.getRegionId(), strRegion.getGroupId(),
|
||||
// strRegion.getKeywords(), strRegion.getExprType(), strRegion.getMatchMethod(),
|
||||
// strRegion.getIsHexbin(), strRegion.getIsValid(), strRegion.getOpTime() };
|
||||
// for (int x = 0; x < obj.length; x++) {
|
||||
// if (x == 7) {
|
||||
// ps.setTimestamp(x + 1, utileDate2TimeStamp(strRegion.getOpTime()));
|
||||
// } else {
|
||||
// ps.setObject(x + 1, obj[x]);
|
||||
// }
|
||||
// }
|
||||
// ps.addBatch();
|
||||
// }
|
||||
// ps.executeBatch();
|
||||
// } catch (Exception e) {
|
||||
// logger.error(e);
|
||||
// msgList.add(e);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @Description:根据表名和字段名称构建sql
|
||||
* @author (zdx)
|
||||
* @date 2017年10月26日 上午9:50:16
|
||||
* @param tabName
|
||||
* @param fieldName
|
||||
* @return
|
||||
*/
|
||||
private static String getSqlStr(String tabName,String fieldName){
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(tabName);
|
||||
sb.append("(").append(fieldName);
|
||||
|
||||
//是否包含更新时间字段 值为数据库当前时间
|
||||
if (Configurations.getBooleanProperty("hasLastUpdate", true)) {
|
||||
sb.append(", LAST_UPDATE");
|
||||
}
|
||||
sb.append(") values (");
|
||||
|
||||
String fieldNameObj [] = fieldName.split(",");
|
||||
for (int i = 0; i < fieldNameObj.length; i++) {
|
||||
sb.append("?");
|
||||
if (i+1<fieldNameObj.length) {
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
//是否包含更新时间字段 值为数据库当前时间
|
||||
if (Configurations.getBooleanProperty("hasLastUpdate", true)) {
|
||||
sb.append(", sysdate");
|
||||
}
|
||||
|
||||
sb.append(") ");
|
||||
return sb.toString();
|
||||
}
|
||||
/**
|
||||
* @Description: 向PreparedStatement设置参数
|
||||
* @author (zdx)
|
||||
* @date 2017年10月26日 上午9:47:33
|
||||
* @param fieldNameObj
|
||||
* @param ps
|
||||
* @param object
|
||||
* @throws Exception
|
||||
*/
|
||||
private static void setPsParams(String [] fieldNameObj,PreparedStatement ps,Object object) throws Exception{
|
||||
Object[] obj = new Object[fieldNameObj.length] ;
|
||||
|
||||
for (int i = 0; i < fieldNameObj.length; i++) {
|
||||
String name = fieldNameObj[i].toLowerCase().trim();
|
||||
name = name.substring(0,1).toUpperCase()+name.substring(1);
|
||||
if (name.indexOf("_")>-1) {
|
||||
// name = name.substring(0, name.indexOf("_"))+name.substring(name.indexOf("_")+1,name.indexOf("_")+2).toUpperCase()+name.substring(name.indexOf("_")+2);
|
||||
// }
|
||||
|
||||
while (name.indexOf("_")>-1) {
|
||||
name = name.substring(0, name.indexOf("_"))+name.substring(name.indexOf("_")+1,name.indexOf("_")+2).toUpperCase()+name.substring(name.indexOf("_")+2);
|
||||
}
|
||||
}
|
||||
|
||||
//需要特殊处理字段名
|
||||
if (name.equals("DoBlacklist")) {
|
||||
name = "DoBlackList";
|
||||
}else if (name.equals("AffairId")) {
|
||||
name = "AffAirId";
|
||||
}else if (name.equals("TopicId")) {
|
||||
name = "TopIcId";
|
||||
}
|
||||
|
||||
Method method = object.getClass().getMethod("get"+name);
|
||||
obj[i]= method.invoke(object);
|
||||
}
|
||||
for (int x = 0; x < obj.length; x++) {
|
||||
|
||||
if (obj[x] instanceof Date) {
|
||||
ps.setObject(x + 1, utileDate2TimeStamp((Date) obj[x]));
|
||||
}else {
|
||||
ps.setObject(x + 1, obj[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
List<Exception> msgList = ConfigSourcesService.getMsgList();
|
||||
synchronized (msgList) {
|
||||
try {
|
||||
if (null != compileList && compileList.size() > 0) {
|
||||
saveCompile(compileList, conn, msgList);
|
||||
} else if (null != groupList && groupList.size() > 0) {
|
||||
saveGroup(groupList, conn, msgList);
|
||||
} else if (null != ipRegionList && ipRegionList.size() > 0) {
|
||||
saveIPRegion(tableName, ipRegionList, conn, msgList);
|
||||
} else if (null != strRegionList && strRegionList.size() > 0) {
|
||||
if (null != isStrongStr && isStrongStr) {
|
||||
saveStrongStrRegion(tableName, strRegionList, conn, msgList);
|
||||
} else {
|
||||
saveStrRegion(tableName, strRegionList, conn, msgList);
|
||||
}
|
||||
} else if (null != numRegionList && numRegionList.size() > 0) {
|
||||
saveNumRegion(tableName, numRegionList, conn, msgList);
|
||||
}
|
||||
latch.countDown();
|
||||
System.out.println("latchCount=======================" + latch.getCount());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
139
src/main/java/com/nis/web/service/restful/SpringJDBCTest.java
Normal file
139
src/main/java/com/nis/web/service/restful/SpringJDBCTest.java
Normal file
@@ -0,0 +1,139 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.sql.Types;
|
||||
import java.util.List;
|
||||
import javax.sql.DataSource;
|
||||
import org.springframework.jdbc.object.BatchSqlUpdate;
|
||||
import com.nis.domain.restful.ConfigCompile;
|
||||
import com.nis.domain.restful.ConfigGroupRelation;
|
||||
import com.nis.domain.restful.IpRegion;
|
||||
import com.nis.domain.restful.NumRegion;
|
||||
import com.nis.domain.restful.StrRegion;
|
||||
|
||||
/**
|
||||
* jdbc测试批量插入
|
||||
*
|
||||
* @author RenKaiGe-Office
|
||||
*
|
||||
*/
|
||||
public class SpringJDBCTest {
|
||||
public static BatchSqlUpdate saveCompile(List<ConfigCompile> compileList, DataSource ds, int batchSize) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(
|
||||
"insert into CONFIG_COMPILE (COMPILE_ID ,SERVICE ,ACTION , CONT_TYPE, ATTR_TYPE, CONT_LABEL, Task_id, Guarantee_ID, AFFAIR_ID, TOPIC_ID, DO_BLACKLIST ,DO_LOG ,EFFECTIVE_RANGE , ACTIVE_SYS, CONFIG_PERCENT ,CONFIG_OPTION ,START_TIME ,END_TIME , USER_REGION, IS_VALID,GROUP_NUM,FATHER_CFG_ID ,OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate)");
|
||||
|
||||
BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
|
||||
bsu.setBatchSize(batchSize);
|
||||
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR,
|
||||
Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR,
|
||||
Types.INTEGER, Types.BIGINT, Types.INTEGER, Types.DATE, Types.DATE, Types.VARCHAR, Types.INTEGER,
|
||||
Types.INTEGER, Types.BIGINT, Types.DATE });
|
||||
for (ConfigCompile compile : compileList) {
|
||||
bsu.update(new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
|
||||
compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
|
||||
compile.getGuaranteeId(), compile.getAffAirId(), compile.getTopIcId(), compile.getDoBlackList(),
|
||||
compile.getDoLog(), compile.getEffectiveRange(), compile.getActiveSys(), compile.getConfigPercent(),
|
||||
compile.getConfigOption(), compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(),
|
||||
compile.getIsValid(), compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() });
|
||||
}
|
||||
// bsu.flush();
|
||||
return bsu;
|
||||
}
|
||||
|
||||
public static BatchSqlUpdate saveGroup(List<ConfigGroupRelation> groupList, DataSource ds, int batchSize) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(
|
||||
"insert into CONFIG_GROUP (ID,GROUP_ID, COMPILE_ID, IS_VALID, LAST_UPDATE, OP_TIME ) values ( seq_config_group.nextval, ?, ?, ?, sysdate, ?) ");
|
||||
BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
|
||||
bsu.setBatchSize(batchSize);
|
||||
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.DATE });
|
||||
for (ConfigGroupRelation group : groupList) {
|
||||
bsu.update(
|
||||
new Object[] { group.getGroupId(), group.getCompileId(), group.getIsValid(), group.getOpTime() });
|
||||
}
|
||||
// bsu.flush();
|
||||
return bsu;
|
||||
}
|
||||
|
||||
public static BatchSqlUpdate saveIPRegion(String name, List<IpRegion> ipRegionList, DataSource ds, int batchSize) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(name);
|
||||
sb.append(
|
||||
"(REGION_ID, GROUP_ID, ADDR_TYPE, SRC_IP, MASK_SRC_IP, SRC_PORT, MASK_SRC_PORT, DST_IP, MASK_DST_IP, DST_PORT, MASK_DST_PORT, PROTOCOL, DIRECTION, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
|
||||
BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
|
||||
bsu.setBatchSize(batchSize);
|
||||
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
|
||||
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER,
|
||||
Types.INTEGER, Types.DATE });
|
||||
for (IpRegion ipRegion : ipRegionList) {
|
||||
bsu.update(new Object[] { ipRegion.getRegionId(), ipRegion.getGroupId(), ipRegion.getAddrType(),
|
||||
ipRegion.getSrcIp(), ipRegion.getMaskSrcIp(), ipRegion.getSrcPort(), ipRegion.getMaskSrcPort(),
|
||||
ipRegion.getDstIp(), ipRegion.getMaskDstIp(), ipRegion.getDstPort(), ipRegion.getMaskDstPort(),
|
||||
ipRegion.getProtocol(), ipRegion.getDirection(), ipRegion.getIsValid(), ipRegion.getOpTime()
|
||||
|
||||
});
|
||||
}
|
||||
// bsu.flush();
|
||||
return bsu;
|
||||
}
|
||||
|
||||
public static BatchSqlUpdate saveNumRegion(String name, List<NumRegion> numRegionList, DataSource ds,
|
||||
int batchSize) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(name);
|
||||
sb.append(
|
||||
" (REGION_ID,GROUP_ID,LOW_BOUNDARY,UP_BOUNDARY,IS_VALID,OP_TIME,LAST_UPDATE) values(?, ?, ?, ?, ?, ?, sysdate)");
|
||||
BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
|
||||
bsu.setBatchSize(batchSize);
|
||||
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.DATE });
|
||||
for (NumRegion numRegion : numRegionList) {
|
||||
bsu.update(new Object[] { numRegion.getRegionId(), numRegion.getGroupId(), numRegion.getLowBoundary(),
|
||||
numRegion.getUpBoundary(), numRegion.getIsValid(), numRegion.getOpTime() });
|
||||
}
|
||||
// bsu.flush();
|
||||
return bsu;
|
||||
}
|
||||
|
||||
public static BatchSqlUpdate saveStrongStrRegion(String name, List<StrRegion> strRegionList, DataSource ds,
|
||||
int batchSize) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(name);
|
||||
sb.append(
|
||||
"(REGION_ID, GROUP_ID, DISTRICT, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
|
||||
BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
|
||||
bsu.setBatchSize(batchSize);
|
||||
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER,
|
||||
Types.INTEGER, Types.INTEGER, Types.DATE });
|
||||
for (StrRegion strRegion : strRegionList) {
|
||||
bsu.update(new Object[] { strRegion.getRegionId(), strRegion.getGroupId(), strRegion.getDistrict(),
|
||||
strRegion.getKeywords(), strRegion.getExprType(), strRegion.getMatchMethod(),
|
||||
strRegion.getIsHexbin(), strRegion.getIsValid(), strRegion.getOpTime() });
|
||||
}
|
||||
// bsu.flush();
|
||||
return bsu;
|
||||
}
|
||||
|
||||
public static BatchSqlUpdate saveStrRegion(String name, List<StrRegion> strRegionList, DataSource ds,
|
||||
int batchSize) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(name);
|
||||
sb.append(
|
||||
"(REGION_ID, GROUP_ID, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
|
||||
BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
|
||||
bsu.setBatchSize(batchSize);
|
||||
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER,
|
||||
Types.INTEGER, Types.DATE });
|
||||
|
||||
for (StrRegion strRegion : strRegionList) {
|
||||
bsu.update(new Object[] { strRegion.getRegionId(), strRegion.getGroupId(), strRegion.getKeywords(),
|
||||
strRegion.getExprType(), strRegion.getMatchMethod(), strRegion.getIsHexbin(),
|
||||
strRegion.getIsValid(), strRegion.getOpTime() });
|
||||
}
|
||||
// bsu.flush();
|
||||
return bsu;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,287 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.Types;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import org.springframework.jdbc.object.BatchSqlUpdate;
|
||||
import com.nis.domain.restful.ConfigCompile;
|
||||
import com.nis.domain.restful.ConfigGroupRelation;
|
||||
import com.nis.domain.restful.IpRegion;
|
||||
import com.nis.domain.restful.NumRegion;
|
||||
import com.nis.domain.restful.StrRegion;
|
||||
|
||||
/**
|
||||
* jdbc测试批量插入
|
||||
*
|
||||
* @author RenKaiGe-Office
|
||||
*
|
||||
*/
|
||||
public class SpringJDBCThreadTest implements Runnable {
|
||||
private CountDownLatch latch;
|
||||
private Boolean isStrongStr;
|
||||
private String tableName;
|
||||
private int batchSize;
|
||||
private BatchSqlUpdate bsu;
|
||||
private List<ConfigCompile> compileList;
|
||||
private List<ConfigGroupRelation> groupList;
|
||||
private List<IpRegion> ipRegionList;
|
||||
private List<NumRegion> numRegionList;
|
||||
private List<StrRegion> strRegionList;
|
||||
|
||||
public SpringJDBCThreadTest() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SpringJDBCThreadTest(int batchSize, BatchSqlUpdate bsu, CountDownLatch latch) {
|
||||
super();
|
||||
this.batchSize = batchSize;
|
||||
this.bsu = bsu;
|
||||
this.latch = latch;
|
||||
}
|
||||
|
||||
public SpringJDBCThreadTest(String tableName, int batchSize, BatchSqlUpdate bsu, CountDownLatch latch) {
|
||||
super();
|
||||
this.tableName = tableName;
|
||||
this.batchSize = batchSize;
|
||||
this.bsu = bsu;
|
||||
this.latch = latch;
|
||||
}
|
||||
|
||||
public SpringJDBCThreadTest(boolean isStrongStr, String tableName, int batchSize, BatchSqlUpdate bsu,
|
||||
CountDownLatch latch) {
|
||||
super();
|
||||
this.isStrongStr = isStrongStr;
|
||||
this.tableName = tableName;
|
||||
this.batchSize = batchSize;
|
||||
this.bsu = bsu;
|
||||
this.latch = latch;
|
||||
}
|
||||
|
||||
public int getBatchSize() {
|
||||
return batchSize;
|
||||
}
|
||||
|
||||
public void setBatchSize(int batchSize) {
|
||||
this.batchSize = batchSize;
|
||||
}
|
||||
|
||||
public BatchSqlUpdate getBsu() {
|
||||
return bsu;
|
||||
}
|
||||
|
||||
public void setBsu(BatchSqlUpdate bsu) {
|
||||
this.bsu = bsu;
|
||||
}
|
||||
|
||||
public CountDownLatch getLatch() {
|
||||
return latch;
|
||||
}
|
||||
|
||||
public void setLatch(CountDownLatch latch) {
|
||||
this.latch = latch;
|
||||
}
|
||||
|
||||
public Boolean getIsStrongStr() {
|
||||
return isStrongStr;
|
||||
}
|
||||
|
||||
public void setIsStrongStr(Boolean isStrongStr) {
|
||||
this.isStrongStr = isStrongStr;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public List<ConfigCompile> getCompileList() {
|
||||
return compileList;
|
||||
}
|
||||
|
||||
public void setCompileList(List<ConfigCompile> compileList) {
|
||||
this.compileList = compileList;
|
||||
}
|
||||
|
||||
public List<ConfigGroupRelation> getGroupList() {
|
||||
return groupList;
|
||||
}
|
||||
|
||||
public void setGroupList(List<ConfigGroupRelation> groupList) {
|
||||
this.groupList = groupList;
|
||||
}
|
||||
|
||||
public List<IpRegion> getIpRegionList() {
|
||||
return ipRegionList;
|
||||
}
|
||||
|
||||
public void setIpRegionList(List<IpRegion> ipRegionList) {
|
||||
this.ipRegionList = ipRegionList;
|
||||
}
|
||||
|
||||
public List<NumRegion> getNumRegionList() {
|
||||
return numRegionList;
|
||||
}
|
||||
|
||||
public void setNumRegionList(List<NumRegion> numRegionList) {
|
||||
this.numRegionList = numRegionList;
|
||||
}
|
||||
|
||||
public List<StrRegion> getStrRegionList() {
|
||||
return strRegionList;
|
||||
}
|
||||
|
||||
public void setStrRegionList(List<StrRegion> strRegionList) {
|
||||
this.strRegionList = strRegionList;
|
||||
}
|
||||
|
||||
public static void saveCompile(List<ConfigCompile> compileList, BatchSqlUpdate bsu, int batchSize) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(
|
||||
"insert into CONFIG_COMPILE (COMPILE_ID ,SERVICE ,ACTION , CONT_TYPE, ATTR_TYPE, CONT_LABEL, Task_id, Guarantee_ID, AFFAIR_ID, TOPIC_ID, DO_BLACKLIST ,DO_LOG ,EFFECTIVE_RANGE , ACTIVE_SYS, CONFIG_PERCENT ,CONFIG_OPTION ,START_TIME ,END_TIME , USER_REGION, IS_VALID,GROUP_NUM,FATHER_CFG_ID ,OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate)");
|
||||
|
||||
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
|
||||
bsu.setSql(sb.toString());
|
||||
bsu.setBatchSize(batchSize);
|
||||
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR,
|
||||
Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR,
|
||||
Types.INTEGER, Types.BIGINT, Types.INTEGER, Types.DATE, Types.DATE, Types.VARCHAR, Types.INTEGER,
|
||||
Types.INTEGER, Types.BIGINT, Types.DATE });
|
||||
for (ConfigCompile compile : compileList) {
|
||||
bsu.update(new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
|
||||
compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
|
||||
compile.getGuaranteeId(), compile.getAffAirId(), compile.getTopIcId(), compile.getDoBlackList(),
|
||||
compile.getDoLog(), compile.getEffectiveRange(), compile.getActiveSys(), compile.getConfigPercent(),
|
||||
compile.getConfigOption(), compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(),
|
||||
compile.getIsValid(), compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() });
|
||||
}
|
||||
bsu.flush();
|
||||
}
|
||||
|
||||
public static void saveGroup(List<ConfigGroupRelation> groupList, BatchSqlUpdate bsu, int batchSize) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(
|
||||
"insert into CONFIG_GROUP (ID,GROUP_ID, COMPILE_ID, IS_VALID, LAST_UPDATE, OP_TIME ) values ( seq_config_group.nextval, ?, ?, ?, sysdate, ?) ");
|
||||
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
|
||||
bsu.setSql(sb.toString());
|
||||
bsu.setBatchSize(batchSize);
|
||||
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.DATE });
|
||||
for (ConfigGroupRelation group : groupList) {
|
||||
bsu.update(
|
||||
new Object[] { group.getGroupId(), group.getCompileId(), group.getIsValid(), group.getOpTime() });
|
||||
}
|
||||
bsu.flush();
|
||||
|
||||
}
|
||||
|
||||
public static void saveIPRegion(String name, List<IpRegion> ipRegionList, BatchSqlUpdate bsu, int batchSize) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(name);
|
||||
sb.append(
|
||||
"(REGION_ID, GROUP_ID, ADDR_TYPE, SRC_IP, MASK_SRC_IP, SRC_PORT, MASK_SRC_PORT, DST_IP, MASK_DST_IP, DST_PORT, MASK_DST_PORT, PROTOCOL, DIRECTION, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
|
||||
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
|
||||
bsu.setSql(sb.toString());
|
||||
bsu.setBatchSize(batchSize);
|
||||
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
|
||||
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER,
|
||||
Types.INTEGER, Types.DATE });
|
||||
for (IpRegion ipRegion : ipRegionList) {
|
||||
bsu.update(new Object[] { ipRegion.getRegionId(), ipRegion.getGroupId(), ipRegion.getAddrType(),
|
||||
ipRegion.getSrcIp(), ipRegion.getMaskSrcIp(), ipRegion.getSrcPort(), ipRegion.getMaskSrcPort(),
|
||||
ipRegion.getDstIp(), ipRegion.getMaskDstIp(), ipRegion.getDstPort(), ipRegion.getMaskDstPort(),
|
||||
ipRegion.getProtocol(), ipRegion.getDirection(), ipRegion.getIsValid(), ipRegion.getOpTime()
|
||||
|
||||
});
|
||||
}
|
||||
bsu.flush();
|
||||
}
|
||||
|
||||
public static void saveNumRegion(String name, List<NumRegion> numRegionList, BatchSqlUpdate bsu, int batchSize) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(name);
|
||||
sb.append(
|
||||
" (REGION_ID,GROUP_ID,LOW_BOUNDARY,UP_BOUNDARY,IS_VALID,OP_TIME,LAST_UPDATE) values(?, ?, ?, ?, ?, ?, sysdate)");
|
||||
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
|
||||
bsu.setSql(sb.toString());
|
||||
bsu.setBatchSize(batchSize);
|
||||
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.DATE });
|
||||
for (NumRegion numRegion : numRegionList) {
|
||||
bsu.update(new Object[] { numRegion.getRegionId(), numRegion.getGroupId(), numRegion.getLowBoundary(),
|
||||
numRegion.getUpBoundary(), numRegion.getIsValid(), numRegion.getOpTime() });
|
||||
}
|
||||
bsu.flush();
|
||||
}
|
||||
|
||||
public static void saveStrongStrRegion(String name, List<StrRegion> strRegionList, BatchSqlUpdate bsu,
|
||||
int batchSize) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(name);
|
||||
sb.append(
|
||||
"(REGION_ID, GROUP_ID, DISTRICT, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
|
||||
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
|
||||
bsu.setSql(sb.toString());
|
||||
bsu.setBatchSize(batchSize);
|
||||
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER,
|
||||
Types.INTEGER, Types.INTEGER, Types.DATE });
|
||||
for (StrRegion strRegion : strRegionList) {
|
||||
bsu.update(new Object[] { strRegion.getRegionId(), strRegion.getGroupId(), strRegion.getDistrict(),
|
||||
strRegion.getKeywords(), strRegion.getExprType(), strRegion.getMatchMethod(),
|
||||
strRegion.getIsHexbin(), strRegion.getIsValid(), strRegion.getOpTime() });
|
||||
}
|
||||
bsu.flush();
|
||||
}
|
||||
|
||||
public static void saveStrRegion(String name, List<StrRegion> strRegionList, BatchSqlUpdate bsu, int batchSize) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(name);
|
||||
sb.append(
|
||||
"(REGION_ID, GROUP_ID, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
|
||||
|
||||
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
|
||||
bsu.setSql(sb.toString());
|
||||
bsu.setBatchSize(batchSize);
|
||||
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER,
|
||||
Types.INTEGER, Types.DATE });
|
||||
|
||||
for (StrRegion strRegion : strRegionList) {
|
||||
bsu.update(new Object[] { strRegion.getRegionId(), strRegion.getGroupId(), strRegion.getKeywords(),
|
||||
strRegion.getExprType(), strRegion.getMatchMethod(), strRegion.getIsHexbin(),
|
||||
strRegion.getIsValid(), strRegion.getOpTime() });
|
||||
}
|
||||
bsu.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (null != compileList && compileList.size() > 0) {
|
||||
saveCompile(compileList, bsu, batchSize);
|
||||
} else if (null != groupList && groupList.size() > 0) {
|
||||
saveGroup(groupList, bsu, batchSize);
|
||||
} else if (null != ipRegionList && ipRegionList.size() > 0) {
|
||||
saveIPRegion(tableName, ipRegionList, bsu, batchSize);
|
||||
} else if (null != strRegionList && strRegionList.size() > 0) {
|
||||
if (null != isStrongStr && isStrongStr) {
|
||||
saveStrongStrRegion(tableName, strRegionList, bsu, batchSize);
|
||||
} else {
|
||||
saveStrRegion(tableName, strRegionList, bsu, batchSize);
|
||||
}
|
||||
} else if (null != numRegionList && numRegionList.size() > 0) {
|
||||
saveNumRegion(tableName, numRegionList, bsu, batchSize);
|
||||
}
|
||||
latch.countDown();
|
||||
System.out.println("SpringJDBC--latchCount=======================" + latch.getCount());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,287 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.Types;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import org.springframework.jdbc.object.BatchSqlUpdate;
|
||||
import com.nis.domain.restful.ConfigCompile;
|
||||
import com.nis.domain.restful.ConfigGroupRelation;
|
||||
import com.nis.domain.restful.IpRegion;
|
||||
import com.nis.domain.restful.NumRegion;
|
||||
import com.nis.domain.restful.StrRegion;
|
||||
|
||||
/**
|
||||
* jdbc测试批量插入
|
||||
*
|
||||
* @author RenKaiGe-Office
|
||||
*
|
||||
*/
|
||||
public class SpringJDBCThreadTest2 implements Runnable {
|
||||
private CountDownLatch latch;
|
||||
private Boolean isStrongStr;
|
||||
private String tableName;
|
||||
private int batchSize;
|
||||
private BatchSqlUpdate bsu;
|
||||
private List<ConfigCompile> compileList;
|
||||
private List<ConfigGroupRelation> groupList;
|
||||
private List<IpRegion> ipRegionList;
|
||||
private List<NumRegion> numRegionList;
|
||||
private List<StrRegion> strRegionList;
|
||||
|
||||
public SpringJDBCThreadTest2() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SpringJDBCThreadTest2(int batchSize, BatchSqlUpdate bsu, CountDownLatch latch) {
|
||||
super();
|
||||
this.batchSize = batchSize;
|
||||
this.bsu = bsu;
|
||||
this.latch = latch;
|
||||
}
|
||||
|
||||
public SpringJDBCThreadTest2(String tableName, int batchSize, BatchSqlUpdate bsu, CountDownLatch latch) {
|
||||
super();
|
||||
this.tableName = tableName;
|
||||
this.batchSize = batchSize;
|
||||
this.bsu = bsu;
|
||||
this.latch = latch;
|
||||
}
|
||||
|
||||
public SpringJDBCThreadTest2(boolean isStrongStr, String tableName, int batchSize, BatchSqlUpdate bsu,
|
||||
CountDownLatch latch) {
|
||||
super();
|
||||
this.isStrongStr = isStrongStr;
|
||||
this.tableName = tableName;
|
||||
this.batchSize = batchSize;
|
||||
this.bsu = bsu;
|
||||
this.latch = latch;
|
||||
}
|
||||
|
||||
public int getBatchSize() {
|
||||
return batchSize;
|
||||
}
|
||||
|
||||
public void setBatchSize(int batchSize) {
|
||||
this.batchSize = batchSize;
|
||||
}
|
||||
|
||||
public BatchSqlUpdate getBsu() {
|
||||
return bsu;
|
||||
}
|
||||
|
||||
public void setBsu(BatchSqlUpdate bsu) {
|
||||
this.bsu = bsu;
|
||||
}
|
||||
|
||||
public CountDownLatch getLatch() {
|
||||
return latch;
|
||||
}
|
||||
|
||||
public void setLatch(CountDownLatch latch) {
|
||||
this.latch = latch;
|
||||
}
|
||||
|
||||
public Boolean getIsStrongStr() {
|
||||
return isStrongStr;
|
||||
}
|
||||
|
||||
public void setIsStrongStr(Boolean isStrongStr) {
|
||||
this.isStrongStr = isStrongStr;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public List<ConfigCompile> getCompileList() {
|
||||
return compileList;
|
||||
}
|
||||
|
||||
public void setCompileList(List<ConfigCompile> compileList) {
|
||||
this.compileList = compileList;
|
||||
}
|
||||
|
||||
public List<ConfigGroupRelation> getGroupList() {
|
||||
return groupList;
|
||||
}
|
||||
|
||||
public void setGroupList(List<ConfigGroupRelation> groupList) {
|
||||
this.groupList = groupList;
|
||||
}
|
||||
|
||||
public List<IpRegion> getIpRegionList() {
|
||||
return ipRegionList;
|
||||
}
|
||||
|
||||
public void setIpRegionList(List<IpRegion> ipRegionList) {
|
||||
this.ipRegionList = ipRegionList;
|
||||
}
|
||||
|
||||
public List<NumRegion> getNumRegionList() {
|
||||
return numRegionList;
|
||||
}
|
||||
|
||||
public void setNumRegionList(List<NumRegion> numRegionList) {
|
||||
this.numRegionList = numRegionList;
|
||||
}
|
||||
|
||||
public List<StrRegion> getStrRegionList() {
|
||||
return strRegionList;
|
||||
}
|
||||
|
||||
public void setStrRegionList(List<StrRegion> strRegionList) {
|
||||
this.strRegionList = strRegionList;
|
||||
}
|
||||
|
||||
public static void saveCompile(List<ConfigCompile> compileList, BatchSqlUpdate bsu, int batchSize) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(
|
||||
"insert into CONFIG_COMPILE (COMPILE_ID ,SERVICE ,ACTION , CONT_TYPE, ATTR_TYPE, CONT_LABEL, Task_id, Guarantee_ID, AFFAIR_ID, TOPIC_ID, DO_BLACKLIST ,DO_LOG ,EFFECTIVE_RANGE , ACTIVE_SYS, CONFIG_PERCENT ,CONFIG_OPTION ,START_TIME ,END_TIME , USER_REGION, IS_VALID,GROUP_NUM,FATHER_CFG_ID ,OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate)");
|
||||
|
||||
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
|
||||
bsu.setSql(sb.toString());
|
||||
bsu.setBatchSize(batchSize);
|
||||
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR,
|
||||
Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR,
|
||||
Types.INTEGER, Types.BIGINT, Types.INTEGER, Types.DATE, Types.DATE, Types.VARCHAR, Types.INTEGER,
|
||||
Types.INTEGER, Types.BIGINT, Types.DATE });
|
||||
for (ConfigCompile compile : compileList) {
|
||||
bsu.update(new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
|
||||
compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
|
||||
compile.getGuaranteeId(), compile.getAffAirId(), compile.getTopIcId(), compile.getDoBlackList(),
|
||||
compile.getDoLog(), compile.getEffectiveRange(), compile.getActiveSys(), compile.getConfigPercent(),
|
||||
compile.getConfigOption(), compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(),
|
||||
compile.getIsValid(), compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() });
|
||||
}
|
||||
bsu.flush();
|
||||
}
|
||||
|
||||
public static void saveGroup(List<ConfigGroupRelation> groupList, BatchSqlUpdate bsu, int batchSize) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(
|
||||
"insert into CONFIG_GROUP (ID,GROUP_ID, COMPILE_ID, IS_VALID, LAST_UPDATE, OP_TIME ) values ( seq_config_group.nextval, ?, ?, ?, sysdate, ?) ");
|
||||
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
|
||||
bsu.setSql(sb.toString());
|
||||
bsu.setBatchSize(batchSize);
|
||||
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.DATE });
|
||||
for (ConfigGroupRelation group : groupList) {
|
||||
bsu.update(
|
||||
new Object[] { group.getGroupId(), group.getCompileId(), group.getIsValid(), group.getOpTime() });
|
||||
}
|
||||
bsu.flush();
|
||||
|
||||
}
|
||||
|
||||
public static void saveIPRegion(String name, List<IpRegion> ipRegionList, BatchSqlUpdate bsu, int batchSize) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(name);
|
||||
sb.append(
|
||||
"(REGION_ID, GROUP_ID, ADDR_TYPE, SRC_IP, MASK_SRC_IP, SRC_PORT, MASK_SRC_PORT, DST_IP, MASK_DST_IP, DST_PORT, MASK_DST_PORT, PROTOCOL, DIRECTION, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
|
||||
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
|
||||
bsu.setSql(sb.toString());
|
||||
bsu.setBatchSize(batchSize);
|
||||
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
|
||||
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER,
|
||||
Types.INTEGER, Types.DATE });
|
||||
for (IpRegion ipRegion : ipRegionList) {
|
||||
bsu.update(new Object[] { ipRegion.getRegionId(), ipRegion.getGroupId(), ipRegion.getAddrType(),
|
||||
ipRegion.getSrcIp(), ipRegion.getMaskSrcIp(), ipRegion.getSrcPort(), ipRegion.getMaskSrcPort(),
|
||||
ipRegion.getDstIp(), ipRegion.getMaskDstIp(), ipRegion.getDstPort(), ipRegion.getMaskDstPort(),
|
||||
ipRegion.getProtocol(), ipRegion.getDirection(), ipRegion.getIsValid(), ipRegion.getOpTime()
|
||||
|
||||
});
|
||||
}
|
||||
bsu.flush();
|
||||
}
|
||||
|
||||
public static void saveNumRegion(String name, List<NumRegion> numRegionList, BatchSqlUpdate bsu, int batchSize) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(name);
|
||||
sb.append(
|
||||
" (REGION_ID,GROUP_ID,LOW_BOUNDARY,UP_BOUNDARY,IS_VALID,OP_TIME,LAST_UPDATE) values(?, ?, ?, ?, ?, ?, sysdate)");
|
||||
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
|
||||
bsu.setSql(sb.toString());
|
||||
bsu.setBatchSize(batchSize);
|
||||
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.DATE });
|
||||
for (NumRegion numRegion : numRegionList) {
|
||||
bsu.update(new Object[] { numRegion.getRegionId(), numRegion.getGroupId(), numRegion.getLowBoundary(),
|
||||
numRegion.getUpBoundary(), numRegion.getIsValid(), numRegion.getOpTime() });
|
||||
}
|
||||
bsu.flush();
|
||||
}
|
||||
|
||||
public static void saveStrongStrRegion(String name, List<StrRegion> strRegionList, BatchSqlUpdate bsu,
|
||||
int batchSize) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(name);
|
||||
sb.append(
|
||||
"(REGION_ID, GROUP_ID, DISTRICT, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
|
||||
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
|
||||
bsu.setSql(sb.toString());
|
||||
bsu.setBatchSize(batchSize);
|
||||
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER,
|
||||
Types.INTEGER, Types.INTEGER, Types.DATE });
|
||||
for (StrRegion strRegion : strRegionList) {
|
||||
bsu.update(new Object[] { strRegion.getRegionId(), strRegion.getGroupId(), strRegion.getDistrict(),
|
||||
strRegion.getKeywords(), strRegion.getExprType(), strRegion.getMatchMethod(),
|
||||
strRegion.getIsHexbin(), strRegion.getIsValid(), strRegion.getOpTime() });
|
||||
}
|
||||
bsu.flush();
|
||||
}
|
||||
|
||||
public static void saveStrRegion(String name, List<StrRegion> strRegionList, BatchSqlUpdate bsu, int batchSize) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("insert into ");
|
||||
sb.append(name);
|
||||
sb.append(
|
||||
"(REGION_ID, GROUP_ID, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
|
||||
|
||||
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
|
||||
bsu.setSql(sb.toString());
|
||||
bsu.setBatchSize(batchSize);
|
||||
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER,
|
||||
Types.INTEGER, Types.DATE });
|
||||
|
||||
for (StrRegion strRegion : strRegionList) {
|
||||
bsu.update(new Object[] { strRegion.getRegionId(), strRegion.getGroupId(), strRegion.getKeywords(),
|
||||
strRegion.getExprType(), strRegion.getMatchMethod(), strRegion.getIsHexbin(),
|
||||
strRegion.getIsValid(), strRegion.getOpTime() });
|
||||
}
|
||||
bsu.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (null != compileList && compileList.size() > 0) {
|
||||
saveCompile(compileList, bsu, batchSize);
|
||||
} else if (null != groupList && groupList.size() > 0) {
|
||||
saveGroup(groupList, bsu, batchSize);
|
||||
} else if (null != ipRegionList && ipRegionList.size() > 0) {
|
||||
saveIPRegion(tableName, ipRegionList, bsu, batchSize);
|
||||
} else if (null != strRegionList && strRegionList.size() > 0) {
|
||||
if (null != isStrongStr && isStrongStr) {
|
||||
saveStrongStrRegion(tableName, strRegionList, bsu, batchSize);
|
||||
} else {
|
||||
saveStrRegion(tableName, strRegionList, bsu, batchSize);
|
||||
}
|
||||
} else if (null != numRegionList && numRegionList.size() > 0) {
|
||||
saveNumRegion(tableName, numRegionList, bsu, batchSize);
|
||||
}
|
||||
latch.countDown();
|
||||
System.out.println("SpringJDBC--latchCount=======================" + latch.getCount());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.restful.SystemFunStatus;
|
||||
import com.nis.web.dao.SystemFunStatusDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
|
||||
@Service
|
||||
public class SystemFunStatusService extends CrudService<SystemFunStatusDao, SystemFunStatus> {
|
||||
|
||||
@Autowired
|
||||
public SystemFunStatusDao systemFunStatusDao;
|
||||
|
||||
public void saveSystemFunStatusBatch(List<SystemFunStatus> entity) {
|
||||
super.saveBatch(entity, SystemFunStatusDao.class);
|
||||
}
|
||||
|
||||
public void updateSystemFunStatusBatch(List<SystemFunStatus> entity) {
|
||||
super.updateBatch(entity, SystemFunStatusDao.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,463 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.nis.domain.restful.ConfigCompile;
|
||||
import com.nis.domain.restful.ConfigGroupRelation;
|
||||
import com.nis.domain.restful.IpRegion;
|
||||
import com.nis.domain.restful.NumRegion;
|
||||
import com.nis.domain.restful.StrRegion;
|
||||
import com.nis.util.Configurations;
|
||||
|
||||
/**
|
||||
* jdbc测试批量插入
|
||||
*
|
||||
* @author RenKaiGe-Office
|
||||
*
|
||||
*/
|
||||
public class UpdateCompileByJDBCThread implements Runnable {
|
||||
private static Logger logger = Logger.getLogger(SaveCompileByJDBCThread.class);
|
||||
private static Long start;
|
||||
private CountDownLatch latch;
|
||||
private String tableName;
|
||||
private Connection conn;
|
||||
private List<ConfigCompile> compileList;
|
||||
private List<ConfigGroupRelation> groupList;
|
||||
private List<IpRegion> ipRegionList;
|
||||
private List<NumRegion> numRegionList;
|
||||
private List<StrRegion> strRegionList;
|
||||
private Date opTime;
|
||||
|
||||
public UpdateCompileByJDBCThread() {
|
||||
super();
|
||||
}
|
||||
|
||||
public UpdateCompileByJDBCThread(Connection conn, CountDownLatch latch, Long start, Date opTime) {
|
||||
super();
|
||||
this.conn = conn;
|
||||
this.latch = latch;
|
||||
this.start = start;
|
||||
this.opTime = opTime;
|
||||
}
|
||||
|
||||
public UpdateCompileByJDBCThread(String tableName, Connection conn, CountDownLatch latch, Long start, Date opTime) {
|
||||
super();
|
||||
this.tableName = tableName;
|
||||
this.conn = conn;
|
||||
this.latch = latch;
|
||||
this.start = start;
|
||||
this.opTime = opTime;
|
||||
}
|
||||
|
||||
public Date getOpTime() {
|
||||
return opTime;
|
||||
}
|
||||
|
||||
public void setOpTime(Date opTime) {
|
||||
this.opTime = opTime;
|
||||
}
|
||||
|
||||
public Long getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public void setStart(Long start) {
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public CountDownLatch getLatch() {
|
||||
return latch;
|
||||
}
|
||||
|
||||
public void setLatch(CountDownLatch latch) {
|
||||
this.latch = latch;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public Connection getConn() {
|
||||
return conn;
|
||||
}
|
||||
|
||||
public void setConn(Connection conn) {
|
||||
this.conn = conn;
|
||||
}
|
||||
|
||||
public List<ConfigCompile> getCompileList() {
|
||||
return compileList;
|
||||
}
|
||||
|
||||
public void setCompileList(List<ConfigCompile> compileList) {
|
||||
this.compileList = compileList;
|
||||
}
|
||||
|
||||
public List<ConfigGroupRelation> getGroupList() {
|
||||
return groupList;
|
||||
}
|
||||
|
||||
public void setGroupList(List<ConfigGroupRelation> groupList) {
|
||||
this.groupList = groupList;
|
||||
}
|
||||
|
||||
public List<IpRegion> getIpRegionList() {
|
||||
return ipRegionList;
|
||||
}
|
||||
|
||||
public void setIpRegionList(List<IpRegion> ipRegionList) {
|
||||
this.ipRegionList = ipRegionList;
|
||||
}
|
||||
|
||||
public List<NumRegion> getNumRegionList() {
|
||||
return numRegionList;
|
||||
}
|
||||
|
||||
public void setNumRegionList(List<NumRegion> numRegionList) {
|
||||
this.numRegionList = numRegionList;
|
||||
}
|
||||
|
||||
public List<StrRegion> getStrRegionList() {
|
||||
return strRegionList;
|
||||
}
|
||||
|
||||
public void setStrRegionList(List<StrRegion> strRegionList) {
|
||||
this.strRegionList = strRegionList;
|
||||
}
|
||||
|
||||
public synchronized static java.sql.Timestamp utileDate2TimeStamp(java.util.Date udate) {
|
||||
java.sql.Timestamp sqlDate = null;
|
||||
long t = udate.getTime();
|
||||
sqlDate = new java.sql.Timestamp(t);
|
||||
return sqlDate;
|
||||
|
||||
}
|
||||
|
||||
public static void updateCompile(List<ConfigCompile> compileList, Connection conn, Date opTime,
|
||||
List<Exception> msgList) {
|
||||
if (null != compileList && compileList.size() > 0) {
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String tabName = Configurations.getStringProperty("compileTabName", "CONFIG_COMPILE");
|
||||
String fieldName = Configurations.getStringProperty("updateFields", "IS_VALID");
|
||||
String condition= Configurations.getStringProperty("compileUpdateCondition", "COMPILE_ID");
|
||||
sb.append("update ").append(tabName).append(" set ");
|
||||
|
||||
String fieldNameObj [] = fieldName.split(",");
|
||||
//加上where条件的参数名称
|
||||
String newParamsStr = fieldName+","+condition;
|
||||
for (int i = 0; i < fieldNameObj.length; i++) {
|
||||
sb.append(fieldNameObj[i]+"=?");
|
||||
if (i+1<fieldNameObj.length) {
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
|
||||
//是否包含更新时间字段 值为数据库当前时间
|
||||
if (Configurations.getBooleanProperty("hasLastUpdate", true)) {
|
||||
sb.append(", LAST_UPDATE= sysdate");
|
||||
}
|
||||
sb.append(" where ");
|
||||
String [] condObjs = condition.split(",");
|
||||
for (int i = 0; i < condObjs.length; i++) {
|
||||
sb.append(condObjs[i]+"=?");
|
||||
if (i+1<condObjs.length) {
|
||||
sb.append(" and ");
|
||||
}
|
||||
}
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
|
||||
|
||||
for (ConfigCompile compile : compileList) {
|
||||
setPsParams(newParamsStr.split(","),ps,compile);
|
||||
ps.addBatch();
|
||||
}
|
||||
ps.executeBatch();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
msgList.add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateGroup(List<ConfigGroupRelation> groupList, Connection conn, Date opTime,
|
||||
List<Exception> msgList) {
|
||||
if (null != groupList && groupList.size() > 0) {
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
String tabName = Configurations.getStringProperty("groupTabName", "CONFIG_GROUP");
|
||||
String fieldName = Configurations.getStringProperty("updateFields", "IS_VALID");
|
||||
String condition = Configurations.getStringProperty("groupUpdateCondition", "GROUP_ID");
|
||||
|
||||
sb.append(" update ").append(tabName);
|
||||
sb.append(" set ");
|
||||
String fieldNameObj [] = fieldName.split(",");
|
||||
//加上where条件的参数名称
|
||||
String newParamsStr = fieldName+","+condition;
|
||||
for (int i = 0; i < fieldNameObj.length; i++) {
|
||||
sb.append(fieldNameObj[i]+"=?");
|
||||
if (i+1<fieldNameObj.length) {
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
|
||||
//是否包含更新时间字段 值为数据库当前时间
|
||||
if (Configurations.getBooleanProperty("hasLastUpdate", true)) {
|
||||
sb.append(", LAST_UPDATE= sysdate");
|
||||
}
|
||||
// + "where GROUP_ID=? and COMPILE_ID=? ");
|
||||
sb.append(" where ");
|
||||
String [] condObjs = condition.split(",");
|
||||
for (int i = 0; i < condObjs.length; i++) {
|
||||
sb.append(condObjs[i]+"=?");
|
||||
if (i+1<condObjs.length) {
|
||||
sb.append(" and ");
|
||||
}
|
||||
}
|
||||
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
for (ConfigGroupRelation group : groupList) {
|
||||
setPsParams(newParamsStr.split(","), ps, group);
|
||||
ps.addBatch();
|
||||
}
|
||||
ps.executeBatch();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
msgList.add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateIPRegion(String name, List<IpRegion> ipRegionList, Connection conn, Date opTime,
|
||||
List<Exception> msgList) {
|
||||
if (null != ipRegionList && ipRegionList.size() > 0) {
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
|
||||
String fieldName = Configurations.getStringProperty("updateFields", "IS_VALID");
|
||||
String condition = Configurations.getStringProperty("regionId", "REGION_ID");
|
||||
sb.append("update ");
|
||||
sb.append(name);
|
||||
sb.append(" set ");
|
||||
|
||||
String fieldNameObj [] = fieldName.split(",");
|
||||
//加上where条件的参数名称
|
||||
String newParamsStr = fieldName+","+condition;
|
||||
for (int i = 0; i < fieldNameObj.length; i++) {
|
||||
sb.append(fieldNameObj[i]+"=?");
|
||||
if (i+1<fieldNameObj.length) {
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
|
||||
//是否包含更新时间字段 值为数据库当前时间
|
||||
if (Configurations.getBooleanProperty("hasLastUpdate", true)) {
|
||||
sb.append(", LAST_UPDATE= sysdate");
|
||||
}
|
||||
// + "where GROUP_ID=? and COMPILE_ID=? ");
|
||||
sb.append(" where ");
|
||||
String [] condObjs = condition.split(",");
|
||||
for (int i = 0; i < condObjs.length; i++) {
|
||||
sb.append(condObjs[i]+"=?");
|
||||
if (i+1<condObjs.length) {
|
||||
sb.append(" and ");
|
||||
}
|
||||
}
|
||||
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
for (IpRegion ipRegion : ipRegionList) {
|
||||
setPsParams(newParamsStr.split(","), ps, ipRegion);
|
||||
ps.addBatch();
|
||||
}
|
||||
ps.executeBatch();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
msgList.add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateNumRegion(String name, List<NumRegion> numRegionList, Connection conn, Date opTime,
|
||||
List<Exception> msgList) {
|
||||
if (null != numRegionList && numRegionList.size() > 0) {
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String fieldName = Configurations.getStringProperty("updateFields", "IS_VALID");
|
||||
String condition = Configurations.getStringProperty("regionId", "REGION_ID");
|
||||
sb.append("update ");
|
||||
sb.append(name);
|
||||
sb.append(" set ");
|
||||
|
||||
String fieldNameObj [] = fieldName.split(",");
|
||||
//加上where条件的参数名称
|
||||
String newParamsStr = fieldName+","+condition;
|
||||
for (int i = 0; i < fieldNameObj.length; i++) {
|
||||
sb.append(fieldNameObj[i]+"=?");
|
||||
if (i+1<fieldNameObj.length) {
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
|
||||
//是否包含更新时间字段 值为数据库当前时间
|
||||
if (Configurations.getBooleanProperty("hasLastUpdate", true)) {
|
||||
sb.append(", LAST_UPDATE= sysdate");
|
||||
}
|
||||
// + "where GROUP_ID=? and COMPILE_ID=? ");
|
||||
sb.append(" where ");
|
||||
String [] condObjs = condition.split(",");
|
||||
for (int i = 0; i < condObjs.length; i++) {
|
||||
sb.append(condObjs[i]+"=?");
|
||||
if (i+1<condObjs.length) {
|
||||
sb.append(" and ");
|
||||
}
|
||||
}
|
||||
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
for (NumRegion numRegion : numRegionList) {
|
||||
setPsParams(newParamsStr.split(","), ps, numRegion);
|
||||
ps.addBatch();
|
||||
}
|
||||
ps.executeBatch();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
msgList.add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateStrRegion(String name, List<StrRegion> strRegionList, Connection conn, Date opTime,
|
||||
List<Exception> msgList) {
|
||||
if (null != strRegionList && strRegionList.size() > 0) {
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String fieldName = Configurations.getStringProperty("updateFields", "IS_VALID");
|
||||
String condition = Configurations.getStringProperty("regionId", "REGION_ID");
|
||||
sb.append("update ");
|
||||
sb.append(name);
|
||||
sb.append(" set ");
|
||||
|
||||
String fieldNameObj [] = fieldName.split(",");
|
||||
//加上where条件的参数名称
|
||||
String newParamsStr = fieldName+","+condition;
|
||||
for (int i = 0; i < fieldNameObj.length; i++) {
|
||||
sb.append(fieldNameObj[i]+"=?");
|
||||
if (i+1<fieldNameObj.length) {
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
|
||||
//是否包含更新时间字段 值为数据库当前时间
|
||||
if (Configurations.getBooleanProperty("hasLastUpdate", true)) {
|
||||
sb.append(", LAST_UPDATE= sysdate");
|
||||
}
|
||||
// + "where GROUP_ID=? and COMPILE_ID=? ");
|
||||
sb.append(" where ");
|
||||
String [] condObjs = condition.split(",");
|
||||
for (int i = 0; i < condObjs.length; i++) {
|
||||
sb.append(condObjs[i]+"=?");
|
||||
if (i+1<condObjs.length) {
|
||||
sb.append(" and ");
|
||||
}
|
||||
}
|
||||
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
for (StrRegion strRegion : strRegionList) {
|
||||
setPsParams(newParamsStr.split(","), ps, strRegion);
|
||||
ps.addBatch();
|
||||
}
|
||||
ps.executeBatch();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
msgList.add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @Description: 向PreparedStatement设置参数
|
||||
* @author (zdx)
|
||||
* @date 2017年10月26日 上午9:47:33
|
||||
* @param fieldNameObj
|
||||
* @param ps
|
||||
* @param object
|
||||
* @throws Exception
|
||||
*/
|
||||
private static void setPsParams(String [] fieldNameObj,PreparedStatement ps,Object object) throws Exception{
|
||||
Object[] obj = new Object[fieldNameObj.length] ;
|
||||
|
||||
for (int i = 0; i < fieldNameObj.length; i++) {
|
||||
String name = fieldNameObj[i].toLowerCase().trim();
|
||||
name = name.substring(0,1).toUpperCase()+name.substring(1);
|
||||
if (name.indexOf("_")>-1) {
|
||||
// name = name.substring(0, name.indexOf("_"))+name.substring(name.indexOf("_")+1,name.indexOf("_")+2).toUpperCase()+name.substring(name.indexOf("_")+2);
|
||||
// }
|
||||
|
||||
while (name.indexOf("_")>-1) {
|
||||
name = name.substring(0, name.indexOf("_"))+name.substring(name.indexOf("_")+1,name.indexOf("_")+2).toUpperCase()+name.substring(name.indexOf("_")+2);
|
||||
}
|
||||
}
|
||||
|
||||
//需要特殊处理字段名
|
||||
if (name.equals("DoBlacklist")) {
|
||||
name = "DoBlackList";
|
||||
}else if (name.equals("AffairId")) {
|
||||
name = "AffAirId";
|
||||
}else if (name.equals("TopicId")) {
|
||||
name = "TopIcId";
|
||||
}
|
||||
|
||||
Method method = object.getClass().getMethod("get"+name);
|
||||
obj[i]= method.invoke(object);
|
||||
}
|
||||
for (int x = 0; x < obj.length; x++) {
|
||||
|
||||
if (obj[x] instanceof Date) {
|
||||
ps.setObject(x + 1, utileDate2TimeStamp((Date) obj[x]));
|
||||
}else {
|
||||
ps.setObject(x + 1, obj[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
List<Exception> msgList = ConfigSourcesService.getMsgList();
|
||||
synchronized (msgList) {
|
||||
try {
|
||||
if (null != compileList && compileList.size() > 0) {
|
||||
updateCompile(compileList, conn, opTime, msgList);
|
||||
} else if (null != groupList && groupList.size() > 0) {
|
||||
updateGroup(groupList, conn, opTime, msgList);
|
||||
} else if (null != ipRegionList && ipRegionList.size() > 0) {
|
||||
updateIPRegion(tableName, ipRegionList, conn, opTime, msgList);
|
||||
} else if (null != strRegionList && strRegionList.size() > 0) {
|
||||
updateStrRegion(tableName, strRegionList, conn, opTime, msgList);
|
||||
} else if (null != numRegionList && numRegionList.size() > 0) {
|
||||
updateNumRegion(tableName, numRegionList, conn, opTime, msgList);
|
||||
}
|
||||
latch.countDown();
|
||||
// System.out.println("latchCount=======================" +
|
||||
// latch.getCount());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
*@Title: DmbCkService.java
|
||||
*@Package com.nis.web.service.restful
|
||||
*@Description TODO
|
||||
*@author wx
|
||||
*@date 2016年9月7日 下午3:28:44
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.web.service.restful.jk;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.restful.jk.JkDmbCk;
|
||||
import com.nis.web.dao.jk.JkDmbCkDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
|
||||
/**
|
||||
* @ClassName: DmbCkService.java
|
||||
* @Description: TODO
|
||||
* @author (wx)
|
||||
* @date 2016年9月7日 下午3:28:44
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class JkDmbCkService extends CrudService<JkDmbCkDao, JkDmbCk> {
|
||||
@Autowired
|
||||
public JkDmbCkDao jkDmbCkDao;
|
||||
|
||||
public JkDmbCk findById(long id) {
|
||||
return get(id);
|
||||
}
|
||||
public void saveDmbCkBatch(List<JkDmbCk> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
super.saveBatch(entity,JkDmbCkDao.class);
|
||||
}
|
||||
public void updateDmbCkBatch(List<JkDmbCk> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
super.updateBatch(entity, JkDmbCkDao.class);
|
||||
}
|
||||
|
||||
public void removeDmbCk(long id) {
|
||||
jkDmbCkDao.delete(id);
|
||||
}
|
||||
public void removeDmbCkBatch(List<JkDmbCk> entity) {
|
||||
super.deleteBatch(entity, JkDmbCkDao.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
*@Title: JkFdZbService.java
|
||||
*@Package com.nis.web.service.restful
|
||||
*@Description TODO
|
||||
*@author wx
|
||||
*@date 2016年9月7日 下午3:28:44
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.web.service.restful.jk;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.jk.JkFdZb;
|
||||
import com.nis.web.dao.jk.JkFdZbDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
|
||||
/**
|
||||
* @ClassName: JkFdZbService.java
|
||||
* @Description: TODO
|
||||
* @author (DDM)
|
||||
* @date 2016年10月19日 下午21:28:44
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class JkFdZbService extends CrudService<JkFdZbDao, JkFdZb> {
|
||||
@Autowired
|
||||
public JkFdZbDao dmbCkDao;
|
||||
public Page<JkFdZb> getJkFdZb(Page<JkFdZb> page, JkFdZb entity) {
|
||||
return findPage(page, entity);
|
||||
}
|
||||
|
||||
public JkFdZb findById(long zbId) {
|
||||
return get(zbId);
|
||||
}
|
||||
public void saveJkFdZbBatch(List<JkFdZb> entity) {
|
||||
super.saveBatch(entity,JkFdZbDao.class);
|
||||
}
|
||||
public void updateJkFdZbBatch(List<JkFdZb> entity) {
|
||||
super.updateBatch(entity, JkFdZbDao.class);
|
||||
}
|
||||
public void removeJkFdZb(long zbId) {
|
||||
dmbCkDao.delete(zbId);
|
||||
}
|
||||
public void removeJkFdZbBatch(List<JkFdZb> entity) {
|
||||
super.deleteBatch(entity, JkFdZbDao.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
*@Title: JkFfjInfoService.java
|
||||
*@Package com.nis.web.service.restful
|
||||
*@Description TODO
|
||||
*@author (zbc)
|
||||
*@date 2016年10月19日 下午20:04:16
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.web.service.restful.jk;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.jk.JkFdZb;
|
||||
import com.nis.domain.restful.jk.JkFfjInfo;
|
||||
import com.nis.web.dao.jk.JkFdZbDao;
|
||||
import com.nis.web.dao.jk.JkFfjInfoDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
|
||||
/**
|
||||
* @ClassName: JkFfjInfoService.java
|
||||
* @Description: TODO
|
||||
* @author (zbc)
|
||||
* @date 2016年10月19日 下午20:04:16
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class JkFfjInfoService extends CrudService<JkFfjInfoDao, JkFfjInfo> {
|
||||
|
||||
@Autowired
|
||||
public JkFfjInfoDao jkFfjInfoDao;
|
||||
|
||||
public void saveJkFfjBatch(List<JkFfjInfo> entity) {
|
||||
super.saveBatch(entity, JkFfjInfoDao.class);
|
||||
}
|
||||
|
||||
|
||||
public void updateJkFfjBatch(List<JkFfjInfo> entity) {
|
||||
super.updateBatch(entity, JkFfjInfoDao.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
*@Title: JkFfjInfoService.java
|
||||
*@Package com.nis.web.service.restful
|
||||
*@Description TODO
|
||||
*@author (zbc)
|
||||
*@date 2016年10月19日 下午20:04:16
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.web.service.restful.jk;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.restful.jk.JkFwqInfo;
|
||||
import com.nis.web.dao.jk.JkFwqInfoDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
|
||||
/**
|
||||
* @ClassName: JkFfjInfoService.java
|
||||
* @Description: TODO
|
||||
* @author (zbc)
|
||||
* @date 2016年10月19日 下午20:04:16
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class JkFwqInfoService extends CrudService<JkFwqInfoDao, JkFwqInfo> {
|
||||
|
||||
@Autowired
|
||||
public JkFwqInfoDao jkFwqInfoDao;
|
||||
|
||||
public void savejkFwqInfoBatch(List<JkFwqInfo> entity) {
|
||||
super.saveBatch(entity, JkFwqInfoDao.class);
|
||||
}
|
||||
|
||||
|
||||
public void updatejkFwqInfoBatch(List<JkFwqInfo> entity) {
|
||||
super.updateBatch(entity, JkFwqInfoDao.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
*@Title: JkLyqService.java
|
||||
*@Package com.nis.web.service.restful
|
||||
*@Description TODO
|
||||
*@author wx
|
||||
*@date 2016年9月7日 下午3:28:44
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.web.service.restful.jk;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.restful.jk.JkLyq;
|
||||
import com.nis.web.dao.jk.JkLyqDao;
|
||||
import com.nis.web.service.CrudService;
|
||||
import com.nis.web.service.SaveRequestLogThread;
|
||||
|
||||
/**
|
||||
* @ClassName: JkLyqService.java
|
||||
* @Description: TODO
|
||||
* @author (wx)
|
||||
* @date 2016年9月7日 下午3:28:44
|
||||
* @version V1.0
|
||||
*/
|
||||
@Service
|
||||
public class JkLyqService extends CrudService<JkLyqDao, JkLyq> {
|
||||
@Autowired
|
||||
public JkLyqDao jkLyqDao;
|
||||
|
||||
public JkLyq findById(long id) {
|
||||
return get(id);
|
||||
}
|
||||
public void saveJkLyqBatch(List<JkLyq> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
super.saveBatch(entity,JkLyqDao.class);
|
||||
}
|
||||
public void updateJkLyqBatch(List<JkLyq> entity) {
|
||||
// TODO Auto-generated method stub
|
||||
super.updateBatch(entity, JkLyqDao.class);
|
||||
}
|
||||
public void removeJkLyq(long id) {
|
||||
jkLyqDao.delete(id);
|
||||
}
|
||||
public void removeJkLyqBatch(List<JkLyq> entity) {
|
||||
super.deleteBatch(entity, JkLyqDao.class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user