摘录自PfUtilClient类,具体上下文可参考该类

前台根据单据类型编码获取节点编号
String funNode = PfUIDataCache.getBillType(new BillTypeCacheKey().buildBilltype(context.getSrcBillType()).buildPkGroup(context.getPk_group())).getNodecode();
IPfExchangeService exchangeService=NCLocator.getInstance().lookup(IPfExchangeService.class);
//根据来源单据类型,目的单据类型获取最合适的VO转换规则
ExchangeVO changeVO=exchangeService.queryMostSuitableExchangeVO(context.getSrcBillType(),context.getCurrBilltype(), null, PfUtilUITools.getLoginGroup(), null);
if (changeVO != null) {
src_qrytemplate = changeVO.getSrc_qrytemplate();//获取来源单据的查询模板
src_qrytemplate = src_qrytemplate == null ? null : src_qrytemplate.trim();
src_billui = changeVO.getSrc_billui();//获取来源单据的界面UI
src_nodekey = changeVO.getSrc_nodekey();//获取来源单据的节点编号
}
// a.获取来源单据的查询对话框,即为m_condition赋值
IBillReferQuery qcDLG = null;
if (StringUtil.isEmptyWithTrim(src_qrytemplate)) {
Logger.debug("使用来源单据类型对应节点使用的查询模板对话框");
src_qrytemplate = PfUtilUITools.getTemplateId(ITemplateStyle.queryTemplate, context.getPk_group(),
funNode, context.getUserId(), src_nodekey);
qcDLG = setConditionClient(src_qrytemplate, context.getParent(), context.getUserId(), funNode, context.getPk_group());
} else if (src_qrytemplate.startsWith("<")) {
Logger.debug("使用产品组定制的来源单据查询对话框");
src_qrytemplate = src_qrytemplate.substring(1, src_qrytemplate.length() - 1);
qcDLG = loadUserQuery(context.getParent(), src_qrytemplate, context.getPk_group(), context.getUserId(), funNode,
context.getCurrBilltype(), context.getSrcBillType(), src_nodekey, context.getUserObj());
} else {
Logger.debug("使用注册的查询模板的查询对话框");
qcDLG = setConditionClient(src_qrytemplate, context.getParent(), context.getUserId(), funNode, context.getPk_group());
}
//给查询对话框设置业务类型,asked by scm-puqh
if(context.getBusiTypes()!= null && qcDLG instanceof IBillReferQueryWithBusitype)
((IBillReferQueryWithBusitype)qcDLG).setBusitypes(context.getBusiTypes());
//给查询对话框设置交易类型,用于过滤上游单据,asked by scm-puqh
if(context.getTransTypes()!= null && qcDLG instanceof IBillReferQueryWithTranstype)
((IBillReferQueryWithTranstype)qcDLG).setTranstypes(context.getTransTypes());
if (context.getSrcBillId() == null) {
//b.显示来源单据的查询对话框
if (qcDLG.showModal() == UIDialog.ID_OK) {
// c.显示来源单据,并进行选择
refBillSource(context.getPk_group(), funNode, context.getUserId(), context.getCurrBilltype(), context.getParent(), context.getUserObj(),
context.getSrcBillType(), src_qrytemplate, src_billui, src_nodekey, null, qcDLG);
} else {
m_isOk = false;
return;
}
} else {
//b'.直接显示来源单据
refBillSource(context.getPk_group(), funNode, context.getUserId(), context.getCurrBilltype(), context.getParent(), context.getUserObj(), context.getSrcBillType(),
src_qrytemplate, src_billui, src_nodekey, context.getSrcBillId(), qcDLG);
return;
}

生成下游单据后,回写上游单据累计执行量,参考

public void process(BillVO[] vos) {
ItemKeyMapping mapping = new ItemKeyMapping();
mapping.setNnumKey("nnum");//设置要回写的数量-调拨订单数量
BillRewriter tool = new BillRewriter(mapping);
tool.addSRCHeadClazz(POBillType.PrayBill.getCode(),
PraybillHeaderVO.class);
tool.addSRCItemClazz(POBillType.PrayBill.getCode(),
PraybillItemVO.class);
//Map<String, List<RewritePara>> paraIndex = tool.splitForDelete(vos);//根据要删除的单据实体,组织回写参数
//Map<String, List<RewritePara>> paraIndex = tool.splitForInsert(vos);//根据要新增的单据实体,组织回写参数
Map<String, List<RewritePara>> paraIndex = tool.splitForUpdate(newBills,
originBills);//根据要修改的单据实体,组织回写参数
List<RewritePara> paraList = (List<RewritePara>) paraIndex
.get(POBillType.PrayBill.getCode());
if ((paraList != null) && (paraList.size() > 0)) {
M20For5XService service = new M20For5XService();
service.rewriteTransNum(paraList);
}
}