| 
					
				 | 
			
			
				@ -3,33 +3,27 @@ package com.yihu.jw.basic.resource.dao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.fasterxml.jackson.databind.ObjectMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.basic.redis.schema.AdapterMetaDataKeySchema; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.basic.standard.service.redis.StdRedisService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.basic.resource.service.RedisService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.basic.resource.service.RsResourceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.ehr.redis.schema.StdDataSetKeySchema; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.ehr.resource.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.exception.ApiException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.mysql.model.QueryCondition; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.mysql.sqlparser.ParserFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.mysql.sqlparser.ParserSql; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.profile.ProfileType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.profile.core.ResourceCore; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.profile.family.ResourceCells; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.basic.resource.service.RedisService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.basic.resource.service.RsResourceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.Envelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.ehr.resource.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.ListEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.PageEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.collections.CollectionUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.data.domain.Page; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.data.domain.PageImpl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.data.domain.PageRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.BeanPropertyRowMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.JdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Repository; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.io.IOException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -644,7 +638,7 @@ public class ResourceBrowseDao { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Page<Map<String, Object>> getMysqlDataAndCondition(String sql,String queryParam,String sortParam,Integer page, Integer size) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Page<Map<String, Object>> getMysqlDataAndCondition(String sql,String queryParam,String sortParam,Integer page, Integer size,List<String> resourcesCodes) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sortOrder = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sortOrderSql = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNoneBlank(sortParam)){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -688,12 +682,42 @@ public class ResourceBrowseDao { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //字典翻译 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<DtoResourceMetadata> resourceMetadataList = resourceBrowseMetadataDao.getResourceMetadataHasDict(resourcesCodes.get(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(resourceMetadataList.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,String> fieldDictMap = resourceMetadataList.stream().collect(Collectors.toMap(DtoResourceMetadata::getEhrId,DtoResourceMetadata::getDictCode)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Map<String,String>> dictMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String dictSql = "select * from rs_dictionary_entry where DICT_CODE = ?"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (DtoResourceMetadata metadata:resourceMetadataList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String dictCode = metadata.getDictCode(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if(!dictMap.containsKey(dictCode)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        List<RsDictionaryEntry> dictionaryEntries = jdbcTemplate.query(dictSql,new Object[]{dictCode},new BeanPropertyRowMapper<>(RsDictionaryEntry.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        Map<String,String> tmpMap = dictionaryEntries.stream().collect(Collectors.toMap(RsDictionaryEntry::getCode,RsDictionaryEntry::getName)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        dictMap.put(dictCode,tmpMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (Map<String, Object> map:list){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    for (Map.Entry<String, String> entry : fieldDictMap.entrySet()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String key = entry.getKey(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String value = entry.getValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if(map.get(key)!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            String dictValue =  dictMap.get(value).get(map.get(key)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            map.put(key,dictValue); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return new PageImpl<>(list, PageRequest.of(page - 1, size), count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取Mysql配置库数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * getMysqlData" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param resourcesCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param page 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param size 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -744,6 +768,35 @@ public class ResourceBrowseDao { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(list.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //字典翻译 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<DtoResourceMetadata> resourceMetadataList = resourceBrowseMetadataDao.getResourceMetadataHasDict(resourcesCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(resourceMetadataList.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,String> fieldDictMap = resourceMetadataList.stream().collect(Collectors.toMap(DtoResourceMetadata::getStdCode,DtoResourceMetadata::getDictCode)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Map<String,Map<String,String>> dictMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String dictSql = "select * from rs_dictionary_entry where DICT_CODE = ?"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (DtoResourceMetadata metadata:resourceMetadataList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String dictCode = metadata.getDictCode(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if(!dictMap.containsKey(dictCode)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        List<RsDictionaryEntry> dictionaryEntries = jdbcTemplate.query(dictSql,new Object[]{dictCode},new BeanPropertyRowMapper<>(RsDictionaryEntry.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        Map<String,String> tmpMap = dictionaryEntries.stream().collect(Collectors.toMap(RsDictionaryEntry::getCode,RsDictionaryEntry::getName)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        dictMap.put(dictCode,tmpMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (Map<String, Object> map:list){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    for (Map.Entry<String, String> entry : fieldDictMap.entrySet()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String key = entry.getKey(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String value = entry.getValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if(map.get(key)!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            String dictValue =  dictMap.get(value).get(map.get(key)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            map.put(key,dictValue); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return new PageImpl<>(list, PageRequest.of(page - 1, size), count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 |