流程事件监听调用插件
This commit is contained in:
parent
07401992c6
commit
4cdd7a2625
|
@ -23,6 +23,7 @@ import com.hzya.frame.util.PluginUtils;
|
|||
import com.hzya.frame.web.entity.BaseResult;
|
||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||
import com.hzya.frame.web.exception.BaseSystemException;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -495,64 +496,48 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
|
|||
throw new BaseSystemException("根据formID:" + formAppId + "eventType:"+eventType+"未查询到API配置");
|
||||
}
|
||||
SysApplicationApiEntity sysApp = applist.get(0);
|
||||
//数据源配置
|
||||
SysApplicationDatabaseEntity sysApiDatabase = new SysApplicationDatabaseEntity();
|
||||
sysApiDatabase.setAppId(sysApp.getAppId());
|
||||
List<SysApplicationDatabaseEntity> apiDataBaseList = sysApplicationDatabaseDao.queryDSBase(sysApiDatabase);
|
||||
if (CollectionUtils.isNotEmpty(apiDataBaseList) && apiDataBaseList.size() == 1){
|
||||
sysApiDatabase = apiDataBaseList.get(0);
|
||||
}
|
||||
JSONArray headerArray = JSONArray.parseArray(sysApp.getHeaderIn());
|
||||
Map<String,String> headerMap = new HashMap<>();
|
||||
if (null != headerArray && headerArray.size() > 0) {
|
||||
String plugId = null;
|
||||
for (int i = 0; i < headerArray.size(); i++) {
|
||||
JSONObject querys = headerArray.getJSONObject(i);
|
||||
//query 只有基本类型,不用循环判断下级
|
||||
//判断参数是否有值
|
||||
//获取对象下面的层级数据
|
||||
String parameterName = querys.getString("parameterName");
|
||||
if (null != parameterName && "plugId".equals(parameterName)) {
|
||||
plugId = querys.getString("example");
|
||||
break;
|
||||
}
|
||||
String example = querys.getString("example");
|
||||
headerMap.put(parameterName,example);
|
||||
}
|
||||
if (null == plugId) {
|
||||
if (headerMap.isEmpty()){
|
||||
throw new BaseSystemException("根据formID:" + formAppId + "未获取到head参数");
|
||||
} else {
|
||||
PluginBaseEntity pluginBaseEntity = null;
|
||||
JsonResultEntity result;
|
||||
pluginBaseEntity = PluginUtils.getPluginsById(plugId);
|
||||
if (null == pluginBaseEntity) {
|
||||
throw new BaseSystemException("根据ID获取插件错误!请传入正确的 pluginId");
|
||||
} else {
|
||||
//执行业务逻辑代码
|
||||
JSONObject reqJson = new JSONObject();
|
||||
reqJson.put("jsonStr",jsonStr);
|
||||
reqJson.put("formAppId",formAppId);
|
||||
reqJson.put("eventType",eventType);
|
||||
result = pluginBaseEntity.executeBusiness(reqJson);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PluginBaseEntity pluginBaseEntity = PluginUtils.getPluginsById(headerMap.get("plugId"));
|
||||
if (null == pluginBaseEntity) {
|
||||
throw new BaseSystemException("根据ID获取插件错误!请传入正确的 pluginId");
|
||||
}
|
||||
//执行业务逻辑代码
|
||||
JSONObject reqJson = new JSONObject();
|
||||
reqJson.put("jsonStr",jsonStr);
|
||||
reqJson.put("formAppId",formAppId);
|
||||
reqJson.put("eventType",eventType);
|
||||
reqJson.put("headers",JSON.toJSONString(headerMap));
|
||||
reqJson.put("apiDataSourceCode",sysApiDatabase.getSourceCode());
|
||||
JsonResultEntity result = pluginBaseEntity.executeBusiness(reqJson);
|
||||
return result;
|
||||
} else {
|
||||
throw new BaseSystemException("根据formID:" + formAppId + "未获取到head参数");
|
||||
}
|
||||
|
||||
|
||||
// Map<String, String> headerMap = MapBuilder.<String, String>create(true)
|
||||
// .put("apiCode", String.valueOf(sysApp.getApiCode()))
|
||||
// //这里用中台做为发送方
|
||||
// .put("publicKey","ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj")
|
||||
// .put("secretKey","fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")
|
||||
// .put("appId",String.valueOf(sysApp.getAppCode()))
|
||||
// .build();
|
||||
// String body = HttpRequest.post("http://127.0.0.1:10086/kangarooDataCenterV3/entranceController/externalCallInterface").addHeaders(headerMap).body(jsonStr).timeout(60000).execute().body();
|
||||
// logger.info("调用中台返回的参数:{}",body);
|
||||
// return body;
|
||||
}
|
||||
}else{
|
||||
// StrUtil.isNotEmpty(jsonStr) && StrUtil.isNotEmpty(formAppId) && StrUtil.isNotEmpty(eventType)
|
||||
logger.info("jsonStr,formAppId,eventType为空!执行错误"+jsonStr+formAppId+eventType);
|
||||
throw new BaseSystemException("jsonStr,formAppId,eventType为空!执行错误");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonResultEntity chengeBody(JSONObject object) throws Exception {
|
||||
JSONObject jsonstr = object.getJSONObject("jsonStr");
|
||||
|
|
Loading…
Reference in New Issue