Commit 4600ba1b7e44f041de4fdea71f3fd5911db3923e

Authored by yangfei
1 parent 3ab4c6e15d

乐陵住院提醒

Showing 6 changed files with 185 additions and 66 deletions

platform-biz-patient-service/src/main/java/com/lyms/platform/biz/RemoteUrlEnum.java View file @ 4600ba1
... ... @@ -6,7 +6,7 @@
6 6 * @Version: V1.0
7 7 */
8 8 public enum RemoteUrlEnum {
9   - INVALID_COUPON_URL("coupon/invalid", "作废优惠券");
  9 + INVALID_COUPON_URL("coupon/invalid", "作废优惠券"),RECEIVE_PATSER_SYNC_URL("/sync", "领取硬件设备");
10 10  
11 11 RemoteUrlEnum(String url, String desc) {
12 12 this.url = url;
platform-biz-service/src/main/java/com/lyms/platform/permission/model/PatientMarkHospitalLog.java View file @ 4600ba1
... ... @@ -20,7 +20,7 @@
20 20 */
21 21 private Integer remResult;
22 22 /**
23   - * 回院/住院日期
  23 + * 预约日期/回院日期/住院日期
24 24 */
25 25 private Date makeDate;
26 26 /**
... ... @@ -40,7 +40,7 @@
40 40 */
41 41 private Date markeDate;
42 42 /**
43   - * 提醒类型(1-回院提醒、2-住院提醒
  43 + * 提醒类型(1-住院预约修改,2-回院提醒修改、3-住院提醒修改
44 44 */
45 45 private Integer markeType;
46 46 /**
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientMarkHospServiceFacade.java View file @ 4600ba1
... ... @@ -483,6 +483,9 @@
483 483 ps.setInHospitStatus(1);
484 484 patientMarkHospitalService.addPatientMarkHospital(ps);
485 485  
  486 + //添加日志
  487 + addPatientMarkHospLog(ps,1);
  488 +
486 489 BaseResponse baseResponse = new BaseResponse();
487 490 baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
488 491 baseResponse.setErrormsg("成功");
489 492  
490 493  
491 494  
492 495  
493 496  
494 497  
... ... @@ -499,23 +502,52 @@
499 502 * @return
500 503 */
501 504 public BaseResponse updatePatientMarkHospital(PatientMarkHospital ps, int type, Integer id) {
  505 + PatientMarkHospitalLog markHospitalLog = new PatientMarkHospitalLog();
  506 + if (type == 1) {//预约住院
  507 + ps.setMakeDoctor(String.valueOf(id));
  508 + ps.setMakeDate(new Date());
  509 + } else if (type == 2) {//回院提醒
  510 + ps.setBackDoctor(String.valueOf(id));
  511 + ps.setBackDate(new Date());
  512 + ps.setBackStatus(2);
  513 + } else if (type == 3) {//住院提醒
  514 + if (ps.getHospitStatus() == null) {
  515 + ps.setHospitStatus(1);
  516 + }
  517 + ps.setInHospitDoctor(String.valueOf(id));
  518 + ps.setInHospitDate(new Date());
  519 + ps.setInHospitStatus(2);
  520 + }
  521 + //添加日志
  522 + addPatientMarkHospLog(ps,type);
  523 +
502 524 //根据用户id获取医院ID
503   - String hospitalId = autoMatchFacade.getHospitalId(id);
  525 + patientMarkHospitalService.updatePatientMarkHospital(ps);
504 526  
  527 + BaseResponse baseResponse = new BaseResponse();
  528 + baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  529 + baseResponse.setErrormsg("成功");
  530 + return baseResponse;
  531 + }
505 532  
  533 + /**
  534 + * 添加住院预约日志
  535 + * @param ps
  536 + * @param type (1-住院预约修改,2-回院提醒修改、3-住院提醒修改)
  537 + */
  538 + public void addPatientMarkHospLog(PatientMarkHospital ps,int type){
506 539 PatientMarkHospitalLog markHospitalLog = new PatientMarkHospitalLog();
507 540 markHospitalLog.setId(UUID.randomUUID().toString().replace("-", ""));
508   - markHospitalLog.setHospitalId(hospitalId);
  541 + markHospitalLog.setHospitalId(ps.getHospitalId());
509 542 markHospitalLog.setPatientMakeHosId(ps.getId());
510 543 markHospitalLog.setPatientId(ps.getPatientId());
511 544 if (type == 1) {//预约住院
512   - markHospitalLog.setMakeDate(ps.getMakeDate());
  545 + markHospitalLog.setMakeDate(ps.getMakeInHospitDate());
513 546 markHospitalLog.setMakeRemark(ps.getMakeRemark());
514 547 markHospitalLog.setMarkeDoctor(ps.getMakeDoctor());
515 548 markHospitalLog.setMarkeDate(ps.getMakeDate());
516 549 markHospitalLog.setMarkeType(1);
517   - ps.setMakeDoctor(String.valueOf(id));
518   - ps.setMakeDate(new Date());
  550 +
519 551 } else if (type == 2) {//回院提醒
520 552 markHospitalLog.setRemResult(ps.getBackResult());
521 553 markHospitalLog.setMakeDate(ps.getBackMakeDate());
522 554  
... ... @@ -523,10 +555,8 @@
523 555 markHospitalLog.setMakeRemark(ps.getBackRemark());
524 556 markHospitalLog.setMarkeDoctor(ps.getBackDoctor());
525 557 markHospitalLog.setMarkeDate(ps.getBackDate());
  558 +
526 559 markHospitalLog.setMarkeType(2);
527   - ps.setBackDoctor(String.valueOf(id));
528   - ps.setBackDate(new Date());
529   - ps.setBackStatus(2);
530 560 } else if (type == 3) {//住院提醒
531 561 markHospitalLog.setRemResult(ps.getInHospitResult());
532 562 markHospitalLog.setMakeDate(ps.getInHospitMakeDate());
533 563  
534 564  
... ... @@ -535,21 +565,8 @@
535 565 markHospitalLog.setMarkeDoctor(ps.getInHospitDoctor());
536 566 markHospitalLog.setMarkeDate(ps.getInHospitDate());
537 567 markHospitalLog.setMarkeType(3);
538   - // ps.setHospitStatus(1);
539   - if (ps.getHospitStatus() == null) {
540   - ps.setHospitStatus(1);
541   - }
542   - ps.setInHospitDoctor(String.valueOf(id));
543   - ps.setInHospitDate(new Date());
544   - ps.setInHospitStatus(2);
545 568 }
546   - //根据用户id获取医院ID
547   - patientMarkHospitalService.updatePatientMarkHospital(ps);
548 569 patientMarkHospitalLogService.addPatientMarkHospitalLog(markHospitalLog);
549   - BaseResponse baseResponse = new BaseResponse();
550   - baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
551   - baseResponse.setErrormsg("成功");
552   - return baseResponse;
553 570 }
554 571  
555 572 /**
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientServiceFacade.java View file @ 4600ba1
1 1 package com.lyms.platform.operate.web.facade;
2 2  
  3 +import com.alibaba.fastjson.JSONObject;
  4 +import com.lyms.platform.biz.RemoteUrlEnum;
3 5 import com.lyms.platform.biz.service.AntExRecordService;
4 6 import com.lyms.platform.biz.service.AntenatalExaminationService;
5 7 import com.lyms.platform.biz.service.CommonService;
6 8  
... ... @@ -9,7 +11,9 @@
9 11 import com.lyms.platform.common.result.BaseListResponse;
10 12 import com.lyms.platform.common.result.BaseObjectResponse;
11 13 import com.lyms.platform.common.result.BaseResponse;
  14 +import com.lyms.platform.common.utils.Config;
12 15 import com.lyms.platform.common.utils.DateUtil;
  16 +import com.lyms.platform.common.utils.HttpClientUtil;
13 17 import com.lyms.platform.common.utils.StringUtils;
14 18 import com.lyms.platform.operate.web.request.BasePageQueryRequest;
15 19 import com.lyms.platform.operate.web.result.PatientSerResult;
... ... @@ -21,6 +25,7 @@
21 25 import com.lyms.platform.permission.service.UsersService;
22 26 import com.lyms.platform.pojo.Patients;
23 27 import com.lyms.platform.query.PatientsQuery;
  28 +import net.sf.json.JSONArray;
24 29 import org.apache.commons.collections.CollectionUtils;
25 30 import org.springframework.beans.factory.annotation.Autowired;
26 31 import org.springframework.stereotype.Component;
... ... @@ -52,6 +57,8 @@
52 57 @Autowired
53 58 private AntenatalExaminationService antenatalExaminationService;
54 59  
  60 + public static String patSer_sync_url = Config.getItem("patSer_sync_url", "0");
  61 +
55 62 public BaseResponse patientServiceInit() {
56 63 Map map = new HashMap();
57 64 //服务类型
58 65  
... ... @@ -117,9 +124,9 @@
117 124 public BaseResponse addPatientService(PatientService ps, Integer id) {
118 125 //根据用户id获取医院ID
119 126 String hospitalId = autoMatchFacade.getHospitalId(id);
120   - String [] serTypes = ps.getSerTypes().split(",");
  127 + String[] serTypes = ps.getSerTypes().split(",");
  128 + List<PatientService> patientServiceList = new ArrayList<>();
121 129 for (String psType : serTypes) {
122   -
123 130 //先根据孕妇id和开通服务类型、开通医生进行查询,如果已经开通过则开通失败
124 131 PatientServiceQuery patientQuery = new PatientServiceQuery();
125 132 patientQuery.setHospitalId(hospitalId);
126 133  
... ... @@ -149,8 +156,11 @@
149 156 //领取操作医生id
150 157 ps.setReceiveUser(String.valueOf(id));
151 158 patientServiceService.addPatientService(ps);
  159 + patientServiceList.add(ps);
152 160 }
153 161  
  162 + synPatientService(patientServiceList.toArray(new PatientService[patientServiceList.size()]));
  163 +
154 164 BaseResponse baseResponse = new BaseResponse();
155 165 baseResponse.setObject(ps.getId());
156 166 baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
... ... @@ -171,7 +181,7 @@
171 181 ps.setUpdateDate(new Date());
172 182 ps.setUpdateUser(String.valueOf(id));
173 183 patientServiceService.updatePatientService(ps);
174   -
  184 + synPatientService(ps);
175 185 BaseResponse baseResponse = new BaseResponse();
176 186 baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
177 187 baseResponse.setErrormsg("成功");
... ... @@ -284,6 +294,15 @@
284 294 return baseResponse;
285 295 }
286 296  
  297 + /**
  298 + * 根据条件查询验证码列表
  299 + *
  300 + * @param serType 服务类型(1-高危精准指导、2-体重、3-血糖、4-血压、5-专家咨询)
  301 + * @param queryNo 查询关键字(姓名/证件号/联系方式/就诊卡号)
  302 + * @param cDueWeekStart 开始当前孕周
  303 + * @param cDueWeekEnd 结束当前孕周
  304 + * @return
  305 + */
287 306 public BaseListResponse ptientServiceCodeList(Integer serType, String queryNo, Integer cDueWeekStart, Integer cDueWeekEnd, BasePageQueryRequest pageInfo, Integer id) {
288 307  
289 308 //根据用户id获取医院ID
... ... @@ -370,6 +389,7 @@
370 389 ps.setReceiveDate(new Date());
371 390 ps.setReceiveUser(String.valueOf(id));
372 391 patientServiceService.updatePatientService(ps);
  392 + synReceiveData(ps.getOrderId());
373 393  
374 394 BaseResponse baseResponse = new BaseResponse();
375 395 baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
376 396  
... ... @@ -377,6 +397,77 @@
377 397 return baseResponse;
378 398 }
379 399  
  400 + /**
  401 + * 新增或修改同步到小程序
  402 + *
  403 + * @param patientServices 数据
  404 + * @return
  405 + */
  406 + public boolean synPatientService(final PatientService... patientServices) {
  407 + try {
  408 + new Thread(new Runnable() {
  409 + @Override
  410 + public void run() {
  411 + Map<String, String> params = new HashMap<>();
  412 + JSONArray jsonArray = new JSONArray();
  413 + for (PatientService ps : patientServices) {
  414 + JSONObject jsonObject = new JSONObject();
  415 + jsonObject.put("parentid", ps.getParentid());
  416 + jsonObject.put("pid", ps.getPid());
  417 + jsonObject.put("serType", ps.getSerType());
  418 + jsonObject.put("serDoct", ps.getSerDoct());
  419 + jsonObject.put("serStatus", ps.getSerStatus());
  420 + jsonObject.put("hospitalId", ps.getHospitalId());
  421 + jsonObject.put("createDate", ps.getCreateDate());
  422 + jsonArray.add(jsonObject);
  423 + }
  424 + params.put("data", jsonArray.toString());
  425 + String rest = HttpClientUtil.doPost(patSer_sync_url + RemoteUrlEnum.RECEIVE_PATSER_SYNC_URL.getUrl(), params, "utf-8");
  426 + System.out.println("增值服务数据同步结果:" + rest);
  427 + }
  428 + }).start();
  429 + } catch (Exception e) {
  430 + e.printStackTrace();
  431 + try {
  432 + //休眠10分钟继续调用同步
  433 + Thread.sleep(600000);
  434 + } catch (InterruptedException e1) {
  435 + e1.printStackTrace();
  436 + }
  437 + synPatientService(patientServices);
  438 + }
  439 + return true;
  440 + }
380 441  
  442 + /**
  443 + * 领取结果同步到小程序
  444 + *
  445 + * @param orderId
  446 + */
  447 + public boolean synReceiveData(final String orderId) {
  448 + try {
  449 + new Thread(new Runnable() {
  450 + @Override
  451 + public void run() {
  452 + Map<String, String> params = new HashMap<>();
  453 + JSONObject jsonObject = new JSONObject();
  454 + jsonObject.put("orderId", orderId);
  455 + params.put("data", jsonObject.toString());
  456 + String rest = HttpClientUtil.doPost(patSer_sync_url + RemoteUrlEnum.RECEIVE_PATSER_SYNC_URL.getUrl(), params, "utf-8");
  457 + System.out.println("领取设备结果:" + rest);
  458 + }
  459 + }).start();
  460 + } catch (Exception e) {
  461 + e.printStackTrace();
  462 + try {
  463 + //休眠10分钟继续调用同步
  464 + Thread.sleep(600000);
  465 + } catch (InterruptedException e1) {
  466 + e1.printStackTrace();
  467 + }
  468 + synReceiveData(orderId);
  469 + }
  470 + return true;
  471 + }
381 472 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientServiceSysFacade.java View file @ 4600ba1
... ... @@ -6,6 +6,7 @@
6 6 import com.lyms.platform.permission.model.PatientService;
7 7 import com.lyms.platform.permission.model.PatientServiceQuery;
8 8 import com.lyms.platform.permission.service.PatientServiceService;
  9 +import net.sf.json.JSONArray;
9 10 import net.sf.json.JSONObject;
10 11 import org.apache.commons.collections.CollectionUtils;
11 12 import org.springframework.beans.factory.annotation.Autowired;
12 13  
13 14  
14 15  
15 16  
... ... @@ -21,42 +22,48 @@
21 22 * @discription
22 23 */
23 24 @Component
24   -public class PatientServiceSysFacade implements SysBaseFacade{
  25 +public class PatientServiceSysFacade implements SysBaseFacade {
25 26 @Autowired
26 27 private PatientServiceService patientServiceService;
  28 +
27 29 @Override
28 30 public BaseResponse sysData(String synForm) {
29   - JSONObject jsonObject = JSONObject.fromObject(synForm);
30   - PatientService patientService = (PatientService)JSONObject.toBean(jsonObject, PatientService.class);
31   - BaseResponse baseResponse = validate(patientService);
32   - if(baseResponse.getErrorcode()!=ErrorCodeConstants.SUCCESS){
33   - return baseResponse;
34   - }
  31 + JSONArray jsonArray = JSONArray.fromObject(synForm);
  32 + BaseResponse baseResponse = new BaseResponse();
  33 + for (int i = 0; i < jsonArray.size(); i++) {
  34 + // JSONObject jsonObject = JSONObject.fromObject(synForm);
  35 + // PatientService patientService = (PatientService)JSONObject.toBean(jsonObject, PatientService.class);
  36 + PatientService patientService = (PatientService) JSONObject.toBean(jsonArray.getJSONObject(i), PatientService.class);
  37 + baseResponse = validate(patientService);
  38 + if (baseResponse.getErrorcode() != ErrorCodeConstants.SUCCESS) {
  39 + return baseResponse;
  40 + }
35 41  
36   - //先根据孕妇id和开通服务类型、开通医生进行查询,如果已经开通过则开通失败
37   - PatientServiceQuery patientQuery = new PatientServiceQuery();
38   - //开通医院
39   - patientQuery.setHospitalId(patientService.getHospitalId());
40   - //孕妇Id
41   - patientQuery.setParentid(patientService.getParentid());
42   - //开通服务
43   - patientQuery.setSerType(patientService.getSerType());
44   - //指定医生
45   - patientQuery.setSerDoct(patientService.getSerDoct());
  42 + //先根据孕妇id和开通服务类型、开通医生进行查询,如果已经开通过则开通失败
  43 + PatientServiceQuery patientQuery = new PatientServiceQuery();
  44 + //开通医院
  45 + patientQuery.setHospitalId(patientService.getHospitalId());
  46 + //孕妇Id
  47 + patientQuery.setParentid(patientService.getParentid());
  48 + //开通服务
  49 + patientQuery.setSerType(patientService.getSerType());
  50 + //指定医生
  51 + patientQuery.setSerDoct(patientService.getSerDoct());
46 52  
47   - List<PatientService> patientServices = patientServiceService.queryPatientService(patientQuery);
48   - if (CollectionUtils.isNotEmpty(patientServices)) {//修改
49   - PatientService ps = patientServices.get(0);
50   - ps.setSerStatus(patientService.getSerStatus());
51   - ps.setSerCode(patientService.getSerCode());
52   - ps.setOrderId(patientService.getOrderId());
53   - ps.setUpdateDate(new Date());
54   - patientServiceService.updatePatientService(ps);
55   - }else{//新增
56   - patientService.setId(UUID.randomUUID().toString().replace("-", ""));
57   - //默认待领取
58   - patientService.setStatus(1);
59   - patientServiceService.addPatientService(patientService);
  53 + List<PatientService> patientServices = patientServiceService.queryPatientService(patientQuery);
  54 + if (CollectionUtils.isNotEmpty(patientServices)) {//修改
  55 + PatientService ps = patientServices.get(0);
  56 + ps.setSerStatus(patientService.getSerStatus());
  57 + ps.setSerCode(patientService.getSerCode());
  58 + ps.setOrderId(patientService.getOrderId());
  59 + ps.setUpdateDate(new Date());
  60 + patientServiceService.updatePatientService(ps);
  61 + } else {//新增
  62 + patientService.setId(UUID.randomUUID().toString().replace("-", ""));
  63 + //默认待领取
  64 + patientService.setStatus(1);
  65 + patientServiceService.addPatientService(patientService);
  66 + }
60 67 }
61 68 System.out.println("同步数据方法结束");
62 69 baseResponse.setErrorcode(0);
63 70  
64 71  
65 72  
66 73  
67 74  
68 75  
69 76  
70 77  
71 78  
... ... @@ -67,55 +74,56 @@
67 74  
68 75 /**
69 76 * 数据同步数据验证
  77 + *
70 78 * @param ps
71 79 * @return
72 80 */
73   - public BaseResponse validate(PatientService ps){
  81 + public BaseResponse validate(PatientService ps) {
74 82 BaseResponse baseResponse = new BaseResponse();
75 83 //孕妇id
76   - if(StringUtils.isEmpty(ps.getParentid())){
  84 + if (StringUtils.isEmpty(ps.getParentid())) {
77 85 baseResponse.setErrormsg("请传入parentid");
78 86 baseResponse.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR);
79 87 return baseResponse;
80 88 }
81 89 //孕妇id
82   - if(StringUtils.isEmpty(ps.getPid())){
  90 + if (StringUtils.isEmpty(ps.getPid())) {
83 91 baseResponse.setErrormsg("请传入pid");
84 92 baseResponse.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR);
85 93 return baseResponse;
86 94 }
87 95 //serType服务类型(1-高危精准指导、2-体重、3-血糖、4-血压、5-专家咨询)
88   - if(ps.getSerTypes()==null){
  96 + if (ps.getSerTypes() == null) {
89 97 baseResponse.setErrormsg("请传入serTypes");
90 98 baseResponse.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR);
91 99 return baseResponse;
92 100 }
93 101 //指定医生
94   - if(ps.getSerDoct()==null){
  102 + if (ps.getSerDoct() == null) {
95 103 baseResponse.setErrormsg("请传入serDoct");
96 104 baseResponse.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR);
97 105 return baseResponse;
98 106 }
99 107 //验证码
100   - if(ps.getSerCode()==null){
  108 + if (ps.getSerCode() == null) {
101 109 baseResponse.setErrormsg("请传入serCode");
102 110 baseResponse.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR);
103 111 return baseResponse;
104 112 }
105 113 //订单号
106   - if(ps.getOrderId()==null){
  114 + if (ps.getOrderId() == null) {
107 115 baseResponse.setErrormsg("请传入orderId");
108 116 baseResponse.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR);
109 117 return baseResponse;
110 118 }
111 119 //开通时间
112   - if(ps.getCreateDate()==null){
  120 + if (ps.getCreateDate() == null) {
113 121 baseResponse.setErrormsg("请传入createDate");
114 122 baseResponse.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR);
115 123 return baseResponse;
116 124 }
117 125 //服务状态
118   - if(ps.getSerStatus()==null){
  126 + if (ps.getSerStatus() == null) {
119 127 baseResponse.setErrormsg("请传入serStatus");
120 128 baseResponse.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR);
121 129 return baseResponse;
platform-operate-api/src/main/resources/database.properties View file @ 4600ba1
... ... @@ -60,6 +60,9 @@
60 60 mongo_sync_token=68884AD1832AB397E2F85F87FE371C74
61 61 mongo_crypto_key=Lymsh@2016
62 62  
  63 +#С³ÌÐòÊý¾Ýͬ²½µØÖ·
  64 +patSer_sync_url=https://dev-app-member-api.healthbaby.com.cn
  65 +
63 66 # sequence id configs
64 67 sequence.create.size=3000
65 68 sequence.index=20000000