Commit 36fc43800f197a3d2d6febc04f525a6239835389
Exists in
master
and in
1 other branch
Merge remote-tracking branch 'origin/master'
Showing 8 changed files
- platform-common/src/main/java/com/lyms/platform/common/dao/BaseMongoDAOImpl.java
- platform-common/src/main/java/com/lyms/platform/common/utils/MongoSyncUtil.java
- platform-dal/src/main/java/com/lyms/platform/query/BabyModelQuery.java
- platform-data-api/src/main/java/com/lyms/platform/data/service/impl/SmsServiceImpl.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyBookbuildingFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyCheckFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/SyncDataTaskService.java
- platform-operate-api/src/main/resources/spring/applicationContext.xml
platform-common/src/main/java/com/lyms/platform/common/dao/BaseMongoDAOImpl.java
View file @
36fc438
... | ... | @@ -4,7 +4,6 @@ |
4 | 4 | import com.lyms.platform.common.pojo.SyncDataModel; |
5 | 5 | import com.lyms.platform.common.utils.*; |
6 | 6 | import org.apache.commons.collections.CollectionUtils; |
7 | -import org.apache.commons.lang.*; | |
8 | 7 | import org.springframework.beans.factory.annotation.Autowired; |
9 | 8 | import org.springframework.data.mongodb.core.MongoTemplate; |
10 | 9 | import org.springframework.data.mongodb.core.query.Query; |
... | ... | @@ -144,6 +143,9 @@ |
144 | 143 | public static String mongo_crypto_key = Config.getItem("mongo_crypto_key", "0"); |
145 | 144 | public static String mongo_sync = Config.getItem("mongo_sync", "0"); |
146 | 145 | public void addSyncData(String action, Object data, String id) { |
146 | + if ("SyncDataModel".equals(data.getClass().getSimpleName())) { | |
147 | + return; | |
148 | + } | |
147 | 149 | if ("1".equals(mongo_sync)) { |
148 | 150 | try { |
149 | 151 | if (action.startsWith("Mysql")) { |
platform-common/src/main/java/com/lyms/platform/common/utils/MongoSyncUtil.java
View file @
36fc438
1 | 1 | package com.lyms.platform.common.utils; |
2 | 2 | |
3 | -import com.lyms.platform.common.base.LoginContext; | |
4 | 3 | import com.lyms.platform.common.base.PageInfo; |
5 | -import com.lyms.platform.common.dao.operator.MongoCondition; | |
6 | -import com.lyms.platform.common.dao.operator.MongoOper; | |
7 | -import com.lyms.platform.common.dao.operator.MongoQuery; | |
8 | -import com.mchange.lang.LongUtils; | |
9 | 4 | import org.apache.commons.httpclient.HttpClient; |
10 | 5 | import org.apache.commons.httpclient.NameValuePair; |
11 | 6 | import org.apache.commons.httpclient.methods.PostMethod; |
12 | 7 | |
13 | -import java.util.HashMap; | |
14 | -import java.util.Map; | |
15 | - | |
16 | 8 | /** |
17 | 9 | * Created by Administrator on 2016/9/13 0013. |
18 | 10 | */ |
19 | 11 | |
... | ... | @@ -23,8 +15,39 @@ |
23 | 15 | public static String mongo_sync_token = Config.getItem("mongo_sync_token", "0"); |
24 | 16 | public static String mongo_crypto_key = Config.getItem("mongo_crypto_key", "0"); |
25 | 17 | |
18 | + public static boolean sync(String action, String jsonData, String id, String className) { | |
19 | + if ("1".equals(mongo_sync)) { | |
20 | + boolean boo = false; | |
21 | + try { | |
22 | + HttpClient client = new HttpClient(); | |
23 | + client.getHttpConnectionManager().getParams().setConnectionTimeout(3000); | |
24 | + client.getHttpConnectionManager().getParams().setSoTimeout(3000); | |
25 | + PostMethod post = new MessageUtil.UTF8PostMethod(mongo_sync_url); | |
26 | + NameValuePair[] pairs = { | |
27 | + new NameValuePair("action", action), | |
28 | + new NameValuePair("token", mongo_sync_token), | |
29 | + new NameValuePair("className", className), | |
30 | + new NameValuePair("jsonData", jsonData), | |
31 | + new NameValuePair("id", id), | |
32 | + }; | |
33 | + post.setRequestBody(pairs); | |
34 | + client.executeMethod(post); | |
35 | + int statusCode = post.getStatusCode(); | |
36 | + System.out.println(post.getResponseBodyAsString()); | |
37 | + post.releaseConnection(); | |
38 | + if (200 == statusCode) { | |
39 | + boo = true; | |
40 | + } | |
41 | + return boo; | |
42 | + } catch (Exception e) { | |
43 | + e.printStackTrace(); | |
44 | + return boo; | |
45 | + } | |
46 | + } | |
47 | + return true; | |
48 | + } | |
49 | + | |
26 | 50 | public static boolean sync(String action, Object data, String id) { |
27 | - System.out.println(mongo_sync +" :: "+id+" -- "+action); | |
28 | 51 | if ("1".equals(mongo_sync)) { |
29 | 52 | boolean boo = false; |
30 | 53 | try { |
platform-dal/src/main/java/com/lyms/platform/query/BabyModelQuery.java
View file @
36fc438
... | ... | @@ -175,7 +175,16 @@ |
175 | 175 | //诊断 |
176 | 176 | private String lastDiagnose; |
177 | 177 | |
178 | + private List<Integer> buildTypeList; | |
178 | 179 | |
180 | + public List<Integer> getBuildTypeList() { | |
181 | + return buildTypeList; | |
182 | + } | |
183 | + | |
184 | + public void setBuildTypeList(List<Integer> buildTypeList) { | |
185 | + this.buildTypeList = buildTypeList; | |
186 | + } | |
187 | + | |
179 | 188 | public String getLastDiagnose() { |
180 | 189 | return lastDiagnose; |
181 | 190 | } |
... | ... | @@ -369,6 +378,15 @@ |
369 | 378 | MongoCondition con1 = MongoCondition.newInstance("phoneId", phoneId, MongoOper.LIKE); |
370 | 379 | MongoCondition con = MongoCondition.newInstance("cardId", cardId, MongoOper.LIKE); |
371 | 380 | condition = condition.orCondition(new MongoCondition[]{con1, con}); |
381 | + } | |
382 | + | |
383 | + if(null != buildTypeList) { | |
384 | + MongoCondition mongoCondition = MongoCondition.newInstance("buildType", 3, MongoOper.IS); | |
385 | + MongoCondition condition1 = mongoCondition.and("enable", "1", MongoOper.IS); | |
386 | + | |
387 | + MongoCondition condition2 = MongoCondition.newInstance("buildType", buildTypeList, MongoOper.IN); | |
388 | + | |
389 | + condition = condition.orCondition(new MongoCondition[]{condition1, condition2}); | |
372 | 390 | } |
373 | 391 | |
374 | 392 | if(null!=sex){ |
platform-data-api/src/main/java/com/lyms/platform/data/service/impl/SmsServiceImpl.java
View file @
36fc438
... | ... | @@ -397,6 +397,10 @@ |
397 | 397 | babyQuery.setYn(YnEnums.YES.getId()); |
398 | 398 | babyQuery.setHospitalId(hospitalId); |
399 | 399 | |
400 | +// List buildType = new ArrayList(); | |
401 | +// buildType.add(1); | |
402 | +// buildType.add(2); | |
403 | +// babyQuery.setBuildTypeList(buildType); | |
400 | 404 | |
401 | 405 | //儿童年龄满三岁就不在提供短信服务 |
402 | 406 | Date birthdayMax = DateUtil.addYear(new Date(), -3); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyBookbuildingFacade.java
View file @
36fc438
... | ... | @@ -1569,6 +1569,12 @@ |
1569 | 1569 | |
1570 | 1570 | private List<BabyModel> getBabayListByCondition(BabyManageRequest request, boolean isPage, BabyModelQuery babyQuery) { |
1571 | 1571 | |
1572 | + | |
1573 | + List buildType = new ArrayList(); | |
1574 | + buildType.add(1); | |
1575 | + buildType.add(2); | |
1576 | + babyQuery.setBuildTypeList(buildType); | |
1577 | + | |
1572 | 1578 | babyQuery.setYn(YnEnums.YES.getId()); |
1573 | 1579 | if (isPage) { |
1574 | 1580 | babyQuery.setNeed("true"); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyCheckFacade.java
View file @
36fc438
... | ... | @@ -258,6 +258,11 @@ |
258 | 258 | babyModelQuery.setBuildType(3); |
259 | 259 | List<BabyModel> babyModelList= babyBookbuildingService.queryBabyBuildByCond(babyModelQuery); |
260 | 260 | if(CollectionUtils.isNotEmpty(babyModelList)){ |
261 | + | |
262 | + BabyModel babyModel = new BabyModel(); | |
263 | + babyModel.setEnable("1"); | |
264 | + babyBookbuildingService.updateBabyBuild(babyModel,babyModelList.get(0).getId()); | |
265 | + | |
261 | 266 | ReferralApplyOrderQuery referralApplyOrderQuery = new ReferralApplyOrderQuery(); |
262 | 267 | referralApplyOrderQuery.setParentId(request.getBuildId()); |
263 | 268 | String hospital =babyModelList.get(0).getHospitalId(); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/SyncDataTaskService.java
View file @
36fc438
1 | +package com.lyms.platform.operate.web.service; | |
2 | + | |
3 | +import com.lyms.platform.biz.service.SyncDataService; | |
4 | +import com.lyms.platform.common.pojo.SyncDataModel; | |
5 | +import com.lyms.platform.common.utils.MongoSyncUtil; | |
6 | +import com.lyms.platform.query.SyncDataQuery; | |
7 | +import org.springframework.beans.factory.annotation.Autowired; | |
8 | +import org.springframework.stereotype.Service; | |
9 | + | |
10 | +import java.util.Date; | |
11 | +import java.util.List; | |
12 | + | |
13 | +/** | |
14 | + * Created by riecard on 16/9/26. | |
15 | + */ | |
16 | +@Service("syncDataTaskService") | |
17 | +public class SyncDataTaskService { | |
18 | + | |
19 | + @Autowired | |
20 | + private SyncDataService syncDataService; | |
21 | + | |
22 | + public void syncData() { | |
23 | + SyncDataQuery query = new SyncDataQuery(); | |
24 | + query.setStatus(1); | |
25 | + query.setLimit(1000); | |
26 | + query.setNeed("0"); | |
27 | + List<SyncDataModel> list = syncDataService.querySyncData(query); | |
28 | + for (SyncDataModel model:list) { | |
29 | + if (MongoSyncUtil.sync(model.getAction(),model.getJsonData(),model.getDataId(),model.getClassName())) { | |
30 | + model.setStatus(0); | |
31 | + model.setModified(new Date()); | |
32 | + syncDataService.updateSyncData(model); | |
33 | + } | |
34 | + } | |
35 | + } | |
36 | + | |
37 | +} |
platform-operate-api/src/main/resources/spring/applicationContext.xml
View file @
36fc438
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | 2 | <beans xmlns="http://www.springframework.org/schema/beans" |
3 | - xmlns:context="http://www.springframework.org/schema/context" | |
3 | + xmlns:p="http://www.springframework.org/schema/p" | |
4 | + xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" | |
4 | 5 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
6 | + xmlns:cache="http://www.springframework.org/schema/cache" | |
7 | + xmlns:task="http://www.springframework.org/schema/task" xmlns:aop="http://www.springframework.org/schema/aop" | |
5 | 8 | xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd |
6 | - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"> | |
9 | + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd | |
10 | + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd | |
11 | + http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd | |
12 | + http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> | |
7 | 13 | |
8 | 14 | <!-- 采用注释的方式配置bean --> |
9 | 15 | <context:annotation-config/> |
... | ... | @@ -14,6 +20,7 @@ |
14 | 20 | <!-- 配置要扫描的包 --> |
15 | 21 | <context:component-scan base-package="com.lyms.platform.biz.dal.impl"/> |
16 | 22 | <context:component-scan base-package="com.lyms.platform.operate.web.facade"/> |
23 | + <context:component-scan base-package="com.lyms.platform.operate.web.service"/> | |
17 | 24 | <context:component-scan base-package="com.lyms.platform.permission.*"/> |
18 | 25 | <context:component-scan base-package="com.lymsh.platform.reportdata.model.*" /> |
19 | 26 | <context:component-scan base-package="com.lymsh.platform.reportdata.dao" /> |
... | ... | @@ -28,6 +35,11 @@ |
28 | 35 | <!--医院单机版的时候需要打开 |
29 | 36 | <import resource="classpath:/spring/applicationContext-slave.xml"/>--> |
30 | 37 | |
38 | + <task:annotation-driven/> | |
39 | + | |
40 | + <!--<task:scheduled-tasks>--> | |
41 | + <!--<task:scheduled ref="syncDataTaskService" method="syncData" cron="0 0/10 * * * ?"/>--> | |
42 | + <!--</task:scheduled-tasks>--> | |
31 | 43 | |
32 | 44 | <bean id="sessionProvider" class="com.lyms.platform.operate.web.session.SessionProvider"> |
33 | 45 | <property name="iSessionProviderMap"> |