SyncTableJob.java 2.24 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
package com.lyms.cm.job;

import java.io.Serializable;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;

import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.lyms.base.common.entity.sys.SyncDataBasic;
import com.lyms.base.common.service.sys.SyncDataBasicService;
import com.lyms.sync.ParamsAdpter;
import com.lyms.sync.SyncCallback;
import com.lyms.sync.SyncCenter;
import com.lyms.sync.SyncHandler;
import com.lyms.sync.SyncCenter.Work;
import com.lyms.sync.channel.ChannelData;
import com.lyms.sync.queue.SyncQueue;
import com.lyms.util.HttpUtils;
import com.lyms.util.JsonUtils;

/**
* <li>@ClassName: SyncTableJob
* <li>@Description: 同步任务执行器,获取SYNC_DATA_BASIC表格的数据进行处理
* <li>@author 方承
* <li>@date 2017年5月5日
* <li>
*/
public class SyncTableJob {
private static Logger log = LoggerFactory.getLogger(SyncTableJob.class);

@Autowired
private SyncDataBasicService syncDataBasicService;
public void excute() {
List<SyncDataBasic> dataList = syncDataBasicService.selectList(new EntityWrapper<SyncDataBasic>().where("IFSUC=0"));
if(dataList != null ){
log.debug("=======开始进行 SYNC_DATA_BASIC 表格数据的同步=======");
for(SyncDataBasic entity : dataList){
try{
ChannelData data = JsonUtils.jsonToBean(entity.getData(), ChannelData.class);
Object handResult = SyncHandler.handler(data);
if (data.getLoop()) {
data = (ChannelData) handResult;
} else {
data.setData(ParamsAdpter.builder().push(handResult).toJsonString());
}
entity.setIfsuc(1);
syncDataBasicService.updateById(entity);
}catch (Exception e) {
log.error("【SYNC_DATA_BASIC】表格数据的同步错误:SyncDataBasic = {} {}",JSONObject.toJSON(entity),e);
}
}
}
}
}