|
@@ -25,6 +25,8 @@ public class DataProcess {
|
|
|
|
|
|
private List<String> serviceAuthMap = new ArrayList<>();
|
|
|
|
|
|
+ private Set<Integer> enableLogCalculationLibrary = new HashSet<>();
|
|
|
+
|
|
|
public DataProcess(String service_Id) {
|
|
|
lastActive = System.currentTimeMillis();
|
|
|
serviceId = service_Id;
|
|
@@ -36,9 +38,10 @@ public class DataProcess {
|
|
|
}
|
|
|
|
|
|
Map<String, Object> calculationMap = baseDbHelper.queryByParamsReturnList("SELECT CL.*,DI.* FROM calculation_library CL left JOIN datasourceinfo DI ON DI.dataSourceID = CL.datasource_id WHERE CL.service_id =? and CL.library_type is not null order by library_sort,library_id", service_Id);
|
|
|
+
|
|
|
calcList = Objects.isNull(calculationMap.get("returnData")) ? null : (List<Map<String, Object>>) calculationMap.get("returnData");
|
|
|
if (!calculationMap.get("code").equals("0") || calcList == null || calcList.isEmpty()) {
|
|
|
- errorMessage = "查询".concat(serviceId).concat("的算法失败:").concat(calculationMap.containsKey("message")?calculationMap.get("message").toString():"对应算法不存在");
|
|
|
+ errorMessage = "查询".concat(serviceId).concat("的算法失败:").concat(calculationMap.containsKey("message") ? calculationMap.get("message").toString() : "对应算法不存在");
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -51,6 +54,12 @@ public class DataProcess {
|
|
|
if (!Objects.isNull(serviceAuthList)) {
|
|
|
serviceAuthMap = ((List<Map<String, Object>>) serviceAuthList).stream().map(map -> map.get("app_id").toString()).toList();
|
|
|
}
|
|
|
+ List<Map<String, Object>> returnData = (List<Map<String, Object>>) calculationMap.getOrDefault("returnData", Collections.EMPTY_LIST);
|
|
|
+
|
|
|
+ List<Integer> enabled = returnData.stream()
|
|
|
+ .filter(it -> Objects.nonNull(it.get("processType")) && "1".equals(it.get("processType").toString()))
|
|
|
+ .map(it -> ((Integer) it.get("library_id"))).toList();
|
|
|
+ enableLogCalculationLibrary.addAll(enabled);
|
|
|
} catch (Exception e) {
|
|
|
errorMessage = "数据处理对象初始化异常: ".concat(serviceId).concat(";异常信息:").concat(LogUtils.getException(e));
|
|
|
}
|
|
@@ -143,8 +152,24 @@ public class DataProcess {
|
|
|
return processFail(library_id.concat("数据计算错误:").concat(lastResult.get("message").toString()), library_id);
|
|
|
}
|
|
|
|
|
|
- LogUtils.log("DataProcess:9999", "0", library_id, "数据接收后处理成功", serviceId, calcData, dataObjectId, preListData, inputData.get("event"));
|
|
|
-
|
|
|
+ List<Map<String, Object>> logData = calcData;
|
|
|
+ logData = logData.stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .filter(it ->
|
|
|
+ {
|
|
|
+
|
|
|
+ Object libraryId = it.get("library_id");
|
|
|
+ return enableLogCalculationLibrary.contains(libraryId);
|
|
|
+ }
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (logData.size() == 1 && "0".equals(logData.get(0).getOrDefault("library_id", 0).toString())) {
|
|
|
+ logData.clear();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!logData.isEmpty()) {
|
|
|
+ LogUtils.log("DataProcess:9999", "0", library_id, "数据接收后处理成功", serviceId, logData, dataObjectId, preListData, inputData.get("event"));
|
|
|
+ }
|
|
|
calcData = calcData.stream().filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
return processSuccess(calcData.get(calcData.size() - 1));
|
|
|
} catch (Exception e) {
|
|
@@ -188,7 +213,7 @@ public class DataProcess {
|
|
|
String tempRowAuth = rowAuthObj.toString();
|
|
|
String connect = tempRowAuth.startsWith("!") ? "!=" : "=";
|
|
|
tempRowAuth = tempRowAuth.startsWith("!") ? tempRowAuth.substring(1) : tempRowAuth;
|
|
|
- String[] row_auths = tempRowAuth.split(",",-1);
|
|
|
+ String[] row_auths = tempRowAuth.split(",", -1);
|
|
|
for (String row_auth : row_auths) {
|
|
|
if (MapTools.isBlank(row_auth)) continue;
|
|
|
Map<String, Object> signRowAuth = new HashMap<>();
|
|
@@ -224,7 +249,6 @@ public class DataProcess {
|
|
|
}
|
|
|
|
|
|
|
|
|
- *
|
|
|
* @param columnName ID
|
|
|
* @param row_auth 2
|
|
|
* @param nextRule t_user_group.up_user_groupid
|
|
@@ -232,7 +256,7 @@ public class DataProcess {
|
|
|
*/
|
|
|
private List<Object> extendNextAuth(String columnName, String row_auth, Object nextRule) {
|
|
|
List<Object> returnData = new ArrayList<>();
|
|
|
- String[] rule = nextRule.toString().split("\\.",-1);
|
|
|
+ String[] rule = nextRule.toString().split("\\.", -1);
|
|
|
Map<String, Object> queryAuthReturnList = baseDbHelper.queryByParamsReturnList("select " + columnName + " from " + rule[0] + " where " + rule[1] + " = ?", row_auth);
|
|
|
if ("-1".equals(queryAuthReturnList.get("code")) || ((List) queryAuthReturnList.get("returnData")).isEmpty()) {
|
|
|
return returnData;
|
|
@@ -290,6 +314,8 @@ public class DataProcess {
|
|
|
calcData.add(currentResult);
|
|
|
if (Objects.nonNull(currentResult) && !currentResult.get("code").equals("0")) {
|
|
|
break;
|
|
|
+ } else {
|
|
|
+ currentResult.put("library_id", lastLibraryId);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -423,15 +449,15 @@ public class DataProcess {
|
|
|
tempList.add(returnData);
|
|
|
returnData = tempList;
|
|
|
}
|
|
|
- if ("Array".contains(dataType)){
|
|
|
- if (returnData instanceof List<?> tempList && !tempList.isEmpty() ) {
|
|
|
+ if ("Array".contains(dataType)) {
|
|
|
+ if (returnData instanceof List<?> tempList && !tempList.isEmpty()) {
|
|
|
List<Object> tpList = new ArrayList<>();
|
|
|
for (Object o : tempList) {
|
|
|
- if (o instanceof Map<?,?>){
|
|
|
+ if (o instanceof Map<?, ?>) {
|
|
|
tpList.add(MapTools.objToJSONStr(o));
|
|
|
- }else if (o instanceof String tpStr && tpStr.contains("=") && tpStr.contains("{") && tpStr.contains("}")){
|
|
|
+ } else if (o instanceof String tpStr && tpStr.contains("=") && tpStr.contains("{") && tpStr.contains("}")) {
|
|
|
tpList.add(MapTools.objToJSONStr(MapTools.strToObj(tpStr)));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
tpList.add(o);
|
|
|
}
|
|
|
}
|