|
|
|
@ -25,17 +25,20 @@ public class SyncHeartService {
|
|
|
|
|
private SyncDataSetDao syncDataSetDao;
|
|
|
|
|
|
|
|
|
|
public void syncProcess() {
|
|
|
|
|
//查询数据同步设置
|
|
|
|
|
pushData();
|
|
|
|
|
pushOrder();
|
|
|
|
|
pullData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void pushData() {
|
|
|
|
|
SyncDataSetEntity syncDataSetEntity = syncDataSetDao.selectSet();
|
|
|
|
|
if (!syncDataSetEntity.isDownstreamEnable()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//查询数据同步设置
|
|
|
|
|
pushData(syncDataSetEntity);
|
|
|
|
|
pushOrder(syncDataSetEntity);
|
|
|
|
|
pullData(syncDataSetEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void pushData(SyncDataSetEntity syncDataSetEntity) {
|
|
|
|
|
|
|
|
|
|
//定时上传最近更新基础数据至上游轮询时间
|
|
|
|
|
long timeInterval1 = syncDataSetEntity.getSyncTime() * 6 * 1000L;
|
|
|
|
|
long curTime1 = System.currentTimeMillis();
|
|
|
|
@ -75,11 +78,8 @@ public class SyncHeartService {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void pushOrder() {
|
|
|
|
|
SyncDataSetEntity syncDataSetEntity = syncDataSetDao.selectSet();
|
|
|
|
|
if (!syncDataSetEntity.isDownstreamEnable()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
public void pushOrder(SyncDataSetEntity syncDataSetEntity) {
|
|
|
|
|
|
|
|
|
|
//定时上传最近更新单据数据至上游轮询时间
|
|
|
|
|
long timeInterval2 = syncDataSetEntity.getOrderSyncTime() * 6 * 1000L;
|
|
|
|
|
long curTime2 = System.currentTimeMillis();
|
|
|
|
@ -100,23 +100,43 @@ public class SyncHeartService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void pullData() {
|
|
|
|
|
try {
|
|
|
|
|
heartService.dlAllOrder();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
log.error(ExceptionUtils.getStackTrace(e));
|
|
|
|
|
public void pullData(SyncDataSetEntity syncDataSetEntity) {
|
|
|
|
|
|
|
|
|
|
if (syncDataSetEntity == null) {
|
|
|
|
|
syncDataSetEntity = syncDataSetDao.selectSet();
|
|
|
|
|
if (!syncDataSetEntity.isDownstreamEnable()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
heartService.dlAllDiProducts();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
log.error(ExceptionUtils.getStackTrace(e));
|
|
|
|
|
|
|
|
|
|
//定时下载上游最近更新数据轮询时间
|
|
|
|
|
long timeInterval = syncDataSetEntity.getSyncDownloadTime() * 6 * 100;
|
|
|
|
|
long curTime = System.currentTimeMillis();
|
|
|
|
|
Long lastTime = (Long) redisUtil.get("SPS_SYNC_DOWNLOAD_DATA");
|
|
|
|
|
if (lastTime == null) {
|
|
|
|
|
lastTime = System.currentTimeMillis();
|
|
|
|
|
redisUtil.set("SPS_SYNC_DOWNLOAD_DATA", lastTime);
|
|
|
|
|
}
|
|
|
|
|
Arrays.stream(BasicExportTypeEnum.values()).forEach(i -> {
|
|
|
|
|
heartService.pullData(i);
|
|
|
|
|
});
|
|
|
|
|
redisUtil.set("SPS_SYNC_DOWNLOAD_DATA", System.currentTimeMillis());
|
|
|
|
|
if (curTime - lastTime > timeInterval) {
|
|
|
|
|
try {
|
|
|
|
|
heartService.dlAllOrder();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
log.error(ExceptionUtils.getStackTrace(e));
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
heartService.dlAllDiProducts();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
log.error(ExceptionUtils.getStackTrace(e));
|
|
|
|
|
}
|
|
|
|
|
Arrays.stream(BasicExportTypeEnum.values()).forEach(i -> {
|
|
|
|
|
heartService.pullData(i);
|
|
|
|
|
});
|
|
|
|
|
redisUtil.set("SPS_SYNC_DOWNLOAD_DATA", System.currentTimeMillis());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|