调用插件方法增加数据源、请求头参数
This commit is contained in:
parent
1c9963aab8
commit
2baa228f10
|
@ -38,8 +38,7 @@ public class CbsLogServiceImpl extends BaseService<CbsLogEntity,String> implemen
|
|||
Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private ICbsLogDao cbsLogDao;
|
||||
@Value("${OA.data_source_code:}")
|
||||
private String oa_data_source_code;
|
||||
|
||||
@Autowired
|
||||
public void setCbsLogDao(ICbsLogDao cbsLogDao) {
|
||||
this.cbsLogDao = cbsLogDao;
|
||||
|
@ -84,7 +83,7 @@ public class CbsLogServiceImpl extends BaseService<CbsLogEntity,String> implemen
|
|||
//根据oaid判断是否在日志表中存在,如果存在,则更新,如果不存在,则新增
|
||||
CbsLogEntity cbsLogEntityResend=new CbsLogEntity();
|
||||
cbsLogEntityResend.setOa_id(cbsLogEntity.getOa_id());
|
||||
cbsLogEntityResend.setDataSourceCode(oa_data_source_code);
|
||||
cbsLogEntityResend.setDataSourceCode(cbsLogEntity.getDataSourceCode());
|
||||
List<CbsLogEntity> queryList = query(cbsLogEntityResend);
|
||||
if(CollectionUtils.isEmpty(queryList)){
|
||||
String data = StrUtil.format(getXmlTemplate(),title,pay_company,payee,amount,cbs_apply_code,bill_code,oa_id,tab_name_ch,tab_name_en,pay_state,message,apply_state,successed);
|
||||
|
@ -108,7 +107,7 @@ public class CbsLogServiceImpl extends BaseService<CbsLogEntity,String> implemen
|
|||
logEntity.setApply_state(apply_state);
|
||||
logEntity.setSuccessed(successed);
|
||||
logEntity.setBill_code(cbsLogEntity.getBill_code());
|
||||
logEntity.setDataSourceCode(oa_data_source_code);
|
||||
logEntity.setDataSourceCode(cbsLogEntity.getDataSourceCode());
|
||||
try {
|
||||
update(logEntity);
|
||||
}catch (Exception e){
|
||||
|
|
|
@ -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,55 +496,44 @@ 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("sourceCode",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)
|
||||
|
|
Loading…
Reference in New Issue