package cn.net.caoyao.cpzshandset.common.config;

import android.content.Context;
import cn.net.caoyao.cpzshandset.common.util.CacheGet;
import cn.net.caoyao.cpzshandset.db.presenter.ActivateDal;
import cn.net.caoyao.cpzshandset.db.presenter.ActivateWithPackDal;
import cn.net.caoyao.cpzshandset.db.presenter.ActivateWithRelationDal;
import cn.net.caoyao.cpzshandset.db.presenter.BatchLabelDal;
import cn.net.caoyao.cpzshandset.db.presenter.CertificateDal;
import cn.net.caoyao.cpzshandset.db.presenter.DealerDal;
import cn.net.caoyao.cpzshandset.db.presenter.DriverInfoDal;
import cn.net.caoyao.cpzshandset.db.presenter.GroupInfoDal;
import cn.net.caoyao.cpzshandset.db.presenter.InvoiceDal;
import cn.net.caoyao.cpzshandset.db.presenter.LandDal;
import cn.net.caoyao.cpzshandset.db.presenter.OnlineTruckInvoiceDal;
import cn.net.caoyao.cpzshandset.db.presenter.ProductDal;
import cn.net.caoyao.cpzshandset.db.presenter.SheepDealerDal;
import cn.net.caoyao.cpzshandset.db.presenter.SingleLabelDal;
import cn.net.caoyao.cpzshandset.db.presenter.TruckAddressDal;
import cn.net.caoyao.cpzshandset.db.presenter.TruckConsigneeDal;
import cn.net.caoyao.cpzshandset.db.presenter.TruckInvoiceDal;
import cn.net.caoyao.cpzshandset.service.presenter.tools.ActivateConfigCreateTools;
import cn.net.caoyao.cpzshandset.service.presenter.tools.BackWarehouseConfigCreateTools;
import cn.net.caoyao.cpzshandset.service.presenter.tools.CertificateConfigCreateTools;
import cn.net.caoyao.cpzshandset.service.presenter.tools.FarmConfigCreateTools;
import cn.net.caoyao.cpzshandset.service.presenter.tools.InWarehouseConfigCreateTools;
import cn.net.caoyao.cpzshandset.service.presenter.tools.LabelDalCreateTools;
import cn.net.caoyao.cpzshandset.service.presenter.tools.LandConfigCreateTools;
import cn.net.caoyao.cpzshandset.service.presenter.tools.OutWarehouseConfigCreateTools;
import cn.net.caoyao.cpzshandset.service.presenter.tools.PackConfigCreateTools;
import cn.net.caoyao.cpzshandset.service.presenter.tools.PlantConfigCreateTools;
import cn.net.caoyao.cpzshandset.service.presenter.tools.ProductConfigCreateTools;
import cn.net.caoyao.cpzshandset.service.presenter.tools.SaleConfigCreateTools;
import cn.net.caoyao.cpzshandset.service.presenter.tools.SettingConfigCreateTools;
import cn.net.caoyao.cpzshandset.service.presenter.tools.TrainShipmentConfigCreateTools;
import cn.net.caoyao.cpzshandset.service.presenter.tools.TruckShipmentConfigCreateTools;
import cn.net.caoyao.cpzshandset.service.presenter.tools.UnPackConfigCreateTools;

public class ConfigDBCreateService {
	private ActivateConfigCreateTools activateCongigCreate;
	private SettingConfigCreateTools settingCongigCreateTools;
	private ProductConfigCreateTools productCongigCreateTools;
	private PackConfigCreateTools packCongigCreateTools;
	private UnPackConfigCreateTools unPackCongigCreateTools;
	private OutWarehouseConfigCreateTools outWarehouseCongigCreateTools;
	private InWarehouseConfigCreateTools inWarehouseCongigCreateTools;
	private BackWarehouseConfigCreateTools backWarehouseCongigCreateTools;
	private SaleConfigCreateTools saleCongigCreateTools;
	private FarmConfigCreateTools farmCongigCreateTools;
	private PlantConfigCreateTools plantCongigCreateTools;
	private TrainShipmentConfigCreateTools trainShipmentCongigCreateTools;
	private TruckShipmentConfigCreateTools truckShipmentCongigCreateTools;
	private LabelDalCreateTools labelDalCreateTools;
	private LandConfigCreateTools landConfigCreateTools;
	private CertificateConfigCreateTools certificateConfigCreateTools;
	
//	private UserLoginCreateTools userLoginCreateTools;

	public ConfigDBCreateService() {

	}

