Commit 0d93db8cb76ebfa771949ae9e5feb1de0b468ede

Authored by rui.zhang

Merge remote-tracking branch 'origin/master'

Showing 17 changed files

platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/PatientsService.java View file @ 0d93db8
... ... @@ -44,6 +44,16 @@
44 44 return iPatientDao.queryPatient(query.addOrder(Sort.Direction.DESC, "id"));
45 45 }
46 46  
  47 + public int queryPatientCount(PatientsQuery patientsQuery) {
  48 + return iPatientDao.queryPatientCount(patientsQuery.convertToQuery());
  49 + }
  50 +
  51 + public int queryPatientCount(String _id) {
  52 + PatientsQuery patientsQuery = new PatientsQuery();
  53 + patientsQuery.setId(_id);
  54 + return iPatientDao.queryPatientCount(patientsQuery.convertToQuery());
  55 + }
  56 +
47 57 /**
48 58 * 根据身份证号码查询某一个患者
49 59 *
platform-biz-service/src/main/resources/mainOrm/Permissions.xml View file @ 0d93db8
... ... @@ -97,12 +97,12 @@
97 97  
98 98  
99 99 <sql id="orderAndLimit">
100   -<if test="sort != null and sort != '' ">
101   -order by ${sort}
  100 +
  101 +order by weight
102 102 <if test="need != null">
103 103 limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER}
104 104 </if>
105   -</if>
  105 +
106 106 </sql>
107 107  
108 108  
platform-common/src/main/java/com/lyms/platform/common/utils/LoginUtil.java View file @ 0d93db8
... ... @@ -25,7 +25,7 @@
25 25 int statusCode = post.getStatusCode();
26 26 String result = new String(post.getResponseBodyAsString());
27 27 post.releaseConnection();
28   - if(200 == statusCode) {
  28 + if (200 == statusCode) {
29 29 LoginContext loginState = JsonUtil.str2Obj(result, LoginContext.class);
30 30 return loginState;
31 31 }
32 32  
... ... @@ -51,9 +51,9 @@
51 51 String result = new String(post.getResponseBodyAsString());
52 52  
53 53 post.releaseConnection();
54   - if(200 == statusCode) {
  54 + if (200 == statusCode) {
55 55 LoginContext loginState = JsonUtil.str2Obj(result, LoginContext.class);
56   - if(0 == loginState.getErrorcode()) {
  56 + if (0 == loginState.getErrorcode()) {
57 57 return loginState.getId();
58 58 }
59 59 }
60 60  
... ... @@ -79,9 +79,9 @@
79 79 String result = new String(post.getResponseBodyAsString());
80 80  
81 81 post.releaseConnection();
82   - if(200 == statusCode) {
  82 + if (200 == statusCode) {
83 83 LoginContext loginState = JsonUtil.str2Obj(result, LoginContext.class);
84   - if(0 == loginState.getErrorcode()) {
  84 + if (0 == loginState.getErrorcode()) {
85 85 return loginState.getToken();
86 86 }
87 87 }
88 88  
... ... @@ -107,9 +107,9 @@
107 107 String result = new String(post.getResponseBodyAsString());
108 108  
109 109 post.releaseConnection();
110   - if(200 == statusCode) {
  110 + if (200 == statusCode) {
111 111 LoginContext loginState = JsonUtil.str2Obj(result, LoginContext.class);
112   - if(0 == loginState.getErrorcode()) {
  112 + if (0 == loginState.getErrorcode()) {
113 113 return loginState.getToken();
114 114 }
115 115 }
... ... @@ -119,6 +119,17 @@
119 119 return null;
120 120 }
121 121  
  122 + public static void deleteToken(String token) {
  123 + try {
  124 + MessageUtil.UTF8GetMethod utf8GetMethod = new MessageUtil.UTF8GetMethod("http://passport.healthbaby.com.cn/v1/logout.action");
  125 + utf8GetMethod.setRequestHeader("Authorization", token);
  126 + HttpClient client = new HttpClient();
  127 + client.executeMethod(utf8GetMethod);
  128 + } catch (Exception e) {
  129 + ExceptionUtils.catchException(e, "delete token , " + e.getMessage());
  130 + }
  131 + }
  132 +
122 133 public static LoginContext sendVerCode(String phone, String typeId, String token) {
123 134 HttpClient client = new HttpClient();
124 135 String query = "?phone=" + phone + "&typeId=" + typeId + "&token=" + token + "&userType=2";
... ... @@ -130,7 +141,7 @@
130 141 int statusCode = get.getStatusCode();
131 142 String result = new String(get.getResponseBodyAsString());
132 143 get.releaseConnection();
133   - if(200 == statusCode) {
  144 + if (200 == statusCode) {
134 145 LoginContext loginState = JsonUtil.str2Obj(result, LoginContext.class);
135 146 return loginState;
136 147 }
... ... @@ -144,7 +155,7 @@
144 155 public static LoginContext checkLoginState(String token) {
145 156 LoginContext loginState = new LoginContext();
146 157 HttpClient client = new HttpClient();
147   - String query = "?token=" + token ;
  158 + String query = "?token=" + token;
148 159 GetMethod get = new MessageUtil.UTF8GetMethod("http://passport.healthbaby.com.cn/v1/check.action" + query);
149 160 get.setRequestHeader("Authorization", token);
150 161 try {
... ... @@ -152,7 +163,7 @@
152 163 int statusCode = get.getStatusCode();
153 164 String result = new String(get.getResponseBodyAsString());
154 165 get.releaseConnection();
155   - if(200 == statusCode) {
  166 + if (200 == statusCode) {
156 167 loginState = JsonUtil.str2Obj(result, LoginContext.class);
157 168 return loginState;
158 169 }
159 170  
... ... @@ -163,11 +174,9 @@
163 174 }
164 175  
165 176  
166   -
167   -
168 177 public static String md5(String plainText) {
169 178 try {
170   - if(plainText==null){
  179 + if (plainText == null) {
171 180 return null;
172 181 }
173 182 MessageDigest md = MessageDigest.getInstance("MD5");
platform-dal/src/main/java/com/lyms/platform/pojo/Patients.java View file @ 0d93db8
... ... @@ -61,6 +61,86 @@
61 61 }
62 62  
63 63 /**
  64 + * 产后休养地
  65 + */
  66 + private String addressPostRest;
  67 + private String provincePostRestId;
  68 + private String cityPostRestId;
  69 + private String areaPostRestId;
  70 +
  71 + public String getAddressPostRest() {
  72 + return addressPostRest;
  73 + }
  74 +
  75 + public void setAddressPostRest(String addressPostRest) {
  76 + this.addressPostRest = addressPostRest;
  77 + }
  78 +
  79 + public String getProvincePostRestId() {
  80 + return provincePostRestId;
  81 + }
  82 +
  83 + public void setProvincePostRestId(String provincePostRestId) {
  84 + this.provincePostRestId = provincePostRestId;
  85 + }
  86 +
  87 + public String getCityPostRestId() {
  88 + return cityPostRestId;
  89 + }
  90 +
  91 + public void setCityPostRestId(String cityPostRestId) {
  92 + this.cityPostRestId = cityPostRestId;
  93 + }
  94 +
  95 + public String getAreaPostRestId() {
  96 + return areaPostRestId;
  97 + }
  98 +
  99 + public void setAreaPostRestId(String areaPostRestId) {
  100 + this.areaPostRestId = areaPostRestId;
  101 + }
  102 +
  103 + /**
  104 + * 户籍
  105 + */
  106 + private String addressRegister;
  107 + private String provinceRegisterId;
  108 + private String cityRegisterId;
  109 + private String areaRegisterId;
  110 +
  111 + public String getAddressRegister() {
  112 + return addressRegister;
  113 + }
  114 +
  115 + public void setAddressRegister(String addressRegister) {
  116 + this.addressRegister = addressRegister;
  117 + }
  118 +
  119 + public String getProvinceRegisterId() {
  120 + return provinceRegisterId;
  121 + }
  122 +
  123 + public void setProvinceRegisterId(String provinceRegisterId) {
  124 + this.provinceRegisterId = provinceRegisterId;
  125 + }
  126 +
  127 + public String getCityRegisterId() {
  128 + return cityRegisterId;
  129 + }
  130 +
  131 + public void setCityRegisterId(String cityRegisterId) {
  132 + this.cityRegisterId = cityRegisterId;
  133 + }
  134 +
  135 + public String getAreaRegisterId() {
  136 + return areaRegisterId;
  137 + }
  138 +
  139 + public void setAreaRegisterId(String areaRegisterId) {
  140 + this.areaRegisterId = areaRegisterId;
  141 + }
  142 +
  143 + /**
64 144 * 社区id
65 145 */
66 146 private String communityId;
... ... @@ -120,6 +200,42 @@
120 200 private Integer serviceType;
121 201 private Integer vip;
122 202 private String lastReportDoctorName;
  203 + private String mommyPatientId;
  204 + private String husbandName;
  205 + private String husbandPhone;
  206 + private String vcCardNo;
  207 +
  208 + public String getVcCardNo() {
  209 + return vcCardNo;
  210 + }
  211 +
  212 + public void setVcCardNo(String vcCardNo) {
  213 + this.vcCardNo = vcCardNo;
  214 + }
  215 +
  216 + public String getHusbandName() {
  217 + return husbandName;
  218 + }
  219 +
  220 + public void setHusbandName(String husbandName) {
  221 + this.husbandName = husbandName;
  222 + }
  223 +
  224 + public String getHusbandPhone() {
  225 + return husbandPhone;
  226 + }
  227 +
  228 + public void setHusbandPhone(String husbandPhone) {
  229 + this.husbandPhone = husbandPhone;
  230 + }
  231 +
  232 + public String getMommyPatientId() {
  233 + return mommyPatientId;
  234 + }
  235 +
  236 + public void setMommyPatientId(String mommyPatientId) {
  237 + this.mommyPatientId = mommyPatientId;
  238 + }
