| 
					
				 | 
			
			
				@@ -2,24 +2,26 @@ package thyyxxk.webserver.service.hutoolcache; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.hutool.cache.Cache; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.hutool.cache.CacheUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import lombok.RequiredArgsConstructor; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.dao.his.hutoolcache.HutoolCacheDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.entity.login.UserInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import thyyxxk.webserver.service.PublicServer; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import thyyxxk.webserver.utils.ListUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import thyyxxk.webserver.utils.TokenUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@RequiredArgsConstructor 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class UserCache implements HutoolCacheInterface<UserInfo> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private final HutoolCacheDao dao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private final DeptCache deptCache; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private static final int CACHE_SIZE = 512; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private final Cache<String, UserInfo> cache = CacheUtil.newLFUCache(CACHE_SIZE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public UserCache(HutoolCacheDao dao) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.dao = dao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void put(String key, UserInfo value) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -69,11 +71,39 @@ public class UserCache implements HutoolCacheInterface<UserInfo> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             dao.delNewUserToDjUserBase(userInfo.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             dao.insertNewUserToDjUserBase(userInfo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        userInfo.setDeptName(deptCache.getDeptName(userInfo.getDeptCode())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        userInfo.setHzDay(dao.getDeptHzDayByCode(userInfo.getDeptCode())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         userInfo.setRoles(dao.selectUserRoles(code)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         userInfo.setPartTimeDept(dao.selectUserPartTimeDept(userInfo.getCode())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Set<String> deptList = getDept(userInfo.getDeptCode(), userInfo.getPartTimeDept()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!deptList.isEmpty()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map<String, String> tempMap = new HashMap<>(deptList.size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            deptList.forEach(item -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (item != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    tempMap.put(item, deptCache.getDeptName(item)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            userInfo.setPartTimeDeptMap(tempMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return userInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private Set<String> getDept(String code, List<String> partTimeDept) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Set<String> list = new HashSet<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (ListUtil.notBlank(partTimeDept)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            list.addAll(partTimeDept); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        list.add(code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        QueryWrapper<?> qw = new QueryWrapper<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        qw.in("parent_code", list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<String> temp = dao.selectChildDeptByCodeList(qw); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (ListUtil.notBlank(temp)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            list.addAll(temp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public UserInfo getUserInfoByToken() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return get(TokenUtil.getInstance().getTokenUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 |