|
@@ -42,6 +42,8 @@ import com.xunmei.system.service.ISysOrgService;
|
|
|
import com.xunmei.system.util.*;
|
|
import com.xunmei.system.util.*;
|
|
|
import io.netty.util.internal.StringUtil;
|
|
import io.netty.util.internal.StringUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.redisson.api.RLock;
|
|
|
|
|
+import org.redisson.api.RedissonClient;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -53,6 +55,7 @@ import java.io.IOException;
|
|
|
import java.net.URLEncoder;
|
|
import java.net.URLEncoder;
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
@@ -786,11 +789,34 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<SysOrgVO> loadingOrgCache() {
|
|
public List<SysOrgVO> loadingOrgCache() {
|
|
|
- List<SysOrgVO> sysOrgVOS = baseMapper.selectSysOrgVOList();
|
|
|
|
|
- List<SysOrgVO> hsOrgs = sysOrgVOS.stream().filter(x -> ObjectUtil.equal(x.getType(), 3)).collect(Collectors.toList());
|
|
|
|
|
- clearOrgCache();
|
|
|
|
|
- RedisUtils.setCacheList(CacheConstants.ORG_CACHE_LIST_KEY, sysOrgVOS);
|
|
|
|
|
- RedisUtils.setCacheList(CacheConstants.HS_ORG_CACHE_LIST_KEY, hsOrgs);
|
|
|
|
|
|
|
+ RLock rLock=null;
|
|
|
|
|
+ boolean lockflag=false;
|
|
|
|
|
+ List<SysOrgVO> sysOrgVOS =new ArrayList<>();
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ sysOrgVOS = baseMapper.selectSysOrgVOList();
|
|
|
|
|
+ List<SysOrgVO> hsOrgs = sysOrgVOS.stream().filter(x -> ObjectUtil.equal(x.getType(), 3)).collect(Collectors.toList());
|
|
|
|
|
+ RedissonClient redissonClient = RedisUtils.getClient();
|
|
|
|
|
+ rLock= redissonClient.getLock("loadingOrgCache");
|
|
|
|
|
+ lockflag= rLock.tryLock(200L,5000L, TimeUnit.MILLISECONDS);
|
|
|
|
|
+ if(lockflag)
|
|
|
|
|
+ {
|
|
|
|
|
+ clearOrgCache();
|
|
|
|
|
+ RedisUtils.setCacheList(CacheConstants.ORG_CACHE_LIST_KEY, sysOrgVOS);
|
|
|
|
|
+ RedisUtils.setCacheList(CacheConstants.HS_ORG_CACHE_LIST_KEY, hsOrgs);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception e)
|
|
|
|
|
+ {
|
|
|
|
|
+ log.error(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ finally {
|
|
|
|
|
+
|
|
|
|
|
+ if(lockflag&& rLock.isHeldByCurrentThread())
|
|
|
|
|
+ {
|
|
|
|
|
+ rLock.unlock();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
return sysOrgVOS;
|
|
return sysOrgVOS;
|
|
|
}
|
|
}
|
|
|
|
|
|