|
@ -19,10 +19,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.text.NumberFormat;
|
|
|
import java.text.ParseException;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Created by janseny on 2018/9/18.
|
|
@ -39,6 +36,7 @@ public class ElasticSearchDataProcessService {
|
|
|
private static String dataSource_k = "dataSource";
|
|
|
private static String table_k = "table";
|
|
|
private static String rowKey_k = "rowkey";
|
|
|
private static String subRowKey_k = "subRowkey";
|
|
|
private static String action_k = "action";
|
|
|
|
|
|
@Autowired
|
|
@ -98,9 +96,7 @@ public class ElasticSearchDataProcessService {
|
|
|
if(dataMap.get(key)!= null){
|
|
|
keyValue = dataMap.get(key).toString();
|
|
|
}
|
|
|
|
|
|
//根据列名 查找出 对应的维度code及是否要数据字典,是否通过算法扩展出来
|
|
|
// 是否是子集模式中
|
|
|
List<CubeMappingModel> cubeMappingModels = cubeMappingService.findCubeMappingModelsByFieldCode(table, key);
|
|
|
if(cubeMappingModels != null && cubeMappingModels.size() > 0){
|
|
|
for(CubeMappingModel cubeMappingModel :cubeMappingModels){
|
|
@ -140,6 +136,7 @@ public class ElasticSearchDataProcessService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// 是否是 子集属性
|
|
|
List<CubeMemberMappingModel> cubeMemberMappingModels = cubeMemberMappingService.findCubeMemberMappingModels(table,key);
|
|
|
if(cubeMemberMappingModels != null && cubeMemberMappingModels.size() > 0){
|
|
|
for(CubeMemberMappingModel cubeMemberMappingModel :cubeMemberMappingModels){
|
|
@ -148,23 +145,41 @@ public class ElasticSearchDataProcessService {
|
|
|
if(cubeMemberMappingModel.getChildSaveType() != null){
|
|
|
int childSaveType = cubeMemberMappingModel.getChildSaveType();
|
|
|
if(childSaveType == 1 ){//对象方式
|
|
|
//拼装成数据结构
|
|
|
String field = parentCode + "." + cloumnCode;
|
|
|
source.put(field,keyValue);
|
|
|
Map<String, Object> objChildMap = new HashMap<>();
|
|
|
objChildMap.put(cloumnCode,keyValue);
|
|
|
source.put(parentCode,objChildMap);
|
|
|
}
|
|
|
if(childSaveType == 2 ){//nested 方式
|
|
|
List<Map<String,Object>> nestedList = new ArrayList<>();
|
|
|
//查出历史数据 然后组合保存
|
|
|
String field = parentCode + ".subRowkey";
|
|
|
String field = parentCode + "." + subRowKey_k;
|
|
|
List<Map<String, Object>> subDataList = elasticSearchUtil.findByField(index, type, field, rowKey);
|
|
|
if(subDataList != null && subDataList.size() > 0){
|
|
|
String parentRowkey = subDataList.get(0).get(rowKey_k).toString();
|
|
|
List<Map<String, Object>> dataList = elasticSearchUtil.findByField(index, type, rowKey_k, parentRowkey);
|
|
|
if(dataList != null && dataList.size() > 0){
|
|
|
//组装 子集历史数据 在添加
|
|
|
//组装 子集历史数据,更改当前字段值 在添加
|
|
|
for(Map<String, Object> map : dataList){
|
|
|
if(map.get(subRowKey_k).equals(rowKey)){
|
|
|
for(String colKey :map.keySet()){
|
|
|
if(colKey.equals(cloumnCode)){
|
|
|
map.put(key,keyValue);
|
|
|
}
|
|
|
}
|
|
|
nestedList.add(map);
|
|
|
}else{
|
|
|
nestedList.add(map);
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
//单条添加
|
|
|
//库中没有记录,单条添加
|
|
|
Map<String, Object> nestedChildMap = new HashMap<>();
|
|
|
nestedChildMap.put(cloumnCode,keyValue);
|
|
|
nestedChildMap.put(subRowKey_k,rowKey);
|
|
|
nestedList.add(nestedChildMap);
|
|
|
}
|
|
|
}
|
|
|
source.put(parentCode,nestedList);
|
|
|
}
|
|
|
}else {
|
|
|
//字典扩展
|