botp生成目标数据,并建立上查下查关系

来源:互联网 发布:ehr人力资源软件 编辑:程序博客网 时间:2024/06/06 02:24
代码中调用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;

    }


botp关系对照表:

关联关系表头:实体(BOTRelation)表(T_BOT_Relation)字段别名参考值描述srcEntityID源实体BosTypeBFBCAD51bosTypedestEntityID目标实体BosType500AB75EbosTypesrcObjectID源对象IDkcYAAAIQ0ui/vK1RiddestObjectID目标对象IDrV/n+mBsQcW1681XLqJCelAKt14=iddate转换日期2013/12/300:00:00当前日期operatorID操作ID87212(当前人的名称编号都可以)relationEntries关系分录对应分录,每条分录都对一个分录规则BOTMappingID转换规则idjxIXJwEREADgAE3AfwAAAQRRIsQ=id(实体:BOTMapping
表:T_BOT_Mapping)botp规则的idisEffected是否生效1type类型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源对象IDkcYAAAIQ0ui/vK1R表头记录的源对象IDdestObjectID目标对象IDrV/n+mBsQcW1681XLqJCelAKt14=表头记录的目标对象IDsrcEntryID源分录IDkcYAAAIQ0ul6YBWh记录源分录对象IDdestEntryID目标分录IDeV3H6QkzQpuenoWSZNxcUhF3S7Q=记录目标分录对象IDsrcEntryPropName源分录属性名__src.entry可为空destEntryPropName目标分录属性名__dest.entry可为空srcPropertyName源属性名为空即可destPropertyName目标属性名id统一id即可value值为空即可relation单头idwWqp5eBTTnaYUcZP4AtDZFkwLsY=记录单头id

原创粉丝点击