|
@@ -10,14 +10,12 @@ import com.diagbot.dto.QcCasesEntryHospitalDTO;
|
|
|
import com.diagbot.dto.SysLoginLogDTO;
|
|
|
import com.diagbot.dto.SysOperationLogDTO;
|
|
|
import com.diagbot.dto.SysRoleDTO;
|
|
|
-import com.diagbot.dto.SysUserDeptDTO;
|
|
|
import com.diagbot.entity.BasDeptInfo;
|
|
|
import com.diagbot.entity.QcType;
|
|
|
import com.diagbot.dto.SysUserRoleDTO;
|
|
|
import com.diagbot.entity.SysHospitalSet;
|
|
|
import com.diagbot.entity.SysRole;
|
|
|
import com.diagbot.entity.SysUser;
|
|
|
-import com.diagbot.entity.SysUserDept;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.facade.LoginLogFacade;
|
|
@@ -111,7 +109,14 @@ public class LogAspect {
|
|
|
operationLogHandler(joinPoint);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 操作日志处理类
|
|
|
+ *
|
|
|
+ * @param joinPoint
|
|
|
+ * @Return void
|
|
|
+ */
|
|
|
private void operationLogHandler(JoinPoint joinPoint) {
|
|
|
+
|
|
|
try {
|
|
|
//1.去sys_hospital_set表中拿所有需要进行操作日志记录的url
|
|
|
List<SysHospitalSet> hospitalSets = sysHospitalSetFacade
|
|
@@ -124,7 +129,16 @@ public class LogAspect {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 有包含操作日志配置的进行处理
|
|
|
+ *
|
|
|
+ * @param hospitalSets 操作日志配置
|
|
|
+ * @param httpServletRequest 请求
|
|
|
+ * @param joinPoint 入参
|
|
|
+ * @Return void
|
|
|
+ */
|
|
|
private void havingOperation(List<SysHospitalSet> hospitalSets, HttpServletRequest httpServletRequest, JoinPoint joinPoint) {
|
|
|
+
|
|
|
StringBuffer operationRecordBuffer = new StringBuffer();
|
|
|
//结果拼接容器
|
|
|
Map<String, Object> outMap = new HashMap<>();
|
|
@@ -132,6 +146,7 @@ public class LogAspect {
|
|
|
hospitalSets.stream().forEach(hospitalSet -> {
|
|
|
if (matchers(hospitalSet.getCode(), httpServletRequest)) {
|
|
|
operationUrlHandler(outMap, HttpUtils.getHttpServletRequest().getRequestURI(), joinPoint);
|
|
|
+ //替换拼接结果
|
|
|
String operationRecord = makeOperationRecord(hospitalSet.getValue(), outMap);
|
|
|
if (!operationRecord.contains("#")) {
|
|
|
operationRecordBuffer.append(operationRecord).append(";");
|
|
@@ -158,7 +173,15 @@ public class LogAspect {
|
|
|
saveOperationLog(joinPoint, operationRecordBuffer.toString());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存操作日志
|
|
|
+ *
|
|
|
+ * @param joinPoint
|
|
|
+ * @param operationRecord
|
|
|
+ * @Return void
|
|
|
+ */
|
|
|
private void saveOperationLog(JoinPoint joinPoint, String operationRecord) {
|
|
|
+
|
|
|
try {
|
|
|
if (StringUtil.isNotBlank(operationRecord)) {
|
|
|
SysOperationLogDTO operationLog = new SysOperationLogDTO();
|
|
@@ -199,33 +222,50 @@ public class LogAspect {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 操作日志模板拼接
|
|
|
+ *
|
|
|
+ * @param value 数据库模板内容弄个
|
|
|
+ * @param outMap 拼接集合<占位符,替换值>
|
|
|
+ * @Return java.lang.String
|
|
|
+ */
|
|
|
private String makeOperationRecord(String value, Map<String, Object> outMap) {
|
|
|
+
|
|
|
if (StringUtil.isBlank(value) || outMap.keySet().size() == 0) {
|
|
|
return value;
|
|
|
}
|
|
|
+ //直接占位符替换
|
|
|
for (String key : outMap.keySet()) {
|
|
|
if (value.contains(key)) {
|
|
|
value = value.replaceAll(key, outMap.get(key) + "");
|
|
|
}
|
|
|
}
|
|
|
- //对通过入参的值为key获取value[针对统一url,根据入参的值不同,替换的内容也不同,把这些内容拼接到模板value中{"入参值1":"拼接结果1","入参值2":"拼接结果2","key":"入参名称"}]
|
|
|
try {
|
|
|
+ //对通过入参的值为key获取value[针对统一url,根据入参的值不同,替换的内容也不同,把这些内容拼接到模板value中{"入参值1":"拼接结果1","入参值2":"拼接结果2","key":"入参名称"}]
|
|
|
value = transformModeValue(value, outMap);
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return value;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 针对根据入参值不同取不同内容进行处理
|
|
|
+ * 根据入参的值不同,替换的内容也不同,把这些内容拼接到模板value中{"入参值1":"拼接结果1","入参值2":"拼接结果2","key":"入参名称"}
|
|
|
+ *
|
|
|
+ * @param value
|
|
|
+ * @param outMap
|
|
|
+ * @Return java.lang.String
|
|
|
+ */
|
|
|
private String transformModeValue(String value, Map<String, Object> outMap) {
|
|
|
while (value.contains("{") && value.contains("}")) {
|
|
|
- String strParam = value.substring(value.indexOf("{"), value.indexOf("}")+1);
|
|
|
+ String strParam = value.substring(value.indexOf("{"), value.indexOf("}") + 1);
|
|
|
JSONObject paramJSON = JSONObject.parseObject(strParam);
|
|
|
- String temp = paramJSON.getString(outMap.get("#"+paramJSON.getString("key"))+"");
|
|
|
- if(temp == null){
|
|
|
- temp = "";
|
|
|
+ String temp = paramJSON.getString(outMap.get("#" + paramJSON.getString("key")) + "");
|
|
|
+ if (temp == null) {
|
|
|
+ temp = "#";
|
|
|
}
|
|
|
- value = StringUtils.replace(value,strParam,temp);
|
|
|
+ value = StringUtils.replace(value, strParam, temp);
|
|
|
}
|
|
|
return value;
|
|
|
}
|
|
@@ -241,8 +281,16 @@ public class LogAspect {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 两个对象进行比较
|
|
|
+ *
|
|
|
+ * @param class1
|
|
|
+ * @param class2
|
|
|
+ * @param outMap
|
|
|
+ * @Return void
|
|
|
+ */
|
|
|
public static void compareTwoClass(Object class1, Object class2, Map<String, Object> outMap) {
|
|
|
+
|
|
|
//获取对象的class
|
|
|
Class<?> clazz1 = class1.getClass();
|
|
|
Class<?> clazz2 = class2.getClass();
|
|
@@ -289,25 +337,6 @@ public class LogAspect {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private static void transformValue(Map<String, Object> outMap) {
|
|
|
- if (outMap.keySet().contains("#isReject_new")) {
|
|
|
- if ("0".equals(outMap.get("#isReject_new").toString())) {
|
|
|
- outMap.put("#isReject_new", "非单否");
|
|
|
- }
|
|
|
- if ("1".equals(outMap.get("#isReject_new").toString())) {
|
|
|
- outMap.put("#isReject_new", "单否");
|
|
|
- }
|
|
|
- }
|
|
|
- if (outMap.keySet().contains("#isUsed_new")) {
|
|
|
- if ("0".equals(outMap.get("#isUsed_new").toString())) {
|
|
|
- outMap.put("#isUsed_new", "未启用");
|
|
|
- }
|
|
|
- if ("1".equals(outMap.get("#isUsed_new").toString())) {
|
|
|
- outMap.put("#isUsed_new", "启用");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
//对比两个数据是否内容相同
|
|
|
public static boolean compareTwo(Object object1, Object object2) {
|
|
@@ -339,7 +368,16 @@ public class LogAspect {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 操作日志处理中心
|
|
|
+ *
|
|
|
+ * @param outMap
|
|
|
+ * @param requestURI
|
|
|
+ * @param joinPoint
|
|
|
+ * @Return void
|
|
|
+ */
|
|
|
private void operationUrlHandler(Map<String, Object> outMap, String requestURI, JoinPoint joinPoint) {
|
|
|
+
|
|
|
try {
|
|
|
Object[] args = joinPoint.getArgs();
|
|
|
switch (requestURI) {
|
|
@@ -454,8 +492,6 @@ public class LogAspect {
|
|
|
QcCasesEntryUpdataVO qcCasesEntryUpdataVO = (QcCasesEntryUpdataVO) args[0];
|
|
|
QcCasesEntryHospitalDTO qcCasesEntryHospitalDTO = operationLogFacade.getQcCasesEntryById(qcCasesEntryUpdataVO.getId());
|
|
|
compareTwoClass(qcCasesEntryHospitalDTO, qcCasesEntryUpdataVO, outMap);
|
|
|
- //常规值替换
|
|
|
- transformValue(outMap);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -487,7 +523,9 @@ public class LogAspect {
|
|
|
break;
|
|
|
default:
|
|
|
if (null != args && args.length >= 0) {
|
|
|
- compareTwoClass(args[0], new Object(), outMap);
|
|
|
+ for (Object o : args) {
|
|
|
+ compareTwoClass(o, new Object(), outMap);
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
@@ -542,6 +580,13 @@ public class LogAspect {
|
|
|
return params.trim();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 登录日志处理
|
|
|
+ *
|
|
|
+ * @param joinPoint
|
|
|
+ * @param jsonResult
|
|
|
+ * @Return void
|
|
|
+ */
|
|
|
public void loginLogHandle(JoinPoint joinPoint, Object jsonResult) {
|
|
|
// 返回参数
|
|
|
if (null != jsonResult) {
|
|
@@ -575,7 +620,14 @@ public class LogAspect {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * token解析
|
|
|
+ *
|
|
|
+ * @param token
|
|
|
+ * @Return com.auth0.jwt.interfaces.DecodedJWT
|
|
|
+ */
|
|
|
public static DecodedJWT decodedJWT(String token) {
|
|
|
+
|
|
|
try {
|
|
|
DecodedJWT jwt = JWT.decode(token);
|
|
|
return jwt;
|
|
@@ -585,8 +637,15 @@ public class LogAspect {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * url比对
|
|
|
+ *
|
|
|
+ * @param url
|
|
|
+ * @param request
|
|
|
+ * @Return boolean
|
|
|
+ */
|
|
|
private boolean matchers(String url, HttpServletRequest request) {
|
|
|
+
|
|
|
AntPathRequestMatcher matcher = new AntPathRequestMatcher(url);
|
|
|
if (matcher.matches(request)) {
|
|
|
return true;
|