package nccloud.impl.hrkq.hrkq;

import nc.bs.framework.common.NCLocator;
import nc.ui.pub.print.IDataSource;
import nc.vo.hrkq.monthottime.AggMonthOtTimeVO;
import nc.vo.pub.BusinessException;
import nccloud.base.exception.ExceptionUtils;
import nccloud.commons.lang.ArrayUtils;
import nccloud.itf.hrkq.hrkq.IMonthottimevoMaintain;
import nccloud.pubitf.platform.print.AbstractPrintService;
import nccloud.pubitf.platform.print.IPrintInfo;
import nccloud.pubitf.platform.print.vo.PrintInfo;
import nccloud.web.hr.print.HRNccMetaDataDataSource;

public class MonthOtTimeVOPrintService extends AbstractPrintService {

	@Override
	public IDataSource[] getDataSources(IPrintInfo info) {
		PrintInfo printInfo = (PrintInfo)info;
		String[] pks = printInfo.getIds();
		if (ArrayUtils.isEmpty(pks)) {
			return new IDataSource[] { new HRNccMetaDataDataSource(new Object[0]) };
		}
		try {
			AggMonthOtTimeVO agg = ((IMonthottimevoMaintain)NCLocator.getInstance().lookup(IMonthottimevoMaintain.class)).queryByPk(pks[0]);
			 if (agg == null) {
				 return new IDataSource[] { new HRNccMetaDataDataSource(new Object[0]) };
			 }
			 MonthOtTimeVOPrintDataSource monthOtTimeVOPrintDataSource = new MonthOtTimeVOPrintDataSource(new AggMonthOtTimeVO[] { agg });
			 return new IDataSource[] { monthOtTimeVOPrintDataSource };
		} catch (BusinessException e) {
			 ExceptionUtils.wrapException(e);
		}
		return null;
	}

}
