上传代码

This commit is contained in:
zhangdongxu
2017-12-19 14:55:52 +08:00
commit 13acafd43d
4777 changed files with 898870 additions and 0 deletions

View File

@@ -0,0 +1,182 @@
package com.nis.web.controller.restful;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.nis.domain.restful.ConfigFile;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.MD5Utils;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
/**
* @ClassName: ConfigFileController
* @Description: 配置文件上传
* @author (DDM)
* @date 2016年9月19日 下午6:09:33
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/file/v1")
@Api(value = "ConfigFileController", description = "配置文件上传")
public class ConfigFileController extends BaseRestController {
Logger logger = LoggerFactory.getLogger(ConfigSourcesController.class);
SimpleDateFormat ymdhms=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Autowired
ServicesRequestLogService servicesRequestLogService;
@RequestMapping(value = "/fileUploadSources", method = RequestMethod.POST)
@ApiOperation(value = "文件上传", httpMethod = "POST", response = Map.class, notes = "多文件上传")
@ApiParam(value = "文件上传", name = "filesUpload", required = true)
public Map fileUploadSources(ConfigFile configFile,HttpServletRequest request,
HttpServletResponse response){
long start=System.currentTimeMillis();
System.out.println("operator:"+configFile.getOperator()+
"version:"+configFile.getVersion()+
"opAction:"+configFile.getOpAction()+
"opTime:"+configFile.getOpTime()
);
JSONArray fileArray=new JSONArray();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, configFile,fileArray);
String serviceDir=request.getRealPath("upload");
try {
MultipartFile[] files=configFile.getFiles();
if(files != null && files.length > 0){
for (MultipartFile file : files) {
//记录上传过程起始时的时间,用来计算上传时间
int pre = (int) System.currentTimeMillis();
//取得上传文件
if(file != null){
//取得当前上传文件的文件名称
String myFileName = file.getOriginalFilename();
if(!"".equals(myFileName.trim())){
JSONObject fileObject=new JSONObject();
myFileName=myFileName.trim();
//定义上传路径
File serviceFile = new File(serviceDir,myFileName);
//上传的文件已经存在,如果需要另存,请取消注释
// if(serviceFile.exists()){
// myFileName=myFileName.substring(0, myFileName.lastIndexOf(".")-1)+"_new"+
// myFileName.substring(myFileName.lastIndexOf("."), myFileName.length());
// serviceFile=new File(serviceDir,myFileName);
// }
file.transferTo(serviceFile);
fileObject.put("fileName", myFileName);
fileObject.put("fileNameMd5", MD5Utils.getMD5Checksum(serviceDir+"/"+myFileName));
fileObject.put("uploadTime", ymdhms.format(new Date()));
fileArray.add(fileObject);
}
}
//记录上传该文件后的时间
int finaltime = (int) System.currentTimeMillis();
System.out.println(finaltime - pre);
}
}
// thread.setContent(fileArray);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger.error(e.toString());
throw new RestServiceException(thread,System.currentTimeMillis()-start,"文件上传失败");
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "文件上传成功",fileArray);
}
@RequestMapping(value = "/fileDownLoadSources", method = RequestMethod.GET)
@ApiOperation(value = "文件下载", httpMethod = "GET", response = Map.class, notes = "文件下载")
@ApiParam(value = "文件下载", name = "fileDownLoad", required = true)
public Map fileDownLoadSources(String fileName,
HttpServletRequest request,
HttpServletResponse response){
long start=System.currentTimeMillis();
JSONObject fileObject=new JSONObject();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, fileObject);
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
String downLoadPath=null;
if(!StringUtil.isBlank(fileName)){
}else{
throw new RestServiceException(thread,System.currentTimeMillis()-start,"文件名称为空");
}
try {
fileName=fileName.trim();
response.setContentType("text/html;charset=utf-8");
request.setCharacterEncoding("UTF-8");
String ctxPath = request.getRealPath("upload");
downLoadPath = ctxPath +"/"+ fileName;
long fileLength = new File(downLoadPath).length();
response.setContentType("application/x-msdownload;");
response.setHeader("Content-disposition", "attachment; filename="
+ new String(fileName.getBytes("utf-8"), "ISO8859-1"));
response.setHeader("Content-Length", String.valueOf(fileLength));
bis = new BufferedInputStream(new FileInputStream(downLoadPath));
bos = new BufferedOutputStream(response.getOutputStream());
byte[] buff = new byte[2048];
int bytesRead;
while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
bos.write(buff, 0, bytesRead);
}
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger.error(e.toString());
throw new RestServiceException(thread,System.currentTimeMillis()-start,"文件下载失败");
} finally {
try {
if (bis != null)
bis.close();
if (bos != null)
bos.close();
} catch (Exception e2) {
thread.setExceptionInfo(e2.getMessage()+" "+e2.getCause());
logger.error(e2.toString());
throw new RestServiceException(thread,System.currentTimeMillis()-start,"文件下载失败");
}
}
try {
fileObject.put("fileName", downLoadPath);
fileObject.put("fileNameMd5", MD5Utils.getMD5Checksum(downLoadPath));
fileObject.put("downloadTime", ymdhms.format(new Date()));
} catch (NoSuchAlgorithmException e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
// TODO Auto-generated catch block
e.printStackTrace();
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "文件下载",fileName);
}
}

View File

@@ -0,0 +1,56 @@
package com.nis.web.controller.restful;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.ConfigPzIdSource;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.ConfigPzIdService;
import com.wordnik.swagger.annotations.ApiOperation;
@RestController
@RequestMapping("${servicePath}/cfg/v1")
@SuppressWarnings({ "rawtypes", "unchecked" })
public class ConfigPzIdController extends BaseRestController {
protected final Logger logger1 = Logger.getLogger(this.getClass());
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@Autowired
protected ConfigPzIdService configPzIdService;
@RequestMapping(value = "/configPzIdSources", method = RequestMethod.GET)
@ApiOperation(value = "配置ID获取服务", httpMethod = "GET", notes = "get pz_id")
public Map configPzIdSources(ConfigPzIdSource configPzIdSource, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
configPzIdSource);
try {
configPzIdService.getConfigPzIdList(configPzIdSource);
} catch (Exception e) {
e.printStackTrace();
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger.error(e.getMessage());
logger.error(e.getCause());
throw new RestServiceException(thread, System.currentTimeMillis() - start, "配置ID获取失败");
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "配置ID获取成功",
configPzIdSource);
}
}

View File

@@ -0,0 +1,323 @@
package com.nis.web.controller.restful;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.ConfigCompile;
import com.nis.domain.restful.ConfigSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.util.StringUtils;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.ConfigSourcesService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
/**
* @ClassName: ConfigSourcesController
* @Description: 配置存储服务
* @author (zx)
* @date 2016年9月5日 下午6:20:33
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}")
@Api(value = "ConfigSourcesController", description = "配置存储服务,包括管控、监测、白名单的控制类")
public class ConfigSourcesController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected ConfigSourcesService configSourcesService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@RequestMapping(value = "/cfg/v1/configSources", method = RequestMethod.POST)
@ApiOperation(value = "业务配置存储", httpMethod = "POST", response = Map.class, notes = "对有效的配置(封堵|监测|白名单)存储")
@ApiParam(value = "业务配置数据源", name = "configSource", required = true)
public Map createConfigSource(@RequestBody ConfigSource configSource, HttpServletRequest request,
HttpServletResponse response) {
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
configSource);
StringBuffer sb = new StringBuffer();
if (null != configSource && null != configSource.getConfigCompileList()
&& configSource.getConfigCompileList().size() > 0) {
int opAction = configSource.getOpAction();
checkOpAction(thread, System.currentTimeMillis() - start, opAction, 1);
// 验证配置编译数据
validateConfigSource(thread, start, configSource);
Long benginTime = System.currentTimeMillis();
String msg = configSourcesService.saveByJDBCThread(thread, start, configSource.getConfigCompileList(), sb);
if (msg.equals("error")) {
String errorCode = "";
Exception exception = ConfigSourcesService.getMsgList().get(0);
String str = exception.getMessage();
if (null != str && str.length() > 0) {
int index = str.toUpperCase().indexOf("ORA-");
if (index != -1) {
errorCode = str.substring(index + 4, index + 9);
}
}
Map<Integer, String> throwExceptionInfo = OracleErrorCodeUtil.throwExceptionInfo(errorCode);
for (int errorNum : throwExceptionInfo.keySet()) {
if (errorNum == 998) {
thread.setExceptionInfo(exception.toString());
} else {
thread.setExceptionInfo(throwExceptionInfo.get(errorNum));
}
throw new RestServiceException(thread, System.currentTimeMillis() - start,
throwExceptionInfo.get(errorNum), errorNum);
}
}
// configSourcesService.insertConfigSourceData(thread, start,
// configSource.getConfigCompileList(), sb);
Long endSaveTime = System.currentTimeMillis();
Long time = (endSaveTime - benginTime) / 1000;
System.out.println("插入数据成功总共需要" + time + "");
} else {
thread.setExceptionInfo("编译配置数据不能为空");
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置数据不能为空",
RestBusinessCode.missing_args.getValue());
}
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
"编译配置数据插入成功" + sb.toString(), configSource);
}
@RequestMapping(value = "/cfg/v1/configSources", method = RequestMethod.PUT)
@ApiOperation(value = "业务配置状态更新", httpMethod = "PUT", response = Map.class, notes = "对有效的配置(封堵|监测|白名单)进行配置失效")
@ApiParam(value = "业务配置数据源", name = "configSource", required = true)
public Map updateConfigSource(@RequestBody ConfigSource configSource, HttpServletRequest request,
HttpServletResponse response) {
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
configSource);
StringBuffer sb = new StringBuffer();
if (null == configSource.getOpTime()) {
configSource.setOpTime(new Date());
}
if (null != configSource && null != configSource.getConfigCompileList()
&& configSource.getConfigCompileList().size() > 0) {
int opAction = configSource.getOpAction();
checkOpAction(thread, System.currentTimeMillis() - start, opAction, 2);
String msg = "";
ConfigCompile compile = configSource.getConfigCompileList().get(0);
if(StringUtil.isEmpty(compile.getGroupRelationList())&&StringUtil.isEmpty(compile.getIpRegionList())&&StringUtil.isEmpty(compile.getStrRegionList())&&StringUtil.isEmpty(compile.getNumRegionList())){
msg = configSourcesService.updateByJDBCThread3(thread, start, configSource.getConfigCompileList(),
configSource.getOpTime(), sb);
}else{
msg = configSourcesService.updateByJDBCThread12(thread, start, configSource.getConfigCompileList(),
configSource.getOpTime(), sb);
}
if (msg.equals("error")) {
String errorCode = "";
Exception exception = ConfigSourcesService.getMsgList().get(0);
String message = exception.getMessage();
if (null != message && message.length() > 0) {
int index = message.toUpperCase().indexOf("ORA-");
if (index != -1) {
errorCode = message.substring(index + 4, index + 9);
}
}
Map<Integer, String> throwExceptionInfo = OracleErrorCodeUtil.throwExceptionInfo(errorCode);
for (int errorNum : throwExceptionInfo.keySet()) {
if (errorNum == 998) {
thread.setExceptionInfo(exception.toString());
} else {
thread.setExceptionInfo(throwExceptionInfo.get(errorNum));
}
throw new RestServiceException(thread, System.currentTimeMillis() - start,
throwExceptionInfo.get(errorNum), errorNum);
}
}
// configSourcesService.updateConfigSource(thread, start,
// configSource.getConfigCompileList(),
// configSource.getOpTime(), sb);
} else {
thread.setExceptionInfo("编译配置数据不能为空");
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置数据不能为空" + sb.toString(),
RestBusinessCode.missing_args.getValue());
}
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
"编译配置修改成功" + sb.toString(), configSource);
}
@RequestMapping(value = "/cfg/v1/configModifySources", method = RequestMethod.PUT)
@ApiOperation(value = "编译配置修改", httpMethod = "PUT", response = Map.class, notes = "对有效的配置(封堵|监测|白名单)存储")
@ApiParam(value = "编译配置修改", name = "configSource", required = true)
public Map configModifySources(@RequestBody ConfigSource configSource, HttpServletRequest request,
HttpServletResponse response) {
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
configSource);
StringBuffer sb = new StringBuffer();
if (null != configSource && null != configSource.getConfigCompileList()
&& configSource.getConfigCompileList().size() > 0) {
int opAction = configSource.getOpAction();
checkOpAction(thread, System.currentTimeMillis() - start, opAction, 2);
// 验证配置编译数据
validateConfigSource(thread, start, configSource);
try {
List<ConfigCompile> configCompileList = configSource.getConfigCompileList();
if (null != configCompileList && configCompileList.size() > 0) {
int count = 0;
for (ConfigCompile configCompile : configCompileList) {
Long compileId = configCompile.getCompileId();
if (null == compileId) {
thread.setExceptionInfo("编译配置id不能为空");
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置id不能为空",
RestBusinessCode.missing_args.getValue());
}
if ((configCompile.getActiveSys() != null) || (configCompile.getEffectiveRange() != null
&& !configCompile.getEffectiveRange().equals(""))) {
count++;
configSourcesService.setCompileInvalid(configCompile);
}
}
if (count > 0) {
Thread.sleep(14000);
}
String str = configSourcesService.configModifySources(configCompileList);
if (str.equals("idIsNull")) {
thread.setExceptionInfo("编译配置id不能为空");
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置id不能为空",
RestBusinessCode.missing_args.getValue());
}
} else {
thread.setExceptionInfo("编译配置数据不能为空");
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置数据不能为空",
RestBusinessCode.missing_args.getValue());
}
} catch (Exception e) {
List<ConfigCompile> configCompileList = configSource.getConfigCompileList();
if (null != configCompileList && configCompileList.size() > 0) {
for (ConfigCompile configCompile : configCompileList) {
Long compileId = configCompile.getCompileId();
if (null == compileId) {
thread.setExceptionInfo("编译配置id不能为空");
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置id不能为空",
RestBusinessCode.missing_args.getValue());
}
if ((configCompile.getActiveSys() != null) || (configCompile.getEffectiveRange() != null
&& !configCompile.getEffectiveRange().equals(""))) {
try {
configSourcesService.setCompileValid(configCompile);
} catch (Exception e1) {
String errorCode = "";
String message = e.getMessage();
if (null != message && message.length() > 0) {
int index = message.toUpperCase().indexOf("ORA-");
if (index != -1) {
errorCode = message.substring(index + 4, index + 9);
}
}
Map<Integer, String> throwExceptionInfo = OracleErrorCodeUtil.throwExceptionInfo(errorCode);
for (int errorNum : throwExceptionInfo.keySet()) {
if (errorNum == 998) {
thread.setExceptionInfo(e.toString());
} else {
thread.setExceptionInfo(throwExceptionInfo.get(errorNum));
}
throw new RestServiceException(thread, System.currentTimeMillis() - start,
throwExceptionInfo.get(errorNum), errorNum);
}
}
}
}
}
String errorCode = "";
String message = e.getMessage();
if (null != message && message.length() > 0) {
int index = message.toUpperCase().indexOf("ORA-");
if (index != -1) {
errorCode = message.substring(index + 4, index + 9);
}
}
Map<Integer, String> throwExceptionInfo = OracleErrorCodeUtil.throwExceptionInfo(errorCode);
for (int errorNum : throwExceptionInfo.keySet()) {
if (errorNum == 998) {
thread.setExceptionInfo(e.toString());
} else {
thread.setExceptionInfo(throwExceptionInfo.get(errorNum));
}
throw new RestServiceException(thread, System.currentTimeMillis() - start,
throwExceptionInfo.get(errorNum), errorNum);
}
}
} else {
thread.setExceptionInfo("编译配置数据不能为空");
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置数据不能为空",
RestBusinessCode.missing_args.getValue());
}
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
"修改编译配置数据成功" + sb.toString(), configSource);
}
private void validateConfigSource(SaveRequestLogThread thread, long start, ConfigSource configSource) {
String errorInfo = "";
List<ConfigCompile> configCompileList = configSource.getConfigCompileList();
if (StringUtils.isEmpty(configSource.getOperator())) {
errorInfo = "get operator is Empty";
}
if (StringUtils.isEmpty(configSource.getVersion())) {
errorInfo = "get version is Empty";
}
if (!isBlank(configSource.getOpTime())) {
errorInfo = "get OpTime is Empty";
}
if (configCompileList.size() <= 0) {
errorInfo = "编译配置不能为空";
}
if (!errorInfo.equals("")) {
thread.setExceptionInfo(errorInfo);
throw new RestServiceException(thread, System.currentTimeMillis() - start, errorInfo,
RestBusinessCode.missing_args.getValue());
}
}
private boolean isBlank(Date datetime) {
if (null != datetime) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,820 @@
package com.nis.web.controller.restful;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nis.crypt.AESUtil;
import com.nis.domain.Page;
import com.nis.domain.restful.ConfigCompile;
import com.nis.domain.restful.ConfigCompileTest;
import com.nis.domain.restful.ConfigGroupRelation;
import com.nis.domain.restful.ConfigSourceTest;
import com.nis.domain.restful.IpRegion;
import com.nis.domain.restful.IpRegionTest;
import com.nis.domain.restful.NumRegion;
import com.nis.domain.restful.NumRegionTest;
import com.nis.domain.restful.StrRegion;
import com.nis.domain.restful.StrRegionTest;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Configurations;
import com.nis.util.Constants;
import com.nis.util.JsonDateValueProcessor;
import com.nis.util.StringUtils;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.ConfigSourcesService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import net.sf.json.JSONArray;
import net.sf.json.JsonConfig;
/**
* @ClassName: ConfigSourceTestsController
* @Description: 配置存储服务
* @author (zx)
* @date 2016年9月5日 下午6:20:33
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}")
@Api(value = "ConfigTestController", description = "配置存储服务,包括管控、监测、白名单的控制类")
public class ConfigTestController extends BaseRestController {
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Logger logger = LoggerFactory.getLogger(ConfigTestController.class);
@Autowired
protected ConfigSourcesService configSourcesService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
private long allCount = 0l;
@RequestMapping(value = "/cfg/v1/insertBatch", method = RequestMethod.POST)
@ApiOperation(value = "批量业务配置存储", httpMethod = "POST", response = Map.class, notes = "对有效的配置(封堵|监测|白名单)存储")
public Map insertBatchaaaaa(@RequestParam(value = "configCount", required = false) Long configCount,
@RequestParam(value = "action", required = false) Integer action,
@RequestParam(value = "serviceType", required = false) Long serviceType,
@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime, HttpServletRequest request,
HttpServletResponse response) throws Exception {
StringBuffer sb = new StringBuffer();
allCount = 0l;
long dataCount = 0l;
long start = System.currentTimeMillis();
SaveRequestLogThread thread1 = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
null);
if (configCount == null) {
throw new RestServiceException(thread1, System.currentTimeMillis() - start, "批量增加条数不能为空",
RestBusinessCode.missing_args.getValue());
}
if (startTime == null || startTime.equals("")) {
throw new RestServiceException(thread1, System.currentTimeMillis() - start, "开始时间不能为空",
RestBusinessCode.missing_args.getValue());
}
if (endTime == null || endTime.equals("")) {
throw new RestServiceException(thread1, System.currentTimeMillis() - start, "结束时间不能为空",
RestBusinessCode.missing_args.getValue());
}
System.out.println("configCount" + configCount);
System.out.println("action" + action);
System.out.println("serviceType" + serviceType);
System.out.println("startTime" + startTime);
System.out.println("endTime" + endTime);
Integer[] zeroArr = { 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
Integer[] oneArr = { 15, 16, 32, 33, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60 };
Integer[] twoArr = { 2 };
try {
Date date = new Date();
// String date = "2016-09-26T03:39:30.577Z";
ConfigSourceTest configSource = new ConfigSourceTest();
configSource.setOpTime(date);
configSource.setOpAction(1);
configSource.setOperator("rkg");
configSource.setVersion("0.1");
List<ConfigCompile> configCompileList = new ArrayList<ConfigCompile>();
long count = System.currentTimeMillis() + 1;
for (Integer x = 0; x < zeroArr.length; x++) {
for (Long i = 1l; i <= configCount; i++) {
count++;
dataCount++;
ConfigCompile configCompile = setCompileTest(zeroArr[x].longValue(), 0, date, startTime, endTime,
count);
configCompileList.add(configCompile);
}
}
for (Integer x = 15; x < oneArr.length + 15; x++) {
for (Long i = 1l; i <= configCount; i++) {
count++;
dataCount++;
ConfigCompile configCompile = setCompileTest(oneArr[x - 15].longValue(), 1, date, startTime,
endTime, count);
configCompileList.add(configCompile);
}
}
for (Integer x = 50; x < twoArr.length + 50; x++) {
for (Long i = 1l; i <= configCount; i++) {
count++;
dataCount++;
ConfigCompile configCompile = setCompileTest(twoArr[x - 50].longValue(), 2, date, startTime,
endTime, count);
configCompileList.add(configCompile);
}
}
configSource.setConfigCompileList(configCompileList);
validateConfigSourceTest(thread1, start, configSource);
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.registerJsonValueProcessor(Date.class, new JsonDateValueProcessor());
JSONArray jsonArray = JSONArray.fromObject(configSource, jsonConfig);
String jsonStr = jsonArray.getString(0);
String distisct = "\"district\":\"\",";
if (jsonStr.contains(distisct)) {
jsonStr = jsonStr.replaceAll(distisct, "");
}
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST,
request, configSource);
System.out.println("开始执行插入操作" + dataCount + "条配置总计" + allCount + "条数据");
Long benginTime = System.currentTimeMillis();
configSourcesService.insertConfigSourceData(thread, System.currentTimeMillis() - start,
configSource.getConfigCompileList(), sb);
Long endSaveTime = System.currentTimeMillis();
Long time = (endSaveTime - benginTime) / 1000;
System.out.println("插入了" + dataCount + "条配置总计" + allCount + "条数据总共需要" + time + "");
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "编译配置数据插入成功",
configSource);
} catch (Exception e) {
thread1.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
return serviceResponse(thread1, System.currentTimeMillis() - start, request, response, "编译配置数据插入失败", null);
}
}
@RequestMapping(value = "/test/v1/insertBatchss", method = RequestMethod.POST)
@ApiOperation(value = "批量业务配置存储", httpMethod = "POST", response = Map.class, notes = "对有效的配置(封堵|监测|白名单)存储")
public Map insertBatch(@RequestParam(value = "configCount", required = false) Long configCount,
@RequestParam(value = "action", required = false) Integer action,
@RequestParam(value = "serviceType", required = false) Long serviceType,
@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime, HttpServletRequest request,
HttpServletResponse response) throws Exception {
StringBuffer sb = new StringBuffer();
long start = System.currentTimeMillis();
SaveRequestLogThread thread1 = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
if (configCount == null) {
throw new RestServiceException(thread1, System.currentTimeMillis() - start, "批量增加条数不能为空",
RestBusinessCode.missing_args.getValue());
}
if (serviceType == null) {
throw new RestServiceException(thread1, System.currentTimeMillis() - start, "业务类型不能为空",
RestBusinessCode.missing_args.getValue());
}
if (startTime == null || startTime.equals("")) {
throw new RestServiceException(thread1, System.currentTimeMillis() - start, "开始时间不能为空",
RestBusinessCode.missing_args.getValue());
}
if (endTime == null || endTime.equals("")) {
throw new RestServiceException(thread1, System.currentTimeMillis() - start, "结束时间不能为空",
RestBusinessCode.missing_args.getValue());
}
System.out.println("configCount" + configCount);
System.out.println("action" + action);
System.out.println("serviceType" + serviceType);
System.out.println("startTime" + startTime);
System.out.println("endTime" + endTime);
try {
Date date = new Date();
// String date = "2016-09-26T03:39:30.577Z";
ConfigSourceTest configSource = new ConfigSourceTest();
configSource.setOpTime(date);
configSource.setOpAction(1);
configSource.setOperator("rkg");
configSource.setVersion("0.1");
List<ConfigCompile> configCompileList = new ArrayList<ConfigCompile>();
for (Long i = 0l; i < configCount; i++) {
ConfigCompile configCompile = setCompileTest(serviceType, action, date, startTime, endTime, i);
configCompileList.add(configCompile);
}
configSource.setConfigCompileList(configCompileList);
validateConfigSourceTest(thread1, start, configSource);
Long benginTime = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST,
request, configSource);
configSourcesService.insertConfigSourceData(thread, System.currentTimeMillis() - start,
configSource.getConfigCompileList(), sb);
Long endSaveTime = System.currentTimeMillis();
Long time = (endSaveTime - benginTime) / 1000;
System.out.println("插入" + configCount + "条数据总共需要" + time + "");
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "编译配置数据插入成功",
configSource);
} catch (Exception e) {
thread1.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
return serviceResponse(thread1, System.currentTimeMillis() - start, request, response, "编译配置数据插入失败", null);
}
}
@RequestMapping(value = "/test/v1/findCompile", method = RequestMethod.POST)
public Map findCompile(ConfigCompileTest configCompileTest, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread1 = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
configCompileTest);
Page page = new Page();
int no = configCompileTest.getPagesNo() == null ? 1 : configCompileTest.getPagesNo();
int size = configCompileTest.getPagesSize() == null ? 10 : configCompileTest.getPagesSize();
page.setPageNo(no);
page.setPageSize(size);
Page<ConfigCompileTest> queryAllCompile = null;
try {
if (configCompileTest.getSearchStartTime() != null && !configCompileTest.getSearchStartTime().equals("")) {
configCompileTest.setStartTime(sdf.parse(configCompileTest.getSearchStartTime()));
// configCompile.setStartTime(configCompile.getSearchStartTime());
}
if (configCompileTest.getSearchEndTime() != null && !configCompileTest.getSearchEndTime().equals("")) {
configCompileTest.setEndTime(sdf.parse(configCompileTest.getSearchEndTime()));
// configCompile.setEndTime(configCompile.getSearchEndTime());
}
queryAllCompile = configSourcesService.queryAllCompile(page, configCompileTest);
} catch (SQLException e) {
thread1.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
throw new RestServiceException(thread1, System.currentTimeMillis() - start, "编译配置获取失败");
} catch (Exception e) {
thread1.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
throw new RestServiceException(thread1, System.currentTimeMillis() - start, "编译配置获取失败");
}
return serviceResponse(thread1, System.currentTimeMillis() - start, request, response, "编译配置获取成功",
queryAllCompile);
}
public ConfigSourceTest setConfigSourceTest() throws Exception {
Long configCount = 2l;
Date date = new Date();
// String date = "2016-09-26T03:39:30.577Z";
ConfigSourceTest configSource = new ConfigSourceTest();
configSource.setOpTime(date);
configSource.setOpAction(1);
configSource.setOperator("rkg");
configSource.setVersion("0.1");
List<ConfigCompile> configCompileList = new ArrayList<ConfigCompile>();
Long serviceType = 1l;
Integer action = 0;
String startTime = "2016-09-26";
String endTime = "2016-09-29";
for (Long i = 0l; i < configCount; i++) {
ConfigCompile configCompile = setCompileTest(serviceType, action, date, startTime, endTime, i);
configCompileList.add(configCompile);
}
configSource.setConfigCompileList(configCompileList);
// validateConfigSourceTest(thread1, start,configSource);
return configSource;
}
@RequestMapping(value = "/test/v1/saveByQuery", method = RequestMethod.POST)
public String saveByQuery(String id, HttpServletRequest request, HttpServletResponse response) {
System.out.println(id);
try {
// String url =
// "http://127.0.0.1:8888/gk/service/cfg/v1/configSources";
String url = Configurations.getStringProperty("httpUrl", "");
ConfigSourceTest configSource = new ConfigSourceTest();
configSource.setOpTime(new Date());
configSource.setOpAction(1);
configSource.setOperator("rkg");
configSource.setVersion("0.1");
id = id.replace("[", "");
id = id.replace("]", "");
id = id.substring(1);
List<ConfigCompile> configCompileList = new ArrayList<ConfigCompile>();
List<ConfigCompileTest> queryConfigCompileByIdArr = configSourcesService.queryConfigCompileByIdArr(id);
for (int i = 0; i < queryConfigCompileByIdArr.size(); i++) {
ConfigCompile configCompile = queryConfigCompileByIdArr.get(i);
ConfigCompile compileInfo = getCompileInfo(configCompile);
configCompileList.add(compileInfo);
}
configSource.setConfigCompileList(configCompileList);
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.registerJsonValueProcessor(Date.class, new JsonDateValueProcessor());
JSONArray jsonArray = JSONArray.fromObject(configSource, jsonConfig);
String jsonStr = jsonArray.getString(0);
String distisct = "\"district\":\"\",";
if (jsonStr.contains(distisct)) {
jsonStr = jsonStr.replaceAll(distisct, "");
}
System.out.println(jsonStr);
String result = sendPost(url, jsonStr);
System.out.println(result);
if (result.equals("")) {
return "error";
} else {
return "ok";
}
} catch (Exception e) {
e.printStackTrace();
}
return "error";
}
@RequestMapping(value = "/test/v1/saveAllByQuery", method = RequestMethod.POST)
public String saveAllByQuery(ConfigCompileTest configCompileTest, HttpServletRequest request,
HttpServletResponse respons) throws Exception {
try {
if (configCompileTest.getSearchStartTime() != null && !configCompileTest.getSearchStartTime().equals("")) {
configCompileTest.setStartTime(sdf.parse(configCompileTest.getSearchStartTime()));
// configCompile.setStartTime(configCompile.getSearchStartTime());
}
if (configCompileTest.getSearchEndTime() != null && !configCompileTest.getSearchEndTime().equals("")) {
configCompileTest.setEndTime(sdf.parse(configCompileTest.getSearchEndTime()));
// configCompile.setEndTime(configCompile.getSearchEndTime());
}
List<ConfigCompile> compileList = new ArrayList<ConfigCompile>();
List<ConfigCompileTest> queryAllCompile = configSourcesService.queryAllCompile(configCompileTest);
for (int i = 0; i < queryAllCompile.size(); i++) {
ConfigCompile configCompile = queryAllCompile.get(i);
ConfigCompile compileInfo = getCompileInfo(configCompile);
compileList.add(compileInfo);
}
ConfigSourceTest configSource = new ConfigSourceTest();
configSource.setOpTime(new Date());
configSource.setOpAction(1);
configSource.setOperator("rkg");
configSource.setVersion("0.1");
configSource.setConfigCompileList(compileList);
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.registerJsonValueProcessor(Date.class, new JsonDateValueProcessor());
// String url =
// "http://127.0.0.1:8888/gk/service/cfg/v1/configSources";
String url = Configurations.getStringProperty("httpUrl", "");
JSONArray jsonArray = JSONArray.fromObject(configSource, jsonConfig);
String jsonStr = jsonArray.getString(0);
String distisct = "\"district\":\"\",";
if (jsonStr.contains(distisct)) {
jsonStr = jsonStr.replaceAll(distisct, "");
}
System.out.println(jsonStr);
String result = sendPost(url, jsonStr);
System.out.println(result);
if (result.equals("")) {
return "error";
} else {
return "ok";
}
} catch (Exception e) {
e.printStackTrace();
}
return "error";
}
public ConfigCompile getCompileInfo(ConfigCompile configCompileTest) {
List<ConfigGroupRelation> groupByCompileList = configSourcesService
.getGroupByCompile(configCompileTest.getCompileId());
configCompileTest.setGroupRelationList(groupByCompileList);
Long[] groupIdArr = new Long[groupByCompileList.size()];
for (int i = 0; i < groupByCompileList.size(); i++) {
groupIdArr[i] = groupByCompileList.get(i).getGroupId();
}
Map<String, String> tableMap = configSourcesService.getTableMap(configCompileTest.getService().intValue());
List<String> strTable = new ArrayList<String>();
String ipTable = null;
String numTable = null;
if (null != tableMap && tableMap.size() > 0) {
for (String str : tableMap.keySet()) {
if (tableMap.get(str).equals("ip")) {
ipTable = str;
} else if (tableMap.get(str).equals("num")) {
numTable = str;
} else if (tableMap.get(str).equals("str")) {
strTable.add(str);
}
}
}
if (strTable.size() > 0) {
List<StrRegion> strRegionList = configSourcesService.getStrRegionByGId(strTable, groupIdArr);
if (null != strRegionList && strRegionList.size() > 0) {
configCompileTest.setStrRegionList(strRegionList);
}
}
if (ipTable != null) {
if (ipTable.equals("DF_IP_PORT")) {
System.out.println("DF_IP_PORT" + configCompileTest.getService());
}
if (ipTable.equals("FX_IP_PORT")) {
System.out.println("FX_IP_PORT" + configCompileTest.getService());
}
List<IpRegion> ipRegionByGId = configSourcesService.getIpRegionByGId(ipTable, groupIdArr);
if (null != ipRegionByGId && ipRegionByGId.size() > 0) {
configCompileTest.setIpRegionList(ipRegionByGId);
}
}
if (numTable != null) {
List<NumRegion> numRegionList = configSourcesService.getNumRegionByGId(numTable, groupIdArr);
if (null != numRegionList && numRegionList.size() > 0) {
configCompileTest.setNumRegionList(numRegionList);
}
}
return configCompileTest;
}
/**
* 向指定URL发送POST方法的请求
*
* @param url
* 发送请求的url
* @param param
* 请求参数,格式为 name1=value1&name2=value2的形式
* @return 所代表远程资源的相应结果
*/
public String sendPost(String url, String param) {
// ConfigSourceTest
PrintWriter out = null;
BufferedReader in = null;
String result = "";
try {
URL realUrl = new URL(url);
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setConnectTimeout(200000);
conn.setReadTimeout(3000000);
conn.connect();
// 获取URLConnection对象对应的输出流
out = new PrintWriter(conn.getOutputStream());
// 发送请求参数
out.print(param);
// flush输出流的缓冲
out.flush();
out.close();
InputStream inputStream = conn.getInputStream();
in = new BufferedReader(new InputStreamReader(inputStream));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送POST请求出现异常" + e);
e.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
public String sendGet(String url, String param) {
BufferedReader in = null;
String result = "";
try {
String urlNameString = url + "?" + param;
urlNameString = "http://127.0.0.1:8888/gk/service/log/v1/dfStatLogDailySources?pageNo=1&pageSize=2";
URL realUrl = new URL(urlNameString);
// 打开和URL之间的连接
URLConnection conn = realUrl.openConnection();
// 设置通用的请求属性
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
conn.connect();
Map<String, List<String>> headerFields = conn.getHeaderFields();
for (String key : headerFields.keySet()) {
System.out.println(key);
}
InputStream inputStream = conn.getInputStream();
in = new BufferedReader(new InputStreamReader(inputStream));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送POST请求出现异常" + e);
e.printStackTrace();
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
public ConfigCompileTest setCompileTest(Long serviceType, Integer action, Date date, String startTime,
String endTime, Long index) throws Exception {
Long compileId = System.currentTimeMillis() + index;
System.out.println("compileId--------------------------" + compileId);
ConfigCompileTest configCompile = new ConfigCompileTest();
configCompile.setCompileId(compileId);
configCompile.setService(serviceType);
configCompile.setAction(action);
configCompile.setContType(0);
configCompile.setAttrType(0);
configCompile.setContLabel("0");
configCompile.setTaskId(0);
configCompile.setGuaranteeId(0);
configCompile.setAffAirId(0);
configCompile.setTopIcId(0);
configCompile.setDoBlackList(0l);
configCompile.setDoLog(0);
configCompile.setEffectiveRange("0");
configCompile.setConfigPercent(100l);
configCompile.setConfigOption(1);
configCompile.setStartTime(sdf.parse(startTime));
configCompile.setEndTime(sdf.parse(endTime));
// configCompile.setStartTime(startTime);
// configCompile.setEndTime(endTime);
configCompile.setActiveSys(0);
configCompile.setLastUpdate(date);
configCompile.setProcSeq(compileId);
configCompile.setUserRegion("0");
configCompile.setIsValid(1);
configCompile.setGroupNum(1);
configCompile.setFatherCfgId(0l);
configCompile.setOpTime(date);
Long groupId = System.currentTimeMillis() + (long) ((Math.random()) * 100000);
configCompile.setGroupRelationList(setGroupList(compileId, date, groupId));
Map<String, String> tableMap = configSourcesService.getTableMap(serviceType.intValue());
List<String> strTable = new ArrayList<String>();
String ipTable = null;
String numTable = null;
if (null != tableMap && tableMap.size() > 0) {
for (String str : tableMap.keySet()) {
if (tableMap.get(str).equals("ip")) {
ipTable = str;
} else if (tableMap.get(str).equals("num")) {
numTable = str;
} else if (tableMap.get(str).equals("str")) {
strTable.add(str);
}
}
}
configCompile.setStrRegionList(setStrRegionList(serviceType, groupId, date, strTable, index));
configCompile.setIpRegionList(setIpRegionList(serviceType, groupId, date, ipTable, index));
configCompile.setNumRegionList(setNumRegionList(serviceType, groupId, date, numTable, index));
return configCompile;
}
public List<ConfigGroupRelation> setGroupList(Long compileId, Date date, Long groupId) {
List<ConfigGroupRelation> groupRelationList = new ArrayList<ConfigGroupRelation>();
ConfigGroupRelation configGroupRelation = new ConfigGroupRelation();
configGroupRelation.setGroupId(groupId);
configGroupRelation.setId(groupId);
configGroupRelation.setCompileId(compileId);
configGroupRelation.setIsValid(1);
configGroupRelation.setOpTime(date);
groupRelationList.add(configGroupRelation);
allCount++;
return groupRelationList;
}
public List<StrRegion> setStrRegionList(Long service, Long groupId, Date date, List<String> tableName, Long index) {
List<StrRegion> strRegionList = new ArrayList<StrRegion>();
if (tableName != null & tableName.size() > 0) {
Long regionId = System.currentTimeMillis() + index;
System.out.println("Strid--------------------------" + regionId);
StrRegionTest strRegion = new StrRegionTest();
strRegion.setRegionId(regionId);
strRegion.setGroupId(groupId);
strRegion.setKeywords("百度");
strRegion.setExprType(0);
strRegion.setMatchMethod(0);
strRegion.setIsHexbin(0);
strRegion.setIsValid(1);
strRegion.setOpTime(date);
if (configSourcesService.isStrStrongRegion(tableName.get(0))) {
strRegion.setDistrict("南京");
}
strRegion.setTableName(tableName.get(0));
strRegion.setProcSeq(regionId);
strRegionList.add(strRegion);
StrRegionTest strRegion1 = new StrRegionTest();
Long regionId1 = System.currentTimeMillis() + index + 100000;
System.out.println("Strid===================================" + regionId);
strRegion1.setRegionId(regionId1);
strRegion1.setGroupId(groupId);
strRegion1.setKeywords("新浪");
strRegion1.setExprType(0);
strRegion1.setMatchMethod(0);
strRegion1.setIsHexbin(0);
strRegion1.setIsValid(1);
strRegion1.setOpTime(date);
strRegion1.setProcSeq(regionId1);
if (tableName.size() > 1) {
strRegion1.setTableName(tableName.get(1));
if (configSourcesService.isStrStrongRegion(tableName.get(1))) {
strRegion1.setDistrict("北京");
}
} else {
strRegion1.setTableName(tableName.get(0));
if (configSourcesService.isStrStrongRegion(tableName.get(0))) {
strRegion1.setDistrict("上海");
}
}
strRegionList.add(strRegion1);
allCount++;
return strRegionList;
} else {
return strRegionList;
}
}
public List<IpRegion> setIpRegionList(Long service, Long groupId, Date date, String tableName, Long index) {
List<IpRegion> ipRegionList = new ArrayList<IpRegion>();
if (tableName != null) {
IpRegionTest ipRegion = new IpRegionTest();
Long regionId = System.currentTimeMillis() + index;
System.out.println("Ipid--------------------------" + regionId);
ipRegion.setRegionId(regionId);
ipRegion.setGroupId(groupId);
ipRegion.setAddrType(4);
ipRegion.setSrcIp("0.0.0.0");
ipRegion.setMaskSrcIp("0.0.0.0");
ipRegion.setSrcPort("0");
ipRegion.setMaskSrcPort("0");
ipRegion.setDstIp("0.0.0.0");
ipRegion.setMaskDstIp("0.0.0.0");
ipRegion.setDstPort("0");
ipRegion.setMaskDstPort("0");
ipRegion.setProtocol(0);
ipRegion.setDirection(0);
ipRegion.setIsValid(1);
ipRegion.setOpTime(date);
ipRegion.setTableName(tableName);
ipRegion.setProcSeq(regionId);
ipRegionList.add(ipRegion);
allCount++;
return ipRegionList;
} else {
return ipRegionList;
}
}
public List<NumRegion> setNumRegionList(Long service, Long groupId, Date date, String tableName, Long index) {
List<NumRegion> numRegionList = new ArrayList<NumRegion>();
if (tableName != null) {
NumRegionTest numRegion = new NumRegionTest();
Long regionId = System.currentTimeMillis() + index;
System.out.println("numid--------------------------" + regionId);
numRegion.setRegionId(regionId);
numRegion.setGroupId(groupId);
numRegion.setLowBoundary(index);
numRegion.setUpBoundary(index);
numRegion.setIsValid(1);
numRegion.setOpTime(date);
numRegion.setTableName(tableName);
numRegion.setProcSeq(regionId);
numRegionList.add(numRegion);
allCount++;
return numRegionList;
} else {
return numRegionList;
}
}
private void validateConfigSourceTest(SaveRequestLogThread thread, long start, ConfigSourceTest configSource) {
String errorInfo = "";
List<ConfigCompile> configCompileList = configSource.getConfigCompileList();
if (StringUtils.isEmpty(configSource.getOperator())) {
errorInfo = "get operator is Empty";
}
if (StringUtils.isEmpty(configSource.getVersion())) {
errorInfo = "get version is Empty";
}
if (!isBlank(configSource.getOpTime())) {
errorInfo = "get OpTime is Empty";
}
if (configCompileList.size() <= 0) {
errorInfo = "编译配置不能为空";
}
if (!errorInfo.equals("")) {
throw new RestServiceException(thread, System.currentTimeMillis() - start, errorInfo,
RestBusinessCode.missing_args.getValue());
}
}
private boolean isBlank(Date datetime) {
if (null != datetime) {
return true;
}
return false;
}
public static synchronized String getId() {
long nowDate = new Date().getTime();
String hexString = Integer.toHexString((int) nowDate);
return hexString;
}
public static void main(String[] args) {
try {
// Calendar cl = Calendar.getInstance();
// cl.add(Calendar.SECOND, 10);
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
// System.out.println(sdf.format(cl.getTime().getTime() - 8 * 60 * 60 * 1000));
// props.setProperty("jdbc.product.password", new
// String(AESUtil.decrypt(Base64.decodeBase64(productPassword),
// productScretKey)));
String Key = AESUtil.initKeyString();
String password = new String(Base64.encodeBase64(AESUtil.encrypt("changan@2016".getBytes(), Key)));
String watchpwd = new String(AESUtil.decrypt(Base64.decodeBase64(password), Key));
// String decryptKey = new
// String(AESUtil.decrypt(Base64.decodeBase64("IkkVipTYFzqpSaX3nYwjRQ=="),
// "lsBezRxQ38m60L5pWhzoyA=="));
System.out.println(Key);
System.out.println(password);
System.out.println(watchpwd);
List<String> list = new ArrayList<String>();
// list.add("1");
// new ConfigTestController().setStrRegionList(1l, 2l, new Date(),
// list);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,193 @@
package com.nis.web.controller.restful;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.Page;
import com.nis.domain.restful.DataDictionaryValue;
import com.nis.listener.SystemConfigListener;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DataDictionaryService;
@RestController
@RequestMapping("${servicePath}")
public class DataDictionaryController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
private DataDictionaryService dataDictionaryService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@RequestMapping(value = "/cfg/v1/findAllDataDict", method = RequestMethod.POST)
public Map findAllDataDict(DataDictionaryValue dataDictionaryValue, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
dataDictionaryValue);
Page page = new Page();
int no = dataDictionaryValue.getPagesNo() == null ? 1 : dataDictionaryValue.getPagesNo();
int size = dataDictionaryValue.getPagesSize() == null ? 10 : dataDictionaryValue.getPagesSize();
page.setPageNo(no);
page.setPageSize(size);
Page<DataDictionaryValue> dataDictPage = null;
try {
dataDictPage = dataDictionaryService.getDataDictList(page, dataDictionaryValue);
} catch (Exception e) {
logger.error(e);
throw new RestServiceException(thread, start, "数据字典获取失败");
}
return serviceResponse(thread, start, request, response, "编译配置获取成功", dataDictPage);
}
@RequestMapping(value = "/cfg/v1/getAllDictName", method = RequestMethod.GET)
public Map getAllDictName(HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
try {
return serviceResponse(thread, start, request, response, "编译配置获取成功",
dataDictionaryService.getDataDictList());
} catch (Exception e) {
logger.error(e);
throw new RestServiceException(thread, start, "数据字典获取失败");
}
}
@RequestMapping(value = "/cfg/v1/addDictName", method = RequestMethod.POST)
public Map addDictName(String dataDictId, String addDictName, String dictVal, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
null);
try {
String option = "";
if (null != addDictName && !addDictName.equals("") && null != dictVal && !dictVal.equals("")) {
option = "addNameAndValue";
} else if (null != addDictName && !addDictName.equals("")) {
option = "addName";
} else if (null != dataDictId && !dataDictId.equals("") && null != dictVal && !dictVal.equals("")) {
option = "addValue";
}
String saveDataDict = dataDictionaryService.saveDataDict(dataDictId, addDictName, dictVal, option);
if (saveDataDict.equals("error")) {
return serviceResponse(thread, start, request, response, "添加数据字典失败", "error");
}
return serviceResponse(thread, start, request, response, "添加数据字典成功", "ok");
} catch (Exception e) {
logger.error(e);
throw new RestServiceException(thread, start, "添加数据字典失败");
}
}
@RequestMapping(value = "/cfg/v1/delDictVal", method = RequestMethod.POST)
public Map delDictVal(String dictValId, HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
null);
try {
String saveDataDict = dataDictionaryService.delDictVal(dictValId);
if (saveDataDict.equals("error")) {
return serviceResponse(thread, start, request, response, "删除数据字典值失败", "error");
}
return serviceResponse(thread, start, request, response, "删除数据字典值成功", "ok");
} catch (Exception e) {
logger.error(e);
throw new RestServiceException(thread, start, "删除数据字典值失败");
}
}
@RequestMapping(value = "/cfg/v1/delDictName", method = RequestMethod.POST)
public Map delDictName(String dictNameId, HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
null);
try {
String saveDataDict = dataDictionaryService.delDictName(dictNameId);
if (saveDataDict.equals("error")) {
return serviceResponse(thread, start, request, response, "删除数据字典名称失败", "error");
}
return serviceResponse(thread, start, request, response, "删除数据字典名称成功", "ok");
} catch (Exception e) {
logger.error(e);
throw new RestServiceException(thread, start, "删除数据字典名称失败");
}
}
@RequestMapping(value = "/cfg/v1/getDict", method = RequestMethod.POST)
public Map getDict(String dictValId, ModelMap map, HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
null);
try {
DataDictionaryValue dict = dataDictionaryService.getDict(dictValId);
if (null == dict) {
return serviceResponse(thread, start, request, response, "获取数据字典对象失败", "error");
}
return serviceResponse(thread, start, request, response, "获取数据字典对象成功", dict);
// if (null == dict) {
// map.put("dict", null);
// } else {
// map.put("dict", dict);
// }
// return "/test/page/dataDict/addOrUpdateDataDict.jsp";
} catch (Exception e) {
logger.error(e);
throw new RestServiceException(thread, start, "获取数据字典对象失败");
}
}
@RequestMapping(value = "/cfg/v1/updateDictName", method = RequestMethod.POST)
public Map updateDictName(String dictVal, String dictId, HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
null);
try {
String option = "updateVal";
String saveDataDict = dataDictionaryService.updateDataDict(dictVal, dictId, option);
if (saveDataDict.equals("error")) {
return serviceResponse(thread, start, request, response, "修改数据字典失败", "error");
}
return serviceResponse(thread, start, request, response, "修改数据字典成功", "ok");
} catch (Exception e) {
logger.error(e);
throw new RestServiceException(thread, start, "修改数据字典失败");
}
}
@RequestMapping(value = "/cfg/v1/setDataDictEffective", method = RequestMethod.POST)
public Map setDataDictEffective(HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
null);
try {
Map<String, List<DataDictionaryValue>> allDataDict = dataDictionaryService.getAllDataDict();
if (null != allDataDict && allDataDict.size() > 0) {
SystemConfigListener.setDictionaryMap(allDataDict);
}
return serviceResponse(thread, start, request, response, "数据字典更新成功", "ok");
} catch (Exception e) {
logger.error(e);
throw new RestServiceException(thread, start, "数据字典更新失败");
}
}
}

