异常收集

This commit is contained in:
wenc000 2020-08-02 23:18:08 +08:00
parent 9a452bea6b
commit bb4ff95a3e
8 changed files with 31 additions and 106 deletions

View File

@ -40,14 +40,6 @@ public class ClientExceptionController extends AbstractController {
@Autowired
private SecurityComponent securityComponent;
@ApiOperation(value = "新增客户端异常", notes = "新增客户端异常接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("saveclientexception")
@CheckRequestBodyAnnotation
public SuccessResult saveClientException(@RequestBody ClientExceptionVO clientExceptionVO) throws Exception {
return clientExceptionService.saveClientException(clientExceptionVO);
}
@ApiOperation(value = "删除客户端异常(id列表)", notes = "删除客户端异常(id列表)接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "ids", value = "ID列表用下划线分隔", paramType = "path", example = "1_2_3")

View File

@ -36,17 +36,6 @@ public class ClientExceptionAppController extends AbstractController {
@Autowired
private IClientExceptionService clientExceptionService;
@ApiOperation(value = "新增客户端异常", notes = "新增客户端异常接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("saveclientexception")
@CheckRequestBodyAnnotation
public SuccessResult saveClientException(@RequestHeader("token") String token, @RequestBody ClientExceptionVO clientExceptionVO) throws Exception {
return clientExceptionService.saveClientExceptionByToken(token, clientExceptionVO);
}
@ApiOperation(value = "删除客户端异常(id列表)", notes = "删除客户端异常(id列表)接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),

View File

@ -36,17 +36,6 @@ public class ClientExceptionResourceController extends AbstractController {
@Autowired
private IClientExceptionService clientExceptionService;
@ApiOperation(value = "新增客户端异常", notes = "新增客户端异常接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("saveclientexception")
@CheckRequestBodyAnnotation
public SuccessResult saveClientException(@RequestBody ClientExceptionVO clientExceptionVO) throws Exception {
return clientExceptionService.saveClientException(clientExceptionVO);
}
@ApiOperation(value = "删除客户端异常(id列表)", notes = "删除客户端异常(id列表)接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"),

View File

@ -3,6 +3,7 @@ package com.cm.central.control.pojo.vos.clientexception;
import com.cm.common.annotation.CheckNumberAnnotation;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringEscapeUtils;
/**
*

View File

@ -22,25 +22,6 @@ import java.util.Map;
**/
public interface IClientExceptionService {
/**
* 新增客户端异常
*
* @param clientExceptionVO
* @return
* @throws Exception
*/
SuccessResult saveClientException(ClientExceptionVO clientExceptionVO) throws Exception;
/**
* 新增客户端异常(APP)
*
* @param token
* @param clientExceptionVO
* @return
* @throws Exception
*/
SuccessResult saveClientExceptionByToken(String token, ClientExceptionVO clientExceptionVO) throws Exception;
/**
* 新增客户端异常
*
@ -50,16 +31,6 @@ public interface IClientExceptionService {
*/
String saveClientExceptionReturnId(ClientExceptionVO clientExceptionVO) throws Exception;
/**
* 新增客户端异常(APP)
*
* @param token
* @param clientExceptionVO
* @return clientExceptionId
* @throws Exception
*/
String saveClientExceptionByTokenReturnId(String token, ClientExceptionVO clientExceptionVO) throws Exception;
/**
* 删除客户端异常
*

View File

@ -34,56 +34,12 @@ public class ClientExceptionServiceImpl extends AbstractService implements IClie
@Autowired
private IClientExceptionDao clientExceptionDao;
@Override
public SuccessResult saveClientException(ClientExceptionVO clientExceptionVO) throws Exception {
saveClientExceptionInfo(null, clientExceptionVO);
return new SuccessResult();
}
@Override
public SuccessResult saveClientExceptionByToken(String token, ClientExceptionVO clientExceptionVO) throws Exception {
saveClientExceptionInfo(token, clientExceptionVO);
return new SuccessResult();
}
@Override
public String saveClientExceptionReturnId(ClientExceptionVO clientExceptionVO) throws Exception {
return saveClientExceptionInfoReturnId(null, clientExceptionVO);
}
@Override
public String saveClientExceptionByTokenReturnId(String token, ClientExceptionVO clientExceptionVO) throws Exception {
return saveClientExceptionInfoReturnId(token, clientExceptionVO);
}
/**
* 新增客户端异常
*
* @param token
* @param clientExceptionVO
* @throws Exception
*/
private void saveClientExceptionInfo(String token, ClientExceptionVO clientExceptionVO) throws Exception {
saveClientExceptionInfoReturnId(token, clientExceptionVO);
}
/**
* 新增客户端异常
*
* @param token
* @param clientExceptionVO
* @return clientExceptionId
* @throws Exception
*/
private String saveClientExceptionInfoReturnId(String token, ClientExceptionVO clientExceptionVO) throws Exception {
String clientExceptionId = UUIDUtil.getUUID();
Map<String, Object> params = HashMapUtil.beanToMap(clientExceptionVO);
params.put("clientExceptionId", clientExceptionId);
if (token != null) {
setSaveInfo(token, params);
} else {
setSaveInfo(params);
}
setSaveInfoByUserId(params, "1");
clientExceptionDao.saveClientException(params);
return clientExceptionId;
}

View File

@ -1,8 +1,16 @@
package com.cm.central.control.service.socket.exception;
import com.alibaba.fastjson.JSONObject;
import com.cm.central.control.manager.SocketServerManager;
import com.cm.central.control.pojo.bos.SocketClientBO;
import com.cm.central.control.pojo.vos.clientexception.ClientExceptionVO;
import com.cm.central.control.service.clientexception.IClientExceptionService;
import com.cm.central.control.service.socket.BaseSocketService;
import com.cm.socket.consts.ISocketConst;
import com.cm.socket.pojo.Message;
import com.cm.socket.pojo.SocketResult;
import io.netty.channel.ChannelHandlerContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
@ -18,9 +26,26 @@ import org.springframework.stereotype.Service;
@Service("socketExceptionServiceImpl")
public class SocketExceptionServiceImpl extends BaseSocketService {
@Autowired
private IClientExceptionService clientExceptionService;
@Override
protected void readMessageService(ChannelHandlerContext channelHandlerContext, Message readMessage) {
SocketResult<JSONObject> socketResult = JSONObject.parseObject(readMessage.getContent(), SocketResult.class);
SocketServerManager socketServerManager = SocketServerManager.getInstance();
SocketClientBO onlineClientByToken = socketServerManager.getOnlineClientByToken(channelHandlerContext.channel().id().asShortText());
ClientExceptionVO clientExceptionVO = new ClientExceptionVO();
clientExceptionVO.setClientId(onlineClientByToken.getClientId());
clientExceptionVO.setExceptionName(socketResult.getData().getString(ISocketConst.EXCEPTION_MESSAGE));
clientExceptionVO.setExceptionSummary(socketResult.getData().getString(ISocketConst.EXCEPTION_CONTENT));
clientExceptionVO.setExceptionType(socketResult.getData().getString(ISocketConst.EXCEPTION_CLASS));
clientExceptionVO.setIsHandle(0);
clientExceptionVO.setIsNoticeProjectLeader(0);
try {
clientExceptionService.saveClientExceptionReturnId(clientExceptionVO);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
}
@Override

View File

@ -53,6 +53,8 @@ public class SocketServerRunnable implements Runnable {
serverBootstrap.option(ChannelOption.SO_KEEPALIVE, true);
// 有数据就立即发送
serverBootstrap.option(ChannelOption.TCP_NODELAY, true);
serverBootstrap.option(ChannelOption.SO_SNDBUF, 1024 * 1024 * 1024);
serverBootstrap.option(ChannelOption.SO_RCVBUF, 1024 * 1024 * 1024);
serverBootstrap.childHandler(socketServerChannelInitializer);
// 启动服务