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

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接口类 * 致远OA接口类
*
* @author 👻👻👻👻👻👻👻👻👻👻 gjh * @author 👻👻👻👻👻👻👻👻👻👻 gjh
* @version 1.0 * @version 1.0
* @content * @content
@ -24,7 +25,6 @@ public interface ISeeYonInterFace {
JsonResultEntity thirdInterfaceSend(JSONObject requestData); JsonResultEntity thirdInterfaceSend(JSONObject requestData);
/*** /***
* @Content: 提供给OA的标准接口方法包含参数 entity 为OA 的data信息 , eventType 为事件类型 * @Content: 提供给OA的标准接口方法包含参数 entity 为OA 的data信息 , eventType 为事件类型
* @Author 👻👻👻👻👻👻👻👻 gjh * @Author 👻👻👻👻👻👻👻👻 gjh
@ -59,13 +59,16 @@ public interface ISeeYonInterFace {
/** /**
* seeyon流程事件监听前置方法绑定数据源 * seeyon流程事件监听前置方法绑定数据源
*
* @param sysExtensionApi * @param sysExtensionApi
* @return * @return
* @throws Exception * @throws Exception
*/ */
SysExtensionApiEntity colEventPre(SysExtensionApiEntity sysExtensionApi) throws Exception; SysExtensionApiEntity colEventPre(SysExtensionApiEntity sysExtensionApi) throws Exception;
/** /**
* seeyon流程事件监听 * seeyon流程事件监听
*
* @param jsonObject * @param jsonObject
* @return * @return
* @throws Exception * @throws Exception
@ -74,17 +77,18 @@ public interface ISeeYonInterFace {
/** /**
* seeyon流程事件监听后置方法调用三方接口 * seeyon流程事件监听后置方法调用三方接口
*
* @param jsonStr * @param jsonStr
* @param formAppId * @param formAppId
* @param eventType * @param eventType
* @return * @return
* @throws Exception * @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; JsonResultEntity chengeBody(JSONObject jsonObject) throws Exception;
SysExtensionApiEntity chengeBodySetPlug(SysExtensionApiEntity entity); 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.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.map.MapBuilder;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
@ -30,6 +29,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -52,14 +52,30 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
private static final String sendUrl = "http://60.204.152.210/seeyon/"; private static final String sendUrl = "http://60.204.152.210/seeyon/";
//速网esb地址 //速网esb地址
private static final String baseUrl = "http://hzya.ufyct.com:9067/kangarooDataCenter/entranceController/externalCallInterface"; 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 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 ,"); eventTypeBuffer.append("发起前事件 onBeforeStart ,");
@ -77,24 +93,6 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
eventTypeBuffer.append("取回事件 onTakeBack,"); 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:发起无流程表单接口实现 * @Content:发起无流程表单接口实现
* @Author 👻👻👻👻👻👻👻👻 gjh * @Author 👻👻👻👻👻👻👻👻 gjh
@ -225,73 +223,74 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
//formApp 最好过滤一下 //formApp 最好过滤一下
String result = null; JsonResultEntity result = null;
try { try {
//流程事件处理 //流程事件处理
result = colEventPost(jsonStr, formApp, eventType); result = colEventPost(jsonStr, formApp, eventType);
} catch (Exception e) { } catch (Exception e) {
return BaseResult.getFailureMessageEntity("传递失败", e.getMessage()); return BaseResult.getFailureMessageEntity("传递失败", e.getMessage());
} }
try { return result;
/** 根据事件类型处理相关事件*/ // try {
switch (eventType) { // /** 根据事件类型处理相关事件*/
/** 发起前事件*/ // switch (eventType) {
case "onBeforeStart": // /** 发起前事件*/
break; // case "onBeforeStart":
/** 发起事件*/ // break;
case "onStart": // /** 发起事件*/
//流程发起 新增grpu8单据 // case "onStart":
break; // //流程发起 新增grpu8单据
/** 终止前事件*/ // break;
case "onBeforeStop": // /** 终止前事件*/
break; // case "onBeforeStop":
/** 终止事件*/ // break;
case "onStop": // /** 终止事件*/
//流程终止更新grpu8单据 // case "onStop":
break; // //流程终止更新grpu8单据
/** 撤销前事件*/ // break;
case "onBeforeCancel": // /** 撤销前事件*/
break; // case "onBeforeCancel":
/** 撤销事件*/ // break;
case "onCancel": // /** 撤销事件*/
//流程撤销更新grpu8单据 // case "onCancel":
break; // //流程撤销更新grpu8单据
/** 结束事件*/ // break;
case "onProcessFinished": // /** 结束事件*/
break; // case "onProcessFinished":
/** 处理前事件*/ // break;
case "onBeforeFinishWorkitem": // /** 处理前事件*/
/** 根据form处理相关业务表单的数据*/ // case "onBeforeFinishWorkitem":
switch (formApp) { // /** 根据form处理相关业务表单的数据*/
case "abc123": // switch (formApp) {
break; // case "abc123":
default: // break;
return BaseResult.getFailureMessageEntity("未匹配到表单当前formID" + formApp, ""); // default:
} // return BaseResult.getFailureMessageEntity("未匹配到表单当前formID" + formApp, "");
break; // }
/** 处理事件*/ // break;
case "onFinishWorkitem": // /** 处理事件*/
break; // case "onFinishWorkitem":
/** 回退前事件*/ // break;
case "onBeforeStepBack": // /** 回退前事件*/
break; // case "onBeforeStepBack":
/** 回退事件*/ // break;
case "onStepBack": // /** 回退事件*/
break; // case "onStepBack":
/** 取回前事件*/ // break;
case "onBeforeTakeBack": // /** 取回前事件*/
break; // case "onBeforeTakeBack":
/** 取回事件*/ // break;
case "onTakeBack": // /** 取回事件*/
break; // case "onTakeBack":
default: // break;
// throw new RuntimeException("传入了非法事件类型!请参照:" + eventTypeBuffer.toString()); // default:
return BaseResult.getFailureMessageEntity("传入了非法事件类型!请参照:" + eventTypeBuffer.toString(), "", ""); //// throw new RuntimeException("传入了非法事件类型!请参照:" + eventTypeBuffer.toString());
} // return BaseResult.getFailureMessageEntity("传入了非法事件类型!请参照:" + eventTypeBuffer.toString(), "", "");
return BaseResult.getSuccessMessageEntity("传递成功", result); // }
}catch (Exception e){ // return BaseResult.getSuccessMessageEntity("传递成功", result);
return BaseResult.getFailureMessageEntity("传递失败",e.getMessage()); // }catch (Exception e){
} // return BaseResult.getFailureMessageEntity("传递失败",e.getMessage());
// }
} }
@ -414,6 +413,7 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
/** /**
* seeyon流程事件监听前置方法绑定数据源 * seeyon流程事件监听前置方法绑定数据源
*
* @param entity * @param entity
* @return * @return
* @throws Exception * @throws Exception
@ -482,7 +482,7 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
* @throws Exception * @throws Exception
*/ */
@Override @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)) { if (StrUtil.isNotEmpty(jsonStr) && StrUtil.isNotEmpty(formAppId) && StrUtil.isNotEmpty(eventType)) {
SysApplicationApiEntity sysApplicationApiEntity = new SysApplicationApiEntity(); SysApplicationApiEntity sysApplicationApiEntity = new SysApplicationApiEntity();
sysApplicationApiEntity.setHeaderIn(formAppId + "_" + eventType); sysApplicationApiEntity.setHeaderIn(formAppId + "_" + eventType);
@ -492,16 +492,51 @@ public class SeeYonInterFaceImpl implements ISeeYonInterFace {
throw new BaseSystemException("根据formID" + formAppId + "查询出多条数据"); throw new BaseSystemException("根据formID" + formAppId + "查询出多条数据");
} }
SysApplicationApiEntity sysApp = applist.get(0); SysApplicationApiEntity sysApp = applist.get(0);
Map<String, String> headerMap = MapBuilder.<String, String>create(true) JSONArray headerArray = JSONArray.parseArray(sysApp.getHeaderIn());
.put("apiCode", String.valueOf(sysApp.getApiCode())) if (null != headerArray && headerArray.size() > 0) {
//这里用中台做为发送方 String plugId = null;
.put("publicKey","ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj") for (int i = 0; i < headerArray.size(); i++) {
.put("secretKey","fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=") JSONObject querys = headerArray.getJSONObject(i);
.put("appId",String.valueOf(sysApp.getAppCode())) //query 只有基本类型不用循环判断下级
.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); String parameterName = querys.getString("parameterName");
return body; 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; return null;