|
|
@ -19,17 +19,19 @@ import com.bfd.assemble.entity.Constants; |
|
|
|
@Slf4j |
|
|
|
public class DataUtil { |
|
|
|
/** |
|
|
|
* |
|
|
|
* @param key 传入的key |
|
|
|
* @param key 传入的key |
|
|
|
* @param dataMap 数据map |
|
|
|
* @return 根据传入的参数进行判断解析,返回正确的dataValue |
|
|
|
*/ |
|
|
|
public static Object getValue(String key, Map dataMap) { |
|
|
|
try { |
|
|
|
//公式为空直接就返回 |
|
|
|
if(key.equals(Constants.EMPTY)){ |
|
|
|
return Constants.EMPTY; |
|
|
|
} |
|
|
|
try { |
|
|
|
//公式为空直接就返回 |
|
|
|
if (key.equals(Constants.EMPTY)) { |
|
|
|
return Constants.EMPTY; |
|
|
|
} |
|
|
|
if (!key.contains(Constants.NOT_KEY)) { |
|
|
|
return key; |
|
|
|
} |
|
|
|
Object dataValue; |
|
|
|
String isJson = "#json#"; |
|
|
|
if (key.contains(isJson)) { |
|
|
@ -51,13 +53,13 @@ public class DataUtil { |
|
|
|
String jsonPath = keySplit[1]; |
|
|
|
String dataJson = (String) dataMap.get(keySplit[0]); |
|
|
|
JSONObject dataJsonObject = JSON.parseObject(dataJson); |
|
|
|
dataValue = JSONPath.eval(dataJsonObject, jsonPath); |
|
|
|
dataValue = JSONPath.eval(dataJsonObject, jsonPath); |
|
|
|
return dataValue; |
|
|
|
} catch (Exception e) { |
|
|
|
// TODO: handle exception |
|
|
|
log.error("jsonpath公式取值异常,",e); |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
// TODO: handle exception |
|
|
|
log.error("jsonpath公式取值异常,", e); |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |