
# 单据转换插件中获取到自定义参数的使用说明
## 1.问题描述
在调用下推服务ConvertServiceHelper#push时,在下推服务参数(PushArgs)中传入自定义参数pushArgs. getCustomParams ().put(key, paramValue);如何在转换插件中,取到这个自定义参数值呢?
## 2.说明
转换插件可以使用 Object paramValue = this.getOption().getVariableValue ("key"); 获取传入的自定义参数值
## 3.代码示例
传入自定义参数:
```java
PushArgs pushArgs= new PushArgs();
pushArgs.getCustomParams().put("billStatus", "已审核");
pushArgs.getCustomParams().put("billNo", "test_0001");
ConvertServiceHelper.push(pushArgs);
```
获取自定义参数:
```java
package kd.bos.form.plugin.botp;
import kd.bos.entity.BillEntityType;
import kd.bos.entity.botp.ConvertOpType;
import kd.bos.entity.botp.ConvertRuleElement;
import kd.bos.entity.botp.plugin.AbstractConvertPlugIn;
import kd.bos.entity.botp.plugin.args.AfterBuildQueryParemeterEventArgs;
import kd.bos.entity.botp.plugin.args.AfterConvertEventArgs;
import kd.bos.entity.botp.plugin.args.AfterCreateLinkEventArgs;
import kd.bos.entity.botp.plugin.args.AfterCreateTargetEventArgs;
import kd.bos.entity.botp.plugin.args.AfterFieldMappingEventArgs;
import kd.bos.entity.botp.plugin.args.AfterGetSourceDataEventArgs;
import kd.bos.entity.botp.plugin.args.BeforeBuildGroupModeEventArgs;
import kd.bos.entity.botp.plugin.args.BeforeBuildRowConditionEventArgs;
import kd.bos.entity.botp.plugin.args.BeforeCreateLinkEventArgs;
import kd.bos.entity.botp.plugin.args.BeforeCreateTargetEventArgs;
import kd.bos.entity.botp.plugin.args.BeforeGetSourceDataEventArgs;
import kd.bos.entity.botp.plugin.args.InitVariableEventArgs;
/**
* 演示单据转换插件事件的触发时机
*
* @author rd_JohnnyDing
*/
public class Test extends AbstractConvertPlugIn {
/**
* 演示如何获取上下文信息
*/
private void getContext() {
// 源单主实体
BillEntityType srcMainType = this.getSrcMainType();
// 目标单主实体
BillEntityType tgtMainType = this.getTgtMainType();
// 转换规则
ConvertRuleElement rule = this.getRule();
// 转换方式:下推、选单
ConvertOpType opType = this.getOpType();
}
/**
* 初始化变量事件
*
* @param e
* @remark 获取上下文信息,构建一些必须的变量
*/
@Override
public void initVariable(InitVariableEventArgs e) {
this.printEventInfo("initVariable", "");
Object paramValue = this.getOption().getVariableValue ("billStatus");
}
/**
* 构建取数参数后事件
*
* @param e
* @remark 添加额外的字段、过滤条件
*/
@Override
public void afterBuildQueryParemeter(AfterBuildQueryParemeterEventArgs e) {
this.printEventInfo("afterBuildQueryParemeter", "");
Object paramValue = this.getOption().getVariableValue ("billStatus");
}
/**
* 编译数据筛选条件前事件
*
* @param e
* @remark 设置忽略规则原生的条件,改用插件定制条件,或者在规则条件基础上,追加定制条件
*/
@Override
public void beforeBuildRowCondition(BeforeBuildRowConditionEventArgs e) {
this.printEventInfo("beforeBuildRowCondition", "");
Object paramValue = this.getOption().getVariableValue ("billStatus");
}
/**
* 取源单数据前事件
*
* @param e
* @remark 修改取数语句、取数条件
*/
@Override
public void beforeGetSourceData(BeforeGetSourceDataEventArgs e) {
this.printEventInfo("beforeGetSourceData", "");
Object paramValue = this.getOption().getVariableValue ("billStatus");
}
/**
* 取源单数据后事件
*
* @param e
* @remark 根据源单数据,获取其他定制的引用数据;也可以替换系统自动获取到的数据
*/
@Override
public void afterGetSourceData(AfterGetSourceDataEventArgs e) {
this.printEventInfo("afterGetSourceData", "");
Object paramValue = this.getOption().getVariableValue ("billStatus");
}
/**
* 构建分单、行合并模式之前事件
*