2、新增:新增医共体子医院的患者信息缓存,减少对数据库的请求。并在清除缓存接口加入清除子医院本地缓存。 3、调整:智能导诊新增2个参数返回,医生简介为空时默认返回暂无简介。 4、修复:同步数据时部分数据为空时会报错的问题修复加入默认值。debug
parent
e8631a70a6
commit
1147b5fe9b
17 changed files with 235 additions and 59 deletions
@ -0,0 +1,71 @@ |
||||
package com.ynxbd.common.cache; |
||||
|
||||
import com.ynxbd.common.bean.Patient; |
||||
import com.ynxbd.common.bean.User; |
||||
import com.ynxbd.common.config.EhCacheConfig; |
||||
import com.ynxbd.common.helper.common.JsonHelper; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.ehcache.Cache; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
|
||||
@Slf4j |
||||
public class GmcCacheManager { |
||||
// 医共体缓存数据
|
||||
private static Cache<String, User> GMC_USER_CACHE; |
||||
|
||||
static { |
||||
createGmcUserCacheManager(); |
||||
} |
||||
|
||||
private synchronized static void createGmcUserCacheManager() { |
||||
if (GMC_USER_CACHE == null) { |
||||
GMC_USER_CACHE = EhCacheConfig.createCacheTTL(String.class, User.class, "db_gmc_cache", (900L)); // 15分钟
|
||||
} |
||||
} |
||||
|
||||
public static Cache<String, User> getGmcUserCacheManager() { |
||||
if (GMC_USER_CACHE == null) { |
||||
createGmcUserCacheManager(); |
||||
} |
||||
return GMC_USER_CACHE; |
||||
} |
||||
|
||||
public static void addCacheGmcUser(String openid, User user) { |
||||
Cache<String, User> cache = getGmcUserCacheManager(); |
||||
if (cache != null) { |
||||
cache.put(openid, user); |
||||
} |
||||
} |
||||
|
||||
public static void removeCacheGmcUser(String openid) { |
||||
Cache<String, User> cache = getGmcUserCacheManager(); |
||||
if (cache != null) { |
||||
cache.remove(openid); |
||||
} |
||||
} |
||||
|
||||
public static boolean hasCacheGmcUser(String openid) { |
||||
if (GMC_USER_CACHE == null) { |
||||
createGmcUserCacheManager(); |
||||
} |
||||
return GMC_USER_CACHE.containsKey(openid); |
||||
} |
||||
|
||||
public static List<Patient> getCacheGmcUserPatientList(String openid) { |
||||
if (GMC_USER_CACHE == null) { |
||||
createGmcUserCacheManager(); |
||||
} |
||||
User user = GMC_USER_CACHE.get(openid); |
||||
if (user == null) { |
||||
return new ArrayList<>(); |
||||
} |
||||
List<Patient> patientList = user.getPatientList(); |
||||
if (patientList == null || patientList.isEmpty()) { |
||||
return new ArrayList<>(); |
||||
} |
||||
return JsonHelper.copyArray(patientList, Patient.class); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue