Commit e20d7c640fb9af481bd4544ae38449086ced4703
Exists in
master
and in
6 other branches
Merge remote-tracking branch 'origin/master'
Showing 17 changed files
- platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/MasterOrganizationMapper.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/service/OrganizationService.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/OrganizationServiceImpl.java
- platform-biz-service/src/main/resources/mainOrm/master/MasterOrganization.xml
- platform-common/src/main/java/com/lyms/platform/common/utils/IpUtils.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/controller/ReportController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/SyncDataController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/LisFacade.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/request/SqlRequest.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/HttpClientUtil.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/SendMysqlSyncDatUtil.java
- platform-operate-api/src/main/resources/config.properties
- platform-operate-api/src/main/resources/mybatis.xml
- platform-operate-api/src/main/resources/spring/applicationContext-dal.xml
platform-biz-service/src/main/java/com/lyms/platform/permission/dao/master/MasterOrganizationMapper.java
View file @
e20d7c6
platform-biz-service/src/main/java/com/lyms/platform/permission/service/OrganizationService.java
View file @
e20d7c6
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/OrganizationServiceImpl.java
View file @
e20d7c6
... | ... | @@ -77,6 +77,11 @@ |
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | + @Override | |
81 | + public void execSql(String sql) { | |
82 | + masterOrganizationMapper.execSql(sql); | |
83 | + } | |
84 | + | |
80 | 85 | private void addDefaultRoles(Organization obj) { |
81 | 86 | List<Roles> rolesList = new ArrayList<>(); |
82 | 87 | rolesList.add(rolesService.getRoles(87)); |
platform-biz-service/src/main/resources/mainOrm/master/MasterOrganization.xml
View file @
e20d7c6
platform-common/src/main/java/com/lyms/platform/common/utils/IpUtils.java
View file @
e20d7c6
1 | +package com.lyms.platform.common.utils; | |
2 | + | |
3 | +import org.apache.commons.collections.CollectionUtils; | |
4 | + | |
5 | +import javax.servlet.http.HttpServletRequest; | |
6 | +import java.util.HashSet; | |
7 | +import java.util.Set; | |
8 | + | |
9 | +/** | |
10 | + * ip 白名单验证 | |
11 | + * Created by Administrator on 2017-04-21. | |
12 | + */ | |
13 | +public class IpUtils { | |
14 | + | |
15 | + private static Set<String> ipSet = new HashSet<>(); | |
16 | + | |
17 | + static | |
18 | + { | |
19 | + String ips = PropertiesUtils.getPropertyValue("app_server_ip_white"); | |
20 | + if (StringUtils.isNotEmpty(ips)) | |
21 | + { | |
22 | + CollectionUtils.addAll(ipSet, ips.split(",")); | |
23 | + } | |
24 | + } | |
25 | + | |
26 | + public static boolean isWhite(HttpServletRequest request) { | |
27 | + return ipSet.contains(request.getRemoteHost()); | |
28 | + } | |
29 | + | |
30 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/LisController.java
View file @
e20d7c6
... | ... | @@ -129,6 +129,7 @@ |
129 | 129 | |
130 | 130 | /** |
131 | 131 | * 获取lis和ris报告的接口 |
132 | + * 包含这个孕妇在整个区域的lis、ris数据 | |
132 | 133 | * @param vcCardNo 就诊卡号 |
133 | 134 | * @param sortType 排序类型(1,根据日期分类;2,根据检查项目分类) |
134 | 135 | * @return |
... | ... | @@ -141,6 +142,20 @@ |
141 | 142 | HttpServletRequest request) { |
142 | 143 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
143 | 144 | return lisFacade.getLisAndRisData(vcCardNo,sortType,loginState.getId()); |
145 | + } | |
146 | + | |
147 | + | |
148 | + /** | |
149 | + * 返回小程序查询个人的lis报告 | |
150 | + * 该接口由app服务器端调用 | |
151 | + * @param patientId 院内系统的孕妇的建档id | |
152 | + * @return | |
153 | + */ | |
154 | + @RequestMapping(method = RequestMethod.GET, value = "/getAppLis") | |
155 | + @ResponseBody | |
156 | + public BaseResponse getLisAndRisData(@RequestParam("patientId") String patientId, | |
157 | + HttpServletRequest request) { | |
158 | + return lisFacade.getAppLis(patientId,request); | |
144 | 159 | } |
145 | 160 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ReportController.java
View file @
e20d7c6
... | ... | @@ -55,12 +55,12 @@ |
55 | 55 | * @param childBirth |
56 | 56 | */ |
57 | 57 | @RequestMapping(value = "/check/export", method = RequestMethod.GET) |
58 | -// @TokenRequired | |
58 | + @TokenRequired | |
59 | 59 | public void exportCheck(String startDate, String endDate, Integer startWeek, Integer endWeek, Integer childBirth, |
60 | 60 | HttpServletRequest request, HttpServletResponse resp) { |
61 | -// LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
62 | -// reportService.exportCheck(startDate, endDate, startWeek, endWeek, childBirth, loginState.getId(), resp); | |
63 | - reportService.exportCheck(startDate, endDate, startWeek, endWeek, childBirth, 753, resp); | |
61 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
62 | + reportService.exportCheck(startDate, endDate, startWeek, endWeek, childBirth, loginState.getId(), resp); | |
63 | +// reportService.exportCheck(startDate, endDate, startWeek, endWeek, childBirth, 753, resp); | |
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | |
... | ... | @@ -77,13 +77,13 @@ |
77 | 77 | * @return |
78 | 78 | */ |
79 | 79 | @RequestMapping(method = RequestMethod.GET,value = "/checkInfo") |
80 | -// @TokenRequired | |
80 | + @TokenRequired | |
81 | 81 | @ResponseBody |
82 | 82 | public BaseObjectResponse checkInfo(Integer childBirth, String startDate, String endDate, Integer startWeek, Integer endWeek, Integer number, |
83 | 83 | String name, Integer currentPage, Integer pageSize, HttpServletRequest request) { |
84 | -// LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
85 | -// reportService.checkInfo(childBirth, startDate, endDate, startWeek, endWeek, number, name, loginState.getId(), currentPage, pageSize); | |
86 | - return reportService.checkInfo(childBirth, startDate, endDate, startWeek, endWeek, number, name, 753, currentPage, pageSize); | |
84 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
85 | + return reportService.checkInfo(childBirth, startDate, endDate, startWeek, endWeek, number, name, loginState.getId(), currentPage, pageSize); | |
86 | +// return reportService.checkInfo(childBirth, startDate, endDate, startWeek, endWeek, number, name, 753, currentPage, pageSize); | |
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | 90 | |
... | ... | @@ -98,12 +98,12 @@ |
98 | 98 | * @return |
99 | 99 | */ |
100 | 100 | @RequestMapping(method = RequestMethod.GET,value = "/checkInfo/export") |
101 | -// @TokenRequired | |
101 | + @TokenRequired | |
102 | 102 | public void exportCheckInfo(Integer childBirth, String startDate, String endDate, Integer startWeek, Integer endWeek, Integer number, |
103 | 103 | String name, HttpServletRequest request, HttpServletResponse resp) { |
104 | -// LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
105 | -// reportService.exportCheckInfo(childBirth, startDate, endDate, startWeek, endWeek, number, name, loginState.getId(), resp); | |
106 | - reportService.exportCheckInfo(childBirth, startDate, endDate, startWeek, endWeek, number, name, 753, resp); | |
104 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
105 | + reportService.exportCheckInfo(childBirth, startDate, endDate, startWeek, endWeek, number, name, loginState.getId(), resp); | |
106 | +// reportService.exportCheckInfo(childBirth, startDate, endDate, startWeek, endWeek, number, name, 753, resp); | |
107 | 107 | } |
108 | 108 | |
109 | 109 | |
... | ... | @@ -119,8 +119,8 @@ |
119 | 119 | @TokenRequired |
120 | 120 | public BaseObjectResponse doctorMedical(String startDate, String endDate, Integer childBirth, HttpServletRequest request) { |
121 | 121 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
122 | -// return reportService.doctorMedical(startDate, endDate, childBirth, loginState.getId()); | |
123 | - return reportService.doctorMedical(startDate, endDate, childBirth, 753); | |
122 | + return reportService.doctorMedical(startDate, endDate, childBirth, loginState.getId()); | |
123 | +// return reportService.doctorMedical(startDate, endDate, childBirth, 753); | |
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
127 | 127 | |
... | ... | @@ -136,12 +136,12 @@ |
136 | 136 | */ |
137 | 137 | @RequestMapping(method = RequestMethod.GET,value = "/doctorInfo") |
138 | 138 | @ResponseBody |
139 | -// @TokenRequired | |
139 | + @TokenRequired | |
140 | 140 | public BaseObjectResponse doctorInfo(String startDate, String endDate, Integer childBirth, Integer number, String name, |
141 | 141 | Integer currentPage, Integer pageSize, HttpServletRequest request) { |
142 | -// LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
143 | -// return reportService.doctorInfo(startDate, endDate, childBirth, number, name,currentPage, pageSize, loginState.getId()); | |
144 | - return reportService.doctorInfo(startDate, endDate, childBirth, number, name,currentPage, pageSize, 753); | |
142 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
143 | + return reportService.doctorInfo(startDate, endDate, childBirth, number, name,currentPage, pageSize, loginState.getId()); | |
144 | +// return reportService.doctorInfo(startDate, endDate, childBirth, number, name,currentPage, pageSize, 753); | |
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
148 | 148 | |
... | ... | @@ -154,12 +154,12 @@ |
154 | 154 | * @return |
155 | 155 | */ |
156 | 156 | @RequestMapping(method = RequestMethod.GET,value = "/doctorInfo/export") |
157 | -// @TokenRequired | |
157 | + @TokenRequired | |
158 | 158 | public void exportDoctorInfo(String startDate, String endDate, Integer childBirth, Integer number, String name, |
159 | 159 | HttpServletRequest request, HttpServletResponse resp) { |
160 | -// LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
161 | -// reportService.exportDoctorInfo(startDate, endDate, childBirth, number, name, loginState.getId(), resp); | |
162 | - reportService.exportDoctorInfo(startDate, endDate, childBirth, number, name, 753, resp); | |
160 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
161 | + reportService.exportDoctorInfo(startDate, endDate, childBirth, number, name, loginState.getId(), resp); | |
162 | +// reportService.exportDoctorInfo(startDate, endDate, childBirth, number, name, 753, resp); | |
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
... | ... | @@ -173,9 +173,9 @@ |
173 | 173 | @TokenRequired |
174 | 174 | public void exportDoctor(String startDate, String endDate, Integer childBirth, |
175 | 175 | HttpServletRequest request, HttpServletResponse resp) { |
176 | -// LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
177 | -// reportService.exportDoctor(startDate, endDate, childBirth, loginState.getId(), resp); | |
178 | - reportService.exportDoctor(startDate, endDate, childBirth, 753, resp); | |
176 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
177 | + reportService.exportDoctor(startDate, endDate, childBirth, loginState.getId(), resp); | |
178 | +// reportService.exportDoctor(startDate, endDate, childBirth, 753, resp); | |
179 | 179 | } |
180 | 180 | |
181 | 181 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/SyncDataController.java
View file @
e20d7c6
... | ... | @@ -3,16 +3,21 @@ |
3 | 3 | import com.lyms.platform.biz.service.SyncDataService; |
4 | 4 | import com.lyms.platform.common.base.BaseController; |
5 | 5 | import com.lyms.platform.common.pojo.SyncDataModel; |
6 | -import com.lyms.platform.common.utils.Config; | |
7 | -import com.lyms.platform.common.utils.JsonUtil; | |
8 | -import com.lyms.platform.common.utils.LymsEncodeUtil; | |
6 | +import com.lyms.platform.common.utils.*; | |
7 | +import com.lyms.platform.operate.web.request.BabyCheckRequest; | |
8 | +import com.lyms.platform.operate.web.request.SqlRequest; | |
9 | +import com.lyms.platform.permission.service.OrganizationService; | |
9 | 10 | import com.lyms.platform.query.SyncDataQuery; |
11 | +import org.apache.commons.codec.binary.Base64; | |
10 | 12 | import org.apache.commons.lang.StringUtils; |
11 | 13 | import org.springframework.beans.factory.annotation.Autowired; |
12 | 14 | import org.springframework.stereotype.Controller; |
15 | +import org.springframework.web.bind.annotation.RequestBody; | |
16 | +import org.springframework.web.bind.annotation.RequestHeader; | |
13 | 17 | import org.springframework.web.bind.annotation.RequestMapping; |
14 | 18 | import org.springframework.web.bind.annotation.RequestMethod; |
15 | 19 | |
20 | +import javax.servlet.http.HttpServletRequest; | |
16 | 21 | import javax.servlet.http.HttpServletResponse; |
17 | 22 | import java.util.List; |
18 | 23 | |
... | ... | @@ -27,6 +32,9 @@ |
27 | 32 | @Autowired |
28 | 33 | private SyncDataService syncDataService; |
29 | 34 | |
35 | + @Autowired | |
36 | + private OrganizationService organizationService; | |
37 | + | |
30 | 38 | public static String mongo_crypto_key = Config.getItem("mongo_crypto_key", "0"); |
31 | 39 | |
32 | 40 | @RequestMapping(value = "/findSyncData", method = RequestMethod.POST) |
... | ... | @@ -63,6 +71,40 @@ |
63 | 71 | writeString(response,"updateSyncData success"); |
64 | 72 | } else { |
65 | 73 | writeString(response, "updateSyncData fail"); |
74 | + } | |
75 | + } | |
76 | + | |
77 | + | |
78 | + /** | |
79 | + * 同步mysql的数据 | |
80 | + * 把线上执行的sql拿到区域上面执行 | |
81 | + * @param response | |
82 | + * @param sqlRequest | |
83 | + * @param request | |
84 | + */ | |
85 | + @RequestMapping(value = "/syncMysqlData", method = RequestMethod.POST) | |
86 | + public void updateSyncData(HttpServletResponse response, @RequestBody SqlRequest sqlRequest,HttpServletRequest request, | |
87 | + @RequestHeader("Authorization") String token) { | |
88 | + | |
89 | + if (!"3d19960bf3e81e7d816c4f26051c49ba".equals(token)) | |
90 | + { | |
91 | + ExceptionUtils.catchException("The request token is "+ token); | |
92 | + writeString(response, "Token is error"); | |
93 | + return; | |
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); | |
104 | + } | |
105 | + writeString(response,"execSyncMysqlData success"); | |
106 | + } else { | |
107 | + writeString(response, "execSyncMysqlData fail"); | |
66 | 108 | } |
67 | 109 | } |
68 | 110 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/LisFacade.java
View file @
e20d7c6
... | ... | @@ -28,6 +28,7 @@ |
28 | 28 | import org.springframework.data.domain.Sort; |
29 | 29 | import org.springframework.stereotype.Component; |
30 | 30 | |
31 | +import javax.servlet.http.HttpServletRequest; | |
31 | 32 | import java.util.*; |
32 | 33 | |
33 | 34 | /** |
... | ... | @@ -384,6 +385,23 @@ |
384 | 385 | } |
385 | 386 | } |
386 | 387 | return result; |
388 | + } | |
389 | + | |
390 | + /** | |
391 | + * 返回小程序查询个人的lis报告 | |
392 | + * 该接口由app服务器端调用 | |
393 | + * @param patientId | |
394 | + * @param request | |
395 | + * @return | |
396 | + */ | |
397 | + public BaseResponse getAppLis(String patientId, HttpServletRequest request) { | |
398 | + | |
399 | + System.out.println(request.getRemoteAddr()); | |
400 | + System.out.println(request.getRemoteHost()); | |
401 | + System.out.println(request.getRemotePort()); | |
402 | + System.out.println(request.getRequestURI()); | |
403 | + System.out.println(request.getRequestURL()); | |
404 | + return null; | |
387 | 405 | } |
388 | 406 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/inteceptor/MybatisSqlInterceptor.java
View file @
e20d7c6
1 | +package com.lyms.platform.operate.web.inteceptor; | |
2 | + | |
3 | + | |
4 | +import java.text.DateFormat; | |
5 | +import java.util.Date; | |
6 | +import java.util.List; | |
7 | +import java.util.Locale; | |
8 | +import java.util.Properties; | |
9 | + | |
10 | +import com.lyms.platform.operate.web.utils.SendMysqlSyncDatUtil; | |
11 | +import org.apache.ibatis.executor.Executor; | |
12 | +import org.apache.ibatis.mapping.BoundSql; | |
13 | +import org.apache.ibatis.mapping.MappedStatement; | |
14 | +import org.apache.ibatis.mapping.ParameterMapping; | |
15 | +import org.apache.ibatis.plugin.Interceptor; | |
16 | +import org.apache.ibatis.plugin.Intercepts; | |
17 | +import org.apache.ibatis.plugin.Invocation; | |
18 | +import org.apache.ibatis.plugin.Plugin; | |
19 | +import org.apache.ibatis.plugin.Signature; | |
20 | +import org.apache.ibatis.reflection.MetaObject; | |
21 | +import org.apache.ibatis.session.Configuration; | |
22 | +import org.apache.ibatis.type.TypeHandlerRegistry; | |
23 | + | |
24 | +/** | |
25 | + * Created by Administrator on 2017-04-24. | |
26 | + */ | |
27 | +@Intercepts({ | |
28 | + @Signature(type = Executor.class, method = "update", args = { MappedStatement.class, Object.class }) }) | |
29 | +public class MybatisSqlInterceptor implements Interceptor { | |
30 | + | |
31 | + private Properties properties; | |
32 | + | |
33 | + public Object intercept(Invocation invocation) throws Throwable { | |
34 | + MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0]; | |
35 | + Object parameter = null; | |
36 | + if (invocation.getArgs().length > 1) { | |
37 | + parameter = invocation.getArgs()[1]; | |
38 | + } | |
39 | + String sqlId = mappedStatement.getId(); | |
40 | + BoundSql boundSql = mappedStatement.getBoundSql(parameter); | |
41 | + Configuration configuration = mappedStatement.getConfiguration(); | |
42 | + Object returnValue = invocation.proceed(); | |
43 | + String sql = getSql(configuration, boundSql, sqlId); | |
44 | + System.out.println("mysql sql ======"+sql); | |
45 | + return returnValue; | |
46 | + } | |
47 | + | |
48 | + public static String getSql(Configuration configuration, BoundSql boundSql, String sqlId) { | |
49 | + String sql = showSql(configuration, boundSql); | |
50 | + SendMysqlSyncDatUtil.sendSql(sql,sqlId); | |
51 | + return sql; | |
52 | + } | |
53 | + | |
54 | + private static String getParameterValue(Object obj) { | |
55 | + String value = null; | |
56 | + if (obj instanceof String) { | |
57 | + value = "'" + obj.toString() + "'"; | |
58 | + } else if (obj instanceof Date) { | |
59 | + DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.CHINA); | |
60 | + value = "'" + formatter.format(new Date()) + "'"; | |
61 | + } else { | |
62 | + if (obj != null) { | |
63 | + value = obj.toString(); | |
64 | + } else { | |
65 | + value = ""; | |
66 | + } | |
67 | + | |
68 | + } | |
69 | + return value; | |
70 | + } | |
71 | + | |
72 | + public static String showSql(Configuration configuration, BoundSql boundSql) { | |
73 | + Object parameterObject = boundSql.getParameterObject(); | |
74 | + List<ParameterMapping> parameterMappings = boundSql.getParameterMappings(); | |
75 | + String sql = boundSql.getSql().replaceAll("[\\s]+", " "); | |
76 | + if (parameterMappings.size() > 0 && parameterObject != null) { | |
77 | + TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry(); | |
78 | + if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) { | |
79 | + sql = sql.replaceFirst("\\?", getParameterValue(parameterObject)); | |
80 | + | |
81 | + } else { | |
82 | + MetaObject metaObject = configuration.newMetaObject(parameterObject); | |
83 | + for (ParameterMapping parameterMapping : parameterMappings) { | |
84 | + String propertyName = parameterMapping.getProperty(); | |
85 | + if (metaObject.hasGetter(propertyName)) { | |
86 | + Object obj = metaObject.getValue(propertyName); | |
87 | + sql = sql.replaceFirst("\\?", getParameterValue(obj)); | |
88 | + } else if (boundSql.hasAdditionalParameter(propertyName)) { | |
89 | + Object obj = boundSql.getAdditionalParameter(propertyName); | |
90 | + sql = sql.replaceFirst("\\?", getParameterValue(obj)); | |
91 | + } | |
92 | + } | |
93 | + } | |
94 | + } | |
95 | + | |
96 | + return sql; | |
97 | + } | |
98 | + | |
99 | + | |
100 | + | |
101 | + | |
102 | + | |
103 | + public Object plugin(Object target) { | |
104 | + return Plugin.wrap(target, this); | |
105 | + } | |
106 | + | |
107 | + public void setProperties(Properties properties0) { | |
108 | + this.properties = properties0; | |
109 | + } | |
110 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/SqlRequest.java
View file @
e20d7c6
1 | +package com.lyms.platform.operate.web.request; | |
2 | + | |
3 | +/** | |
4 | + * Created by Administrator on 2017-04-25. | |
5 | + */ | |
6 | +public class SqlRequest { | |
7 | + | |
8 | + private String sql; | |
9 | + | |
10 | + private String sqlId; | |
11 | + | |
12 | + public String getSqlId() { | |
13 | + return sqlId; | |
14 | + } | |
15 | + | |
16 | + public void setSqlId(String sqlId) { | |
17 | + this.sqlId = sqlId; | |
18 | + } | |
19 | + | |
20 | + public String getSql() { | |
21 | + return sql; | |
22 | + } | |
23 | + | |
24 | + public void setSql(String sql) { | |
25 | + this.sql = sql; | |
26 | + } | |
27 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/ReportServiceImpl.java
View file @
e20d7c6
... | ... | @@ -29,6 +29,16 @@ |
29 | 29 | @Autowired |
30 | 30 | AutoMatchFacade autoMatchFacade; |
31 | 31 | |
32 | + private static final Map<String, String> colorMap = new HashMap<>(); | |
33 | + | |
34 | + static { | |
35 | + colorMap.put("绿色预警", "#50e39f"); | |
36 | + colorMap.put("黄色预警", "#ffd84d"); | |
37 | + colorMap.put("橙色预警", "#f17d02"); | |
38 | + colorMap.put("红色预警", "#ff6767"); | |
39 | + colorMap.put("紫色预警", "#be75ff"); | |
40 | + } | |
41 | + | |
32 | 42 | @Override |
33 | 43 | public BaseObjectResponse areaCountFacade(String startDate, String endDate, Integer startWeek, Integer endWeek, Integer childBirth, Integer userId) { |
34 | 44 | BaseObjectResponse rest = new BaseObjectResponse(); |
35 | 45 | |
... | ... | @@ -48,13 +58,14 @@ |
48 | 58 | |
49 | 59 | @Override |
50 | 60 | public BaseObjectResponse doctorMedical(String startDate, String endDate, Integer childBirth, Integer userId) { |
61 | + String hospitalId = autoMatchFacade.getHospitalId(userId); | |
51 | 62 | BaseObjectResponse rest = new BaseObjectResponse(); |
52 | 63 | ReportModel reportModel = new ReportModel(); |
53 | 64 | List<Object> params = new ArrayList<>(); |
54 | 65 | List<Object> doctorNames = new ArrayList<>(); |
55 | 66 | List<Object> doctorInfo = new ArrayList<>(); |
56 | 67 | |
57 | - List<Map<String, Object>> restList = reportDao.findList(getDoctorMedicalSql(startDate, endDate, childBirth, params), params); | |
68 | + List<Map<String, Object>> restList = reportDao.findList(getDoctorMedicalSql(startDate, endDate, childBirth, hospitalId, params), params); | |
58 | 69 | |
59 | 70 | List<Map<String, Object>> grid = createDoctorGrid(restList, doctorNames, doctorInfo); |
60 | 71 | |
61 | 72 | |
... | ... | @@ -146,10 +157,30 @@ |
146 | 157 | List<Object> params = new ArrayList<>(); |
147 | 158 | String hospitalId = autoMatchFacade.getHospitalId(userId); |
148 | 159 | PageResult page = findPage(getCheckInfoSql(childBirth, startDate, endDate, startWeek, endWeek, number, name, hospitalId, params), currentPage, pageSize, params); |
160 | + List<Map<String, Object>> grid = (List<Map<String, Object>>) page.getGrid(); | |
161 | + setColor(grid); | |
149 | 162 | rest.setData(page); |
150 | 163 | return rest; |
151 | 164 | } |
152 | 165 | |
166 | + private void setColor(List<Map<String, Object>> grid) { | |
167 | + Iterator<Map<String, Object>> iterator = grid.iterator(); | |
168 | + while (iterator.hasNext()) { | |
169 | + Map<String, Object> map = iterator.next(); | |
170 | + List<String> colors = new ArrayList<>(); | |
171 | + Object highRiskGrade = map.get("HIGH_RISK_GRADE"); | |
172 | + if(highRiskGrade != null && StringUtils.isNotBlank(highRiskGrade.toString())) { | |
173 | + List<String> grades = Arrays.asList(highRiskGrade.toString()); | |
174 | + for (String grade : grades) { | |
175 | + if(colorMap.get(grade) != null) { | |
176 | + colors.add(colorMap.get(grade)); | |
177 | + } | |
178 | + } | |
179 | + map.put("HIGH_RISK_GRADE", colors); | |
180 | + } | |
181 | + } | |
182 | + } | |
183 | + | |
153 | 184 | @Override |
154 | 185 | public void exportCheck(String startDate, String endDate, Integer startWeek, Integer endWeek, Integer childBirth, Integer userId, HttpServletResponse resp) { |
155 | 186 | BaseObjectResponse rest = areaCountFacade(startDate, endDate, startWeek, endWeek, childBirth, userId); |
... | ... | @@ -231,6 +262,8 @@ |
231 | 262 | List<Object> params = new ArrayList<>(); |
232 | 263 | String hospitalId = autoMatchFacade.getHospitalId(userId); |
233 | 264 | PageResult page = findPage(getDoctorInfoSql(startDate, endDate, childBirth, number, name, hospitalId, params), currentPage, pageSize, params); |
265 | + List<Map<String, Object>> grid = (List<Map<String, Object>>) page.getGrid(); | |
266 | + setColor(grid); | |
234 | 267 | rest.setData(page); |
235 | 268 | return rest; |
236 | 269 | } |
... | ... | @@ -310,7 +343,7 @@ |
310 | 343 | } |
311 | 344 | |
312 | 345 | if(StringUtils.isNotBlank(hospitalId)) { |
313 | - sql.append("AND C.YCY_STSTEM_ID = ? "); | |
346 | + sql.append("AND C.YCY_STSTEM_ID = ? "); | |
314 | 347 | params.add(hospitalId); |
315 | 348 | } |
316 | 349 | |
... | ... | @@ -344,7 +377,8 @@ |
344 | 377 | .append("B.HIGH_RISK_FACTOR, ") |
345 | 378 | .append("(CASE WHEN A.IS_CHILDBIRTH=3 THEN E.CHILDBIRTH_DATE ELSE A.EDD_DATE END), ") |
346 | 379 | .append("D.INSERT_DATE, ") |
347 | - .append("D.DOCTOR_NAME"); | |
380 | + .append("D.DOCTOR_NAME ") | |
381 | + .append("ORDER BY D.INSERT_DATE DESC"); | |
348 | 382 | |
349 | 383 | return sql.toString(); |
350 | 384 | } |
... | ... | @@ -481,7 +515,7 @@ |
481 | 515 | return sql.toString(); |
482 | 516 | } |
483 | 517 | |
484 | - private String getDoctorMedicalSql(String startDate, String endDate, Integer childBirth, List<Object> params) { | |
518 | + private String getDoctorMedicalSql(String startDate, String endDate, Integer childBirth, String hospitalId, List<Object> params) { | |
485 | 519 | StringBuilder sql = new StringBuilder(); |
486 | 520 | sql.append("SELECT B.DOCTOR_NAME, ") |
487 | 521 | .append("COUNT(B.EXAMINE_ID) AS CJ_RC, ") |
... | ... | @@ -493,7 +527,7 @@ |
493 | 527 | .append("INNER JOIN ODS_D_HOSPITAL C ON A.HOSPITAL_NO=C.HOSPITAL_NO ") |
494 | 528 | .append("LEFT JOIN ODS_F_EXAMINE_HISTORY_ASC D ON B.EXAMINE_ID=D.EXAMINE_ID AND D.EXAMINE_HISTORY_NUM>1 ") |
495 | 529 | .append("LEFT JOIN ODS_F_EXAMINE_HISTORY_ASC E ON B.EXAMINE_ID=E.EXAMINE_ID AND E.EXAMINE_HISTORY_NUM>4 ") |
496 | - .append("WHERE C.YCY_STSTEM_ID='216' "); | |
530 | + .append("WHERE 1 = 1 "); | |
497 | 531 | |
498 | 532 | if(childBirth != null) { |
499 | 533 | sql.append("AND A.IS_CHILDBIRTH = ? "); |
500 | 534 | |
... | ... | @@ -506,13 +540,17 @@ |
506 | 540 | params.add(endDate); |
507 | 541 | } |
508 | 542 | |
543 | + if(StringUtils.isNotBlank(hospitalId)) { | |
544 | + sql.append("AND C.YCY_STSTEM_ID = ? "); | |
545 | + params.add(hospitalId); | |
546 | + } | |
547 | + | |
509 | 548 | /* if(startWeek != null && endWeek != null) { |
510 | 549 | sql.append("AND A.NOW_WEEKS BETWEEN ? AND ? "); |
511 | 550 | params.add(startWeek); |
512 | 551 | params.add(endWeek); |
513 | 552 | }*/ |
514 | 553 | |
515 | - | |
516 | 554 | sql.append("GROUP BY B.DOCTOR_NAME,B.DOCTOR_NO ") |
517 | 555 | .append("UNION ALL ") |
518 | 556 | .append("SELECT '总计', ") |
519 | 557 | |
520 | 558 | |
... | ... | @@ -523,14 +561,20 @@ |
523 | 561 | .append("FROM ODS_F_GRAVIDA_RECORD A ") |
524 | 562 | .append("INNER JOIN ODS_F_EXAMINE_HISTORY_ASC B ON A.RECORD_ID=B.RECORD_ID AND A.HOSPITAL_NO=B.HOSPITAL_NO ") |
525 | 563 | .append("INNER JOIN ODS_D_HOSPITAL C ON A.HOSPITAL_NO=C.HOSPITAL_NO ") |
526 | - .append("LEFT JOIN ODS_F_EXAMINE_HISTORY_ASC D ON B.EXAMINE_ID=D.EXAMINE_ID AND D.EXAMINE_HISTORY_NUM>1 ") | |
527 | - .append("LEFT JOIN ODS_F_EXAMINE_HISTORY_ASC E ON B.EXAMINE_ID=E.EXAMINE_ID AND E.EXAMINE_HISTORY_NUM>4 "); | |
564 | + .append("LEFT JOIN ODS_F_EXAMINE_HISTORY_ASC D ON B.EXAMINE_ID=D.EXAMINE_ID AND D.EXAMINE_HISTORY_NUM=2 ") | |
565 | + .append("LEFT JOIN ODS_F_EXAMINE_HISTORY_ASC E ON B.EXAMINE_ID=E.EXAMINE_ID AND E.EXAMINE_HISTORY_NUM=5 "); | |
528 | 566 | |
567 | + sql.append("WHERE 1 = 1 "); | |
529 | 568 | if(childBirth != null) { |
530 | 569 | sql.append("AND A.IS_CHILDBIRTH = ? "); |
531 | 570 | params.add(childBirth); |
532 | 571 | } |
533 | 572 | |
573 | + if(StringUtils.isNotBlank(hospitalId)) { | |
574 | + sql.append("AND C.YCY_STSTEM_ID = ? "); | |
575 | + params.add(hospitalId); | |
576 | + } | |
577 | + | |
534 | 578 | if(startDate != null && endDate != null) { |
535 | 579 | sql.append("AND A.CREATE_DATE BETWEEN to_date(?,'yyyy-mm-dd') AND to_date(?,'yyyy-mm-dd') "); |
536 | 580 | params.add(startDate); |
... | ... | @@ -599,7 +643,8 @@ |
599 | 643 | .append("B.HIGH_RISK_FACTOR, ") |
600 | 644 | .append("(CASE WHEN A.IS_CHILDBIRTH=3 THEN E.CHILDBIRTH_DATE ELSE A.EDD_DATE END), ") |
601 | 645 | .append("D.INSERT_DATE, ") |
602 | - .append("D.DOCTOR_NAME "); | |
646 | + .append("D.DOCTOR_NAME ") | |
647 | + .append("ORDER BY D.INSERT_DATE DESC "); | |
603 | 648 | return sql.toString(); |
604 | 649 | } |
605 | 650 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/HttpClientUtil.java
View file @
e20d7c6
... | ... | @@ -3,17 +3,23 @@ |
3 | 3 | /** |
4 | 4 | * Created by Administrator on 2017-01-18. |
5 | 5 | */ |
6 | +import java.io.IOException; | |
6 | 7 | import java.util.*; |
7 | 8 | import java.util.Map.Entry; |
8 | 9 | |
9 | 10 | import com.lyms.platform.common.pojo.SyncDataModel; |
11 | +import com.lyms.platform.common.utils.ExceptionUtils; | |
10 | 12 | import com.lyms.platform.common.utils.JsonUtil; |
11 | 13 | import org.apache.http.HttpEntity; |
12 | 14 | import org.apache.http.HttpResponse; |
15 | +import org.apache.http.HttpStatus; | |
13 | 16 | import org.apache.http.NameValuePair; |
14 | 17 | import org.apache.http.client.HttpClient; |
18 | +import org.apache.http.client.config.RequestConfig; | |
15 | 19 | import org.apache.http.client.entity.UrlEncodedFormEntity; |
16 | 20 | import org.apache.http.client.methods.HttpPost; |
21 | +import org.apache.http.entity.StringEntity; | |
22 | +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; | |
17 | 23 | import org.apache.http.message.BasicNameValuePair; |
18 | 24 | import org.apache.http.util.EntityUtils; |
19 | 25 | |
... | ... | @@ -22,6 +28,30 @@ |
22 | 28 | */ |
23 | 29 | public class HttpClientUtil { |
24 | 30 | |
31 | + | |
32 | + private static PoolingHttpClientConnectionManager connMgr; | |
33 | + private static RequestConfig requestConfig; | |
34 | + private static final int MAX_TIMEOUT = 7000; | |
35 | + | |
36 | + static { | |
37 | + // 设置连接池 | |
38 | + connMgr = new PoolingHttpClientConnectionManager(); | |
39 | + // 设置连接池大小 | |
40 | + connMgr.setMaxTotal(100); | |
41 | + connMgr.setDefaultMaxPerRoute(connMgr.getMaxTotal()); | |
42 | + | |
43 | + RequestConfig.Builder configBuilder = RequestConfig.custom(); | |
44 | + // 设置连接超时 | |
45 | + configBuilder.setConnectTimeout(MAX_TIMEOUT); | |
46 | + // 设置读取超时 | |
47 | + configBuilder.setSocketTimeout(MAX_TIMEOUT); | |
48 | + // 设置从连接池获取连接实例的超时 | |
49 | + configBuilder.setConnectionRequestTimeout(MAX_TIMEOUT); | |
50 | + // 在提交请求之前 测试连接是否可用 | |
51 | + configBuilder.setStaleConnectionCheckEnabled(true); | |
52 | + requestConfig = configBuilder.build(); | |
53 | + } | |
54 | + | |
25 | 55 | public static String doPost(String url,Map<String,String> map,String charset){ |
26 | 56 | HttpClient httpClient = null; |
27 | 57 | HttpPost httpPost = null; |
... | ... | @@ -51,6 +81,54 @@ |
51 | 81 | ex.printStackTrace(); |
52 | 82 | } |
53 | 83 | return result; |
84 | + } | |
85 | + | |
86 | + | |
87 | + /** | |
88 | + * 发送 SSL POST 请求(HTTPS),JSON形式 | |
89 | + * @param apiUrl API接口URL | |
90 | + * @param json JSON对象 | |
91 | + * @return | |
92 | + */ | |
93 | + public static String doPostSSL(String apiUrl, Object json,String token) { | |
94 | + | |
95 | + HttpClient httpClient = null; | |
96 | + HttpPost httpPost = new HttpPost(apiUrl); | |
97 | + HttpResponse response = null; | |
98 | + String httpStr = null; | |
99 | + | |
100 | + try { | |
101 | + httpClient = new SSLClient(); | |
102 | + httpPost.addHeader("Authorization", token); | |
103 | + httpPost.setConfig(requestConfig); | |
104 | + StringEntity stringEntity = new StringEntity(json.toString(),"UTF-8");//解决中文乱码问题 | |
105 | + stringEntity.setContentEncoding("UTF-8"); | |
106 | + stringEntity.setContentType("application/json"); | |
107 | + httpPost.setEntity(stringEntity); | |
108 | + response = httpClient.execute(httpPost); | |
109 | + int statusCode = response.getStatusLine().getStatusCode(); | |
110 | + if (statusCode != HttpStatus.SC_OK) { | |
111 | + return null; | |
112 | + } | |
113 | + HttpEntity entity = response.getEntity(); | |
114 | + if (entity == null) { | |
115 | + return null; | |
116 | + } | |
117 | + httpStr = EntityUtils.toString(entity, "utf-8"); | |
118 | + } catch (Exception e) { | |
119 | + ExceptionUtils.catchException(e,"error https post "); | |
120 | + e.printStackTrace(); | |
121 | + } finally { | |
122 | + if (response != null) { | |
123 | + try { | |
124 | + EntityUtils.consume(response.getEntity()); | |
125 | + } catch (IOException e) { | |
126 | + ExceptionUtils.catchException(e, "error https post "); | |
127 | + e.printStackTrace(); | |
128 | + } | |
129 | + } | |
130 | + } | |
131 | + return httpStr; | |
54 | 132 | } |
55 | 133 | |
56 | 134 | public static void main(String[] args) throws Exception { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/SendMysqlSyncDatUtil.java
View file @
e20d7c6
1 | +package com.lyms.platform.operate.web.utils; | |
2 | + | |
3 | +import com.lyms.platform.common.utils.JsonUtil; | |
4 | +import com.lyms.platform.common.utils.PropertiesUtils; | |
5 | +import com.lyms.platform.common.utils.StringUtils; | |
6 | +import com.lyms.platform.operate.web.request.SqlRequest; | |
7 | +import org.apache.commons.codec.binary.Base64; | |
8 | +import org.apache.commons.collections.CollectionUtils; | |
9 | + | |
10 | +import java.util.HashSet; | |
11 | +import java.util.Set; | |
12 | + | |
13 | +/** | |
14 | + * Created by Administrator on 2017-04-25. | |
15 | + */ | |
16 | +public class SendMysqlSyncDatUtil { | |
17 | + | |
18 | + private static Set<String> urls = new HashSet<>(); | |
19 | + static | |
20 | + { | |
21 | + String sync_mysql_data_url = PropertiesUtils.getPropertyValue("sync_mysql_data_url"); | |
22 | + if (StringUtils.isNotEmpty(sync_mysql_data_url)) | |
23 | + { | |
24 | + String[] arrs = sync_mysql_data_url.split(","); | |
25 | + if (arrs != null && arrs.length > 0) | |
26 | + { | |
27 | + CollectionUtils.addAll(urls, arrs); | |
28 | + } | |
29 | + } | |
30 | + | |
31 | + } | |
32 | + | |
33 | + public static void sendSql(String sql ,String sqlId) | |
34 | + { | |
35 | + SqlRequest request = new SqlRequest(); | |
36 | + request.setSql(Base64.encodeBase64String(sql.getBytes())); | |
37 | + request.setSqlId(sqlId); | |
38 | + String json = JsonUtil.obj2Str(request); | |
39 | + if (CollectionUtils.isNotEmpty(urls)) | |
40 | + { | |
41 | + for(String url : urls) | |
42 | + { | |
43 | + System.out.println("sync mysql url = " + url); | |
44 | + HttpClientUtil.doPostSSL(url,json,"3d19960bf3e81e7d816c4f26051c49ba"); | |
45 | + } | |
46 | + } | |
47 | + | |
48 | + } | |
49 | +} |
platform-operate-api/src/main/resources/config.properties
View file @
e20d7c6
... | ... | @@ -27,6 +27,9 @@ |
27 | 27 | #区域统计地址 |
28 | 28 | area_count_url=119.90.57.26:1522 |
29 | 29 | |
30 | +#同步mysql数据到各个区域的地址,多个用逗号隔开 如:https://area-qhd-api.healthbaby.com.cn:18019/syncMysqlData,https://area-dz-api.healthbaby.com.cn:12356/syncMysqlData | |
31 | +sync_mysql_data_url= | |
32 | + | |
30 | 33 | #数据源相关配置 |
31 | 34 | jdbc.0.driver=oracle.jdbc.driver.OracleDriver |
32 | 35 | jdbc.0.url=jdbc:oracle:thin:@119.90.57.26:1522:orcl |
platform-operate-api/src/main/resources/mybatis.xml
View file @
e20d7c6
1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
2 | +<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" | |
3 | + "http://mybatis.org/dtd/mybatis-3-config.dtd"> | |
4 | +<configuration> | |
5 | +<settings> | |
6 | + <setting name="cacheEnabled" value="true" /> | |
7 | + <setting name="lazyLoadingEnabled" value="true" /> | |
8 | + <setting name="aggressiveLazyLoading" value="false" /> | |
9 | + <setting name="multipleResultSetsEnabled" value="true" /> | |
10 | + <setting name="useColumnLabel" value="true" /> | |
11 | + <setting name="autoMappingBehavior" value="FULL" /> | |
12 | + <setting name="defaultExecutorType" value="SIMPLE" /> | |
13 | + <setting name="defaultStatementTimeout" value="25000" /> | |
14 | + <setting name="callSettersOnNulls" value="true"/> | |
15 | +</settings> | |
16 | + <plugins> | |
17 | + <!-- mybatis写出sql记录控件(拦截器) --> | |
18 | + <plugin interceptor="com.lyms.platform.operate.web.inteceptor.MybatisSqlInterceptor"> <!-- 自己写的那个拦截器 --> | |
19 | + <property name="dialect" value="mysql"/> <!-- mysql的方言 --> | |
20 | + </plugin> | |
21 | + </plugins> | |
22 | +</configuration> |
platform-operate-api/src/main/resources/spring/applicationContext-dal.xml
View file @
e20d7c6
... | ... | @@ -32,6 +32,7 @@ |
32 | 32 | |
33 | 33 | <bean id="masterSqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> |
34 | 34 | <property name="dataSource" ref="masterdataSourceB"/> |
35 | + <property name="configLocation" value="classpath:mybatis.xml"/> | |
35 | 36 | <property name="mapperLocations"> |
36 | 37 | <list> |
37 | 38 | <value>classpath*:mainOrm/master/*.xml</value> |