Commit af4f352566b00c605c69b8ec80122d93cefad54a
1 parent
0bc1dc8b83
Exists in
master
and in
1 other branch
领取设备数据同步
Showing 10 changed files with 149 additions and 30 deletions
- platform-biz-service/src/main/java/com/lyms/platform/permission/model/PatientService.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/model/PatientServiceQuery.java
- platform-biz-service/src/main/resources/mainOrm/master/BabyPatientExtendEarHearingDiagnose.xml
- platform-biz-service/src/main/resources/mainOrm/master/PatientService.xml
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/HearingDiagnoseController.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/PatientServiceFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientServiceSysFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/SysBaseFacade.java
- platform-operate-api/src/main/resources/spring/applicationContext-quartz.xml
platform-biz-service/src/main/java/com/lyms/platform/permission/model/PatientService.java
View file @
af4f352
... | ... | @@ -85,6 +85,18 @@ |
85 | 85 | * 订单号 |
86 | 86 | */ |
87 | 87 | private String orderId; |
88 | + /** | |
89 | + * 同步状态 默认不需要同步、1-待同步、2-已同步 | |
90 | + */ | |
91 | + private Integer synStatus; | |
92 | + | |
93 | + public Integer getSynStatus() { | |
94 | + return synStatus; | |
95 | + } | |
96 | + | |
97 | + public void setSynStatus(Integer synStatus) { | |
98 | + this.synStatus = synStatus; | |
99 | + } | |
88 | 100 | |
89 | 101 | public String getOrderId() { |
90 | 102 | return orderId; |
platform-biz-service/src/main/java/com/lyms/platform/permission/model/PatientServiceQuery.java
View file @
af4f352
... | ... | @@ -59,6 +59,18 @@ |
59 | 59 | * 订单号 |
60 | 60 | */ |
61 | 61 | private String orderId; |
62 | + /** | |
63 | + * 同步状态 默认不需要同步、1-待同步、2-已同步 | |
64 | + */ | |
65 | + private Integer synStatus; | |
66 | + | |
67 | + public Integer getSynStatus() { | |
68 | + return synStatus; | |
69 | + } | |
70 | + | |
71 | + public void setSynStatus(Integer synStatus) { | |
72 | + this.synStatus = synStatus; | |
73 | + } | |
62 | 74 | |
63 | 75 | public String getOrderId() { |
64 | 76 | return orderId; |
platform-biz-service/src/main/resources/mainOrm/master/BabyPatientExtendEarHearingDiagnose.xml
View file @
af4f352
platform-biz-service/src/main/resources/mainOrm/master/PatientService.xml
View file @
af4f352
... | ... | @@ -23,12 +23,13 @@ |
23 | 23 | <result column="back_date" property="backDate" jdbcType="TIMESTAMP" /> |
24 | 24 | <result column="back_user" property="backUser" jdbcType="VARCHAR" /> |
25 | 25 | <result column="order_id" property="orderId" jdbcType="VARCHAR" /> |
26 | + <result column="syn_status" property="synStatus" jdbcType="INTEGER" /> | |
26 | 27 | </resultMap> |
27 | 28 | |
28 | 29 | |
29 | 30 | |
30 | 31 | <insert id="addPatientService" parameterType="com.lyms.platform.permission.model.PatientService"> |
31 | - insert into patient_service (id,parentid,pid,ser_type,ser_doct,create_date,create_user_name,create_user,ser_status,update_date,update_user_name,update_user,hospital_id,ser_code,status,receive_date,receive_user,back_date,back_user,order_id) values (#{id},#{parentid},#{pid},#{serType},#{serDoct},#{createDate},#{createUserName},#{createUser},#{serStatus},#{updateDate},#{updateUserName},#{updateUser},#{hospitalId},#{serCode},#{status},#{receiveDate},#{receiveUser},#{backDate},#{backUser},#{orderId}) | |
32 | + insert into patient_service (id,parentid,pid,ser_type,ser_doct,create_date,create_user_name,create_user,ser_status,update_date,update_user_name,update_user,hospital_id,ser_code,status,receive_date,receive_user,back_date,back_user,order_id,syn_status) values (#{id},#{parentid},#{pid},#{serType},#{serDoct},#{createDate},#{createUserName},#{createUser},#{serStatus},#{updateDate},#{updateUserName},#{updateUser},#{hospitalId},#{serCode},#{status},#{receiveDate},#{receiveUser},#{backDate},#{backUser},#{orderId},#{synStatus}) | |
32 | 33 | </insert> |
33 | 34 | |
34 | 35 | |
... | ... | @@ -91,6 +92,9 @@ |
91 | 92 | <if test="orderId != null and orderId != ''"> |
92 | 93 | order_id = #{orderId,jdbcType=VARCHAR}, |
93 | 94 | </if> |
95 | + <if test="synStatus != null and synStatus != ''"> | |
96 | + syn_status = #{synStatus,jdbcType=INTEGER}, | |
97 | + </if> | |
94 | 98 | </set> |
95 | 99 | where id = #{id,jdbcType=VARCHAR} |
96 | 100 | </update> |
... | ... | @@ -103,7 +107,7 @@ |
103 | 107 | |
104 | 108 | |
105 | 109 | <select id="getPatientService" resultMap="PatientServiceResultMap" parameterType="java.lang.String"> |
106 | - select id,parentid,pid,ser_type,ser_doct,create_date,create_user_name,create_user,ser_status,update_date,update_user_name,update_user,hospital_id,ser_code,status,receive_date,receive_user,back_date,back_user,order_id | |
110 | + select id,parentid,pid,ser_type,ser_doct,create_date,create_user_name,create_user,ser_status,update_date,update_user_name,update_user,hospital_id,ser_code,status,receive_date,receive_user,back_date,back_user,order_id,syn_status | |
107 | 111 | from patient_service where id = #{id,jdbcType=VARCHAR} |
108 | 112 | </select> |
109 | 113 | |
... | ... | @@ -199,6 +203,9 @@ |
199 | 203 | <if test="orderId != null and orderId != ''"> |
200 | 204 | and order_id = #{orderId,jdbcType=VARCHAR} |
201 | 205 | </if> |
206 | + <if test="synStatus != null and synStatus != ''"> | |
207 | + and syn_status = #{synStatus,jdbcType=INTEGER} | |
208 | + </if> | |
202 | 209 | <if test="sql != null and sql != ''"> |
203 | 210 | ${sql} |
204 | 211 | </if> |
... | ... | @@ -206,7 +213,7 @@ |
206 | 213 | </sql> |
207 | 214 | |
208 | 215 | <select id="queryPatientService" resultMap="PatientServiceResultMap" parameterType="com.lyms.platform.permission.model.PatientServiceQuery"> |
209 | - select id,parentid,pid,ser_type,ser_doct,create_date,create_user_name,create_user,ser_status,update_date,update_user_name,update_user,hospital_id,ser_code,status,receive_date,receive_user,back_date,back_user,order_id | |
216 | + select id,parentid,pid,ser_type,ser_doct,create_date,create_user_name,create_user,ser_status,update_date,update_user_name,update_user,hospital_id,ser_code,status,receive_date,receive_user,back_date,back_user,order_id,syn_status | |
210 | 217 | from patient_service |
211 | 218 | <include refid="PatientServiceCondition" /> |
212 | 219 | <include refid="orderAndLimit" /> |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/HearingDiagnoseController.java
View file @
af4f352
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/SyncDataController.java
View file @
af4f352
... | ... | @@ -17,12 +17,14 @@ |
17 | 17 | import org.apache.commons.lang.StringUtils; |
18 | 18 | import org.springframework.beans.factory.annotation.Autowired; |
19 | 19 | import org.springframework.stereotype.Controller; |
20 | +import org.springframework.util.ReflectionUtils; | |
20 | 21 | import org.springframework.web.bind.annotation.*; |
21 | 22 | import org.springframework.web.context.ContextLoader; |
22 | 23 | import org.springframework.web.context.WebApplicationContext; |
23 | 24 | |
24 | 25 | import javax.servlet.http.HttpServletRequest; |
25 | 26 | import javax.servlet.http.HttpServletResponse; |
27 | +import java.lang.reflect.Method; | |
26 | 28 | import java.util.List; |
27 | 29 | |
28 | 30 | /** |
... | ... | @@ -44,6 +46,9 @@ |
44 | 46 | /** |
45 | 47 | * 小程序同步数据接口 |
46 | 48 | * |
49 | + * @param action 请求处理类 默认执行execute方法 | |
50 | + * @param synForm 请求数据 | |
51 | + * | |
47 | 52 | * @return |
48 | 53 | */ |
49 | 54 | @ResponseBody |
50 | 55 | |
... | ... | @@ -51,13 +56,13 @@ |
51 | 56 | public BaseResponse sysnDataSer( |
52 | 57 | @RequestParam(value = "action", required = true) String action, |
53 | 58 | @RequestParam(value = "synForm", required = true) String synForm |
54 | - ){ | |
55 | - try{ | |
56 | - System.out.println("数据同步开始:action:"+action+",synForm:"+synForm); | |
59 | + ) { | |
60 | + try { | |
61 | + System.out.println("数据同步开始:action:" + action + ",synForm:" + synForm); | |
57 | 62 | WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext(); |
58 | - SysBaseFacade sysBaseFacade = (SysBaseFacade)webApplicationContext.getBean(action); | |
59 | - return sysBaseFacade.sysData(synForm); | |
60 | - }catch (Exception e){ | |
63 | + SysBaseFacade sysBaseFacade = (SysBaseFacade) webApplicationContext.getBean(action); | |
64 | + return sysBaseFacade.execute(synForm); | |
65 | + } catch (Exception e) { | |
61 | 66 | BaseResponse baseResponse = new BaseResponse(); |
62 | 67 | baseResponse.setObject(e.getMessage()); |
63 | 68 | baseResponse.setErrorcode(ErrorCodeConstants.SYSTEM_ERROR); |
... | ... | @@ -66,6 +71,43 @@ |
66 | 71 | } |
67 | 72 | } |
68 | 73 | |
74 | + /** | |
75 | + * 小程序同步数据接口 | |
76 | + * | |
77 | + * @param action 请求处理类 | |
78 | + * @param synForm 请求数据 | |
79 | + * @param method 请求处理方法,默认执行execute | |
80 | + * @return | |
81 | + */ | |
82 | + @ResponseBody | |
83 | + @RequestMapping(value = "/sysnReflectDataSer", method = RequestMethod.POST) | |
84 | + public BaseResponse sysnReflectDataSer( | |
85 | + @RequestParam(value = "action", required = true) String action, | |
86 | + @RequestParam(value = "synForm", required = false) String synForm, | |
87 | + @RequestParam(value = "method", required = true) String method | |
88 | + ) { | |
89 | + try { | |
90 | + System.out.println("数据同步开始:action:" + action + ",synForm:" + synForm); | |
91 | + WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext(); | |
92 | + //返回值 | |
93 | + BaseResponse baseResponse = null; | |
94 | + if(StringUtils.isNotEmpty(synForm)){//如果有参数 | |
95 | + Method mh = ReflectionUtils.findMethod(webApplicationContext.getBean(action).getClass(), method, new Class[]{String.class}); | |
96 | + baseResponse = (BaseResponse) ReflectionUtils.invokeMethod(mh, webApplicationContext.getBean(action), synForm); | |
97 | + }else{//无参数 | |
98 | + Method mh = ReflectionUtils.findMethod(webApplicationContext.getBean(action).getClass(), method, null); | |
99 | + baseResponse = (BaseResponse) ReflectionUtils.invokeMethod(mh, webApplicationContext.getBean(action), null); | |
100 | + } | |
101 | + return baseResponse; | |
102 | + } catch (Exception e) { | |
103 | + BaseResponse baseResponse = new BaseResponse(); | |
104 | + baseResponse.setObject(e.getMessage()); | |
105 | + baseResponse.setErrorcode(ErrorCodeConstants.SYSTEM_ERROR); | |
106 | + baseResponse.setErrormsg(ErrorCodeConstants.SYSTEM_ERROR_DESCRIPTION); | |
107 | + return baseResponse; | |
108 | + } | |
109 | + } | |
110 | + | |
69 | 111 | @RequestMapping(value = "/findSyncData", method = RequestMethod.POST) |
70 | 112 | public void findSyncData(HttpServletResponse response) { |
71 | 113 | SyncDataQuery syncDataQuery = new SyncDataQuery(); |
... | ... | @@ -73,7 +115,7 @@ |
73 | 115 | syncDataQuery.setLimit(2000); |
74 | 116 | syncDataQuery.setStatus(1); |
75 | 117 | List<SyncDataModel> list = syncDataService.querySyncData(syncDataQuery); |
76 | - for (SyncDataModel model:list) { | |
118 | + for (SyncDataModel model : list) { | |
77 | 119 | model.setModified(null); |
78 | 120 | model.setCreated(null); |
79 | 121 | if (model.getAction().startsWith("POST")) { |
80 | 122 | |
... | ... | @@ -91,13 +133,13 @@ |
91 | 133 | public void updateSyncData(HttpServletResponse response, String ids) { |
92 | 134 | if (StringUtils.isNotBlank(ids)) { |
93 | 135 | String[] array = ids.split(","); |
94 | - for (String id:array) { | |
136 | + for (String id : array) { | |
95 | 137 | SyncDataModel model = new SyncDataModel(); |
96 | 138 | model.setId(id); |
97 | 139 | model.setStatus(0); |
98 | 140 | syncDataService.updateSyncData(model); |
99 | 141 | } |
100 | - writeString(response,"updateSyncData success"); | |
142 | + writeString(response, "updateSyncData success"); | |
101 | 143 | } else { |
102 | 144 | writeString(response, "updateSyncData fail"); |
103 | 145 | } |
104 | 146 | |
105 | 147 | |
106 | 148 | |
107 | 149 | |
108 | 150 | |
109 | 151 | |
110 | 152 | |
... | ... | @@ -107,37 +149,35 @@ |
107 | 149 | /** |
108 | 150 | * 同步mysql的数据 |
109 | 151 | * 把线上执行的sql拿到区域上面执行 |
152 | + * | |
110 | 153 | * @param response |
111 | 154 | * @param sqlRequest |
112 | 155 | * @param request |
113 | 156 | */ |
114 | 157 | @RequestMapping(value = "/syncMysqlData", method = RequestMethod.POST) |
115 | - public void updateSyncData(HttpServletResponse response, @RequestBody SqlRequest sqlRequest,HttpServletRequest request, | |
158 | + public void updateSyncData(HttpServletResponse response, @RequestBody SqlRequest sqlRequest, HttpServletRequest request, | |
116 | 159 | @RequestHeader("Authorization") String token) { |
117 | 160 | |
118 | - if (!"3d19960bf3e81e7d816c4f26051c49ba".equals(token)) | |
119 | - { | |
120 | - ExceptionUtils.catchException("The request token is "+ token); | |
161 | + if (!"3d19960bf3e81e7d816c4f26051c49ba".equals(token)) { | |
162 | + ExceptionUtils.catchException("The request token is " + token); | |
121 | 163 | writeString(response, "Token is error"); |
122 | 164 | return; |
123 | 165 | } |
124 | 166 | try { |
125 | 167 | if (sqlRequest != null) { |
126 | 168 | String base64Sql = sqlRequest.getSql(); |
127 | - if (StringUtils.isNotEmpty(base64Sql)) | |
128 | - { | |
169 | + if (StringUtils.isNotEmpty(base64Sql)) { | |
129 | 170 | String sqlId = sqlRequest.getSqlId(); |
130 | - String sql = new String(Base64.decodeBase64(base64Sql),"utf-8"); | |
131 | - System.out.println("sqlId = " + sqlId+" : "+sql); | |
171 | + String sql = new String(Base64.decodeBase64(base64Sql), "utf-8"); | |
172 | + System.out.println("sqlId = " + sqlId + " : " + sql); | |
132 | 173 | organizationService.execSql(sql); |
133 | 174 | } |
134 | 175 | } |
135 | - } catch (Exception e) | |
136 | - { | |
176 | + } catch (Exception e) { | |
137 | 177 | writeString(response, "execSyncMysqlData fail"); |
138 | - ExceptionUtils.catchException(e,"execSyncMysqlData fail"); | |
178 | + ExceptionUtils.catchException(e, "execSyncMysqlData fail"); | |
139 | 179 | } |
140 | - writeString(response,"success"); | |
180 | + writeString(response, "success"); | |
141 | 181 | } |
142 | 182 | |
143 | 183 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientServiceFacade.java
View file @
af4f352
... | ... | @@ -370,6 +370,51 @@ |
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
373 | + * 小程序调用:获取已经领取设备,但是还未同步的数据 | |
374 | + */ | |
375 | + public BaseResponse getAlreaRece(){ | |
376 | + PatientServiceQuery patientQuery = new PatientServiceQuery(); | |
377 | + //待同步默认不需要同步、1-待同步、2-已同步 | |
378 | + patientQuery.setSynStatus(1); | |
379 | + List<PatientService> patientServices = patientServiceService.queryPatientService(patientQuery); | |
380 | + List<String> orders = new ArrayList<>(); | |
381 | + for(PatientService ps :patientServices){ | |
382 | + orders.add(ps.getOrderId()); | |
383 | + } | |
384 | + | |
385 | + BaseResponse baseResponse = new BaseResponse(); | |
386 | + baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
387 | + baseResponse.setObject(orders); | |
388 | + baseResponse.setErrormsg("成功"); | |
389 | + return baseResponse; | |
390 | + } | |
391 | + | |
392 | + /** | |
393 | + * 小程序调用:修改同步状态为已同步 | |
394 | + * | |
395 | + * @param orderIds 订单号集合 | |
396 | + * @return | |
397 | + */ | |
398 | + public BaseResponse receivePatientService(String orderIds) { | |
399 | + PatientServiceQuery patientQuery = new PatientServiceQuery(); | |
400 | + patientQuery.setSql("and order_id in ("+orderIds+")"); | |
401 | + | |
402 | + List<PatientService> patientServices = patientServiceService.queryPatientService(patientQuery); | |
403 | + if(CollectionUtils.isNotEmpty(patientServices)){ | |
404 | + for(PatientService ps :patientServices){ | |
405 | + ps.setSynStatus(2); | |
406 | + patientServiceService.updatePatientService(ps); | |
407 | + } | |
408 | + } | |
409 | + | |
410 | + BaseResponse baseResponse = new BaseResponse(); | |
411 | + baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
412 | + baseResponse.setErrormsg("成功"); | |
413 | + return baseResponse; | |
414 | + } | |
415 | + | |
416 | + | |
417 | + /** | |
373 | 418 | * 修改状态为领取 |
374 | 419 | * |
375 | 420 | * @param psId 服务记录Id |
... | ... | @@ -394,6 +439,8 @@ |
394 | 439 | } |
395 | 440 | //设置为领取状态 |
396 | 441 | ps.setStatus(2); |
442 | + //同步状态为待同步 | |
443 | + ps.setSynStatus(1); | |
397 | 444 | //根据用户id获取医院ID |
398 | 445 | ps.setReceiveDate(new Date()); |
399 | 446 | ps.setReceiveUser(String.valueOf(id)); |
... | ... | @@ -444,7 +491,8 @@ |
444 | 491 | } catch (InterruptedException e1) { |
445 | 492 | e1.printStackTrace(); |
446 | 493 | } |
447 | - synPatientService(patientServices); | |
494 | + //迭代继续同步 | |
495 | + // synPatientService(patientServices); | |
448 | 496 | } |
449 | 497 | return true; |
450 | 498 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientServiceSysFacade.java
View file @
af4f352
... | ... | @@ -28,7 +28,7 @@ |
28 | 28 | private PatientServiceService patientServiceService; |
29 | 29 | |
30 | 30 | @Override |
31 | - public BaseResponse sysData(String synForm) { | |
31 | + public BaseResponse execute(String synForm) { | |
32 | 32 | JSONArray jsonArray = JSONArray.fromObject(synForm); |
33 | 33 | BaseResponse baseResponse = new BaseResponse(); |
34 | 34 | for (int i = 0; i < jsonArray.size(); i++) { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/SysBaseFacade.java
View file @
af4f352
platform-operate-api/src/main/resources/spring/applicationContext-quartz.xml
View file @
af4f352
... | ... | @@ -199,9 +199,9 @@ |
199 | 199 | <ref bean="correctSieveOrderTrigger"/> |
200 | 200 | <ref bean="autoInsertIdTrigger"/> |
201 | 201 | <!--乐陵住院系统同步--> |
202 | - <ref bean="synLlHisDataTrigger"/> | |
202 | + <!--<ref bean="synLlHisDataTrigger"/>--> | |
203 | 203 | <!--乐陵住院启动时执行一次--> |
204 | - <ref bean="rsh_simpleTrigger1" /> | |
204 | + <!--<ref bean="rsh_simpleTrigger1" />--> | |
205 | 205 | <!--<ref bean="qhdFmTrigger"/>--> |
206 | 206 | <!--<ref bean="dzfyFmTrigger"/>--> |
207 | 207 | <!--<ref bean="crisisTrigger"/>--> |