|  | @ -2,7 +2,6 @@ package com.yihu.ehr.standard.service.standard;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.fasterxml.jackson.databind.JsonNode;
 | 
	
		
			
				|  |  | import com.fasterxml.jackson.databind.ObjectMapper;
 | 
	
		
			
				|  |  | import com.yihu.ehr.common.ReflectUtil;
 | 
	
		
			
				|  |  | import com.yihu.ehr.framework.common.dao.SQLGeneralDAO;
 | 
	
		
			
				|  |  | import com.yihu.ehr.framework.constrant.Constants;
 | 
	
		
			
				|  |  | import com.yihu.ehr.framework.constrant.ErrorCode;
 | 
	
	
		
			
				|  | @ -16,20 +15,21 @@ import com.yihu.ehr.framework.util.sql.RequestParamTransformer;
 | 
	
		
			
				|  |  | import com.yihu.ehr.framework.util.sql.SqlCreator;
 | 
	
		
			
				|  |  | import com.yihu.ehr.standard.model.Select2;
 | 
	
		
			
				|  |  | import com.yihu.ehr.standard.model.adapter.AdapterMetadataModel;
 | 
	
		
			
				|  |  | import com.yihu.ehr.standard.model.standard.StandardVersionModel;
 | 
	
		
			
				|  |  | import com.yihu.ehr.standard.model.standard.StdDataSetModel;
 | 
	
		
			
				|  |  | import com.yihu.ehr.standard.model.standard.StdDictionaryEntryModel;
 | 
	
		
			
				|  |  | import com.yihu.ehr.standard.model.standard.StdMetaDataModel;
 | 
	
		
			
				|  |  | import com.yihu.ehr.standard.model.standard.*;
 | 
	
		
			
				|  |  | import com.yihu.ehr.standard.model.standard.resultModel.StandardParamResultModel;
 | 
	
		
			
				|  |  | import com.yihu.ehr.standard.service.bo.StandardVersion;
 | 
	
		
			
				|  |  | import org.hibernate.Criteria;
 | 
	
		
			
				|  |  | import org.hibernate.Query;
 | 
	
		
			
				|  |  | import org.hibernate.SQLQuery;
 | 
	
		
			
				|  |  | import org.hibernate.Session;
 | 
	
		
			
				|  |  | import org.hibernate.criterion.Restrictions;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import java.io.IOException;
 | 
	
		
			
				|  |  | import java.lang.reflect.Field;
 | 
	
		
			
				|  |  | import java.util.*;
 | 
	
		
			
				|  |  | import java.util.stream.Collectors;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * 数据元管理接口实现。
 | 
	
	
		
			
				|  | @ -43,6 +43,8 @@ import java.util.*;
 | 
	
		
			
				|  |  | public class StdMetadataService extends SQLGeneralDAO {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public static final String BEAN_ID = "StdMetadataService";
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     StandardService standardService;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public StdMetadataService() {
 | 
	
		
			
				|  |  |     }
 | 
	
	
		
			
				|  | @ -323,8 +325,9 @@ public class StdMetadataService extends SQLGeneralDAO {
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public List getAllVersionMetadataList(String condition) {
 | 
	
		
			
				|  |  |         //数据元列表应该是所选择的数据集列表的数据元并集去重 @modify by yingjie chen
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             Map<Integer, String> versionMap = new HashMap<>();
 | 
	
		
			
				|  |  |             List<String>  versionList = new ArrayList<>();
 | 
	
		
			
				|  |  |             String sql = Constants.EMPTY;
 | 
	
		
			
				|  |  |             ObjectMapper objectMapper = new ObjectMapper();
 | 
	
		
			
				|  |  |             String code = Constants.EMPTY;
 | 
	
	
		
			
				|  | @ -333,17 +336,26 @@ public class StdMetadataService extends SQLGeneralDAO {
 | 
	
		
			
				|  |  |                 code = jsonNode.get("code").asText();
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String hql = "FROM StandardVersionModel WHERE publishTime is not null order by publishTime";
 | 
	
		
			
				|  |  |             Query query = getCurrentSession().createQuery(hql);
 | 
	
		
			
				|  |  |             List<StandardVersionModel> versionModelList = query.list();
 | 
	
		
			
				|  |  |             for (StandardVersionModel versionModel : versionModelList) {
 | 
	
		
			
				|  |  |                 SqlCreator sqlDatasetCreator = new SqlCreator(StdDataSetModel.class);
 | 
	
		
			
				|  |  |                 StandardVersion version = new StandardVersion(versionModel.getVersion());
 | 
	
		
			
				|  |  |                 versionMap.put(versionModel.getStandardId(), versionModel.getVersion());
 | 
	
		
			
				|  |  |                 sqlDatasetCreator.equalCondition("code", code);
 | 
	
		
			
				|  |  |                 sql = sql + sqlDatasetCreator.selectData(version.getDataSetTableName()) + Constants.UNION;
 | 
	
		
			
				|  |  |             Criteria criteria = getCurrentSession().createCriteria(StandardModel.class);
 | 
	
		
			
				|  |  |             StandardParamResultModel standardParam = standardService.getStandardParam(Constants.STANDARD);
 | 
	
		
			
				|  |  |             String VersionCode = standardParam.getCode();
 | 
	
		
			
				|  |  |             criteria.add(Restrictions.eq("code", VersionCode));
 | 
	
		
			
				|  |  |             List<StandardModel> standardModelList = criteria.list();
 | 
	
		
			
				|  |  |             List<Integer> idList = standardModelList.stream().map(StandardModel::getId).collect(Collectors.toList());
 | 
	
		
			
				|  |  |             List<StandardVersionModel> versionModelList;
 | 
	
		
			
				|  |  |             if (!CollectionUtil.isEmpty(idList)) {
 | 
	
		
			
				|  |  |                 String hql = "FROM StandardVersionModel WHERE publishTime is not null AND standardId IN :idList order by publishTime";
 | 
	
		
			
				|  |  |                 Query query = getCurrentSession().createQuery(hql);
 | 
	
		
			
				|  |  |                 query.setParameterList("idList", idList);
 | 
	
		
			
				|  |  |                 versionModelList = query.list();
 | 
	
		
			
				|  |  |                 for (StandardVersionModel versionModel : versionModelList) {
 | 
	
		
			
				|  |  |                     SqlCreator sqlDatasetCreator = new SqlCreator(StdDataSetModel.class);
 | 
	
		
			
				|  |  |                     StandardVersion version = new StandardVersion(versionModel.getVersion());
 | 
	
		
			
				|  |  |                     versionList.add(versionModel.getVersion());
 | 
	
		
			
				|  |  |                     sqlDatasetCreator.equalCondition("code", code);
 | 
	
		
			
				|  |  |                     sql = sql + sqlDatasetCreator.selectData(version.getDataSetTableName()) + Constants.UNION;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             BeanTransformer datasetTransformer = new BeanTransformer(StdDataSetModel.class);
 | 
	
		
			
				|  |  |             if (!StringUtil.isEmpty(sql)) {
 | 
	
		
			
				|  |  |                 sql = sql.substring(0, sql.length() - Constants.UNION.length());
 | 
	
	
		
			
				|  | @ -354,12 +366,15 @@ public class StdMetadataService extends SQLGeneralDAO {
 | 
	
		
			
				|  |  |                 sql = Constants.EMPTY;
 | 
	
		
			
				|  |  |                 Integer count = 1;
 | 
	
		
			
				|  |  |                 Map<Integer, String> datasetIdMap = new HashMap<>();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 for (StdDataSetModel model : modelList) {
 | 
	
		
			
				|  |  |                     SqlCreator sqlMetadataCreator = new SqlCreator(StdMetaDataModel.class);
 | 
	
		
			
				|  |  |                     StandardVersion version = new StandardVersion(versionMap.get(model.getstandardId()));
 | 
	
		
			
				|  |  |                     datasetIdMap.put(count++, StringUtil.toString(model.getId()));
 | 
	
		
			
				|  |  |                     sqlMetadataCreator.equalConditionQue("datasetId", model.getId());
 | 
	
		
			
				|  |  |                     sql = sql + sqlMetadataCreator.selectData(version.getMetaDataTableName()) + Constants.UNION;
 | 
	
		
			
				|  |  |                     for (String versionKey : versionList) {
 | 
	
		
			
				|  |  |                         datasetIdMap.put(count++, StringUtil.toString(model.getId()));
 | 
	
		
			
				|  |  |                         StandardVersion version = new StandardVersion(versionKey);
 | 
	
		
			
				|  |  |                         sql = sql + sqlMetadataCreator.selectSingleData(version.getMetaDataTableName()) + Constants.UNION;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 BeanTransformer metadataTransformer = new BeanTransformer(StdMetaDataModel.class);
 |