package nc.bs.pub.action;

import java.util.Hashtable;

import nc.bs.framework.common.NCLocator;
import nc.bs.pub.compiler.AbstractCompiler2;
import nc.pubitf.para.ISysInitDAO;
import nc.vo.arap.payable.AggPayableBillVO;
import nc.vo.arap.pub.ArapConstant;
import nc.vo.fipub.exception.ExceptionHandler;
import nc.vo.pub.AggregatedValueObject;
import nc.vo.pub.BusinessException;
import nc.vo.pub.compiler.PfParameterVO;
import nccloud.pubitf.arap.arappub.IArapBillPubUtilService;

public class N_F1_DELETE extends AbstractCompiler2 {
	private Hashtable<String, Object> m_keyHas = null;

	/*
	 * 备注：平台编写规则类 接口执行类
	 */
	public Object runComClass(PfParameterVO paraVo) throws BusinessException {
		try {

			if (paraVo.m_preValueVos == null)
				return null;
			Object obj = null;
			super.m_tmpVo = paraVo;
			// 权限校验
			String actionCode = ArapConstant.DELETE;
			NCLocator.getInstance().lookup(IArapBillPubUtilService.class).interceptorVaildator(paraVo.m_preValueVos, actionCode);
			setParameter("context", paraVo.m_preValueVos);
			obj = runClass("nc.bs.arap.actions.PayablebillDeleteBatchBSAction", "deleteVOs", "&context:nc.vo.pub.AggregatedValueObject[]", paraVo, m_keyHas);
			// 批量操作
			//调用影像状态同步接口 2021-05-18 ll
			nc.pubimpl.payablebill.yx.PayablebillAfterRule rule=new nc.pubimpl.payablebill.yx.PayablebillAfterRule();
			rule.getService((nc.vo.arap.payable.AggPayableBillVO[])getVos());
			
			//add by djy 20220104对于碧优资同步过来的单不能直接删除
			ISysInitDAO InitDAO = NCLocator.getInstance().lookup(ISysInitDAO.class);
			String src_byz = InitDAO.getSysInitTempVO("src_byz").getDefaultvalue();
			AggregatedValueObject aggvo=this.getVo();
			if((aggvo instanceof AggPayableBillVO) && src_byz.equals(aggvo.getParentVO().getAttributeValue("def56")))
				throw new BusinessException("ARC同步过来的单据不能删除！");
			
			return obj;
		} catch (Exception ex) {
			throw ExceptionHandler.handleException(this.getClass(), ex);

		}
	}

	public String getCodeRemark() {
		return " arap action script not allowed to modify ,all rights reserved!";
	}

	protected void setParameter(String key, Object val) {
		if (m_keyHas == null) {
			m_keyHas = new Hashtable<String, Object>();
		}
		if (val != null) {
			m_keyHas.put(key, val);
		}
	}

}