	/**
	 * 创建手持机的版本模式
	 * 
	 * @param cacheGet
	 * @param context
	 * @return 一个数字代表模式 从共享参数中取 模式
	 */
	public int getHandsetVersionMode(CacheGet cacheG, Context context) {
		if (Config.canSwitchHandsetVersionMode) {
			// 默认为0，通用版
			return cacheG.getCacheIntegerG(context, Config.handsetVersionConfigSp, Config.currentHandsetVersion);
		} else {
			return Config.CURRENT_HANDSET_VERSION_MODE;
		}
	}

	/**
	 * 获取汽车发运客户数据相关的数据库dal
	 * 
	 * @param handsetVersionMode
	 * @param context
	 * @return
	 */
	public TruckConsigneeDal createTruckConsigneeDal(CacheGet cacheG, Context context) {
		return getTruckShipmentCreate().createTruckCondigneeDal(getHandsetVersionMode(cacheG, context), context);
	}

	/**
	 * 获取汽车发运地址数据相关的数据库dal
	 * 
	 * @param handsetVersionMode
	 * @param context
	 * @return
	 */
	public TruckAddressDal createTruckAddressDal(CacheGet cacheG, Context context) {
		return getTruckShipmentCreate().createTruckAddressDal(getHandsetVersionMode(cacheG, context), context);
	}

	/**
	 * 获取激活相关的数据库dal
	 * 
	 * @param handsetVersionMode
	 * @param context
	 * @return
	 */
	public TruckInvoiceDal createTruckInvoiceDal(CacheGet cacheG, Context context) {
		return getTruckShipmentCreate().createTruckInvoiceDal(getHandsetVersionMode(cacheG, context), context);
	}

	public DriverInfoDal createOnlineDriverInfoDal(CacheGet cacheG,Context context){
		return getTruckShipmentCreate().createOnlineDriverDal(getHandsetVersionMode(cacheG, context), context);
	}

	public OnlineTruckInvoiceDal createOnlineOrderDal(CacheGet cacheG,Context context){
		return getTruckShipmentCreate().createOnlineOrderDal(getHandsetVersionMode(cacheG, context), context);
	}
	/**
	 * 获取激活相关的数据库dal
	 * 
	 * @param handsetVersionMode
	 * @param context
	 * @return
	 */
	public InvoiceDal createInvoiceDal(CacheGet cacheG, Context context) {
		return getTruckShipmentCreate().createInvoiceDal(getHandsetVersionMode(cacheG, context), context);
	}

	/**
	 * 获取激活相关的数据库dal
	 * 
	 * @param handsetVersionMode
	 * @param context
	 * @return
	 */
	public ActivateDal createActivateDal(CacheGet cacheG, Context context) {
		return getActivateCreate().createActivateDal(getHandsetVersionMode(cacheG, context), context);
	}
	
	public GroupInfoDal createGroupInfoDal(CacheGet cacheG,Context context) {
		return getActivateCreate().createGroupInfoDal(getHandsetVersionMode(cacheG, context), context);
	}
	public DealerDal createDealerDal(CacheGet cacheG,Context context) {
		return getSaleCreate().createDealerDal(getHandsetVersionMode(cacheG, context), context);
	}
	public SheepDealerDal createSheepDealerDal(CacheGet cacheG,Context context) {
		return getSaleCreate().createSheepDealerDal(getHandsetVersionMode(cacheG, context), context);
	}
	/**
	 * 获取激活相关的数据库dal
	 * 
	 * @param handsetVersionMode
	 * @param context
	 * @return
	 */
	public ActivateWithPackDal createActivateWithPackDal(CacheGet cacheG, Context context) {
		return getActivateCreate().createActivateWithPackDal(getHandsetVersionMode(cacheG, context), context);
	}
	
	/**
	 * 获取激活相关的数据库dal
	 * 
	 * @param handsetVersionMode
	 * @param context
	 * @return
	 */
	public ActivateWithRelationDal createActivateWithRelationDal(CacheGet cacheG, Context context) {
		return getActivateCreate().createActivateWithRelationDal(getHandsetVersionMode(cacheG, context), context);
	}
	/**
	 * 获取单标操作表的数据库dal
	 * 
	 * @param handsetVersionMode
	 * @param context
	 * @return
	 */
	public SingleLabelDal createSingleLabeDal(CacheGet cacheG, Context context) {
		return getLabelCreateCreate().createSingleLabelDal(getHandsetVersionMode(cacheG, context), context);
	}

	/**
	 * 获取批量操作表的数据库dal
	 * 
	 * @param handsetVersionMode
	 * @param context
	 * @return
	 */
	public BatchLabelDal createBatchLabeDal(CacheGet cacheG, Context context) {
		return getLabelCreateCreate().createBatchLabelDal(getHandsetVersionMode(cacheG, context), context);
	}

