123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- package com.diagbot.facade;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.diagbot.client.PushNewServiceClient;
- import com.diagbot.dto.DictionaryInfoDTO;
- import com.diagbot.dto.PushReloadDTO;
- import com.diagbot.entity.SysDeptPush;
- import com.diagbot.entity.TranHospitalInfo;
- import com.diagbot.enums.IsDeleteEnum;
- import com.diagbot.enums.RedisEnum;
- import com.diagbot.enums.StandConvertEnum;
- import com.diagbot.util.EntityUtil;
- import com.diagbot.util.ListUtil;
- import com.diagbot.util.RedisUtil;
- import com.diagbot.util.StringUtil;
- import org.apache.commons.collections4.map.LinkedMap;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.cache.annotation.CacheEvict;
- import org.springframework.stereotype.Component;
- import java.util.List;
- import java.util.Map;
- import java.util.stream.Collectors;
- /**
- * @Description:
- * @Author:zhoutg
- * @time: 2018/11/23 11:37
- */
- @Component
- public class CacheFacade {
- @Autowired
- RedisUtil redisUtil;
- @Autowired
- NeoFacade neoFacade;
- @Autowired
- private KlDiagnoseBaseFacade klDiagnoseBaseFacade;
- @Autowired
- KlDictionaryInfoFacade klDictionaryInfoFacade;
- @Autowired
- TranHospitalInfoFacade tranHospitalInfoFacade;
- @Autowired
- PushNewServiceClient pushNewServiceClient;
- @Autowired
- DeptPushFacade deptPushFacade;
- /**
- * 清除缓存信息
- *
- * @return
- */
- @CacheEvict(value = "cache", allEntries = true)
- public void clear() {
- }
- /**
- * 清除标准词转换缓存信息
- *
- * @return
- */
- public void clearStandConvert() {
- redisUtil.deleteByPrex(StandConvertEnum.disease.getName());
- redisUtil.deleteByPrex(StandConvertEnum.drug.getName());
- redisUtil.deleteByPrex(StandConvertEnum.lis.getName());
- redisUtil.deleteByPrex(StandConvertEnum.operation.getName());
- redisUtil.deleteByPrex(StandConvertEnum.pacs.getName());
- redisUtil.deleteByPrex(StandConvertEnum.symptom.getName());
- redisUtil.deleteByPrex(StandConvertEnum.vital.getName());
- redisUtil.deleteByPrex(StandConvertEnum.transfusion.getName());
- }
- /**
- * 加载药品类型缓存
- *
- * @return
- */
- public void loadDrugTypeCache() {
- redisUtil.deleteByPrex(RedisEnum.drugType.getName());
- neoFacade.getDrugCache();
- }
- /**
- * 加载数据库中症状特征缓存
- *
- * @return
- */
- public void getSymptomFeatureCache() {
- redisUtil.deleteByPrex(RedisEnum.symptomFeature.getName());
- neoFacade.symptomFeatureCache();
- }
- /**
- * 加载数据库中疾病对应缓存
- *
- * @return
- */
- public void getDiseaseCorrespondCache() {
- redisUtil.deleteByPrex(RedisEnum.diseaseCorrespond.getName());
- neoFacade.diseaseCorrespondCache();
- }
- /**
- * 加载数据库中疾病过滤缓存
- *
- * @return
- */
- public void getdiseaseFilterCache() {
- redisUtil.deleteByPrex(RedisEnum.diseaseFilter.getName());
- neoFacade.diseaseFilterCache();
- }
- /**
- * 缓存医学知识库中的所有规则
- *
- * @return
- */
- public void loadAllRuleCache(){
- redisUtil.deleteByPrex(RedisEnum.allRule.getName());
- redisUtil.delete(RedisEnum.drugAllergen.getName());
- neoFacade.allRuleCache();
- }
- /**
- * 缓存VTE医嘱数据
- *
- * @return
- */
- public void loadVteAdviceCache(){
- redisUtil.deleteByPrex(RedisEnum.vteAdvice.getName());
- // 加载
- List<DictionaryInfoDTO> dictionaryInfoDTOList = klDictionaryInfoFacade.getListByGroupType(100);
- if (ListUtil.isNotEmpty(dictionaryInfoDTOList)) {
- // 提示语
- Map<String, List<DictionaryInfoDTO>> map = EntityUtil.makeEntityListMap(dictionaryInfoDTOList, "name");
- for (String key : map.keySet()) {
- redisUtil.set(RedisEnum.vteAdvice.getName() + key, map.get(key).stream().map(r -> r.getVal())
- .filter(r -> StringUtil.isNotBlank(r)).distinct().collect(Collectors.toList()));
- }
- }
- }
- /**
- * 重新加载大数据缓存
- *
- * @return
- */
- public Boolean reloadPushDB(){
- PushReloadDTO pushReloadDTO = pushNewServiceClient.reloadPushDB();
- return pushReloadDTO != null && pushReloadDTO.getStatus().equals(0);
- }
- /**
- * 缓存医学知识库中的所有去重的基础诊断依据
- *
- * @return
- */
- public void loadAllBaseDiagnoseCache(){
- redisUtil.delete(RedisEnum.allBaseDiagnose.getName());
- neoFacade.allBaseDiagnose();
- }
- /**
- * 缓存医学知识库中的所有去重的基础规则
- *
- * @return
- */
- public void loadAllBaseRegulationCache(){
- redisUtil.delete(RedisEnum.allBaseRegulation.getName());
- neoFacade.allBaseRegulation();
- }
- public void clearLoadCache(String str) {
- redisUtil.deleteByPrex(str);
- }
- /**
- * 加载大数据推送类型
- */
- public void loadPushModel() {
- redisUtil.delete("pushVersion"); // 删除脏数据
- redisUtil.delete(RedisEnum.pushModel.getName());
- // 加载
- List<TranHospitalInfo> hospitalList = tranHospitalInfoFacade.list(new QueryWrapper<TranHospitalInfo>()
- .eq("is_deleted", IsDeleteEnum.N.getKey())
- );
- if (ListUtil.isNotEmpty(hospitalList)) {
- // 推送版本
- Map<String, Object> versionMap = new LinkedMap<>();
- for (TranHospitalInfo hospitalInfo : hospitalList) {
- if (hospitalInfo.getPushMode() != null) {
- versionMap.put(RedisEnum.hospitalId_.getName() + hospitalInfo.getId(), hospitalInfo.getPushMode());
- } else {
- versionMap.put(RedisEnum.hospitalId_.getName() + hospitalInfo.getId(), 0);
- }
- }
- redisUtil.putHashMap(RedisEnum.pushModel.getName(), versionMap);
- }
- }
- /**
- * 加载标准科室和推送类型的映射关系【sys_dept_push】
- */
- public void loadDeptPush() {
- // 删除
- redisUtil.delete(RedisEnum.deptPush.getName());
- // 加载
- List<SysDeptPush> deptPushList = deptPushFacade.list(new QueryWrapper<SysDeptPush>()
- .eq("is_deleted", IsDeleteEnum.N.getKey())
- );
- if (ListUtil.isNotEmpty(deptPushList)) {
- // 推送类型
- redisUtil.putHashMap(RedisEnum.deptPush.getName(),
- deptPushList.stream().collect(Collectors.toMap(k -> k.getDeptName(), v -> v.getPush(), (v1, v2) -> (v2))));
- }
- }
- /**
- * 加载开单频次
- */
- public void loadFrequency() {
- // 删除
- redisUtil.delete(RedisEnum.frequency.getName());
- // 加载
- List<DictionaryInfoDTO> dictionaryInfoDTOList = klDictionaryInfoFacade.getListByGroupType(40);
- redisUtil.set(RedisEnum.frequency.getName(), dictionaryInfoDTOList);
- }
- /**
- * 加载提示语
- */
- public void loadMsg() {
- // 开单提示语
- redisUtil.delete(RedisEnum.msg.getName());
- List<DictionaryInfoDTO> dictionaryInfoDTOList = klDictionaryInfoFacade.getListByGroupType(41);
- if (ListUtil.isNotEmpty(dictionaryInfoDTOList)) {
- // 提示语
- Map<String, Object> msgMap = new LinkedMap<>();
- for (DictionaryInfoDTO dic : dictionaryInfoDTOList) {
- msgMap.put(dic.getName(), dic.getVal());
- }
- redisUtil.putHashMap(RedisEnum.msg.getName(), msgMap);
- }
- // 其他值提醒化验提示语
- redisUtil.delete(RedisEnum.otherMsg.getName());
- List<DictionaryInfoDTO> otherLisList = klDictionaryInfoFacade.getListByGroupType(42);
- if (ListUtil.isNotEmpty(otherLisList)) {
- // 提示语
- Map<String, Object> msgMap = new LinkedMap<>();
- for (DictionaryInfoDTO dic : otherLisList) {
- msgMap.put(dic.getName(), dic.getVal());
- }
- redisUtil.putHashMap(RedisEnum.otherMsg.getName(), msgMap);
- }
- }
- }
|