Commit ff23596df5b38a9c8525b1d724eb85dd89907131

Authored by jiangjiazhi

Merge remote-tracking branch 'origin/master'

Showing 11 changed files

platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/MasterLisMapper.java View file @ ff23596
... ... @@ -26,5 +26,7 @@
26 26 List<LisReportModel> queryLisDataByQuery(LisReportQuery query);
27 27  
28 28 void updateAppLisStatus(List<String> list);
  29 +
  30 + int saveLisDataTemp(LisReportModel models);
29 31 }
platform-biz-service/src/main/java/com/lyms/platform/permission/service/LisService.java View file @ ff23596
... ... @@ -21,5 +21,7 @@
21 21 List<LisReportModel> queryLisDataByQuery(LisReportQuery query);
22 22  
23 23 void updateAppLisStatus(List<String> list);
  24 +
  25 + int saveLisDataTemp(LisReportModel models);
24 26 }
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/LisServiceImpl.java View file @ ff23596
... ... @@ -83,5 +83,10 @@
83 83 public void updateAppLisStatus(List<String> list) {
84 84 masterLisMapper.updateAppLisStatus(list);
85 85 }
  86 +
  87 + @Override
  88 + public int saveLisDataTemp(LisReportModel models) {
  89 + return masterLisMapper.saveLisDataTemp(models);
  90 + }
86 91 }
platform-biz-service/src/main/resources/mainOrm/master/MasterLis.xml View file @ ff23596
... ... @@ -271,11 +271,60 @@
271 271 </select>
272 272  
273 273 <update id="updateAppLisStatus" parameterType="java.util.List" >
274   - UPDATE LIS_REPORT_TBL STATUS = 1 WHERE ID IN
  274 + UPDATE LIS_REPORT_TBL SET STATUS = 1 WHERE ID IN
275 275 <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
276 276 #{item}
277 277 </foreach>
278 278 </update>
  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>
279 328  
280 329 </mapper>
platform-operate-api/src/main/java/com/lyms/platform/operate/web/Test.java View file @ ff23596
... ... @@ -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 @ ff23596
... ... @@ -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/controller/SyncDataController.java View file @ ff23596
... ... @@ -92,20 +92,23 @@
92 92 writeString(response, "Token is error");
93 93 return;
94 94 }
95   -
96   - if (sqlRequest != null) {
97   - String base64Sql = sqlRequest.getSql();
98   - if (StringUtils.isNotEmpty(base64Sql))
99   - {
100   - String sqlId = sqlRequest.getSqlId();
101   - String sql = new String(Base64.decodeBase64(base64Sql));
102   - System.out.println("sqlId = " + sqlId+" : "+sql);
103   - organizationService.execSql(sql);
  95 + try {
  96 + if (sqlRequest != null) {
  97 + String base64Sql = sqlRequest.getSql();
  98 + if (StringUtils.isNotEmpty(base64Sql))
  99 + {
  100 + String sqlId = sqlRequest.getSqlId();
  101 + String sql = new String(Base64.decodeBase64(base64Sql));
  102 + System.out.println("sqlId = " + sqlId+" : "+sql);
  103 + organizationService.execSql(sql);
  104 + }
104 105 }
105   - writeString(response,"execSyncMysqlData success");
106   - } else {
  106 + } catch (Exception e)
  107 + {
107 108 writeString(response, "execSyncMysqlData fail");
  109 + ExceptionUtils.catchException(e,"execSyncMysqlData fail");
108 110 }
  111 + writeString(response,"execSyncMysqlData success");
109 112 }
110 113  
111 114 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyStatisticsManagerFacade.java View file @ ff23596
... ... @@ -925,7 +925,9 @@
925 925 }
926 926 }
927 927 babyCount.add(nocheckCount);
  928 +
928 929 percent.add(percent(nocheckCount,total));
  930 +
929 931 babyStatisticsManagerSelfConversionListResult.setResult(result);
930 932 babyStatisticsManagerSelfConversionListResult.setResultOther(resultOther);
931 933 babyStatisticsManagerSelfConversionListResult.setBabyCount(babyCount);
932 934  
933 935  
... ... @@ -936,9 +938,14 @@
936 938 return babyStatisticsManagerSelfConversionListResult;
937 939 }
938 940  
939   - private String percent(Integer count,Integer total)
  941 + private String percent(Integer count,Integer total)
940 942 {
  943 + if (total != null && total == 0)
  944 + {
  945 + return new BigDecimal(0) + "%";
  946 + }
941 947 return new BigDecimal((double) count * 100 / (double) total).setScale(2, BigDecimal.ROUND_HALF_UP) + "%";
942 948 }
  949 +
