|
@@ -106,15 +106,16 @@ public class DataProcess {
|
|
|
LogUtils.log("processData:1", "-1", null, "服务不可用" + errorMessage, serviceId, AppConfig.WORK_ID, MapTools.jacksonObjToStr(inputData), null, null, null);
|
|
|
return processFail("服务不可用" + errorMessage, null);
|
|
|
}
|
|
|
- lastActive = System.currentTimeMillis();//更新最后活跃时间 //------更新当前服务的最后活跃时间,用于服务监控
|
|
|
- //更新服务的活跃时间
|
|
|
- MyDbHelper myDbHelper = ObjectMap.getordropMyDbHelper(AppConfig.getSystemParams(AppConfig.REMOTE_DB_CONNECT));
|
|
|
- if (Objects.nonNull(myDbHelper.getErrorMessage())) {
|
|
|
- LogUtils.log("processData:2", "-1", null, "数据接收错误,获取远程数据库对象: " + myDbHelper.getErrorMessage(), serviceId, AppConfig.WORK_ID, MapTools.jacksonObjToStr(inputData), null, null, null);
|
|
|
- return processFail("数据接收错误,获取远程数据库对象: " + myDbHelper.getErrorMessage(), null);
|
|
|
+ if (System.currentTimeMillis() - lastActive > 1000) { // 更新数据库中的服务最新活跃时间
|
|
|
+ //更新服务的活跃时间
|
|
|
+ MyDbHelper myDbHelper = ObjectMap.getordropMyDbHelper(AppConfig.getSystemParams(AppConfig.REMOTE_DB_CONNECT));
|
|
|
+ if (Objects.nonNull(myDbHelper.getErrorMessage())) {
|
|
|
+ LogUtils.log("processData:2", "-1", null, "数据接收错误,获取远程数据库对象: " + myDbHelper.getErrorMessage(), serviceId, AppConfig.WORK_ID, MapTools.jacksonObjToStr(inputData), null, null, null);
|
|
|
+ return processFail("数据接收错误,获取远程数据库对象: " + myDbHelper.getErrorMessage(), null);
|
|
|
+ }
|
|
|
+ myDbHelper.updateByCondition("update serviceinfo set runState = 1 ,lastactive = now() where serviceID =?", null, serviceId); // 服务表增加最后活跃时间
|
|
|
}
|
|
|
- // 更新数据库中的服务最新活跃时间
|
|
|
- myDbHelper.updateByCondition("update serviceinfo set runState = 1 ,lastactive = now() where serviceID =?", null, serviceId); // 服务表增加最后活跃时间
|
|
|
+ lastActive = System.currentTimeMillis();//更新最后活跃时间 //------更新当前服务的最后活跃时间,用于服务监控
|
|
|
//创建生命周期ID;//默认继承
|
|
|
if (!inputData.containsKey("dataObjectId")) {
|
|
|
// 生成新的生命周期ID
|
|
@@ -128,9 +129,14 @@ public class DataProcess {
|
|
|
//通过用户编号,服务编号,从用户权限表获取行列权限
|
|
|
// 如果列权限为空则 直接返回空
|
|
|
// 重新组建入口参数:添加filter(行权限)
|
|
|
- Map<String, Object> authServiceMap = myDbHelper.queryByParamsReturnList("SELECT auth_id FROM t_auth WHERE serviceID = ? and auth_id = ? ", serviceId, inputData.get("auth_id"));
|
|
|
- if (authServiceMap.get("code").equals("-1")) return authServiceMap;
|
|
|
- if (event.equals("0") && Objects.nonNull(user_id) && authServiceMap.get("returnData") instanceof List<?> returnDataList && !returnDataList.isEmpty()) {
|
|
|
+ if (!event.equals("1") && Objects.nonNull(user_id) && inputData.containsKey("auth_id")) {
|
|
|
+ MyDbHelper myDbHelper = ObjectMap.getordropMyDbHelper(AppConfig.getSystemParams(AppConfig.REMOTE_DB_CONNECT));
|
|
|
+ if (Objects.nonNull(myDbHelper.getErrorMessage())) {
|
|
|
+ LogUtils.log("processData:2", "-1", null, "数据接收错误,获取远程数据库对象: " + myDbHelper.getErrorMessage(), serviceId, AppConfig.WORK_ID, MapTools.jacksonObjToStr(inputData), null, null, null);
|
|
|
+ return processFail("数据接收错误,获取远程数据库对象: " + myDbHelper.getErrorMessage(), null);
|
|
|
+ }
|
|
|
+ Map<String, Object> authServiceMap = myDbHelper.queryByParamsReturnList("SELECT auth_id FROM t_auth WHERE serviceID = ? and auth_id = ? ", serviceId, inputData.get("auth_id"));
|
|
|
+ if (authServiceMap.get("code").equals("-1") || (authServiceMap.get("returnData") instanceof List<?> returnDataList && returnDataList.isEmpty())) return authServiceMap;
|
|
|
//判断filter不为空 且 filter不包含left---{"filter":[{"user_id":""}]} ---- >[{filter:[{left:,column:},{left:,column:}
|
|
|
/*获取权限filter*/
|
|
|
Map<String, Object> userDataAuthMap = myDbHelper.queryByParamsReturnList("SELECT QCS.columnName,TUA.row_auth FROM t_user_group_auth TUA LEFT JOIN querytemplatecolumnset QCS on TUA.queryTemplateColumnSetID = QCS.queryTemplateColumnSetID WHERE TUA.user_id = ? AND TUA.auth_id = ? AND TUA.queryTemplateColumnSetID IS NOT NULL", user_id[0], inputData.get("auth_id"));
|
|
@@ -141,19 +147,19 @@ public class DataProcess {
|
|
|
for (String row_auth : row_auths) {
|
|
|
if (Objects.isNull(row_auth)) continue;
|
|
|
HashMap<String, Object> hashMap = new HashMap<>();
|
|
|
- hashMap.put(tempMap.get("columnName").toString(), row_auth.startsWith("!")?row_auth.substring(1):row_auth);
|
|
|
+ hashMap.put(tempMap.get("columnName").toString(), row_auth.startsWith("!") ? row_auth.substring(1) : row_auth);
|
|
|
if (row_auth.startsWith("!")) {
|
|
|
userList.addAll(changeSignFilter(hashMap, "!", "or"));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
userList.addAll(changeSignFilter(hashMap, null, "or"));
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
/*userList第一个以及最后一个添加()*/
|
|
|
- ((Map<String,Object>)userList.get(0)).put("left","(");
|
|
|
- ((Map<String,Object>)userList.get(userList.size()-1)).put("connector"," and ");
|
|
|
- ((Map<String,Object>)userList.get(userList.size()-1)).put("right"," ) ");
|
|
|
- inputData= initParam(inputData, "0", userList);
|
|
|
+ ((Map<String, Object>) userList.get(0)).put("left", "(");
|
|
|
+ ((Map<String, Object>) userList.get(userList.size() - 1)).put("connector", " and ");
|
|
|
+ ((Map<String, Object>) userList.get(userList.size() - 1)).put("right", " ) ");
|
|
|
+ inputData = initParam(inputData, "0", userList);
|
|
|
}
|
|
|
|
|
|
List<Map<String, Object>> calculationResult = new ArrayList<>();//定义算法全量结果列表
|
|
@@ -219,13 +225,13 @@ public class DataProcess {
|
|
|
Object tempFilterObject = inDataContent.get("filter");//获取filter
|
|
|
tempFilterObject = Objects.isNull(tempFilterObject) ? inDataContent : tempFilterObject;//如果不存在filter则等于原始MAP
|
|
|
if (tempFilterObject instanceof Map) {////如果filter是单个Map则
|
|
|
- authList.addAll(changeSignFilter((Map)tempFilterObject,null,null));
|
|
|
+ authList.addAll(changeSignFilter((Map) tempFilterObject, null, null));
|
|
|
returnData.put("filter", authList);//转换为标准条件集
|
|
|
} else {
|
|
|
if (tempFilterObject instanceof List tempFilterObjectList && tempFilterObjectList.get(0) instanceof Map) {//如果filter是List则"123"
|
|
|
List<Object> tempFilterList = new ArrayList<>(authList);
|
|
|
for (Object o : tempFilterObjectList) {//循环List -{c1:c2,c3:c4}
|
|
|
- tempFilterList.addAll(changeSignFilter((Map) o,null,null)); //循环添加
|
|
|
+ tempFilterList.addAll(changeSignFilter((Map) o, null, null)); //循环添加
|
|
|
}
|
|
|
returnData.put("filter", tempFilterList);//转换为标准条件集
|
|
|
} else {//此时tempFilterObject既不是List也不是Map:1、dataContent包含filter且filter是一个字符串
|
|
@@ -247,91 +253,18 @@ public class DataProcess {
|
|
|
Object keyValues = filterMap.get(filterKey);
|
|
|
returnMap.put("left", "");
|
|
|
returnMap.put("column", filterKey);
|
|
|
- returnMap.put("comparator",(Objects.nonNull(compare) && compare.startsWith("!"))?"!=":" = ");
|
|
|
+ returnMap.put("comparator", (Objects.nonNull(compare) && compare.startsWith("!")) ? "!=" : " = ");
|
|
|
if (Objects.isNull(keyValues)) {
|
|
|
returnMap.put("comparator", " is null ");
|
|
|
}
|
|
|
returnMap.put("value", keyValues);
|
|
|
returnMap.put("right", "");
|
|
|
- returnMap.put("connector", Objects.nonNull(connect)?(" "+connect): " and ");
|
|
|
+ returnMap.put("connector", Objects.nonNull(connect) ? (" " + connect) : " and ");
|
|
|
objects.add(returnMap);
|
|
|
}
|
|
|
return objects;
|
|
|
}
|
|
|
|
|
|
-// private static Map<String, Object> initParam(Map<String, Object> inputData) {
|
|
|
-// Object dataContent = inputData.get("dataContent");
|
|
|
-// if (Objects.isNull(dataContent)) {// null
|
|
|
-// dataContent = MapTools.removeKey(inputData, baseInfo);
|
|
|
-// }
|
|
|
-// /*如果dataContent不是数组也不是map则返回inData,--不是map数组 返回InData*/
|
|
|
-// if (!(dataContent instanceof Map<?, ?>) && (dataContent instanceof List<?> && !(((List<?>) dataContent).get(0) instanceof Map))) {
|
|
|
-// return inputData;
|
|
|
-// }
|
|
|
-// if (dataContent instanceof Map<?, ?> temMap) {
|
|
|
-// List<Object> tempList = new ArrayList<>();
|
|
|
-// tempList.add(temMap);
|
|
|
-// dataContent = tempList;
|
|
|
-// }
|
|
|
-// /*同步添加Value*/
|
|
|
-// List<Map<String, Object>> tempDataList = (List<Map<String, Object>>) dataContent;
|
|
|
-// if (!tempDataList.get(0).containsKey("filter")) { //[{a=1,b=2},{a=2,b=3}] ---->[{"filter":[{a=1,b=2}]},{"filter":[{a=2,b=3}]}]
|
|
|
-// List<Object> tempList = new ArrayList<>();
|
|
|
-// for (Object tempMap : tempDataList) { //[{a=1,b=2},{a=2,b=3}]
|
|
|
-// List<Object> tepList = new ArrayList<>();
|
|
|
-// tepList.add(tempMap);
|
|
|
-// Map<Object, Object> tmpData = new HashMap<>();
|
|
|
-// tmpData.put("filter", tepList);
|
|
|
-// tempList.add(tmpData);
|
|
|
-// }
|
|
|
-// dataContent = tempList;
|
|
|
-// }
|
|
|
-// if (tempDataList.get(0).get("filter") instanceof Map<?, ?> filterMap) { //[{"filter":{a=1,b=2}},{"filter":{a=2,b=3}}]
|
|
|
-// List<Map<String, Object>> returnDataList = new ArrayList<>();
|
|
|
-// for (Map<String, Object> temp : tempDataList) {
|
|
|
-// List<Object> tempList = new ArrayList<>();
|
|
|
-// tempList.add(filterMap);
|
|
|
-// temp.put("filter", tempList);
|
|
|
-// returnDataList.add(temp);
|
|
|
-// }
|
|
|
-// dataContent = returnDataList; // [{"filter":[{a=1,b=2}}],{"filter":[{a=2,b=3}]}]
|
|
|
-// }
|
|
|
-// List<Map<String, Object>> data = new ArrayList<>();
|
|
|
-// List<Map<String, Object>> filterList = ((List<Map<String, List<Map<String, Object>>>>) dataContent).get(0).get("filter");
|
|
|
-// if (!filterList.get(0).containsKey("left")) {
|
|
|
-// authoParams(filterList, data); //[{"filter":{a=1,b=2}},{"filter":{a=2,b=3}}]
|
|
|
-// } else {
|
|
|
-// data = (List<Map<String, Object>>) dataContent;
|
|
|
-// }
|
|
|
-// inputData.put("dataContent", data);
|
|
|
-// return inputData;
|
|
|
-// }
|
|
|
-//
|
|
|
-// //[{"filter":{a=1,b=2}},{"filter":{a=2,b=3}}]
|
|
|
-// private static void authoParams(List<Map<String, Object>> ListInMap, List<Map<String, Object>> filterMapList) {
|
|
|
-//// String filterTemplate = "{\"left\":\"左括号\",\"column\":\"字段\",\"comparator\":\"=\",\"value\":\"值\",\"right\":\"右括号\",\"connector\":\"连接符\"}";
|
|
|
-// List<Object> filterValue = new ArrayList<>();
|
|
|
-// for (Map<String, Object> filterKey : ListInMap) {
|
|
|
-// for (String filKey : filterKey.keySet()) {
|
|
|
-// HashMap<String, Object> filterMap = new HashMap<>();
|
|
|
-// Object keyValues = filterKey.get(filKey);
|
|
|
-// filterMap.put("left", "");
|
|
|
-// filterMap.put("column", filKey);
|
|
|
-// filterMap.put("comparator", " = ");
|
|
|
-// if (Objects.isNull(keyValues)) {
|
|
|
-// filterMap.put("comparator", " is null ");
|
|
|
-// }
|
|
|
-// filterMap.put("value", keyValues);
|
|
|
-// filterMap.put("right", "");
|
|
|
-// filterMap.put("connector", " and ");
|
|
|
-// filterValue.add(filterMap);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// HashMap<String, Object> hashMap = new HashMap<>();
|
|
|
-// hashMap.put("filter", filterValue);
|
|
|
-// filterMapList.add(hashMap);
|
|
|
-// }
|
|
|
-
|
|
|
public Map<String, List<Map<String, Object>>> execCalultion(List<Map<String, Object>> inData, String beginLibraryId, Object event, String dataObjectId, Object page, Object pageSize) {
|
|
|
Map<String, List<Map<String, Object>>> returnData = new HashMap<>();
|
|
|
List<Map<String, Object>> preData = new ArrayList<>();
|
|
@@ -504,7 +437,7 @@ public class DataProcess {
|
|
|
* @param serviceId
|
|
|
* @return
|
|
|
*/
|
|
|
- public static synchronized String createLifeCycleCol(Long workerId, Integer serviceId) {
|
|
|
+ public static String createLifeCycleCol(Long workerId, Integer serviceId) {
|
|
|
long timestamp = System.currentTimeMillis();
|
|
|
//如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常
|
|
|
//如果是同一时间生成的,则进行毫秒内序列
|