Commit d507f5ad14b1f6f8cdf21484163469cee1feaeb3
1 parent
7fc6af8642
Exists in
master
and in
6 other branches
update code
Showing 2 changed files with 25 additions and 28 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/inteceptor/MybatisSqlInterceptor.java
View file @
d507f5a
| ... | ... | @@ -45,9 +45,10 @@ |
| 45 | 45 | |
| 46 | 46 | Object[] args = invocation.getArgs(); |
| 47 | 47 | Object returnValue = null; |
| 48 | - System.out.println("args===="+args); | |
| 48 | + System.out.println("args===="+args.length); | |
| 49 | 49 | if (args != null && args.length == 2) |
| 50 | 50 | { |
| 51 | + System.out.println("if===="+args.length); | |
| 51 | 52 | MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0]; |
| 52 | 53 | Object parameter = null; |
| 53 | 54 | if (invocation.getArgs().length > 1) { |
| 54 | 55 | |
| 55 | 56 | |
| 56 | 57 | |
| 57 | 58 | |
| 58 | 59 | |
| ... | ... | @@ -59,29 +60,33 @@ |
| 59 | 60 | Configuration configuration = mappedStatement.getConfiguration(); |
| 60 | 61 | sqlCommandType = mappedStatement.getSqlCommandType().name(); |
| 61 | 62 | |
| 62 | - sql = getSql(configuration, boundSql, sqlId); | |
| 63 | - System.out.println("sqlCommandType = "+sqlCommandType+":mysql sql =" + sql); | |
| 64 | - returnValue = invocation.proceed(); | |
| 65 | - | |
| 66 | - | |
| 67 | - //排除lis表 | |
| 68 | - if (sql == null || sql.toUpperCase().contains("LIS_REPORT_TBL") || sql.toUpperCase().contains("RIS_REPORT_TBL")) | |
| 63 | + if (!(sql == null || sql.toUpperCase().contains("LIS_REPORT_TBL") || sql.toUpperCase().contains("RIS_REPORT_TBL"))) | |
| 69 | 64 | { |
| 70 | - return returnValue; | |
| 65 | + if ("insert".equals(sqlCommandType.toLowerCase())) | |
| 66 | + { | |
| 67 | + sql = getSql(configuration, boundSql, sqlId); | |
| 68 | + } | |
| 69 | + else | |
| 70 | + { | |
| 71 | + if ("update".equals(sqlCommandType.toLowerCase()) || "delete".equals(sqlCommandType.toLowerCase())) | |
| 72 | + { | |
| 73 | + System.out.println("delete and update sync sql = "+sql); | |
| 74 | + //发送要同步的sql | |
| 75 | + SendMysqlSyncDatUtil.sendSql(sql, sqlId); | |
| 76 | + sql = null; | |
| 77 | + } | |
| 78 | + } | |
| 71 | 79 | } |
| 72 | - if ("UPDATE".equals(sqlCommandType.toLowerCase()) || "DELETE".equals(sqlCommandType.toLowerCase())) | |
| 73 | - { | |
| 74 | - System.out.println("delete and update sync sql = "+sql); | |
| 75 | - //发送要同步的sql | |
| 76 | - SendMysqlSyncDatUtil.sendSql(sql, sqlId); | |
| 77 | - } | |
| 78 | 80 | |
| 81 | + System.out.println("sqlCommandType = "+sqlCommandType+":mysql sql =" + sql); | |
| 82 | + returnValue = invocation.proceed(); | |
| 79 | 83 | } |
| 80 | 84 | else |
| 81 | 85 | { |
| 82 | - returnValue = invocation.proceed(); | |
| 86 | + System.out.println("else = "+sql); | |
| 83 | 87 | if (StringUtils.isNotEmpty(sql) && "insert".equals(sqlCommandType.toLowerCase())) |
| 84 | 88 | { |
| 89 | + returnValue = invocation.proceed(); | |
| 85 | 90 | if (returnValue != null && returnValue instanceof ArrayList) |
| 86 | 91 | { |
| 87 | 92 | List<Integer> list = (ArrayList)returnValue; |
| 88 | 93 | |
| 89 | 94 | |
| 90 | 95 | |
| ... | ... | @@ -89,22 +94,14 @@ |
| 89 | 94 | { |
| 90 | 95 | sql = sql.replaceFirst("\\(","(ID,"); |
| 91 | 96 | sql = sql.substring(0,sql.lastIndexOf("(")+1)+list.get(0)+","+sql.substring(sql.lastIndexOf("(")+1,sql.length()); |
| 92 | - | |
| 93 | - | |
| 94 | - //排除lis表 | |
| 95 | - if (sql == null || sql.toUpperCase().contains("LIS_REPORT_TBL") || sql.toUpperCase().contains("RIS_REPORT_TBL")) | |
| 96 | - { | |
| 97 | - return returnValue; | |
| 98 | - } | |
| 99 | 97 | System.out.println("add sync sql = "+sql); |
| 100 | 98 | //发送要同步的sql |
| 101 | 99 | SendMysqlSyncDatUtil.sendSql(sql, sqlId); |
| 100 | + sql = null; | |
| 102 | 101 | } |
| 103 | 102 | } |
| 104 | 103 | } |
| 105 | - | |
| 106 | 104 | } |
| 107 | - | |
| 108 | 105 | return returnValue; |
| 109 | 106 | } |
| 110 | 107 |
platform-operate-api/src/main/resources/mybatis.xml
View file @
d507f5a
| ... | ... | @@ -13,11 +13,11 @@ |
| 13 | 13 | <setting name="defaultStatementTimeout" value="25000" /> |
| 14 | 14 | <setting name="callSettersOnNulls" value="true"/> |
| 15 | 15 | </settings> |
| 16 | - <!-- <plugins> | |
| 17 | - mybatis写出sql记录控件(拦截器) | |
| 16 | + <plugins> | |
| 17 | + <!--mybatis写出sql记录控件(拦截器)--> | |
| 18 | 18 | <plugin interceptor="com.lyms.platform.operate.web.inteceptor.MybatisSqlInterceptor"> |
| 19 | 19 | <property name="dialect" value="mysql"/> |
| 20 | 20 | </plugin> |
| 21 | - </plugins> --> | |
| 21 | + </plugins> <!-- --> | |
| 22 | 22 | </configuration> |