Commit 37673a98f90f87407254c836e9a3eda053b69801
1 parent
00a1ac669d
Exists in
master
and in
6 other branches
增值服务开通服务同步
Showing 2 changed files with 102 additions and 2 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/SyncDataController.java
View file @
37673a9
... | ... | @@ -53,6 +53,7 @@ |
53 | 53 | @RequestParam(value = "synForm", required = true) String synForm |
54 | 54 | ){ |
55 | 55 | try{ |
56 | + System.out.println("数据同步开始:action:"+action+",synForm:"+synForm); | |
56 | 57 | WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext(); |
57 | 58 | SysBaseFacade sysBaseFacade = (SysBaseFacade)webApplicationContext.getBean(action); |
58 | 59 | return sysBaseFacade.sysData(synForm); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientServiceSysFacade.java
View file @
37673a9
1 | 1 | package com.lyms.platform.operate.web.facade; |
2 | 2 | |
3 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
3 | 4 | import com.lyms.platform.common.result.BaseResponse; |
5 | +import com.lyms.platform.common.utils.StringUtils; | |
4 | 6 | import com.lyms.platform.permission.model.PatientService; |
7 | +import com.lyms.platform.permission.model.PatientServiceQuery; | |
8 | +import com.lyms.platform.permission.service.PatientServiceService; | |
5 | 9 | import net.sf.json.JSONObject; |
10 | +import org.apache.commons.collections.CollectionUtils; | |
11 | +import org.springframework.beans.factory.annotation.Autowired; | |
6 | 12 | import org.springframework.stereotype.Component; |
7 | 13 | |
14 | +import java.util.Date; | |
15 | +import java.util.List; | |
16 | +import java.util.UUID; | |
17 | + | |
8 | 18 | /** |
9 | 19 | * @auther yangfei |
10 | 20 | * @createTime 2017年10月12日 17时09分 |
11 | 21 | |
12 | 22 | |
13 | 23 | |
14 | 24 | |
... | ... | @@ -12,18 +22,107 @@ |
12 | 22 | */ |
13 | 23 | @Component |
14 | 24 | public class PatientServiceSysFacade implements SysBaseFacade{ |
25 | + @Autowired | |
26 | + private PatientServiceService patientServiceService; | |
15 | 27 | @Override |
16 | 28 | public BaseResponse sysData(String synForm) { |
17 | 29 | JSONObject jsonObject = JSONObject.fromObject(synForm); |
18 | 30 | PatientService patientService = (PatientService)JSONObject.toBean(jsonObject, PatientService.class); |
31 | + BaseResponse baseResponse = validate(patientService); | |
32 | + if(baseResponse.getErrorcode()!=ErrorCodeConstants.SUCCESS){ | |
33 | + return baseResponse; | |
34 | + } | |
19 | 35 | |
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()); | |
20 | 46 | |
21 | - System.out.println("同步数据方法"); | |
22 | - BaseResponse baseResponse = new BaseResponse(); | |
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); | |
60 | + } | |
61 | + System.out.println("同步数据方法结束"); | |
23 | 62 | baseResponse.setErrorcode(0); |
24 | 63 | baseResponse.setObject(synForm); |
25 | 64 | baseResponse.setErrormsg("成功"); |
26 | 65 | return baseResponse; |
27 | 66 | } |
67 | + | |
68 | + /** | |
69 | + * 数据同步数据验证 | |
70 | + * @param ps | |
71 | + * @return | |
72 | + */ | |
73 | + public BaseResponse validate(PatientService ps){ | |
74 | + BaseResponse baseResponse = new BaseResponse(); | |
75 | + //孕妇id | |
76 | + if(StringUtils.isEmpty(ps.getParentid())){ | |
77 | + baseResponse.setErrormsg("请传入parentid"); | |
78 | + baseResponse.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR); | |
79 | + return baseResponse; | |
80 | + } | |
81 | + //孕妇id | |
82 | + if(StringUtils.isEmpty(ps.getPid())){ | |
83 | + baseResponse.setErrormsg("请传入pid"); | |
84 | + baseResponse.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR); | |
85 | + return baseResponse; | |
86 | + } | |
87 | + //serType服务类型(1-高危精准指导、2-体重、3-血糖、4-血压、5-专家咨询) | |
88 | + if(ps.getSerTypes()==null){ | |
89 | + baseResponse.setErrormsg("请传入serTypes"); | |
90 | + baseResponse.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR); | |
91 | + return baseResponse; | |
92 | + } | |
93 | + //指定医生 | |
94 | + if(ps.getSerDoct()==null){ | |
95 | + baseResponse.setErrormsg("请传入serDoct"); | |
96 | + baseResponse.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR); | |
97 | + return baseResponse; | |
98 | + } | |
99 | + //验证码 | |
100 | + if(ps.getSerCode()==null){ | |
101 | + baseResponse.setErrormsg("请传入serCode"); | |
102 | + baseResponse.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR); | |
103 | + return baseResponse; | |
104 | + } | |
105 | + //订单号 | |
106 | + if(ps.getOrderId()==null){ | |
107 | + baseResponse.setErrormsg("请传入orderId"); | |
108 | + baseResponse.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR); | |
109 | + return baseResponse; | |
110 | + } | |
111 | + //开通时间 | |
112 | + if(ps.getCreateDate()==null){ | |
113 | + baseResponse.setErrormsg("请传入createDate"); | |
114 | + baseResponse.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR); | |
115 | + return baseResponse; | |
116 | + } | |
117 | + //服务状态 | |
118 | + if(ps.getSerStatus()==null){ | |
119 | + baseResponse.setErrormsg("请传入serStatus"); | |
120 | + baseResponse.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR); | |
121 | + return baseResponse; | |
122 | + } | |
123 | + baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
124 | + return baseResponse; | |
125 | + } | |
126 | + | |
28 | 127 | } |