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 @@ + + + + +