Commit 1d332f44 authored by yajun.zhang's avatar yajun.zhang

防止重复下载

parent 5449a841
...@@ -29,6 +29,7 @@ import java.util.Map; ...@@ -29,6 +29,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.Query; import javax.persistence.Query;
...@@ -39,6 +40,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -39,6 +40,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.InputStreamResource; import org.springframework.core.io.InputStreamResource;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
...@@ -66,6 +68,9 @@ public class ThirdWorkOrderServiceImpl implements IThirdWorkOrderService { ...@@ -66,6 +68,9 @@ public class ThirdWorkOrderServiceImpl implements IThirdWorkOrderService {
@Value("${customer.transaction.mail.from}") @Value("${customer.transaction.mail.from}")
private String from; private String from;
@Autowired
private RedisTemplate<String, Object> redisTemplate;
ExecutorService executorService = Executors.newFixedThreadPool(2); ExecutorService executorService = Executors.newFixedThreadPool(2);
private static int pageSize = 500; private static int pageSize = 500;
...@@ -216,6 +221,12 @@ public class ThirdWorkOrderServiceImpl implements IThirdWorkOrderService { ...@@ -216,6 +221,12 @@ public class ThirdWorkOrderServiceImpl implements IThirdWorkOrderService {
if (StringUtils.isBlank(account)){ if (StringUtils.isBlank(account)){
return JsonResult.buildErrorStateResult("账号名为空"); return JsonResult.buildErrorStateResult("账号名为空");
} }
String key = "export_"+account ;
String value = (String)redisTemplate.opsForValue().get(key);
if (StringUtils.isNotBlank(value)){
return JsonResult.buildErrorStateResult("系统导出处理中,请勿重复下载");
}
redisTemplate.opsForValue().set(key,"lock",1, TimeUnit.MINUTES);
executorService.execute(()->{ executorService.execute(()->{
doExportBusiness(param,account,tenantId); doExportBusiness(param,account,tenantId);
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment