异步同步

master
wj 2 years ago
parent 42d931d688
commit f170787fc5

@ -26,9 +26,11 @@ import com.glxp.api.service.sync.BasicExportService;
import com.glxp.api.service.sync.BasicExportTimeService; import com.glxp.api.service.sync.BasicExportTimeService;
import com.glxp.api.service.sync.SpsSyncDownloadService; import com.glxp.api.service.sync.SpsSyncDownloadService;
import com.glxp.api.service.sync.SyncDataSetService; import com.glxp.api.service.sync.SyncDataSetService;
import com.glxp.api.task.TaskExecutorConfig;
import com.glxp.api.util.CustomUtil; import com.glxp.api.util.CustomUtil;
import com.glxp.api.util.RedisUtil; import com.glxp.api.util.RedisUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -42,6 +44,7 @@ import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture;
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@ -238,6 +241,7 @@ public class SpsSyncExportStatusController {
private final SpsSyncDownloadService spsSyncDownloadService; private final SpsSyncDownloadService spsSyncDownloadService;
private final SyncDataSetService syncDataSetService; private final SyncDataSetService syncDataSetService;
private final ThreadPoolTaskExecutor executorConfig;
/** /**
* *
@ -257,16 +261,18 @@ public class SpsSyncExportStatusController {
if (syncDataSetEntity.getSyncTime() == null) { if (syncDataSetEntity.getSyncTime() == null) {
return ResultVOUtils.error(ResultEnum.NOT_NETWORK.getCode(), "缺少初始化数据"); return ResultVOUtils.error(ResultEnum.NOT_NETWORK.getCode(), "缺少初始化数据");
} }
switch (req.getExportType()) { CompletableFuture future = CompletableFuture.runAsync(() -> {
case IO_ORDER: switch (req.getExportType()) {
spsSyncDownloadService.syncOrderTask(); case IO_ORDER:
break; spsSyncDownloadService.syncOrderTask();
case COUNTRY_DI_DATA: break;
spsSyncDownloadService.syncDiProductsTask(); case COUNTRY_DI_DATA:
break; spsSyncDownloadService.syncDiProductsTask();
default: break;
spsSyncDownloadService.syncData(syncDataSetEntity, req.getExportType(), req.getSyncTime()); default:
} spsSyncDownloadService.syncData(syncDataSetEntity, req.getExportType(), req.getSyncTime());
}
}, executorConfig);
return ResultVOUtils.success(); return ResultVOUtils.success();
} }

Loading…
Cancel
Save