Compare commits
No commits in common. "7aa126dbe5e5e002540e9fc1c241e3e9c2c11314" and "3f0498eb9d95afd9c9a37f3c0c171b6f76584b28" have entirely different histories.
7aa126dbe5
...
3f0498eb9d
@ -5,7 +5,6 @@ import com.czlis.common.constant.CacheConstants;
|
||||
import com.czlis.common.core.domain.entity.lis.ComOpt;
|
||||
import com.czlis.common.core.redis.RedisCache;
|
||||
import com.czlis.common.utils.spring.SpringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -13,37 +12,33 @@ import java.util.List;
|
||||
public class ComOptionUtils {
|
||||
|
||||
/**
|
||||
* 设置参数缓存
|
||||
* 缓存格式:com_opt:HISOPT:SP_INTER com_opt:yq:xxdh
|
||||
* @param yq 仪器
|
||||
* @param xxdh 项目代码
|
||||
* @param comOpt 参数数据
|
||||
* 设置字典缓存
|
||||
*
|
||||
* @param key 参数键
|
||||
* @param optDatas 字典数据列表
|
||||
*/
|
||||
public static void setOptCache(String yq,String xxdh, ComOpt comOpt) {
|
||||
public static void setOptCache(String key, List<ComOpt> optDatas) {
|
||||
//先清除该key的所有缓存,然后再重新设置该key的缓存
|
||||
String key = yq+":"+xxdh;
|
||||
SpringUtils.getBean(RedisCache.class).deleteObject(key);
|
||||
SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(key), comOpt);
|
||||
SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(key), optDatas);
|
||||
}
|
||||
/**
|
||||
* 清空参数缓存
|
||||
* 清空字典缓存
|
||||
*/
|
||||
public static void clearOptCache() {
|
||||
Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(CacheConstants.COM_OPT_KEY + "*");
|
||||
Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys("com_opt:" + "*");
|
||||
SpringUtils.getBean(RedisCache.class).deleteObject(keys);
|
||||
}
|
||||
/**
|
||||
* 获取参数缓存
|
||||
* 根据现在的参数,获取到的数据应该只有一条
|
||||
* @param yq 仪器
|
||||
* @param xxdh 项目代码
|
||||
* @return ComOpt 参数数据
|
||||
* 获取字典缓存
|
||||
*
|
||||
* @param key 参数键
|
||||
* @return dictDatas 字典数据列表
|
||||
*/
|
||||
public static ComOpt getOptCache(String yq,String xxdh) {
|
||||
String key = yq+":"+xxdh;
|
||||
Object cacheObject = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
|
||||
if (StringUtils.isNotNull(cacheObject)) {
|
||||
return (ComOpt) cacheObject;
|
||||
public static List<ComOpt> getOptCache(String key) {
|
||||
JSONArray arrayCache = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
|
||||
if (StringUtils.isNotNull(arrayCache)) {
|
||||
return arrayCache.toList(ComOpt.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -129,17 +129,14 @@ public class CommonUtil {
|
||||
return comDictMapper.getComDictIdByName(zdlb,zdmc);
|
||||
}
|
||||
public String getComOptValue(String yq,String xxdh){
|
||||
ComOpt comOpt =getOptCache(yq,xxdh);
|
||||
if(comOpt != null) {
|
||||
//获取到缓存,直接返回缓存中的数据
|
||||
return comOpt.getXxqz();
|
||||
}else{
|
||||
//没有获取到缓存,则先从数据库中查询数据,然后再进行缓存
|
||||
ComOpt comOpt1 = comOptMapper.getComOptOne(yq, xxdh);
|
||||
ComOptionUtils.setOptCache(yq,xxdh,comOpt1);
|
||||
return comOpt1.getXxqz();
|
||||
List<ComOpt> comOptList =getOptCache(yq);
|
||||
if(comOptList!=null){
|
||||
for (ComOpt opt : comOptList) {
|
||||
if (xxdh.equals(opt.getXxdh())) {
|
||||
return opt.getXxqz();
|
||||
}
|
||||
|
||||
}}
|
||||
return comOptMapper.getComOptValue(yq,xxdh);
|
||||
}
|
||||
|
||||
public List<LabReqdetail> getLabReqdetailList(String sqh){
|
||||
@ -149,9 +146,8 @@ public class CommonUtil {
|
||||
private List<ComDict> getDictCache(String zdlb) {
|
||||
return ComDictUtils.getDictCache(zdlb);
|
||||
}
|
||||
|
||||
private ComOpt getOptCache(String yq,String xxdh) {
|
||||
return ComOptionUtils.getOptCache(yq,xxdh);
|
||||
private List<ComOpt> getOptCache(String yq) {
|
||||
return ComOptionUtils.getOptCache(yq);
|
||||
}
|
||||
|
||||
public Boolean getUserPower(String yq,String yhdh,int powerIdx){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user