1、删除无用类和方法;
2、修改异常处理方式,一直往上抛在controller里记录日志并返回给客户端; 3、回调类配置新增时isValid只能为1
This commit is contained in:
@@ -17,11 +17,8 @@ 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.domain.restful.NtcReportEntity;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
@@ -342,259 +339,7 @@ public abstract class BaseLogService {
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* wx 报表查询条件检查
|
||||
*
|
||||
* @param clazz
|
||||
* 需要检验的实体名称[需要保证resultMap的id命名方式为[className]Map]
|
||||
* @param page
|
||||
* 需要校验的page对象
|
||||
*/
|
||||
public void queryConditionCheck(AuditLogThread 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(AuditLogThread 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(AuditLogThread 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
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
*@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);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
*@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);
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
/**
|
||||
*@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;
|
||||
}
|
||||
}
|
||||
@@ -1,163 +0,0 @@
|
||||
/**
|
||||
*@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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
/**
|
||||
*@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 com.nis.web.service.AuditLogThread;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @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(AuditLogThread 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(AuditLogThread 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;
|
||||
}
|
||||
}
|
||||
@@ -1,218 +0,0 @@
|
||||
/**
|
||||
*@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.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.AuditLogThread;
|
||||
|
||||
/**
|
||||
* @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(AuditLogThread 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(AuditLogThread 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;
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
*@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);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/**
|
||||
*@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;
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/**
|
||||
*@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;
|
||||
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
*@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);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
*@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);
|
||||
}
|
||||
}
|
||||
@@ -1,665 +0,0 @@
|
||||
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.DigestRegion;
|
||||
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 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 List<DigestRegion> digestRegionList;
|
||||
|
||||
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 List<DigestRegion> getDigestRegionList() {
|
||||
return digestRegionList;
|
||||
}
|
||||
|
||||
public void setDigestRegionList(List<DigestRegion> digestRegionList) {
|
||||
this.digestRegionList = digestRegionList;
|
||||
}
|
||||
|
||||
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);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public static void saveDigestRegion(String name, List<DigestRegion> digestRegionList, Connection conn,
|
||||
List<Exception> msgList) {
|
||||
if (null != digestRegionList && digestRegionList.size() > 0) {
|
||||
try {
|
||||
String fieldName = Configurations.getStringProperty("digestRegionFieldName", "REGION_ID");
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(getSqlStr(name, fieldName));
|
||||
for (DigestRegion numRegion : digestRegionList) {
|
||||
setPsParams(fieldName.split(","),ps,numRegion);
|
||||
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);
|
||||
} else if (null != digestRegionList && digestRegionList.size() > 0) {
|
||||
saveDigestRegion(tableName, digestRegionList, conn, msgList);
|
||||
}
|
||||
latch.countDown();
|
||||
System.out.println("latchCount=======================" + latch.getCount());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,570 +0,0 @@
|
||||
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.DigestRegion;
|
||||
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 List<DigestRegion> digestRegionList;
|
||||
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 List<DigestRegion> getDigestRegionList() {
|
||||
return digestRegionList;
|
||||
}
|
||||
|
||||
public void setDigestRegionList(List<DigestRegion> digestRegionList) {
|
||||
this.digestRegionList = digestRegionList;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateDigestRegion(String name, List<DigestRegion> digestRegionList, Connection conn, Date opTime,
|
||||
List<Exception> msgList) {
|
||||
if (null != digestRegionList && digestRegionList.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 (DigestRegion digestRegion : digestRegionList) {
|
||||
setPsParams(newParamsStr.split(","), ps, digestRegion);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @Description: 根据compileId更新与之对应的group关系表的生效状态
|
||||
* @author (zdx)
|
||||
* @date 2017年8月16日 上午9:46:44
|
||||
* @param compileList
|
||||
* @param conn
|
||||
* @param opTime
|
||||
* @param msgList
|
||||
*/
|
||||
public static void updateGroupByCompileId(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("groupTabName", "CONFIG_GROUP");
|
||||
sb.append("update "+tabName+" set IS_VALID=?,op_time=?,LAST_UPDATE=sysdate where COMPILE_ID=? ");
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
for (ConfigCompile compile : compileList) {
|
||||
Object[] obj = new Object[] { compile.getIsValid(), opTime,compile.getCompileId() };
|
||||
for (int x = 0; x < obj.length; x++) {
|
||||
if (x == 1) {
|
||||
ps.setTimestamp(x + 1, utileDate2TimeStamp(opTime));
|
||||
} else {
|
||||
ps.setObject(x + 1, obj[x]);
|
||||
}
|
||||
}
|
||||
ps.addBatch();
|
||||
}
|
||||
ps.executeBatch();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
msgList.add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@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);
|
||||
} else if (null != digestRegionList && digestRegionList.size() > 0) {
|
||||
updateDigestRegion(tableName, digestRegionList, conn, opTime, msgList);
|
||||
}
|
||||
|
||||
if((null !=compileList && compileList.size() > 0)&&(null != groupList && groupList.size()==0)){
|
||||
updateGroupByCompileId(compileList, conn, opTime, msgList);
|
||||
}
|
||||
|
||||
if((null !=compileList && compileList.size() > 0)&&(null != groupList && groupList.size()==0)){
|
||||
updateGroupByCompileId(compileList, conn, opTime, msgList);
|
||||
}
|
||||
latch.countDown();
|
||||
// System.out.println("latchCount=======================" +
|
||||
// latch.getCount());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user