123 239  
124 240 public String getLastCheckEmployeeId() {
125 241 return lastCheckEmployeeId;
platform-dal/src/main/java/com/lyms/platform/query/PatientsQuery.java View file @ 0d93db8
... ... @@ -190,7 +190,7 @@
190 190 condition= condition.and("communityId", communityId, MongoOper.IS);
191 191 }
192 192 if(null!=id){
193   - condition= condition.and("id", new ObjectId(id), MongoOper.IS);
  193 + condition= condition.and("id", id, MongoOper.IS);
194 194 }
195 195 if(null!=cardNo){
196 196 condition=condition.and("cardno", cardNo, MongoOper.IS);
platform-data-api/src/main/java/com/lyms/platform/data/controller/TaskController.java View file @ 0d93db8
... ... @@ -59,6 +59,9 @@
59 59 } else if ("fullUpdateUsers".equals(sid)) {
60 60 dataImportTaskService.fullUpdateUsers();
61 61 writeString(response, "success");
  62 + } else if ("fullUpdatePatients".equals(sid)) {
  63 + dataImportTaskService.fullUpdatePatients();
  64 + writeString(response, "success");
62 65 } else if ("codeinit111".equals(sid)) {
63 66 try {
64 67 List<String> list = FileUtils.readLines(new File("d:/streets.csv"));
platform-data-api/src/main/java/com/lyms/platform/data/service/impl/DataImportTaskServiceImpl.java View file @ 0d93db8
1 1 package com.lyms.platform.data.service.impl;
2 2  
  3 +import com.lyms.platform.biz.service.BabyService;
3 4 import com.lyms.platform.biz.service.BasicConfigService;
  5 +import com.lyms.platform.biz.service.PatientsService;
4 6 import com.lyms.platform.common.enums.PermissionTypeEnums;
5 7 import com.lyms.platform.common.enums.YnEnums;
6 8 import com.lyms.platform.common.utils.JsonUtil;
7 9  
... ... @@ -9,7 +11,10 @@
9 11 import com.lyms.platform.data.service.DataImportTaskService;
10 12 import com.lyms.platform.permission.model.*;
11 13 import com.lyms.platform.permission.service.*;
  14 +import com.lyms.platform.pojo.BabyModel;
12 15 import com.lyms.platform.pojo.BasicConfig;
  16 +import com.lyms.platform.pojo.Patients;
  17 +import com.lyms.platform.pojo.PuerperaModel;
13 18 import com.lymsh.mommybaby.earlydata.dao.PlatMapper;
14 19 import com.lymsh.mommybaby.earlydata.model.PlatDataContent;
15 20 import org.apache.commons.lang.StringUtils;
... ... @@ -46,6 +51,12 @@
46 51 private UserRoleMapsService userRoleMapsService;
47 52  
48 53 @Autowired
  54 + private PatientsService patientsService;
  55 +
  56 + @Autowired
  57 + private BabyService babyService;
  58 +
  59 + @Autowired
49 60 private PlatMapper platMapper;
50 61  
51 62  
52 63  
53 64  
... ... @@ -65,9 +76,63 @@
65 76 }
66 77 }
67 78  
  79 + /**
  80 + * 每个小时的57分钟同步一次
  81 + */
