用友nc65 uap审批流按钮开发

用友nc65 uap审批流按钮开发
1.目标:审批流按钮开发,如图:
用友nc65 uap审批流按钮开发_第1张图片
2.步骤:
1.按钮组生成:

	
		
		
		
			
				
				
			
		
	

	
		
		
		
		
		 
			
		
	

	
	
		
		
		
		
		
		
	
2.按钮java类
package nc.ui.fdc_pr.h303113510.actions;

import java.awt.event.ActionEvent;

import nc.bs.pubapp.pf.util.ApproveFlowUtil;
import nc.md.data.access.NCObject;
import nc.ui.pubapp.uif2app.AppUiState;
import nc.ui.pubapp.uif2app.actions.pflow.ApproveStatus;
import nc.ui.pubapp.uif2app.actions.pflow.ScriptPFlowAction;
import nc.ui.pubapp.uif2app.query2.action.DefaultRefreshAction;
import nc.ui.pubapp.uif2app.view.ShowUpableBillForm;
import nc.vo.fdc_pr.h303113510.AggRentPact;
import nc.vo.pubapp.pattern.model.entity.bill.AbstractBill;

public class ValidPatchAction extends ScriptPFlowAction {
	

	/**
	 * 生效按钮
	 */
	private static final long serialVersionUID = -9099914472763064509L;
	ShowUpableBillForm billform;
	private DefaultRefreshAction refreshAction;
	
	public DefaultRefreshAction getRefreshAction() {
		return refreshAction;
	}
	public void setRefreshAction(DefaultRefreshAction refreshAction) {
		this.refreshAction = refreshAction;
	}
	public ShowUpableBillForm getBillform() {
		return billform;
	}
	public void setBillform(ShowUpableBillForm billform) {
		this.billform = billform;
	}
	public ValidPatchAction(){
		setBtnName("合同生效");
		setCode("validAction");
	}
	@Override
	  public void doBeforAction() {
	    super.doBeforAction();
	  }
		
	  @Override
	public void doAction(ActionEvent e) throws Exception {			
		  super.doAction(e);
	}
	  /*
	   * 流程平台处理需要制单人和主组织信息
	   */
	  @Override
	  protected void fillBusitypeAfterLight(AbstractBill[] lightVOs) {
	    super.fillBusitypeAfterLight(lightVOs);    
	  }

	  @Override
	  protected String getErrorMsg() {
	    return  "合同生效失败!";
	  }

	  @Override
	  protected boolean isActionEnable() {
	    Object[] objs = this.model.getSelectedOperaDatas();
	    if (objs != null && objs.length > 1) {
	      return true;
	    }

	    Object selectedData = this.model.getSelectedData();
	    int status = ApproveStatus.FREE;
	    if (selectedData != null) {
	      NCObject obj = NCObject.newInstance(selectedData);
	      if (obj != null) {
	        status = ApproveFlowUtil.getBillStatus(obj).intValue();
	      }
	    }
	  
	    int volid = -1;
	    if (selectedData instanceof AggRentPact) {
	    	AggRentPact agg = (AggRentPact)selectedData;	      
	    	volid = agg.getParentVO().getFpactstate();	      
	    }
	    
	    boolean isEnable =
	        this.model.getAppUiState() == AppUiState.NOT_EDIT
	            && selectedData != null;
	    boolean flag =
	    	//最新UE规范:要求“未找到匹配审批流的单据也必须提交后才能审批,即自由态单据不能审批。”
	        //status == ApproveStatus.FREE || 
	        status == ApproveStatus.APPROVED && volid==0;
	    isEnable = isEnable && flag;

	    return isEnable;
	  }
}
package nc.ui.fdc_pr.h303113510.actions;

import nc.ui.pubapp.uif2app.AppUiState;
import nc.ui.pubapp.uif2app.actions.pflow.ScriptPFlowAction;
import nc.ui.pubapp.uif2app.view.ShowUpableBillForm;
import nc.vo.fdc_pr.h303113510.AggRentPact;

