|
@ -35,6 +35,7 @@ public class ElasticSearchDataProcessService {
|
|
|
|
|
|
private static String dataSource_k = "dataSource";
|
|
|
private static String table_k = "table";
|
|
|
private static String id_k = "_id";
|
|
|
private static String rowKey_k = "rowkey";
|
|
|
private static String subRowKey_k = "subRowkey";
|
|
|
private static String action_k = "action";
|
|
@ -78,8 +79,8 @@ public class ElasticSearchDataProcessService {
|
|
|
*/
|
|
|
public void hbaseDataProcess(Map<String, Object> dataMap){
|
|
|
Map<String, Object> source = new HashMap<>();
|
|
|
String index = "";
|
|
|
String type = "";
|
|
|
String index = "patient_event";
|
|
|
String type = "info";
|
|
|
String table = dataMap.get(table_k).toString();
|
|
|
//通过表找到 对应的数据集 保存的索引和type
|
|
|
//TODO 可以维护到数据字典 - 保存到redis 减少去数据库里面查询
|
|
@ -96,6 +97,8 @@ public class ElasticSearchDataProcessService {
|
|
|
if(dataMap.get(key)!= null){
|
|
|
keyValue = dataMap.get(key).toString();
|
|
|
}
|
|
|
source.put(id_k,rowKey);
|
|
|
source.put(rowKey_k,rowKey);
|
|
|
//根据列名 查找出 对应的维度code及是否要数据字典,是否通过算法扩展出来
|
|
|
List<CubeMappingModel> cubeMappingModels = cubeMappingService.findCubeMappingModelsByFieldCode(table, key);
|
|
|
if(cubeMappingModels != null && cubeMappingModels.size() > 0){
|
|
@ -104,24 +107,24 @@ public class ElasticSearchDataProcessService {
|
|
|
DictFunc dictFunc = new DictFunc();
|
|
|
//字典扩展
|
|
|
if(StringUtils.isNotEmpty(cubeMappingModel.getDict()) && StringUtils.isEmpty(cubeMappingModel.getAlgorithm())){
|
|
|
String value = "";
|
|
|
String param[] = {cubeMappingModel.getDict(),keyValue};
|
|
|
String value = dictFunc.execute(param);
|
|
|
String dictCode = cloumnCode + ".Code";
|
|
|
String dictName = cloumnCode + ".Name";
|
|
|
source.put(dictCode,key);
|
|
|
source.put(dictName,value);
|
|
|
// value = dictFunc.execute(param);
|
|
|
value = key + "测试值";
|
|
|
source.put(cloumnCode,keyValue);
|
|
|
source.put(cloumnCode + "Name",value);
|
|
|
}else if(StringUtils.isNotEmpty(cubeMappingModel.getAlgorithm())){
|
|
|
//计算后 又经过字典 如:年龄段
|
|
|
if(cubeMappingModel.getAlgorithm().equals("AgeGroupFunc") && StringUtils.isNotEmpty(cubeMappingModel.getParm())){
|
|
|
String value = "";
|
|
|
AgeGroupFunc ageGroupFunc = new AgeGroupFunc();
|
|
|
String ageGroup = ageGroupFunc.execute(keyValue);
|
|
|
String ageGroup = ageGroupFunc.execute(Integer.valueOf(keyValue));
|
|
|
String param[] = {cubeMappingModel.getDict(),ageGroup};
|
|
|
String value = dictFunc.execute(param);
|
|
|
// value = dictFunc.execute(param);
|
|
|
value = "年龄段=" + ageGroup;
|
|
|
if(StringUtils.isNotEmpty(cubeMappingModel.getDict())){
|
|
|
String dictCode = cloumnCode + ".Code";
|
|
|
String dictName = cloumnCode + ".Name";
|
|
|
source.put(dictCode,key);
|
|
|
source.put(dictName,value);
|
|
|
source.put(cloumnCode,ageGroup);
|
|
|
source.put(cloumnCode + "Name",value);
|
|
|
}
|
|
|
}
|
|
|
//其他具体维度 对应具体算法
|
|
@ -184,13 +187,13 @@ public class ElasticSearchDataProcessService {
|
|
|
}else {
|
|
|
//字典扩展
|
|
|
if(StringUtils.isNotEmpty(cubeMemberMappingModel.getDict())){
|
|
|
String value = "";
|
|
|
DictFunc dictFunc = new DictFunc();
|
|
|
String param[] = {cubeMemberMappingModel.getDict(),cloumnCode};
|
|
|
String value = dictFunc.execute(param);
|
|
|
String dictCode = cloumnCode + ".Code";
|
|
|
String dictName = cloumnCode + ".Name";
|
|
|
source.put(dictCode,key);
|
|
|
source.put(dictName,value);
|
|
|
// value = dictFunc.execute(param);
|
|
|
value = key + "测试值";
|
|
|
source.put(cloumnCode + "Name",value);
|
|
|
source.put(cloumnCode,keyValue);
|
|
|
}else if(StringUtils.isNotEmpty(cubeMemberMappingModel.getAlgorithm())){
|
|
|
if(cubeMemberMappingModel.getAlgorithm().equals("DivisionFunc") && StringUtils.isNotEmpty(cubeMemberMappingModel.getParm())){
|
|
|
if(cubeMemberMappingModel.getParm().equals(key)){
|
|
@ -220,13 +223,13 @@ public class ElasticSearchDataProcessService {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
elasticSearchUtil.index(index, type, dataMap);
|
|
|
elasticSearchUtil.update(index, type,rowKey, source);
|
|
|
}else if (action.contains(action_del)){
|
|
|
for(String key : dataMap.keySet()){
|
|
|
dataMap.put(key,"");
|
|
|
}
|
|
|
//保存数据
|
|
|
elasticSearchUtil.index(index, type, dataMap);
|
|
|
elasticSearchUtil.update(index, type, rowKey,dataMap);
|
|
|
}else if(action.contains(action_delFamily)){
|
|
|
elasticSearchUtil.delete(index,type,rowKey);
|
|
|
}
|