Commit edb1708243041c2ea656eb3fd411fac693f82b9f

Authored by baohanddd

Merge remote-tracking branch 'origin/master'

Showing 11 changed files

platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/PatientDaoImpl.java View file @ edb1708
... ... @@ -18,7 +18,7 @@
18 18 * <p>
19 19 * Created by Administrator on 2016/4/22 0022.
20 20 */
21   -@Repository("patientDaoImpl")
  21 +@Repository("patientDao")
22 22 public class PatientDaoImpl extends BaseMongoDAOImpl<Patients> implements IPatientDao {
23 23 @Override
24 24 public Patients addPatient(Patients obj) {
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/param/CommunityQuery.java View file @ edb1708
... ... @@ -10,6 +10,19 @@
10 10 private String id;
11 11 private String orgAreaId;
12 12  
  13 + public String getGxxq() {
  14 + return gxxq;
  15 + }
  16 +
  17 + public void setGxxq(String gxxq) {
  18 + this.gxxq = gxxq;
  19 + }
  20 +
  21 + //管辖区域名字
  22 + private String gxxq;
  23 +
  24 +
  25 +
13 26 public String getOrgAreaId() {
14 27 return orgAreaId;
15 28 }
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/BasicConfigService.java View file @ edb1708
1 1 package com.lyms.platform.biz.service;
2 2  
3   -import java.util.Collection;
4   -import java.util.List;
5   -
6   -import com.lyms.platform.common.enums.YnEnums;
7   -import org.apache.commons.lang.StringUtils;
8   -import org.springframework.beans.factory.annotation.Autowired;
9   -import org.springframework.data.domain.Sort;
10   -import org.springframework.data.domain.Sort.Direction;
11   -import org.springframework.stereotype.Service;
12   -
  3 +import com.google.common.cache.*;
13 4 import com.lyms.platform.biz.dal.IBasicConfigDao;
14 5 import com.lyms.platform.common.dao.operator.MongoCondition;
15 6 import com.lyms.platform.common.dao.operator.MongoOper;
16 7 import com.lyms.platform.common.dao.operator.MongoQuery;
17 8 import com.lyms.platform.common.dao.operator.Page;
  9 +import com.lyms.platform.common.enums.YnEnums;
  10 +import com.lyms.platform.common.utils.CacheHelper;
18 11 import com.lyms.platform.pojo.BasicConfig;
19 12 import com.lyms.platform.query.BasicConfigQuery;
  13 +import org.apache.commons.lang.StringUtils;
  14 +import org.springframework.beans.factory.InitializingBean;
  15 +import org.springframework.beans.factory.annotation.Autowired;
  16 +import org.springframework.data.domain.Sort;
  17 +import org.springframework.data.domain.Sort.Direction;
  18 +import org.springframework.stereotype.Service;
20 19  
  20 +import java.util.Collection;
  21 +import java.util.List;
  22 +import java.util.concurrent.TimeUnit;
  23 +
21 24 @Service("basicConfigService")
22   -public class BasicConfigService {
23   -
  25 +public class BasicConfigService implements InitializingBean {
  26 +
24 27 @Autowired
25 28 private IBasicConfigDao basicConfigDao;
26 29  
  30 + private LoadingCache<String, BasicConfig> cached=null;
  31 +
27 32 public void addBasicConfig(BasicConfig obj) {
28 33 obj.setModifiedDate(System.currentTimeMillis());
29 34 basicConfigDao.addBasicConfig(obj);
30 35  
31 36  
32 37  
33 38  
... ... @@ -52,15 +57,35 @@
52 57 return basicConfigDao.queryBasicConfig(MongoCondition.newInstance("parentId", "0", MongoOper.IS).and("yn", YnEnums.YES.getId(), MongoOper.IS).toMongoQuery()
53 58 .addOrder(Direction.ASC, "id"));
54 59 }
  60 +
  61 +
  62 +
  63 +
55 64 public BasicConfig getOneBasicConfigById(String id) {
56   - return basicConfigDao.getOneBasicConfigById(id);
  65 + try{
  66 + return cached.get(id);
  67 + }catch (Exception e){
  68 + }
  69 + return null;
57 70 }
  71 +
58 72 public List<BasicConfig> queryByParentId(String parentId) {
59   - return basicConfigDao.queryBasicConfig(MongoCondition.newInstance("parentId", parentId, MongoOper.IS).and("yn", YnEnums.YES.getId(),MongoOper.IS).toMongoQuery());
  73 + return basicConfigDao.queryBasicConfig(MongoCondition.newInstance("parentId", parentId, MongoOper.IS).and("yn", YnEnums.YES.getId(), MongoOper.IS).toMongoQuery());
60 74 }
61 75  
62 76 public Page<BasicConfig> queryGuidesAndPage(int start, int end) {
63 77 return basicConfigDao.findPage(MongoCondition.newInstance().toMongoQuery().start(start).end(end).addOrder(Direction.ASC, "id"));
  78 + }
  79 +
  80 + @Override
  81 + public void afterPropertiesSet() throws Exception {
  82 + //cache size 为400 缓存3分钟
  83 + cached = CacheHelper.cached(new CacheLoader<String, BasicConfig>() {
  84 + @Override
  85 + public BasicConfig load(String key) throws Exception {
  86 + return basicConfigDao.getOneBasicConfigById(key);
  87 + }
  88 + },400,3);
64 89 }
65 90 }
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/CommunityConfigService.java View file @ edb1708
... ... @@ -46,6 +46,9 @@
46 46 //查询社区
47 47 public List<CommunityConfig> queryCommunity(CommunityQuery communityQuery) {
48 48 MongoCondition mongoCondition = MongoCondition.newInstance();
  49 + if(null!=communityQuery.getGxxq()){
  50 + mongoCondition = new MongoCondition("gxxq", communityQuery.getGxxq(), MongoOper.LIKE);
  51 + }
49 52 if(null != communityQuery.getKeyword()) {
50 53 mongoCondition = mongoCondition.orCondition(new MongoCondition[]{new MongoCondition("name", communityQuery.getKeyword(), MongoOper.LIKE), new MongoCondition("gxxq", communityQuery.getKeyword(), MongoOper.LIKE)});
51 54 }
platform-biz-service/src/main/java/com/lyms/platform/permission/model/Organization.java View file @ edb1708
... ... @@ -34,7 +34,7 @@
34 34 private Object area;
35 35 private Object street;
36 36 private String foreignId;
37   - private Integer orgType; //-1 δÉèÖà 0 ¹«Ë¾ 1 Ò½Ôº
  37 + private Integer orgType; //-1 未设置 0 å…¬å¸ 1 医院
38 38  
39 39 public Integer getOrgType() {
40 40 return orgType;
platform-biz-service/src/main/java/com/lyms/platform/permission/model/Roles.java View file @ edb1708
... ... @@ -10,7 +10,7 @@
10 10 private Integer publishId;
11 11 private String publishName;
12 12 private Integer yn;
13   - private Integer enable; //1 ÆôÓÃ 2½ûÓÃ
  13 + private Integer enable;
14 14 private Date modified;
15 15 private Date created;
16 16 private String remarks;
platform-common/src/main/java/com/lyms/platform/common/perf/DalMethodInterceptor.java View file @ edb1708
... ... @@ -42,7 +42,7 @@
42 42 try {
43 43  
44 44 Object object = arg0.proceed();
45   - if(null==object && arg0.getMethod().getReturnType().isPrimitive()){
  45 + if(null==object &&!"Void".equalsIgnoreCase(arg0.getMethod().getReturnType().getSimpleName())&&arg0.getMethod().getReturnType().isPrimitive()){
46 46 logger.warn("method return is Primitive ,result is null.");
47 47 return typeMap.get(arg0.getMethod().getReturnType());
48 48 }
platform-common/src/main/java/com/lyms/platform/common/utils/CacheHelper.java View file @ edb1708
  1 +package com.lyms.platform.common.utils;
  2 +
  3 +import com.google.common.cache.*;
  4 +
  5 +import java.util.concurrent.TimeUnit;
  6 +
  7 +/**
  8 + * 创建本地缓存
  9 + *
  10 + * Created by Administrator on 2016/5/27 0027.
  11 + */
  12 +public class CacheHelper {
  13 + public static <K, V> LoadingCache<K, V> cached(CacheLoader<K, V> cacheLoader,int size,int minutes) {
  14 + LoadingCache<K, V> cache = CacheBuilder
  15 + .newBuilder()
  16 + .maximumSize(size)
  17 + .expireAfterAccess(minutes, TimeUnit.MINUTES)
  18 + .removalListener(new RemovalListener<K, V>() {
  19 + @Override
  20 + public void onRemoval(RemovalNotification<K, V> rn) {
  21 + System.out.println(rn.getKey() + "被移除");
  22 + }
  23 + })
  24 + .build(cacheLoader);
  25 + return cache;
  26 + }
  27 +}
platform-common/src/main/java/com/lyms/platform/common/utils/LoginUtil.java View file @ edb1708
... ... @@ -6,13 +6,18 @@
6 6 import org.apache.commons.httpclient.methods.GetMethod;
7 7 import org.apache.commons.httpclient.methods.PostMethod;
8 8 import org.apache.commons.lang.*;
  9 +import org.slf4j.Logger;
  10 +import org.slf4j.LoggerFactory;
  11 +import org.springframework.util.StopWatch;
9 12  
10 13 import java.security.MessageDigest;
11 14 import java.security.NoSuchAlgorithmException;
12 15  
13 16 public class LoginUtil {
14   -
  17 + private static Logger logger = LoggerFactory.getLogger("HTTP-INVOKE");
15 18 public static LoginContext register(String phone, String token, String typeId) {
  19 + StopWatch stopWatch = new StopWatch("register");
  20 + stopWatch.start("init http client");
16 21 HttpClient client = new HttpClient();
17 22 PostMethod post = new MessageUtil.UTF8PostMethod("http://passport.healthbaby.com.cn/v1/register.action");
18 23 NameValuePair[] data = {
19 24  
20 25  
21 26  
22 27  
23 28  
24 29  
... ... @@ -21,22 +26,31 @@
21 26 };
22 27 post.setRequestBody(data);
23 28 post.setRequestHeader("Authorization", token);
  29 + stopWatch.stop();
24 30 try {
  31 + stopWatch.start("excuteMethod");
25 32 client.executeMethod(post);
26 33 int statusCode = post.getStatusCode();
27 34 String result = new String(post.getResponseBodyAsString());
28 35 post.releaseConnection();
  36 + stopWatch.stop();
29 37 if (200 == statusCode) {
  38 + stopWatch.start("parse json");
30 39 LoginContext loginState = JsonUtil.str2Obj(result, LoginContext.class);
  40 + stopWatch.stop();
31 41 return loginState;
32 42 }
33 43 } catch (Exception e) {
34 44 e.printStackTrace();
  45 + }finally {
  46 + logger.info(stopWatch.toString());
35 47 }
36 48 return null;
37 49 }
38 50  
39 51 public static Integer aouHospitalUser(String account, String pwd, String typeId, String token) {
  52 + StopWatch stopWatch = new StopWatch("aouHospitalUser");
  53 + stopWatch.start("init http client");
40 54 HttpClient client = new HttpClient();
41 55 PostMethod post = new MessageUtil.UTF8PostMethod("http://passport.healthbaby.com.cn/v1/checkUser.action");
42 56 NameValuePair[] data = {
43 57  
44 58  
45 59  
46 60  
47 61  
48 62  
... ... @@ -46,25 +60,34 @@
46 60 };
47 61 post.setRequestBody(data);
48 62 post.setRequestHeader("Authorization", token);
  63 + stopWatch.stop();
49 64 try {
  65 + stopWatch.start("excuteMethod");
50 66 client.executeMethod(post);
51 67 int statusCode = post.getStatusCode();
52 68 String result = new String(post.getResponseBodyAsString());
53 69  
54 70 post.releaseConnection();
  71 + stopWatch.stop();
55 72 if (200 == statusCode) {
  73 + stopWatch.start("parse json");
56 74 LoginContext loginState = JsonUtil.str2Obj(result, LoginContext.class);
  75 + stopWatch.stop();
57 76 if (0 == loginState.getErrorcode()) {
58 77 return loginState.getId();
59 78 }
60 79 }
61 80 } catch (Exception e) {
62 81 e.printStackTrace();
  82 + }finally {
  83 + logger.info(stopWatch.toString());
63 84 }
64 85 return null;
65 86 }
66 87  
67 88 public static LoginContext loginHospitalUser(String account, String pwd, String typeId, String token) {
  89 + StopWatch stopWatch = new StopWatch("loginHospitalUser");
  90 + stopWatch.start("init http client");
68 91 HttpClient client = new HttpClient();
69 92 PostMethod post = new MessageUtil.UTF8PostMethod("http://passport.healthbaby.com.cn/v1/userLogin.action");
70 93 NameValuePair[] data = {
71 94  
72 95  
73 96  
74 97  
75 98  
76 99  
... ... @@ -74,24 +97,33 @@
74 97 };
75 98 post.setRequestBody(data);
76 99 post.setRequestHeader("Authorization", token);
  100 + stopWatch.stop();
77 101 try {
  102 + stopWatch.start("excuteMethod");
78 103 client.executeMethod(post);
79 104 int statusCode = post.getStatusCode();
80 105 String result = new String(post.getResponseBodyAsString());
81 106  
82 107 post.releaseConnection();
  108 + stopWatch.stop();
83 109 LoginContext loginState = new LoginContext();
84 110 if (200 == statusCode) {
  111 + stopWatch.start("parse json");
85 112 loginState = JsonUtil.str2Obj(result, LoginContext.class);
  113 + stopWatch.stop();
86 114 return loginState;
87 115 }
88 116 } catch (Exception e) {
89 117 e.printStackTrace();
  118 + }finally {
  119 + logger.info(stopWatch.toString());
90 120 }
91 121 return null;
92 122 }
93 123  
94 124 public static LoginContext login(String phone, String varCode, String typeId, String token) {
  125 + StopWatch stopWatch = new StopWatch("login");
  126 + stopWatch.start("init http client");
95 127 HttpClient client = new HttpClient();
96 128 PostMethod post = new MessageUtil.UTF8PostMethod("http://passport.healthbaby.com.cn/v1/login.action");
97 129 NameValuePair[] data = {
98 130  
99 131  
100 132  
101 133  
102 134  
... ... @@ -101,19 +133,26 @@
101 133 };
102 134 post.setRequestBody(data);
103 135 post.setRequestHeader("Authorization", token);
  136 + stopWatch.stop();
104 137 try {
  138 + stopWatch.start("excuteMethod");
105 139 client.executeMethod(post);
106 140 int statusCode = post.getStatusCode();
107 141 String result = new String(post.getResponseBodyAsString());
108 142  
109   - post.releaseConnection();
  143 + post.releaseConnection();stopWatch.stop();
  144 +
110 145 LoginContext loginState = new LoginContext();
111 146 if (200 == statusCode) {
  147 + stopWatch.start("parse json");
112 148 loginState = JsonUtil.str2Obj(result, LoginContext.class);
  149 + stopWatch.stop();
113 150 return loginState;
114 151 }
115 152 } catch (Exception e) {
116 153 e.printStackTrace();
  154 + }finally {
  155 + logger.info(stopWatch.toString());
117 156 }
118 157 return null;
119 158 }
120 159  
121 160  
122 161  
123 162  
124 163  
125 164  
126 165  
127 166  
128 167  
129 168  
130 169  
131 170  
132 171  
... ... @@ -130,44 +169,62 @@
130 169 }
131 170  
132 171 public static LoginContext sendVerCode(String phone, String typeId, String token) {
  172 + StopWatch stopWatch = new StopWatch("sendVerCode");
  173 + stopWatch.start("init http client");
133 174 HttpClient client = new HttpClient();
134 175 String query = "?phone=" + phone + "&typeId=" + typeId + "&token=" + token + "&userType=2";
135 176 GetMethod get = new MessageUtil.UTF8GetMethod("http://passport.healthbaby.com.cn/v1/vercode.action" + query);
136 177  
137 178 get.setRequestHeader("Authorization", token);
  179 + stopWatch.stop();
138 180 try {
  181 + stopWatch.start("excuteMethod");
139 182 client.executeMethod(get);
140 183 int statusCode = get.getStatusCode();
141 184 String result = new String(get.getResponseBodyAsString());
142 185 get.releaseConnection();
  186 + stopWatch.stop();
143 187 if (200 == statusCode) {
  188 + stopWatch.start("parse json");
144 189 LoginContext loginState = JsonUtil.str2Obj(result, LoginContext.class);
  190 + stopWatch.stop();
145 191 return loginState;
146 192 }
147 193 } catch (Exception e) {
148 194 e.printStackTrace();
  195 + }finally {
  196 + logger.info(stopWatch.toString());
149 197 }
150 198 return null;
151 199 }
152 200  
153 201  
154 202 public static LoginContext checkLoginState(String token) {
  203 + StopWatch stopWatch = new StopWatch("checkLoginState");
  204 + stopWatch.start("init http client");
155 205 LoginContext loginState = new LoginContext();
156 206 HttpClient client = new HttpClient();
157 207 String query = "?token=" + token;
158 208 GetMethod get = new MessageUtil.UTF8GetMethod("http://passport.healthbaby.com.cn/v1/check.action" + query);
159 209 get.setRequestHeader("Authorization", token);
  210 + stopWatch.stop();
160 211 try {
  212 + stopWatch.start("excuteMethod");
161 213 client.executeMethod(get);
162 214 int statusCode = get.getStatusCode();
163 215 String result = new String(get.getResponseBodyAsString());
164 216 get.releaseConnection();
  217 + stopWatch.stop();
165 218 if (200 == statusCode) {
  219 + stopWatch.start("parse json");
166 220 loginState = JsonUtil.str2Obj(result, LoginContext.class);
  221 + stopWatch.stop();
167 222 return loginState;
168 223 }
169 224 } catch (Exception e) {
170 225 e.printStackTrace();
  226 + }finally {
  227 + logger.info(stopWatch.toString());
171 228 }
172 229 return loginState;
173 230 }
platform-data-api/src/main/java/com/lyms/platform/data/service/impl/DataImportTaskServiceImpl.java View file @ edb1708
1 1 package com.lyms.platform.data.service.impl;
2 2  
  3 +import com.lyms.platform.biz.param.CommunityQuery;
3 4 import com.lyms.platform.biz.service.BabyService;
4 5 import com.lyms.platform.biz.service.BasicConfigService;
  6 +import com.lyms.platform.biz.service.CommunityConfigService;
5 7 import com.lyms.platform.biz.service.PatientsService;
6 8 import com.lyms.platform.common.enums.PermissionTypeEnums;
7 9 import com.lyms.platform.common.enums.UserTypeEnum;
8 10 import com.lyms.platform.common.enums.VisitStatusEnums;
9 11 import com.lyms.platform.common.enums.YnEnums;
10   -import com.lyms.platform.common.utils.JsonUtil;
  12 +import com.lyms.platform.common.utils.Assert;
11 13 import com.lyms.platform.common.utils.LogUtil;
12 14 import com.lyms.platform.common.utils.LoginUtil;
13 15 import com.lyms.platform.data.service.DataImportTaskService;
14 16 import com.lyms.platform.permission.model.*;
15 17 import com.lyms.platform.permission.service.*;
16   -import com.lyms.platform.pojo.BabyModel;
17 18 import com.lyms.platform.pojo.BasicConfig;
  19 +import com.lyms.platform.pojo.CommunityConfig;
18 20 import com.lyms.platform.pojo.Patients;
19   -import com.lyms.platform.pojo.PuerperaModel;
20 21 import com.lymsh.mommybaby.earlydata.dao.PlatMapper;
21 22 import com.lymsh.mommybaby.earlydata.model.PlatDataContent;
22 23 import com.lymsh.mommybaby.earlydata.model.PlatDataType;
  24 +import org.apache.commons.collections.CollectionUtils;
23 25 import org.apache.commons.lang.StringUtils;
24 26 import org.joda.time.DateTime;
25 27 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -61,6 +63,8 @@
61 63  
62 64 @Autowired
63 65 private PlatMapper platMapper;
  66 + @Autowired
  67 + private CommunityConfigService communityConfigService;
64 68  
65 69  
66 70 @Value("#{configProperties['login.token']}")
... ... @@ -86,7 +90,7 @@
86 90 public void updateBasicConfig() {
87 91 try {
88 92 List<PlatDataType> typeList = platMapper.selectPlatDataType();
89   - for (PlatDataType type:typeList) {
  93 + for (PlatDataType type : typeList) {
90 94 try {
91 95 if (StringUtils.isBlank(type.getDtId())) {
92 96 continue;
... ... @@ -177,6 +181,7 @@
177 181 }
178 182 }
179 183  
  184 +
180 185 /**
181 186 * 每天晚上9点25同步一次
182 187 */
... ... @@ -376,7 +381,6 @@
376 381 }
377 382  
378 383  
379   -
380 384 /**
381 385 * 每5分钟同步一次(早六点到晚九点)
382 386 */
... ... @@ -442,7 +446,8 @@
442 446 patients.setAreaRegisterId(map.get("P_HUSBANDMOBILEPHONE") == null ? null : map.get("P_HUSBANDMOBILEPHONE").toString());
443 447 patients.setVcCardNo(map.get("VC_CARDNO") == null ? null : map.get("VC_CARDNO").toString());
444 448 patients.setDeliverOrg(map.get("P_HOSPITALID") == null ? null : map.get("P_HOSPITALID").toString());
445   -
  449 + //分配社区
  450 + updateCommunity(patients);
446 451 if (patientsService.queryPatientCount(patients.getId()) == 0) {
447 452 patients.setCreated(patients.getModified());
448 453 patients.setIsVisit(VisitStatusEnums.UNVISIT.getId());
... ... @@ -462,6 +467,30 @@
462 467 } catch (Exception e) {
463 468 e.printStackTrace();
464 469 LogUtil.taskError(e.getMessage(), e);
  470 + }
  471 + }
  472 +
  473 + private void updateCommunity(Patients patients) {
  474 + Assert.notNull(patients, "patient must not null.");
  475 +
  476 + CommunityQuery communityQuery = null;
  477 + CommunityConfig communityConfig = null;
  478 + //优先产后修养地,然后现住地址
  479 + if (StringUtils.isNotEmpty(patients.getAreaPostRestId()) && StringUtils.isNotEmpty(patients.getAddressPostRest())) {
  480 + communityQuery = new CommunityQuery();
  481 + communityQuery.setOrgAreaId(patients.getAreaPostRestId());
  482 + communityQuery.setGxxq(patients.getAddressPostRest());
  483 + } else if (StringUtils.isNotEmpty(patients.getAddress()) && StringUtils.isNotEmpty(patients.getAreaId())) {
  484 + communityQuery = new CommunityQuery();
  485 + communityQuery.setOrgAreaId(patients.getAreaId());
  486 + communityQuery.setGxxq(patients.getAddress());
  487 + }
  488 + if (null != communityQuery) {
  489 + List<CommunityConfig> list = communityConfigService.queryCommunity(communityQuery);
  490 + if (CollectionUtils.isNotEmpty(list)) {
  491 + communityConfig = list.get(0);
  492 + patients.setCommunityId(communityConfig.getId());
  493 + }
465 494 }
466 495 }
467 496  
platform-operate-api/src/main/resources/log4j_config.xml View file @ edb1708
... ... @@ -23,9 +23,9 @@
23 23 <param name="ConversionPattern" value="%d %p - %m%n" />
24 24 </layout>
25 25 </appender>
26   - <appender name="Info" class="org.apache.log4j.DailyRollingFileAppender">
  26 + <appender name="HTTP-INVOKE-Info" class="org.apache.log4j.DailyRollingFileAppender">
27 27 <param name="Append" value="true" />
28   - <param name="File" value="${catalina.base}/logs/biz_info.log" />
  28 + <param name="File" value="${catalina.base}/logs/http-invoke.log" />
29 29 <layout class="org.apache.log4j.PatternLayout">
30 30 <param name="ConversionPattern" value="%d %p - %m%n" />
31 31 </layout>
... ... @@ -65,6 +65,10 @@
65 65 <logger name="DAL-MONITOR">
66 66 <level value="debug" />
67 67 <appender-ref ref="DAL-MONITOR" />
  68 + </logger>
  69 + <logger name="HTTP-INVOKE">
  70 + <level value="debug" />
  71 + <appender-ref ref="HTTP-INVOKE-Info" />
68 72 </logger>
69 73 <logger name="ACCESS-MONITOR">
70 74 <level value="debug" />