@GetMapping("/task/import")
@ApiOperation(value = "导入校验成功的文件", notes = "入参为taskId, 异步导入", httpMethod = "GET")
public R<UploadTask> importFile(Long taskId) {
R<UploadTask> result = new R<>();
if (taskId == null) {
result.setCode(ResultCode.FAIL_REQUEST.getCode());
result.setMsg("taskId不能为空");
return result;
}
boolean stateUpdated = uploadTaskService.stateSpecialFlow(taskId, UploadTaskState.IMPORTING);
if (!stateUpdated) {
result.setMsg("状态不允许导入");
result.setCode(ResultCode.FAIL_REQUEST.getCode());
return result;
}
Thread thread = new Thread(() -> {
//异步执行业务
});
thread.start();
result.setMsg("请求已受理");
result.setCode(ResultCode.SUCCESS_REQUEST.getCode());
return result;
}
Java线程异步执行
最新推荐文章于 2024-07-14 21:35:28 发布