Commit 1b6e655f65ed53a1a718c30552eefd3f5097907e
1 parent
3e0fd3a187
Exists in
master
and in
8 other branches
add sync data task
Showing 2 changed files with 51 additions and 2 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/SyncDataTaskService.java
View file @
1b6e655
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())) { | |
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 @
1b6e655
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"> |