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