From 1b6e655f65ed53a1a718c30552eefd3f5097907e Mon Sep 17 00:00:00 2001 From: riecard Date: Mon, 26 Sep 2016 20:54:14 +0800 Subject: [PATCH] add sync data task --- .../operate/web/service/SyncDataTaskService.java | 37 ++++++++++++++++++++++ .../main/resources/spring/applicationContext.xml | 16 ++++++++-- 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/SyncDataTaskService.java diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/SyncDataTaskService.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/SyncDataTaskService.java new file mode 100644 index 0000000..ed50e26 --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/SyncDataTaskService.java @@ -0,0 +1,37 @@ +package com.lyms.platform.operate.web.service; + +import com.lyms.platform.biz.service.SyncDataService; +import com.lyms.platform.common.pojo.SyncDataModel; +import com.lyms.platform.common.utils.MongoSyncUtil; +import com.lyms.platform.query.SyncDataQuery; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + +/** + * Created by riecard on 16/9/26. + */ +@Service("syncDataTaskService") +public class SyncDataTaskService { + + @Autowired + private SyncDataService syncDataService; + + public void syncData() { + SyncDataQuery query = new SyncDataQuery(); + query.setStatus(1); + query.setLimit(1000); + query.setNeed("0"); + List list = syncDataService.querySyncData(query); + for (SyncDataModel model:list) { + if (MongoSyncUtil.sync(model.getAction(),model.getJsonData(),model.getDataId())) { + model.setStatus(0); + model.setModified(new Date()); + syncDataService.updateSyncData(model); + } + } + } + +} diff --git a/platform-operate-api/src/main/resources/spring/applicationContext.xml b/platform-operate-api/src/main/resources/spring/applicationContext.xml index 5ae7718..24099c1 100644 --- a/platform-operate-api/src/main/resources/spring/applicationContext.xml +++ b/platform-operate-api/src/main/resources/spring/applicationContext.xml @@ -1,9 +1,15 @@ + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd + http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd + 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"> @@ -14,6 +20,7 @@ + @@ -28,6 +35,11 @@ + + + + + -- 1.8.3.1