View File

@@ -0,0 +1,231 @@
package com.nis.web.controller.restful;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.Page;
import com.nis.domain.restful.DfDjLogStatistics;
import com.nis.domain.restful.DfDjPzLogStatistics;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.JsonMapper;
import com.nis.util.redis.RedisDao;
import com.nis.util.redis.SaveRedisThread;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DfdjLogStatService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: LogStatisticsController
* @Description: 封堵/监测日志统计查询服务
* @author (zbc)
* @date 2016年11月14日 下午4:00:00
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/log/v1")
@SuppressWarnings({ "rawtypes", "unchecked" })
public class DfDjLogStatController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
protected String logSource="0";
@Autowired
protected DfdjLogStatService logStatService;
@Autowired
protected RedisDao redisDao;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
/*@RequestMapping(value="/dfLogStatistics", method = RequestMethod.GET)
@ApiOperation(value="封堵日志总量统计查询" , httpMethod = "GET", notes="get log list")
public Map dfLogStatistics(
@RequestParam(value = "searchStatActiveSys", required = false, defaultValue = "2") String searchStatActiveSys,
@RequestParam(value = "searchService", required = true) String searchService,
DfDjLogStatistics logStatistics, HttpServletRequest request, HttpServletResponse response) {
if(!"4".equals(searchStatActiveSys) ) {
searchStatActiveSys="2";
logStatistics.setSearchStatActiveSys(searchStatActiveSys);
}
long start = System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
DfDjLogStatistics entity = null;
try{
logStatService.queryConditionCheck(thread,start,logStatistics, DfDjLogStatistics.class, null);
entity = logStatService.findDfLogStatistics(logStatistics);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"封堵日志总量统计检索失败");
}
((RestServiceException) e).setActiveSys(searchStatActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "封堵日志总量统计检索成功",
entity, searchStatActiveSys, logSource);
}
@RequestMapping(value="/dfPzLogStatistics", method = RequestMethod.GET)
@ApiOperation(value="封堵配置日志总量统计查询" , httpMethod = "GET", notes="get log list")
public Map dfPzLogStatistics(
@RequestParam(value = "searchStatActiveSys", required = false, defaultValue = "2") String searchStatActiveSys,
@RequestParam(value = "searchService", required = true) String searchService,
Page<DfDjPzLogStatistics> page, DfDjPzLogStatistics logStatistics,
HttpServletRequest request, HttpServletResponse response) {
if(!"4".equals(searchStatActiveSys) ) {
searchStatActiveSys="2";
logStatistics.setSearchStatActiveSys(searchStatActiveSys);
}
long start = System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfDjPzLogStatistics> logPage = null;
boolean keyExists = false;
String key = "";
try {
logStatService.queryConditionCheck(thread,start,logStatistics, DfDjPzLogStatistics.class, page);
if (Constants.IS_OPEN_REDIS) {
// 根据查询条件获取key
key = logStatService.getJedisKey(request, true);
// 判断key是否存在
keyExists = redisDao.exists(key);
}
// 存在则直接从redis中查询
if (keyExists) {
logPage = (Page<DfDjPzLogStatistics>) JsonMapper.fromJsonString(redisDao.getString(key), Page.class);
} else {
// 不存在则查询数据库并保存查询结果到redis中
logPage = logStatService.findDfPzLogStatistics(
new Page<DfDjPzLogStatistics>(request, response, DfDjPzLogStatistics.class), logStatistics);
if (Constants.IS_OPEN_REDIS)
new SaveRedisThread(key, logPage, Constants.ORACLE_EXPIRE).start();
}
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"封堵配置日志总量统计检索失败");
}
((RestServiceException) e).setActiveSys(searchStatActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "封堵配置日志总量统计检索成功",
logPage, searchStatActiveSys, logSource);
}
@RequestMapping(value="/djLogStatistics", method = RequestMethod.GET)
@ApiOperation(value="监测日志总量统计查询" , httpMethod = "GET", notes="get log list")
public Map djLogStatistics(
@RequestParam(value = "searchStatActiveSys", required = false, defaultValue = "2") String searchStatActiveSys,
@RequestParam(value = "searchService", required = true) String searchService,
DfDjLogStatistics logStatistics, HttpServletRequest request, HttpServletResponse response) {
if(!"4".equals(searchStatActiveSys) ) {
searchStatActiveSys="2";
logStatistics.setSearchStatActiveSys(searchStatActiveSys);
}
long start = System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
DfDjLogStatistics entity = null;
try{
logStatService.queryConditionCheck(thread,start,logStatistics, DfDjLogStatistics.class, null);
entity = logStatService.findDjLogStatistics(logStatistics);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"监测日志总量统计检索失败");
}
((RestServiceException) e).setActiveSys(searchStatActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测日志总量统计检索成功",
entity, searchStatActiveSys, logSource);
}
@RequestMapping(value="/djPzLogStatistics", method = RequestMethod.GET)
@ApiOperation(value="监测配置日志总量统计查询" , httpMethod = "GET", notes="get log list")
public Map djPzLogStatistics(
@RequestParam(value = "searchStatActiveSys", required = false, defaultValue = "2") String searchStatActiveSys,
@RequestParam(value = "searchService", required = true) String searchService,
Page<DfDjPzLogStatistics> page, DfDjPzLogStatistics logStatistics,
HttpServletRequest request, HttpServletResponse response) {
if(!"4".equals(searchStatActiveSys) ) {
searchStatActiveSys="2";
logStatistics.setSearchStatActiveSys(searchStatActiveSys);
}
long start = System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfDjPzLogStatistics> logPage = null;
boolean keyExists = false;
String key = "";
try {
logStatService.queryConditionCheck(thread,start,logStatistics, DfDjPzLogStatistics.class, page);
if (Constants.IS_OPEN_REDIS) {
// 根据查询条件获取key
key = logStatService.getJedisKey(request, true);
// 判断key是否存在
keyExists = redisDao.exists(key);
}
// 存在则直接从redis中查询
if (keyExists) {
logPage = (Page<DfDjPzLogStatistics>) JsonMapper.fromJsonString(redisDao.getString(key), Page.class);
} else {
// 不存在则查询数据库并保存查询结果到redis中
logPage = logStatService.findDjPzLogStatistics(
new Page<DfDjPzLogStatistics>(request, response, DfDjPzLogStatistics.class), logStatistics);
if (Constants.IS_OPEN_REDIS)
new SaveRedisThread(key, logPage, Constants.ORACLE_EXPIRE).start();
}
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"监测配置日志总量统计检索失败");
}
((RestServiceException) e).setActiveSys(searchStatActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测配置日志总量统计检索成功",
logPage, searchStatActiveSys, logSource);
}*/
}

View File

@@ -0,0 +1,230 @@
/**
*@Title: DfIpPortUdpController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author wx
*@date 2016年9月7日 下午3:58:16
*@version 版本号
*/
package com.nis.web.controller.restful;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.DfIpPortUdp;
import com.nis.domain.restful.DfIpPortUdpSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DfIpPortUdpService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: DfIpPortUdpController.java
* @Description: TODO
* @author (wx)
* @date 2016年9月7日 下午3:58:16
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/cfg/v1")
public class DfIpPortUdpController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@Autowired
protected DfIpPortUdpService dfIpPortUdpService;
// @Autowired
// protected CommonConfigService commonConfigService;
// @Autowired
// protected RedisDao redisDao;
/**
* saveDfIpPortUdpBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param DfIpPortUdpSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dfIpPortUdpSources", method = RequestMethod.POST)
@ApiOperation(value = "保存IP+端口Udp协议G设备封堵配置", httpMethod = "POST", notes = "save ip port udp")
public Map saveDfIpPortUdpBatch(@RequestBody DfIpPortUdpSource dfIpPortUdpSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, dfIpPortUdpSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dfIpPortUdpSource.getOpAction(), Constants.OPACTION_POST);
try{
this.chekckData(dfIpPortUdpSource,false);
dfIpPortUdpService.saveDfIpPortUdpBatch(dfIpPortUdpSource.getDfIpPortUdpList());
// commonConfigService.saveOrUpdateConfigState("DF_IP_PORT_UDP", dfIpPortUdpSource.getOpTime());
// redisDao.saveMaps(dfIpPortUdpSource.getDfIpPortUdpList(), "DF_IP_PORT_UDP", DfIpPortUdp.class, "cfgId");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存IP+端口Udp协议G设备封堵配置失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存IP+端口Udp协议G设备封堵配置成功",dfIpPortUdpSource.getDfIpPortUdpList());
}
/**
*
* updateDfIpPortUdpBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param DfIpPortUdpSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dfIpPortUdpSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新IP+端口Udp协议G设备封堵配置", httpMethod = "PUT", notes = "update ip port udp")
public Map updateDfIpPortUdpBatch(@RequestBody DfIpPortUdpSource dfIpPortUdpSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, dfIpPortUdpSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dfIpPortUdpSource.getOpAction(), Constants.OPACTION_PUT);
try{
this.chekckData(dfIpPortUdpSource,true);
dfIpPortUdpService.updateDfIpPortUdpBatch(dfIpPortUdpSource.getDfIpPortUdpList());
// commonConfigService.saveOrUpdateConfigState("DF_IP_PORT_UDP", dfIpPortUdpSource.getOpTime());
// redisDao.updateMaps(dfIpPortUdpSource.getDfIpPortUdpList(), "DF_IP_PORT_UDP", DfIpPortUdp.class, "cfgId");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新IP+端口Udp协议G设备封堵配置失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新IP+端口Udp协议G设备封堵配置成功",dfIpPortUdpSource.getDfIpPortUdpList());
}
/**
*
* deleteDfIpPortUdp(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dfIpPortUdpSources/{cfgId}", method = RequestMethod.DELETE)
@ApiOperation(value = "删除IP+端口Udp协议G设备封堵配置", httpMethod = "DELETE", notes = "delete ip port udp")
public Map deleteDfIpPortUdp(@PathVariable("cfgId") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
dfIpPortUdpService.removeDfIpPortUdp(id);
// commonConfigService.saveOrUpdateConfigState("DF_IP_PORT_UDP", new Date());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除IP+端口Udp协议G设备封堵配置失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteDfIpPortUdp(多条删除)
* (这里描述这个方法适用条件 可选)
* @param DfIpPortUdpSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dfIpPortUdpSources", method = RequestMethod.DELETE)
@ApiOperation(value = "删除IP+端口Udp协议G设备封堵配置", httpMethod = "DELETE", notes = "delete ip port udp")
public Map deleteDfIpPortUdp(@RequestBody DfIpPortUdpSource dfIpPortUdpSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, dfIpPortUdpSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dfIpPortUdpSource.getOpAction(), Constants.OPACTION_DELETE);
try{
dfIpPortUdpService.removeDfIpPortUdpBatch(dfIpPortUdpSource.getDfIpPortUdpList());
// commonConfigService.saveOrUpdateConfigState("DF_IP_PORT_UDP", dfIpPortUdpSource.getOpTime());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除IP+端口Udp协议G设备封堵配置失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",dfIpPortUdpSource.getDfIpPortUdpList());
}
/**
*
* chekckData(操作验证时间)
* (这里描述这个方法适用条件 可选)
* @param entity
* @return
*boolean
* @exception
* @since 1.0.0
*/
private void chekckData(DfIpPortUdpSource entity,boolean update){
Date now=new Date();
for(DfIpPortUdp dfIpPortUdp :entity.getDfIpPortUdpList()){
dfIpPortUdp.setLastUpdate(now);
if(dfIpPortUdp.getOpTime()==null)
dfIpPortUdp.setOpTime(entity.getOpTime());
if(!update){//新增时判断非空值
if(dfIpPortUdp.getEffectiveRange()==null)dfIpPortUdp.setEffectiveRange("0");
if(dfIpPortUdp.getProtocol()==null)dfIpPortUdp.setProtocol(0);
if(dfIpPortUdp.getDirection()==null)dfIpPortUdp.setDirection(0);
}
}
}
}

View File