68 82 @Override
  83 + public void updateBasicConfig() {
  84 + try {
  85 + List<PlatDataContent> list = platMapper.selectPlatDataContent();
  86 + for (PlatDataContent data : list) {
  87 + try {
  88 + if (StringUtils.isBlank(data.getDcId())) {
  89 + continue;
  90 + }
  91 + BasicConfig config = new BasicConfig();
  92 + config.setId(data.getDcId());
  93 + config.setCode(data.getDcNo());
  94 + config.setName(data.getDcName());
  95 + config.setParentId(data.getDcParentid());
  96 + config.setTypeId(data.getDcDatatypeid());
  97 + config.setYn(YnEnums.YES.getId());
  98 + BasicConfig db = basicConfigService.getOneBasicConfigById(data.getDcId());
  99 + if (db == null) {
  100 + basicConfigService.addBasicConfig(config);
  101 + } else {
  102 + basicConfigService.updateBasicConfig(config);
  103 + }
  104 + } catch (Exception ee) {
  105 + ee.printStackTrace();
  106 + LogUtil.taskError(ee.getMessage(), ee);
  107 + }
  108 + }
  109 + } catch (Exception e) {
  110 + e.printStackTrace();
  111 + LogUtil.taskError(e.getMessage(), e);
  112 + }
  113 + }
  114 +
  115 + @Override
  116 + public void updateAssay() {
  117 +
  118 + }
  119 +
  120 + @Override
  121 + public void fullUpdateAssay() {
  122 +
  123 + }
  124 +
  125 + @Override
  126 + public void updateAssayByHospital(String hospitalForeignId, Integer hospitalId, Date startTime) {
  127 +
  128 + }
  129 +
  130 + /**
  131 + * 每10分钟同步一次(早六点到晚九点)
  132 + */
  133 + @Override
