二开下推
public Object doCmd(DefaultContext context, ArrayList<Object> paras) throws Throwable { String IDs = TypeConvertor.toString(paras.get(0)); // 指定的订单ID,用逗号分割 Boolean merge = TypeConvertor.toBoolean(paras.get(1)); //是否跨物料合并 IMetaFactory metaFactory = context.getVE().getMetaFactory(); MetaDataObject mo = metaFactory.getDataObject("LRP_WMTx"); // 首先读取出库订单并将单据直接下推 DefaultContext ncontext = new DefaultContext(context); LoadData l = new LoadData("LRP_OutboundNotice", OID); Document srcdoc = l.load(ncontext, null); MidDataMapUtil Util = new MidDataMapUtil(); Document tgtDoc = Util.mapWithoutSave(ncontext, "OutboundNotice-Tx201", srcdoc, ""); DataTable dtHead = tgtDoc.get("LRP_WMTx_H"); DataTable dtDetail = tgtDoc.get("LRP_WMTx_L"); // 将生成的单据保存 ncontext = new DefaultContext(context); SaveData save = new SaveData(mo, null, tgtDoc); save.save(ncontext); return result; }
二开下推的解题思路:
根据参数拿出当前环境下的OID
另置环境DefaultContext nctx=new DefaultContext(context);
根据LoadData l=new LoadData("数据对象标识Key",OID);
获取上游单据数据Document srcdoc=l.load(nctx,null);
获取下推工具类MidDataMapUtil Util=new MidDataMapUtil();
下推操作Document tgtdoc=Util.mapwithoutSave(nctx,'数据映射',srcdoc,'');
保存 MetaDataObject mo=ctx.getVE().getMetaFactory()..getDataObject("LRP_WMTx");
nctx=new DefaultContext(ctx);
SaveData save=new SavaData(mo,null,tgtdoc);
save.save(nctx);