代码调用单据转换规则,生成下游单据。
/**
* 调用BOTP生成下游单据,用于后台
* @param ctx 上下文
* @param sourceType 源单类型
* @param destType 目标单据类型
* @param sourceColl 源单集合
* @param botpId 单据转换规则
*
*/
public static void botp(Context ctx, BOSObjectType sourceType, BOSObjectType destType, CoreBillBaseCollection sourceColl, BOSUuid botpId) throws BOSException {
IBOTMapping botMapping = BOTMappingFactory.getLocalInstance(ctx);
CoreBillBaseInfo model = sourceColl.get(0); //源单对象
try {
BOTMappingInfo botp = botMapping.getMapping(model, destType.toString(), DefineSysEnum.BTP);
if (botp == null) {
throw new FMException(FMException.NODESTBILL);
}
IBTPManager botpManager = BTPManagerFactory.getLocalInstance(ctx);
BTPTransformResult btpResult = null;
btpResult = botpManager.transformForBotp(sourceColl, destType.toString(), new ObjectUuidPK(botpId));
IObjectCollection destColl = btpResult.getBills(); //目标单据集合
BOTRelationCollection botRelations = btpResult.getBOTRelationCollection();
for (int i = 0; i < destColl.size(); i++) {
CoreBillBaseInfo destBillInfo = (CoreBillBaseInfo) destColl.getObject(i); //目标单据
botpManager.saveRelations(destBillInfo, botRelations);
}
} catch (Exception e) {
throw new BOSException(e);
}
}