调整致远插件调用方式,以后致远流程事件统一通过插件处理

This commit is contained in:
476474485@qq.com 2025-02-28 16:12:45 +08:00
parent 5d45dd740e
commit 012d7adbc6
2 changed files with 207 additions and 168 deletions

View File

@ -6,6 +6,7 @@ import com.hzya.frame.web.entity.JsonResultEntity;
/**
* 致远OA接口类
*
* @author 👻👻👻👻👻👻👻👻👻👻 gjh
* @version 1.0
* @content
@ -24,7 +25,6 @@ public interface ISeeYonInterFace {
JsonResultEntity thirdInterfaceSend(JSONObject requestData);
/***
* @Content: 提供给OA的标准接口方法包含参数 entity 为OA 的data信息 , eventType 为事件类型
* @Author 👻👻👻👻👻👻👻👻 gjh
@ -59,13 +59,16 @@ public interface ISeeYonInterFace {
/**
* seeyon流程事件监听前置方法绑定数据源
*
* @param sysExtensionApi
* @return
* @throws Exception
*/
SysExtensionApiEntity colEventPre(SysExtensionApiEntity sysExtensionApi) throws Exception;
/**
* seeyon流程事件监听
*
* @param jsonObject
* @return
* @throws Exception
@ -74,17 +77,18 @@ public interface ISeeYonInterFace {
/**
* seeyon流程事件监听后置方法调用三方接口
*
* @param jsonStr
* @param formAppId
* @param eventType
* @return
* @throws Exception
*/
String colEventPost(String jsonStr,String formAppId,String eventType)throws Exception;
JsonResultEntity colEventPost(String jsonStr, String formAppId, String eventType) throws Exception;
JsonResultEntity chengeBody(JSONObject jsonObject) throws Exception;
SysExtensionApiEntity chengeBodySetPlug(SysExtensionApiEntity entity);
}

View File

