[转]服务端直接调用BOTP

public static void generateDestBill(Context ctx, String srcBosType,
            String destBosType, CoreBillBaseCollection srcBillCollection,
            IObjectPK botpPK) throws Exception {
        IBOTMapping botMapping = BOTMappingFactory.getLocalInstance(ctx);
        CoreBillBaseInfo billInfo = srcBillCollection.get(0);
        BOTMappingInfo botMappingInfo = botMapping.getMapping(billInfo, destBosType, DefineSysEnum.BTP);
        if (botMappingInfo == null) {
            throw new FMException(FMException.NODESTBILL);
        }
        IBTPManager iBTPManager = BTPManagerFactory.getLocalInstance(ctx);
        BTPTransformResult btpResult = null;
        /*String[] ids = new String[srcBillCollection.size()];
        for (int i = 0; i < srcBillCollection.size(); ++i) {
            CoreBaseInfo info = srcBillCollection.get(i);
            ids[i] = info.getId().toString();
        }*/
        btpResult = iBTPManager.transformForBotp(srcBillCollection,destBosType, botpPK);
        IObjectCollection destBillCols = btpResult.getBills();
        BOTRelationCollection botRelationCols = btpResult.getBOTRelationCollection();
        for (int i = 0; i < destBillCols.size(); i++) {
            CoreBillBaseInfo destBillInfo = (CoreBillBaseInfo) destBillCols.getObject(i);
            iBTPManager.submitRelations(destBillInfo, botRelationCols);
        }
    }

参数说明:

1、ctx :服务端上下文

2、srcBosType:源单据的BosType

3、destBosType:目标单据的BosType

4、srcBillCollection:源单据集合,可以批量转换

5、botpPK:要使用的BOTP的PK。

可以通过表T_BOT_Mapping查找到id,将id转换成PK。

select t.fid from T_BOT_Mapping t where t.fname='***',***是botp的名称。

posted @ 2015-06-26 09:38  果然  阅读(504)  评论(0编辑  收藏  举报