Commit 77df6afee8291636f8523c2cbc8a1e51f6cd1919
1 parent
76cef22899
Exists in
master
and in
6 other branches
update
Showing 8 changed files with 139 additions and 37 deletions
- platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/MasterLisMapper.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/service/LisService.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/LisServiceImpl.java
- platform-biz-service/src/main/resources/mainOrm/master/MasterLis.xml
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/Test.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/LisController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/inteceptor/MybatisSqlInterceptor.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/SendMysqlSyncDatUtil.java
platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/MasterLisMapper.java
View file @
77df6af
platform-biz-service/src/main/java/com/lyms/platform/permission/service/LisService.java
View file @
77df6af
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/LisServiceImpl.java
View file @
77df6af
platform-biz-service/src/main/resources/mainOrm/master/MasterLis.xml
View file @
77df6af
| ... | ... | @@ -277,5 +277,54 @@ |
| 277 | 277 | </foreach> |
| 278 | 278 | </update> |
| 279 | 279 | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + <insert id="saveLisDataTemp" parameterType="com.lyms.platform.permission.model.LisReportModel" > | |
| 284 | + <selectKey order="AFTER" keyProperty="id" resultType="java.lang.Integer">SELECT LAST_INSERT_ID()</selectKey> | |
| 285 | + INSERT INTO LIS_REPORT_TBL( | |
| 286 | + LIS_ID, | |
| 287 | + TITLE, | |
| 288 | + TYPE, | |
| 289 | + VCCARDNO, | |
| 290 | + NAME, | |
| 291 | + BHNUM, | |
| 292 | + AGE, | |
| 293 | + SEX, | |
| 294 | + APPLY_TIME, | |
| 295 | + CHECK_TIME, | |
| 296 | + PUBLISH_TIME, | |
| 297 | + APPLY_DOCTOR, | |
| 298 | + APPLY_DEPT, | |
| 299 | + CHECKER, | |
| 300 | + MODIFIED, | |
| 301 | + CREATED, | |
| 302 | + HOSPITAL_ID, | |
| 303 | + PHONE, | |
| 304 | + ITEM_JSON | |
| 305 | + ) VALUES ( | |
| 306 | + #{lisId}, | |
| 307 | + #{title}, | |
| 308 | + #{type}, | |
| 309 | + #{vcCardNo}, | |
| 310 | + #{name}, | |
| 311 | + #{ bhnum}, | |
| 312 | + #{age}, | |
| 313 | + #{sex}, | |
| 314 | + #{applyTime}, | |
| 315 | + #{checkTime}, | |
| 316 | + #{publishTime}, | |
| 317 | + #{applyDoctor}, | |
| 318 | + #{applyDept}, | |
| 319 | + #{checker}, | |
| 320 | + #{modified}, | |
| 321 | + #{created}, | |
| 322 | + #{hospitalId}, | |
| 323 | + #{phone}, | |
| 324 | + #{itemJson} | |
| 325 | + ) | |
| 326 | + | |
| 327 | + </insert> | |
| 328 | + | |
| 280 | 329 | </mapper> |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/Test.java
View file @
77df6af
| ... | ... | @@ -25,10 +25,10 @@ |
| 25 | 25 | // |
| 26 | 26 | // |
| 27 | 27 | // System.out.print("5878388d0cf235c11f845399".length()); |
| 28 | - | |
| 29 | - for (Integer i = PatientCheckTicketFacade.complyCurrentDay(DateUtil.parseYMD("2016-08-06")); i <= 5; i++) { | |
| 30 | - System.out.println(i); | |
| 31 | - } | |
| 28 | +// | |
| 29 | +// for (Integer i = PatientCheckTicketFacade.complyCurrentDay(DateUtil.parseYMD("2016-08-06")); i <= 5; i++) { | |
| 30 | +// System.out.println(i); | |
| 31 | +// } | |
| 32 | 32 | // String str = |
| 33 | 33 | // "{\"yesOrNo\":\"yes\",\"26cac65c-a040-4898-b7da-8deed3ba0ec3\":{\"checkBox\":true,\"proName\":\"循环系统类\",\"selected\":[\"6c46f0c0-97f1-4b72-a11c-98eacfff9a8f\",\"3beb4592-0fda-4041-b148-97d315fccb94\",\"87f35a26-379d-4a05-8ab8-01e634835474\",\"17e9c0ff-92e6-4f48-9f02-264711a8689d\",\"fd51e86b-d3ef-4b38-9dc3-174cf5431855\",\"f14e3084-2ad5-4e25-a634-196e96949ef3\",\"f9acf716-50b0-4b45-bebc-9d21983c616f\",\"31f9dcd6-d7f0-42b5-bd7d-72dd7fe3b01a\",\"322ad477-8130-46d0-a67c-de1b4dc9c640\",\"e7582017-b94c-46ed-b7fd-e36c747da13a\",\"04f8bb8b-f074-41bc-8f41-d3bedb65874b\"]},\"57e4bedbf0f0baa1bee496cd\":{\"checkBox\":true,\"proName\":\"其他\",\"selected\":\"其他既往史\"}}"; |
| 34 | 34 | // |
| ... | ... | @@ -81,6 +81,14 @@ |
| 81 | 81 | // } |
| 82 | 82 | // } |
| 83 | 83 | // } |
| 84 | + | |
| 85 | + | |
| 86 | + String sql = "INSERT INTO LIS_REPORT_TBL( LIS_ID, TITLE) VALUES ('122', 'bbbb')"; | |
| 87 | + sql = sql.replaceFirst("\\(","(ID,"); | |
| 88 | + | |
| 89 | + | |
| 90 | + sql = sql.substring(0,sql.lastIndexOf("(")+1)+"11212,"+sql.substring(sql.lastIndexOf("(")+1,sql.length()); | |
| 91 | + System.out.println(sql); | |
| 84 | 92 | |
| 85 | 93 | } |
| 86 | 94 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/LisController.java
View file @
77df6af
| ... | ... | @@ -89,6 +89,15 @@ |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | |
| 92 | +// @RequestMapping(method = RequestMethod.POST, value = "/saveLisDataTemp") | |
| 93 | +// @ResponseBody | |
| 94 | +// public Integer saveLisDataTemp(@RequestBody LisReportModel models, | |
| 95 | +// HttpServletRequest httpServletRequest) { | |
| 96 | +// | |
| 97 | +// return lisService.saveLisDataTemp(models); | |
| 98 | +// } | |
| 99 | + | |
| 100 | + | |
| 92 | 101 | /** |
| 93 | 102 | * 获取lis和ris报告的接口 |
| 94 | 103 | * 包含这个孕妇在整个区域的lis、ris数据 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/inteceptor/MybatisSqlInterceptor.java
View file @
77df6af
| 1 | 1 | package com.lyms.platform.operate.web.inteceptor; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | +import java.sql.ResultSet; | |
| 5 | +import java.sql.Statement; | |
| 4 | 6 | import java.text.DateFormat; |
| 5 | -import java.util.Date; | |
| 6 | -import java.util.List; | |
| 7 | -import java.util.Locale; | |
| 8 | -import java.util.Properties; | |
| 7 | +import java.util.*; | |
| 9 | 8 | |
| 10 | 9 | import com.lyms.platform.operate.web.utils.SendMysqlSyncDatUtil; |
| 10 | +import org.apache.commons.collections.CollectionUtils; | |
| 11 | +import org.apache.commons.lang.StringUtils; | |
| 11 | 12 | import org.apache.ibatis.executor.Executor; |
| 13 | +import org.apache.ibatis.executor.resultset.ResultSetHandler; | |
| 12 | 14 | import org.apache.ibatis.mapping.BoundSql; |
| 13 | 15 | import org.apache.ibatis.mapping.MappedStatement; |
| 14 | 16 | import org.apache.ibatis.mapping.ParameterMapping; |
| 15 | 17 | |
| 16 | 18 | |
| 17 | 19 | |
| 18 | 20 | |
| 19 | 21 | |
| 20 | 22 | |
| 21 | 23 | |
| 22 | 24 | |
| ... | ... | @@ -22,44 +24,76 @@ |
| 22 | 24 | import org.apache.ibatis.type.TypeHandlerRegistry; |
| 23 | 25 | |
| 24 | 26 | /** |
| 27 | + * 同步线上mysql的操作到区域 | |
| 25 | 28 | * Created by Administrator on 2017-04-24. |
| 26 | 29 | */ |
| 27 | 30 | @Intercepts({ |
| 28 | - @Signature(type = Executor.class, method = "update", args = { MappedStatement.class, Object.class }) | |
| 29 | - | |
| 31 | + @Signature(type = Executor.class, method = "update", args = { MappedStatement.class,Object.class }), | |
| 32 | + @Signature(type= ResultSetHandler.class, method = "handleResultSets", args = {Statement.class}) | |
| 30 | 33 | }) |
| 31 | 34 | public class MybatisSqlInterceptor implements Interceptor { |
| 32 | 35 | |
| 36 | + private String sql; | |
| 33 | 37 | |
| 34 | -// @Signature(type= ResultSetHandler.class, method = "handleResultSets", args = {Statement.class}) | |
| 35 | 38 | private Properties properties; |
| 36 | 39 | |
| 40 | + private String sqlCommandType; | |
| 41 | + | |
| 42 | + private String sqlId; | |
| 43 | + | |
| 37 | 44 | public Object intercept(Invocation invocation) throws Throwable { |
| 38 | - MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0]; | |
| 39 | - Object parameter = null; | |
| 40 | - if (invocation.getArgs().length > 1) { | |
| 41 | - parameter = invocation.getArgs()[1]; | |
| 45 | + | |
| 46 | + Object[] args = invocation.getArgs(); | |
| 47 | + Object returnValue = null; | |
| 48 | + if (args != null && args.length == 2) | |
| 49 | + { | |
| 50 | + MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0]; | |
| 51 | + Object parameter = null; | |
| 52 | + if (invocation.getArgs().length > 1) { | |
| 53 | + parameter = invocation.getArgs()[1]; | |
| 54 | + } | |
| 55 | + | |
| 56 | + sqlId = mappedStatement.getId(); | |
| 57 | + BoundSql boundSql = mappedStatement.getBoundSql(parameter); | |
| 58 | + Configuration configuration = mappedStatement.getConfiguration(); | |
| 59 | + sqlCommandType = mappedStatement.getSqlCommandType().name(); | |
| 60 | + | |
| 61 | + sql = getSql(configuration, boundSql, sqlId); | |
| 62 | + System.out.println("sqlCommandType = "+sqlCommandType+":mysql sql =" + sql); | |
| 63 | + returnValue = invocation.proceed(); | |
| 42 | 64 | } |
| 65 | + else | |
| 66 | + { | |
| 67 | + returnValue = invocation.proceed(); | |
| 68 | + if (StringUtils.isNotEmpty(sql) && "insert".equals(sqlCommandType.toLowerCase())) | |
| 69 | + { | |
| 70 | + if (returnValue != null && returnValue instanceof ArrayList) | |
| 71 | + { | |
| 72 | + List<Integer> list = (ArrayList)returnValue; | |
| 73 | + if (CollectionUtils.isNotEmpty(list)) | |
| 74 | + { | |
| 75 | + sql = sql.replaceFirst("\\(","(ID,"); | |
| 76 | + sql = sql.substring(0,sql.lastIndexOf("(")+1)+list.get(0)+","+sql.substring(sql.lastIndexOf("(")+1,sql.length()); | |
| 77 | + } | |
| 78 | + } | |
| 79 | + } | |
| 43 | 80 | |
| 44 | - String sqlId = mappedStatement.getId(); | |
| 45 | - BoundSql boundSql = mappedStatement.getBoundSql(parameter); | |
| 46 | - Configuration configuration = mappedStatement.getConfiguration(); | |
| 47 | - Object returnValue = invocation.proceed(); | |
| 48 | - System.out.println("mysql result ======" + returnValue); | |
| 49 | - System.out.println(mappedStatement.getResulSets()); | |
| 50 | - String sql = getSql(configuration, boundSql, sqlId); | |
| 51 | - System.out.println("mysql sql ======" + sql); | |
| 81 | + //排除lis表 | |
| 82 | + if (sql == null || sql.toUpperCase().contains("LIS_REPORT_TBL") || sql.toUpperCase().contains("RIS_REPORT_TBL")) | |
| 83 | + { | |
| 84 | + return returnValue; | |
| 85 | + } | |
| 86 | + System.out.println("sync sql = "+sql); | |
| 87 | + //发送要同步的sql | |
| 88 | + SendMysqlSyncDatUtil.sendSql(sql, sqlId); | |
| 89 | + } | |
| 90 | + | |
| 52 | 91 | return returnValue; |
| 53 | 92 | } |
| 54 | 93 | |
| 55 | 94 | public static String getSql(Configuration configuration, BoundSql boundSql, String sqlId) { |
| 56 | 95 | String sql = showSql(configuration, boundSql); |
| 57 | - //排除lis表 | |
| 58 | - if (sql.toUpperCase().contains("LIS_REPORT_TBL") || sql.toUpperCase().contains("RIS_REPORT_TBL")) | |
| 59 | - { | |
| 60 | - return sql; | |
| 61 | - } | |
| 62 | - SendMysqlSyncDatUtil.sendSql(sql,sqlId); | |
| 96 | + | |
| 63 | 97 | return sql; |
| 64 | 98 | } |
| 65 | 99 | |
| 66 | 100 | |
| ... | ... | @@ -74,9 +108,8 @@ |
| 74 | 108 | if (obj != null) { |
| 75 | 109 | value = obj.toString(); |
| 76 | 110 | } else { |
| 77 | - value = ""; | |
| 111 | + value = "''"; | |
| 78 | 112 | } |
| 79 | - | |
| 80 | 113 | } |
| 81 | 114 | return value; |
| 82 | 115 | } |
| 83 | 116 | |
| ... | ... | @@ -104,13 +137,8 @@ |
| 104 | 137 | } |
| 105 | 138 | } |
| 106 | 139 | } |
| 107 | - | |
| 108 | 140 | return sql; |
| 109 | 141 | } |
| 110 | - | |
| 111 | - | |
| 112 | - | |
| 113 | - | |
| 114 | 142 | |
| 115 | 143 | public Object plugin(Object target) { |
| 116 | 144 | return Plugin.wrap(target, this); |