根据业务单据ID,获取该单据对应附件管理中的附件集合(多个附件)。
以下示例方法用于前端调用,如需用于后端,需要添加上下文ctx参数以及改变接口实例的获取方式。
/**
* 获取单据对应的所有附件,用于前台
* @param billId 单据主键
*/
public static AttachmentCollection getAttachments(String billId) throws BOSException, EASBizException{
AttachmentCollection attachments = null; //附件集合
IBoAttchAsso iBoAttchAsso = BoAttchAssoFactory.getRemoteInstance(); //附件与业务对象关联接口
EntityViewInfo view = new EntityViewInfo();
FilterInfo filter = new FilterInfo();
filter.getFilterItems().add(new FilterItemInfo("boID", billId));
view.setFilter(filter);
BoAttchAssoCollection coll = iBoAttchAsso.getBoAttchAssoCollection(view); //查询所关联附件
if(VerifyUtil.isNull(coll)){
return attachments;
}
attachments = new AttachmentCollection();
IAttachment iAttachment = AttachmentFactory.getRemoteInstance();
for(int i = 0; i < coll.size(); i++){
BoAttchAssoInfo bo = coll.get(i); //附件关联对象
AttachmentInfo attachment = bo.getAttachment(); //附件对象
attachment = iAttachment.getAttachmentInfo(new ObjectUuidPK(attachment.getId()));
attachments.add(attachment);
}
return attachments;
}