943 950 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/LisFacade.java View file @ ff23596
... ... @@ -417,6 +417,20 @@
417 417 query.setHospitalId(patients.getHospitalId());
418 418  
419 419 List<LisReportModel> lises = lisService.queryLisDataByQuery(query);
  420 + if (CollectionUtils.isNotEmpty(lises))
  421 + {
  422 + for(LisReportModel lisReportModel : lises)
  423 + {
  424 + String json = lisReportModel.getItemJson();
  425 + if (StringUtils.isNotEmpty(json))
  426 + {
  427 + List<LisReportItemModel> items = JsonUtil.toList(json,LisReportItemModel.class);
  428 + lisReportModel.setItems(items);
  429 + lisReportModel.setItemJson(null);
  430 + }
  431 + }
  432 + }
  433 +
420 434 BaseObjectResponse objectResponse = new BaseObjectResponse();
421 435 objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
422 436 objectResponse.setData(lises);
423 437  
424 438  
... ... @@ -432,15 +446,21 @@
432 446 * @return
433 447 */
434 448 public BaseResponse updateAppLisStatus(String ids) {
435   - if (StringUtils.isNotEmpty(ids))
436   - {
437   - String[] arrs = ids.split(",");
438   - if (arrs != null && arrs.length > 0)
  449 + try {
  450 + if (StringUtils.isNotEmpty(ids))
439 451 {
440   - List<String> list = new ArrayList<>();
441   - CollectionUtils.addAll(list, arrs);
442   - lisService.updateAppLisStatus(list);
  452 + String[] arrs = ids.split(",");
  453 + if (arrs != null && arrs.length > 0)
  454 + {
  455 + List<String> list = new ArrayList<>();
  456 + CollectionUtils.addAll(list, arrs);
  457 + lisService.updateAppLisStatus(list);
  458 + }
443 459 }
  460 + }
  461 + catch (Exception e)
  462 + {
  463 + return new BaseResponse().setErrorcode(ErrorCodeConstants.SYSTEM_ERROR).setErrormsg(ErrorCodeConstants.SYSTEM_ERROR_DESCRIPTION);
444 464 }
445 465 return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg(ErrorCodeConstants.SUCCESS_DESCRIPTION);
446 466 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/inteceptor/MybatisSqlInterceptor.java View file @ ff23596
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  
  9 +import com.lyms.platform.common.utils.DateUtil;
10 10 import com.lyms.platform.operate.web.utils.SendMysqlSyncDatUtil;
  11 +import org.apache.commons.collections.CollectionUtils;
  12 +import org.apache.commons.lang.StringUtils;
11 13 import org.apache.ibatis.executor.Executor;
  14 +import org.apache.ibatis.executor.resultset.ResultSetHandler;
12 15 import org.apache.ibatis.mapping.BoundSql;
13 16 import org.apache.ibatis.mapping.MappedStatement;
14 17 import org.apache.ibatis.mapping.ParameterMapping;
15 18  
16 19  
17 20  
18 21  
19 22  
20 23  
21 24  
22 25  
23 26  
... ... @@ -22,48 +25,80 @@
22 25 import org.apache.ibatis.type.TypeHandlerRegistry;
23 26  
24 27 /**
  28 + * ๅŒๆญฅ็บฟไธŠmysql็š„ๆ“ไฝœๅˆฐๅŒบๅŸŸ
25 29 * Created by Administrator on 2017-04-24.
26 30 */
27 31 @Intercepts({
28   - @Signature(type = Executor.class, method = "update", args = { MappedStatement.class, Object.class })
29   -
  32 + @Signature(type = Executor.class, method = "update", args = { MappedStatement.class,Object.class }),
  33 + @Signature(type= ResultSetHandler.class, method = "handleResultSets", args = {Statement.class})
30 34 })
31 35 public class MybatisSqlInterceptor implements Interceptor {
32 36  
  37 + private String sql;
33 38  
34   -// @Signature(type= ResultSetHandler.class, method = "handleResultSets", args = {Statement.class})
35 39 private Properties properties;
36 40  
  41 + private String sqlCommandType;
  42 +
  43 + private String sqlId;
  44 +
37 45 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];
  46 +
  47 + Object[] args = invocation.getArgs();
  48 + Object returnValue = null;
  49 + if (args != null && args.length == 2)
  50 + {
  51 + MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
  52 + Object parameter = null;
  53 + if (invocation.getArgs().length > 1) {
  54 + parameter = invocation.getArgs()[1];
  55 + }
  56 +
  57 + sqlId = mappedStatement.getId();
  58 + BoundSql boundSql = mappedStatement.getBoundSql(parameter);
  59 + Configuration configuration = mappedStatement.getConfiguration();
  60 + sqlCommandType = mappedStatement.getSqlCommandType().name();
  61 +
  62 + sql = getSql(configuration, boundSql, sqlId);
  63 + System.out.println("sqlCommandType = "+sqlCommandType+":mysql sql =" + sql);
  64 + returnValue = invocation.proceed();
42 65 }
  66 + else
  67 + {
  68 + returnValue = invocation.proceed();
  69 + if (StringUtils.isNotEmpty(sql) && "insert".equals(sqlCommandType.toLowerCase()))
  70 + {
  71 + if (returnValue != null && returnValue instanceof ArrayList)
  72 + {
  73 + List<Integer> list = (ArrayList)returnValue;
  74 + if (CollectionUtils.isNotEmpty(list))
  75 + {
  76 + sql = sql.replaceFirst("\\(","(ID,");
  77 + sql = sql.substring(0,sql.lastIndexOf("(")+1)+list.get(0)+","+sql.substring(sql.lastIndexOf("(")+1,sql.length());
  78 + }
  79 + }
  80 + }
43 81  
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);
  82 + //ๆŽ’้™คlis่กจ
  83 + if (sql == null || sql.toUpperCase().contains("LIS_REPORT_TBL") || sql.toUpperCase().contains("RIS_REPORT_TBL"))
  84 + {
  85 + return returnValue;
  86 + }
  87 + System.out.println("sync sql = "+sql);
  88 + //ๅ‘้€่ฆๅŒๆญฅ็š„sql
  89 + SendMysqlSyncDatUtil.sendSql(sql, sqlId);
  90 + }
  91 +
52 92 return returnValue;
53 93 }
54 94  
55 95 public static String getSql(Configuration configuration, BoundSql boundSql, String sqlId) {
56 96 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);
  97 +
