package com.engine.htsc.payment.util;

import com.engine.htsc.payment.enums.BudgetWF;
import com.engine.htsc.payment.pojo.BudgetDTO;
import com.engine.htsc.payment.pojo.BxBudgetDTO;
import com.engine.htsc.payment.service.BudgetStrategy;

public class  BudgetStrategyFactory {

	/**
	 * 预算入参为 BudgetDTO
	 * @param code code
	 * @return BudgetStrategy<BudgetDTO>
	 */
	public static BudgetStrategy<BudgetDTO> getBudgetStrategyForPayment(String code) {
		try {
			return (BudgetStrategy<BudgetDTO>) Class.forName(BudgetWF.getClassNameByCode(code)).newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * 报销预算入参为 BxBudgetDTO
	 * @param code code
	 * @return BudgetStrategy<BxBudgetDTO>
	 */
	public static BudgetStrategy<BxBudgetDTO> getBxBudgetStrategyForPayment(String code) {
		try {
			return (BudgetStrategy<BxBudgetDTO>) Class.forName(BudgetWF.getClassNameByCode(code)).newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * 差旅报销预算入参为 BxBudgetDTO
	 * @param code code
	 * @return BudgetStrategy<BxBudgetDTO>
	 */
	public static BudgetStrategy<BxBudgetDTO> getClBxBudgetStrategyForPayment(String code) {
		try {
			return (BudgetStrategy<BxBudgetDTO>) Class.forName(BudgetWF.getClassNameByCode(code)).newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * 采购商城付款预算入参为 BxBudgetDTO
	 * @param code code
	 * @return BudgetStrategy<BxBudgetDTO>
	 */
	public static BudgetStrategy<BudgetDTO> getBudgetStrategyForCgscPayment(String code) {
		try {
			return (BudgetStrategy<BudgetDTO>) Class.forName(BudgetWF.getClassNameByCode(code)).newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		return null;
	}

}
