金蝶EAS·BOS,附件处理,代码实现附件复制到下游单据

72 篇文章 23 订阅
24 篇文章 6 订阅
/**
 * 附件处理功能工具
 * @author 郭旭
 *
 */
public class AttachHandleFacadeControllerBean extends AbstractAttachHandleFacadeControllerBean {
	
    private static Logger logger = Logger.getLogger("com.kingdee.eas.ric.audit.app.AttachHandleFacadeControllerBean");
    
    /**
     * 附件处理
     * 用于将源单据所包含附件复制到下游单据
     */
    @Override
    protected boolean _attachHandle(Context ctx, IObjectValue sourceBill, IObjectValue bill) throws BOSException, EASBizException {
    	
    	IBoAttchAsso iBoAttchAsso = BoAttchAssoFactory.getLocalInstance(ctx); //附件与业务对象关联接口
    	CoreBaseInfo sourceModel = (CoreBaseInfo) sourceBill; //源单据对象
    	CoreBaseInfo billModel = (CoreBaseInfo) bill; //目标单据对象
    	if(sourceModel.getId() == null || billModel.getId() == null){
    		throw new EASBizException(new NumericExceptionSubItem("099", "附件处理失败!"));
    	}
    	
    	FilterInfo filter = new FilterInfo();
    	filter.getFilterItems().add(new FilterItemInfo("boID", sourceModel.getId()));
    	boolean flag = iBoAttchAsso.exists(filter); //是否存在附件
    	if(!flag) return false; //不存在附件,直接返回
    	
    	EntityViewInfo view = new EntityViewInfo();
    	view.setFilter(filter);
    	BoAttchAssoCollection coll = iBoAttchAsso.getBoAttchAssoCollection(view); //查询源单据所有的附件关联
    	for(int i = 0; i < coll.size(); i++){
    		
    		BoAttchAssoInfo sourceAttch = coll.get(i); //源单据附件
    		BoAttchAssoInfo billAttch = new BoAttchAssoInfo(); //目标单据附件
    		billAttch.setBoID(billModel.getId().toString()); //业务单据ID
    		billAttch.setAssoType(sourceAttch.getAssoType()); //类型
    		billAttch.setAttachment(sourceAttch.getAttachment()); //附件
    		billAttch.setAssoBusObjType(billModel.getBOSType().toString()); //关联业务对象的类型
    		iBoAttchAsso.submit(billAttch); //提交目标单据的附件关联
    		
    	}
    	
	return true;
    	
    }
    
}

  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值