代码中调用botp规则来生成目标单据,并建立 上查下查关系的方法:
protected void callBotpService(Context ctx, String botpName,MaterialRequestBillInfo billInfo, List entryIds) throws BOSException, BTPException, EASBizException {
//自动生成XX单据
IBOTMapping botFac = BOTMappingFactory.getLocalInstance(ctx);
BOTMappingInfo botInfo = null;
BOTMappingCollection botCol = botFac.getBOTMappingCollection("select id,srcEntityname,destentityName where name='"+botpName+"' and extRule.isEffected=1 ");
if(botCol.size()==1){
botInfo = botCol.get(0);
}else{
throw new BOSException("BOTP("+botpName+")不存在或未启用!");
}
IBTPManager iBTPManager = BTPManagerFactory.getLocalInstance(ctx);
BTPTransformResult btpResult = iBTPManager.transformForBotp(new String[] { billInfo.getId().toString() }, new String[] { "entry" }, entryIds, null, botInfo.getDestEntityName(),
new ObjectUuidPK(botInfo.getId().toString()),botInfo.getSrcEntityName());
if (btpResult.getBills().size()<=0) {
return;
}
BOTRelationCollection relations = btpResult.getBOTRelationCollection();
Map map = getMapByRelation(relations);
for (int i = 0; i < btpResult.getBills().size(); i++) {
IObjectValue destBillInfo = btpResult.getBills().getObject(i);
CoreBillBaseInfo destBill = (CoreBillBaseInfo) destBillInfo;
BOTRelationCollection botrelationcollection =(BOTRelationCollection)map.get(destBill.getId().toString());
iBTPManager.saveRelations(destBill, botrelationcollection);
}
}
public Map getMapByRelation(BOTRelationCollection relations) {
Map map = new HashMap();
for (int i = 0; i < relations.size(); i++) {
BOTRelationInfo relationInfo = relations.get(i);
String oid = relationInfo.getDestObjectID();
if (map.get(oid) != null) {
BOTRelationCollection botrelationcollection=(BOTRelationCollection) map.get(oid);
botrelationcollection.add(relationInfo);
map.put(oid, botrelationcollection);
} else {
BOTRelationCollection botrelationcollection = new BOTRelationCollection();
botrelationcollection.add(relationInfo);
map.put(oid, botrelationcollection);
}
}
return map;
参考语句:insert into T_BOT_Relation(fid,fsrcEntityID,fdestEntityID,fsrcObjectID,fdestObjectID,foperatorID,fBOTMappingID,fisEffected,ftype)
values(newbosid('59302EC6'),'C48A423A','CC3E933B','iMsAAAAHsMHEikI6','iMsAAAAHsOTMPpM7','user','6a7669e6-0108-1000-e000-2136c0a812fd045122C4',1,0)
protected void callBotpService(Context ctx, String botpName,MaterialRequestBillInfo billInfo, List entryIds) throws BOSException, BTPException, EASBizException {
//自动生成XX单据
IBOTMapping botFac = BOTMappingFactory.getLocalInstance(ctx);
BOTMappingInfo botInfo = null;
BOTMappingCollection botCol = botFac.getBOTMappingCollection("select id,srcEntityname,destentityName where name='"+botpName+"' and extRule.isEffected=1 ");
if(botCol.size()==1){
botInfo = botCol.get(0);
}else{
throw new BOSException("BOTP("+botpName+")不存在或未启用!");
}
IBTPManager iBTPManager = BTPManagerFactory.getLocalInstance(ctx);
BTPTransformResult btpResult = iBTPManager.transformForBotp(new String[] { billInfo.getId().toString() }, new String[] { "entry" }, entryIds, null, botInfo.getDestEntityName(),
new ObjectUuidPK(botInfo.getId().toString()),botInfo.getSrcEntityName());
if (btpResult.getBills().size()<=0) {
return;
}
BOTRelationCollection relations = btpResult.getBOTRelationCollection();
Map map = getMapByRelation(relations);
for (int i = 0; i < btpResult.getBills().size(); i++) {
IObjectValue destBillInfo = btpResult.getBills().getObject(i);
CoreBillBaseInfo destBill = (CoreBillBaseInfo) destBillInfo;
BOTRelationCollection botrelationcollection =(BOTRelationCollection)map.get(destBill.getId().toString());
iBTPManager.saveRelations(destBill, botrelationcollection);
}
}
public Map getMapByRelation(BOTRelationCollection relations) {
Map map = new HashMap();
for (int i = 0; i < relations.size(); i++) {
BOTRelationInfo relationInfo = relations.get(i);
String oid = relationInfo.getDestObjectID();
if (map.get(oid) != null) {
BOTRelationCollection botrelationcollection=(BOTRelationCollection) map.get(oid);
botrelationcollection.add(relationInfo);
map.put(oid, botrelationcollection);
} else {
BOTRelationCollection botrelationcollection = new BOTRelationCollection();
botrelationcollection.add(relationInfo);
map.put(oid, botrelationcollection);
}
}
return map;
}
botp关系对照表:
关联关系表头:实体(BOTRelation)表(T_BOT_Relation) | |||
字段 | 别名 | 参考值 | 描述 |
srcEntityID | 源实体BosType | BFBCAD51 | bosType |
destEntityID | 目标实体BosType | 500AB75E | bosType |
srcObjectID | 源对象ID | kcYAAAIQ0ui/vK1R | id |
destObjectID | 目标对象ID | rV/n+mBsQcW1681XLqJCelAKt14= | id |
date | 转换日期 | 2013/12/300:00:00 | 当前日期 |
operatorID | 操作ID | 87212 | (当前人的名称编号都可以) |
relationEntries | 关系分录 | 对应分录,每条分录都对一个分录规则 | |
BOTMappingID | 转换规则id | jxIXJwEREADgAE3AfwAAAQRRIsQ= | id(实体:BOTMapping 表:T_BOT_Mapping)botp规则的id |
isEffected | 是否生效 | 1 | |
type | 类型 | 0 |
参考语句:insert into T_BOT_Relation(fid,fsrcEntityID,fdestEntityID,fsrcObjectID,fdestObjectID,foperatorID,fBOTMappingID,fisEffected,ftype)
values(newbosid('59302EC6'),'C48A423A','CC3E933B','iMsAAAAHsMHEikI6','iMsAAAAHsOTMPpM7','user','6a7669e6-0108-1000-e000-2136c0a812fd045122C4',1,0)
botp关系对照分录表:
关联关系分录:实体(BOTRelationEntry)表(T_BOT_RelationEntry) | |||
字段 | 别名 | 参考值 | 描述 |
srcObjectID | 源对象ID | kcYAAAIQ0ui/vK1R | 表头记录的源对象ID |
destObjectID | 目标对象ID | rV/n+mBsQcW1681XLqJCelAKt14= | 表头记录的目标对象ID |
srcEntryID | 源分录ID | kcYAAAIQ0ul6YBWh | 记录源分录对象ID |
destEntryID | 目标分录ID | eV3H6QkzQpuenoWSZNxcUhF3S7Q= | 记录目标分录对象ID |
srcEntryPropName | 源分录属性名 | __src.entry | 可为空 |
destEntryPropName | 目标分录属性名 | __dest.entry | 可为空 |
srcPropertyName | 源属性名 | 为空即可 | |
destPropertyName | 目标属性名 | id | 统一id即可 |
value | 值 | 为空即可 | |
relation | 单头id | wWqp5eBTTnaYUcZP4AtDZFkwLsY= | 记录单头id |