public class UnValidPatchAction extends ScriptPFlowAction {

	/**
	 * 失效按钮
	 */
	private static final long serialVersionUID = 2666694877481724325L;
	ShowUpableBillForm billform;
	
	public ShowUpableBillForm getBillform() {
		return billform;
	}

	public void setBillform(ShowUpableBillForm billform) {
		this.billform = billform;
	}

	public UnValidPatchAction(){
		setBtnName("合同失效");
		setCode("unValidAction");
	}	
	
	 @Override
	  public void doBeforAction() {
	    super.doBeforAction();
	  }


	  @Override
	  protected void beforeCheck(Object vo) {
	    super.beforeCheck(vo);
	  }

	  @Override
	  protected String getErrorMsg() {
	    return "合同终止失败!";
	  }

	  @Override
	  protected boolean isActionEnable() {
	    Object[] objs = this.model.getSelectedOperaDatas();
	    if (objs != null && objs.length > 1) {
	      return true;
	    }

	    Object selectedData = this.model.getSelectedData();
	    int status = -1;
	    if (selectedData instanceof AggRentPact) {
	    	AggRentPact agg = (AggRentPact)selectedData;	      
	        status = agg.getParentVO().getFpactstate();	      
	    }
	    
	    //单据为  已生效 状态 未生效才可用 
	    boolean isEnable =
	        this.model.getAppUiState() == AppUiState.NOT_EDIT && 
	        selectedData != null && status == 1;
	    return isEnable;
	  }
}
3.在客户端单据动作管理中配置信息:
用友nc65 uap审批流按钮开发_第2张图片
4.在
nc . itf . fdc_pr .IH303113510Maintain接口中声明方法:
public AggRentPact[] valid(AggRentPact[] clientFullVOs,
			AggRentPact[] originBills) throws BusinessException;
	
	public AggRentPact[] unvalid(AggRentPact[] clientFullVOs,
			AggRentPact[] originBills) throws BusinessException;
5.接口实现调用 nc . impl . fdc_pr .H303113510MaintainImpl
@Override
	public AggRentPact[] valid(AggRentPact[] clientFullVOs,
			AggRentPact[] originBills) throws BusinessException {
		
		return super.pubvalidbills(clientFullVOs, originBills);
	}

	@Override
	public AggRentPact[] unvalid(AggRentPact[] clientFullVOs,
			AggRentPact[] originBills) throws BusinessException {
		
		return super.pubunvalidbills(clientFullVOs, originBills);
	}
6.service实现类 nc . impl . pub . ace .AceH303113510PubServiceImpl
// 生效
	public AggRentPact[] pubvalidbills(AggRentPact[] clientFullVOs,
			AggRentPact[] originBills) throws BusinessException {
		for (int i = 0; clientFullVOs != null && i < clientFullVOs.length; i++) {
			clientFullVOs[i].getParentVO().setFpactstate(1);
		}
		AceH303113510ValidBP bp = new AceH303113510ValidBP();
		AggRentPact[] retvos = bp.valid(clientFullVOs, originBills);
		return retvos;
	}
	
	// 未生效
	public AggRentPact[] pubunvalidbills(AggRentPact[] clientFullVOs,
			AggRentPact[] originBills) throws BusinessException {
		for (int i = 0; clientFullVOs != null && i < clientFullVOs.length; i++) {
			clientFullVOs[i].getParentVO().setFpactstate(0);
		}
		AceH303113510UnValidBP bp = new AceH303113510UnValidBP();
		AggRentPact[] retvos = bp.unvalid(clientFullVOs, originBills);
		return retvos;
	}
	
7.代码结构图如下:
用友nc65 uap审批流按钮开发_第3张图片

8.AceH303113510ValidBP类代码:
package nc.bs.fdc_pr.h303113510.ace.bp;

import nc.impl.pubapp.pattern.data.bill.BillUpdate;
import nc.vo.fdc_pr.h303113510.AggRentPact;
import nc.vo.pub.VOStatus;

