|
@@ -2,6 +2,7 @@ package org.bfkj.application;
|
|
|
|
|
|
|
|
|
import org.bfkj.config.AppConfig;
|
|
|
+import org.bfkj.config.ObjectMap;
|
|
|
import org.bfkj.utils.LogUtils;
|
|
|
import org.bfkj.utils.MapTools;
|
|
|
import org.bfkj.utils.MyDbHelper;
|
|
@@ -28,7 +29,7 @@ public class DataProcess {//数据处理对象
|
|
|
lastActive = System.currentTimeMillis();//默认最后活跃时间
|
|
|
serviceId = service_Id;
|
|
|
try {
|
|
|
- baseDbHelper = new MyDbHelper(AppConfig.REMOTE_DB_CONNECT);//获取底座数据库对象
|
|
|
+ baseDbHelper = ObjectMap.getordropMyDbHelper(AppConfig.REMOTE_DB_CONNECT);
|
|
|
if (Objects.nonNull(baseDbHelper.getErrorMessage())) {
|
|
|
errorMessage = "获取底座myDbHelper对象异常: ".concat(baseDbHelper.getErrorMessage());
|
|
|
return;
|
|
@@ -80,7 +81,7 @@ public class DataProcess {//数据处理对象
|
|
|
try {
|
|
|
resultData1 = (Map<String, Object>) returnData;
|
|
|
} catch (Exception e) {
|
|
|
- resultData1.put("returnData",returnData);
|
|
|
+ resultData1.put("returnData", returnData);
|
|
|
}
|
|
|
resultData1.put("code", "0");
|
|
|
return resultData1;
|
|
@@ -112,7 +113,7 @@ public class DataProcess {//数据处理对象
|
|
|
}
|
|
|
if (System.currentTimeMillis() - lastActive > 2000) { // 更新数据库中的服务最新活跃时间
|
|
|
lastActive = System.currentTimeMillis();//更新最后活跃时间 //------更新当前服务的最后活跃时间,用于服务监控
|
|
|
- baseDbHelper.updateByCondition("update serviceinfo set runState = ? ,lastactive = ? where serviceID =?", null, "1", lastActive, serviceId); // 服务表增加最后活跃时间
|
|
|
+ baseDbHelper.updateByCondition("update serviceinfo set runState = ? ,lastactive = ? where serviceID =?", null, "1", new Date(lastActive), serviceId); // 服务表增加最后活跃时间
|
|
|
}
|
|
|
//创建生命周期ID;//默认继承
|
|
|
if (!inputData.containsKey("dataObjectId")) {
|
|
@@ -147,7 +148,7 @@ public class DataProcess {//数据处理对象
|
|
|
calcData = calcData.stream().filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
return processSuccess(calcData.get(calcData.size() - 1)); /*可订阅任意算法结果,也可以订阅全量结果,由最后一个算法决定*/
|
|
|
} catch (Exception e) {
|
|
|
- return processFail("processData 异常: " + LogUtils.getException(e),null);
|
|
|
+ return processFail("processData 异常: " + LogUtils.getException(e), null);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -176,6 +177,14 @@ public class DataProcess {//数据处理对象
|
|
|
authColumn.add(columnName);//添加到列权限
|
|
|
Object rowAuthObj = dataAuthMap.get("row_auth");//获取对应列的行权限
|
|
|
if (Objects.nonNull(rowAuthObj)) {//如果存在则组建标准的限制条件
|
|
|
+
|
|
|
+ /*获取规格*/
|
|
|
+ Map<String, Object> authExtendMapList = baseDbHelper.queryByParamsReturnList("select nextRule from belowSet where auth_id =?", inputData.get("authId"));
|
|
|
+ if ("-1".equals(authExtendMapList.get("code"))) {
|
|
|
+ System.out.println("权限集成执行异常".concat(authExtendMapList.get("message").toString()));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Object nextRule =authExtendMapList.get("returnData") instanceof List<?> tempList && tempList.get(0) instanceof Map tempMap ? tempMap.get("nextRule"):null; // t_user_group.up_user_groupid
|
|
|
String tempRowAuth = rowAuthObj.toString();
|
|
|
String connect = tempRowAuth.startsWith("!") ? "!=" : "=";//如果首位是!代表不等于,否则代表等于
|
|
|
tempRowAuth = tempRowAuth.startsWith("!") ? tempRowAuth.substring(1) : tempRowAuth;//修订行权限表达式
|
|
@@ -185,6 +194,17 @@ public class DataProcess {//数据处理对象
|
|
|
Map<String, Object> signRowAuth = new HashMap<>();
|
|
|
signRowAuth.put(columnName, row_auth);
|
|
|
rowAuth.addAll(baseDbHelper.changeSignFilter(signRowAuth, connect, connect.equals("!=") ? "and" : "or"));
|
|
|
+ //如果row_auth开始左括号,且结束是右口号则------PEK,CTU,(t_user_group.up_user_groupid)
|
|
|
+ if (Objects.nonNull(nextRule)) {
|
|
|
+ List<Object> childAuthList = extendNextAuth(columnName, row_auth, nextRule); // [4,5]
|
|
|
+ if (!childAuthList.isEmpty()) {
|
|
|
+ childAuthList.forEach(authid -> {
|
|
|
+ Map<String, Object> tpSignRowAuth = new HashMap<>();
|
|
|
+ tpSignRowAuth.put(columnName, authid);
|
|
|
+ rowAuth.addAll(baseDbHelper.changeSignFilter(tpSignRowAuth, connect, connect.equals("!=") ? "and" : "or"));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -196,13 +216,34 @@ public class DataProcess {//数据处理对象
|
|
|
}
|
|
|
inputData.put("authColumn", authColumn);//添加到入参,方便后面调用
|
|
|
}
|
|
|
- inputData.put("currentUser",user_id);
|
|
|
+ inputData.put("currentUser", user_id);
|
|
|
} catch (Exception e) {
|
|
|
System.out.println("authCheck 异常:" + LogUtils.getException(e));
|
|
|
}
|
|
|
return inputData;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param columnName ID
|
|
|
+ * @param row_auth 2
|
|
|
+ * @param nextRule t_user_group.up_user_groupid
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<Object> extendNextAuth(String columnName, String row_auth, Object nextRule) {
|
|
|
+ List<Object> returnData = new ArrayList<>();
|
|
|
+ String[] rule = nextRule.toString().split("\\.");
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ ((List<Map<String,Object>>) queryAuthReturnList.get("returnData")).stream().filter(Objects::nonNull).forEach(authvalue -> {
|
|
|
+ returnData.add(authvalue.get(columnName)); // 5
|
|
|
+ returnData.addAll(extendNextAuth(columnName, authvalue.toString(), nextRule));
|
|
|
+ });
|
|
|
+ return returnData;
|
|
|
+ }
|
|
|
+
|
|
|
/*执行算法*/
|
|
|
public Map<String, Object> execCalultion(List<Map<String, Object>> inData, String beginLibraryId, String dataObjectId) {
|
|
|
Map<String, Object> returnData = new HashMap<>();//初始化最终返回结果
|
|
@@ -226,7 +267,7 @@ public class DataProcess {//数据处理对象
|
|
|
preCalMap.put("library_type", 2);/*如果脚本包含function则js否则java*/
|
|
|
preCalMap.put("computing_expression", is_exec); //组建前置算法配置信息
|
|
|
Map<String, Object> preEnginResult = execEngine(lastLibraryId, preCalMap, calcData);//调用算法引擎进行执行
|
|
|
- preEnginResult.put("preExecTime",System.currentTimeMillis()-beginTime);
|
|
|
+ preEnginResult.put("preExecTime", System.currentTimeMillis() - beginTime);
|
|
|
beginTime = System.currentTimeMillis();
|
|
|
// 获取当前时间搓
|
|
|
preData.add(preEnginResult);//添加执行结果到前置检测结果列表
|
|
@@ -242,7 +283,7 @@ public class DataProcess {//数据处理对象
|
|
|
}
|
|
|
//依据算法类型调用数据库对象或脚本引擎对象进行算法执行
|
|
|
Map<String, Object> currentResult = calculationLibrary.get("library_type").toString().equals("3") ? execDB(lastLibraryId, calculationLibrary, inData, dataObjectId) : execEngine(lastLibraryId, calculationLibrary, inData);
|
|
|
- currentResult.put("execTime",System.currentTimeMillis()-beginTime);
|
|
|
+ currentResult.put("execTime", System.currentTimeMillis() - beginTime);
|
|
|
beginTime = System.currentTimeMillis();
|
|
|
|
|
|
setServiceErrorCount(lastLibraryId, Objects.nonNull(currentResult) && currentResult.containsKey("code") ? currentResult.get("code").toString() : "0");//依据返回的code进行连续错误计数和重置
|
|
@@ -252,8 +293,8 @@ public class DataProcess {//数据处理对象
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- }catch (Exception e){
|
|
|
- System.out.println("execCalultion: 算法执行异常: " +LogUtils.getException(e) );
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("execCalultion: 算法执行异常: " + LogUtils.getException(e));
|
|
|
}
|
|
|
returnData.put("library_id", lastLibraryId);
|
|
|
returnData.put("preData", preData);
|
|
@@ -283,11 +324,11 @@ public class DataProcess {//数据处理对象
|
|
|
Map<String, Object> paramValue = new HashMap<>();
|
|
|
for (String key : parmaNames.keySet()) {//理论上此处最多单个key是list[],如果存在多个list[]则应开启迪卡乘积
|
|
|
Object currentData = dataSubscription(calcAllData, key, currentCalMap);//获取数据
|
|
|
- paramValue.put(currentCalMap.get("library_type").toString().equals("2")?parmaNames.get(key):key, currentData);
|
|
|
+ paramValue.put(currentCalMap.get("library_type").toString().equals("2") ? parmaNames.get(key) : key, currentData);
|
|
|
}
|
|
|
Map<String, Object> stringObjectMap = currentEngin.execScript(paramValue);
|
|
|
return stringObjectMap;
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
return processFail("创建引擎失败".concat(LogUtils.getException(e)), library_id);
|
|
|
}
|
|
|
}
|
|
@@ -332,7 +373,7 @@ public class DataProcess {//数据处理对象
|
|
|
return myDbHelper.generalProcess(tempCalcInfo, tempDBPrams, dataObjectId, calcData.get(0));//调用表名方式执行事件
|
|
|
}
|
|
|
return myDbHelper.generalProcess(calculationLibrary, tempDBPrams, dataObjectId, calcData.get(0));
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
return processFail("数据库执行失败".concat(LogUtils.getException(e)), library_id);
|
|
|
}
|
|
|
}
|
|
@@ -391,9 +432,9 @@ public class DataProcess {//数据处理对象
|
|
|
: returnData)));
|
|
|
}
|
|
|
return returnData;
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
System.out.println("数据订阅异常: ".concat(LogUtils.getException(e)));
|
|
|
- return null;
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
}
|