63 98 return sql;
64 99 }
65 100  
66   - private static String getParameterValue(Object obj) {
  101 + private static String getParameterValue(Object obj,String javaType) {
67 102 String value = null;
68 103 if (obj instanceof String) {
69 104 value = "'" + obj.toString() + "'";
70 105  
... ... @@ -73,10 +108,13 @@
73 108 } else {
74 109 if (obj != null) {
75 110 value = obj.toString();
76   - } else {
77   - value = "";
  111 + } else if ("java.util.Date".equals(javaType)){
  112 + value = "'" +DateUtil.getyyyy_MM_dd_hms(new Date())+ "'";
78 113 }
79   -
  114 + else
  115 + {
  116 + value = "''";
  117 + }
80 118 }
81 119 return value;
82 120 }
... ... @@ -88,7 +126,7 @@
88 126 if (parameterMappings.size() > 0 && parameterObject != null) {
89 127 TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry();
90 128 if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) {
91   - sql = sql.replaceFirst("\\?", getParameterValue(parameterObject));
  129 + sql = sql.replaceFirst("\\?", getParameterValue(parameterObject,parameterObject.getClass().getName()));
92 130  
93 131 } else {
94 132 MetaObject metaObject = configuration.newMetaObject(parameterObject);
95 133  
96 134  
97 135  
... ... @@ -96,21 +134,16 @@
96 134 String propertyName = parameterMapping.getProperty();
97 135 if (metaObject.hasGetter(propertyName)) {
98 136 Object obj = metaObject.getValue(propertyName);
99   - sql = sql.replaceFirst("\\?", getParameterValue(obj));
  137 + sql = sql.replaceFirst("\\?", getParameterValue(obj,parameterMapping.getJavaType().getName()));
100 138 } else if (boundSql.hasAdditionalParameter(propertyName)) {
101 139 Object obj = boundSql.getAdditionalParameter(propertyName);
102   - sql = sql.replaceFirst("\\?", getParameterValue(obj));
  140 + sql = sql.replaceFirst("\\?", getParameterValue(obj,parameterMapping.getJavaType().getName()));
103 141 }
104 142 }
105 143 }
106 144 }
107   -
108 145 return sql;
109 146 }
110   -
111   -
112   -
113   -
114 147  
115 148 public Object plugin(Object target) {
116 149 return Plugin.wrap(target, this);
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/SendMysqlSyncDatUtil.java View file @ ff23596
... ... @@ -27,7 +27,6 @@
27 27 CollectionUtils.addAll(urls, arrs);
28 28 }
29 29 }
30   -
31 30 }
32 31  
33 32 public static void sendSql(String sql ,String sqlId)