public class AceH303113510ValidBP {
	/**
	 * 生效动作
	 * 
	 * @param vos
	 * @param script
	 * @return
	 */
	public AggRentPact[] valid(AggRentPact[] clientBills,
			AggRentPact[] originBills) {
		for (AggRentPact clientBill : clientBills) {
			clientBill.getParentVO().setFpactstate(1);
			clientBill.getParentVO().setStatus(VOStatus.UPDATED);
		}
		BillUpdate update = new BillUpdate();
		AggRentPact[] returnVos = update.update(clientBills, originBills);
		return returnVos;
	}
}
9. 标准单据的扩展插入点        加入失效,生效。   nc . bs . fdc_pr . h303113510 . plugin . bpplugin .H303113510PluginPoint类
package nc.bs.fdc_pr.h303113510.plugin.bpplugin;

import nc.impl.pubapp.pattern.rule.plugin.IPluginPoint;

/**
 * 标准单据的扩展插入点
 * 
 */
public enum H303113510PluginPoint implements IPluginPoint {
	/**
	 * 生效
	 */
	VALID,
	/**
	 * 未生效
	 */
	UNVALID,
	/**
	 * 审批
	 */
	APPROVE,
	/**
	 * 送审
	 */
	SEND_APPROVE,

	/**
	 * 取消审核
	 */
	UNAPPROVE,

	/**
	 * 收回
	 */
	UNSEND_APPROVE,
	/**
	 * 删除
	 */
	DELETE,
	/**
	 * 新增
	 */
	INSERT,
	/**
	 * 更新
	 */
	UPDATE,
	/**
	 * 脚本删除
	 */
	SCRIPT_DELETE,
	/**
	 * 脚本新增
	 */
	SCRIPT_INSERT,
	/**
	 * 脚本更新
	 */
	SCRIPT_UPDATE;

	@Override
	public String getComponent() {
		return "H303113510";
	}

	@Override
	public String getModule() {
		return "fdc_pr";
	}

	@Override
	public String getPoint() {
		return this.getClass().getName() + "." + this.name();
	}

}
10. nc . bs . pub . action .N_H318_VALID类代码
package nc.bs.pub.action;

import nc.bs.fdc_pr.h303113510.plugin.bpplugin.H303113510PluginPoint;
import nc.bs.framework.common.NCLocator;
import nc.bs.pub.rule.PushChargeListAfterRule;
import nc.bs.pub.rule.PushToRevfareAfterRule;
import nc.bs.pub.rule.WriteBackHCAfterRule;
import nc.bs.pubapp.pf.action.AbstractPfAction;
import nc.impl.pubapp.pattern.rule.processer.CompareAroundProcesser;
import nc.itf.fdc_pr.IH303113510Maintain;
import nc.vo.fdc_pr.h303113510.AggRentPact;
import nc.vo.pub.BusinessException;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;

public class N_H318_VALID extends AbstractPfAction{

	@Override
	protected CompareAroundProcesser getCompareAroundProcesserWithRules(
			Object userObj) {
		CompareAroundProcesser processor = new CompareAroundProcesser(
				H303113510PluginPoint.SCRIPT_UPDATE);
		//processor.addBeforeRule(new ApproveStatusCheckRule());
		//审批后事件处理
		//processor.addAfterRule(new PushChargeListAfterRule());
		
		return processor;
	}

	@Override
	protected AggRentPact[] processBP(Object userObj,
			AggRentPact[] clientFullVOs, AggRentPact[] originBills) {
		AggRentPact[] bills = null;
		IH303113510Maintain operator = NCLocator.getInstance().lookup(
				IH303113510Maintain.class);
		try {
			bills = operator.valid(clientFullVOs, originBills);
		} catch (BusinessException e) {
			ExceptionUtils.wrappBusinessException(e.getMessage());
		}
		
		
		return bills;		
	}

}















你可能感兴趣的:(用友nc,nc65,uap,用友,用友nc,xml)