|
@@ -9,7 +9,6 @@ import org.bfkj.utils.MyDbHelper;
|
|
|
import org.bfkj.utils.ScriptEnginePro;
|
|
|
|
|
|
import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
@@ -26,9 +25,9 @@ public class DataProcess {
|
|
|
|
|
|
private final Map<String, ScriptEnginePro> ScriptEngineProMaps = new HashMap<>();
|
|
|
|
|
|
- private Map<String, List<String>> columnMaps = new HashMap<>();
|
|
|
+ private final Map<String, List<String>> columnMaps = new HashMap<>();
|
|
|
|
|
|
- private static List<String> baseInfo = new ArrayList<>() {{
|
|
|
+ private static final List<String> baseInfo = new ArrayList<>() {{
|
|
|
add("serviceId");
|
|
|
add("event");
|
|
|
add("page");
|
|
@@ -45,8 +44,6 @@ public class DataProcess {
|
|
|
errorMessage = "获取myDbHelper对象异常: " + myDbHelper.getErrorMessage();
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
Map<String, Object> serviceInfoResult = myDbHelper.queryByParamsReturnList("select * from serviceinfo where serviceID = ?", service_Id);
|
|
|
List<Map<String, Object>> mapList = MapTools.getMapList(serviceInfoResult);
|
|
|
if (!serviceInfoResult.get("code").equals("0") || Objects.isNull(mapList) || mapList.isEmpty()) {
|
|
@@ -60,13 +57,13 @@ public class DataProcess {
|
|
|
if (!calculationResult.get("code").equals("0")) {
|
|
|
errorMessage = "查询" + service_Id + "的算法失败:" + calculationResult.get("message");
|
|
|
}
|
|
|
+ if (calculationLibraryList == null || calculationLibraryList.isEmpty()) {
|
|
|
+ errorMessage = "服务ID " + service_Id +"没有找到对应的算法";
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
* 关闭的连接信息
|
|
|
- *
|
|
|
- * @param
|
|
|
- * @return
|
|
|
*/
|
|
|
public void close() {
|
|
|
for (ScriptEnginePro scriptEnginePro : ScriptEngineProMaps.values()) {
|
|
@@ -166,7 +163,6 @@ public class DataProcess {
|
|
|
calculationResult.add(inputData);
|
|
|
Map<String, List<Map<String, Object>>> execResult = execCalultion(calculationResult, null, event, dataObjectId, inputData.get("page"), inputData.get("pageSize"));
|
|
|
calculationResult = execResult.get("calcData");
|
|
|
-
|
|
|
Map<String, Object> lastResult = calculationResult.get(calculationResult.size() - 1);
|
|
|
if (Objects.equals(lastResult.get("code"), "-1")) {
|
|
|
String libraryId = lastResult.get("library_id").toString();
|
|
@@ -181,7 +177,7 @@ public class DataProcess {
|
|
|
|
|
|
|
|
|
|
|
|
- List<Map<String, Object>> collect = calculationResult.stream().filter(map -> Objects.isNull(map.get("library_id")) || !map.get("library_id").toString().contains("_N")).collect(Collectors.toList());
|
|
|
+ List<Map<String, Object>> collect = calculationResult.stream().filter(map -> Objects.isNull(map.get("library_id")) || !map.get("library_id").toString().contains("_N")).toList();
|
|
|
return processSuccess(collect.get(collect.size() - 1));
|
|
|
}
|
|
|
|
|
@@ -210,6 +206,7 @@ public class DataProcess {
|
|
|
return inputData;
|
|
|
}
|
|
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
private static Map<String, Object> createStandardParameters(Map<String, Object> inDataContent, String event, List<Object> authList) {
|
|
|
Map<String, Object> returnData = new HashMap<>();
|
|
|
if ("1,2".contains(event)) {
|
|
@@ -225,13 +222,13 @@ public class DataProcess {
|
|
|
Object tempFilterObject = inDataContent.get("filter");
|
|
|
tempFilterObject = Objects.isNull(tempFilterObject) ? inDataContent : tempFilterObject;
|
|
|
if (tempFilterObject instanceof Map) {
|
|
|
- authList.addAll(changeSignFilter((Map) tempFilterObject, null, null));
|
|
|
+ authList.addAll(changeSignFilter((Map<String, Object>) tempFilterObject, null, null));
|
|
|
returnData.put("filter", authList);
|
|
|
} else {
|
|
|
if (tempFilterObject instanceof List tempFilterObjectList && tempFilterObjectList.get(0) instanceof Map) {
|
|
|
List<Object> tempFilterList = new ArrayList<>(authList);
|
|
|
for (Object o : tempFilterObjectList) {
|
|
|
- tempFilterList.addAll(changeSignFilter((Map) o, null, null));
|
|
|
+ tempFilterList.addAll(changeSignFilter((Map<String, Object>) o, null, null));
|
|
|
}
|
|
|
returnData.put("filter", tempFilterList);
|
|
|
} else {
|
|
@@ -248,7 +245,7 @@ public class DataProcess {
|
|
|
objects.add(filterMap);
|
|
|
return objects;
|
|
|
}
|
|
|
- for (Object filterKey : filterMap.keySet()) {
|
|
|
+ for (String filterKey : filterMap.keySet()) {
|
|
|
Map<String, Object> returnMap = new HashMap<>();
|
|
|
Object keyValues = filterMap.get(filterKey);
|
|
|
returnMap.put("left", "");
|
|
@@ -270,7 +267,7 @@ public class DataProcess {
|
|
|
List<Map<String, Object>> preData = new ArrayList<>();
|
|
|
List<Map<String, Object>> calcData = Objects.isNull(inData) || inData.isEmpty() ? new ArrayList<>() : inData;
|
|
|
for (Map<String, Object> calculationLibrary : calculationLibraryList) {
|
|
|
-
|
|
|
+
|
|
|
String library_id = calculationLibrary.get("library_id").toString();
|
|
|
if (MapTools.isNotBlank(beginLibraryId) && !beginLibraryId.equals(library_id)) {
|
|
|
continue;
|
|
@@ -309,17 +306,12 @@ public class DataProcess {
|
|
|
returnData.put("calcData", calcData);
|
|
|
return returnData;
|
|
|
}
|
|
|
- Object sourceObjectName = calculationLibrary.get("sourceObjectName");
|
|
|
+
|
|
|
+ String tableName = Objects.isNull(calculationLibrary.get("sourceObjectName")) ? null : calculationLibrary.get("sourceObjectName").toString();
|
|
|
Object isActiveTable = calculationLibrary.get("isActiveTable");
|
|
|
- Object eventStr = calculationLibrary.get("event");
|
|
|
- String eventFlag;
|
|
|
- if (Objects.isNull(eventStr)) {
|
|
|
- eventFlag = Objects.nonNull(sourceObjectName) ? event.toString() : AppConfig.staticEvent.get(Objects.requireNonNull(computing_expression).trim().toLowerCase().substring(0, 6));
|
|
|
- } else {
|
|
|
- eventFlag = eventStr.toString();
|
|
|
- }
|
|
|
+
|
|
|
+ String eventFlag = Objects.isNull(calculationLibrary.get("event")) ? (MapTools.isNotBlank(tableName)? event.toString() : AppConfig.staticEvent.get(Objects.requireNonNull(computing_expression).trim().toLowerCase().substring(0, 6))) : calculationLibrary.get("event").toString();
|
|
|
if (null == eventFlag) {
|
|
|
-
|
|
|
calcData.add(processFail("事件标志为空", library_id));
|
|
|
returnData.put("calcData", calcData);
|
|
|
return returnData;
|
|
@@ -329,14 +321,14 @@ public class DataProcess {
|
|
|
Object tempDBPrams = null;
|
|
|
try {
|
|
|
if (Objects.isNull(calculationLibrary.get("parmIndex"))) {
|
|
|
- Map<String, Object> tempMap = inData.get(inData.size() - 1);
|
|
|
+ Map<String, Object> tempMap = calcData.get(calcData.size() - 1);
|
|
|
tempDBPrams = tempMap.containsKey("dataContent") ? tempMap.get("dataContent") : tempMap.get("returnData");
|
|
|
} else {
|
|
|
- tempDBPrams = inData;
|
|
|
+ tempDBPrams = calcData;
|
|
|
String[] parmSplit = calculationLibrary.get("parmIndex").toString().split("\\.");
|
|
|
for (String item : parmSplit) {
|
|
|
if (MapTools.isNumber(item)) {
|
|
|
- tempDBPrams = ((List) tempDBPrams).get(Integer.parseInt(item));
|
|
|
+ tempDBPrams = ((List<?>) tempDBPrams).get(Integer.parseInt(item));
|
|
|
} else {
|
|
|
tempDBPrams = ((Map) tempDBPrams).get(item);
|
|
|
}
|
|
@@ -354,9 +346,9 @@ public class DataProcess {
|
|
|
}
|
|
|
|
|
|
if (eventFlag.equals("6")) {
|
|
|
- currentResult = myDbHelper.insertOrUpdate(Objects.nonNull(sourceObjectName) ? sourceObjectName.toString() : "", dbPrams);
|
|
|
+ currentResult = myDbHelper.insertOrUpdate(tableName, dbPrams);
|
|
|
} else {
|
|
|
- currentResult = myDbHelper.generalProcess(eventFlag, Objects.nonNull(sourceObjectName) ? sourceObjectName.toString() : "", computing_expression, null, dbPrams, Objects.nonNull(isActiveTable) && Objects.equals(isActiveTable, "true"), page, pageSize);
|
|
|
+ currentResult = myDbHelper.generalProcess(eventFlag, tableName, computing_expression, null, dbPrams, Objects.nonNull(isActiveTable) && Objects.equals(isActiveTable, "true"), page, pageSize);
|
|
|
}
|
|
|
|
|
|
} else {
|
|
@@ -367,6 +359,7 @@ public class DataProcess {
|
|
|
}
|
|
|
calcData.add(currentResult);
|
|
|
returnData.put("calcData", calcData);
|
|
|
+
|
|
|
setServiceErrorCount(library_id, serviceId, "0");
|
|
|
}
|
|
|
return returnData;
|