|
@ -3,10 +3,15 @@ package com.yihu.jw.basic.resource.service;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.JavaType;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.jw.basic.resource.dao.ResourceBrowseDao;
|
|
|
import com.yihu.jw.basic.resource.dao.ResourceBrowseMetadataDao;
|
|
|
import com.yihu.jw.basic.resource.dao.RsResourceDao;
|
|
|
import com.yihu.jw.basic.resource.dao.RsResourceDefaultParamDao;
|
|
|
import com.yihu.jw.constants.ErrorCode;
|
|
|
import com.yihu.jw.basic.resource.dao.ResourceBrowseDao;
|
|
|
import com.yihu.jw.entity.ehr.resource.DtoResourceMetadata;
|
|
|
import com.yihu.jw.entity.ehr.resource.RsResource;
|
|
|
import com.yihu.jw.entity.ehr.resource.RsResourceDefaultParam;
|
|
|
import com.yihu.jw.entity.ehr.resource.RsResourceMetadata;
|
|
|
import com.yihu.jw.exception.ApiException;
|
|
|
import com.yihu.jw.mysql.enums.Operation;
|
|
|
import com.yihu.jw.mysql.model.QueryCondition;
|
|
@ -14,10 +19,6 @@ import com.yihu.jw.mysql.query.BaseJpaService;
|
|
|
import com.yihu.jw.profile.ProfileType;
|
|
|
import com.yihu.jw.profile.family.ResourceCells;
|
|
|
import com.yihu.jw.restmodel.ehr.resource.MRsColumnsModel;
|
|
|
import com.yihu.jw.basic.resource.dao.ResourceBrowseMetadataDao;
|
|
|
import com.yihu.jw.basic.resource.dao.RsResourceDao;
|
|
|
import com.yihu.jw.entity.ehr.resource.DtoResourceMetadata;
|
|
|
import com.yihu.jw.entity.ehr.resource.RsResource;
|
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
@ -499,31 +500,64 @@ public class ResourceBrowseService extends BaseJpaService {
|
|
|
//获取资源编码列表
|
|
|
List<String> codeList = (List<String>) objectMapper.readValue(resourcesCodes, List.class);
|
|
|
String tableName = "";
|
|
|
String where = "";
|
|
|
Map<String,Integer> relationMap = new HashMap<>();//多视图关联
|
|
|
Map<String,String> filedMap = new HashMap<>();//参数加别名
|
|
|
//资源判空检查
|
|
|
for (String code : codeList) {
|
|
|
RsResource rsResources = rsResourceService.getResourceByCategory(code,"standard");
|
|
|
if (rsResources == null) {
|
|
|
throw new ApiException( "无效的资源编码" + code,ErrorCode.BAD_REQUEST.value());
|
|
|
}
|
|
|
List<RsResourceMetadata> resourceMetadataList = resourceBrowseMetadataDao.findResourceMetadata(code);
|
|
|
for (RsResourceMetadata metadata:resourceMetadataList){
|
|
|
filedMap.put(metadata.getMetadataId(),code);
|
|
|
}
|
|
|
String sortOrder = "";
|
|
|
List<RsResourceDefaultParam> paramsList = resourceDefaultParamDao.findByResourcesCode(code);
|
|
|
for (RsResourceDefaultParam param : paramsList) {
|
|
|
if (param.getParamKey().equals("sort")) {
|
|
|
Map<String, String> temp = objectMapper.readValue(param.getParamValue(), Map.class);
|
|
|
String paramKey = param.getParamKey();
|
|
|
String paramValue = param.getParamValue();
|
|
|
if ("sort".equals(paramKey)) {
|
|
|
Map<String, String> temp = objectMapper.readValue(paramValue, Map.class);
|
|
|
for (Map.Entry<String, String> entry:temp.entrySet()){
|
|
|
String key = entry.getKey();
|
|
|
String value = entry.getValue();
|
|
|
sortOrder ="T."+key+" "+ value+",";
|
|
|
}
|
|
|
}else if (param.getParamKey().equals("table")){
|
|
|
tableName += " ("+param.getParamValue()+") "+ code;
|
|
|
}else if ("table".equals(paramKey)){
|
|
|
tableName += " ("+paramValue+") "+ code +",";
|
|
|
}else if("relation".equals(paramKey)){
|
|
|
String relate[] = paramValue.split(",");
|
|
|
for (String re:relate){
|
|
|
if(relationMap.containsKey(re)){
|
|
|
relationMap.put(re,relationMap.get(re)+1);
|
|
|
}else {
|
|
|
relationMap.put(re,1);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
String code1 = codeList.get(0);
|
|
|
int codeLength = codeList.size();
|
|
|
for (int i=1;i<codeLength ;i++) {
|
|
|
String codeTmp = codeList.get(i);
|
|
|
for (Map.Entry<String, Integer> entry : relationMap.entrySet()) {
|
|
|
String key = entry.getKey();
|
|
|
int value = entry.getValue();
|
|
|
if(value == codeLength){
|
|
|
where += " and " + code1+"."+key+"="+codeTmp+"."+key;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
tableName = tableName.substring(0,tableName.length()-1);
|
|
|
StringBuffer stringBuffer = new StringBuffer();
|
|
|
if (!StringUtils.isEmpty(queryCondition)) {
|
|
|
stringBuffer = parseCondition1(queryCondition);
|
|
|
}
|
|
|
stringBuffer.append(where);
|
|
|
//数据元信息字段
|
|
|
if(!StringUtils.isEmpty(metaData)){
|
|
|
metaData = metaData.replaceAll(",","\",\"");
|
|
@ -532,10 +566,14 @@ public class ResourceBrowseService extends BaseJpaService {
|
|
|
//参数集合
|
|
|
List<String> paramList = new ArrayList<>(customizeList.size() * 2);
|
|
|
for (String id : customizeList) {
|
|
|
String codeTmp = filedMap.get(id);
|
|
|
if(id.contains("-")){
|
|
|
String tmp = id.substring(id.lastIndexOf("-")+1);
|
|
|
id = tmp + " as '" +id+"'";
|
|
|
}
|
|
|
if(codeTmp!=null){
|
|
|
id = codeTmp+"."+id;
|
|
|
}
|
|
|
paramList.add(id);
|
|
|
}
|
|
|
String queryString = org.apache.commons.lang3.StringUtils.join(paramList, ",");
|