69 134 public void updateUsers() {
70   - Date startTime = new DateTime().minusMinutes(7).toDate();
  135 + Date startTime = new DateTime().minusMinutes(14).toDate();
71 136 OrganizationQuery query = new OrganizationQuery();
72 137 query.setYn(YnEnums.YES.getId());
73 138 List<Organization> list = organizationService.queryOrganization(query);
... ... @@ -78,6 +143,9 @@
78 143 }
79 144 }
80 145  
  146 + /**
  147 + * 每天晚上9点25同步一次
  148 + */
81 149 @Override
82 150 public void fullUpdateUsers() {
83 151 updateUsersByHospital(null, null, null);
84 152  
85 153  
86 154  
87 155  
88 156  
89 157  
90 158  
91 159  
92 160  
93 161  
94 162  
95 163  
96 164  
97 165  
98 166  
99 167  
... ... @@ -271,77 +339,117 @@
271 339  
272 340 }
273 341  
  342 +
  343 +
  344 + /**
  345 + * 每5分钟同步一次(早六点到晚九点)
  346 + */
274 347 @Override
275   - public void updateBasicConfig() {
276   - try {
277   - List<PlatDataContent> list = platMapper.selectPlatDataContent();
278   - for (PlatDataContent data : list) {
279   - try {
280   - if (StringUtils.isBlank(data.getDcId())) {
281   - continue;
282   - }
283   - BasicConfig config = new BasicConfig();
284   - config.setId(data.getDcId());
285   - config.setCode(data.getDcNo());
286   - config.setName(data.getDcName());
287   - config.setParentId(data.getDcParentid());
288   - config.setTypeId(data.getDcDatatypeid());
289   - config.setYn(YnEnums.YES.getId());
290   - BasicConfig db = basicConfigService.getOneBasicConfigById(data.getDcId());
291   - if (db == null) {
292   - basicConfigService.addBasicConfig(config);
293   - } else {
294   - basicConfigService.updateBasicConfig(config);
295   - }
296   - } catch (Exception ee) {
297   - ee.printStackTrace();
298   - LogUtil.taskError(ee.getMessage(), ee);
299   - }
  348 + public void updatePatients() {
  349 + Date startTime = new DateTime().minusMinutes(10).toDate();
  350 + OrganizationQuery query = new OrganizationQuery();
  351 + query.setYn(YnEnums.YES.getId());
  352 + List<Organization> list = organizationService.queryOrganization(query);
  353 + for (Organization organization : list) {
  354 + if (StringUtils.isNotBlank(organization.getForeignId())) {
  355 + updatePatientsByHospital(organization.getForeignId(), organization.getId(), null);
300 356 }
301   - } catch (Exception e) {
302   - e.printStackTrace();
303   - LogUtil.taskError(e.getMessage(), e);
304 357 }
305 358 }
306 359  
  360 + /**
  361 + * 每天晚上9点55同步一次
  362 + */
307 363 @Override
308   - public void updateAssay() {
309   -
  364 + public void fullUpdatePatients() {
  365 + updatePatientsByHospital(null, null, null);
310 366 }
311 367  
312 368 @Override
313   - public void fullUpdateAssay() {
  369 + public void updatePatientsByHospital(String hospitalForeignId, Integer hospitalId, Date startTime) {
  370 + try {
  371 + List<String> pidList = new ArrayList<>();
  372 + List<Map> list = platMapper.selectAllPuerperaByHospitalId(hospitalForeignId, startTime);
  373 + if (list != null && list.size() > 0) {
  374 + for (Map map : list) {
  375 + try {
  376 + if (!pidList.contains(map.get("P_ID"))) {
  377 + pidList.add(map.get("P_ID").toString());
  378 + Patients patients = new Patients();
  379 + patients.setModified(new Date());
  380 + patients.setYn(YnEnums.YES.getId());
  381 + patients.setPublishName("system");
  382 + patients.setPublishId("worker");
  383 + patients.setId(map.get("P_ID").toString().replace("-", ""));
  384 + patients.setMommyPatientId(map.get("P_NO").toString());
  385 + patients.setUsername(map.get("P_NAME").toString());
  386 + patients.setPhone(map.get("P_MOBILEPHONE").toString());
  387 + patients.setBirth(map.get("P_BIRTHDAY") == null ? null : (Date) map.get("P_BIRTHDAY"));
  388 + patients.setLastMenses(map.get("P_LASTMENSTRUALPERIOD") == null ? null : (Date) map.get("P_LASTMENSTRUALPERIOD"));
314 389  
315   - }
  390 + patients.setAddress(map.get("P_ADDRESSSTREET") == null ? null : map.get("P_ADDRESSSTREET").toString());
  391 + patients.setProvinceId(map.get("P_ADDRESSPROVINCE") == null ? null : map.get("P_ADDRESSPROVINCE").toString());
  392 + patients.setCityId(map.get("P_ADDRESSCITY") == null ? null : map.get("P_ADDRESSCITY").toString());
  393 + patients.setAreaId(map.get("P_ADDRESSCOUNTY") == null ? null : map.get("P_ADDRESSCOUNTY").toString());
316 394  
317   - @Override
318   - public void updateAssayByHospital(String hospitalForeignId, Integer hospitalId, Date startTime) {
  395 + patients.setAddressPostRest(map.get("P_POSTPARTUMSTREET") == null ? null : map.get("P_POSTPARTUMSTREET").toString());
  396 + patients.setProvincePostRestId(map.get("P_POSTPARTUMPROVINCE") == null ? null : map.get("P_POSTPARTUMPROVINCE").toString());
  397 + patients.setCityPostRestId(map.get("P_POSTPARTUMCITY") == null ? null : map.get("P_POSTPARTUMCITY").toString());
  398 + patients.setAreaPostRestId(map.get("P_POSTPARTUMCOUNTY") == null ? null : map.get("P_POSTPARTUMCOUNTY").toString());
319 399  
320   - }
  400 + patients.setAddressRegister(map.get("P_RRSTREET") == null ? null : map.get("P_RRSTREET").toString());
  401 + patients.setProvinceRegisterId(map.get("P_RRPROVINCE") == null ? null : map.get("P_RRPROVINCE").toString());
  402 + patients.setCityRegisterId(map.get("P_RRCITY") == null ? null : map.get("P_RRCITY").toString());
  403 + patients.setAreaRegisterId(map.get("P_RRCOUNTY") == null ? null : map.get("P_RRCOUNTY").toString());
321 404  
322   - @Override
323   - public void updatePatients() {
  405 + patients.setAreaRegisterId(map.get("P_HUSBANDNAME") == null ? null : map.get("P_HUSBANDNAME").toString());
  406 + patients.setAreaRegisterId(map.get("P_HUSBANDMOBILEPHONE") == null ? null : map.get("P_HUSBANDMOBILEPHONE").toString());
  407 + patients.setVcCardNo(map.get("VC_CARDNO") == null ? null : map.get("VC_CARDNO").toString());
  408 + patients.setDeliverOrg(map.get("P_HOSPITALID") == null ? null : map.get("P_HOSPITALID").toString());
324 409  
325   - }
  410 + if (patientsService.queryPatientCount(patients.getId()) == 0) {
  411 + patients.setCreated(patients.getModified());
  412 + patientsService.addPatient(patients);
  413 + } else {
  414 + patientsService.updatePatient(patients);
  415 + }
326 416  
327   - @Override
328   - public void fullUpdatePatients() {
329   -
  417 + }
  418 + } catch (Exception ee) {
  419 + LogUtil.taskError(ee.getMessage(), ee);
  420 + }
  421 + }
  422 + } else {
  423 + LogUtil.taskInfo("hospitalId:" + hospitalForeignId + " has no data!");
  424 + }
  425 + } catch (Exception e) {
  426 + e.printStackTrace();
  427 + LogUtil.taskError(e.getMessage(), e);
  428 + }
330 429 }
331 430  
  431 + /**
  432 + * 每5分钟同步一次(早六点到晚九点)
  433 + */
332 434 @Override
333   - public void updatePatientsByHospital(String hospitalForeignId, Integer hospitalId, Date startTime) {
334   -
335   - }
336   -
337   - @Override
338 435 public void updateNewBorns() {
339   -
  436 + Date startTime = new DateTime().minusMinutes(10).toDate();
  437 + OrganizationQuery query = new OrganizationQuery();
  438 + query.setYn(YnEnums.YES.getId());
  439 + List<Organization> list = organizationService.queryOrganization(query);
  440 + for (Organization organization : list) {
  441 + if (StringUtils.isNotBlank(organization.getForeignId())) {
  442 + updateNewBornsByHospital(organization.getForeignId(), organization.getId(), null);
  443 + }
  444 + }
340 445 }
341 446  
  447 + /**
  448 + * 每天晚上11点25同步一次
  449 + */
342 450 @Override
343 451 public void fullUpdateNewBorns() {
344   -
  452 + updateNewBornsByHospital(null, null, null);
345 453 }
346 454  
347 455 @Override
platform-data-api/src/main/webapp/WEB-INF/vm/task/index.vm View file @ 0d93db8
... ... @@ -34,11 +34,11 @@
34 34 </td>
35 35 </tr>
36 36 <tr>
37   - <td>初始化省市区乡镇code</td>
  37 + <td>产妇</td>
38 38 <td></td>
39 39 <td>无</td>
40 40 <td>
41   - <button class="btn btn-sm btn-danger" onclick="execOne('codeinit')">执行</button>
  41 + <button class="btn btn-sm btn-danger" onclick="execOne('fullUpdatePatients')">执行</button>
42 42 </td>
43 43 </tr>
44 44 </table>
platform-mommyData/src/main/java/com/lymsh/mommybaby/earlydata/dao/PlatMapper.java View file @ 0d93db8
... ... @@ -34,5 +34,7 @@
34 34  
35 35 public List<Map> selectAllUserByHospitalId(@Param("hospitalId") String hospitalId, @Param("startTime") Date startTime);
36 36  
  37 + public List<Map> selectAllPuerperaByHospitalId(@Param("hospitalId") String hospitalId, @Param("startTime") Date startTime);
  38 +
37 39 }
platform-mommyData/src/main/java/com/lymsh/mommybaby/earlydata/service/PlatService.java View file @ 0d93db8
... ... @@ -31,5 +31,7 @@
31 31  
32 32 public List<Map> selectAllByHospitalId(String hospitalId, Date startTime);
33 33  
  34 + public List<Map> selectAllPuerperaByHospitalId(String hospitalId, Date startTime);
  35 +
34 36 }
platform-mommyData/src/main/java/com/lymsh/mommybaby/earlydata/service/impl/PlatServiceImpl.java View file @ 0d93db8
... ... @@ -101,5 +101,10 @@
101 101 public List<Map> selectAllByHospitalId(String hospitalId, Date startTime) {
102 102 return platMapper.selectAllByHospitalId(hospitalId, startTime);
103 103 }
  104 +
  105 + @Override
  106 + public List<Map> selectAllPuerperaByHospitalId(String hospitalId, Date startTime) {
  107 + return platMapper.selectAllPuerperaByHospitalId(hospitalId, startTime);
  108 + }
104 109 }
platform-mommyData/src/main/resources/earlyOrm/Plat.xml View file @ 0d93db8
... ... @@ -221,6 +221,24 @@
221 221 order by h.h_id,d.d_id,u.u_id
222 222 </select>
223 223  
  224 + <select id="selectAllPuerperaByHospitalId" resultType="hashmap" parameterType="map">
  225 + select
  226 + ppt.*,mp.*,card.*
  227 + from
  228 + mommy_patient mp,plat_patient ppt, mommy_visitcard card
  229 + where
  230 + mp.p_platpatientid = ppt.p_id and card.vc_patientno = mp.p_no
  231 + and mp.p_hospitalid is not null and ppt.p_id is not null and mp.p_no is not null and ppt.p_name is not null and mp.P_MOBILEPHONE is not null
  232 + and ( floor((sysdate - P_LASTMENSTRUALPERIOD+1)/7) > 41 or ( SELECT COUNT(0) FROM mommy_pregDeliveryrecord pp WHERE pp.PDR_PATIENTID =mp.p_platpatientid)>0 )
  233 + <if test="hospitalId != null">
  234 + and mp.p_hospitalid = #{hospitalId}
  235 + </if>
  236 + <if test="startTime != null">
  237 + and (mp.p_opertime >= #{startTime} or ppt.p_opertime >= #{startTime} or card.vc_opertime >= #{startTime} )
  238 + </if>
  239 + order by mp.p_hospitalid,ppt.p_id,mp.p_no
  240 + </select>
  241 +
224 242  
225 243 </mapper>
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UsersController.java View file @ 0d93db8
... ... @@ -335,6 +335,7 @@
335 335  
336 336 if(!usersList.get(0).getType().equals(0)) {
337 337 ResultUtils.buildParameterErrorResultAndWrite(response, "用户错误");
  338 + return;
338 339 }
339 340  
340 341 //将已有映射设为失效
... ... @@ -909,6 +910,18 @@
909 910 users.setModified(new Date());
910 911 usersService.updateUsers(users);
911 912 ResultUtils.buildSuccessResultAndWrite(response);
  913 + }
  914 +
  915 + @RequestMapping(value = "/logout", method = RequestMethod.GET)
  916 + @ResponseBody
  917 + public Map<String, Object> resetToken(@RequestHeader(value = "Authorization", required = false) String token) {
  918 + if (StringUtils.isNotEmpty(token)) {
  919 + LoginUtil.deleteToken(token);
  920 + }
  921 + Map<String, Object> result = new HashMap<>();
  922 + result.put("errorcode", ConstantInterface.SUCCESS);
  923 + result.put("errormsg", "update");
  924 + return result;
912 925 }
913 926 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java View file @ 0d93db8
... ... @@ -50,23 +50,43 @@
50 50 * @return
51 51 */
52 52 public BaseResponse matchCommunity(PuerperaMatcherCommunityRequest puerperaMatcherCommunityRequest) {
53   - Patients puerperaModel = patientsService.findOnePatientById(puerperaMatcherCommunityRequest.getParentId());
54 53  
55   - Assert.notNull(puerperaModel, "产妇信息不存在");
  54 + if(0==puerperaMatcherCommunityRequest.getT()){
  55 + Patients puerperaModel = patientsService.findOnePatientById(puerperaMatcherCommunityRequest.getParentId());
56 56  
57   - puerperaModel.setCommunityId(puerperaMatcherCommunityRequest.getCommunityId());
58   - patientsService.updatePatient(puerperaModel);
  57 + Assert.notNull(puerperaModel, "产妇信息不存在");
59 58  
  59 + puerperaModel.setCommunityId(puerperaMatcherCommunityRequest.getCommunityId());
  60 + patientsService.updatePatient(puerperaModel);
  61 + //修改新生儿的社区信息
  62 + updateBabyCommunity(puerperaModel.getId(),puerperaModel.getPhone(),puerperaMatcherCommunityRequest.getCommunityId(),Boolean.FALSE);
  63 +
  64 + }else{
  65 + updateBabyCommunity(puerperaMatcherCommunityRequest.getParentId(), null, puerperaMatcherCommunityRequest.getCommunityId(), Boolean.TRUE);
  66 + }
  67 +
  68 + //TODO 产妇分配了社区,需要给对应的社区提示消息
  69 + return new BaseResponse().setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS);
  70 + }
  71 +
  72 + /**
  73 + * 修改新生儿的社区信息
  74 + */
  75 + private void updateBabyCommunity(String parentId,String phone,String communityId,boolean isBaby){
60 76 BabyModelQuery babyModelQuery = new BabyModelQuery();
61   - babyModelQuery.setParentId(puerperaModel.getId());
62 77 babyModelQuery.setYn(YnEnums.YES.getId());
  78 + if(isBaby){
  79 + babyModelQuery.setId(parentId);
  80 + }else{
  81 + babyModelQuery.setParentId(parentId);
  82 + }
63 83  
64 84 BabyModel babyModel = new BabyModel();
65   - babyModel.setCommunityId(puerperaMatcherCommunityRequest.getCommunityId());
66   - babyModel.setMphone(puerperaModel.getPhone());
  85 + babyModel.setCommunityId(communityId);
  86 + if(StringUtils.isNotEmpty(phone)){
  87 + babyModel.setMphone(phone);
  88 + }
67 89 babyService.findAndModify(babyModelQuery.convertToQuery(),babyModel);
68   - //TODO 产妇分配了社区,需要给对应的社区提示消息
69   - return new BaseResponse().setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS);
70 90 }
71 91  
72 92 /**
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/VisitFacade.java View file @ 0d93db8
... ... @@ -71,10 +71,23 @@
71 71 */
72 72 public BaseObjectResponse findOneByCardNo(String cardNo) {
73 73 Patients puerperaModel = findOnePuerperaByCardNo(cardNo, 3);
74   - if (null == puerperaModel) {
75   - return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.DEPT_NOT_EXISTS).setErrormsg("产妇信息不存在");
  74 + if (null != puerperaModel) {
  75 + return doBiz(puerperaModel);
76 76 }
77   - return doBiz(puerperaModel);
  77 + BabyModelQuery babyModelQuery =new BabyModelQuery();
  78 + babyModelQuery.setYn(YnEnums.YES.getId());
  79 + babyModelQuery.setMphone(cardNo);
  80 + List<BabyModel> babyModels = babyService.queryBabyWithQuery(babyModelQuery);
  81 +
  82 + if(CollectionUtils.isNotEmpty(babyModels)){
  83 + VisitResult data = new VisitResult();
  84 + BabyModel babyModel = babyModels.get(0);
  85 + data.convertToResult1(babyModel, CommonsHelper.fullAddress(babyModel, basicConfigService));
  86 + data.setData(Collections.EMPTY_LIST);
  87 + return new BaseObjectResponse().setData(data).setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功");
  88 + }
  89 +
  90 + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.DEPT_NOT_EXISTS).setErrormsg("产妇信息不存在");