	/**
	 * 获取产品表的数据库dal
	 * 
	 * @param handsetVersionMode
	 * @param context
	 * @return
	 */
	public ProductDal createProductDal(CacheGet cacheG, Context context) {
		return getProductCreate().createProductDal(getHandsetVersionMode(cacheG, context), context);
	}

	/**
	 * 操作基地列表的dal
	 * 
	 * @return
	 */
	public LandDal createLandDal(CacheGet cacheG, Context context) {
		return getLandConfigCreate().createLandDal(getHandsetVersionMode(cacheG, context), context);
	}

	/**
	 * 操作证书列表的dal
	 * 
	 * @return
	 */
	public CertificateDal createCertificateDal(CacheGet cacheG, Context context) {
		return getCertificateConfigCreate().createCertificateDal(getHandsetVersionMode(cacheG, context), context);
	}

	private ActivateConfigCreateTools getActivateCreate() {
		if (activateCongigCreate == null) {
			activateCongigCreate = new ActivateConfigCreateTools();
		}
		return activateCongigCreate;
	}

	private SettingConfigCreateTools getSettingCreate() {
		if (settingCongigCreateTools == null) {
			settingCongigCreateTools = new SettingConfigCreateTools();
		}
		return settingCongigCreateTools;
	}

	private ProductConfigCreateTools getProductCreate() {
		if (productCongigCreateTools == null) {
			productCongigCreateTools = new ProductConfigCreateTools();
		}
		return productCongigCreateTools;
	}

	private PackConfigCreateTools getPackCreate() {
		if (packCongigCreateTools == null) {
			packCongigCreateTools = new PackConfigCreateTools();
		}
		return packCongigCreateTools;
	}

	private UnPackConfigCreateTools getUnPackCreate() {
		if (unPackCongigCreateTools == null) {
			unPackCongigCreateTools = new UnPackConfigCreateTools();
		}
		return unPackCongigCreateTools;
	}

	private OutWarehouseConfigCreateTools getOutWarehouseCreate() {
		if (outWarehouseCongigCreateTools == null) {
			outWarehouseCongigCreateTools = new OutWarehouseConfigCreateTools();
		}
		return outWarehouseCongigCreateTools;
	}

	private InWarehouseConfigCreateTools getInWarehouseCreate() {
		if (inWarehouseCongigCreateTools == null) {
			inWarehouseCongigCreateTools = new InWarehouseConfigCreateTools();
		}
		return inWarehouseCongigCreateTools;
	}

	private BackWarehouseConfigCreateTools getbackWarehouseCreate() {
		if (backWarehouseCongigCreateTools == null) {
			backWarehouseCongigCreateTools = new BackWarehouseConfigCreateTools();
		}
		return backWarehouseCongigCreateTools;
	}

	private SaleConfigCreateTools getSaleCreate() {
		if (saleCongigCreateTools == null) {
			saleCongigCreateTools = new SaleConfigCreateTools();
		}
		return saleCongigCreateTools;
	}

	private FarmConfigCreateTools getFarmCreate() {
		if (farmCongigCreateTools == null) {
			farmCongigCreateTools = new FarmConfigCreateTools();
		}
		return farmCongigCreateTools;
	}

	private PlantConfigCreateTools getPlantCreate() {
		if (plantCongigCreateTools == null) {
			plantCongigCreateTools = new PlantConfigCreateTools();
		}
		return plantCongigCreateTools;
	}

	private TrainShipmentConfigCreateTools getTrainShipmentCreate() {
		if (trainShipmentCongigCreateTools == null) {
			trainShipmentCongigCreateTools = new TrainShipmentConfigCreateTools();
		}
		return trainShipmentCongigCreateTools;
	}

	private TruckShipmentConfigCreateTools getTruckShipmentCreate() {
		if (truckShipmentCongigCreateTools == null) {
			truckShipmentCongigCreateTools = new TruckShipmentConfigCreateTools();
		}
		return truckShipmentCongigCreateTools;
	}

	private LabelDalCreateTools getLabelCreateCreate() {
		if (labelDalCreateTools == null) {
			labelDalCreateTools = new LabelDalCreateTools();
		}
		return labelDalCreateTools;
	}

	private LandConfigCreateTools getLandConfigCreate() {
		if (landConfigCreateTools == null) {
			landConfigCreateTools = new LandConfigCreateTools();
		}
		return landConfigCreateTools;
	}

	private CertificateConfigCreateTools getCertificateConfigCreate() {
		if (certificateConfigCreateTools == null) {
			certificateConfigCreateTools = new CertificateConfigCreateTools();
		}
		return certificateConfigCreateTools;
	}
}
