主数据下发,重新发送
This commit is contained in:
parent
70a7fe3ff2
commit
2d4b3af64c
|
@ -18,6 +18,7 @@ import com.hzya.frame.sysnew.application.api.dao.ISysApplicationApiDao;
|
|||
import com.hzya.frame.sysnew.application.api.entity.SysApplicationApiEntity;
|
||||
import com.hzya.frame.sysnew.application.dao.ISysApplicationDao;
|
||||
import com.hzya.frame.sysnew.application.entity.SysApplicationEntity;
|
||||
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
|
||||
import com.hzya.frame.sysnew.application.script.dao.ISysApplicationScriptDao;
|
||||
import com.hzya.frame.sysnew.application.script.entity.SysApplicationScriptEntity;
|
||||
import com.hzya.frame.sysnew.grovy.service.IGroovyIntegrationService;
|
||||
|
@ -118,6 +119,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
|
|||
if (null != requestJson) {
|
||||
//如果这个id不为空,说明是重试的
|
||||
String id = requestJson.getString("integration_task_living_details_id");
|
||||
//执行重新发送
|
||||
if (StrUtil.isNotEmpty(id)) {
|
||||
//查询日志表
|
||||
IntegrationTaskLivingDetailsEntity taskDetailEntity = taskLivingDetailsService.get(id);
|
||||
|
@ -298,27 +300,33 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
|
|||
//执行脚本
|
||||
JSONObject groovy = new JSONObject();
|
||||
JSONObject parameterJson = new JSONObject();
|
||||
parameterJson.put("header",apiEntity.getHeaderInValue());
|
||||
//parameterJson.put("body",apiEntity.getBodyIn());
|
||||
parameterJson.put("header",apiEntity.getHeaderIn());
|
||||
parameterJson.put("body",apiEntity.getBodyIn());
|
||||
parameterJson.put("query",apiEntity.getQueryIn());
|
||||
parameterJson.put("data",object);
|
||||
/** head */
|
||||
Map<String, String> header = null;
|
||||
/** query */
|
||||
String querys = null;
|
||||
/** body */
|
||||
String bodys = object.toJSONString();
|
||||
if(scriptEntity != null && scriptEntity.getId() != null ){
|
||||
groovy.put("code",scriptEntity.getScriptCode());
|
||||
groovy.put("className",scriptEntity.getClassName());
|
||||
groovy.put("name",scriptEntity.getScriptName());
|
||||
groovy.put("methodStr",scriptEntity.getScriptData());
|
||||
groovy.put("parameterJson",parameterJson);
|
||||
JSONObject groovyStr = new JSONObject();
|
||||
groovyStr.put("jsonStr",groovy);
|
||||
try {
|
||||
JsonResultEntity jsonResultEntity = groovyIntegrationService.groovyScriptExecution(groovy);
|
||||
if(!jsonResultEntity.isFlag()){
|
||||
taskDetailEntity.setResult("分发脚本转换错误");
|
||||
taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity);
|
||||
return BaseResult.getFailureMessageEntity("分发脚本转换错误");
|
||||
}
|
||||
JSONObject returnGroovy = JSONObject.parseObject(jsonResultEntity.getAttribute().toString());
|
||||
SysExtensionApiEntity jsonResultEntity = groovyIntegrationService.groovyScriptExecution(groovy);
|
||||
header = jsonResultEntity.getHeaders();
|
||||
querys = jsonResultEntity.getQuerys();
|
||||
bodys = jsonResultEntity.getBodys();
|
||||
}catch (Exception e){
|
||||
taskDetailEntity.setResult("分发脚本转换错误");
|
||||
taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity);
|
||||
return BaseResult.getFailureMessageEntity("分发脚本转换错误");
|
||||
//return BaseResult.getFailureMessageEntity("分发脚本转换错误");
|
||||
}
|
||||
}
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
|
@ -326,8 +334,11 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
|
|||
headers.put("secretKey","fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=");
|
||||
headers.put("appId",sysApplicationEntity.getAppId().toString());
|
||||
headers.put("apiCode",apiEntity.getApiCode().toString());
|
||||
if(header != null){
|
||||
headers.putAll(header);
|
||||
}
|
||||
//组装数据发送
|
||||
JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,object.toJSONString());
|
||||
JsonResultEntity jsonResultEntity = sendData(apiEntity,headers,bodys,querys);
|
||||
if(jsonResultEntity.isFlag()){
|
||||
taskDetailEntity.setResult("发送成功");
|
||||
taskLivingDetailsService.saveLogFailToSuccess(taskDetailEntity);
|
||||
|
@ -339,7 +350,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
|
|||
}
|
||||
}
|
||||
}else {
|
||||
//执行正常逻辑
|
||||
//执行正常下发
|
||||
|
||||
|
||||
}
|
||||
|
@ -352,9 +363,12 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
|
|||
return BaseResult.getSuccessMessageEntity("执行成功");
|
||||
}
|
||||
|
||||
private JsonResultEntity sendData(SysApplicationApiEntity applicationApiEntity, Map<String, String> headers ,String bodys ) {
|
||||
private JsonResultEntity sendData(SysApplicationApiEntity applicationApiEntity, Map<String, String> headers ,String bodys ,String querys) {
|
||||
StringBuffer urls = new StringBuffer(url);
|
||||
|
||||
if (querys != null) {
|
||||
urls.append("?");
|
||||
urls.append(querys);
|
||||
}
|
||||
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
||||
// HttpClient
|
||||
CloseableHttpClient closeableHttpClient = httpClientBuilder.disableCookieManagement().build();
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
a.id,
|
||||
a.api_status,
|
||||
b.name as app_name,
|
||||
b.interfaceAddress as app_url,
|
||||
b.interface_address as app_url,
|
||||
a.app_id,
|
||||
a.catalogue_id,
|
||||
c.name as catalogue_name,
|
||||
|
@ -704,7 +704,7 @@ where id = #{id}
|
|||
<!-- </trim>-->
|
||||
<!-- order by a.sorts asc-->
|
||||
<!-- </select>-->
|
||||
<select id="queryVoList" databaseId="mysql" resultType="com.hzya.frame.sysnew.application.api.entity.SysApplicationApiVo" parameterType="com.hzya.frame.sysnew.application.api.entity.SysApplicationApiEntity">
|
||||
<select id="queryVoList" resultType="com.hzya.frame.sysnew.application.api.entity.SysApplicationApiVo" parameterType="com.hzya.frame.sysnew.application.api.entity.SysApplicationApiEntity">
|
||||
select
|
||||
a.id,
|
||||
a.catalogue_id AS catalogueId,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.hzya.frame.sysnew.grovy.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
|
||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||
|
||||
/**
|
||||
|
@ -21,5 +22,5 @@ public interface IGroovyIntegrationService {
|
|||
* @param jsonObject 请求参数对象
|
||||
* @return com.hzya.frame.web.entity.JsonResultEntity
|
||||
**/
|
||||
JsonResultEntity groovyScriptExecution(JSONObject jsonObject);
|
||||
SysExtensionApiEntity groovyScriptExecution(JSONObject jsonObject);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.hzya.frame.sysnew.grovy.service.impl;
|
|||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
|
||||
import com.hzya.frame.sysnew.grovy.service.IGroovyIntegrationService;
|
||||
import com.hzya.frame.util.GroovyUtil;
|
||||
import com.hzya.frame.web.entity.BaseResult;
|
||||
|
@ -44,8 +45,8 @@ public class GroovyIntegrationServiceImpl implements IGroovyIntegrationService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public JsonResultEntity groovyScriptExecution(JSONObject jsonObject) {
|
||||
public SysExtensionApiEntity groovyScriptExecution(JSONObject jsonObject) {
|
||||
Object object = GroovyUtil.execute(jsonObject);
|
||||
return BaseResult.getSuccessMessageEntity(object);
|
||||
return new SysExtensionApiEntity();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue