diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/inteceptor/MybatisSqlInterceptor.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/inteceptor/MybatisSqlInterceptor.java index 05ca121..e2a77ee 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/inteceptor/MybatisSqlInterceptor.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/inteceptor/MybatisSqlInterceptor.java @@ -45,9 +45,10 @@ public class MybatisSqlInterceptor implements Interceptor { Object[] args = invocation.getArgs(); Object returnValue = null; - System.out.println("args===="+args); + System.out.println("args===="+args.length); if (args != null && args.length == 2) { + System.out.println("if===="+args.length); MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0]; Object parameter = null; if (invocation.getArgs().length > 1) { @@ -59,29 +60,33 @@ public class MybatisSqlInterceptor implements Interceptor { Configuration configuration = mappedStatement.getConfiguration(); sqlCommandType = mappedStatement.getSqlCommandType().name(); - sql = getSql(configuration, boundSql, sqlId); - System.out.println("sqlCommandType = "+sqlCommandType+":mysql sql =" + sql); - returnValue = invocation.proceed(); - - - //排除lis表 - if (sql == null || sql.toUpperCase().contains("LIS_REPORT_TBL") || sql.toUpperCase().contains("RIS_REPORT_TBL")) - { - return returnValue; - } - if ("UPDATE".equals(sqlCommandType.toLowerCase()) || "DELETE".equals(sqlCommandType.toLowerCase())) + if (!(sql == null || sql.toUpperCase().contains("LIS_REPORT_TBL") || sql.toUpperCase().contains("RIS_REPORT_TBL"))) { - System.out.println("delete and update sync sql = "+sql); - //发送要同步的sql - SendMysqlSyncDatUtil.sendSql(sql, sqlId); + if ("insert".equals(sqlCommandType.toLowerCase())) + { + sql = getSql(configuration, boundSql, sqlId); + } + else + { + if ("update".equals(sqlCommandType.toLowerCase()) || "delete".equals(sqlCommandType.toLowerCase())) + { + System.out.println("delete and update sync sql = "+sql); + //发送要同步的sql + SendMysqlSyncDatUtil.sendSql(sql, sqlId); + sql = null; + } + } } + System.out.println("sqlCommandType = "+sqlCommandType+":mysql sql =" + sql); + returnValue = invocation.proceed(); } else { - returnValue = invocation.proceed(); + System.out.println("else = "+sql); if (StringUtils.isNotEmpty(sql) && "insert".equals(sqlCommandType.toLowerCase())) { + returnValue = invocation.proceed(); if (returnValue != null && returnValue instanceof ArrayList) { List list = (ArrayList)returnValue; @@ -89,22 +94,14 @@ public class MybatisSqlInterceptor implements Interceptor { { sql = sql.replaceFirst("\\(","(ID,"); sql = sql.substring(0,sql.lastIndexOf("(")+1)+list.get(0)+","+sql.substring(sql.lastIndexOf("(")+1,sql.length()); - - - //排除lis表 - if (sql == null || sql.toUpperCase().contains("LIS_REPORT_TBL") || sql.toUpperCase().contains("RIS_REPORT_TBL")) - { - return returnValue; - } System.out.println("add sync sql = "+sql); //发送要同步的sql SendMysqlSyncDatUtil.sendSql(sql, sqlId); + sql = null; } } } - } - return returnValue; } diff --git a/platform-operate-api/src/main/resources/mybatis.xml b/platform-operate-api/src/main/resources/mybatis.xml index 21e1189..a3ff9b6 100644 --- a/platform-operate-api/src/main/resources/mybatis.xml +++ b/platform-operate-api/src/main/resources/mybatis.xml @@ -13,10 +13,10 @@ - - --> + \ No newline at end of file