package nccloud.impl.hrkq.trip;

import nc.md.persist.framework.MDPersistenceService;
import nc.ui.pub.print.IDataSource;
import nc.vo.pub.BusinessException;
import nccloud.base.exception.ExceptionUtils;
import nccloud.commons.lang.ArrayUtils;
import nccloud.pubitf.platform.print.AbstractPrintService;
import nccloud.pubitf.platform.print.IPrintInfo;
import nccloud.pubitf.platform.print.vo.PrintInfo;
import nccloud.vo.hrkq.trip.AggTripVO;
import nccloud.web.hr.print.HRNccMetaDataDataSource;

public class TripVOPrintService 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 {
		     AggTripVO agg = MDPersistenceService.lookupPersistenceQueryService().queryBillOfVOByPK(AggTripVO.class, pks[0], false);
			 if (agg == null) {
				 return new IDataSource[] { new HRNccMetaDataDataSource(new Object[0]) };
			 }
			 AggTripVOPrintDataSource aggTripVOPrintDataSource = new AggTripVOPrintDataSource(new AggTripVO[] { agg });
			 return new IDataSource[] { aggTripVOPrintDataSource };
		} catch (BusinessException e) {
			 ExceptionUtils.wrapException(e);
		}
		return null;
	}

}