78 91 }
79 92  
80 93 /**
... ... @@ -160,14 +173,7 @@
160 173 } else {
161 174 // 表示是新的产妇直接新增
162 175 // parentId = puerperaService.addPuerpera(visitRequest.getPuerpera().build()).getId();
163   - Patients patients = visitRequest.getPatients();
164   - patients.setType(3);
165   - patients.setYn(YnEnums.YES.getId());
166   - patients.setId(null);
167   - patients.setCreated(new Date());
168   - patients.setModified(new Date());
169   - patients.setIsVisit(VisitStatusEnums.UNVISIT.getId());
170   - parentId = patientsService.addPatient(patients).getId();
  176 + parentId= addOnePatients(visitRequest.getPatients());
171 177 }
172 178  
173 179 // 如果为空表示新增
... ... @@ -194,6 +200,31 @@
194 200 }
195 201  
196 202 /**
  203 + *
  204 + * 增加一个患者并根据患者的手机号去关联小孩的数据
  205 + *
  206 + * @param patients
  207 + * @return
  208 + */
  209 + public String addOnePatients(Patients patients){
  210 + patients.setType(3);
  211 + patients.setYn(YnEnums.YES.getId());
  212 + patients.setId(null);
  213 + patients.setCreated(new Date());
  214 + patients.setModified(new Date());
  215 + patients.setIsVisit(VisitStatusEnums.UNVISIT.getId());
  216 + String parentId = patientsService.addPatient(patients).getId();
  217 +
  218 + BabyModelQuery babyModelQuery = new BabyModelQuery();
  219 + babyModelQuery.setMphone(patients.getPhone());
  220 + babyModelQuery.setYn(YnEnums.YES.getId());
  221 + BabyModel babyModel = new BabyModel();
  222 + babyModel.setParentId(parentId);
  223 + babyService.findAndModify(babyModelQuery.convertToQuery(),babyModel);
  224 + return parentId;
  225 + }
  226 +
  227 + /**
197 228 * 增加一条小孩的访视记录
198 229 *
199 230 * @param babyVisitAddRequest
200 231  
... ... @@ -225,8 +256,16 @@
225 256 babyModel.setVisitstatus(VisitStatusEnums.UNVISIT.getId());
226 257 babyId = babyService.addOneBaby(babyModel).getId();
227 258 } else {
  259 + BabyModel babyModel= babyVisitAddRequest.getBabyModel();
  260 + PatientsQuery patientsQuery = new PatientsQuery();
  261 + patientsQuery.setPhone(babyModel.getMphone());
  262 + patientsQuery.setType(3);
  263 + List<Patients> patientses = patientsService.queryPatient(patientsQuery);
  264 + if(CollectionUtils.isNotEmpty(patientses)){
  265 + babyModel.setParentId(patientses.get(0).getId());
  266 + }
228 267 //修改小孩基本信息
229   - babyService.updateOneBaby(babyVisitAddRequest.getBabyModel(), babyId);
  268 + babyService.updateOneBaby(babyModel, babyId);
230 269 }
231 270 babyVisitModel.setParentId(babyId);
232 271 //表示新增访视记录
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/PuerperaMatcherCommunityRequest.java View file @ 0d93db8
... ... @@ -18,6 +18,12 @@
18 18 @NotEmpty(message = "communityId不能为空")
19 19 private String communityId;
20 20  
  21 + /**
  22 + * t表示type 0 为产妇 1为新生儿
  23 + */
  24 + @FormParam
  25 + private int t=0;
  26 +
