Commit bf606d657455aee26db28e6f59a808ee36a2ed40
1 parent
bf5daf7ee1
Exists in
master
and in
6 other branches
孕妇学校
Showing 5 changed files with 97 additions and 28 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/PatientCourseService.java
- platform-dal/src/main/java/com/lyms/platform/query/PatientCourseQuery.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientCourseFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/inteceptor/MysqlDataInterceptor.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/SyncDataTaskService.java
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/PatientCourseService.java
View file @
bf606d6
| ... | ... | @@ -29,6 +29,16 @@ |
| 29 | 29 | return patientCourseDao.queryPatientCourseList(query.addOrder(Sort.Direction.DESC, "created")); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | + public List<PatientCourseModel> queryPatientCourseList(PatientCourseQuery patientCourseQuery,String sort) | |
| 33 | + { | |
| 34 | + MongoQuery query = patientCourseQuery.convertToQuery(); | |
| 35 | + if (StringUtils.isNotEmpty(patientCourseQuery.getNeed())) { | |
| 36 | + patientCourseQuery.mysqlBuild(patientCourseDao.queryPatientCourseListCount(patientCourseQuery.convertToQuery())); | |
| 37 | + query.start(patientCourseQuery.getOffset()).end(patientCourseQuery.getLimit()); | |
| 38 | + } | |
| 39 | + return patientCourseDao.queryPatientCourseList(query.addOrder(Sort.Direction.DESC,sort)); | |
| 40 | + } | |
| 41 | + | |
| 32 | 42 | public void addPatientCourse(PatientCourseModel model) { |
| 33 | 43 | patientCourseDao.addPatientCourse(model); |
| 34 | 44 | } |
platform-dal/src/main/java/com/lyms/platform/query/PatientCourseQuery.java
View file @
bf606d6
| ... | ... | @@ -8,6 +8,7 @@ |
| 8 | 8 | import org.springframework.data.mongodb.core.query.Criteria; |
| 9 | 9 | |
| 10 | 10 | import java.util.Date; |
| 11 | +import java.util.List; | |
| 11 | 12 | |
| 12 | 13 | /** |
| 13 | 14 | * 孕妇预约和签到 |
| ... | ... | @@ -47,6 +48,8 @@ |
| 47 | 48 | //patientid |
| 48 | 49 | private String patientId; |
| 49 | 50 | |
| 51 | + private List<String> patientIds; | |
| 52 | + | |
| 50 | 53 | //课程id |
| 51 | 54 | private String courseId; |
| 52 | 55 | |
| ... | ... | @@ -100,6 +103,10 @@ |
| 100 | 103 | condition = condition.and("patientId", patientId, MongoOper.IS); |
| 101 | 104 | } |
| 102 | 105 | |
| 106 | + if (null != patientIds) { | |
| 107 | + condition = condition.and("patientId", patientIds, MongoOper.IN); | |
| 108 | + } | |
| 109 | + | |
| 103 | 110 | if (null != courseId) { |
| 104 | 111 | condition = condition.and("courseId", courseId, MongoOper.IS); |
| 105 | 112 | } |
| ... | ... | @@ -133,6 +140,14 @@ |
| 133 | 140 | } |
| 134 | 141 | |
| 135 | 142 | return condition.toMongoQuery(); |
| 143 | + } | |
| 144 | + | |
| 145 | + public List<String> getPatientIds() { | |
| 146 | + return patientIds; | |
| 147 | + } | |
| 148 | + | |
| 149 | + public void setPatientIds(List<String> patientIds) { | |
| 150 | + this.patientIds = patientIds; | |
| 136 | 151 | } |
| 137 | 152 | |
| 138 | 153 | public String getQueryNo() { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientCourseFacade.java
View file @
bf606d6
| ... | ... | @@ -533,11 +533,34 @@ |
| 533 | 533 | result.put("limitNum", model.getLimitNum() == null ? "0" : String.valueOf(model.getLimitNum())); |
| 534 | 534 | |
| 535 | 535 | patientCourseQuery.setCourseId(model.getId()); |
| 536 | - patientCourseQuery.setPatientId(patientId); | |
| 537 | 536 | |
| 537 | + List<String> patids = new ArrayList<>(); | |
| 538 | 538 | |
| 539 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
| 540 | + patientsQuery.setYn(YnEnums.YES.getId()); | |
| 541 | + patientsQuery.setId(patientId); | |
| 542 | + List<Patients> patientses = patientsService.queryPatient(patientsQuery); | |
| 543 | + if (CollectionUtils.isNotEmpty(patientses)) { | |
| 544 | + | |
| 545 | + Patients patients = patientses.get(0); | |
| 546 | + patientsQuery.setId(null); | |
| 547 | + patientsQuery.setPid(patients.getPid()); | |
| 548 | + patientsQuery.setDesc("true"); | |
| 549 | + patientsQuery.setSort("created"); | |
| 550 | + patientses = patientsService.queryPatient(patientsQuery); | |
| 551 | + if (CollectionUtils.isNotEmpty(patientses)) | |
| 552 | + { | |
| 553 | + for (Patients pat : patientses) | |
| 554 | + { | |
| 555 | + patids.add(pat.getId()); | |
| 556 | + } | |
| 557 | + } | |
| 558 | + } | |
| 559 | + | |
| 560 | + patientCourseQuery.setPatientIds(patids); | |
| 561 | + | |
| 539 | 562 | Integer patientStatus = 0; |
| 540 | - List<PatientCourseModel> patientCourseModels = patientCourseService.queryPatientCourseList(patientCourseQuery); | |
| 563 | + List<PatientCourseModel> patientCourseModels = patientCourseService.queryPatientCourseList(patientCourseQuery,"status"); | |
| 541 | 564 | if (CollectionUtils.isNotEmpty(patientCourseModels)) |
| 542 | 565 | { |
| 543 | 566 | patientStatus = patientCourseModels.get(0).getStatus(); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/inteceptor/MysqlDataInterceptor.java
View file @
bf606d6
| 1 | 1 | package com.lyms.platform.operate.web.inteceptor; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | +import com.lyms.platform.biz.service.SyncDataService; | |
| 4 | 5 | import com.lyms.platform.common.utils.ExceptionUtils; |
| 5 | 6 | import com.lyms.platform.operate.web.utils.SendMysqlSyncDatUtil; |
| 6 | 7 | import org.apache.commons.collections.CollectionUtils; |
| 7 | 8 | |
| ... | ... | @@ -14,13 +15,14 @@ |
| 14 | 15 | import org.apache.ibatis.reflection.MetaObject; |
| 15 | 16 | import org.apache.ibatis.session.Configuration; |
| 16 | 17 | import org.apache.ibatis.type.TypeHandlerRegistry; |
| 18 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 17 | 19 | |
| 18 | 20 | import java.sql.Statement; |
| 19 | 21 | import java.text.DateFormat; |
| 20 | 22 | import java.util.*; |
| 21 | 23 | |
| 22 | 24 | /** |
| 23 | - * 同步线上mysql的操作到区域 | |
| 25 | + * 眼科和听筛执行的sql保存下来 然后把区域执行的这些sql同步到线上执行 | |
| 24 | 26 | * Created by Administrator on 2017-04-24. |
| 25 | 27 | */ |
| 26 | 28 | @Intercepts({ |
| ... | ... | @@ -29,6 +31,10 @@ |
| 29 | 31 | }) |
| 30 | 32 | public class MysqlDataInterceptor implements Interceptor { |
| 31 | 33 | |
| 34 | + | |
| 35 | + @Autowired | |
| 36 | + private SyncDataService syncDataService; | |
| 37 | + | |
| 32 | 38 | //同步的表 |
| 33 | 39 | private static Set<String> uses = new HashSet<>(); |
| 34 | 40 | static { |
| 35 | 41 | |
| 36 | 42 | |
| ... | ... | @@ -71,10 +77,9 @@ |
| 71 | 77 | sql = getSql(configuration, boundSql, sqlId); |
| 72 | 78 | if (isSyncTable(sql)) |
| 73 | 79 | { |
| 74 | - | |
| 75 | 80 | System.out.println("==============delete or update sync sql = " + sql); |
| 76 | - //发送要同步的sql | |
| 77 | 81 | sql = null; |
| 82 | + syncDataService.savePostMysql(sql,sqlId); | |
| 78 | 83 | } |
| 79 | 84 | } |
| 80 | 85 | else if ("insert".equals(sqlCommandType.toLowerCase()) ) |
| 81 | 86 | |
| ... | ... | @@ -97,10 +102,8 @@ |
| 97 | 102 | List<Integer> list = (ArrayList)returnValue; |
| 98 | 103 | if (CollectionUtils.isNotEmpty(list)) |
| 99 | 104 | { |
| 100 | -// sql = sql.replaceFirst("\\(","(ID,"); | |
| 101 | -// sql = sql.substring(0,sql.lastIndexOf("(")+1)+list.get(0)+","+sql.substring(sql.lastIndexOf("(")+1,sql.length()); | |
| 102 | 105 | System.out.println("============add sync sql = " + sql); |
| 103 | - //发送要同步的sql | |
| 106 | + syncDataService.savePostMysql(sql,sqlId); | |
| 104 | 107 | sql = null; |
| 105 | 108 | } |
| 106 | 109 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/SyncDataTaskService.java
View file @
bf606d6
| ... | ... | @@ -3,42 +3,34 @@ |
| 3 | 3 | import com.lyms.platform.biz.service.*; |
| 4 | 4 | import com.lyms.platform.common.enums.YnEnums; |
| 5 | 5 | import com.lyms.platform.common.pojo.SyncDataModel; |
| 6 | -import com.lyms.platform.common.pojo.UpdateMultiData; | |
| 7 | -import com.lyms.platform.common.utils.*; | |
| 8 | -import com.lyms.platform.operate.web.request.GuideQuery; | |
| 6 | +import com.lyms.platform.common.pojo.SyncMysqlDataModel; | |
| 7 | +import com.lyms.platform.common.utils.DateUtil; | |
| 8 | +import com.lyms.platform.common.utils.ExceptionUtils; | |
| 9 | +import com.lyms.platform.common.utils.JsonUtil; | |
| 10 | +import com.lyms.platform.common.utils.MongoSyncUtil; | |
| 9 | 11 | import com.lyms.platform.operate.web.utils.HttpClientUtil; |
| 10 | -import com.lyms.platform.operate.web.utils.SSLClient; | |
| 11 | 12 | import com.lyms.platform.permission.model.Users; |
| 12 | 13 | import com.lyms.platform.permission.model.UsersQuery; |
| 14 | +import com.lyms.platform.permission.service.OrganizationService; | |
| 13 | 15 | import com.lyms.platform.permission.service.UsersService; |
| 14 | 16 | import com.lyms.platform.pojo.*; |
| 15 | 17 | import com.lyms.platform.query.*; |
| 16 | -import com.qiniu.util.Json; | |
| 18 | + | |
| 17 | 19 | import org.apache.commons.collections.CollectionUtils; |
| 18 | -import org.apache.commons.httpclient.HttpClient; | |
| 19 | -import org.apache.commons.httpclient.NameValuePair; | |
| 20 | -import org.apache.commons.httpclient.methods.PostMethod; | |
| 20 | + | |
| 21 | 21 | import org.apache.commons.io.FileUtils; |
| 22 | -import org.apache.commons.lang.*; | |
| 22 | + | |
| 23 | + | |
| 23 | 24 | import org.apache.commons.lang.StringUtils; |
| 24 | -import org.apache.http.HttpEntity; | |
| 25 | -import org.apache.http.HttpResponse; | |
| 26 | -import org.apache.http.client.entity.UrlEncodedFormEntity; | |
| 27 | -import org.apache.http.client.methods.HttpPost; | |
| 28 | -import org.apache.http.message.BasicNameValuePair; | |
| 29 | -import org.apache.http.util.EntityUtils; | |
| 30 | 25 | import org.joda.time.DateTime; |
| 31 | 26 | import org.springframework.beans.factory.annotation.Autowired; |
| 32 | 27 | import org.springframework.beans.factory.annotation.Qualifier; |
| 33 | -import org.springframework.data.domain.Sort; | |
| 34 | 28 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| 35 | 29 | import org.springframework.stereotype.Service; |
| 36 | 30 | |
| 37 | -import javax.print.attribute.standard.DateTimeAtCompleted; | |
| 38 | 31 | import java.io.File; |
| 32 | +import java.io.UnsupportedEncodingException; | |
| 39 | 33 | import java.util.*; |
| 40 | -import java.util.concurrent.Executor; | |
| 41 | -import java.util.concurrent.Executors; | |
| 42 | 34 | |
| 43 | 35 | /** |
| 44 | 36 | * Created by riecard on 16/9/26. |
| ... | ... | @@ -102,6 +94,8 @@ |
| 102 | 94 | @Qualifier("commonThreadPool") |
| 103 | 95 | private ThreadPoolTaskExecutor commonThreadPool; |
| 104 | 96 | |
| 97 | + @Autowired | |
| 98 | + private OrganizationService organizationService; | |
| 105 | 99 | |
| 106 | 100 | /** |
| 107 | 101 | * 该方法是区域或者单体医院部署的把数据定时往某个环境上传 |
| 108 | 102 | |
| ... | ... | @@ -155,9 +149,17 @@ |
| 155 | 149 | public void run() { |
| 156 | 150 | if (CollectionUtils.isNotEmpty(tempList)) |
| 157 | 151 | { |
| 152 | + boolean boo = false; | |
| 158 | 153 | StringBuffer ids = new StringBuffer(); |
| 159 | 154 | for (SyncDataModel model : tempList) { |
| 160 | - boolean boo = mongoSyncService.syncData(model.getAction(), model.getDataId(), model.getClassName(), model.getJsonData()); | |
| 155 | + if ("POSTMYSQL".equals(model.getAction())) | |
| 156 | + { | |
| 157 | + boo = exceSql(model.getJsonData()); | |
| 158 | + } | |
| 159 | + else | |
| 160 | + { | |
| 161 | + boo = mongoSyncService.syncData(model.getAction(), model.getDataId(), model.getClassName(), model.getJsonData()); | |
| 162 | + } | |
| 161 | 163 | if (boo) { |
| 162 | 164 | ids.append(model.getId()); |
| 163 | 165 | ids.append(","); |
| ... | ... | @@ -186,6 +188,22 @@ |
| 186 | 188 | { |
| 187 | 189 | String json = HttpClientUtil.doPost(url, param, "utf-8"); |
| 188 | 190 | return json; |
| 191 | + } | |
| 192 | + | |
| 193 | + | |
| 194 | + private boolean exceSql(String json) | |
| 195 | + { | |
| 196 | + try { | |
| 197 | + SyncMysqlDataModel mysqlDataModel = JsonUtil.str2Obj(json, SyncMysqlDataModel.class); | |
| 198 | + if (mysqlDataModel != null && org.apache.commons.lang.StringUtils.isNotEmpty(mysqlDataModel.getSql())) | |
| 199 | + { | |
| 200 | + String sql = new String(org.apache.commons.codec.binary.Base64.decodeBase64(mysqlDataModel.getSql()), "utf-8"); | |
| 201 | + organizationService.execSql(sql); | |
| 202 | + } | |
| 203 | + } catch (UnsupportedEncodingException e) { | |
| 204 | + ExceptionUtils.catchException(e,"exce sql error. JSONDATA="+json); | |
| 205 | + } | |
| 206 | + return true; | |
| 189 | 207 | } |
| 190 | 208 | |
| 191 | 209 |