单据下推部分分录原创
10人赞赏了该文章
5,203次浏览
编辑于2021年06月04日 17:00:11
场景:
某些业务需要下推操作时,只下推符合要求的分录,或者选择部分分录,这里可以使用在列表上打开列表参数,列表插件、单据转换插件实现。
方法1:
(1)列表绑定列表选项参数,默认列表会有一个
(2)开启分录支持被选择参数
(3)选择分录下推
方法2:插件实现,后台下推,
插件代码如下:
package kd.bos.ecos.covert;
import java.util.EventObject;
import java.util.List;
import java.util.Set;
import java.util.List;
import java.util.Set;
import kd.bos.dataentity.utils.StringUtils;
import kd.bos.entity.botp.runtime.ConvertOperationResult;
import kd.bos.entity.botp.runtime.PushArgs;
import kd.bos.entity.datamodel.ListSelectedRow;
import kd.bos.entity.datamodel.ListSelectedRowCollection;
import kd.bos.form.control.events.ItemClickEvent;
import kd.bos.list.BillList;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.metadata.botp.ConvertRuleReader;
import kd.bos.servicehelper.botp.ConvertServiceHelper;
import kd.bos.entity.botp.runtime.ConvertOperationResult;
import kd.bos.entity.botp.runtime.PushArgs;
import kd.bos.entity.datamodel.ListSelectedRow;
import kd.bos.entity.datamodel.ListSelectedRowCollection;
import kd.bos.form.control.events.ItemClickEvent;
import kd.bos.list.BillList;
import kd.bos.list.plugin.AbstractListPlugin;
import kd.bos.metadata.botp.ConvertRuleReader;
import kd.bos.servicehelper.botp.ConvertServiceHelper;
public class BillListCovertPlugin extends AbstractListPlugin {
@Override
public void registerListener(EventObject e) {
this.addItemClickListeners("toolbarap");
}
@Override
public void registerListener(EventObject e) {
this.addItemClickListeners("toolbarap");
}
@Override
public void itemClick(ItemClickEvent evt) {
String key = evt.getItemKey();
// 后台下推
if (StringUtils.equals("kdec_baritemap2", key)) {
PushArgs args = new PushArgs();
//源单单据标识
String sourceEntityNumber = "kdec_twopur_apply";
//目标单单据标识
String targetEntityNumber = "kdec_twopur_order";
args.setSourceEntityNumber(sourceEntityNumber);
args.setTargetEntityNumber(targetEntityNumber);
args.setHasRight(false);
// args.addCustomParam("", "");
//下推后默认保存
args.setAutoSave(true);
// 单据转换规则id
ConvertRuleReader read = new ConvertRuleReader();
List<String> ruleids = read.loadRuleIds(sourceEntityNumber, targetEntityNumber, false);
if (ruleids.size() > 0) {
args.setRuleId(ruleids.get(0));
}
BillList billList = this.getView().getControl("billlistap");
ListSelectedRowCollection rs = billList.getSelectedRows();
//构建新的选择行
ListSelectedRowCollection rows = new ListSelectedRowCollection();
int i = 0;
for (ListSelectedRow listSelectedRow : rs) {
i++;
//只下推前三条分录
if (i > 3)
break;
// 一些逻辑
rows.add(listSelectedRow);
}
args.setSelectedRows(rows);
//是否生成单据转换报告
args.setBuildConvReport(false);
ConvertOperationResult result = ConvertServiceHelper.pushAndSave(args);
//获取目标的id
Set<Object> targetBillIds = result.getTargetBillIds();
}
}
public void itemClick(ItemClickEvent evt) {
String key = evt.getItemKey();
// 后台下推
if (StringUtils.equals("kdec_baritemap2", key)) {
PushArgs args = new PushArgs();
//源单单据标识
String sourceEntityNumber = "kdec_twopur_apply";
//目标单单据标识
String targetEntityNumber = "kdec_twopur_order";
args.setSourceEntityNumber(sourceEntityNumber);
args.setTargetEntityNumber(targetEntityNumber);
args.setHasRight(false);
// args.addCustomParam("", "");
//下推后默认保存
args.setAutoSave(true);
// 单据转换规则id
ConvertRuleReader read = new ConvertRuleReader();
List<String> ruleids = read.loadRuleIds(sourceEntityNumber, targetEntityNumber, false);
if (ruleids.size() > 0) {
args.setRuleId(ruleids.get(0));
}
BillList billList = this.getView().getControl("billlistap");
ListSelectedRowCollection rs = billList.getSelectedRows();
//构建新的选择行
ListSelectedRowCollection rows = new ListSelectedRowCollection();
int i = 0;
for (ListSelectedRow listSelectedRow : rs) {
i++;
//只下推前三条分录
if (i > 3)
break;
// 一些逻辑
rows.add(listSelectedRow);
}
args.setSelectedRows(rows);
//是否生成单据转换报告
args.setBuildConvReport(false);
ConvertOperationResult result = ConvertServiceHelper.pushAndSave(args);
//获取目标的id
Set<Object> targetBillIds = result.getTargetBillIds();
}
}
}
赞 10
10人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!
推荐阅读