21 27 public String getCommunityId() {
22 28 return communityId;
23 29 }
... ... @@ -32,6 +38,14 @@
32 38  
33 39 public void setParentId(String parentId) {
34 40 this.parentId = parentId;
  41 + }
  42 +
  43 + public int getT() {
  44 + return t;
  45 + }
  46 +
  47 + public void setT(int t) {
  48 + this.t = t;
35 49 }
36 50 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/VisitResult.java View file @ 0d93db8
... ... @@ -6,6 +6,7 @@
6 6  
7 7 import com.lyms.platform.common.utils.DateUtil;
8 8 import com.lyms.platform.common.utils.JsonUtil;
  9 +import com.lyms.platform.pojo.BabyModel;
9 10 import com.lyms.platform.pojo.Patients;
10 11 import com.lyms.platform.pojo.PuerperaModel;
11 12  
12 13  
... ... @@ -122,12 +123,28 @@
122 123 }
123 124 setPhone(model.getPhone());
124 125 setId(model.getId());
125   -// setCardNo(null==model.getCardNo()?"":model.getCardNo());
126   - setCardNo(null==model.getPhone()?"":model.getPhone());
  126 + setCardNo(null==model.getCardNo()?"":model.getCardNo());
  127 +// setCardNo(null==model.getPhone()?"":model.getPhone());
127 128 setDeliverOrg(model.getDeliverOrg()==null?"":model.getDeliverOrg());
128 129 setDueDate(DateUtil.getyyyy_MM_dd(model.getDueDate()));
129 130 setDueType(model.getDueType()==null?"":model.getDueType());
130 131 setName(model.getUsername());
  132 + }
  133 +
  134 + public void convertToResult1(BabyModel model,Address address) {
  135 + try {
  136 + setAddress(address);
  137 + } catch (Exception e) {
  138 + }
  139 + try {
  140 + setAge(DateUtil.getyyyy_MM_dd(model.getBirth()));
  141 + }catch (Exception e){
  142 + }
  143 + setPhone(model.getMphone());
  144 +// setId(model.getId());
  145 + setCardNo(null==model.getCardNo()?"":model.getCardNo());
  146 + setDueDate(DateUtil.getyyyy_MM_dd(model.getBirth()));
  147 + setName(model.getMname());
131 148 }
132 149 }