//handleCash
@Pointcut("execution(* com.gmall88.server.manager.superapp.SuperAppServerManager.handle*(..))")public voidhandleCash(){
}
@Pointcut("execution(* com.gmall88.server.manager.superapp.SuperAppServerManager.addDo*(..))")public voidaddDo(){
}
@Pointcut("execution(* com.gmall88.server.manager.superapp.SuperAppServerManager.handleRetry*(..))")public voidhandleRetry(){
}
@AfterReturning(pointcut= "handleCash() || handleRetry()", returning = "resultValue")public voidhandleCashAfterReturning(JoinPoint jp, Object resultValue) {try{
Object[] parames= jp.getArgs();//获取目标方法体参数
String params = parseParames(parames); //解析目标方法体的参数
String className = jp.getTarget().getClass().toString();//获取目标类名
className = className.substring(className.indexOf("com"));
logger.info("params" +params);
String signature= jp.getSignature().toString();//获取目标方法签名
String methodName = signature.substring(signature.lastIndexOf(".") + 1, signature.indexOf("("));
logger.info("methodName" +methodName);
ReturnResult result= newReturnResult();
String msg= "";int code = -1;if(resultValue instanceofMap){
Map map=(Map) resultValue;if(map.containsKey("errorMsg")){
msg= (String) map.get("errorMsg");
}
}else if(resultValue instanceofReturnResult){
result=(ReturnResult) resultValue;
code=result.getCode();if(code ==ReturnCodeType.NOT_FOUND.getCode()){
msg=result.getMessage();
}
}else{if(resultValue !=null){
msg=resultValue.toString();
}
}if(StringUtils.isNotBlank(msg)) {
String res= com.gmall88.server.util.StringUtils.lessWord(msg, 1000 - 3);
Map map= newHashMap();
map.put("code", code);
map.put("params", params);
map.put("message", res);
JSONObject obj=JSONObject.fromObject(map);
String type="AfterReturning:";
String objString= new String(obj.toString().getBytes("UTF-8"));
String objUTF8= URLEncoder.encode(objString, "UTF-8");
superAppServerManager.addJmsSendEmailToMq(className,methodName,objString,type);
}
}catch(Exception e) {
logger.error(e.getMessage(), e);
}
}