@@ -0,0 +1,753 @@
package com.nis.web.controller.restful;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
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.Constants;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DfJitLogSearchService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
*
* @ClassName: DfJitLogSearchController
* @Description: 管控日志实时统计查询服务
* @author (rkg)
* @date 2016年9月13日上午10:32:21
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/log/v1")
@SuppressWarnings({ "rawtypes" })
public class DfJitLogSearchController extends BaseRestController {
private final Logger logger1 = Logger.getLogger(this.getClass());
protected String logSource="0";
@Autowired
private DfJitLogSearchService dfJitLogSearchService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@RequestMapping(value = "/dfJitFlSrcReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控分类性质源IP实时统计", httpMethod = "GET", notes = "管控分类性质源IP实时统计列表")
public Map dfJitFlSrcReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DfJitFlSrcReport dfJitFlSrcReportSources, HttpServletRequest request,
HttpServletResponse response) {
if(!Constants.ACTIVESYS_A.equals(searchActiveSys) && !Constants.ACTIVESYS_C.equals(searchActiveSys)) searchActiveSys=Constants.ACTIVESYS_B;
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DfJitFlSrcReport> dfJitFlSrcReportSourcesPage = null;
try {
// 公共请求参数校验
dfJitLogSearchService.queryDfJitFlCheck(thread, start, dfJitFlSrcReportSources.getSearchFl(),
dfJitFlSrcReportSources.getSearchXz());
dfJitLogSearchService.queryConditionCheck(thread, start, dfJitFlSrcReportSources, DfJitFlSrcReport.class,
page);
dfJitFlSrcReportSourcesPage = dfJitLogSearchService.findDfJitFlSrcReport(
new Page<DfJitFlSrcReport>(request, response, DfJitFlSrcReport.class), dfJitFlSrcReportSources);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控分类性质源IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控分类性质源IP实时统计检索成功",
dfJitFlSrcReportSourcesPage, searchActiveSys,logSource);
}
@RequestMapping(value = "/dfJitFlDestReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控分类性质目的IP实时统计服务", httpMethod = "GET", notes = "管控分类性质目的IP实时统计列表")
public Map dfJitFlDestReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DfJitFlDestReport dfJitFlDestReport, HttpServletRequest request, HttpServletResponse response) {
if(!Constants.ACTIVESYS_A.equals(searchActiveSys) && !Constants.ACTIVESYS_C.equals(searchActiveSys)) searchActiveSys=Constants.ACTIVESYS_B;
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DfJitFlDestReport> reporPage = null;
try {
// 公共请求参数校验
dfJitLogSearchService.queryDfJitFlCheck(thread, start, dfJitFlDestReport.getSearchFl(),
dfJitFlDestReport.getSearchXz());
dfJitLogSearchService.queryConditionCheck(thread, start, dfJitFlDestReport, DfJitFlDestReport.class, page);
reporPage = dfJitLogSearchService.findDfJitFlDestReport(
new Page<DfJitFlDestReport>(request, response, DfJitFlDestReport.class), dfJitFlDestReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控分类性质目的IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控分类性质目的IP实时统计检索成功",
reporPage, searchActiveSys,logSource);
}
@RequestMapping(value = "/dfJitAffairSrcReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控事件子话题源IP实时统计服务", httpMethod = "GET", notes = "管控事件子话题源IP实时统计列表")
public Map dfJitAffairSrcReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DfJitAffairSrcReport dfJitAffairSrcReport, HttpServletRequest request,
HttpServletResponse response) {
if(!Constants.ACTIVESYS_A.equals(searchActiveSys) && !Constants.ACTIVESYS_C.equals(searchActiveSys)) searchActiveSys=Constants.ACTIVESYS_B;
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
try {
if (!StringUtil.isBlank(dfJitAffairSrcReport.getSearchAffair())) {
Integer.parseInt(dfJitAffairSrcReport.getSearchAffair());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchAffair参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchAffair参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
try {
if (!StringUtil.isBlank(dfJitAffairSrcReport.getSearchTopic())) {
Integer.parseInt(dfJitAffairSrcReport.getSearchTopic());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchTopic参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchTopic参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
Page<DfJitAffairSrcReport> reporPage = null;
try {
dfJitLogSearchService.queryConditionCheck(thread, start, dfJitAffairSrcReport, DfJitAffairSrcReport.class,
page);
reporPage = dfJitLogSearchService.findDfJitAffairSrcReport(
new Page<DfJitAffairSrcReport>(request, response, DfJitAffairSrcReport.class),
dfJitAffairSrcReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控事件子话题源IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控事件子话题源IP实时统计检索成功",
reporPage, searchActiveSys,logSource);
}
@RequestMapping(value = "/dfJitAffairDestReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控事件子话题目的IP实时统计服务", httpMethod = "GET", notes = "管控事件子话题目的IP实时统计列表")
public Map dfJitAffairDestReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DfJitAffairDestReport dfJitAffairDestReport, HttpServletRequest request,
HttpServletResponse response) {
if(!Constants.ACTIVESYS_A.equals(searchActiveSys) && !Constants.ACTIVESYS_C.equals(searchActiveSys)) searchActiveSys=Constants.ACTIVESYS_B;
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
try {
if (!StringUtil.isBlank(dfJitAffairDestReport.getSearchAffair())) {
Integer.parseInt(dfJitAffairDestReport.getSearchAffair());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchAffair参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchAffair参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
try {
if (!StringUtil.isBlank(dfJitAffairDestReport.getSearchTopic())) {
Integer.parseInt(dfJitAffairDestReport.getSearchTopic());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchTopic参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchTopic参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
Page<DfJitAffairDestReport> reporPage = null;
try {
dfJitLogSearchService.queryConditionCheck(thread, start, dfJitAffairDestReport, DfJitAffairDestReport.class,
page);
reporPage = dfJitLogSearchService.findDfJitAffairDestReport(
new Page<DfJitAffairDestReport>(request, response, DfJitAffairDestReport.class),
dfJitAffairDestReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控事件子话题目的IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控事件子话题目的IP实时统计检索成功",
reporPage, searchActiveSys,logSource);
}
@RequestMapping(value = "/dfJitMissionSrcReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控任务源IP实时统计服务", httpMethod = "GET", notes = "管控任务源IP实时统计列表")
public Map dfJitMissionSrcReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DfJitMissionSrcReport dfJitMissionSrcReport, HttpServletRequest request,
HttpServletResponse response) {
if(!Constants.ACTIVESYS_A.equals(searchActiveSys) && !Constants.ACTIVESYS_C.equals(searchActiveSys)) searchActiveSys=Constants.ACTIVESYS_B;
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
try {
if (!StringUtil.isBlank(dfJitMissionSrcReport.getSearchMission())) {
Integer.parseInt(dfJitMissionSrcReport.getSearchMission());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchMission参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchMission参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
Page<DfJitMissionSrcReport> reporPage = null;
try {
dfJitLogSearchService.queryConditionCheck(thread, start, dfJitMissionSrcReport, DfJitMissionSrcReport.class,
page);
reporPage = dfJitLogSearchService.findDfJitMissionSrcReport(
new Page<DfJitMissionSrcReport>(request, response, DfJitMissionSrcReport.class),
dfJitMissionSrcReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控任务源IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控任务源IP实时统计检索成功",
reporPage, searchActiveSys,logSource);
}
@RequestMapping(value = "/dfJitMissionDestReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控任务目的IP实时统计服务", httpMethod = "GET", notes = "管控任务目的IP实时统计列表")
public Map dfJitMissionDestReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DfJitMissionDestReport dfJitMissionDestReport, HttpServletRequest request,
HttpServletResponse response) {
if(!Constants.ACTIVESYS_A.equals(searchActiveSys) && !Constants.ACTIVESYS_C.equals(searchActiveSys)) searchActiveSys=Constants.ACTIVESYS_B;
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
try {
if (!StringUtil.isBlank(dfJitMissionDestReport.getSearchMission())) {
Integer.parseInt(dfJitMissionDestReport.getSearchMission());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchMission参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchMission参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
Page<DfJitMissionDestReport> reporPage = null;
try {
dfJitLogSearchService.queryConditionCheck(thread, start, dfJitMissionDestReport,
DfJitMissionDestReport.class, page);
reporPage = dfJitLogSearchService.findDfJitMissionDestReport(
new Page<DfJitMissionDestReport>(request, response, DfJitMissionDestReport.class),
dfJitMissionDestReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控任务目的IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控任务目的IP实时统计检索成功",
reporPage, searchActiveSys,logSource);
}
@RequestMapping(value = "/dfJitGuaranteeSrcReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控保障期源IP实时统计服务", httpMethod = "GET", notes = "管控保障期源IP实时统计列表")
public Map dfJitGuaranteeSrcReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DfJitGuaranteeSrcReport dfJitGuaranteeSrcReport, HttpServletRequest request,
HttpServletResponse response) {
if(!Constants.ACTIVESYS_A.equals(searchActiveSys) && !Constants.ACTIVESYS_C.equals(searchActiveSys)) searchActiveSys=Constants.ACTIVESYS_B;
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
try {
if (!StringUtil.isBlank(dfJitGuaranteeSrcReport.getSearchGuarantee())) {
Integer.parseInt(dfJitGuaranteeSrcReport.getSearchGuarantee());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchGuarantee参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchGuarantee参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
Page<DfJitGuaranteeSrcReport> reporPage = null;
try {
dfJitLogSearchService.queryConditionCheck(thread, start, dfJitGuaranteeSrcReport,
DfJitGuaranteeSrcReport.class, page);
reporPage = dfJitLogSearchService.findDfJitGuaranteeSrcReport(
new Page<DfJitGuaranteeSrcReport>(request, response, DfJitGuaranteeSrcReport.class),
dfJitGuaranteeSrcReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控保障期源IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控保障期源IP实时统计检索成功",
reporPage, searchActiveSys,logSource);
}
@RequestMapping(value = "/dfJitGuaranteeDestReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控保障期目的IP实时统计服务", httpMethod = "GET", notes = "管控保障期目的IP实时统计列表")
public Map dfJitGuaranteeDestReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DfJitGuaranteeDestReport dfJitGuaranteeDestReport, HttpServletRequest request,
HttpServletResponse response) {
if(!Constants.ACTIVESYS_A.equals(searchActiveSys) && !Constants.ACTIVESYS_C.equals(searchActiveSys)) searchActiveSys=Constants.ACTIVESYS_B;
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
try {
if (!StringUtil.isBlank(dfJitGuaranteeDestReport.getSearchGuarantee())) {
Integer.parseInt(dfJitGuaranteeDestReport.getSearchGuarantee());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchGuarantee参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchGuarantee参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
Page<DfJitGuaranteeDestReport> reporPage = null;
try {
dfJitLogSearchService.queryConditionCheck(thread, start, dfJitGuaranteeDestReport,
DfJitGuaranteeDestReport.class, page);
reporPage = dfJitLogSearchService.findDfJitGuaranteeDestReport(
new Page<DfJitGuaranteeDestReport>(request, response, DfJitGuaranteeDestReport.class),
dfJitGuaranteeDestReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控保障期目的IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控保障期目的IP实时统计检索成功",
reporPage, searchActiveSys,logSource);
}
@RequestMapping(value = "/dfJitTagSrcReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控标签源IP实时统计服务", httpMethod = "GET", notes = "管控标签源IP实时统计列表")
public Map dfJitTagSrcReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DfJitTagSrcReport dfJitTagSrcReport, HttpServletRequest request, HttpServletResponse response) {
if(!Constants.ACTIVESYS_A.equals(searchActiveSys) && !Constants.ACTIVESYS_C.equals(searchActiveSys)) searchActiveSys=Constants.ACTIVESYS_B;
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
if (null != dfJitTagSrcReport.getSearchTag() && !dfJitTagSrcReport.getSearchTag().equals("")) {
String[] tagArr = dfJitTagSrcReport.getSearchTag().split(",");
List<String> tagList = new ArrayList<String>();
for (int i = 0; i < tagArr.length; i++) {
if (!tagArr[i].equals("")) {
try {
Integer.parseInt(tagArr[i]);
tagList.add(tagArr[i]);
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread,
System.currentTimeMillis() - start, "searchTag参数格式错误",
RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchTag参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
}
}
StringBuffer sb = new StringBuffer();
for (String str : tagList) {
sb.append(str + ",");
}
String tag = sb.substring(0, sb.length() - 1);
dfJitTagSrcReport.setSearchTag(tag);
}
Page<DfJitTagSrcReport> reporPage = null;
try {
dfJitLogSearchService.queryConditionCheck(thread, start, dfJitTagSrcReport, DfJitTagSrcReport.class, page);
reporPage = dfJitLogSearchService.findDfJitTagSrcReport(
new Page<DfJitTagSrcReport>(request, response, DfJitTagSrcReport.class), dfJitTagSrcReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控标签源IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控标签源IP实时统计检索成功",
reporPage, searchActiveSys,logSource);
}
@RequestMapping(value = "/dfJitTagDestReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控标签目的IP实时统计服务", httpMethod = "GET", notes = "管控标签目的IP实时统计列表")
public Map dfJitTagDestReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DfJitTagDestReport dfJitTagDestReport, HttpServletRequest request,
HttpServletResponse response) {
if(!Constants.ACTIVESYS_A.equals(searchActiveSys) && !Constants.ACTIVESYS_C.equals(searchActiveSys)) searchActiveSys=Constants.ACTIVESYS_B;
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
if (null != dfJitTagDestReport.getSearchTag() && !dfJitTagDestReport.getSearchTag().equals("")) {
String[] tagArr = dfJitTagDestReport.getSearchTag().split(",");
List<String> tagList = new ArrayList<String>();
for (int i = 0; i < tagArr.length; i++) {
if (!tagArr[i].equals("")) {
try {
Integer.parseInt(tagArr[i]);
tagList.add(tagArr[i]);
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread,
System.currentTimeMillis() - start, "searchTag参数格式错误",
RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchTag参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
}
}
StringBuffer sb = new StringBuffer();
for (String str : tagList) {
sb.append(str + ",");
}
String tag = sb.substring(0, sb.length() - 1);
dfJitTagDestReport.setSearchTag(tag);
}
Page<DfJitTagDestReport> reporPage = null;
try {
dfJitLogSearchService.queryConditionCheck(thread, start, dfJitTagDestReport, DfJitTagDestReport.class,
page);
reporPage = dfJitLogSearchService.findDfJitTagDestReport(
new Page<DfJitTagDestReport>(request, response, DfJitTagDestReport.class), dfJitTagDestReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控标签目的IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控标签目的IP实时统计检索成功",
reporPage, searchActiveSys,logSource);
}
@RequestMapping(value = "/dfJitIdSrcReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控规则源IP实时统计服务", httpMethod = "GET", notes = "管控规则源IP实时统计列表")
public Map dfJitIdSrcReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DfJitIdSrcReport dfJitIdSrcReport, HttpServletRequest request, HttpServletResponse response) {
if(!Constants.ACTIVESYS_A.equals(searchActiveSys) && !Constants.ACTIVESYS_C.equals(searchActiveSys)) searchActiveSys=Constants.ACTIVESYS_B;
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
try {
if (!StringUtil.isBlank(dfJitIdSrcReport.getSearchId())) {
Integer.parseInt(dfJitIdSrcReport.getSearchId());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchId参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchId参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
Page<DfJitIdSrcReport> reporPage = null;
try {
dfJitLogSearchService.queryConditionCheck(thread, start, dfJitIdSrcReport, DfJitIdSrcReport.class, page);
reporPage = dfJitLogSearchService.findDfJitIdSrcReport(
new Page<DfJitIdSrcReport>(request, response, DfJitIdSrcReport.class), dfJitIdSrcReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控规则源IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控规则源IP实时统计检索成功",
reporPage, searchActiveSys,logSource);
}
@RequestMapping(value = "/dfJitIdDestReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控规则目的IP实时统计服务", httpMethod = "GET", notes = "管控规则目的IP实时统计列表")
public Map dfJitIdDestReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DfJitIdDestReport dfJitIdDestReport, HttpServletRequest request, HttpServletResponse response) {
if(!Constants.ACTIVESYS_A.equals(searchActiveSys) && !Constants.ACTIVESYS_C.equals(searchActiveSys)) searchActiveSys=Constants.ACTIVESYS_B;
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
try {
if (!StringUtil.isBlank(dfJitIdDestReport.getSearchId())) {
Integer.parseInt(dfJitIdDestReport.getSearchId());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchId参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchId参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
Page<DfJitIdDestReport> reporPage = null;
try {
dfJitLogSearchService.queryConditionCheck(thread, start, dfJitIdDestReport, DfJitIdDestReport.class, page);
reporPage = dfJitLogSearchService.findDfJitIdDestReport(
new Page<DfJitIdDestReport>(request, response, DfJitIdDestReport.class), dfJitIdDestReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控规则目的IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控规则目的IP实时统计检索成功",
reporPage, searchActiveSys,logSource);
}
}

View File

@@ -0,0 +1,90 @@
/**
* @Title: DfKeyConvertUrlController.java
* @Package com.nis.web.controller.restful
* @Description: TODO(用一句话描述该文件做什么)
* @author (DDM)
* @date 2016年9月27日 上午10:17:20
* @version V1.0
*/
package com.nis.web.controller.restful;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.Page;
import com.nis.domain.restful.DfKeyConvertUrl;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DfKeyConvertUrlService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
*
* @ClassName: DfKeyConvertUrlController
* @Description: TODO(这里用一句话描述这个类的作用)
* @author (DDM)
* @date 2016年9月27日 上午10:17:20
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/log/v1")
@SuppressWarnings({ "rawtypes" })
public class DfKeyConvertUrlController extends BaseRestController{
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected DfKeyConvertUrlService dfKeyConvertUrlService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
protected String logSource = "0";
@RequestMapping(value="/dfKeyConvertUrlSources", method = RequestMethod.GET)
@ApiOperation(value="关键字业务转换URL日志信息获取" , httpMethod = "GET", notes="get log list")
public Map dfKeyConvertUrlSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DfKeyConvertUrl dfKeyConvertUrl, HttpServletRequest request,
HttpServletResponse response, Model model) {
if(!Constants.ACTIVESYS_A.equals(searchActiveSys)
&& !Constants.ACTIVESYS_C.equals(searchActiveSys)
) searchActiveSys=Constants.ACTIVESYS_B;
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
//请求参数校验
dfKeyConvertUrlService.queryConditionCheck(thread,start,dfKeyConvertUrl,page);
Page<DfKeyConvertUrl> dfKeyConvertUrlPage = null;
try {
dfKeyConvertUrlPage = dfKeyConvertUrlService.findFlowControlStopPage(new Page<DfKeyConvertUrl>(request, response,DfKeyConvertUrl.class), dfKeyConvertUrl);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "关键字业务转换URL日志信息检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "关键字业务转换URL日志信息检索成功",dfKeyConvertUrlPage
,searchActiveSys, logSource);
}
}

View File

@@ -0,0 +1,91 @@
/**
* @Title: dfKeyMailAddController.java
* @Package com.nis.web.controller.restful
* @Description: 关键字业务转换邮件地址日志服务
* @author (ZBC)
* @date 2016年11月09日 下午02:25:00
* @version V1.0
*/
package com.nis.web.controller.restful;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.Page;
import com.nis.domain.restful.DfKeyMailAdd;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DfKeyMailAddService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
*
* @ClassName: dfKeyMailAddController
* @Description: 关键字业务转换邮件地址日志服务
* @author (ZBC)
* @date 2016年11月09日 下午02:25:00
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/log/v1")
@SuppressWarnings({ "rawtypes" })
public class DfKeyMailAddController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@Autowired
protected DfKeyMailAddService dfKeyMailAddService;
protected String logSource = "0";
@RequestMapping(value = "/dfKeyMailAddSources", method = RequestMethod.GET)
@ApiOperation(value = "关键字业务转换邮件地址日志信息获取", httpMethod = "GET", notes = "get log list")
public Map dfKeyConvertUrlSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DfKeyMailAdd dfKeyMailAdd, HttpServletRequest request,
HttpServletResponse response, Model model) {
if(!Constants.ACTIVESYS_A.equals(searchActiveSys)
&& !Constants.ACTIVESYS_C.equals(searchActiveSys)
) searchActiveSys=Constants.ACTIVESYS_B;
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null);
// 请求参数校验
dfKeyMailAddService.queryConditionCheck(thread, start, dfKeyMailAdd, page);
Page<DfKeyMailAdd> dfKeyMailAddPage = null;
try {
dfKeyMailAddPage = dfKeyMailAddService.findDfKeyMailAddPage(
new Page<DfKeyMailAdd>(request, response, DfKeyMailAdd.class), dfKeyMailAdd);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "关键字业务转换邮件地址日志信息检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "关键字业务转换邮件地址日志信息检索成功",
dfKeyMailAddPage,searchActiveSys, logSource);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,215 @@
package com.nis.web.controller.restful;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.DfReportEntity;
import com.nis.domain.LogEntity;
import com.nis.domain.Page;
import com.nis.domain.restful.DfLwhhAttrReport;
import com.nis.domain.restful.DfLwhhTagReport;
import com.nis.domain.restful.DfSrcIpAttrReport;
import com.nis.domain.restful.DfSrcIpTagReport;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.DateUtils;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DfMultiDimensionalReportService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
*
* @ClassName: DfMultiDimensionalReportController
* @Description: TODO(df多维实时统计)
* @author (DDM)
* @date 2017年8月4日下午2:53:01
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/log/v1")
@SuppressWarnings({ "rawtypes" })
public class DfMultiDimensionalReportController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
protected String activeSys = Constants.ACTIVESYS_ALL;
protected String logSource = "0";
@Autowired
protected DfMultiDimensionalReportService dfMultiDimensionalReportService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@RequestMapping(value = "dfLwhhAttrReportSources", method = RequestMethod.GET)
@ApiOperation(value = "来文函号、性质多维实时统计", httpMethod = "GET", notes = "get log list")
public Map dfServiceReportSources(Page page, DfLwhhAttrReport dfLwhhAttrReport, Model model,
HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DfLwhhAttrReport> lwhhAttrReportPage = null;
try {
//设置本地默认查询时间
resetTime(dfLwhhAttrReport);
// 校验
dfMultiDimensionalReportService.queryConditionCheck(thread, start, dfLwhhAttrReport, DfLwhhAttrReport.class,
page);
// 查询数据库
lwhhAttrReportPage = dfMultiDimensionalReportService.findDfLwhhAttrReportPage(
new Page<DfLwhhAttrReport>(request, response, DfLwhhAttrReport.class), dfLwhhAttrReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "来文函号、性质多维实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "来文函号、性质多维实时统计成功",
lwhhAttrReportPage, activeSys, logSource);
}
@RequestMapping(value = "dfLwhhTagReportSources", method = RequestMethod.GET)
@ApiOperation(value = "来文函号、标签多维实时统计", httpMethod = "GET", notes = "get log list")
public Map dfServiceReportSources(Page page, DfLwhhTagReport dfLwhhTagReport, Model model,
HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DfLwhhTagReport> lwhhTagReportPage = null;
try {
//设置本地默认查询时间
resetTime(dfLwhhTagReport);
// 校验
dfMultiDimensionalReportService.queryConditionCheck(thread, start, dfLwhhTagReport, DfLwhhTagReport.class,
page);
// 查询数据库
lwhhTagReportPage = dfMultiDimensionalReportService.findDfLwhhTagReportPage(
new Page<DfLwhhTagReport>(request, response, DfLwhhTagReport.class), dfLwhhTagReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "来文函号、标签多维实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "来文函号、标签多维实时统计成功",
lwhhTagReportPage, activeSys, logSource);
}
@RequestMapping(value = "dfSrcIpAttrReportSources", method = RequestMethod.GET)
@ApiOperation(value = "来文函号、性质多维实时统计", httpMethod = "GET", notes = "get log list")
public Map dfServiceReportSources(Page page, DfSrcIpAttrReport dfSrcIpAttrReport, Model model,
HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DfSrcIpAttrReport> srcIpAttrReportPage = null;
try {
//设置本地默认查询时间
resetTime(dfSrcIpAttrReport);
// 校验
dfMultiDimensionalReportService.queryConditionCheck(thread, start, dfSrcIpAttrReport, DfSrcIpAttrReport.class,
page);
// 查询数据库
srcIpAttrReportPage = dfMultiDimensionalReportService.findDfSrcIpAttrReportPage(
new Page<DfSrcIpAttrReport>(request, response, DfSrcIpAttrReport.class), dfSrcIpAttrReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "境内源ip、性质多维实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "境内源ip、性质多维实时统计成功",
srcIpAttrReportPage, activeSys, logSource);
}
@RequestMapping(value = "dfSrcIpTagReportSources", method = RequestMethod.GET)
@ApiOperation(value = "来文函号、标签多维实时统计", httpMethod = "GET", notes = "get log list")
public Map dfServiceReportSources(Page page, DfSrcIpTagReport dfSrcIpTagReport, Model model,
HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DfSrcIpTagReport> srcIpTagReportPage = null;
try {
//设置本地默认查询时间
resetTime(dfSrcIpTagReport);
// 校验
dfMultiDimensionalReportService.queryConditionCheck(thread, start, dfSrcIpTagReport, DfSrcIpTagReport.class,
page);
// 查询数据库
srcIpTagReportPage = dfMultiDimensionalReportService.findDfSrcIpTagReportPage(
new Page<DfSrcIpTagReport>(request, response, DfSrcIpTagReport.class), dfSrcIpTagReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "境内源ip、标签多维实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "境内源ip、标签多维实时统计成功",
srcIpTagReportPage, activeSys, logSource);
}
/**
*
* @Title: resetTime
* @Description: (实时统计默认查询本地一个小时的数据)
* @param @param entity
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
public void resetTime(DfReportEntity<?> entity) throws Exception {
Map<String, String> map = DateUtils.getLocalTime(entity.getSearchReportStartTime(),
entity.getSearchReportEndTime(), Constants.REPORT_LOCAL_TIME,"report");
entity.setSearchReportStartTime(map.get("startTime"));
entity.setSearchReportEndTime(map.get("endTime"));
}
}

View File

@@ -0,0 +1,333 @@
/**
* @Title: DfStatLogController.java
* @Package com.nis.web.controller
* @Description: TODO(用一句话描述该文件做什么)
* @author ddm
* @date 2016年9月13日 下午1:22:15
* @version V1.0
*/
package com.nis.web.controller.restful;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.Page;
import com.nis.domain.StatLogEntity;
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.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.DateUtils;
import com.nis.util.redis.RedisDao;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DfMultiDimensionalStatLogService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: DfStatLogController
* @Description: TODO(这里用一句话描述这个类的作用)
* @author (ddm)
* @date 2016年9月13日 下午1:22:15
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/log/v1")
@SuppressWarnings({ "rawtypes", "unchecked" })
public class DfMultiDimensionalStatLogController extends BaseRestController{
protected final Logger logger = Logger.getLogger(this.getClass());
protected String logSource="0";
protected String activeSys=Constants.ACTIVESYS_ALL;
@Autowired
protected DfMultiDimensionalStatLogService dfMultiDimensionalStatLogService;
@Autowired
protected RedisDao redisDao;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@RequestMapping(value="dfLwhhAttrDailySources", method = RequestMethod.GET)
@ApiOperation(value="封堵来文函号-性质多维日报表" , httpMethod = "GET", notes="get log list")
public Map dfLwhhAttrDailySources(
Page page,DfLwhhAttrDaily dfLwhhAttrDaily, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfLwhhAttrDaily> dfLwhhAttrDailyPage =null;
try {
resetTime(dfLwhhAttrDaily, "daily");
dfMultiDimensionalStatLogService.queryConditionCheck(thread,start,dfLwhhAttrDaily, DfLwhhAttrDaily.class, page);
dfLwhhAttrDailyPage = dfMultiDimensionalStatLogService.dfLwhhAttrDaily(new Page<DfLwhhAttrDaily>(request, response,DfLwhhAttrDaily.class), dfLwhhAttrDaily);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"封堵来文函号-性质多维日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "封堵来文函号-标签多维日报表检索成功",dfLwhhAttrDailyPage,activeSys,logSource);
}
@RequestMapping(value="dfLwhhAttrMonthSources", method = RequestMethod.GET)
@ApiOperation(value="封堵来文函号-性质多维月报表" , httpMethod = "GET", notes="get log list")
public Map dfLwhhAttrMonthSources(
Page page,DfLwhhAttrMonth dfLwhhAttrMonth, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfLwhhAttrMonth> dfLwhhAttrMonthPage =null;
try {
resetTime(dfLwhhAttrMonth, "month");
//查询条件校验
dfMultiDimensionalStatLogService.queryConditionCheck(thread,start,dfLwhhAttrMonth, DfLwhhAttrMonth.class, page);
dfLwhhAttrMonthPage = dfMultiDimensionalStatLogService.dfLwhhAttrMonth(new Page<DfLwhhAttrMonth>(request, response,DfLwhhAttrMonth.class), dfLwhhAttrMonth);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"封堵来文函号-性质多维月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "封堵来文函号-性质多维月报表检索成功",dfLwhhAttrMonthPage,activeSys,logSource);
}
@RequestMapping(value="dfLwhhTagDailySources", method = RequestMethod.GET)
@ApiOperation(value="封堵来文函号-标签多维日报表" , httpMethod = "GET", notes="get log list")
public Map dfLwhhTagDailySources(
Page page,DfLwhhTagDaily dfLwhhTagDaily, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfLwhhTagDaily> dfLwhhTagDailyPage =null;
try {
resetTime(dfLwhhTagDaily, "daily");
dfMultiDimensionalStatLogService.queryConditionCheck(thread,start,dfLwhhTagDaily, DfLwhhTagDaily.class, page);
dfLwhhTagDailyPage = dfMultiDimensionalStatLogService.dfLwhhTagDaily(new Page<DfLwhhTagDaily>(request, response,DfLwhhTagDaily.class), dfLwhhTagDaily);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"封堵来文函号-标签多维日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "封堵来文函号-标签多维日报表检索成功",dfLwhhTagDailyPage,activeSys,logSource);
}
@RequestMapping(value="dfLwhhTagMonthSources", method = RequestMethod.GET)
@ApiOperation(value="封堵来文函号-标签多维月报表" , httpMethod = "GET", notes="get log list")
public Map dfLwhhTagMonthSources(
Page page,DfLwhhTagMonth dfLwhhTagMonth, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfLwhhTagMonth> dfLwhhTagMonthPage =null;
try {
resetTime(dfLwhhTagMonth, "month");
//查询条件校验
dfMultiDimensionalStatLogService.queryConditionCheck(thread,start,dfLwhhTagMonth, DfLwhhTagMonth.class, page);
dfLwhhTagMonthPage = dfMultiDimensionalStatLogService.dfLwhhTagMonth(new Page<DfLwhhTagMonth>(request, response,DfLwhhTagMonth.class), dfLwhhTagMonth);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"封堵来文函号-标签多维月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "封堵来文函号-标签多维月报表检索成功",dfLwhhTagMonthPage,activeSys,logSource);
}
@RequestMapping(value="dfSrcIpAttrDailySources", method = RequestMethod.GET)
@ApiOperation(value="封堵省-性质多维日报表" , httpMethod = "GET", notes="get log list")
public Map dfSrcIpAttrDailySources(
Page page,DfSrcIpAttrDaily dfSrcIpAttrDaily, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfSrcIpAttrDaily> dfSrcIpAttrDailyPage =null;
try {
resetTime(dfSrcIpAttrDaily, "daily");
dfMultiDimensionalStatLogService.queryConditionCheck(thread,start,dfSrcIpAttrDaily, DfSrcIpAttrDaily.class, page);
dfSrcIpAttrDailyPage = dfMultiDimensionalStatLogService.dfSrcIpAttrDaily(new Page<DfSrcIpAttrDaily>(request, response,DfSrcIpAttrDaily.class), dfSrcIpAttrDaily);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"封堵省-性质多维日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "封堵省-标签多维日报表检索成功",dfSrcIpAttrDailyPage,activeSys,logSource);
}
@RequestMapping(value="dfSrcIpAttrMonthSources", method = RequestMethod.GET)
@ApiOperation(value="封堵省-性质多维月报表" , httpMethod = "GET", notes="get log list")
public Map dfSrcIpAttrMonthSources(
Page page,DfSrcIpAttrMonth dfSrcIpAttrMonth, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfSrcIpAttrMonth> dfSrcIpAttrMonthPage =null;
try {
resetTime(dfSrcIpAttrMonth, "month");
//查询条件校验
dfMultiDimensionalStatLogService.queryConditionCheck(thread,start,dfSrcIpAttrMonth, DfSrcIpAttrMonth.class, page);
dfSrcIpAttrMonthPage = dfMultiDimensionalStatLogService.dfSrcIpAttrMonth(new Page<DfSrcIpAttrMonth>(request, response,DfSrcIpAttrMonth.class), dfSrcIpAttrMonth);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"封堵省-性质多维月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "封堵省-性质多维月报表检索成功",dfSrcIpAttrMonthPage,activeSys,logSource);
}
@RequestMapping(value="dfSrcIpTagDailySources", method = RequestMethod.GET)
@ApiOperation(value="封堵省-标签多维日报表" , httpMethod = "GET", notes="get log list")
public Map dfSrcIpTagDailySources(
Page page,DfSrcIpTagDaily dfSrcIpTagDaily, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfSrcIpTagDaily> dfSrcIpTagDailyPage =null;
try {
resetTime(dfSrcIpTagDaily, "daily");
dfMultiDimensionalStatLogService.queryConditionCheck(thread,start,dfSrcIpTagDaily, DfSrcIpTagDaily.class, page);
dfSrcIpTagDailyPage = dfMultiDimensionalStatLogService.dfSrcIpTagDaily(new Page<DfSrcIpTagDaily>(request, response,DfSrcIpTagDaily.class), dfSrcIpTagDaily);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"封堵省-标签多维日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "封堵省-标签多维日报表检索成功",dfSrcIpTagDailyPage,activeSys,logSource);
}
@RequestMapping(value="dfSrcIpTagMonthSources", method = RequestMethod.GET)
@ApiOperation(value="封堵省-标签多维月报表" , httpMethod = "GET", notes="get log list")
public Map dfSrcIpTagMonthSources(
Page page,DfSrcIpTagMonth dfSrcIpTagMonth, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfSrcIpTagMonth> dfSrcIpTagMonthPage =null;
try {
resetTime(dfSrcIpTagMonth, "month");
//查询条件校验
dfMultiDimensionalStatLogService.queryConditionCheck(thread,start,dfSrcIpTagMonth, DfSrcIpTagMonth.class, page);
dfSrcIpTagMonthPage = dfMultiDimensionalStatLogService.dfSrcIpTagMonth(new Page<DfSrcIpTagMonth>(request, response,DfSrcIpTagMonth.class), dfSrcIpTagMonth);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"封堵省-标签多维月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "封堵省-标签多维月报表检索成功",dfSrcIpTagMonthPage,activeSys,logSource);
}
/**
*
* @Title: resetTime
* @Description: (日报表默认查询本地前一天的数据)
* @param @param entity
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
public void resetTime(StatLogEntity<?> entity,String type) throws Exception{
Map<String, String> map = DateUtils.getLocalTime(entity.getSearchStatStartTime(),
entity.getSearchStatEndTime(), Constants.REPORT_LOCAL_TIME,type);
entity.setSearchStatStartTime(map.get("startTime"));
entity.setSearchStatEndTime(map.get("endTime"));
}
}

View File

@@ -0,0 +1,636 @@
package com.nis.web.controller.restful;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.DfReportEntity;
import com.nis.domain.LogEntity;
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.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.DateUtils;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DfReportService;
import com.wordnik.swagger.annotations.ApiOperation;
import net.sf.json.JSONObject;
/**
* @ClassName: DfReportController
* @Description: TODO(一句话描述这个类)
* @author (DDM)
* @date 2016年10月31日上午11:56:50
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/log/v1")
@SuppressWarnings({ "rawtypes" })
public class DfReportController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
protected String activeSys = Constants.ACTIVESYS_ALL;
protected String logSource = "0";
@Autowired
protected DfReportService dfReportService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@RequestMapping(value = "dfPzReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控配置实时统计服务", httpMethod = "GET", notes = "get log list")
public Map dfPzReportSources(Page page, DfPzReport dfPzReport, Model model, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DfPzReport> pzReportPage = null;
try {
//设置本地默认查询时间
resetTime(dfPzReport);
dfReportService.queryConditionCheck(thread, start, dfPzReport, DfPzReport.class, page);
// 查询数据库
pzReportPage = dfReportService.findDfPzReportPage(new Page<DfPzReport>(request, response, DfPzReport.class),
dfPzReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控配置实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控配置实时统计成功",
pzReportPage, activeSys, logSource);
}
/**
* 配置统计[小时]
*
* @param page
* @param dfPzReport
* @param model
* @param request
* @param response
* @return
*/
@RequestMapping(value = "dfPzStatSources", method = RequestMethod.GET)
@ApiOperation(value = "管控各配置量统计服务[小时]", httpMethod = "GET", notes = "get log list")
public Map dfPzStatSources(Page page, DfPzReportStat dfPzReportStat, Model model, HttpServletRequest request,
HttpServletResponse response) {
if (!Constants.ACTIVESYS_A.equals(dfPzReportStat.getSearchStatActiveSys())
&& !Constants.ACTIVESYS_C.equals(dfPzReportStat.getSearchStatActiveSys())
&& !Constants.ACTIVESYS_AB.equals(dfPzReportStat.getSearchStatActiveSys())
) {
dfPzReportStat.setSearchStatActiveSys(Constants.ACTIVESYS_B);
}
activeSys = dfPzReportStat.getSearchStatActiveSys();
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DfPzReportStat> pzReportPage = null;
try {
//设置本地默认查询时间
resetTime(dfPzReportStat);
dfReportService.queryConditionCheck(thread, start, dfPzReportStat, DfPzReportStat.class, page);
// 查询数据库
pzReportPage = dfReportService.findDfPzReportStatPage(
new Page<DfPzReportStat>(request, response, DfPzReportStat.class), dfPzReportStat);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控各配置量统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控各配置量统计成功",
pzReportPage, activeSys, logSource);
}
/**
* 配置统计[分钟]
*
* @param page
* @param dfPzReport
* @param model
* @param request
* @param response
* @return
*/
@RequestMapping(value = "dfPzStatMinutesSources", method = RequestMethod.GET)
@ApiOperation(value = "管控各配置量统计服务[分钟]", httpMethod = "GET", notes = "get log list")
public Map dfPzStatMinutesSources(Page page, DfPzReportStat dfPzReportStat, Model model, HttpServletRequest request,
HttpServletResponse response) {
if (!Constants.ACTIVESYS_A.equals(dfPzReportStat.getSearchStatActiveSys())
&& !Constants.ACTIVESYS_C.equals(dfPzReportStat.getSearchStatActiveSys())
&& !Constants.ACTIVESYS_AB.equals(dfPzReportStat.getSearchStatActiveSys())
) {
dfPzReportStat.setSearchStatActiveSys(Constants.ACTIVESYS_B);
}
activeSys = dfPzReportStat.getSearchStatActiveSys();
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DfPzReportStat> pzReportPage = null;
try {
//设置本地默认查询时间
resetTime(dfPzReportStat);
dfReportService.queryConditionCheck(thread, start, dfPzReportStat, DfPzReportStat.class, page);
// 查询数据库
pzReportPage = dfReportService.findDfPzReportStatMinutesPage(
new Page<DfPzReportStat>(request, response, DfPzReportStat.class), dfPzReportStat);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控各配置量统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控各配置量统计成功",
pzReportPage, activeSys, logSource);
}
/**
* 配置统计
*
* @param page
* @param dfPzReport
* @param model
* @param request
* @param response
* @return
*/
@RequestMapping(value = "dfPzSumStatSources", method = RequestMethod.GET)
@ApiOperation(value = "管控配置总量统计服务", httpMethod = "GET", notes = "get log list")
public Map dfPzSumStatSources(Page page, DfPzReportStat dfPzReportStat, Model model, HttpServletRequest request,
HttpServletResponse response) {
if (!Constants.ACTIVESYS_A.equals(dfPzReportStat.getSearchStatActiveSys())
&& !Constants.ACTIVESYS_C.equals(dfPzReportStat.getSearchStatActiveSys())
) {
dfPzReportStat.setSearchStatActiveSys(Constants.ACTIVESYS_B);
}
activeSys = dfPzReportStat.getSearchStatActiveSys();
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
JSONObject json = new JSONObject();
try {
//设置本地默认查询时间
resetTime(dfPzReportStat);
dfReportService.queryConditionCheck(thread, start, dfPzReportStat, DfPzReportStat.class,page);
// 查询数据库
Long sum = dfReportService.findDfPzReportSumStat(
new Page<DfPzReportStat>(request, response, DfPzReportStat.class), dfPzReportStat);
if (sum == null)
sum = 0l;
json.put("sum", sum);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控配置总量统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控配置总量统计成功", json,
activeSys, logSource);
}
@RequestMapping(value = "dfServiceReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控业务类型实时统计", httpMethod = "GET", notes = "get log list")
public Map dfServiceReportSources(Page page, DfServiceReport dfServiceReport, Model model,
HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DfServiceReport> serviceReportPage = null;
try {
//设置本地默认查询时间
resetTime(dfServiceReport);
// 校验
dfReportService.queryConditionCheck(thread, start, dfServiceReport, DfServiceReport.class,
page);
// 查询数据库
serviceReportPage = dfReportService.findDfServiceReportPage(
new Page<DfServiceReport>(request, response, DfServiceReport.class), dfServiceReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控业务类型实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控业务类型实时统计成功",
serviceReportPage, activeSys, logSource);
}
@RequestMapping(value = "dfTagReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控标签实时统计", httpMethod = "GET", notes = "get log list")
public Map dfTagReportSources(Page page, DfTagReport dfTagReport, Model model, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DfTagReport> tagReportPage = null;
try {
//设置本地默认查询时间
resetTime(dfTagReport);
// 校验
dfReportService.queryConditionCheck(thread, start, dfTagReport, DfTagReport.class, page);
// 查询数据库
tagReportPage = dfReportService
.findDfTagReportPage(new Page<DfTagReport>(request, response, DfTagReport.class), dfTagReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控标签实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控标签实时统计成功",
tagReportPage, activeSys, logSource);
}
@RequestMapping(value = "/dfSrcIpDomesticReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控境内源IP实时统计服务", httpMethod = "GET", notes = "管控境内源IP实时统计列表")
public Map dfSrcIpDomesticReportSources(Page page, DfSrcIpReport dfSrcIpDomesticReport, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DfSrcIpReport> reporPage = null;
try {
//设置本地默认查询时间
resetTime(dfSrcIpDomesticReport);
dfReportService.queryConditionCheck(thread, start, dfSrcIpDomesticReport, DfSrcIpReport.class, page);
reporPage = dfReportService.findDfSrcIpReport(
new Page<DfSrcIpReport>(request, response, DfSrcIpReport.class), dfSrcIpDomesticReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控境内源IP实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控境内源IP实时统计检索成功",
reporPage, activeSys, logSource);
}
@RequestMapping(value = "/dfDestIpCountryReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控各国家目的IP实时统计服务", httpMethod = "GET", notes = "管控各国家目的IP实时统计列表")
public Map dfDestIpCountryReportSources(Page page, DfDestIpReport dfDestIpReport, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DfDestIpReport> reporPage = null;
try {
//设置本地默认查询时间
resetTime(dfDestIpReport);
dfReportService.queryConditionCheck(thread, start, dfDestIpReport, DfDestIpReport.class, page);
reporPage = dfReportService.findDfDestIpReport(
new Page<DfDestIpReport>(request, response, DfDestIpReport.class), dfDestIpReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控各国家目的IP实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控各国家目的IP实时统计检索成功",
reporPage, activeSys, logSource);
}
@RequestMapping(value = "dfPzPrivServiceSumSources", method = RequestMethod.GET)
@ApiOperation(value = "管控配置总量实时统计", httpMethod = "GET", notes = "get log list")
public Map dfPzPrivServiceSumSources(Page page, DfPzReport dfPzReport, Model model, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DfPzReport> pzReportPage = null;
try {
//设置本地默认查询时间
resetTime(dfPzReport);
dfReportService.queryConditionCheck(thread, start, dfPzReport, DfPzReport.class, page);
// 查询数据库
pzReportPage = dfReportService.findDfPriTagReport(new Page<DfPzReport>(request, response, DfPzReport.class),
dfPzReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控配置总量实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控配置总量实时统计成功",
pzReportPage, activeSys, logSource);
}
@RequestMapping(value = "dfAttrTypeReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控性质(带私有标签)实时统计", httpMethod = "GET", notes = "get log list")
public Map dfAttrTypeReportSources(Page page, DfAttrTypeReport dfAttrTypeReport, Model model,
HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DfAttrTypeReport> attrTypeReportPage = null;
try {
//设置本地默认查询时间
resetTime(dfAttrTypeReport);
dfReportService.queryConditionCheck(thread, start, dfAttrTypeReport, DfPzReport.class, page);
// 查询数据库
attrTypeReportPage = dfReportService.findAttrTypeReport(
new Page<DfAttrTypeReport>(request, response, DfAttrTypeReport.class), dfAttrTypeReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控性质(带私有标签)实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控性质(带私有标签)实时统计成功",
attrTypeReportPage, activeSys, logSource);
}
@RequestMapping(value = "dfSrcIpDomesticPrivServiceReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控境内源IP(带私有标签)实时统计", httpMethod = "GET", notes = "get log list")
public Map dfSrcIpDomesticPrivServiceReportSources(Page page, DfSrcIpDomeSticReport dfSrcIpDomeSticReport,
Model model, HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DfSrcIpDomeSticReport> srcIpDomeSticReportPage = null;
try {
//设置本地默认查询时间
resetTime(dfSrcIpDomeSticReport);
dfReportService.queryConditionCheck(thread, start, dfSrcIpDomeSticReport, DfSrcIpDomeSticReport.class,
page);
// 查询数据库
srcIpDomeSticReportPage = dfReportService.findSrcIpDomeSticReport(
new Page<DfSrcIpDomeSticReport>(request, response, DfSrcIpDomeSticReport.class),
dfSrcIpDomeSticReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控境内源IP(带私有标签)实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控境内源IP(带私有标签)实时统计成功",
srcIpDomeSticReportPage, activeSys, logSource);
}
@RequestMapping(value = "dfDestIpCountryPrivServiceReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控境内目的IP(带私有标签)实时统计", httpMethod = "GET", notes = "get log list")
public Map dfDestIpCountryPrivServiceReportSources(Page page, DfDestIpCountryReport dfDestIpCountryReport,
Model model, HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DfDestIpCountryReport> dfDestIpCountryReportPage = null;
try {
//设置本地默认查询时间
resetTime(dfDestIpCountryReport);
dfReportService.queryConditionCheck(thread, start, dfDestIpCountryReport, DfDestIpCountryReport.class,
page);
// 查询数据库
dfDestIpCountryReportPage = dfReportService.findDestIpCountryReport(
new Page<DfDestIpCountryReport>(request, response, DfDestIpCountryReport.class),
dfDestIpCountryReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控境内目的IP(带私有标签)实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控境内目的IP(带私有标签)实时统计成功",
dfDestIpCountryReportPage, activeSys, logSource);
}
@RequestMapping(value = "dfEntranceReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控局点(带私有标签)实时统计", httpMethod = "GET", notes = "get log list")
public Map dfEntranceReportSources(Page page, DfEntranceReport dfEntranceReport, Model model,
HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DfEntranceReport> dfEntranceReportPage = null;
try {
//设置本地默认查询时间
resetTime(dfEntranceReport);
dfReportService.queryConditionCheck(thread, start, dfEntranceReport, DfEntranceReport.class,
page);
// 查询数据库
dfEntranceReportPage = dfReportService.findDfEntranceReport(
new Page<DfEntranceReport>(request, response, DfEntranceReport.class), dfEntranceReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控局点(带私有标签)实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控局点(带私有标签)实时统计成功",
dfEntranceReportPage, activeSys, logSource);
}
@RequestMapping(value = "dfLwhhReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控来文函号(带私有标签)实时统计", httpMethod = "GET", notes = "get log list")
public Map dfLwhhReportSources(Page page, DfLwhhReport dfLwhhReport, Model model, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DfLwhhReport> dfLwhhReportPage = null;
try {
//设置本地默认查询时间
resetTime(dfLwhhReport);
dfReportService.queryConditionCheck(thread, start, dfLwhhReport, DfLwhhReport.class, page);
// 查询数据库
dfLwhhReportPage = dfReportService
.findDfLwhhReport(new Page<DfLwhhReport>(request, response, DfLwhhReport.class), dfLwhhReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控来文函号(带私有标签)实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控来文函号(带私有标签)实时统计成功",
dfLwhhReportPage, activeSys, logSource);
}
@RequestMapping(value = "dfTagPrivServiceReportSources", method = RequestMethod.GET)
@ApiOperation(value = "管控标签(带私有标签)实时统计", httpMethod = "GET", notes = "get log list")
public Map dfTagPrivServiceReportSources(Page page, DfTagReport dfTagReport, Model model, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DfTagReport> dfTagReportPage = null;
try {
//设置本地默认查询时间
resetTime(dfTagReport);
dfReportService.queryConditionCheck(thread, start, dfTagReport, DfTagReport.class, page);
// 查询数据库
dfTagReportPage = dfReportService
.findDfTagReportPage(new Page<DfTagReport>(request, response, DfTagReport.class), dfTagReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "管控标签(带私有标签)实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "管控标签(带私有标签)实时统计成功",
dfTagReportPage, activeSys, logSource);
}
/**
*
* @Title: resetTime
* @Description: (实时统计默认查询本地一个小时的数据)
* @param @param entity
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
public void resetTime(DfReportEntity<?> entity) throws Exception {
Map<String, String> map = DateUtils.getLocalTime(entity.getSearchReportStartTime(),
entity.getSearchReportEndTime(), Constants.REPORT_LOCAL_TIME,"report");
entity.setSearchReportStartTime(map.get("startTime"));
entity.setSearchReportEndTime(map.get("endTime"));
}
}

View File

@@ -0,0 +1,792 @@
/**
* @Title: DfStatLogController.java
* @Package com.nis.web.controller
* @Description: TODO(用一句话描述该文件做什么)
* @author ddm
* @date 2016年9月13日 下午1:22:15
* @version V1.0
*/
package com.nis.web.controller.restful;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.DfReportEntity;
import com.nis.domain.Page;
import com.nis.domain.StatLogEntity;
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.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.DateUtils;
import com.nis.util.JsonMapper;
import com.nis.util.StringUtil;
import com.nis.util.redis.RedisDao;
import com.nis.util.redis.SaveRedisThread;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DfStatLogService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: DfStatLogController
* @Description: TODO(这里用一句话描述这个类的作用)
* @author (ddm)
* @date 2016年9月13日 下午1:22:15
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/log/v1")
@SuppressWarnings({ "rawtypes", "unchecked" })
public class DfStatLogController extends BaseRestController{
protected final Logger logger = Logger.getLogger(this.getClass());
protected String logSource="0";
protected String activeSys=Constants.ACTIVESYS_ALL;
@Autowired
protected DfStatLogService dfStatLogService;
@Autowired
protected RedisDao redisDao;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@RequestMapping(value="dfStatLogDailySources", method = RequestMethod.GET)
@ApiOperation(value="封堵日志配置日报表" , httpMethod = "GET", notes="get log list")
public Map dfStatLogDailySources(
Page page,DfStatLogDaily dailyLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfStatLogDaily> dailyLogPage =null;
try {
resetTime(dailyLog, "daily");
if (!StringUtil.isBlank(dailyLog.getSearchConfigId())) {
Long.parseLong(dailyLog.getSearchConfigId());
}
dfStatLogService.queryConditionCheck(thread,start,dailyLog, DfStatLogDaily.class, page);
dailyLogPage = dfStatLogService.dfStatLogDaily(new Page<DfStatLogDaily>(request, response,DfStatLogDaily.class), dailyLog);
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
RestServiceException restE = new RestServiceException(thread, System.currentTimeMillis() - start,
"SearchConfigId参数格式错误", RestBusinessCode.param_formate_error.getValue());
restE.setActiveSys(activeSys);
restE.setLogSource(logSource);
throw restE;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"封堵日志配置日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "封堵日志配置日报表检索成功",dailyLogPage,activeSys,logSource);
}
@RequestMapping(value="dfStatLogMonthSources", method = RequestMethod.GET)
@ApiOperation(value="封堵日志配置月报表" , httpMethod = "GET", notes="get log list")
public Map dfStatLogMonthSources(
Page page,DfStatLogMonth monthLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfStatLogMonth> monthLogPage =null;
try {
resetTime(monthLog, "month");
if (!StringUtil.isBlank(monthLog.getSearchConfigId())) {
Long.parseLong(monthLog.getSearchConfigId());
}
//查询条件校验
dfStatLogService.queryConditionCheck(thread,start,monthLog, DfStatLogMonth.class, page);
monthLogPage = dfStatLogService.dfStatLogMonth(new Page<DfStatLogMonth>(request, response,DfStatLogMonth.class), monthLog);
}catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
RestServiceException restE = new RestServiceException(thread, System.currentTimeMillis() - start,
"SearchConfigId参数格式错误", RestBusinessCode.param_formate_error.getValue());
restE.setActiveSys(activeSys);
restE.setLogSource(logSource);
throw restE;
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"封堵日志配置月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "封堵日志配置月报表检索成功",monthLogPage,activeSys,logSource);
}
/**
* 标签日报表
*
* @Title: dfTagStatLogDailySources
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="dfTagStatLogDailySources", method = RequestMethod.GET)
@ApiOperation(value="标签封堵日志配置日报表" , httpMethod = "GET", notes="get log list")
public Map dfTagStatLogDailySources(
Page page,DfTagStatLogDaily dailyLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
//查询条件校验
Page<DfTagStatLogDaily> dailyLogPage =null;
try {
resetTime(dailyLog, "daily");
if (!StringUtil.isBlank(dailyLog.getSearchTag())) {
Integer.parseInt(dailyLog.getSearchTag());
}
dfStatLogService.queryConditionCheck(thread,start,dailyLog, DfTagStatLogDaily.class, page);
dailyLogPage = dfStatLogService.dfTagStatLogDaily(new Page<DfTagStatLogDaily>(request, response,DfTagStatLogDaily.class), dailyLog);
}catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
RestServiceException restE = new RestServiceException(thread, System.currentTimeMillis() - start,
"SearchTag参数格式错误", RestBusinessCode.param_formate_error.getValue());
restE.setActiveSys(activeSys);
restE.setLogSource(logSource);
throw restE;
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"标签封堵日志配置日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "标签封堵日志配置日报表检索成功",dailyLogPage,activeSys,logSource);
}
/**
* 标签月报表
*
* @Title: dfTagStatLogDailySources
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="dfTagStatLogMonthSources", method = RequestMethod.GET)
@ApiOperation(value="标签封堵日志配置月报表" , httpMethod = "GET", notes="get log list")
public Map dfTagStatLogMonthSources(
Page page,DfTagStatLogMonth monthLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfTagStatLogMonth> monthLogPage =null;
try {
resetTime(monthLog, "month");
if (!StringUtil.isBlank(monthLog.getSearchTag())) {
Integer.parseInt(monthLog.getSearchTag());
}
//查询条件校验
dfStatLogService.queryConditionCheck(thread,start,monthLog, DfTagStatLogMonth.class, page);
monthLogPage = dfStatLogService.dfTagStatLogMonth(new Page<DfTagStatLogMonth>(request, response,DfTagStatLogMonth.class), monthLog);
}catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
RestServiceException restE = new RestServiceException(thread, System.currentTimeMillis() - start,
"SearchTag参数格式错误", RestBusinessCode.param_formate_error.getValue());
restE.setActiveSys(activeSys);
restE.setLogSource(logSource);
throw restE;
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"标签封堵日志配置月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "标签封堵日志配置月报表检索成功",monthLogPage,activeSys,logSource);
}
/**
* @Title: dfTagStatLogDailySources
* @Description: (性质日报表)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="dfAttrStatLogDailySources", method = RequestMethod.GET)
@ApiOperation(value="性质封堵日志配置日报表" , httpMethod = "GET", notes="get log list")
public Map dfAttrStatLogDailySources(
Page page,DfAttrStatLogDaily dailyLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfAttrStatLogDaily> dailyLogPage =null;
try {
resetTime(dailyLog, "daily");
if (!StringUtil.isBlank(dailyLog.getSearchAttrType())) {
Integer.parseInt(dailyLog.getSearchAttrType());
}
dfStatLogService.queryConditionCheck(thread,start,dailyLog, DfAttrStatLogDaily.class, page);
dailyLogPage = dfStatLogService.dfAttrStatLogDaily(new Page<DfAttrStatLogDaily>(request, response,DfAttrStatLogDaily.class), dailyLog);
}catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
RestServiceException restE = new RestServiceException(thread, System.currentTimeMillis() - start,
"SearchAttrType参数格式错误", RestBusinessCode.param_formate_error.getValue());
restE.setActiveSys(activeSys);
restE.setLogSource(logSource);
throw restE;
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"性质封堵日志配置日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "性质封堵日志配置日报表检索成功",dailyLogPage,activeSys,logSource);
}
/**
* @Title: dfAttrStatLogDailySources
* @Description: (性质月报表)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="dfAttrStatLogMonthSources", method = RequestMethod.GET)
@ApiOperation(value="性质封堵日志配置月报表" , httpMethod = "GET", notes="get log list")
public Map dfAttrStatLogMonthSources(
Page page,DfAttrStatLogMonth monthLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfAttrStatLogMonth> monthLogPage =null;
try {
resetTime(monthLog, "month");
if (!StringUtil.isBlank(monthLog.getSearchAttrType())) {
Integer.parseInt(monthLog.getSearchAttrType());
}
//查询条件校验
dfStatLogService.queryConditionCheck(thread,start,monthLog, DfAttrStatLogMonth.class, page);
monthLogPage = dfStatLogService.dfAttrStatLogMonth(new Page<DfAttrStatLogMonth>(request, response,DfAttrStatLogMonth.class), monthLog);
}catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
RestServiceException restE = new RestServiceException(thread, System.currentTimeMillis() - start,
"SearchAttrType参数格式错误", RestBusinessCode.param_formate_error.getValue());
restE.setActiveSys(activeSys);
restE.setLogSource(logSource);
throw restE;
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"性质封堵日志配置月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "性质封堵日志配置月报表检索成功",monthLogPage,activeSys,logSource);
}
/**
* @Title: dfEntrStatLogDailySources
* @Description: (局点日报表)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="dfEntrStatLogDailySources", method = RequestMethod.GET)
@ApiOperation(value="局点封堵日志配置日报表" , httpMethod = "GET", notes="get log list")
public Map dfEntrStatLogDailySources(
Page page,DfEntrStatLogDaily dailyLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfEntrStatLogDaily> dailyLogPage =null;
try {
resetTime(dailyLog, "daily");
if (!StringUtil.isBlank(dailyLog.getSearchEntranceId())) {
Integer.parseInt(dailyLog.getSearchEntranceId());
}
dfStatLogService.queryConditionCheck(thread,start,dailyLog, DfEntrStatLogDaily.class, page);
dailyLogPage = dfStatLogService.dfEntrStatLogDaily(new Page<DfEntrStatLogDaily>(request, response,DfEntrStatLogDaily.class), dailyLog);
}catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
RestServiceException restE = new RestServiceException(thread, System.currentTimeMillis() - start,
"SearchEntranceId参数格式错误", RestBusinessCode.param_formate_error.getValue());
restE.setActiveSys(activeSys);
restE.setLogSource(logSource);
throw restE;
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"局点封堵日志配置日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "局点封堵日志配置日报表检索成功",dailyLogPage,activeSys,logSource);
}
/**
* @Title: dfEntrStatLogDailySources
* @Description: (局点月报表)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="dfEntrStatLogMonthSources", method = RequestMethod.GET)
@ApiOperation(value="局点封堵日志配置月报表" , httpMethod = "GET", notes="get log list")
public Map dfEntrStatLogMonthSources(
Page page,DfEntrStatLogMonth monthLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfEntrStatLogMonth> monthLogPage =null;
try {
resetTime(monthLog, "month");
if (!StringUtil.isBlank(monthLog.getSearchEntranceId())) {
Integer.parseInt(monthLog.getSearchEntranceId());
}
//查询条件校验
dfStatLogService.queryConditionCheck(thread,start,monthLog, DfEntrStatLogMonth.class, page);
monthLogPage = dfStatLogService.dfEntrStatLogMonth(new Page<DfEntrStatLogMonth>(request, response,DfEntrStatLogMonth.class), monthLog);
}catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
RestServiceException restE = new RestServiceException(thread, System.currentTimeMillis() - start,
"SearchEntranceId参数格式错误", RestBusinessCode.param_formate_error.getValue());
restE.setActiveSys(activeSys);
restE.setLogSource(logSource);
throw restE;
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"局点封堵日志配置月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "局点封堵日志配置月报表检索成功",monthLogPage,activeSys,logSource);
}
/**
* @Title: dfLwhhStatLogDailySources
* @Description: (局点日报表)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="dfLwhhStatLogDailySources", method = RequestMethod.GET)
@ApiOperation(value="来文函号封堵日志配置日报表" , httpMethod = "GET", notes="get log list")
public Map dfLwhhStatLogDailySources(
Page page,DfLwhhStatLogDaily dailyLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
//查询条件校验
Page<DfLwhhStatLogDaily> dailyLogPage =null;
try {
resetTime(dailyLog, "daily");
if (!StringUtil.isBlank(dailyLog.getSearchLwhh())) {
Integer.parseInt(dailyLog.getSearchLwhh());
}
dfStatLogService.queryConditionCheck(thread,start,dailyLog, DfLwhhStatLogDaily.class, page);
dailyLogPage = dfStatLogService.dfLwhhStatLogDaily(new Page<DfLwhhStatLogDaily>(request, response,DfLwhhStatLogDaily.class), dailyLog);
}catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
RestServiceException restE = new RestServiceException(thread, System.currentTimeMillis() - start,
"SearchLwhh参数格式错误", RestBusinessCode.param_formate_error.getValue());
restE.setActiveSys(activeSys);
restE.setLogSource(logSource);
throw restE;
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"来文函号封堵日志配置日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "来文函号封堵日志配置日报表检索成功",dailyLogPage,activeSys,logSource);
}
/**
* @Title: dfLwhhStatLogDailySources
* @Description: (局点月报表)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="dfLwhhStatLogMonthSources", method = RequestMethod.GET)
@ApiOperation(value="来文函号封堵日志配置月报表" , httpMethod = "GET", notes="get log list")
public Map dfLwhhStatLogMonthSources(
Page page,DfLwhhStatLogMonth monthLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfLwhhStatLogMonth> monthLogPage =null;
try {
resetTime(monthLog, "month");
if (!StringUtil.isBlank(monthLog.getSearchLwhh())) {
Integer.parseInt(monthLog.getSearchLwhh());
}
//查询条件校验
dfStatLogService.queryConditionCheck(thread,start,monthLog, DfLwhhStatLogMonth.class, page);
monthLogPage = dfStatLogService.dfLwhhStatLogMonth(new Page<DfLwhhStatLogMonth>(request, response,DfLwhhStatLogMonth.class), monthLog);
}catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
RestServiceException restE = new RestServiceException(thread, System.currentTimeMillis() - start,
"SearchLwhh参数格式错误", RestBusinessCode.param_formate_error.getValue());
restE.setActiveSys(activeSys);
restE.setLogSource(logSource);
throw restE;
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"来文函号封堵日志配置月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "来文函号封堵日志配置月报表检索成功",monthLogPage,activeSys,logSource);
}
/**
* 境内源IP日报表
*
* @Title: dfSrcIpDomesticStatLogDailySources
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="dfSrcIpDomesticStatLogDailySources", method = RequestMethod.GET)
@ApiOperation(value="境内源IP封堵日志配置日报表" , httpMethod = "GET", notes="get log list")
public Map dfSrcIpDomesticStatLogDailySources(
Page page,DfSrcIpDomesticStatLogDaily dailyLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfSrcIpDomesticStatLogDaily> dailyLogPage =null;
try {
resetTime(dailyLog, "daily");
dfStatLogService.queryConditionCheck(thread,start,dailyLog, DfSrcIpDomesticStatLogDaily.class, page);
dailyLogPage = dfStatLogService.dfSrcIpDomesticStatLogDaily(new Page<DfSrcIpDomesticStatLogDaily>(request, response,DfSrcIpDomesticStatLogDaily.class), dailyLog);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"境内源IP封堵日志配置日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "境内源IP封堵日志配置日报表检索成功",dailyLogPage,activeSys,logSource);
}
/**
* 境内源IP月报表
*
* @Title: dfSrcIpDomesticStatLogMonthSources
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="dfSrcIpDomesticStatLogMonthSources", method = RequestMethod.GET)
@ApiOperation(value="境内源IP封堵日志配置月报表" , httpMethod = "GET", notes="get log list")
public Map dfSrcIpDomesticStatLogMonthSources(
Page page,DfSrcIpDomesticStatLogMonth monthLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfSrcIpDomesticStatLogMonth> monthLogPage =null;
try {
resetTime(monthLog, "month");
//查询条件校验
dfStatLogService.queryConditionCheck(thread,start,monthLog, DfSrcIpDomesticStatLogMonth.class, page);
monthLogPage = dfStatLogService.dfSrcIpDomesticStatLogMonth(new Page<DfSrcIpDomesticStatLogMonth>(request, response,DfSrcIpDomesticStatLogMonth.class), monthLog);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"境内源IP封堵日志配置月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "境内源IP封堵日志配置月报表检索成功",monthLogPage,activeSys,logSource);
}
/**
* 国家目的IP日报表
*
* @Title: dfDestIpCounrtyStatLogDailySources
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="dfDestIpCountryStatLogDailySources", method = RequestMethod.GET)
@ApiOperation(value="国家目的IP封堵日志配置日报表" , httpMethod = "GET", notes="get log list")
public Map dfDestIpCounrtyStatLogDailySources(
Page page,DfDestIpCounrtyStatLogDaily dailyLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfDestIpCounrtyStatLogDaily> dailyLogPage =null;
try {
resetTime(dailyLog, "daily");
dfStatLogService.queryConditionCheck(thread,start,dailyLog, DfDestIpCounrtyStatLogDaily.class, page);
dailyLogPage = dfStatLogService.dfDestIpCounrtyStatLogDaily(new Page<DfDestIpCounrtyStatLogDaily>(request, response,DfDestIpCounrtyStatLogDaily.class), dailyLog);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"国家目的IP封堵日志配置日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "国家目的IP封堵日志配置日报表检索成功",dailyLogPage,activeSys,logSource);
}
/**
* 国家目的IP月报表
*
* @Title: dfDestIpCounrtyStatLogMonthSources
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="dfDestIpCountryStatLogMonthSources", method = RequestMethod.GET)
@ApiOperation(value="国家目的IP封堵日志配置月报表" , httpMethod = "GET", notes="get log list")
public Map dfDestIpCounrtyStatLogMonthSources(
Page page,DfDestIpCounrtyStatLogMonth monthLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DfDestIpCounrtyStatLogMonth> monthLogPage =null;
try {
resetTime(monthLog, "month");
//查询条件校验
dfStatLogService.queryConditionCheck(thread,start,monthLog, DfDestIpCounrtyStatLogMonth.class, page);
monthLogPage = dfStatLogService.dfDestIpCounrtyStatLogMonth(new Page<DfDestIpCounrtyStatLogMonth>(request, response,DfDestIpCounrtyStatLogMonth.class), monthLog);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"国家目的IP封堵日志配置月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "国家目的IP封堵日志配置月报表检索成功",monthLogPage,activeSys,logSource);
}
/**
*
* @Title: resetTime
* @Description: (日报表默认查询本地前一天的数据)
* @param @param entity
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
public void resetTime(StatLogEntity<?> entity,String type) throws Exception{
Map<String, String> map = DateUtils.getLocalTime(entity.getSearchStatStartTime(),
entity.getSearchStatEndTime(), Constants.REPORT_LOCAL_TIME,type);
entity.setSearchStatStartTime(map.get("startTime"));
entity.setSearchStatEndTime(map.get("endTime"));
}
}

View File

@@ -0,0 +1,921 @@
package com.nis.web.controller.restful;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
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.Constants;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DjJitLogSearchService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
*
* @ClassName: DjJitLogSearchController
* @Description: 监测日志实时统计查询服务
* @author (rkg)
* @date 2016年9月13日上午10:32:21
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/log/v1")
@SuppressWarnings({ "rawtypes" })
public class DjJitLogSearchController extends BaseRestController {
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private final Logger logger1 = Logger.getLogger(this.getClass());
protected String logSource = "0";
@Autowired
private DjJitLogSearchService djJitLogSearchService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@RequestMapping(value = "/djJitFlSrcReportSources", method = RequestMethod.GET)
@ApiOperation(value = "监测分类性质源IP实时统计", httpMethod = "GET", notes = "监测分类性质源IP实时统计列表")
public Map djJitFlSrcReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DjJitFlSrcReport djJitFlSrcReportSources, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DjJitFlSrcReport> djJitFlSrcReportSourcesPage = null;
try {
// 公共请求参数校验
djJitLogSearchService.queryDjJitFlCheck(thread, start, djJitFlSrcReportSources.getSearchFl(),
djJitFlSrcReportSources.getSearchXz());
djJitLogSearchService.queryConditionCheck(thread, start, djJitFlSrcReportSources, DjJitFlSrcReport.class,
page);
djJitFlSrcReportSourcesPage = djJitLogSearchService.findDjJitFlSrcReport(
new Page<DjJitFlSrcReport>(request, response, DjJitFlSrcReport.class), djJitFlSrcReportSources);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测分类性质源IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测分类性质源IP实时统计检索成功",
djJitFlSrcReportSourcesPage, searchActiveSys, logSource);
}
@RequestMapping(value = "/djJitFlDestReportSources", method = RequestMethod.GET)
@ApiOperation(value = "监测分类性质目的IP实时统计服务", httpMethod = "GET", notes = "监测分类性质目的IP实时统计列表")
public Map djJitFlDestReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DjJitFlDestReport djJitFlDestReport, HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DjJitFlDestReport> reporPage = null;
try {
// 公共请求参数校验
djJitLogSearchService.queryDjJitFlCheck(thread, start, djJitFlDestReport.getSearchFl(),
djJitFlDestReport.getSearchXz());
djJitLogSearchService.queryConditionCheck(thread, start, djJitFlDestReport, DjJitFlDestReport.class, page);
reporPage = djJitLogSearchService.findDjJitFlDestReport(
new Page<DjJitFlDestReport>(request, response, DjJitFlDestReport.class), djJitFlDestReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测分类性质目的IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测分类性质目的IP实时统计检索成功",
reporPage, searchActiveSys, logSource);
}
@RequestMapping(value = "/djJitAffairSrcReportSources", method = RequestMethod.GET)
@ApiOperation(value = "监测事件子话题源IP实时统计服务", httpMethod = "GET", notes = "监测事件子话题源IP实时统计列表")
public Map djJitAffairSrcReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DjJitAffairSrcReport djJitAffairSrcReport, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
try {
if (!StringUtil.isBlank(djJitAffairSrcReport.getSearchAffair())) {
Integer.parseInt(djJitAffairSrcReport.getSearchAffair());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchAffair参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchAffair参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
try {
if (!StringUtil.isBlank(djJitAffairSrcReport.getSearchTopic())) {
Integer.parseInt(djJitAffairSrcReport.getSearchTopic());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchTopic参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchTopic参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
Page<DjJitAffairSrcReport> reporPage = null;
try {
djJitLogSearchService.queryConditionCheck(thread, start, djJitAffairSrcReport, DjJitAffairSrcReport.class,
page);
reporPage = djJitLogSearchService.findDjJitAffairSrcReport(
new Page<DjJitAffairSrcReport>(request, response, DjJitAffairSrcReport.class),
djJitAffairSrcReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测事件子话题源IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测事件子话题源IP实时统计检索成功",
reporPage, searchActiveSys, logSource);
}
@RequestMapping(value = "/djJitAffairDestReportSources", method = RequestMethod.GET)
@ApiOperation(value = "监测事件子话题目的IP实时统计服务", httpMethod = "GET", notes = "监测事件子话题目的IP实时统计列表")
public Map djJitAffairDestReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DjJitAffairDestReport djJitAffairDestReport, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
try {
if (!StringUtil.isBlank(djJitAffairDestReport.getSearchAffair())) {
Integer.parseInt(djJitAffairDestReport.getSearchAffair());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchAffair参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchAffair参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
try {
if (!StringUtil.isBlank(djJitAffairDestReport.getSearchTopic())) {
Integer.parseInt(djJitAffairDestReport.getSearchTopic());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchTopic参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchTopic参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
Page<DjJitAffairDestReport> reporPage = null;
try {
djJitLogSearchService.queryConditionCheck(thread, start, djJitAffairDestReport, DjJitAffairDestReport.class,
page);
reporPage = djJitLogSearchService.findDjJitAffairDestReport(
new Page<DjJitAffairDestReport>(request, response, DjJitAffairDestReport.class),
djJitAffairDestReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测事件子话题目的IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测事件子话题目的IP实时统计检索成功",
reporPage, searchActiveSys, logSource);
}
@RequestMapping(value = "/djJitMissionSrcReportSources", method = RequestMethod.GET)
@ApiOperation(value = "监测任务源IP实时统计服务", httpMethod = "GET", notes = "监测任务源IP实时统计列表")
public Map djJitMissionSrcReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DjJitMissionSrcReport djJitMissionSrcReport, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
try {
if (!StringUtil.isBlank(djJitMissionSrcReport.getSearchMission())) {
Integer.parseInt(djJitMissionSrcReport.getSearchMission());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchMission参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchMission参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
Page<DjJitMissionSrcReport> reporPage = null;
try {
djJitLogSearchService.queryConditionCheck(thread, start, djJitMissionSrcReport, DjJitMissionSrcReport.class,
page);
reporPage = djJitLogSearchService.findDjJitMissionSrcReport(
new Page<DjJitMissionSrcReport>(request, response, DjJitMissionSrcReport.class),
djJitMissionSrcReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测任务源IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测任务源IP实时统计检索成功",
reporPage, searchActiveSys, logSource);
}
@RequestMapping(value = "/djJitMissionDestReportSources", method = RequestMethod.GET)
@ApiOperation(value = "监测任务目的IP实时统计服务", httpMethod = "GET", notes = "监测任务目的IP实时统计列表")
public Map djJitMissionDestReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DjJitMissionDestReport djJitMissionDestReport, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
try {
if (!StringUtil.isBlank(djJitMissionDestReport.getSearchMission())) {
Integer.parseInt(djJitMissionDestReport.getSearchMission());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchMission参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchMission参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
Page<DjJitMissionDestReport> reporPage = null;
try {
djJitLogSearchService.queryConditionCheck(thread, start, djJitMissionDestReport,
DjJitMissionDestReport.class, page);
reporPage = djJitLogSearchService.findDjJitMissionDestReport(
new Page<DjJitMissionDestReport>(request, response, DjJitMissionDestReport.class),
djJitMissionDestReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测任务目的IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测任务目的IP实时统计检索成功",
reporPage, searchActiveSys, logSource);
}
@RequestMapping(value = "/djJitGuaranteeSrcReportSources", method = RequestMethod.GET)
@ApiOperation(value = "监测保障期源IP实时统计服务", httpMethod = "GET", notes = "监测保障期源IP实时统计列表")
public Map djJitGuaranteeSrcReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DjJitGuaranteeSrcReport djJitGuaranteeSrcReport, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
try {
if (!StringUtil.isBlank(djJitGuaranteeSrcReport.getSearchGuarantee())) {
Integer.parseInt(djJitGuaranteeSrcReport.getSearchGuarantee());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchGuarantee参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchGuarantee参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
Page<DjJitGuaranteeSrcReport> reporPage = null;
try {
djJitLogSearchService.queryConditionCheck(thread, start, djJitGuaranteeSrcReport,
DjJitGuaranteeSrcReport.class, page);
reporPage = djJitLogSearchService.findDjJitGuaranteeSrcReport(
new Page<DjJitGuaranteeSrcReport>(request, response, DjJitGuaranteeSrcReport.class),
djJitGuaranteeSrcReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测保障期源IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测保障期源IP实时统计检索成功",
reporPage, searchActiveSys, logSource);
}
@RequestMapping(value = "/djJitGuaranteeDestReportSources", method = RequestMethod.GET)
@ApiOperation(value = "监测保障期目的IP实时统计服务", httpMethod = "GET", notes = "监测保障期目的IP实时统计列表")
public Map djJitGuaranteeDestReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DjJitGuaranteeDestReport djJitGuaranteeDestReport, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
try {
if (!StringUtil.isBlank(djJitGuaranteeDestReport.getSearchGuarantee())) {
Integer.parseInt(djJitGuaranteeDestReport.getSearchGuarantee());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchGuarantee参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchGuarantee参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
Page<DjJitGuaranteeDestReport> reporPage = null;
try {
djJitLogSearchService.queryConditionCheck(thread, start, djJitGuaranteeDestReport,
DjJitGuaranteeDestReport.class, page);
reporPage = djJitLogSearchService.findDjJitGuaranteeDestReport(
new Page<DjJitGuaranteeDestReport>(request, response, DjJitGuaranteeDestReport.class),
djJitGuaranteeDestReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测保障期目的IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测保障期目的IP实时统计检索成功",
reporPage, searchActiveSys, logSource);
}
@RequestMapping(value = "/djJitTagSrcReportSources", method = RequestMethod.GET)
@ApiOperation(value = "监测标签源IP实时统计服务", httpMethod = "GET", notes = "监测标签源IP实时统计列表")
public Map djJitTagSrcReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DjJitTagSrcReport djJitTagSrcReport, HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
if (null != djJitTagSrcReport.getSearchTag() && !djJitTagSrcReport.getSearchTag().equals("")) {
String[] tagArr = djJitTagSrcReport.getSearchTag().split(",");
List<String> tagList = new ArrayList<String>();
for (int i = 0; i < tagArr.length; i++) {
if (!tagArr[i].equals("")) {
try {
Integer.parseInt(tagArr[i]);
tagList.add(tagArr[i]);
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread,
System.currentTimeMillis() - start, "searchTag参数格式错误",
RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchTag参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
}
}
StringBuffer sb = new StringBuffer();
for (String str : tagList) {
sb.append(str + ",");
}
String tag = sb.substring(0, sb.length() - 1);
djJitTagSrcReport.setSearchTag(tag);
}
Page<DjJitTagSrcReport> reporPage = null;
try {
djJitLogSearchService.queryConditionCheck(thread, start, djJitTagSrcReport, DjJitTagSrcReport.class, page);
reporPage = djJitLogSearchService.findDjJitTagSrcReport(
new Page<DjJitTagSrcReport>(request, response, DjJitTagSrcReport.class), djJitTagSrcReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测标签源IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测标签源IP实时统计检索成功",
reporPage, searchActiveSys, logSource);
}
@RequestMapping(value = "/djJitTagDestReportSources", method = RequestMethod.GET)
@ApiOperation(value = "监测标签目的IP实时统计服务", httpMethod = "GET", notes = "监测标签目的IP实时统计列表")
public Map djJitTagDestReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DjJitTagDestReport djJitTagDestReport, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
if (null != djJitTagDestReport.getSearchTag() && !djJitTagDestReport.getSearchTag().equals("")) {
String[] tagArr = djJitTagDestReport.getSearchTag().split(",");
List<String> tagList = new ArrayList<String>();
for (int i = 0; i < tagArr.length; i++) {
if (!tagArr[i].equals("")) {
try {
Integer.parseInt(tagArr[i]);
tagList.add(tagArr[i]);
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread,
System.currentTimeMillis() - start, "searchTag参数格式错误",
RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchTag参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
}
}
StringBuffer sb = new StringBuffer();
for (String str : tagList) {
sb.append(str + ",");
}
String tag = sb.substring(0, sb.length() - 1);
djJitTagDestReport.setSearchTag(tag);
}
Page<DjJitTagDestReport> reporPage = null;
try {
djJitLogSearchService.queryConditionCheck(thread, start, djJitTagDestReport, DjJitTagDestReport.class,
page);
reporPage = djJitLogSearchService.findDjJitTagDestReport(
new Page<DjJitTagDestReport>(request, response, DjJitTagDestReport.class), djJitTagDestReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测标签目的IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测标签目的IP实时统计检索成功",
reporPage, searchActiveSys, logSource);
}
@RequestMapping(value = "/djJitIdSrcReportSources", method = RequestMethod.GET)
@ApiOperation(value = "监测规则源IP实时统计服务", httpMethod = "GET", notes = "监测规则源IP实时统计列表")
public Map djJitIdSrcReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DjJitIdSrcReport djJitIdSrcReport, HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
try {
if (!StringUtil.isBlank(djJitIdSrcReport.getSearchId())) {
Integer.parseInt(djJitIdSrcReport.getSearchId());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchId参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchId参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
Page<DjJitIdSrcReport> reporPage = null;
try {
djJitLogSearchService.queryConditionCheck(thread, start, djJitIdSrcReport, DjJitIdSrcReport.class, page);
reporPage = djJitLogSearchService.findDjJitIdSrcReport(
new Page<DjJitIdSrcReport>(request, response, DjJitIdSrcReport.class), djJitIdSrcReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测规则源IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测规则源IP实时统计检索成功",
reporPage, searchActiveSys, logSource);
}
@RequestMapping(value = "/djJitIdDestReportSources", method = RequestMethod.GET)
@ApiOperation(value = "监测规则目的IP实时统计服务", httpMethod = "GET", notes = "监测规则目的IP实时统计列表")
public Map djJitIdDestReportSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DjJitIdDestReport djJitIdDestReport, HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
try {
if (!StringUtil.isBlank(djJitIdDestReport.getSearchId())) {
Integer.parseInt(djJitIdDestReport.getSearchId());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchId参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchId参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
Page<DjJitIdDestReport> reporPage = null;
try {
djJitLogSearchService.queryConditionCheck(thread, start, djJitIdDestReport, DjJitIdDestReport.class, page);
reporPage = djJitLogSearchService.findDjJitIdDestReport(
new Page<DjJitIdDestReport>(request, response, DjJitIdDestReport.class), djJitIdDestReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测规则目的IP实时统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测规则目的IP实时统计检索成功",
reporPage, searchActiveSys, logSource);
}
@RequestMapping(value = "/djCkStatLogSources", method = RequestMethod.GET)
@ApiOperation(value = "监测日志国际出入口统计服务", httpMethod = "GET", notes = "监测日志国际出入口统计列表")
public Map djCkStatLogSources(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DjCkStatLog djCkStatLog, HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
// 公共请求参数校验
try {
if (!StringUtil.isBlank(djCkStatLog.getSearchCfgId())) {
Long.parseLong(djCkStatLog.getSearchCfgId());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchCfgId参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchId参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
try {
if (!StringUtil.isBlank(djCkStatLog.getSearchGjCkId())) {
Long.parseLong(djCkStatLog.getSearchGjCkId());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchGjCkId参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchGjCkId参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
try {
if (!StringUtil.isBlank(djCkStatLog.getSearchActiveSys())) {
Integer.parseInt(djCkStatLog.getSearchActiveSys());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchActiveSys参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchGjCkId参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
try {
if (!StringUtil.isBlank(djCkStatLog.getSearchCapStartTime())) {
sdf.parse(djCkStatLog.getSearchCapStartTime());
}
} catch (ParseException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchCapStartTime参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchCapStartTime参数格式格式");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
try {
if (!StringUtil.isBlank(djCkStatLog.getSearchCapEndTime())) {
sdf.parse(djCkStatLog.getSearchCapEndTime());
}
} catch (ParseException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchCapEndTime参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchCapEndTime参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
throw ((RestServiceException) e);
}
try {
if (!StringUtil.isBlank(djCkStatLog.getSearchService())) {
Integer.parseInt(djCkStatLog.getSearchService());
}
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
RestServiceException restError = new RestServiceException(thread, System.currentTimeMillis() - start,
"searchService参数格式错误", RestBusinessCode.param_formate_error.getValue());
restError.setActiveSys(searchActiveSys);
restError.setLogSource(logSource);
throw restError;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "searchService参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
try {
djJitLogSearchService.checkCloumnIsExist(thread, start, DjCkStatLog.class, page);
} catch (RestServiceException e) {
logger1.error(e);
e.setActiveSys(searchActiveSys);
e.setLogSource(logSource);
throw e;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "请求参数错误");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
Page<DjCkStatLog> reporPage = null;
try {
reporPage = djJitLogSearchService
.findDjCkStatLog(new Page<DjCkStatLog>(request, response, DjCkStatLog.class), djCkStatLog);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
logger1.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测日志国际出入口统计检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测日志国际出入口统计检索成功",
reporPage, searchActiveSys, logSource);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,215 @@
package com.nis.web.controller.restful;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.DfReportEntity;
import com.nis.domain.LogEntity;
import com.nis.domain.Page;
import com.nis.domain.restful.DjLwhhAttrReport;
import com.nis.domain.restful.DjLwhhTagReport;
import com.nis.domain.restful.DjSrcIpAttrReport;
import com.nis.domain.restful.DjSrcIpTagReport;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.DateUtils;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DjMultiDimensionalReportService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
*
* @ClassName: DjMultiDimensionalReportController
* @Description: TODO(dj多维实时统计)
* @author (DDM)
* @date 2017年8月4日下午2:53:01
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/log/v1")
@SuppressWarnings({ "rawtypes" })
public class DjMultiDimensionalReportController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
protected String activeSys = Constants.ACTIVESYS_ALL;
protected String logSource = "0";
@Autowired
protected DjMultiDimensionalReportService djMultiDimensionalReportService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@RequestMapping(value = "djLwhhAttrReportSources", method = RequestMethod.GET)
@ApiOperation(value = "来文函号、性质多维实时统计", httpMethod = "GET", notes = "get log list")
public Map djServiceReportSources(Page page, DjLwhhAttrReport djLwhhAttrReport, Model model,
HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DjLwhhAttrReport> lwhhAttrReportPage = null;
try {
//设置本地默认查询时间
resetTime(djLwhhAttrReport);
// 校验
djMultiDimensionalReportService.queryConditionCheck(thread, start, djLwhhAttrReport, DjLwhhAttrReport.class,
page);
// 查询数据库
lwhhAttrReportPage = djMultiDimensionalReportService.findDjLwhhAttrReportPage(
new Page<DjLwhhAttrReport>(request, response, DjLwhhAttrReport.class), djLwhhAttrReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "来文函号、性质多维实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "来文函号、性质多维实时统计成功",
lwhhAttrReportPage, activeSys, logSource);
}
@RequestMapping(value = "djLwhhTagReportSources", method = RequestMethod.GET)
@ApiOperation(value = "来文函号、标签多维实时统计", httpMethod = "GET", notes = "get log list")
public Map djServiceReportSources(Page page, DjLwhhTagReport djLwhhTagReport, Model model,
HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DjLwhhTagReport> lwhhTagReportPage = null;
try {
//设置本地默认查询时间
resetTime(djLwhhTagReport);
// 校验
djMultiDimensionalReportService.queryConditionCheck(thread, start, djLwhhTagReport, DjLwhhTagReport.class,
page);
// 查询数据库
lwhhTagReportPage = djMultiDimensionalReportService.findDjLwhhTagReportPage(
new Page<DjLwhhTagReport>(request, response, DjLwhhTagReport.class), djLwhhTagReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "来文函号、标签多维实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "来文函号、标签多维实时统计成功",
lwhhTagReportPage, activeSys, logSource);
}
@RequestMapping(value = "djSrcIpAttrReportSources", method = RequestMethod.GET)
@ApiOperation(value = "来文函号、性质多维实时统计", httpMethod = "GET", notes = "get log list")
public Map djServiceReportSources(Page page, DjSrcIpAttrReport djSrcIpAttrReport, Model model,
HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DjSrcIpAttrReport> srcIpAttrReportPage = null;
try {
//设置本地默认查询时间
resetTime(djSrcIpAttrReport);
// 校验
djMultiDimensionalReportService.queryConditionCheck(thread, start, djSrcIpAttrReport, DjSrcIpAttrReport.class,
page);
// 查询数据库
srcIpAttrReportPage = djMultiDimensionalReportService.findDjSrcIpAttrReportPage(
new Page<DjSrcIpAttrReport>(request, response, DjSrcIpAttrReport.class), djSrcIpAttrReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "境内源ip、性质多维实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "境内源ip、性质多维实时统计成功",
srcIpAttrReportPage, activeSys, logSource);
}
@RequestMapping(value = "djSrcIpTagReportSources", method = RequestMethod.GET)
@ApiOperation(value = "来文函号、标签多维实时统计", httpMethod = "GET", notes = "get log list")
public Map djServiceReportSources(Page page, DjSrcIpTagReport djSrcIpTagReport, Model model,
HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DjSrcIpTagReport> srcIpTagReportPage = null;
try {
//设置本地默认查询时间
resetTime(djSrcIpTagReport);
// 校验
djMultiDimensionalReportService.queryConditionCheck(thread, start, djSrcIpTagReport, DjSrcIpTagReport.class,
page);
// 查询数据库
srcIpTagReportPage = djMultiDimensionalReportService.findDjSrcIpTagReportPage(
new Page<DjSrcIpTagReport>(request, response, DjSrcIpTagReport.class), djSrcIpTagReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "境内源ip、标签多维实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "境内源ip、标签多维实时统计成功",
srcIpTagReportPage, activeSys, logSource);
}
/**
*
* @Title: resetTime
* @Description: (实时统计默认查询本地一个小时的数据)
* @param @param entity
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
public void resetTime(DfReportEntity<?> entity) throws Exception {
Map<String, String> map = DateUtils.getLocalTime(entity.getSearchReportStartTime(),
entity.getSearchReportEndTime(), Constants.REPORT_LOCAL_TIME,"report");
entity.setSearchReportStartTime(map.get("startTime"));
entity.setSearchReportEndTime(map.get("endTime"));
}
}

View File

@@ -0,0 +1,333 @@
/**
* @Title: DjStatLogController.java
* @Package com.nis.web.controller
* @Description: TODO(用一句话描述该文件做什么)
* @author ddm
* @date 2016年9月13日 下午1:22:15
* @version V1.0
*/
package com.nis.web.controller.restful;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.Page;
import com.nis.domain.StatLogEntity;
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.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.DateUtils;
import com.nis.util.redis.RedisDao;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DjMultiDimensionalStatLogService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: DjStatLogController
* @Description: TODO(这里用一句话描述这个类的作用)
* @author (ddm)
* @date 2016年9月13日 下午1:22:15
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/log/v1")
@SuppressWarnings({ "rawtypes", "unchecked" })
public class DjMultiDimensionalStatLogController extends BaseRestController{
protected final Logger logger = Logger.getLogger(this.getClass());
protected String logSource="0";
protected String activeSys=Constants.ACTIVESYS_ALL;
@Autowired
protected DjMultiDimensionalStatLogService djMultiDimensionalStatLogService;
@Autowired
protected RedisDao redisDao;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@RequestMapping(value="djLwhhAttrDailySources", method = RequestMethod.GET)
@ApiOperation(value="监测来文函号-性质多维日报表" , httpMethod = "GET", notes="get log list")
public Map djLwhhAttrDailySources(
Page page,DjLwhhAttrDaily djLwhhAttrDaily, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DjLwhhAttrDaily> djLwhhAttrDailyPage =null;
try {
resetTime(djLwhhAttrDaily, "daily");
djMultiDimensionalStatLogService.queryConditionCheck(thread,start,djLwhhAttrDaily, DjLwhhAttrDaily.class, page);
djLwhhAttrDailyPage = djMultiDimensionalStatLogService.djLwhhAttrDaily(new Page<DjLwhhAttrDaily>(request, response,DjLwhhAttrDaily.class), djLwhhAttrDaily);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"监测来文函号-性质多维日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "监测来文函号-标签多维日报表检索成功",djLwhhAttrDailyPage,activeSys,logSource);
}
@RequestMapping(value="djLwhhAttrMonthSources", method = RequestMethod.GET)
@ApiOperation(value="监测来文函号-性质多维月报表" , httpMethod = "GET", notes="get log list")
public Map djLwhhAttrMonthSources(
Page page,DjLwhhAttrMonth djLwhhAttrMonth, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DjLwhhAttrMonth> djLwhhAttrMonthPage =null;
try {
resetTime(djLwhhAttrMonth, "month");
//查询条件校验
djMultiDimensionalStatLogService.queryConditionCheck(thread,start,djLwhhAttrMonth, DjLwhhAttrMonth.class, page);
djLwhhAttrMonthPage = djMultiDimensionalStatLogService.djLwhhAttrMonth(new Page<DjLwhhAttrMonth>(request, response,DjLwhhAttrMonth.class), djLwhhAttrMonth);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"监测来文函号-性质多维月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "监测来文函号-性质多维月报表检索成功",djLwhhAttrMonthPage,activeSys,logSource);
}
@RequestMapping(value="djLwhhTagDailySources", method = RequestMethod.GET)
@ApiOperation(value="监测来文函号-标签多维日报表" , httpMethod = "GET", notes="get log list")
public Map djLwhhTagDailySources(
Page page,DjLwhhTagDaily djLwhhTagDaily, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DjLwhhTagDaily> djLwhhTagDailyPage =null;
try {
resetTime(djLwhhTagDaily, "daily");
djMultiDimensionalStatLogService.queryConditionCheck(thread,start,djLwhhTagDaily, DjLwhhTagDaily.class, page);
djLwhhTagDailyPage = djMultiDimensionalStatLogService.djLwhhTagDaily(new Page<DjLwhhTagDaily>(request, response,DjLwhhTagDaily.class), djLwhhTagDaily);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"监测来文函号-标签多维日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "监测来文函号-标签多维日报表检索成功",djLwhhTagDailyPage,activeSys,logSource);
}
@RequestMapping(value="djLwhhTagMonthSources", method = RequestMethod.GET)
@ApiOperation(value="监测来文函号-标签多维月报表" , httpMethod = "GET", notes="get log list")
public Map djLwhhTagMonthSources(
Page page,DjLwhhTagMonth djLwhhTagMonth, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DjLwhhTagMonth> djLwhhTagMonthPage =null;
try {
resetTime(djLwhhTagMonth, "month");
//查询条件校验
djMultiDimensionalStatLogService.queryConditionCheck(thread,start,djLwhhTagMonth, DjLwhhTagMonth.class, page);
djLwhhTagMonthPage = djMultiDimensionalStatLogService.djLwhhTagMonth(new Page<DjLwhhTagMonth>(request, response,DjLwhhTagMonth.class), djLwhhTagMonth);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"监测来文函号-标签多维月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "监测来文函号-标签多维月报表检索成功",djLwhhTagMonthPage,activeSys,logSource);
}
@RequestMapping(value="djSrcIpAttrDailySources", method = RequestMethod.GET)
@ApiOperation(value="监测省-性质多维日报表" , httpMethod = "GET", notes="get log list")
public Map djSrcIpAttrDailySources(
Page page,DjSrcIpAttrDaily djSrcIpAttrDaily, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DjSrcIpAttrDaily> djSrcIpAttrDailyPage =null;
try {
resetTime(djSrcIpAttrDaily, "daily");
djMultiDimensionalStatLogService.queryConditionCheck(thread,start,djSrcIpAttrDaily, DjSrcIpAttrDaily.class, page);
djSrcIpAttrDailyPage = djMultiDimensionalStatLogService.djSrcIpAttrDaily(new Page<DjSrcIpAttrDaily>(request, response,DjSrcIpAttrDaily.class), djSrcIpAttrDaily);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"监测省-性质多维日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "监测省-标签多维日报表检索成功",djSrcIpAttrDailyPage,activeSys,logSource);
}
@RequestMapping(value="djSrcIpAttrMonthSources", method = RequestMethod.GET)
@ApiOperation(value="监测省-性质多维月报表" , httpMethod = "GET", notes="get log list")
public Map djSrcIpAttrMonthSources(
Page page,DjSrcIpAttrMonth djSrcIpAttrMonth, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DjSrcIpAttrMonth> djSrcIpAttrMonthPage =null;
try {
resetTime(djSrcIpAttrMonth, "month");
//查询条件校验
djMultiDimensionalStatLogService.queryConditionCheck(thread,start,djSrcIpAttrMonth, DjSrcIpAttrMonth.class, page);
djSrcIpAttrMonthPage = djMultiDimensionalStatLogService.djSrcIpAttrMonth(new Page<DjSrcIpAttrMonth>(request, response,DjSrcIpAttrMonth.class), djSrcIpAttrMonth);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"监测省-性质多维月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "监测省-性质多维月报表检索成功",djSrcIpAttrMonthPage,activeSys,logSource);
}
@RequestMapping(value="djSrcIpTagDailySources", method = RequestMethod.GET)
@ApiOperation(value="监测省-标签多维日报表" , httpMethod = "GET", notes="get log list")
public Map djSrcIpTagDailySources(
Page page,DjSrcIpTagDaily djSrcIpTagDaily, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DjSrcIpTagDaily> djSrcIpTagDailyPage =null;
try {
resetTime(djSrcIpTagDaily, "daily");
djMultiDimensionalStatLogService.queryConditionCheck(thread,start,djSrcIpTagDaily, DjSrcIpTagDaily.class, page);
djSrcIpTagDailyPage = djMultiDimensionalStatLogService.djSrcIpTagDaily(new Page<DjSrcIpTagDaily>(request, response,DjSrcIpTagDaily.class), djSrcIpTagDaily);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"监测省-标签多维日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "监测省-标签多维日报表检索成功",djSrcIpTagDailyPage,activeSys,logSource);
}
@RequestMapping(value="djSrcIpTagMonthSources", method = RequestMethod.GET)
@ApiOperation(value="监测省-标签多维月报表" , httpMethod = "GET", notes="get log list")
public Map djSrcIpTagMonthSources(
Page page,DjSrcIpTagMonth djSrcIpTagMonth, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DjSrcIpTagMonth> djSrcIpTagMonthPage =null;
try {
resetTime(djSrcIpTagMonth, "month");
//查询条件校验
djMultiDimensionalStatLogService.queryConditionCheck(thread,start,djSrcIpTagMonth, DjSrcIpTagMonth.class, page);
djSrcIpTagMonthPage = djMultiDimensionalStatLogService.djSrcIpTagMonth(new Page<DjSrcIpTagMonth>(request, response,DjSrcIpTagMonth.class), djSrcIpTagMonth);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"监测省-标签多维月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "监测省-标签多维月报表检索成功",djSrcIpTagMonthPage,activeSys,logSource);
}
/**
*
* @Title: resetTime
* @Description: (日报表默认查询本地前一天的数据)
* @param @param entity
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
public void resetTime(StatLogEntity<?> entity,String type) throws Exception{
Map<String, String> map = DateUtils.getLocalTime(entity.getSearchStatStartTime(),
entity.getSearchStatEndTime(), Constants.REPORT_LOCAL_TIME,type);
entity.setSearchStatStartTime(map.get("startTime"));
entity.setSearchStatEndTime(map.get("endTime"));
}
}

View File

@@ -0,0 +1,487 @@
package com.nis.web.controller.restful;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.DfReportEntity;
import com.nis.domain.Page;
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.DjPzReport;
import com.nis.domain.restful.DjSrcIpDomeSticReport;
import com.nis.domain.restful.DjTagReport;
import com.nis.domain.restful.DjPzReportStat;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.DateUtils;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DjReportService;
import com.wordnik.swagger.annotations.ApiOperation;
import net.sf.json.JSONObject;
/**
* @ClassName: DjReportController
* @Description: 监测日志实时统计查询服务
* @author (ZBC)
* @date 2016年11月22日下午06:00:00
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/log/v1")
@SuppressWarnings({ "rawtypes" })
public class DjReportController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
protected String activeSys = Constants.ACTIVESYS_ALL;
protected String logSource = "0";
@Autowired
protected DjReportService djReportService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@RequestMapping(value = "djPzReportSources", method = RequestMethod.GET)
@ApiOperation(value = "监测配置实时统计服务", httpMethod = "GET", notes = "get log list")
public Map djPzReportSources(Page page, DjPzReport djPzReport, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DjPzReport> pzReportPage = null;
try {
//设置本地默认查询时间
resetTime(djPzReport);
djReportService.queryConditionCheck(thread, start, djPzReport, DjPzReport.class, page);
// 查询数据库
pzReportPage = djReportService.findDjPzReportPage(new Page<DjPzReport>(request, response, DjPzReport.class),
djPzReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测配置实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测配置实时统计成功",
pzReportPage, activeSys, logSource);
}
/**
* 配置统计【小时】
*
* @param page
* @param djPzReport
* @param model
* @param request
* @param response
* @return
*/
@RequestMapping(value = "djPzStatSources", method = RequestMethod.GET)
@ApiOperation(value = "监测各配置量统计服务[小时]", httpMethod = "GET", notes = "get log list")
public Map djPzStatSources(Page page, DjPzReportStat djPzReportStat, Model model, HttpServletRequest request,
HttpServletResponse response) {
if (!Constants.ACTIVESYS_A.equals(djPzReportStat.getSearchStatActiveSys())
&& !Constants.ACTIVESYS_C.equals(djPzReportStat.getSearchStatActiveSys())
&& !Constants.ACTIVESYS_AB.equals(djPzReportStat.getSearchStatActiveSys())) {
djPzReportStat.setSearchStatActiveSys(Constants.ACTIVESYS_B);
}
activeSys = djPzReportStat.getSearchStatActiveSys();
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DjPzReportStat> pzReportPage = null;
try {
//设置本地默认查询时间
resetTime(djPzReportStat);
djReportService.queryConditionCheck(thread, start, djPzReportStat, DjPzReportStat.class, page);
// 查询数据库
pzReportPage = djReportService.findDjPzReportStatPage(
new Page<DjPzReportStat>(request, response, DjPzReportStat.class), djPzReportStat);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测各配置量统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测各配置量统计成功",
pzReportPage, activeSys, logSource);
}
/**
* 配置统计【分钟】
*
* @param page
* @param djPzReport
* @param model
* @param request
* @param response
* @return
*/
@RequestMapping(value = "djPzStatMinutesSources", method = RequestMethod.GET)
@ApiOperation(value = "监测各配置量统计服务[分钟]", httpMethod = "GET", notes = "get log list")
public Map djPzStatMinutesSources(Page page, DjPzReportStat djPzReportStat, Model model, HttpServletRequest request,
HttpServletResponse response) {
if (!Constants.ACTIVESYS_A.equals(djPzReportStat.getSearchStatActiveSys())
&& !Constants.ACTIVESYS_C.equals(djPzReportStat.getSearchStatActiveSys())
&& !Constants.ACTIVESYS_AB.equals(djPzReportStat.getSearchStatActiveSys())) {
djPzReportStat.setSearchStatActiveSys(Constants.ACTIVESYS_B);
}
activeSys = djPzReportStat.getSearchStatActiveSys();
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DjPzReportStat> pzReportPage = null;
try {
//设置本地默认查询时间
resetTime(djPzReportStat);
djReportService.queryConditionCheck(thread, start, djPzReportStat, DjPzReportStat.class, page);
// 查询数据库
pzReportPage = djReportService.findDjPzReportStatMinutesPage(
new Page<DjPzReportStat>(request, response, DjPzReportStat.class), djPzReportStat);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测各配置量统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测各配置量统计成功",
pzReportPage, activeSys, logSource);
}
/**
* 配置统计
*
* @param page
* @param djPzReport
* @param model
* @param request
* @param response
* @return
*/
@RequestMapping(value = "djPzSumStatSources", method = RequestMethod.GET)
@ApiOperation(value = "监测配置总量统计服务", httpMethod = "GET", notes = "get log list")
public Map djPzSumStatSources(Page page, DjPzReportStat djPzReportStat, Model model, HttpServletRequest request,
HttpServletResponse response) {
if (!Constants.ACTIVESYS_A.equals(djPzReportStat.getSearchStatActiveSys())
&& !Constants.ACTIVESYS_C.equals(djPzReportStat.getSearchStatActiveSys())
) {
djPzReportStat.setSearchStatActiveSys(Constants.ACTIVESYS_B);
}
activeSys = djPzReportStat.getSearchStatActiveSys();
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
JSONObject json = new JSONObject();
try {
//设置本地默认查询时间
resetTime(djPzReportStat);
djReportService.queryConditionCheck(thread, start, djPzReportStat, DjPzReportStat.class,
page);
// 查询数据库
Long sum = djReportService.findDjPzReportSumStat(
new Page<DjPzReportStat>(request, response, DjPzReportStat.class), djPzReportStat);
if (sum == null)
sum = 0l;
json.put("sum", sum);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测配置总量统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测配置总量统计成功", json,
activeSys, logSource);
}
@RequestMapping(value = "djPzPrivServiceReportSources", method = RequestMethod.GET)
@ApiOperation(value = "监测配置(带私有标签)统计服务", httpMethod = "GET", notes = "get log list")
public Map djPzPrivServiceReportSources(Page page, DjPzReport djPzReport, Model model, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DjPzReport> djPzReportPage = null;
try {
//设置本地默认查询时间
resetTime(djPzReport);
djReportService.queryConditionCheck(thread, start, djPzReport, DjPzReport.class, page);
// 查询数据库
djPzReportPage = djReportService
.findDjPzPrivPage(new Page<DjPzReport>(request, response, DjPzReport.class), djPzReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测配置(带私有标签)统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测配置(带私有标签)统计成功",
djPzReportPage, activeSys, logSource);
}
@RequestMapping(value = "djAttrTypeReportSources", method = RequestMethod.GET)
@ApiOperation(value = "监测性质(带私有标签)实时统计", httpMethod = "GET", notes = "get log list")
public Map djAttrTypeReportSources(Page page, DjAttrTypeReport djAttrTypeReport, Model model,
HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DjAttrTypeReport> attrTypeReportPage = null;
try {
//设置本地默认查询时间
resetTime(djAttrTypeReport);
djReportService.queryConditionCheck(thread, start, djAttrTypeReport, DjPzReport.class, page);
// 查询数据库
attrTypeReportPage = djReportService.findAttrTypeReport(
new Page<DjAttrTypeReport>(request, response, DjAttrTypeReport.class), djAttrTypeReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测性质(带私有标签)实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测性质(带私有标签)实时统计成功",
attrTypeReportPage, activeSys, logSource);
}
@RequestMapping(value = "djSrcIpDomesticPrivServiceReportSources", method = RequestMethod.GET)
@ApiOperation(value = "监测境内源IP(带私有标签)实时统计", httpMethod = "GET", notes = "get log list")
public Map djSrcIpDomesticPrivServiceReportSources(Page page, DjSrcIpDomeSticReport djSrcIpDomeSticReport,
Model model, HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DjSrcIpDomeSticReport> srcIpDomeSticReportPage = null;
try {
//设置本地默认查询时间
resetTime(djSrcIpDomeSticReport);
djReportService.queryConditionCheck(thread, start, djSrcIpDomeSticReport, DjSrcIpDomeSticReport.class,
page);
// 查询数据库
srcIpDomeSticReportPage = djReportService.findSrcIpDomeSticReport(
new Page<DjSrcIpDomeSticReport>(request, response, DjSrcIpDomeSticReport.class),
djSrcIpDomeSticReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测境内源IP(带私有标签)实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测境内源IP(带私有标签)实时统计成功",
srcIpDomeSticReportPage, activeSys, logSource);
}
@RequestMapping(value = "djDestIpCountryPrivServiceReportSources", method = RequestMethod.GET)
@ApiOperation(value = "监测境内目的IP(带私有标签)实时统计", httpMethod = "GET", notes = "get log list")
public Map djDestIpCountryPrivServiceReportSources(Page page, DjDestIpCountryReport djDestIpCountryReport,
Model model, HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DjDestIpCountryReport> djDestIpCountryReportPage = null;
try {
//设置本地默认查询时间
resetTime(djDestIpCountryReport);
djReportService.queryConditionCheck(thread, start, djDestIpCountryReport, DjDestIpCountryReport.class,
page);
// 查询数据库
djDestIpCountryReportPage = djReportService.findDestIpCountryReport(
new Page<DjDestIpCountryReport>(request, response, DjDestIpCountryReport.class),
djDestIpCountryReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测境内目的IP(带私有标签)实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测境内目的IP(带私有标签)实时统计成功",
djDestIpCountryReportPage, activeSys, logSource);
}
@RequestMapping(value = "djEntranceReportSources", method = RequestMethod.GET)
@ApiOperation(value = "监测局点(带私有标签)实时统计", httpMethod = "GET", notes = "get log list")
public Map djEntranceReportSources(Page page, DjEntranceReport djEntranceReport, Model model,
HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DjEntranceReport> djEntranceReportPage = null;
try {
//设置本地默认查询时间
resetTime(djEntranceReport);
djReportService.queryConditionCheck(thread, start, djEntranceReport, DjEntranceReport.class,
page);
// 查询数据库
djEntranceReportPage = djReportService.findDjEntranceReport(
new Page<DjEntranceReport>(request, response, DjEntranceReport.class), djEntranceReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测局点(带私有标签)实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测局点(带私有标签)实时统计成功",
djEntranceReportPage, activeSys, logSource);
}
@RequestMapping(value = "djLwhhReportSources", method = RequestMethod.GET)
@ApiOperation(value = "监测来文函号(带私有标签)实时统计", httpMethod = "GET", notes = "get log list")
public Map djLwhhReportSources(Page page, DjLwhhReport djLwhhReport, Model model, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DjLwhhReport> djLwhhReportPage = null;
try {
//设置本地默认查询时间
resetTime(djLwhhReport);
djReportService.queryConditionCheck(thread, start, djLwhhReport, DjLwhhReport.class, page);
// 查询数据库
djLwhhReportPage = djReportService
.findDjLwhhReport(new Page<DjLwhhReport>(request, response, DjLwhhReport.class), djLwhhReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测来文函号(带私有标签)实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测来文函号(带私有标签)实时统计成功",
djLwhhReportPage, activeSys, logSource);
}
@RequestMapping(value = "djTagPrivServiceReportSources", method = RequestMethod.GET)
@ApiOperation(value = "监测标签(带私有标签)实时统计", httpMethod = "GET", notes = "get log list")
public Map djTagPrivServiceReportSources(Page page, DjTagReport djTagReport, Model model, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
null);
Page<DjTagReport> djTagReportPage = null;
try {
//设置本地默认查询时间
resetTime(djTagReport);
djReportService.queryConditionCheck(thread, start, djTagReport, DjTagReport.class, page);
// 查询数据库
djTagReportPage = djReportService
.findDjTagReportPage(new Page<DjTagReport>(request, response, DjTagReport.class), djTagReport);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.debug(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测标签(带私有标签)实时统计失败");
}
((RestServiceException) e).setLogSource(logSource);
((RestServiceException) e).setActiveSys(activeSys);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "监测标签(带私有标签)实时统计成功",
djTagReportPage, activeSys, logSource);
}
/**
*
* @Title: resetTime
* @Description: (实时统计默认查询本地一个小时的数据)
* @param @param entity
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
public void resetTime(DfReportEntity<?> entity) throws Exception {
Map<String, String> map = DateUtils.getLocalTime(entity.getSearchReportStartTime(),
entity.getSearchReportEndTime(), Constants.REPORT_LOCAL_TIME,"report");
entity.setSearchReportStartTime(map.get("startTime"));
entity.setSearchReportEndTime(map.get("endTime"));
}
}

View File

@@ -0,0 +1,791 @@
/**
* @Title: DjStatLogController.java
* @Package com.nis.web.controller
* @Description: TODO(用一句话描述该文件做什么)
* @author ddm
* @date 2016年9月13日 下午1:22:15
* @version V1.0
*/
package com.nis.web.controller.restful;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.Page;
import com.nis.domain.StatLogEntity;
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.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.DateUtils;
import com.nis.util.JsonMapper;
import com.nis.util.StringUtil;
import com.nis.util.redis.RedisDao;
import com.nis.util.redis.SaveRedisThread;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DjStatLogService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: DjStatLogController
* @Description: TODO(这里用一句话描述这个类的作用)
* @author (ddm)
* @date 2016年9月13日 下午1:22:15
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/log/v1")
@SuppressWarnings({ "rawtypes", "unchecked" })
public class DjStatLogController extends BaseRestController{
protected final Logger logger = Logger.getLogger(this.getClass());
protected String logSource="0";
protected String activeSys=Constants.ACTIVESYS_ALL;
@Autowired
protected DjStatLogService djStatLogService;
@Autowired
protected RedisDao redisDao;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@RequestMapping(value="djStatLogDailySources", method = RequestMethod.GET)
@ApiOperation(value="监测日志配置日报表" , httpMethod = "GET", notes="get log list")
public Map djStatLogDailySources(
Page page,DjStatLogDaily dailyLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DjStatLogDaily> dailyLogPage =null;
try {
resetTime(dailyLog, "daily");
if (!StringUtil.isBlank(dailyLog.getSearchConfigId())) {
Long.parseLong(dailyLog.getSearchConfigId());
}
djStatLogService.queryConditionCheck(thread,start,dailyLog, DjStatLogDaily.class, page);
dailyLogPage = djStatLogService.djStatLogDaily(new Page<DjStatLogDaily>(request, response,DjStatLogDaily.class), dailyLog);
} catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
RestServiceException restE = new RestServiceException(thread, System.currentTimeMillis() - start,
"SearchConfigId参数格式错误", RestBusinessCode.param_formate_error.getValue());
restE.setActiveSys(activeSys);
restE.setLogSource(logSource);
throw restE;
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"监测日志配置日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "监测日志配置日报表检索成功",dailyLogPage,activeSys,logSource);
}
@RequestMapping(value="djStatLogMonthSources", method = RequestMethod.GET)
@ApiOperation(value="监测日志配置月报表" , httpMethod = "GET", notes="get log list")
public Map djStatLogMonthSources(
Page page,DjStatLogMonth monthLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DjStatLogMonth> monthLogPage =null;
try {
resetTime(monthLog, "month");
if (!StringUtil.isBlank(monthLog.getSearchConfigId())) {
Long.parseLong(monthLog.getSearchConfigId());
}
//查询条件校验
djStatLogService.queryConditionCheck(thread,start,monthLog, DjStatLogMonth.class, page);
monthLogPage = djStatLogService.djStatLogMonth(new Page<DjStatLogMonth>(request, response,DjStatLogMonth.class), monthLog);
}catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
RestServiceException restE = new RestServiceException(thread, System.currentTimeMillis() - start,
"SearchConfigId参数格式错误", RestBusinessCode.param_formate_error.getValue());
restE.setActiveSys(activeSys);
restE.setLogSource(logSource);
throw restE;
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"监测日志配置月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "监测日志配置月报表检索成功",monthLogPage,activeSys,logSource);
}
/**
* 标签日报表
*
* @Title: djTagStatLogDailySources
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="djTagStatLogDailySources", method = RequestMethod.GET)
@ApiOperation(value="标签监测日志配置日报表" , httpMethod = "GET", notes="get log list")
public Map djTagStatLogDailySources(
Page page,DjTagStatLogDaily dailyLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
//查询条件校验
Page<DjTagStatLogDaily> dailyLogPage =null;
try {
resetTime(dailyLog, "daily");
if (!StringUtil.isBlank(dailyLog.getSearchTag())) {
Integer.parseInt(dailyLog.getSearchTag());
}
djStatLogService.queryConditionCheck(thread,start,dailyLog, DjTagStatLogDaily.class, page);
dailyLogPage = djStatLogService.djTagStatLogDaily(new Page<DjTagStatLogDaily>(request, response,DjTagStatLogDaily.class), dailyLog);
}catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
RestServiceException restE = new RestServiceException(thread, System.currentTimeMillis() - start,
"SearchTag参数格式错误", RestBusinessCode.param_formate_error.getValue());
restE.setActiveSys(activeSys);
restE.setLogSource(logSource);
throw restE;
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"标签监测日志配置日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "标签监测日志配置日报表检索成功",dailyLogPage,activeSys,logSource);
}
/**
* 标签月报表
*
* @Title: djTagStatLogDailySources
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="djTagStatLogMonthSources", method = RequestMethod.GET)
@ApiOperation(value="标签监测日志配置月报表" , httpMethod = "GET", notes="get log list")
public Map djTagStatLogMonthSources(
Page page,DjTagStatLogMonth monthLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DjTagStatLogMonth> monthLogPage =null;
try {
resetTime(monthLog, "month");
if (!StringUtil.isBlank(monthLog.getSearchTag())) {
Integer.parseInt(monthLog.getSearchTag());
}
//查询条件校验
djStatLogService.queryConditionCheck(thread,start,monthLog, DjTagStatLogMonth.class, page);
monthLogPage = djStatLogService.djTagStatLogMonth(new Page<DjTagStatLogMonth>(request, response,DjTagStatLogMonth.class), monthLog);
}catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
RestServiceException restE = new RestServiceException(thread, System.currentTimeMillis() - start,
"SearchTag参数格式错误", RestBusinessCode.param_formate_error.getValue());
restE.setActiveSys(activeSys);
restE.setLogSource(logSource);
throw restE;
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"标签监测日志配置月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "标签监测日志配置月报表检索成功",monthLogPage,activeSys,logSource);
}
/**
* @Title: djTagStatLogDailySources
* @Description: (性质日报表)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="djAttrStatLogDailySources", method = RequestMethod.GET)
@ApiOperation(value="性质监测日志配置日报表" , httpMethod = "GET", notes="get log list")
public Map djAttrStatLogDailySources(
Page page,DjAttrStatLogDaily dailyLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DjAttrStatLogDaily> dailyLogPage =null;
try {
resetTime(dailyLog, "daily");
if (!StringUtil.isBlank(dailyLog.getSearchAttrType())) {
Integer.parseInt(dailyLog.getSearchAttrType());
}
djStatLogService.queryConditionCheck(thread,start,dailyLog, DjAttrStatLogDaily.class, page);
dailyLogPage = djStatLogService.djAttrStatLogDaily(new Page<DjAttrStatLogDaily>(request, response,DjAttrStatLogDaily.class), dailyLog);
}catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
RestServiceException restE = new RestServiceException(thread, System.currentTimeMillis() - start,
"SearchAttrType参数格式错误", RestBusinessCode.param_formate_error.getValue());
restE.setActiveSys(activeSys);
restE.setLogSource(logSource);
throw restE;
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"性质监测日志配置日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "性质监测日志配置日报表检索成功",dailyLogPage,activeSys,logSource);
}
/**
* @Title: djAttrStatLogDailySources
* @Description: (性质月报表)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="djAttrStatLogMonthSources", method = RequestMethod.GET)
@ApiOperation(value="性质监测日志配置月报表" , httpMethod = "GET", notes="get log list")
public Map djAttrStatLogMonthSources(
Page page,DjAttrStatLogMonth monthLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DjAttrStatLogMonth> monthLogPage =null;
try {
resetTime(monthLog, "month");
if (!StringUtil.isBlank(monthLog.getSearchAttrType())) {
Integer.parseInt(monthLog.getSearchAttrType());
}
//查询条件校验
djStatLogService.queryConditionCheck(thread,start,monthLog, DjAttrStatLogMonth.class, page);
monthLogPage = djStatLogService.djAttrStatLogMonth(new Page<DjAttrStatLogMonth>(request, response,DjAttrStatLogMonth.class), monthLog);
}catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
RestServiceException restE = new RestServiceException(thread, System.currentTimeMillis() - start,
"SearchAttrType参数格式错误", RestBusinessCode.param_formate_error.getValue());
restE.setActiveSys(activeSys);
restE.setLogSource(logSource);
throw restE;
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"性质监测日志配置月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "性质监测日志配置月报表检索成功",monthLogPage,activeSys,logSource);
}
/**
* @Title: djEntrStatLogDailySources
* @Description: (局点日报表)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="djEntrStatLogDailySources", method = RequestMethod.GET)
@ApiOperation(value="局点监测日志配置日报表" , httpMethod = "GET", notes="get log list")
public Map djEntrStatLogDailySources(
Page page,DjEntrStatLogDaily dailyLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DjEntrStatLogDaily> dailyLogPage =null;
try {
resetTime(dailyLog, "daily");
if (!StringUtil.isBlank(dailyLog.getSearchEntranceId())) {
Integer.parseInt(dailyLog.getSearchEntranceId());
}
djStatLogService.queryConditionCheck(thread,start,dailyLog, DjEntrStatLogDaily.class, page);
dailyLogPage = djStatLogService.djEntrStatLogDaily(new Page<DjEntrStatLogDaily>(request, response,DjEntrStatLogDaily.class), dailyLog);
}catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
RestServiceException restE = new RestServiceException(thread, System.currentTimeMillis() - start,
"SearchEntranceId参数格式错误", RestBusinessCode.param_formate_error.getValue());
restE.setActiveSys(activeSys);
restE.setLogSource(logSource);
throw restE;
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"局点监测日志配置日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "局点监测日志配置日报表检索成功",dailyLogPage,activeSys,logSource);
}
/**
* @Title: djEntrStatLogDailySources
* @Description: (局点月报表)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="djEntrStatLogMonthSources", method = RequestMethod.GET)
@ApiOperation(value="局点监测日志配置月报表" , httpMethod = "GET", notes="get log list")
public Map djEntrStatLogMonthSources(
Page page,DjEntrStatLogMonth monthLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DjEntrStatLogMonth> monthLogPage =null;
try {
resetTime(monthLog, "month");
if (!StringUtil.isBlank(monthLog.getSearchEntranceId())) {
Integer.parseInt(monthLog.getSearchEntranceId());
}
//查询条件校验
djStatLogService.queryConditionCheck(thread,start,monthLog, DjEntrStatLogMonth.class, page);
monthLogPage = djStatLogService.djEntrStatLogMonth(new Page<DjEntrStatLogMonth>(request, response,DjEntrStatLogMonth.class), monthLog);
}catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
RestServiceException restE = new RestServiceException(thread, System.currentTimeMillis() - start,
"SearchEntranceId参数格式错误", RestBusinessCode.param_formate_error.getValue());
restE.setActiveSys(activeSys);
restE.setLogSource(logSource);
throw restE;
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"局点监测日志配置月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "局点监测日志配置月报表检索成功",monthLogPage,activeSys,logSource);
}
/**
* @Title: djLwhhStatLogDailySources
* @Description: (局点日报表)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="djLwhhStatLogDailySources", method = RequestMethod.GET)
@ApiOperation(value="来文函号监测日志配置日报表" , httpMethod = "GET", notes="get log list")
public Map djLwhhStatLogDailySources(
Page page,DjLwhhStatLogDaily dailyLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
//查询条件校验
Page<DjLwhhStatLogDaily> dailyLogPage =null;
try {
resetTime(dailyLog, "daily");
if (!StringUtil.isBlank(dailyLog.getSearchLwhh())) {
Integer.parseInt(dailyLog.getSearchLwhh());
}
djStatLogService.queryConditionCheck(thread,start,dailyLog, DjLwhhStatLogDaily.class, page);
dailyLogPage = djStatLogService.djLwhhStatLogDaily(new Page<DjLwhhStatLogDaily>(request, response,DjLwhhStatLogDaily.class), dailyLog);
}catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
RestServiceException restE = new RestServiceException(thread, System.currentTimeMillis() - start,
"SearchLwhh参数格式错误", RestBusinessCode.param_formate_error.getValue());
restE.setActiveSys(activeSys);
restE.setLogSource(logSource);
throw restE;
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"来文函号监测日志配置日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "来文函号监测日志配置日报表检索成功",dailyLogPage,activeSys,logSource);
}
/**
* @Title: djLwhhStatLogDailySources
* @Description: (局点月报表)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="djLwhhStatLogMonthSources", method = RequestMethod.GET)
@ApiOperation(value="来文函号监测日志配置月报表" , httpMethod = "GET", notes="get log list")
public Map djLwhhStatLogMonthSources(
Page page,DjLwhhStatLogMonth monthLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DjLwhhStatLogMonth> monthLogPage =null;
try {
resetTime(monthLog, "month");
if (!StringUtil.isBlank(monthLog.getSearchLwhh())) {
Integer.parseInt(monthLog.getSearchLwhh());
}
//查询条件校验
djStatLogService.queryConditionCheck(thread,start,monthLog, DjLwhhStatLogMonth.class, page);
monthLogPage = djStatLogService.djLwhhStatLogMonth(new Page<DjLwhhStatLogMonth>(request, response,DjLwhhStatLogMonth.class), monthLog);
}catch (NumberFormatException e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
RestServiceException restE = new RestServiceException(thread, System.currentTimeMillis() - start,
"SearchLwhh参数格式错误", RestBusinessCode.param_formate_error.getValue());
restE.setActiveSys(activeSys);
restE.setLogSource(logSource);
throw restE;
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"来文函号监测日志配置月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "来文函号监测日志配置月报表检索成功",monthLogPage,activeSys,logSource);
}
/**
* 境内源IP日报表
*
* @Title: djSrcIpDomesticStatLogDailySources
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="djSrcIpDomesticStatLogDailySources", method = RequestMethod.GET)
@ApiOperation(value="境内源IP监测日志配置日报表" , httpMethod = "GET", notes="get log list")
public Map djSrcIpDomesticStatLogDailySources(
Page page,DjSrcIpDomesticStatLogDaily dailyLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DjSrcIpDomesticStatLogDaily> dailyLogPage =null;
try {
resetTime(dailyLog, "daily");
djStatLogService.queryConditionCheck(thread,start,dailyLog, DjSrcIpDomesticStatLogDaily.class, page);
dailyLogPage = djStatLogService.djSrcIpDomesticStatLogDaily(new Page<DjSrcIpDomesticStatLogDaily>(request, response,DjSrcIpDomesticStatLogDaily.class), dailyLog);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"境内源IP监测日志配置日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "境内源IP监测日志配置日报表检索成功",dailyLogPage,activeSys,logSource);
}
/**
* 境内源IP月报表
*
* @Title: djSrcIpDomesticStatLogMonthSources
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="djSrcIpDomesticStatLogMonthSources", method = RequestMethod.GET)
@ApiOperation(value="境内源IP监测日志配置月报表" , httpMethod = "GET", notes="get log list")
public Map djSrcIpDomesticStatLogMonthSources(
Page page,DjSrcIpDomesticStatLogMonth monthLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DjSrcIpDomesticStatLogMonth> monthLogPage =null;
try {
resetTime(monthLog, "month");
//查询条件校验
djStatLogService.queryConditionCheck(thread,start,monthLog, DjSrcIpDomesticStatLogMonth.class, page);
monthLogPage = djStatLogService.djSrcIpDomesticStatLogMonth(new Page<DjSrcIpDomesticStatLogMonth>(request, response,DjSrcIpDomesticStatLogMonth.class), monthLog);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"境内源IP监测日志配置月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "境内源IP监测日志配置月报表检索成功",monthLogPage,activeSys,logSource);
}
/**
* 国家目的IP日报表
*
* @Title: djDestIpCounrtyStatLogDailySources
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="djDestIpCountryStatLogDailySources", method = RequestMethod.GET)
@ApiOperation(value="国家目的IP监测日志配置日报表" , httpMethod = "GET", notes="get log list")
public Map djDestIpCounrtyStatLogDailySources(
Page page,DjDestIpCounrtyStatLogDaily dailyLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DjDestIpCounrtyStatLogDaily> dailyLogPage =null;
try {
resetTime(dailyLog, "daily");
djStatLogService.queryConditionCheck(thread,start,dailyLog, DjDestIpCounrtyStatLogDaily.class, page);
dailyLogPage = djStatLogService.djDestIpCounrtyStatLogDaily(new Page<DjDestIpCounrtyStatLogDaily>(request, response,DjDestIpCounrtyStatLogDaily.class), dailyLog);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"国家目的IP监测日志配置日报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "国家目的IP监测日志配置日报表检索成功",dailyLogPage,activeSys,logSource);
}
/**
* 国家目的IP月报表
*
* @Title: djDestIpCounrtyStatLogMonthSources
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param page
* @param @param dailyLog
* @param @param request
* @param @param response
* @param @return
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
@RequestMapping(value="djDestIpCountryStatLogMonthSources", method = RequestMethod.GET)
@ApiOperation(value="国家目的IP监测日志配置月报表" , httpMethod = "GET", notes="get log list")
public Map djDestIpCounrtyStatLogMonthSources(
Page page,DjDestIpCounrtyStatLogMonth monthLog, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
Page<DjDestIpCounrtyStatLogMonth> monthLogPage =null;
try {
resetTime(monthLog, "month");
//查询条件校验
djStatLogService.queryConditionCheck(thread,start,monthLog, DjDestIpCounrtyStatLogMonth.class, page);
monthLogPage = djStatLogService.djDestIpCounrtyStatLogMonth(new Page<DjDestIpCounrtyStatLogMonth>(request, response,DjDestIpCounrtyStatLogMonth.class), monthLog);
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(!(e instanceof RestServiceException)){
e=new RestServiceException(thread,System.currentTimeMillis()-start,"国家目的IP监测日志配置月报表检索失败");
}
((RestServiceException) e).setActiveSys(activeSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "国家目的IP监测日志配置月报表检索成功",monthLogPage,activeSys,logSource);
}
/**
*
* @Title: resetTime
* @Description: (日报表默认查询本地前一天的数据)
* @param @param entity
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
public void resetTime(StatLogEntity<?> entity,String type) throws Exception{
Map<String, String> map = DateUtils.getLocalTime(entity.getSearchStatStartTime(),
entity.getSearchStatEndTime(), Constants.REPORT_LOCAL_TIME,type);
entity.setSearchStatStartTime(map.get("startTime"));
entity.setSearchStatEndTime(map.get("endTime"));
}
}

View File

@@ -0,0 +1,223 @@
/**
*@Title: DmbCkController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author wx
*@date 2016年9月7日 下午3:58:16
*@version 版本号
*/
package com.nis.web.controller.restful;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.DmbCk;
import com.nis.domain.restful.DmbCkSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DmbCkService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: DmbCkController.java
* @Description: TODO
* @author (wx)
* @date 2016年9月7日 下午3:58:16
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/cfg/v1")
public class DmbCkController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected DmbCkService dmbCkService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
// @Autowired
// protected CommonConfigService commonConfigService;
// @Autowired
// protected RedisDao redisDao;
/**
* saveDmbCkBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param DmbCkSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dmbCkSources", method = RequestMethod.POST)
@ApiOperation(value = "保存运营商信息", httpMethod = "POST", notes = "save provider info")
public Map saveDmbCkBatch(@RequestBody DmbCkSource dmbCkSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, dmbCkSource);
super.checkOpAction(thread,System.currentTimeMillis()-start, dmbCkSource.getOpAction(), Constants.OPACTION_POST);
try{
this.chekckData(dmbCkSource);
dmbCkService.saveDmbCkBatch(dmbCkSource.getDmbCkList());
// commonConfigService.saveOrUpdateConfigState("DMB_CK", dmbCkSource.getOpTime());
// redisDao.saveMaps(dmbCkSource.getDmbCkList(), "DMB_CK", DmbCk.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存运营商信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存运营商信息成功",dmbCkSource.getDmbCkList());
}
/**
*
* updateDmbCkBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param DmbCkSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dmbCkSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新运营商信息", httpMethod = "PUT", notes = "update provider info")
public Map updateDmbCkBatch(@RequestBody DmbCkSource dmbCkSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, dmbCkSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dmbCkSource.getOpAction(), Constants.OPACTION_PUT);
try{
this.chekckData(dmbCkSource);
dmbCkService.updateDmbCkBatch(dmbCkSource.getDmbCkList());
// commonConfigService.saveOrUpdateConfigState("DMB_CK", dmbCkSource.getOpTime());
// redisDao.updateMaps(dmbCkSource.getDmbCkList(), "DMB_CK", DmbCk.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新运营商信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新运营商信息成功",dmbCkSource.getDmbCkList());
}
/**
*
* deleteDmbCk(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dmbCkSources/{id}", method = RequestMethod.DELETE)
@ApiOperation(value = "删除运营商信息", httpMethod = "DELETE", notes = "delete provider info")
public Map deleteDmbCk(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
dmbCkService.removeDmbCk(id);
// commonConfigService.saveOrUpdateConfigState("DMB_CK", new Date());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除运营商信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteDmbCk(多条删除)
* (这里描述这个方法适用条件 可选)
* @param DmbCkSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dmbCkSources", method = RequestMethod.DELETE)
@ApiOperation(value = "删除运营商信息", httpMethod = "DELETE", notes = "delete provider info")
public Map deleteDmbCk(@RequestBody DmbCkSource dmbCkSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, dmbCkSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dmbCkSource.getOpAction(), Constants.OPACTION_DELETE);
try{
dmbCkService.removeDmbCkBatch(dmbCkSource.getDmbCkList());
// commonConfigService.saveOrUpdateConfigState("DMB_CK", dmbCkSource.getOpTime());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除运营商信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",dmbCkSource.getDmbCkList());
}
/**
*
* chekckData(操作验证时间)
* (这里描述这个方法适用条件 可选)
* @param entity
* @return
*boolean
* @exception
* @since 1.0.0
*/
private void chekckData(DmbCkSource entity){
Date now=new Date();
for(DmbCk dmbCk :entity.getDmbCkList()){
dmbCk.setLastUpdate(now);
if(dmbCk.getOpTime()==null)
dmbCk.setOpTime(entity.getOpTime());
}
}
}

View File

@@ -0,0 +1,223 @@
/**
*@Title: DmbPortController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author wx
*@date 2016年9月7日 下午3:58:16
*@version 版本号
*/
package com.nis.web.controller.restful;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.DmbPort;
import com.nis.domain.restful.DmbPortSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DmbPortService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: DmbPortController.java
* @Description: TODO
* @author (wx)
* @date 2016年9月7日 下午3:58:16
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/cfg/v1")
public class DmbPortController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected DmbPortService dmbPortService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
// @Autowired
// protected CommonConfigService commonConfigService;
// @Autowired
// protected RedisDao redisDao;
/**
* saveDmbPortBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param DmbPortSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dmbPortSources", method = RequestMethod.POST)
@ApiOperation(value = "保存运营商端口信息", httpMethod = "POST", notes = "save provider port info")
public Map saveDmbPortBatch(@RequestBody DmbPortSource dmbPortSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, dmbPortSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dmbPortSource.getOpAction(), Constants.OPACTION_POST);
try{
this.chekckData(dmbPortSource);
dmbPortService.saveDmbPortBatch(dmbPortSource.getDmbPortList());
// commonConfigService.saveOrUpdateConfigState("DMB_PORT", dmbPortSource.getOpTime());
// redisDao.saveMaps(dmbPortSource.getDmbPortList(), "DMB_PORT", DmbPort.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存运营商端口信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存运营商端口信息成功",dmbPortSource.getDmbPortList());
}
/**
*
* updateDmbPortBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param DmbPortSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dmbPortSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新运营商端口信息", httpMethod = "PUT", notes = "update provider port info")
public Map updateDmbPortBatch(@RequestBody DmbPortSource dmbPortSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, dmbPortSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dmbPortSource.getOpAction(), Constants.OPACTION_PUT);
try{
this.chekckData(dmbPortSource);
dmbPortService.updateDmbPortBatch(dmbPortSource.getDmbPortList());
// commonConfigService.saveOrUpdateConfigState("DMB_PORT", dmbPortSource.getOpTime());
// redisDao.updateMaps(dmbPortSource.getDmbPortList(), "DMB_PORT", DmbPort.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新运营商端口信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新运营商端口信息成功",dmbPortSource.getDmbPortList());
}
/**
*
* deleteDmbPort(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dmbPortSources/{id}", method = RequestMethod.DELETE)
@ApiOperation(value = "删除运营商端口信息", httpMethod = "DELETE", notes = "delete provider port info")
public Map deleteDmbPort(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
dmbPortService.removeDmbPort(id);
// commonConfigService.saveOrUpdateConfigState("DMB_PORT", new Date());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除运营商端口信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteDmbPort(多条删除)
* (这里描述这个方法适用条件 可选)
* @param DmbPortSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dmbPortSources", method = RequestMethod.DELETE)
@ApiOperation(value = "删除运营商端口信息", httpMethod = "DELETE", notes = "delete provider port info")
public Map deleteDmbPort(@RequestBody DmbPortSource dmbPortSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, dmbPortSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dmbPortSource.getOpAction(), Constants.OPACTION_DELETE);
try{
dmbPortService.removeDmbPortBatch(dmbPortSource.getDmbPortList());
// commonConfigService.saveOrUpdateConfigState("DMB_PORT", dmbPortSource.getOpTime());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除运营商端口信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",dmbPortSource.getDmbPortList());
}
/**
*
* chekckData(操作验证时间)
* (这里描述这个方法适用条件 可选)
* @param entity
* @return
*boolean
* @exception
* @since 1.0.0
*/
private void chekckData(DmbPortSource entity){
Date now=new Date();
for(DmbPort dmbPort :entity.getDmbPortList()){
dmbPort.setLastUpdate(now);
if(dmbPort.getOpTime()==null)
dmbPort.setOpTime(entity.getOpTime());
}
}
}

View File

@@ -0,0 +1,250 @@
/**
*@Title: DnsFakeInfoController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author wx
*@date 2016年9月7日 下午3:58:16
*@version 版本号
*/
package com.nis.web.controller.restful;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.DnsFakeInfo;
import com.nis.domain.restful.DnsFakeInfoSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DnsFakeInfoService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: DnsFakeInfoController.java
* @Description: TODO
* @author (wx)
* @date 2016年9月7日 下午3:58:16
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/cfg/v1")
public class DnsFakeInfoController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected DnsFakeInfoService dnsFakeInfoService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
// @Autowired
// protected CommonConfigService commonConfigService;
// @Autowired
// protected RedisDao redisDao;
/**
* saveDnsFakeInfoBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param DnsFakeInfoSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsFakeInfoSources", method = RequestMethod.POST)
@ApiOperation(value = "保存DNS欺骗信息", httpMethod = "POST", notes = "save dns fake info")
public Map saveDnsFakeInfoBatch(@RequestBody DnsFakeInfoSource dnsFakeInfoSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, dnsFakeInfoSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsFakeInfoSource.getOpAction(), Constants.OPACTION_POST);
try{
if(chekckData(dnsFakeInfoSource,false)){
dnsFakeInfoService.saveDnsFakeInfoBatch(dnsFakeInfoSource.getDnsFakeInfoList());
// commonConfigService.saveOrUpdateConfigState("DNS_FAKE_INFO", dnsFakeInfoSource.getOpTime());
// redisDao.saveMaps(dnsFakeInfoSource.getDnsFakeInfoList(), "DNS_FAKE_INFO", DnsFakeInfo.class, "id");
}else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存DNS欺骗信息失败,组号不能小于0且2-100组号不可使用",RestBusinessCode.unknow_error.getValue());
}catch(RestServiceException e){
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存DNS欺骗信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存DNS欺骗信息成功",dnsFakeInfoSource.getDnsFakeInfoList());
}
/**
*
* updateDnsFakeInfoBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param DnsFakeInfoSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsFakeInfoSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新DNS欺骗信息", httpMethod = "PUT", notes = "update dns fake info")
public Map updateDnsFakeInfoBatch(@RequestBody DnsFakeInfoSource dnsFakeInfoSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, dnsFakeInfoSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsFakeInfoSource.getOpAction(), Constants.OPACTION_PUT);
try{
if(chekckData(dnsFakeInfoSource,true)){
dnsFakeInfoService.updateDnsFakeInfoBatch(dnsFakeInfoSource.getDnsFakeInfoList());
// commonConfigService.saveOrUpdateConfigState("DNS_FAKE_INFO", dnsFakeInfoSource.getOpTime());
// redisDao.updateMaps(dnsFakeInfoSource.getDnsFakeInfoList(), "DNS_FAKE_INFO", DnsFakeInfo.class, "id");
}else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新DNS欺骗信息失败,组号不能小于0且2-100组号不可使用",RestBusinessCode.unknow_error.getValue());
}catch(RestServiceException e){
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新DNS欺骗信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新DNS欺骗信息成功",dnsFakeInfoSource.getDnsFakeInfoList());
}
/**
*
* deleteDnsFakeInfo(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsFakeInfoSources/{id}", method = RequestMethod.DELETE)
@ApiOperation(value = "删除DNS欺骗信息", httpMethod = "DELETE", notes = "delete dns fake info")
public Map deleteDnsFakeInfo(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
boolean isValid=dnsFakeInfoService.isValid(id);
if(!isValid){
dnsFakeInfoService.removeDnsFakeInfo(id);
// commonConfigService.saveOrUpdateConfigState("DNS_FAKE_INFO", new Date());
}else{
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS欺骗信息失败,不能删除有效的DNS欺骗信息",RestBusinessCode.unknow_error.getValue());
}
}catch(RestServiceException e){
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS欺骗信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteDnsFakeInfo(多条删除)
* (这里描述这个方法适用条件 可选)
* @param DnsFakeInfoSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsFakeInfoSources", method = RequestMethod.DELETE)
@ApiOperation(value = "删除DNS欺骗信息", httpMethod = "DELETE", notes = "delete dns fake info")
public Map deleteDnsFakeInfo(@RequestBody DnsFakeInfoSource dnsFakeInfoSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, dnsFakeInfoSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsFakeInfoSource.getOpAction(), Constants.OPACTION_DELETE);
try{
boolean isValid=dnsFakeInfoService.isValid(dnsFakeInfoSource.getDnsFakeInfoList());
if(isValid){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS欺骗信息失败,包含有效的DNS欺骗信息",RestBusinessCode.unknow_error.getValue());
}else{
dnsFakeInfoService.removeDnsFakeInfoBatch(dnsFakeInfoSource.getDnsFakeInfoList());
// commonConfigService.saveOrUpdateConfigState("DNS_FAKE_INFO", dnsFakeInfoSource.getOpTime());
}
}catch(RestServiceException e){
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS欺骗信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",dnsFakeInfoSource.getDnsFakeInfoList());
}
/**
*
* chekckData(0-1组号以及100以外的组号可以使用)
* (这里描述这个方法适用条件 可选)
* @param entityList
* @param update 是否是更新请求
* @return
*boolean
* @exception
* @since 1.0.0
*/
private boolean chekckData(DnsFakeInfoSource entity,boolean update){
int ok=1;
Date now=new Date();
for(DnsFakeInfo dnsFakeInfo :entity.getDnsFakeInfoList()){
dnsFakeInfo.setLastUpdate(now);
if(dnsFakeInfo.getOpTime()==null)
dnsFakeInfo.setOpTime(entity.getOpTime());
// if(update&&dnsFakeInfo.getGroupId()==null)continue;
// if(dnsFakeInfo.getGroupId().intValue()<0||(2<dnsFakeInfo.getGroupId().intValue()&&dnsFakeInfo.getGroupId().intValue()<=100)){
// ok=0;
// break;
// }
}
return ok==1;
}
}

View File

@@ -0,0 +1,249 @@
/**
*@Title: DnsFakeIpController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author wx
*@date 2016年9月7日 下午3:58:16
*@version 版本号
*/
package com.nis.web.controller.restful;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.DnsFakeIp;
import com.nis.domain.restful.DnsFakeIpSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DnsFakeIpService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: DnsFakeIpController.java
* @Description: TODO
* @author (dell)
* @date 2016年9月7日 下午3:58:16
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/cfg/v1")
public class DnsFakeIpController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected DnsFakeIpService dnsFakeIpService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
// @Autowired
// protected RedisDao redisDao;
/**
* saveDnsFakeIpBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param DnsFakeIpSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsFakeIpSources", method = RequestMethod.POST)
@ApiOperation(value = "保存DNS欺骗IP地址", httpMethod = "POST", notes = "save dns fake ip")
public Map saveDnsFakeIpBatch(@RequestBody DnsFakeIpSource dnsFakeIpSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, dnsFakeIpSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsFakeIpSource.getOpAction(), Constants.OPACTION_POST);
try{
if(chekckData(dnsFakeIpSource,false)){
dnsFakeIpService.saveDnsFakeIpBatch(dnsFakeIpSource.getDnsFakeIpList());
}else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存DNS欺骗IP地址失败,组号不能小于0且2-100组号不可使用",RestBusinessCode.unknow_error.getValue());
}catch(RestServiceException e){
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存DNS欺骗IP地址失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存DNS欺骗IP地址成功",dnsFakeIpSource.getDnsFakeIpList());
}
/**
*
* updateDnsFakeIpBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param DnsFakeIpSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsFakeIpSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新DNS欺骗IP地址", httpMethod = "PUT", notes = "update dns fake ip")
public Map updateDnsFakeIpBatch(@RequestBody DnsFakeIpSource dnsFakeIpSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, dnsFakeIpSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsFakeIpSource.getOpAction(), Constants.OPACTION_PUT);
try{
if(chekckData(dnsFakeIpSource,true)){
dnsFakeIpService.updateDnsFakeIpBatch(dnsFakeIpSource.getDnsFakeIpList());
// redisDao.updateMaps(dnsFakeIpSource.getDnsFakeIpList(), "DNS_FAKE_IP", DnsFakeIp.class, "id");
}else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新DNS欺骗IP地址失败,组号不能小于0且2-100组号不可使用",RestBusinessCode.unknow_error.getValue());
}catch(RestServiceException e){
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新DNS欺骗IP地址失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新DNS欺骗IP地址成功",dnsFakeIpSource.getDnsFakeIpList());
}
/**
*
* deleteDnsFakeIp(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsFakeIpSources/{id}", method = RequestMethod.DELETE)
@ApiOperation(value = "删除DNS欺骗IP地址", httpMethod = "DELETE", notes = "delete dns fake ip")
public Map deleteDnsFakeIp(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
boolean isValid=dnsFakeIpService.isValid(id);
if(!isValid){
dnsFakeIpService.removeDnsFakeIp(id);
// commonConfigService.saveOrUpdateConfigState("DNS_FAKE_IP", new Date());
}else{
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS欺骗IP地址失败,不能删除有效的DNS欺骗IP地址",RestBusinessCode.unknow_error.getValue());
}
}catch(RestServiceException e){
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS欺骗IP地址失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteDnsFakeIp(多条删除)
* (这里描述这个方法适用条件 可选)
* @param DnsFakeIpSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsFakeIpSources", method = RequestMethod.DELETE)
@ApiOperation(value = "删除DNS欺骗IP地址", httpMethod = "DELETE", notes = "delete dns fake ip")
public Map deleteDnsFakeIp(@RequestBody DnsFakeIpSource dnsFakeIpSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, dnsFakeIpSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsFakeIpSource.getOpAction(), Constants.OPACTION_DELETE);
try{
boolean isValid=dnsFakeIpService.isValid(dnsFakeIpSource.getDnsFakeIpList());
if(isValid){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS欺骗IP地址失败,包含有效的DNS欺骗IP地址",RestBusinessCode.unknow_error.getValue());
}else{
dnsFakeIpService.removeDnsFakeIpBatch(dnsFakeIpSource.getDnsFakeIpList());
// commonConfigService.saveOrUpdateConfigState("DNS_FAKE_IP", dnsFakeIpSource.getOpTime());
}
}catch(RestServiceException e){
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS欺骗IP地址失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",dnsFakeIpSource.getDnsFakeIpList());
}
/**
*
* chekckData(0-1组号以及100以外的组号可以使用)
* (这里描述这个方法适用条件 可选)
* @param entityList
* @param update 是否是更新请求
* @return
*boolean
* @exception
* @since 1.0.0
*/
private boolean chekckData(DnsFakeIpSource entity,boolean update){
int ok=1;
Date now=new Date();
for(DnsFakeIp dnsFakeIp :entity.getDnsFakeIpList()){
dnsFakeIp.setLastUpdate(now);
if(dnsFakeIp.getOpTime()==null)
dnsFakeIp.setOpTime(entity.getOpTime());
if(!update){//insert需要判断默认值保存完毕返回完整对象
if(dnsFakeIp.getProtocol()==null)dnsFakeIp.setProtocol(0);
if(dnsFakeIp.getDirection()==null)dnsFakeIp.setDirection(0);
}
if(update&&dnsFakeIp.getGroupId()==null)continue;
if(dnsFakeIp.getGroupId().intValue()<0||(2<dnsFakeIp.getGroupId().intValue()&&dnsFakeIp.getGroupId().intValue()<=100)){
ok=0;
break;
}
}
return ok==1;
}
}

View File

@@ -0,0 +1,249 @@
/**
*@Title: DnsGroupTypeController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author dell
*@date 2016年9月7日 下午3:58:16
*@version 版本号
*/
package com.nis.web.controller.restful;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.DnsGroupType;
import com.nis.domain.restful.DnsGroupTypeSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DnsGroupTypeService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: DnsGroupTypeController.java
* @Description: TODO
* @author (dell)
* @date 2016年9月7日 下午3:58:16
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/cfg/v1")
public class DnsGroupTypeController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected DnsGroupTypeService dnsGroupTypeService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
// @Autowired
// protected CommonConfigService commonConfigService;
// @Autowired
// protected RedisDao redisDao;
/**
*
* saveDnsGroupTypeBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param DnsGroupTypeSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsGroupTypeSources", method = RequestMethod.POST)
@ApiOperation(value = "保存DNS分组类型", httpMethod = "POST", notes = "save dns group type")
public Map saveDnsGroupTypeBatch(@RequestBody DnsGroupTypeSource dnsGroupTypeSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, dnsGroupTypeSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsGroupTypeSource.getOpAction(), Constants.OPACTION_POST);
try{
// if(chekckData(dnsGroupTypeSource/*,false*/))
chekckData(thread,start,dnsGroupTypeSource,Constants.OPACTION_POST);
dnsGroupTypeService.saveDnsGroupTypeBatch(thread,start,dnsGroupTypeSource.getDnsGroupTypeList());
// commonConfigService.saveOrUpdateConfigState("DNS_GROUP_TYPE", dnsGroupTypeSource.getOpTime());
// redisDao.saveMaps(dnsGroupTypeSource.getDnsGroupTypeList(), "DNS_GROUP_TYPE", DnsGroupType.class, "id");
// else
// throw new RestServiceException("保存DNS分组类型失败,组号不能小于0且2-100组号不可使用",RestBusinessCode.unknow_error.getValue());
}catch(RestServiceException e){
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存DNS分组类型失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存DNS分组类型成功",dnsGroupTypeSource.getDnsGroupTypeList());
}
/**
*
* updateDnsGroupTypeBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param DnsGroupTypeSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsGroupTypeSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新DNS分组类型", httpMethod = "PUT", notes = "update dns group type")
public Map updateDnsGroupTypeBatch(@RequestBody DnsGroupTypeSource dnsGroupTypeSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, dnsGroupTypeSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsGroupTypeSource.getOpAction(), Constants.OPACTION_PUT);
try{
// if(chekckData(dnsGroupTypeSource/*,true*/))
chekckData(thread,start,dnsGroupTypeSource,Constants.OPACTION_PUT);
dnsGroupTypeService.updateDnsGroupTypeBatch(thread,start,dnsGroupTypeSource.getDnsGroupTypeList());
// commonConfigService.saveOrUpdateConfigState("DNS_GROUP_TYPE", dnsGroupTypeSource.getOpTime());
// redisDao.updateMaps(dnsGroupTypeSource.getDnsGroupTypeList(), "DNS_GROUP_TYPE", DnsGroupType.class, "id");
// else
// throw new RestServiceException("更新DNS分组类型失败,组号不能小于0且2-100组号不可使用",RestBusinessCode.unknow_error.getValue());
}catch(RestServiceException e){
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新DNS分组类型失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新DNS分组类型成功",dnsGroupTypeSource.getDnsGroupTypeList());
}
/**
*
* deleteDnsGroupType(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsGroupTypeSources/{id}", method = RequestMethod.DELETE)
@ApiOperation(value = "删除DNS分组类型", httpMethod = "DELETE", notes = "delete dns group type")
public Map deleteDnsGroupType(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
boolean isValid=dnsGroupTypeService.isValid(id);
if(!isValid){
dnsGroupTypeService.removeDnsGroupType(id);
// commonConfigService.saveOrUpdateConfigState("DNS_GROUP_TYPE", new Date());
}else{
throw new RestServiceException(thread,System.currentTimeMillis()-start,"不能删除有效的DNS分组类型");
}
}catch(RestServiceException e){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS分组类型失败,"+e.getMessage(), RestBusinessCode.unknow_error.getValue());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS分组类型失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteDnsGroupType(多条删除)
* (这里描述这个方法适用条件 可选)
* @param DnsGroupTypeSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsGroupTypeSources", method = RequestMethod.DELETE)
@ApiOperation(value = "删除DNS分组类型", httpMethod = "DELETE", notes = "delete dns group type")
public Map deleteDnsGroupType(@RequestBody DnsGroupTypeSource dnsGroupTypeSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, dnsGroupTypeSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsGroupTypeSource.getOpAction(), Constants.OPACTION_DELETE);
try{
boolean isValid=dnsGroupTypeService.isValid(dnsGroupTypeSource.getDnsGroupTypeList());
if(isValid){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"包含有效的DNS分组类型");
}else{
dnsGroupTypeService.removeDnsGroupTypeBatch(dnsGroupTypeSource.getDnsGroupTypeList());
// commonConfigService.saveOrUpdateConfigState("DNS_GROUP_TYPE", dnsGroupTypeSource.getOpTime());
}
}catch(RestServiceException e){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS分组类型失败,"+e.getMessage(), RestBusinessCode.unknow_error.getValue());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS分组类型失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",dnsGroupTypeSource.getDnsGroupTypeList());
}
/**
*
* chekckData(0-1组号以及100以外的组号可以使用)
* (这里描述这个方法适用条件 可选)
* @param entityList
* @param update 是否是更新请求
* @return
*boolean
* @exception
* @since 1.0.0
*/
private void chekckData(SaveRequestLogThread thread,long start,DnsGroupTypeSource entity,int opAction){
for(DnsGroupType dnsGroupType :entity.getDnsGroupTypeList()){
if(dnsGroupType.getOpTime()==null)
dnsGroupType.setOpTime(entity.getOpTime());
if(opAction==Constants.OPACTION_PUT&&dnsGroupType.getGroupId()==null)continue;
else if(dnsGroupType.getGroupId()==null){
throw new RestServiceException(thread, System.currentTimeMillis(), "组号为空", RestBusinessCode.missing_args.getValue());
}else if(dnsGroupType.getGroupId().intValue()<=100){
throw new RestServiceException(thread, System.currentTimeMillis(), "组号小于等于100", RestBusinessCode.wrong_range.getValue());
}
}
}
}

View File

@@ -0,0 +1,262 @@
/**
*@Title: DnsResponseStrategy.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author dell
*@date 2016年9月5日 下午4:12:27
*@version 版本号
*/
package com.nis.web.controller.restful;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.DnsResponseStrategy;
import com.nis.domain.restful.DnsResponseStrategySource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DnsResponseStrategyService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: DnsResponseStrategyController.java
* @Description: TODO
* @author (wx)
* @date 2016年9月5日 下午4:12:27
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/cfg/v1")
public class DnsResponseStrategyController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected DnsResponseStrategyService dnsResponseStrategyService;
// @Autowired
// protected RedisDao redisDao;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
/**
*
* saveDnsResponseStrategyBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param dnsResponseStrategySource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsResponseStrategySources", method = RequestMethod.POST)
@ApiOperation(value = "保存DNS响应策略", httpMethod = "POST", notes = "save dns response strategy")
public Map saveDnsResponseStrategyBatch(@RequestBody DnsResponseStrategySource dnsResponseStrategySource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, dnsResponseStrategySource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsResponseStrategySource.getOpAction(), Constants.OPACTION_POST);
try{
chekckData(thread,start,dnsResponseStrategySource,Constants.OPACTION_POST);
dnsResponseStrategyService.saveDnsResponseStrategyBatch(thread,start,dnsResponseStrategySource.getDnsResponseStrategyList());
// redisDao.saveMaps(dnsResponseStrategySource.getDnsResponseStrategyList(), "DNS_RESPONSE_STRATEGY", DnsResponseStrategy.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException){
throw e;
}
e.printStackTrace();
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存DNS响应策略失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存DNS响应策略成功",dnsResponseStrategySource.getDnsResponseStrategyList());
}
/**
*
* updateDnsResponseStrategyBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param dnsResponseStrategySource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsResponseStrategySources", method = RequestMethod.PUT)
@ApiOperation(value = "更新DNS响应策略", httpMethod = "PUT", notes = "update dns response strategy")
public Map updateDnsResponseStrategyBatch(@RequestBody DnsResponseStrategySource dnsResponseStrategySource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, dnsResponseStrategySource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsResponseStrategySource.getOpAction(), Constants.OPACTION_PUT);
try{
chekckData(thread,start,dnsResponseStrategySource,Constants.OPACTION_PUT);
dnsResponseStrategyService.updateDnsResponseStrategyBatch(thread,start,dnsResponseStrategySource.getDnsResponseStrategyList());
// commonConfigService.saveOrUpdateConfigState("DNS_RESPONSE_STRATEGY", dnsResponseStrategySource.getOpTime());
// redisDao.updateMaps(dnsResponseStrategySource.getDnsResponseStrategyList(), "DNS_RESPONSE_STRATEGY", DnsResponseStrategy.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException){
throw e;
}
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新DNS响应策略失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新DNS响应策略成功",dnsResponseStrategySource.getDnsResponseStrategyList());
}
/**
*
* deleteDnsResponseStrategy(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsResponseStrategySources/{id}", method = RequestMethod.DELETE)
@ApiOperation(value = "删除DNS响应策略", httpMethod = "DELETE", notes = "delete dns response strategy")
public Map deleteDnsResponseStrategy(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
boolean isValid=dnsResponseStrategyService.isValid(id);
if(!isValid){
dnsResponseStrategyService.removeDnsResponseStrategy(id);
// commonConfigService.saveOrUpdateConfigState("DNS_RESPONSE_STRATEGY", new Date());
}else{
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS响应策略失败,不能删除有效的DNS响应策略", RestBusinessCode.unknow_error.getValue());
}
}catch(RestServiceException e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS响应策略失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteDnsResponseStrategy(多条删除)
* (这里描述这个方法适用条件 可选)
* @param dnsResponseStrategySource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dnsResponseStrategySources", method = RequestMethod.DELETE)
@ApiOperation(value = "删除DNS响应策略", httpMethod = "DELETE", notes = "delete dns response strategy")
public Map deleteDnsResponseStrategy(@RequestBody DnsResponseStrategySource dnsResponseStrategySource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, dnsResponseStrategySource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dnsResponseStrategySource.getOpAction(), Constants.OPACTION_DELETE);
try{
boolean isValid=dnsResponseStrategyService.isValid(dnsResponseStrategySource.getDnsResponseStrategyList());
if(isValid){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS响应策略失败,包含有效的DNS响应策略",RestBusinessCode.unknow_error.getValue());
}else
dnsResponseStrategyService.removeDnsResponseStrategyBatch(dnsResponseStrategySource.getDnsResponseStrategyList());
}catch(RestServiceException e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
throw e;
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除DNS响应策略失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",dnsResponseStrategySource.getDnsResponseStrategyList());
}
/**
*
* chekckData(验证数据,减少遍历次数,尽量在此方法内验证数据)
* (这里描述这个方法适用条件 可选)
* @param entity
*void
* @exception
* @since 1.0.0
*/
private void chekckData(SaveRequestLogThread thread,long start,DnsResponseStrategySource entity,int opAction){
Date now =new Date();
for(DnsResponseStrategy dnsResponseStrategy :entity.getDnsResponseStrategyList()){
checkReqStrateId(thread,start,dnsResponseStrategy,opAction);
dnsResponseStrategy.setLastUpdate(now);
if(dnsResponseStrategy.getOpTime()==null)
dnsResponseStrategy.setOpTime(entity.getOpTime());
if(opAction==Constants.OPACTION_POST){//新增数据时设置默认值
if(dnsResponseStrategy.getResGroupOneId()==null)dnsResponseStrategy.setResGroupOneId(0);
if(dnsResponseStrategy.getResGroupOneNum()==null)dnsResponseStrategy.setResGroupOneNum(0);
if(dnsResponseStrategy.getResGroupTwoId()==null)dnsResponseStrategy.setResGroupTwoId(0);
if(dnsResponseStrategy.getResGroupTwoNum()==null)dnsResponseStrategy.setResGroupTwoNum(0);
if(dnsResponseStrategy.getResGroupThreeId()==null)dnsResponseStrategy.setResGroupThreeId(0);
if(dnsResponseStrategy.getResGroupThreeNum()==null)dnsResponseStrategy.setResGroupThreeNum(0);
if(dnsResponseStrategy.getResGroupFourId()==null)dnsResponseStrategy.setResGroupFourId(0);
if(dnsResponseStrategy.getResGroupFourNum()==null)dnsResponseStrategy.setResGroupFourNum(0);
if(dnsResponseStrategy.getResGroupFiveId()==null)dnsResponseStrategy.setResGroupFiveId(0);
if(dnsResponseStrategy.getResGroupFiveNum()==null)dnsResponseStrategy.setResGroupFiveNum(0);
if(dnsResponseStrategy.getAddGroup()==null)dnsResponseStrategy.setAddGroup(0);
if(dnsResponseStrategy.getAuthGroup()==null)dnsResponseStrategy.setAuthGroup(0);
}
}
}
private void checkReqStrateId(SaveRequestLogThread thread,long start,DnsResponseStrategy dnsResponseStrategy,int opAction){
//update时可以为空
if(opAction==Constants.OPACTION_PUT&&dnsResponseStrategy.getReqStrateId()==null)return;
if(dnsResponseStrategy.getReqStrateId()==null){
throw new RestServiceException(thread, System.currentTimeMillis(), "请求策略号为空", RestBusinessCode.missing_args.getValue());
}else if(dnsResponseStrategy.getReqStrateId()<=100){
throw new RestServiceException(thread, System.currentTimeMillis(), "请求策略号小于等于100", RestBusinessCode.wrong_range.getValue());
}
}
}

View File

@@ -0,0 +1,223 @@
/**
*@Title: EncryptProtoRandomController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author wx
*@date 2016年9月7日 下午3:58:16
*@version 版本号
*/
package com.nis.web.controller.restful;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.EncryptProtoRandom;
import com.nis.domain.restful.EncryptProtoRandomSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.EncryptProtoRandomService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: EncryptProtoRandomController.java
* @Description: TODO
* @author (wx)
* @date 2016年9月7日 下午3:58:16
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/cfg/v1")
public class EncryptProtoRandomController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected EncryptProtoRandomService encryptProtoRandomService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
// @Autowired
// protected CommonConfigService commonConfigService;
// @Autowired
// protected RedisDao redisDao;
/**
* saveEncryptProtoRandomBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param EncryptProtoRandomSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/encryptProtoRandomSources", method = RequestMethod.POST)
@ApiOperation(value = "保存加密类协议随机封堵配置", httpMethod = "POST", notes = "save encrypt_proto_random")
public Map saveEncryptProtoRandomBatch(@RequestBody EncryptProtoRandomSource encryptProtoRandomSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, encryptProtoRandomSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,encryptProtoRandomSource.getOpAction(), Constants.OPACTION_POST);
try{
this.chekckData(encryptProtoRandomSource);
encryptProtoRandomService.saveEncryptProtoRandomBatch(encryptProtoRandomSource.getEncryptProtoRandomList());
// commonConfigService.saveOrUpdateConfigState("DMB_CK", encryptProtoRandomSource.getOpTime());
// redisDao.saveMaps(encryptProtoRandomSource.getEncryptProtoRandomList(), "DMB_CK", EncryptProtoRandom.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存加密类协议随机封堵配置失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存加密类协议随机封堵配置成功",encryptProtoRandomSource.getEncryptProtoRandomList());
}
/**
*
* updateEncryptProtoRandomBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param EncryptProtoRandomSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/encryptProtoRandomSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新加密类协议随机封堵配置", httpMethod = "PUT", notes = "update encrypt_proto_random")
public Map updateEncryptProtoRandomBatch(@RequestBody EncryptProtoRandomSource encryptProtoRandomSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, encryptProtoRandomSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,encryptProtoRandomSource.getOpAction(), Constants.OPACTION_PUT);
try{
this.chekckData(encryptProtoRandomSource);
encryptProtoRandomService.updateEncryptProtoRandomBatch(encryptProtoRandomSource.getEncryptProtoRandomList());
// commonConfigService.saveOrUpdateConfigState("DMB_CK", encryptProtoRandomSource.getOpTime());
// redisDao.updateMaps(encryptProtoRandomSource.getEncryptProtoRandomList(), "DMB_CK", EncryptProtoRandom.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新加密类协议随机封堵配置失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新加密类协议随机封堵配置成功",encryptProtoRandomSource.getEncryptProtoRandomList());
}
/**
*
* deleteEncryptProtoRandom(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/encryptProtoRandomSources/{id}", method = RequestMethod.DELETE)
@ApiOperation(value = "删除加密类协议随机封堵配置", httpMethod = "DELETE", notes = "delete encrypt_proto_random")
public Map deleteEncryptProtoRandom(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
encryptProtoRandomService.removeEncryptProtoRandom(id);
// commonConfigService.saveOrUpdateConfigState("DMB_CK", new Date());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除加密类协议随机封堵配置失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteEncryptProtoRandom(多条删除)
* (这里描述这个方法适用条件 可选)
* @param EncryptProtoRandomSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/encryptProtoRandomSources", method = RequestMethod.DELETE)
@ApiOperation(value = "删除加密类协议随机封堵配置", httpMethod = "DELETE", notes = "delete encrypt_proto_random")
public Map deleteEncryptProtoRandom(@RequestBody EncryptProtoRandomSource encryptProtoRandomSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, encryptProtoRandomSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,encryptProtoRandomSource.getOpAction(), Constants.OPACTION_DELETE);
try{
encryptProtoRandomService.removeEncryptProtoRandomBatch(encryptProtoRandomSource.getEncryptProtoRandomList());
// commonConfigService.saveOrUpdateConfigState("DMB_CK", encryptProtoRandomSource.getOpTime());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除加密类协议随机封堵配置失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",encryptProtoRandomSource.getEncryptProtoRandomList());
}
/**
*
* chekckData(操作验证时间)
* (这里描述这个方法适用条件 可选)
* @param entity
* @return
*boolean
* @exception
* @since 1.0.0
*/
private void chekckData(EncryptProtoRandomSource entity){
Date now=new Date();
for(EncryptProtoRandom encryptProtoRandom :entity.getEncryptProtoRandomList()){
encryptProtoRandom.setLastUpdate(now);
if(encryptProtoRandom.getOpTime()==null)
encryptProtoRandom.setOpTime(entity.getOpTime());
}
}
}

View File

@@ -0,0 +1,223 @@
/**
*@Title: FwqInfoController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author wx
*@date 2016年9月7日 下午3:58:16
*@version 版本号
*/
package com.nis.web.controller.restful;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.FwqInfo;
import com.nis.domain.restful.FwqInfoSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.FwqInfoService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: FwqInfoController.java
* @Description: TODO
* @author (wx)
* @date 2016年9月7日 下午3:58:16
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/cfg/v1")
public class FwqInfoController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected FwqInfoService fwqInfoService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
// @Autowired
// protected CommonConfigService commonConfigService;
// @Autowired
// protected RedisDao redisDao;
/**
* saveFwqInfoBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param FwqInfoSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/fwqInfoSources", method = RequestMethod.POST)
@ApiOperation(value = "保存服务器信息", httpMethod = "POST", notes = "save server info")
public Map saveFwqInfoBatch(@RequestBody FwqInfoSource fwqInfoSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, fwqInfoSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,fwqInfoSource.getOpAction(), Constants.OPACTION_POST);
try{
chekckData(fwqInfoSource);
fwqInfoService.saveFwqInfoBatch(fwqInfoSource.getFwqInfoList());
// commonConfigService.saveOrUpdateConfigState("FWQ_INFO", fwqInfoSource.getOpTime());
// redisDao.saveMaps(fwqInfoSource.getFwqInfoList(), "FWQ_INFO", FwqInfo.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存服务器信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存服务器信息成功",fwqInfoSource.getFwqInfoList());
}
/**
*
* updateFwqInfoBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param FwqInfoSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/fwqInfoSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新服务器信息", httpMethod = "PUT", notes = "update server info")
public Map updateFwqInfoBatch(@RequestBody FwqInfoSource fwqInfoSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, fwqInfoSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,fwqInfoSource.getOpAction(), Constants.OPACTION_PUT);
try{
chekckData(fwqInfoSource);
fwqInfoService.updateFwqInfoBatch(fwqInfoSource.getFwqInfoList());
// commonConfigService.saveOrUpdateConfigState("FWQ_INFO", fwqInfoSource.getOpTime());
// redisDao.updateMaps(fwqInfoSource.getFwqInfoList(), "FWQ_INFO", FwqInfo.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新服务器信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新服务器信息成功",fwqInfoSource.getFwqInfoList());
}
/**
*
* deleteFwqInfo(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/fwqInfoSources/{id}", method = RequestMethod.DELETE)
@ApiOperation(value = "删除服务器信息", httpMethod = "DELETE", notes = "delete server info")
public Map deleteFwqInfo(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
fwqInfoService.removeFwqInfo(id);
// commonConfigService.saveOrUpdateConfigState("FWQ_INFO", new Date());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除服务器信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteFwqInfo(多条删除)
* (这里描述这个方法适用条件 可选)
* @param FwqInfoSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/fwqInfoSources", method = RequestMethod.DELETE)
@ApiOperation(value = "删除服务器信息", httpMethod = "DELETE", notes = "delete server info")
public Map deleteFwqInfo(@RequestBody FwqInfoSource fwqInfoSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, fwqInfoSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,fwqInfoSource.getOpAction(), Constants.OPACTION_DELETE);
try{
fwqInfoService.removeFwqInfoBatch(fwqInfoSource.getFwqInfoList());
// commonConfigService.saveOrUpdateConfigState("FWQ_INFO", fwqInfoSource.getOpTime());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除服务器信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",fwqInfoSource.getFwqInfoList());
}
/**
*
* chekckData(操作验证时间)
* (这里描述这个方法适用条件 可选)
* @param entity
* @return
*boolean
* @exception
* @since 1.0.0
*/
private void chekckData(FwqInfoSource entity){
Date now =new Date();
for(FwqInfo fwqInfo :entity.getFwqInfoList()){
fwqInfo.setLastUpdate(now);
if(fwqInfo.getOpTime()==null)
fwqInfo.setOpTime(entity.getOpTime());
}
}
}

View File

@@ -0,0 +1,89 @@
/**
* @Title: DjLogSearchController.java
* @Package com.nis.web.controller.restful
* @Description: TODO(用一句话描述该文件做什么)
* @author (zbc)
* @date 2016年9月8日下午8:11:58
* @version V1.0
*/
package com.nis.web.controller.restful;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.Page;
import com.nis.domain.restful.DjFlowControlStop;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.IntervalTimeSearchService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
*
* @ClassName: DjLogSearchController
* @Description: TODO(这里用一句话描述这个类的作用)
* @author (zbc)
* @date 2016年9月8日下午8:11:58
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/log/v1")
@SuppressWarnings({ "rawtypes" })
public class IntervalTimeSearchController extends BaseRestController{
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected IntervalTimeSearchService timeSearchService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
protected String logSource = "0";
@RequestMapping(value="/djFlowControlStopSources", method = RequestMethod.GET)
@ApiOperation(value="监测规则流控信息获取" , httpMethod = "GET", notes="get log list")
public Map djFlowControlStopList(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
Page page, DjFlowControlStop flowControlStop, HttpServletRequest request,
HttpServletResponse response, Model model) {
if(!Constants.ACTIVESYS_A.equals(searchActiveSys)
&& !Constants.ACTIVESYS_C.equals(searchActiveSys)
)searchActiveSys=Constants.ACTIVESYS_B;
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_GET,request, null);
//请求参数校验
timeSearchService.queryConditionCheck(thread,start,flowControlStop,page);
Page<DjFlowControlStop> flowControlStopPage = null;
try {
flowControlStopPage = timeSearchService.findFlowControlStopPage(new Page<DjFlowControlStop>(request, response,DjFlowControlStop.class), flowControlStop);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "监测规则流控信息检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "监测规则流控信息检索成功",flowControlStopPage
,searchActiveSys, logSource);
}
}

View File

@@ -0,0 +1,226 @@
/**
*@Title: JdjInfoController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author wx
*@date 2016年9月7日 下午3:58:16
*@version 版本号
*/
package com.nis.web.controller.restful;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.JdjInfo;
import com.nis.domain.restful.JdjInfoSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.JdjInfoService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: JdjInfoController.java
* @Description: TODO
* @author (wx)
* @date 2016年9月7日 下午3:58:16
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/cfg/v1")
public class JdjInfoController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected JdjInfoService jdjInfoService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
// @Autowired
// protected CommonConfigService commonConfigService;
// @Autowired
// protected RedisDao redisDao;
/**
* saveJdjInfoBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param JdjInfoSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/jdjInfoSources", method = RequestMethod.POST)
@ApiOperation(value = "保存节点机信息", httpMethod = "POST", notes = "save node info")
public Map saveJdjInfoBatch(@RequestBody JdjInfoSource jdjInfoSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, jdjInfoSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,jdjInfoSource.getOpAction(), Constants.OPACTION_POST);
try{
this.chekckData(jdjInfoSource,false);
jdjInfoService.saveJdjInfoBatch(jdjInfoSource.getJdjInfoList());
// commonConfigService.saveOrUpdateConfigState("JDJ_INFO", jdjInfoSource.getOpTime());
// redisDao.saveMaps(jdjInfoSource.getJdjInfoList(), "JDJ_INFO", JdjInfo.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存节点机信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存节点机信息成功",jdjInfoSource.getJdjInfoList());
}
/**
*
* updateJdjInfoBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param JdjInfoSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/jdjInfoSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新节点机信息", httpMethod = "PUT", notes = "update node info")
public Map updateJdjInfoBatch(@RequestBody JdjInfoSource jdjInfoSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, jdjInfoSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,jdjInfoSource.getOpAction(), Constants.OPACTION_PUT);
try{
this.chekckData(jdjInfoSource,true);
jdjInfoService.updateJdjInfoBatch(jdjInfoSource.getJdjInfoList());
// commonConfigService.saveOrUpdateConfigState("JDJ_INFO", jdjInfoSource.getOpTime());
// redisDao.updateMaps(jdjInfoSource.getJdjInfoList(), "JDJ_INFO", JdjInfo.class, "id");
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新节点机信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新节点机信息成功",jdjInfoSource.getJdjInfoList());
}
/**
*
* deleteJdjInfo(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/jdjInfoSources/{id}", method = RequestMethod.DELETE)
@ApiOperation(value = "删除节点机信息", httpMethod = "DELETE", notes = "delete node info")
public Map deleteJdjInfo(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
jdjInfoService.removeJdjInfo(id);
// commonConfigService.saveOrUpdateConfigState("JDJ_INFO", new Date());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除节点机信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteJdjInfo(多条删除)
* (这里描述这个方法适用条件 可选)
* @param JdjInfoSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/jdjInfoSources", method = RequestMethod.DELETE)
@ApiOperation(value = "删除节点机信息", httpMethod = "DELETE", notes = "delete node info")
public Map deleteJdjInfo(@RequestBody JdjInfoSource jdjInfoSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, jdjInfoSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,jdjInfoSource.getOpAction(), Constants.OPACTION_DELETE);
try{
jdjInfoService.removeJdjInfoBatch(jdjInfoSource.getJdjInfoList());
// commonConfigService.saveOrUpdateConfigState("JDJ_INFO", jdjInfoSource.getOpTime());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除节点机信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",jdjInfoSource.getJdjInfoList());
}
/**
*
* chekckData(操作验证时间)
* (这里描述这个方法适用条件 可选)
* @param entity
* @return
*boolean
* @exception
* @since 1.0.0
*/
private void chekckData(JdjInfoSource entity, boolean update){
Date now =new Date();
for(JdjInfo jdjInfo :entity.getJdjInfoList()){
jdjInfo.setLastUpdate(now);
if(jdjInfo.getOpTime()==null)
jdjInfo.setOpTime(entity.getOpTime());
if(!update){//新增时判断默认值
if(jdjInfo.getJcIp()==null)jdjInfo.setJcIp("0.0.0.0");
}
}
}
}

View File

@@ -0,0 +1,721 @@
package com.nis.web.controller.restful;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.Page;
import com.nis.domain.restful.ConfigCompile;
import com.nis.domain.restful.ConfigCompileTest;
import com.nis.domain.restful.ConfigGroupRelation;
import com.nis.domain.restful.ConfigSourceTest;
import com.nis.domain.restful.IpRegion;
import com.nis.domain.restful.IpRegionTest;
import com.nis.domain.restful.NumRegion;
import com.nis.domain.restful.NumRegionTest;
import com.nis.domain.restful.StrRegion;
import com.nis.domain.restful.StrRegionTest;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.JsonDateValueProcessor;
import com.nis.util.StringUtils;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.ConfigSourcesService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import net.sf.json.JSONArray;
import net.sf.json.JsonConfig;
@RestController
@RequestMapping("${servicePath}")
@Api(value = "SaveConfigTestController", description = "配置存储服务,包括管控、监测、白名单的控制类")
public class SaveConfigTestController extends BaseRestController {
private long allCount = 0l;
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Logger logger = Logger.getLogger(ConfigTestController.class);
@Autowired
protected ConfigSourcesService configSourcesService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@RequestMapping(value = "/cfg/v1/testSaveByJDBCThread", method = RequestMethod.GET)
@ApiOperation(value = "测试批量业务配置存储", httpMethod = "GET", response = Map.class, notes = "对有效的配置(封堵|监测|白名单)存储")
public Map testSaveByJDBCThread(@RequestParam(value = "configCount", required = false) Long configCount,
@RequestParam(value = "startNum", required = false) Long startNum,
@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime, HttpServletRequest request,
HttpServletResponse response) {
try {
startTime = "2016-11-01 08:20:20";
endTime = "2016-11-8 15:55:33";
if (configCount == null) {
configCount = 0l;
}
allCount = 0l;
long dataCount = 0l;
if (startTime == null || startTime.equals("")) {
startTime = sdf.format(new Date());
}
if (endTime == null || endTime.equals("")) {
endTime = sdf.format(new Date());
}
Date date = new Date();
ConfigSourceTest configSource = new ConfigSourceTest();
configSource.setOpTime(date);
configSource.setOpAction(1);
configSource.setOperator("rkg");
configSource.setVersion("0.1");
List<ConfigCompile> configCompileList = new ArrayList<ConfigCompile>();
if (startNum == null || startNum == 0) {
startNum = 1l;
}
long count = System.currentTimeMillis() + startNum;
Integer[] zeroArr = { 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
Integer[] oneArr = { 15, 16, 17, 18, 32, 33, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62 };
Integer[] twoArr = { 2 };
for (Integer x = 0; x < zeroArr.length; x++) {
for (Long i = 1l; i <= configCount; i++) {
count++;
dataCount++;
allCount++;
ConfigCompile configCompile = setCompileTest(zeroArr[x].longValue(), 0, date, startTime, endTime,
count);
configCompileList.add(configCompile);
}
}
for (Integer x = 15; x < oneArr.length + 15; x++) {
for (Long i = 1l; i <= configCount; i++) {
count++;
dataCount++;
allCount++;
ConfigCompile configCompile = setCompileTest(oneArr[x - 15].longValue(), 1, date, startTime,
endTime, count);
configCompileList.add(configCompile);
}
}
for (Integer x = 50; x < twoArr.length + 50; x++) {
for (Long i = 1l; i <= configCount; i++) {
count++;
dataCount++;
allCount++;
ConfigCompile configCompile = setCompileTest(twoArr[x - 50].longValue(), 2, date, startTime,
endTime, count);
configCompileList.add(configCompile);
}
}
configSource.setConfigCompileList(configCompileList);
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST,
request, configSource);
// JsonConfig jsonConfig = new JsonConfig();
// jsonConfig.registerJsonValueProcessor(Date.class, new
// JsonDateValueProcessor());
// JSONArray jsonArray = JSONArray.fromObject(configSource,
// jsonConfig);
// String jsonStr = jsonArray.getString(0);
// String distisct = "\"district\":\"\",";
// if (jsonStr.contains(distisct)) {
// jsonStr = jsonStr.replaceAll(distisct, "");
// }
// System.out.println(jsonStr);
System.out.println("开始执行插入操作" + dataCount + "条配置总计" + allCount + "条数据");
long start = System.currentTimeMillis();
StringBuffer sb = new StringBuffer();
configSourcesService.saveByJDBCThread(thread, start, configCompileList, sb);
Long end = System.currentTimeMillis();
Long time = (end - start) / 1000;
System.out.println("插入了" + dataCount + "条配置总计" + allCount + "条数据总共需要" + time + "");
validateConfigSourceTest(thread, start, configSource);
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "编译配置数据插入成功",
configSource);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@RequestMapping(value = "/cfg/v1/testSaveByMybatis", method = RequestMethod.GET)
@ApiOperation(value = "测试批量业务配置存储", httpMethod = "GET", response = Map.class, notes = "对有效的配置(封堵|监测|白名单)存储")
public Map testSaveByMybatis(@RequestParam(value = "configCount", required = false) Long configCount,
@RequestParam(value = "batchSize", required = false) Integer batchSize,
@RequestParam(value = "startNum", required = false) Long startNum, HttpServletRequest request,
HttpServletResponse response) {
try {
if (startNum == null || startNum == 0) {
startNum = 1l;
}
allCount = 0l;
long dataCount = 0l;
String startTime = "2016-11-01 08:20:20";
String endTime = "2016-11-8 15:55:33";
Date date = new Date();
ConfigSourceTest configSource = new ConfigSourceTest();
configSource.setOpTime(date);
configSource.setOpAction(1);
configSource.setOperator("rkg");
configSource.setVersion("0.1");
List<ConfigCompile> configCompileList = new ArrayList<ConfigCompile>();
long count = System.currentTimeMillis() + startNum;
Integer[] zeroArr = { 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
Integer[] oneArr = { 15, 16, 17, 18, 32, 33, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62 };
Integer[] twoArr = { 2 };
for (Integer x = 0; x < zeroArr.length; x++) {
for (Long i = 1l; i <= configCount; i++) {
count++;
dataCount++;
allCount++;
ConfigCompile configCompile = setCompileTest(zeroArr[x].longValue(), 0, date, startTime, endTime,
count);
configCompileList.add(configCompile);
}
}
for (Integer x = 15; x < oneArr.length + 15; x++) {
for (Long i = 1l; i <= configCount; i++) {
count++;
dataCount++;
allCount++;
ConfigCompile configCompile = setCompileTest(oneArr[x - 15].longValue(), 1, date, startTime,
endTime, count);
configCompileList.add(configCompile);
}
}
for (Integer x = 50; x < twoArr.length + 50; x++) {
for (Long i = 1l; i <= configCount; i++) {
count++;
dataCount++;
allCount++;
ConfigCompile configCompile = setCompileTest(twoArr[x - 50].longValue(), 2, date, startTime,
endTime, count);
configCompileList.add(configCompile);
}
}
configSource.setConfigCompileList(configCompileList);
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST,
request, configSource);
System.out.println("开始执行插入操作" + dataCount + "条配置总计" + allCount + "条数据");
long start = System.currentTimeMillis();
StringBuffer sb = new StringBuffer();
configSourcesService.insertConfigSourceData(thread, start, configCompileList, sb);
Long end = System.currentTimeMillis();
Long time = (end - start) / 1000;
System.out.println("插入了" + dataCount + "条配置总计" + allCount + "条数据总共需要" + time + "");
validateConfigSourceTest(thread, start, configSource);
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "编译配置数据插入成功",
configSource);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public ConfigCompileTest setCompileTest(Long serviceType, Integer action, Date date, String startTime,
String endTime, Long index) throws Exception {
Long compileId = System.currentTimeMillis() + index;
//System.out.println("compileId--------------------------" + compileId);
ConfigCompileTest configCompile = new ConfigCompileTest();
configCompile.setCompileId(compileId);
configCompile.setService(serviceType);
configCompile.setAction(1);
configCompile.setContType(0);
configCompile.setAttrType(0);
configCompile.setContLabel("0");
configCompile.setTaskId(0);
configCompile.setGuaranteeId(0);
configCompile.setAffAirId(0);
configCompile.setTopIcId(0);
configCompile.setDoBlackList(1l);
configCompile.setDoLog(0);
configCompile.setEffectiveRange("0");
configCompile.setConfigPercent(100l);
configCompile.setConfigOption(1);
configCompile.setStartTime(new Date(1482472334731l));
configCompile.setEndTime(new Date(1482472734731l));
//configCompile.setStartTime(sdf.parse("2016-12-22 08:20:20"));
//configCompile.setEndTime(sdf.parse("2016-12-23 08:20:20"));
// configCompile.setStartTime(startTime);
// configCompile.setEndTime(endTime);
configCompile.setActiveSys(2);
configCompile.setLastUpdate(date);
configCompile.setProcSeq(compileId);
configCompile.setUserRegion("0");
configCompile.setIsValid(1);
configCompile.setGroupNum(1);
configCompile.setFatherCfgId(0l);
configCompile.setOpTime(date);
Long groupId = System.currentTimeMillis() + (long) ((Math.random()) * 100000);
configCompile.setGroupRelationList(setGroupList(compileId, date, groupId));
Map<String, String> tableMap = configSourcesService.getTableMap(serviceType.intValue());
List<String> strTable = new ArrayList<String>();
String ipTable = null;
String numTable = null;
if (null != tableMap && tableMap.size() > 0) {
for (String str : tableMap.keySet()) {
if (tableMap.get(str).equals("ip")) {
ipTable = str;
} else if (tableMap.get(str).equals("num")) {
numTable = str;
} else if (tableMap.get(str).equals("str")) {
strTable.add(str);
}
}
}
configCompile.setStrRegionList(setAllStrRegionList(serviceType, groupId, date, strTable, index));
configCompile.setIpRegionList(setIpRegionList(serviceType, groupId, date, ipTable, index));
configCompile.setNumRegionList(setNumRegionList(serviceType, groupId, date, numTable, index));
return configCompile;
}
public List<ConfigGroupRelation> setGroupList(Long compileId, Date date, Long groupId) {
List<ConfigGroupRelation> groupRelationList = new ArrayList<ConfigGroupRelation>();
ConfigGroupRelation configGroupRelation = new ConfigGroupRelation();
configGroupRelation.setGroupId(groupId);
configGroupRelation.setId(groupId);
configGroupRelation.setCompileId(compileId);
configGroupRelation.setIsValid(1);
configGroupRelation.setOpTime(date);
groupRelationList.add(configGroupRelation);
allCount++;
return groupRelationList;
}
public List<StrRegion> setStrRegionList(Long service, Long groupId, Date date, List<String> tableName, Long index) {
List<StrRegion> strRegionList = new ArrayList<StrRegion>();
if (tableName != null & tableName.size() > 0) {
Long regionId = System.currentTimeMillis() + index + 10000000000000l;
//System.out.println("Strid--------------------------" + regionId);
StrRegionTest strRegion = new StrRegionTest();
strRegion.setRegionId(regionId);
strRegion.setGroupId(groupId);
strRegion.setKeywords("百度");
strRegion.setExprType(0);
strRegion.setMatchMethod(0);
strRegion.setIsHexbin(0);
strRegion.setIsValid(1);
strRegion.setOpTime(date);
if (configSourcesService.isStrStrongRegion(tableName.get(0))) {
strRegion.setDistrict("南京");
}
strRegion.setTableName(tableName.get(0));
strRegion.setProcSeq(regionId);
strRegionList.add(strRegion);
StrRegionTest strRegion1 = new StrRegionTest();
Long regionId1 = System.currentTimeMillis() + index + 100000;
//System.out.println("Strid===================================" + regionId);
strRegion1.setRegionId(regionId1);
strRegion1.setGroupId(groupId);
strRegion1.setKeywords("新浪");
strRegion1.setExprType(0);
strRegion1.setMatchMethod(0);
strRegion1.setIsHexbin(0);
strRegion1.setIsValid(1);
strRegion1.setOpTime(date);
strRegion1.setProcSeq(regionId1);
if (tableName.size() > 1) {
strRegion1.setTableName(tableName.get(1));
if (configSourcesService.isStrStrongRegion(tableName.get(1))) {
strRegion1.setDistrict("北京");
}
} else {
strRegion1.setTableName(tableName.get(0));
if (configSourcesService.isStrStrongRegion(tableName.get(0))) {
strRegion1.setDistrict("上海");
}
}
strRegionList.add(strRegion1);
allCount++;
return strRegionList;
} else {
return strRegionList;
}
}
public List<StrRegion> setAllStrRegionList(Long service, Long groupId, Date date, List<String> tableName,
Long index) {
List<StrRegion> strRegionList = new ArrayList<StrRegion>();
int num = 0;
if (tableName != null & tableName.size() > 0) {
for (String tbName : tableName) {
num++;
Long regionId = System.currentTimeMillis() + index + 999999999999999l * num;
//System.out.println("Strid--------------------------" + regionId);
StrRegionTest strRegion = new StrRegionTest();
strRegion.setRegionId(regionId);
strRegion.setGroupId(groupId);
strRegion.setKeywords("百度");
strRegion.setExprType(0);
strRegion.setMatchMethod(0);
strRegion.setIsHexbin(2);
strRegion.setIsValid(1);
strRegion.setOpTime(date);
if (configSourcesService.isStrStrongRegion(tbName)) {
strRegion.setDistrict("南京");
}
strRegion.setTableName(tbName);
strRegion.setProcSeq(regionId);
strRegionList.add(strRegion);
allCount++;
}
return strRegionList;
} else {
return strRegionList;
}
}
public List<IpRegion> setIpRegionList(Long service, Long groupId, Date date, String tableName, Long index) {
List<IpRegion> ipRegionList = new ArrayList<IpRegion>();
if (tableName != null) {
IpRegionTest ipRegion = new IpRegionTest();
Long regionId = System.currentTimeMillis() + index + 20000000000000l;
//System.out.println("Ipid--------------------------" + regionId);
ipRegion.setRegionId(regionId);
ipRegion.setGroupId(groupId);
ipRegion.setAddrType(4);
ipRegion.setSrcIp("0.0.0.0");
ipRegion.setMaskSrcIp("0.0.0.0");
ipRegion.setSrcPort("0");
ipRegion.setMaskSrcPort("0");
ipRegion.setDstIp("0.0.0.2");
ipRegion.setMaskDstIp("0.0.0.0");
ipRegion.setDstPort("0");
ipRegion.setMaskDstPort("0");
ipRegion.setProtocol(0);
ipRegion.setDirection(0);
ipRegion.setIsValid(1);
ipRegion.setOpTime(date);
ipRegion.setTableName(tableName);
ipRegion.setProcSeq(regionId);
ipRegionList.add(ipRegion);
allCount++;
return ipRegionList;
} else {
return ipRegionList;
}
}
public List<NumRegion> setNumRegionList(Long service, Long groupId, Date date, String tableName, Long index) {
List<NumRegion> numRegionList = new ArrayList<NumRegion>();
if (tableName != null) {
NumRegionTest numRegion = new NumRegionTest();
Long regionId = System.currentTimeMillis() + index + 30000000000000l;
//System.out.println("numid--------------------------" + regionId);
numRegion.setRegionId(regionId);
numRegion.setGroupId(groupId);
numRegion.setLowBoundary(4294967294l);
numRegion.setUpBoundary(4294967295l);
numRegion.setIsValid(1);
numRegion.setOpTime(date);
numRegion.setTableName(tableName);
numRegion.setProcSeq(regionId);
numRegionList.add(numRegion);
allCount++;
return numRegionList;
} else {
return numRegionList;
}
}
private void validateConfigSourceTest(SaveRequestLogThread thread, long start, ConfigSourceTest configSource) {
String errorInfo = "";
List<ConfigCompile> configCompileList = configSource.getConfigCompileList();
if (StringUtils.isEmpty(configSource.getOperator())) {
errorInfo = "get operator is Empty";
}
if (StringUtils.isEmpty(configSource.getVersion())) {
errorInfo = "get version is Empty";
}
if (!isBlank(configSource.getOpTime())) {
errorInfo = "get OpTime is Empty";
}
if (configCompileList.size() <= 0) {
errorInfo = "编译配置不能为空";
}
if (!errorInfo.equals("")) {
throw new RestServiceException(thread, System.currentTimeMillis() - start, errorInfo,
RestBusinessCode.missing_args.getValue());
}
}
private boolean isBlank(Date datetime) {
if (null != datetime) {
return true;
}
return false;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@RequestMapping(value = "/cfg/v1/testUpdateByJDBCThread", method = RequestMethod.GET)
@ApiOperation(value = "测试批量业务配置修改", httpMethod = "GET", response = Map.class, notes = "对有效的配置(封堵|监测|白名单)存储")
public Map testUpdateByJDBCThread(@RequestParam(value = "compileId", required = false) Long compileId,
HttpServletRequest request, HttpServletResponse response) {
allCount = 0l;
long dataCount = 0l;
List<ConfigCompile> compileList = new ArrayList<ConfigCompile>();
ConfigCompileTest configCompileTest = new ConfigCompileTest();
configCompileTest.setIsValid(1);
if (null != compileId) {
configCompileTest.setCompileId(compileId);
}
List<ConfigCompileTest> queryAllCompile = configSourcesService.queryAllCompile(configCompileTest);
for (int i = 0; i < queryAllCompile.size(); i++) {
ConfigCompile compileInfo = getCompileInfo(queryAllCompile.get(i));
compileInfo.setOpTime(new Date());
dataCount++;
allCount++;
// compileInfo.setIsValid(0);
compileList.add(compileInfo);
}
ConfigSourceTest configSource = new ConfigSourceTest();
configSource.setOpTime(new Date());
configSource.setOpAction(1);
configSource.setOperator("rkg");
configSource.setVersion("0.1");
configSource.setConfigCompileList(compileList);
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
configSource);
long start = System.currentTimeMillis();
try {
System.out.println("开始执行修改操作" + dataCount + "条配置总计" + allCount + "条数据");
StringBuffer sb = new StringBuffer();
configSourcesService.updateByJDBCThread(thread, start, configSource.getConfigCompileList(),
configSource.getOpTime(), sb);
Long end = System.currentTimeMillis();
Long time = (end - start) / 1000;
System.out.println("修改了" + dataCount + "条配置总计" + allCount + "条数据总共需要" + time + "");
} catch (Exception e) {
logger.error(e);
if (!e.getMessage().contains("Connection is closed!")) {
RestServiceException rse = (RestServiceException) e;
throw new RestServiceException(thread, System.currentTimeMillis() - start, rse.getMessage(),
rse.getErrorCode());
} else {
throw new RestServiceException(thread, System.currentTimeMillis() - start, "数据保存发生异常!",
RestBusinessCode.unknow_error.getValue());
}
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "编译配置数据修改成功",
configSource);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@RequestMapping(value = "/cfg/v1/updateConfigSource", method = RequestMethod.GET)
@ApiOperation(value = "测试批量业务配置修改", httpMethod = "GET", response = Map.class, notes = "对有效的配置(封堵|监测|白名单)存储")
public Map updateConfigSource(@RequestParam(value = "compileId", required = false) Long compileId,
HttpServletRequest request, HttpServletResponse response) {
allCount = 0l;
long dataCount = 0l;
List<ConfigCompile> compileList = new ArrayList<ConfigCompile>();
ConfigCompileTest configCompileTest = new ConfigCompileTest();
configCompileTest.setIsValid(1);
if (null != compileId) {
configCompileTest.setCompileId(compileId);
}
List<ConfigCompileTest> queryAllCompile = configSourcesService.queryAllCompile(configCompileTest);
for (int i = 0; i < queryAllCompile.size(); i++) {
ConfigCompile compileInfo = getCompileInfo(queryAllCompile.get(i));
// compileInfo.setIsValid(0);
compileInfo.setOpTime(new Date());
compileList.add(compileInfo);
dataCount++;
allCount++;
}
ConfigSourceTest configSource = new ConfigSourceTest();
configSource.setOpTime(new Date());
configSource.setOpAction(1);
configSource.setOperator("rkg");
configSource.setVersion("0.1");
configSource.setConfigCompileList(compileList);
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.registerJsonValueProcessor(Date.class, new JsonDateValueProcessor());
JSONArray jsonArray = JSONArray.fromObject(configSource, jsonConfig);
String jsonStr = jsonArray.getString(0);
String distisct = "\"district\":\"\",";
if (jsonStr.contains(distisct)) {
jsonStr = jsonStr.replaceAll(distisct, "");
}
// System.out.println(jsonStr);
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
configSource);
long start = System.currentTimeMillis();
try {
System.out.println("开始执行修改操作" + dataCount + "条配置总计" + allCount + "条数据");
StringBuffer sb = new StringBuffer();
configSourcesService.updateConfigSource(thread, start, configSource.getConfigCompileList(),
configSource.getOpTime(), sb);
Long end = System.currentTimeMillis();
Long time = (end - start) / 1000;
System.out.println("修改了" + dataCount + "条配置总计" + allCount + "条数据总共需要" + time + "");
} catch (Exception e) {
logger.error(e);
if (!e.getMessage().contains("Connection is closed!")) {
RestServiceException rse = (RestServiceException) e;
throw new RestServiceException(thread, System.currentTimeMillis() - start, rse.getMessage(),
rse.getErrorCode());
} else {
throw new RestServiceException(thread, System.currentTimeMillis() - start, "数据保存发生异常!",
RestBusinessCode.unknow_error.getValue());
}
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "编译配置数据修改成功",
configSource);
}
public ConfigCompile getCompileInfo(ConfigCompile configCompileTest) {
List<ConfigGroupRelation> groupByCompileList = configSourcesService
.getGroupByCompile(configCompileTest.getCompileId());
configCompileTest.setGroupRelationList(groupByCompileList);
Long[] groupIdArr = new Long[groupByCompileList.size()];
for (int i = 0; i < groupByCompileList.size(); i++) {
groupIdArr[i] = groupByCompileList.get(i).getGroupId();
allCount++;
}
Map<String, String> tableMap = configSourcesService.getTableMap(configCompileTest.getService().intValue());
List<String> strTable = new ArrayList<String>();
String ipTable = null;
String numTable = null;
if (null != tableMap && tableMap.size() > 0) {
for (String str : tableMap.keySet()) {
if (tableMap.get(str).equals("ip")) {
ipTable = str;
} else if (tableMap.get(str).equals("num")) {
numTable = str;
} else if (tableMap.get(str).equals("str")) {
strTable.add(str);
}
}
}
if (strTable.size() > 0) {
// List<StrRegion> strList =new ArrayList<StrRegion>();
List<StrRegion> strRegionList = configSourcesService.getStrRegionByGId(strTable, groupIdArr);
if (null != strRegionList && strRegionList.size() > 0) {
for (StrRegion strRegion : strRegionList) {
// strList.add(strRegion)
strRegion.setIsValid(0);
allCount++;
}
configCompileTest.setStrRegionList(strRegionList);
} else {
List<StrRegion> strList = new ArrayList<StrRegion>();
configCompileTest.setStrRegionList(strList);
}
} else {
List<StrRegion> strList = new ArrayList<StrRegion>();
configCompileTest.setStrRegionList(strList);
}
if (ipTable != null) {
List<IpRegion> ipRegionByGId = configSourcesService.getIpRegionByGId(ipTable, groupIdArr);
if (null != ipRegionByGId && ipRegionByGId.size() > 0) {
for (IpRegion ipRegion : ipRegionByGId) {
ipRegion.setIsValid(0);
allCount++;
}
configCompileTest.setIpRegionList(ipRegionByGId);
} else {
List<IpRegion> ipList = new ArrayList<IpRegion>();
configCompileTest.setIpRegionList(ipList);
}
} else {
List<IpRegion> ipList = new ArrayList<IpRegion>();
configCompileTest.setIpRegionList(ipList);
}
if (numTable != null) {
List<NumRegion> numRegionList = configSourcesService.getNumRegionByGId(numTable, groupIdArr);
if (null != numRegionList && numRegionList.size() > 0) {
for (NumRegion numRegion : numRegionList) {
numRegion.setIsValid(0);
allCount++;
}
configCompileTest.setNumRegionList(numRegionList);
} else {
List<NumRegion> numList = new ArrayList<NumRegion>();
configCompileTest.setNumRegionList(numList);
}
} else {
List<NumRegion> numList = new ArrayList<NumRegion>();
configCompileTest.setNumRegionList(numList);
}
return configCompileTest;
}
@RequestMapping(value = "/cfg/v1/findCompile", method = RequestMethod.POST)
public Map findCompile(ConfigCompileTest configCompileTest, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread1 = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
configCompileTest);
Page page = new Page();
int no = configCompileTest.getPagesNo() == null ? 1 : configCompileTest.getPagesNo();
int size = configCompileTest.getPagesSize() == null ? 10 : configCompileTest.getPagesSize();
page.setPageNo(no);
page.setPageSize(size);
Page<ConfigCompileTest> queryAllCompile = null;
try {
if (configCompileTest.getSearchStartTime() != null && !configCompileTest.getSearchStartTime().equals("")) {
configCompileTest.setStartTime(sdf.parse(configCompileTest.getSearchStartTime()));
// configCompile.setStartTime(configCompile.getSearchStartTime());
}
if (configCompileTest.getSearchEndTime() != null && !configCompileTest.getSearchEndTime().equals("")) {
configCompileTest.setEndTime(sdf.parse(configCompileTest.getSearchEndTime()));
// configCompile.setEndTime(configCompile.getSearchEndTime());
}
queryAllCompile = configSourcesService.queryAllCompile(page, configCompileTest);
} catch (SQLException e) {
thread1.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
throw new RestServiceException(thread1, System.currentTimeMillis() - start, "编译配置获取失败");
} catch (Exception e) {
thread1.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
throw new RestServiceException(thread1, System.currentTimeMillis() - start, "编译配置获取失败");
}
return serviceResponse(thread1, System.currentTimeMillis() - start, request, response, "编译配置获取成功",
queryAllCompile);
}
}

View File

@@ -0,0 +1,100 @@
/**
* @Title: ServiceController.java
* @Package com.nis.web.controller
* @Description: TODO(用一句话描述该文件做什么)
* @author darnell
* @date 2016年8月14日 下午2:16:33
* @version V1.0
*/
package com.nis.web.controller.restful;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.ControlLog;
import com.nis.domain.Page;
import com.nis.domain.restful.ConfigSource;
import com.nis.domain.restful.DfIpPortLog;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.restful.ControlLogService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: ServiceController
* @Description: TODO(这里用一句话描述这个类的作用)
* @author (darnell)
* @date 2016年8月14日 下午2:16:33
* @version V1.0
*/
/*@RestController
@RequestMapping("${servicePath}")*/
public class ServiceController extends BaseRestController{
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected ControlLogService logService;
// @RequestMapping(value="/log/v1/logs", method = RequestMethod.GET)
// @ApiOperation(value="日志分页获取" , httpMethod = "GET", notes="get log list")
// public Map logList(ControlLog log, HttpServletRequest request, HttpServletResponse response, Model model) {
// Page<ControlLog> content = logService.findPage(new Page<ControlLog>(request, response), log);
// return serviceResponse(request, response, "数据删除", content);
// }
// @RequestMapping(value="/log/v1/logs/{id}", method = RequestMethod.GET)
// public Map getControlLog(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response) {
//
// ControlLog log = logService.findById(id);
// if (StringUtil.isEmpty(log)) {
// throw new RestServiceException("未获取管控日志日志ID为"+id, RestBusinessCode.missing_args.getValue());
// }
// return serviceResponse(request, response, "数据删除", log);
// }
@RequestMapping(value="/log/v1/logs", method = RequestMethod.POST)
public ControlLog createControlLog(@RequestBody ControlLog controlLog) {
logService.createControlLog(controlLog);
return controlLog;
}
/* @RequestMapping(value="/cfg/v1/configSources", method = RequestMethod.POST)
public ConfigSource createConfigSource(@RequestBody ConfigSource configSource) {
System.out.println(configSource.getOperator());
return null;
}*/
// @RequestMapping(value="/log/v1/logs/{id}", method = RequestMethod.DELETE)
// public Map deleteControlLog(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response) {
// logService.deleteControlLog(id);
// return serviceResponse(request, response, "数据删除");
//
// }
}

View File

@@ -0,0 +1,78 @@
package com.nis.web.controller.restful;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.Page;
import com.nis.domain.ServicesRequestLog;
import com.nis.domain.restful.DfIpPortLog;
import com.nis.domain.restful.ServicesRequestLogBean;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
@RestController
@RequestMapping("${servicePath}")
public class ServicesRequestLogController extends BaseRestController {
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@RequestMapping(value = "/log/v1/getAllLog", method = RequestMethod.POST)
public Map findCompile(ServicesRequestLogBean log, Page page, HttpServletRequest request,
HttpServletResponse response) {
Page<ServicesRequestLogBean> queryAllCompile = null;
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
log);
try {
queryAllCompile = servicesRequestLogService
.getAllLog(new Page<ServicesRequestLogBean>(request, response, ServicesRequestLogBean.class), log);
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
logger.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "获取系统操作日志失败");
}
throw ((RestServiceException) e);
}
return testServiceResponse( System.currentTimeMillis() - start, request, response, "获取系统操作日志成功",
queryAllCompile);
}
@RequestMapping(value = "/log/v1/deleteById", method = RequestMethod.GET)
public String deleteById(String id, HttpServletRequest request, HttpServletResponse response) {
id = id.replace("[", "");
id = id.replace("]", "");
try {
servicesRequestLogService.deleteById(id);
} catch (Exception e) {
e.printStackTrace();
return "error";
}
return "ok";
}
@RequestMapping(value = "/log/v1/deleteAll", method = RequestMethod.GET)
public String deleteAll(HttpServletRequest request, HttpServletResponse response) {
try {
servicesRequestLogService.deleteAll();
} catch (Exception e) {
e.printStackTrace();
return "error";
}
return "ok";
}
}

View File

@@ -0,0 +1,128 @@
package com.nis.web.controller.restful;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.SystemFunStatus;
import com.nis.domain.restful.SystemFunStatusSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.SystemFunStatusService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: SystemFunStatusController.java
* @Description: 文本系统功能类业务配置服务
* @author (zbc)
* @date 2016年11月10日 上午09:47:00
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/cfg/v1")
@SuppressWarnings("rawtypes")
public class SystemFunStatusController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected SystemFunStatusService systemFunStatusService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
/**
*
* @param systemFunStatusSource
* @param request
* @param response
* @return Map
* @since 1.0.0
*/
@RequestMapping(value = "/systemFunStatusSources", method = RequestMethod.POST)
@ApiOperation(value = "保存文本系统功能类业务配置", httpMethod = "POST", notes = "save encrypt_proto_random")
public Map saveSystemFunStatusBatch(@RequestBody SystemFunStatusSource systemFunStatusSource,
HttpServletRequest request, HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request, systemFunStatusSource);
super.checkOpAction(thread, System.currentTimeMillis() - start, systemFunStatusSource.getOpAction(), Constants.OPACTION_POST);
try{
this.chekckData(systemFunStatusSource);
systemFunStatusService.saveSystemFunStatusBatch(systemFunStatusSource.getSystemFunStatusList());
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存文本系统功能类业务配置失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存文本系统功能类业务配置成功",systemFunStatusSource.getSystemFunStatusList());
}
/**
*
* @param systemFunStatusSource
* @param request
* @param response
* @return Map
* @since 1.0.0
*/
@RequestMapping(value = "/systemFunStatusSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新文本系统功能类业务配置", httpMethod = "PUT", notes = "update encrypt_proto_random")
public Map updateSystemFunStatusBatch(@RequestBody SystemFunStatusSource systemFunStatusSource,
HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, systemFunStatusSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,systemFunStatusSource.getOpAction(), Constants.OPACTION_PUT);
try{
this.chekckData(systemFunStatusSource);
systemFunStatusService.updateSystemFunStatusBatch(systemFunStatusSource.getSystemFunStatusList());
}catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage());
logger.error(e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新文本系统功能类业务配置失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新文本系统功能类业务配置成功",systemFunStatusSource.getSystemFunStatusList());
}
private void chekckData(SystemFunStatusSource entity) {
for (SystemFunStatus systemFunStatus : entity.getSystemFunStatusList()) {
if (systemFunStatus.getOpTime() == null)
systemFunStatus.setOpTime(entity.getOpTime());
}
}
}

View File

@@ -0,0 +1,109 @@
package com.nis.web.controller.restful;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.datanucleus.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.Page;
import com.nis.domain.restful.DfDjNestLog;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.JsonMapper;
import com.nis.util.redis.RedisDao;
import com.nis.util.redis.SaveRedisThread;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.DfDjNestLogService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
*
* @ClassName: dfDjNestLogController
* @Description: 嵌套日志查询服务
* @author (zbc)
* @date 2016年11月11日 下午4:40:00
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/log/v1")
@SuppressWarnings({ "rawtypes", "unchecked" })
public class dfDjNestLogController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected DfDjNestLogService dfDjNestLogService;
@Autowired
protected RedisDao redisDao;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
protected String logSource = "0";
@RequestMapping(value = "/dfDjNestLogs", method = RequestMethod.GET)
@ApiOperation(value = "嵌套日志分页获取", httpMethod = "GET", notes = "get log list")
public Map dfDjNestLogList(
@RequestParam(value = "searchActiveSys", required = false, defaultValue = Constants.ACTIVESYS_B) String searchActiveSys,
@RequestParam(value = "searchLayerId", required = true) String searchLayerId,
Page page, DfDjNestLog dfDjNestLog, HttpServletRequest request, HttpServletResponse response) {
if(!Constants.ACTIVESYS_A.equals(searchActiveSys) && !Constants.ACTIVESYS_C.equals(searchActiveSys))searchActiveSys=Constants.ACTIVESYS_B;
if(StringUtils.notEmpty(searchLayerId)) {
dfDjNestLog.setSearchLayerId(searchLayerId);
}
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null);
boolean keyExists = false;
String key = "";
Page<DfDjNestLog> dfDjNestLogPage = null;
try {
// 请求参数校验
dfDjNestLogService.queryConditionCheck(thread, start, dfDjNestLog, DfDjNestLog.class, page);
if (Constants.IS_OPEN_REDIS) {
// 根据查询条件获取key
key = dfDjNestLogService.getJedisKey(request, true);
// 判断key是否存在
keyExists = redisDao.exists(key);
}
// 存在则直接从redis中查询
if (keyExists) {
dfDjNestLogPage = (Page<DfDjNestLog>) JsonMapper.fromJsonString(redisDao.getString(key), Page.class);
} else {
// 不存在则查询数据库并保存查询结果到redis中
dfDjNestLogPage = dfDjNestLogService
.findDfDjNestLogPage(new Page<DfDjNestLog>(request, response, DfDjNestLog.class), dfDjNestLog);
if (Constants.IS_OPEN_REDIS)
new SaveRedisThread(key, dfDjNestLogPage, Constants.ORACLE_EXPIRE).start();
}
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if (!(e instanceof RestServiceException)) {
e = new RestServiceException(thread, System.currentTimeMillis() - start, "嵌套日志检索失败");
}
((RestServiceException) e).setActiveSys(searchActiveSys);
((RestServiceException) e).setLogSource(logSource);
throw ((RestServiceException) e);
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "嵌套日志检索成功",
dfDjNestLogPage, searchActiveSys, logSource);
}
}

View File

@@ -0,0 +1,204 @@
/**
*@Title: JkDmbCkController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author wx
*@date 2016年9月7日 下午3:58:16
*@version 版本号
*/
package com.nis.web.controller.restful.jk;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.jk.JkDmbCk;
import com.nis.domain.restful.jk.JkDmbCkSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.jk.JkDmbCkService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: JkDmbCkController.java
* @Description: TODO
* @author (wx)
* @date 2016年9月7日 下午3:58:16
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/jk/v1")
public class JkDmbCkController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected JkDmbCkService jkDmbCkService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
/**
* saveDmbCkBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param JkDmbCkSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dmbCkSources", method = RequestMethod.POST)
@ApiOperation(value = "保存因特网国际出入口", httpMethod = "POST", notes = "保存因特网国际出入口")
public Map saveDmbCkBatch(@RequestBody JkDmbCkSource dmbCkSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, dmbCkSource);
super.checkOpAction(thread,System.currentTimeMillis()-start, dmbCkSource.getOpAction(), Constants.OPACTION_POST);
try{
checkData(thread,start,dmbCkSource,Constants.OPACTION_POST);
jkDmbCkService.saveDmbCkBatch(dmbCkSource.getDmbCkList());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存因特网国际出入口失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存因特网国际出入口成功",dmbCkSource.getDmbCkList());
}
/**
*
* updateDmbCkBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param JkDmbCkSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/dmbCkSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新因特网国际出入口", httpMethod = "PUT", notes = "更新因特网国际出入口")
public Map updateDmbCkBatch(@RequestBody JkDmbCkSource dmbCkSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, dmbCkSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dmbCkSource.getOpAction(), Constants.OPACTION_PUT);
try{
checkData(thread,start,dmbCkSource,Constants.OPACTION_PUT);
jkDmbCkService.updateDmbCkBatch(dmbCkSource.getDmbCkList());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新因特网国际出入口失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新因特网国际出入口成功",dmbCkSource.getDmbCkList());
}
/**
*
* deleteDmbCk(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
// @RequestMapping(value = "/dmbCkSources/{id}", method = RequestMethod.DELETE)
// @ApiOperation(value = "删除因特网国际出入口", httpMethod = "DELETE", notes = "删除因特网国际出入口")
public Map deleteDmbCk(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
jkDmbCkService.removeDmbCk(id);
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除因特网国际出入口失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteDmbCk(多条删除)
* (这里描述这个方法适用条件 可选)
* @param JkDmbCkSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
// @RequestMapping(value = "/dmbCkSources", method = RequestMethod.DELETE)
// @ApiOperation(value = "删除因特网国际出入口", httpMethod = "DELETE", notes = "删除因特网国际出入口")
public Map deleteDmbCk(@RequestBody JkDmbCkSource dmbCkSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, dmbCkSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,dmbCkSource.getOpAction(), Constants.OPACTION_DELETE);
try{
jkDmbCkService.removeDmbCkBatch(dmbCkSource.getDmbCkList());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e);
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除因特网国际出入口失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",dmbCkSource.getDmbCkList());
}
private void checkData(SaveRequestLogThread thread,long start,JkDmbCkSource dmbCkSource,int opAction){
if(dmbCkSource.getDmbCkList().size()==0){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"因特网国际出入口不能为空", RestBusinessCode.unknow_error.getValue());
}
for(JkDmbCk e:dmbCkSource.getDmbCkList()){
if(opAction==Constants.OPACTION_POST&&e!=null&&e.getSfSx()!=Long.valueOf(Constants.YES)){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"只能新增有效数据", RestBusinessCode.wrong_range.getValue());
}else if(opAction==Constants.OPACTION_PUT&&e!=null&&e.getSfSx()!=Long.valueOf(Constants.NO)){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"只允许将有效数据更改为无效数据", RestBusinessCode.wrong_range.getValue());
}
if(opAction==Constants.OPACTION_POST){
e.setSxFw("0");
}
}
}
}

View File

@@ -0,0 +1,177 @@
package com.nis.web.controller.restful.jk;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.jk.JkFdZb;
import com.nis.domain.restful.jk.JkFdZbSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.jk.JkFdZbService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: JkFdZbController
* @Description: 静态控管封堵/解封
* @author (DDM)
* @date 2016年10月20日 上午10:20:33
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/jk/v1")
@Api(value = "JkFdZbController", description = "静态控管封堵/解封")
public class JkFdZbController extends BaseRestController {
Logger logger = LoggerFactory.getLogger(JkFdZbController.class);
SimpleDateFormat ymdhms=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Autowired
ServicesRequestLogService servicesRequestLogService;
@Autowired
protected JkFdZbService jkFdZbService;
/**
* saveJkFdZbBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param JkFdZbSource
* @param request
* @param response
* @return Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/jkFdZbSources", method = RequestMethod.POST)
@ApiOperation(value = "静态控管封堵", httpMethod = "POST", notes = "save provider info")
public Map saveJkFdZbBatch(@RequestBody JkFdZbSource jkFdZbSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, jkFdZbSource);
super.checkOpAction(thread,System.currentTimeMillis()-start, jkFdZbSource.getOpAction(), Constants.OPACTION_POST);
validJkFdZb(thread,System.currentTimeMillis()-start,jkFdZbSource.getJkFdZbList(),Constants.OPACTION_POST);
try{
Date date=new Date();
if(jkFdZbSource.getJkFdZbList() != null && jkFdZbSource.getJkFdZbList().size() >0){
for (JkFdZb jkFdZb : jkFdZbSource.getJkFdZbList()) {
jkFdZb.setLastUpdate(date);
}
}
jkFdZbService.saveJkFdZbBatch(jkFdZbSource.getJkFdZbList());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage()+"\r\n"+e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"静态控管封堵失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"静态控管封堵成功",jkFdZbSource.getJkFdZbList());
}
/**
*
* updateJkFdZbBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param JkFdZbSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/jkFdZbSources", method = RequestMethod.PUT)
@ApiOperation(value = "静态控管解封", httpMethod = "PUT", notes = "update provider info")
public Map updateJkFdZbBatch(@RequestBody JkFdZbSource jkFdZbSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, jkFdZbSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,jkFdZbSource.getOpAction(), Constants.OPACTION_PUT);
validJkFdZb(thread,System.currentTimeMillis()-start,jkFdZbSource.getJkFdZbList(),Constants.OPACTION_PUT);
try{
Date date=new Date();
if(jkFdZbSource.getJkFdZbList() != null && jkFdZbSource.getJkFdZbList().size() >0){
for (JkFdZb jkFdZb : jkFdZbSource.getJkFdZbList()) {
jkFdZb.setLastUpdate(date);
}
}
jkFdZbService.updateJkFdZbBatch(jkFdZbSource.getJkFdZbList());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage()+"\r\n"+e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"静态控管解封失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"静态控管解封成功",jkFdZbSource.getJkFdZbList());
}
/**
* 校验是否存在无效数据
*
* @Title: validJkFdZb
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param thread
* @param @param start
* @param @param jkFdZbList
* @return Map 返回类型
* @author DDM
* @version V1.0
*/
public void validJkFdZb(SaveRequestLogThread thread,long start, List<JkFdZb> jkFdZbList,int opAction){
String errorInfo = "";
if (jkFdZbList.size() <= 0) {
errorInfo = "静控封堵记录不能为空";
thread.setExceptionInfo(errorInfo);
throw new RestServiceException(thread,System.currentTimeMillis()-start,errorInfo, RestBusinessCode.missing_args.getValue());
}else{
for (JkFdZb jkFdZb : jkFdZbList) {
if(opAction==Constants.OPACTION_POST&&jkFdZb != null && jkFdZb.getSfFd() !=Long.valueOf(Constants.YES)){
errorInfo = "只能新增有效数据";
thread.setExceptionInfo(errorInfo);
throw new RestServiceException(thread,System.currentTimeMillis()-start,errorInfo, RestBusinessCode.wrong_range.getValue());
}else if(opAction==Constants.OPACTION_PUT && jkFdZb != null && jkFdZb.getSfFd() !=Long.valueOf(Constants.NO)){
errorInfo = "只允许将有效数据更改为无效数据";
thread.setExceptionInfo(errorInfo);
throw new RestServiceException(thread,System.currentTimeMillis()-start,errorInfo, RestBusinessCode.wrong_range.getValue());
}
if(!"".equals(errorInfo)){
break;
}
if(opAction==Constants.OPACTION_POST){
jkFdZb.setSxFw("0");
}
}
}
}
}

View File

@@ -0,0 +1,134 @@
/**
*@Title: JkFfjInfoController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author (zbc)
*@date 2016年10月19日 下午20:04:16
*@version V1.0
*/
package com.nis.web.controller.restful.jk;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.jk.JkFfjInfo;
import com.nis.domain.restful.jk.JkFfjInfoSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.jk.JkFfjInfoService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: JkFfjInfoController.java
* @Description: TODO
* @author (zbc)
* @date 2016年10月19日 下午20:04:16
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/jk/v1")
@SuppressWarnings("rawtypes")
public class JkFfjInfoController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@Autowired
protected JkFfjInfoService jkFfjService;
@RequestMapping(value = "/jkFfjSources", method = RequestMethod.POST)
@ApiOperation(value = "保存静态控管分发机信息", httpMethod = "POST", notes = "save server info")
public Map saveJkFfjInfoBatch(@RequestBody JkFfjInfoSource jkFfjSource, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request, jkFfjSource);
super.checkOpAction(thread, System.currentTimeMillis() - start, jkFfjSource.getOpAction(), Constants.OPACTION_POST);
validJkFdZb(thread,System.currentTimeMillis()-start,jkFfjSource.getJkffjList(),Constants.OPACTION_POST);
try {
jkFfjService.saveJkFfjBatch(jkFfjSource.getJkffjList());
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage()+"\r\n"+e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存静态控管分发机信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存静态控管分发机信息成功",jkFfjSource.getJkffjList());
}
@RequestMapping(value = "/jkFfjSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新静态控管分发机信息", httpMethod = "PUT", notes = "update server info")
public Map updateJkFfjInfoBatch(@RequestBody JkFfjInfoSource jkFfjSource, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request, jkFfjSource);
super.checkOpAction(thread, System.currentTimeMillis() - start, jkFfjSource.getOpAction(), Constants.OPACTION_PUT);
validJkFdZb(thread,System.currentTimeMillis()-start,jkFfjSource.getJkffjList(),Constants.OPACTION_PUT);
try {
jkFfjService.updateJkFfjBatch(jkFfjSource.getJkffjList());
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage()+"\r\n"+e.getCause());
if(e instanceof RestServiceException) throw e;
String info = OracleErrorCodeUtil.getOraCode(e);
if (!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread, System.currentTimeMillis() - start, info);
else
throw new RestServiceException(thread, System.currentTimeMillis() - start, "更新静态控管分发机信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新静态控管分发机信息成功",jkFfjSource.getJkffjList());
}
private void validJkFdZb(SaveRequestLogThread thread, long start, List<JkFfjInfo> jkffjList, int opAction) {
String errorInfo = "";
if (jkffjList.size() <= 0) {
errorInfo = "静控分发机记录不能为空";
thread.setExceptionInfo(errorInfo);
throw new RestServiceException(thread,System.currentTimeMillis()-start,errorInfo, RestBusinessCode.missing_args.getValue());
}else{
for (JkFfjInfo JkFfj : jkffjList) {
if(opAction==Constants.OPACTION_POST&&JkFfj != null && JkFfj.getSfSx() !=Long.valueOf(Constants.YES)){
errorInfo = "只能新增有效数据";
thread.setExceptionInfo(errorInfo);
throw new RestServiceException(thread,System.currentTimeMillis()-start,errorInfo, RestBusinessCode.wrong_range.getValue());
}else if(opAction==Constants.OPACTION_PUT&&JkFfj != null && JkFfj.getSfSx() !=Long.valueOf(Constants.NO)){
errorInfo = "只允许将有效数据更改为无效数据";
thread.setExceptionInfo(errorInfo);
throw new RestServiceException(thread,System.currentTimeMillis()-start,errorInfo, RestBusinessCode.wrong_range.getValue());
}
if(!"".equals(errorInfo)){
break;
}
if(opAction==Constants.OPACTION_POST){
JkFfj.setSxFw("0");
}
}
}
}
}

View File

@@ -0,0 +1,134 @@
/**
*@Title: JkFwqInfoController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author (zbc)
*@date 2016年10月19日 下午20:04:16
*@version V1.0
*/
package com.nis.web.controller.restful.jk;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.jk.JkFfjInfo;
import com.nis.domain.restful.jk.JkFfjInfoSource;
import com.nis.domain.restful.jk.JkFwqInfo;
import com.nis.domain.restful.jk.JkFwqInfoSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.jk.JkFwqInfoService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: JkFwqInfoController.java
* @Description: TODO
* @author (zbc)
* @date 2016年10月19日 下午20:04:16
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/jk/v1")
public class JkFwqInfoController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected JkFwqInfoService jkFwqInfoService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@RequestMapping(value = "/jkFwqSources", method = RequestMethod.POST)
@ApiOperation(value = "保存静态控管服务器信息", httpMethod = "POST", notes = "save server info")
public Map saveJkFfjInfoBatch(@RequestBody JkFwqInfoSource jkFwqSource, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request, jkFwqSource);
super.checkOpAction(thread, System.currentTimeMillis() - start, jkFwqSource.getOpAction(), Constants.OPACTION_POST);
validJkFdZb(thread,System.currentTimeMillis()-start,jkFwqSource.getJkFwqInfoList(),Constants.OPACTION_POST);
try {
jkFwqInfoService.savejkFwqInfoBatch(jkFwqSource.getJkFwqInfoList());
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage()+"\r\n"+e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存静态控管服务器信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存静态控管服务器信息成功",jkFwqSource.getJkFwqInfoList());
}
@RequestMapping(value = "/jkFwqSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新静态控管服务器信息", httpMethod = "PUT", notes = "update server info")
public Map updateJkFfjInfoBatch(@RequestBody JkFwqInfoSource jkFwqSource, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request, jkFwqSource);
super.checkOpAction(thread, System.currentTimeMillis() - start, jkFwqSource.getOpAction(), Constants.OPACTION_PUT);
validJkFdZb(thread,System.currentTimeMillis()-start,jkFwqSource.getJkFwqInfoList(),Constants.OPACTION_PUT);
try {
jkFwqInfoService.updatejkFwqInfoBatch(jkFwqSource.getJkFwqInfoList());
} catch (Exception e) {
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage()+"\r\n"+e.getCause());
if(e instanceof RestServiceException) throw e;
String info = OracleErrorCodeUtil.getOraCode(e);
if (!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread, System.currentTimeMillis() - start, info);
else
throw new RestServiceException(thread, System.currentTimeMillis() - start, "更新静态控管服务器信息失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新静态控管服务器信息成功",jkFwqSource.getJkFwqInfoList());
}
private void validJkFdZb(SaveRequestLogThread thread, long start, List<JkFwqInfo> jkFwqList, int opAction) {
String errorInfo = "";
if (jkFwqList.size() <= 0) {
errorInfo = "静态控管服务器信息不能为空";
thread.setExceptionInfo(errorInfo);
throw new RestServiceException(thread,System.currentTimeMillis()-start,errorInfo, RestBusinessCode.missing_args.getValue());
}else{
for (JkFwqInfo jkFwq : jkFwqList) {
if(opAction==Constants.OPACTION_POST&&jkFwq != null && jkFwq.getSfSx()!=Long.valueOf(Constants.YES)){
errorInfo = "只能新增有效数据";
thread.setExceptionInfo(errorInfo);
throw new RestServiceException(thread,System.currentTimeMillis()-start,errorInfo, RestBusinessCode.wrong_range.getValue());
}else if(opAction==Constants.OPACTION_PUT&&jkFwq != null && jkFwq.getSfSx() !=Long.valueOf(Constants.NO)){
errorInfo = "只允许将有效数据更改为无效数据";
thread.setExceptionInfo(errorInfo);
throw new RestServiceException(thread,System.currentTimeMillis()-start,errorInfo, RestBusinessCode.wrong_range.getValue());
}
if(!"".equals(errorInfo)){
break;
}
if(opAction==Constants.OPACTION_POST){
jkFwq.setSxFw("0");
}
}
}
}
}

View File

@@ -0,0 +1,199 @@
/**
*@Title: JkLyqController.java
*@Package com.nis.web.controller.restful
*@Description TODO
*@author wx
*@date 2016年9月7日 下午3:58:16
*@version 版本号
*/
package com.nis.web.controller.restful.jk;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.restful.jk.JkLyq;
import com.nis.domain.restful.jk.JkLyqSource;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.StringUtil;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.jk.JkLyqService;
import com.wordnik.swagger.annotations.ApiOperation;
/**
* @ClassName: JkLyqController.java
* @Description: TODO
* @author (wx)
* @date 2016年9月7日 下午3:58:16
* @version V1.0
*/
@RestController
@RequestMapping("${servicePath}/jk/v1")
public class JkLyqController extends BaseRestController {
protected final Logger logger = Logger.getLogger(this.getClass());
@Autowired
protected JkLyqService jkLyqService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
/**
* saveJkLyqBatch(多条新增)
* (这里描述这个方法适用条件 可选)
* @param JkLyqSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/jkLyqSources", method = RequestMethod.POST)
@ApiOperation(value = "保存静态控管路由器", httpMethod = "POST", notes = "保存静态控管路由器")
public Map saveJkLyqBatch(@RequestBody JkLyqSource jkLyqSource, HttpServletRequest request, HttpServletResponse response) {
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_POST,request, jkLyqSource);
super.checkOpAction(thread,System.currentTimeMillis()-start, jkLyqSource.getOpAction(), Constants.OPACTION_POST);
try{
checKData(thread,start,jkLyqSource,Constants.OPACTION_POST);
jkLyqService.saveJkLyqBatch(jkLyqSource.getJkLyqList());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage()+"\r\n"+e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"保存静态控管路由器失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"保存静态控管路由器成功",jkLyqSource.getJkLyqList());
}
/**
*
* updateJkLyqBatch(多条更新)
* (这里描述这个方法适用条件 可选)
* @param JkLyqSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/jkLyqSources", method = RequestMethod.PUT)
@ApiOperation(value = "更新静态控管路由器", httpMethod = "PUT", notes = "更新静态控管路由器")
public Map updateJkLyqBatch(@RequestBody JkLyqSource jkLyqSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_PUT,request, jkLyqSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,jkLyqSource.getOpAction(), Constants.OPACTION_PUT);
try{
checKData(thread,start,jkLyqSource,Constants.OPACTION_PUT);
jkLyqService.updateJkLyqBatch(jkLyqSource.getJkLyqList());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
e.printStackTrace();
logger.error(e.getMessage()+"\r\n"+e.getCause());
if(e instanceof RestServiceException) throw e;
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"更新静态控管路由器失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"更新静态控管路由器成功",jkLyqSource.getJkLyqList());
}
/**
*
* deleteJkLyq(单条删除)
* (这里描述这个方法适用条件 可选)
* @param id
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
// @RequestMapping(value = "/jkLyqSources/{id}", method = RequestMethod.DELETE)
// @ApiOperation(value = "删除静态控管路由器", httpMethod = "DELETE", notes = "删除静态控管路由器")
public Map deleteJkLyq(@PathVariable("id") long id, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, id);
try{
jkLyqService.removeJkLyq(id);
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除静态控管路由器失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"删除成功",id);
}
/**
*
* deleteJkLyq(多条删除)
* (这里描述这个方法适用条件 可选)
* @param JkLyqSource
* @param request
* @param response
* @return
*Map
* @exception
* @since 1.0.0
*/
@SuppressWarnings("rawtypes")
// @RequestMapping(value = "/jkLyqSources", method = RequestMethod.DELETE)
// @ApiOperation(value = "删除静态控管路由器", httpMethod = "DELETE", notes = "删除静态控管路由器")
public Map deleteJkLyq(@RequestBody JkLyqSource jkLyqSource, HttpServletRequest request, HttpServletResponse response){
long start=System.currentTimeMillis();
SaveRequestLogThread thread=super.saveRequestLog(servicesRequestLogService,Constants.OPACTION_DELETE,request, jkLyqSource);
super.checkOpAction(thread,System.currentTimeMillis()-start,jkLyqSource.getOpAction(), Constants.OPACTION_DELETE);
try{
jkLyqService.removeJkLyqBatch(jkLyqSource.getJkLyqList());
}catch(Exception e){
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
String info=OracleErrorCodeUtil.getOraCode(e);
if(!StringUtil.isEmpty(info))
OracleErrorCodeUtil.throwExceptionInfo(thread,System.currentTimeMillis()-start,info);
else
throw new RestServiceException(thread,System.currentTimeMillis()-start,"删除静态控管路由器失败", RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request,response,"批量删除成功",jkLyqSource.getJkLyqList());
}
private void checKData(SaveRequestLogThread thread,long start,JkLyqSource jkLyqSource,int opAction){
if(jkLyqSource.getJkLyqList().size()==0){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"静态控管路由器不能为空", RestBusinessCode.unknow_error.getValue());
}
for(JkLyq entity:jkLyqSource.getJkLyqList()){
if(opAction==Constants.OPACTION_POST&&entity!=null&&entity.getSfSx()!=Long.valueOf(Constants.YES)){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"只能新增有效数据", RestBusinessCode.wrong_range.getValue());
}else if(opAction==Constants.OPACTION_PUT&&entity!=null&&entity.getSfSx()!=Long.valueOf(Constants.NO)){
throw new RestServiceException(thread,System.currentTimeMillis()-start,"只允许将有效数据更改为无效数据", RestBusinessCode.wrong_range.getValue());
}
if(opAction==Constants.OPACTION_POST){
entity.setSxFw("0");
}
}
}
}