@ -2,7 +2,6 @@ package com.hzya.frame.seeyon.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.map.MapBuilder;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
@ -30,6 +29,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
@ -52,14 +52,30 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
private static final String sendUrl = "http://60.204.152.210/seeyon/";
//速网esb地址
private static final String baseUrl = "http://hzya.ufyct.com:9067/kangarooDataCenter/entranceController/externalCallInterface";
@Resource
private ISysApplicationDatabaseDao sysApplicationDatabaseDao;
@Autowired
private ISysApplicationApiService sysApplicationApiService;
/**
* 定义所支持的事件静态代码块
*/
private static final StringBuffer eventTypeBuffer = new StringBuffer();
//基础档案类型
private final String ARCHIVESTYPE = "archives";
//流程表单类型
private final String FLOWTYPE = "flow";
//创建基础档案
private final String CREATEARCHIVES = "create";
//更新基础档案
private final String UPDATEARCHIVES = "update";
//创建基础档案
private final String CREATEARCHIVESURL = "rest/form/import/";
//创建基础档案
private final String UPDATEARCHIVESURL = "rest/form/update";
@Resource
private ISysApplicationDatabaseDao sysApplicationDatabaseDao;
@Autowired
private ISysApplicationApiService sysApplicationApiService;
@Resource
private ISeeYonInterFaceDao seeYonInterFaceDao;
//上一次同步时间
private final String LAST_SYNCHRONISED_TIME = "";
{
eventTypeBuffer.append("发起前事件 onBeforeStart ,");
@ -77,24 +93,6 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
eventTypeBuffer.append("取回事件 onTakeBack,");
}
//基础档案类型
private final String ARCHIVESTYPE = "archives";
//流程表单类型
private final String FLOWTYPE = "flow";
//创建基础档案
private final String CREATEARCHIVES = "create";
//更新基础档案
private final String UPDATEARCHIVES = "update";
//创建基础档案
private final String CREATEARCHIVESURL = "rest/form/import/";
//创建基础档案
private final String UPDATEARCHIVESURL = "rest/form/update";
@Resource
private ISeeYonInterFaceDao seeYonInterFaceDao;
//上一次同步时间
private String LAST_SYNCHRONISED_TIME = "";
/****
* @Content:发起无流程表单接口实现
* @Author 👻👻👻👻👻👻👻👻 gjh
@ -225,73 +223,74 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
//formApp 最好过滤一下
String result = null;
JsonResultEntity result = null;
try {
//流程事件处理
result = colEventPost(jsonStr, formApp, eventType);
} catch (Exception e) {
return BaseResult.getFailureMessageEntity("传递失败", e.getMessage());
}
try {
/** 根据事件类型处理相关事件*/
switch (eventType) {
/** 发起前事件*/
case "onBeforeStart":
break;
/** 发起事件*/
case "onStart":
//流程发起 新增grpu8单据
break;
/** 终止前事件*/
case "onBeforeStop":
break;
/** 终止事件*/
case "onStop":
//流程终止更新grpu8单据
break;
/** 撤销前事件*/
case "onBeforeCancel":
break;
/** 撤销事件*/
case "onCancel":
//流程撤销更新grpu8单据
break;
/** 结束事件*/
case "onProcessFinished":
break;
/** 处理前事件*/
case "onBeforeFinishWorkitem":
/** 根据form处理相关业务表单的数据*/
switch (formApp) {
case "abc123":
break;
default:
return BaseResult.getFailureMessageEntity("未匹配到表单当前formID" + formApp, "");
}
break;
/** 处理事件*/
case "onFinishWorkitem":
break;
/** 回退前事件*/
case "onBeforeStepBack":
break;
/** 回退事件*/
case "onStepBack":
break;
/** 取回前事件*/
case "onBeforeTakeBack":
break;
/** 取回事件*/
case "onTakeBack":
break;
default:
// throw new RuntimeException("传入了非法事件类型!请参照:" + eventTypeBuffer.toString());
return BaseResult.getFailureMessageEntity("传入了非法事件类型!请参照:" + eventTypeBuffer.toString(), "", "");
}
return BaseResult.getSuccessMessageEntity("传递成功", result);
}catch (Exception e){
return BaseResult.getFailureMessageEntity("传递失败",e.getMessage());
}
return result;
// try {
// /** 根据事件类型处理相关事件*/
// switch (eventType) {
// /** 发起前事件*/
// case "onBeforeStart":
// break;
// /** 发起事件*/
// case "onStart":
// //流程发起 新增grpu8单据
// break;
// /** 终止前事件*/
// case "onBeforeStop":
// break;
// /** 终止事件*/
// case "onStop":
// //流程终止更新grpu8单据
// break;
// /** 撤销前事件*/
// case "onBeforeCancel":
// break;
// /** 撤销事件*/
// case "onCancel":
// //流程撤销更新grpu8单据
// break;
// /** 结束事件*/
// case "onProcessFinished":
// break;
// /** 处理前事件*/
// case "onBeforeFinishWorkitem":
// /** 根据form处理相关业务表单的数据*/
// switch (formApp) {
// case "abc123":
// break;
// default:
// return BaseResult.getFailureMessageEntity("未匹配到表单当前formID" + formApp, "");
// }
// break;
// /** 处理事件*/
// case "onFinishWorkitem":
// break;
// /** 回退前事件*/
// case "onBeforeStepBack":
// break;
// /** 回退事件*/
// case "onStepBack":
// break;
// /** 取回前事件*/
// case "onBeforeTakeBack":
// break;
// /** 取回事件*/
// case "onTakeBack":
// break;
// default:
//// throw new RuntimeException("传入了非法事件类型!请参照:" + eventTypeBuffer.toString());
// return BaseResult.getFailureMessageEntity("传入了非法事件类型!请参照:" + eventTypeBuffer.toString(), "", "");
// }
// return BaseResult.getSuccessMessageEntity("传递成功", result);
// }catch (Exception e){
// return BaseResult.getFailureMessageEntity("传递失败",e.getMessage());
// }
}
@ -414,6 +413,7 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
/**
* seeyon流程事件监听前置方法绑定数据源
*
* @param entity
* @return
* @throws Exception
@ -482,7 +482,7 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
* @throws Exception
*/
@Override
public String colEventPost(String jsonStr, String formAppId, String eventType) throws Exception {
public JsonResultEntity colEventPost(String jsonStr, String formAppId, String eventType) throws Exception {
if (StrUtil.isNotEmpty(jsonStr) && StrUtil.isNotEmpty(formAppId) && StrUtil.isNotEmpty(eventType)) {
SysApplicationApiEntity sysApplicationApiEntity = new SysApplicationApiEntity();
sysApplicationApiEntity.setHeaderIn(formAppId + "_" + eventType);
@ -492,16 +492,51 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
throw new BaseSystemException("根据formID" + formAppId + "查询出多条数据");
}
SysApplicationApiEntity sysApp = applist.get(0);
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;
JSONArray headerArray = JSONArray.parseArray(sysApp.getHeaderIn());
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;
}
}
if (null == plugId) {
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 {
//执行业务逻辑代码
result = pluginBaseEntity.executeBusiness(JSON.parseObject(jsonStr));
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;
}
}
return null;