public List<ChangeCusCarWithOMViewModel> GetChangeCusCarOfPlat(string tenantCode, string iconSkin)
        {
            List<ChangeCusCarWithOMViewModel> list = new List<ChangeCusCarWithOMViewModel>();
            try
            {
                IList<EMTenant> ltTenantAll = new EMTenantService().GetGrandChildren(tenantCode);
                if (ltTenantAll.IsNullOrEmpty())
                    return list;

                var ltAllCus = ltTenantAll.Where(s => s.TenantType == EnumTenantType.EndCustomer && !string.IsNullOrEmpty(s.TenantName));
                if (ltAllCus.Count() == 0) return list;

                List<string> ltCusTenantCode = ltAllCus.Select(o => o.TenantCode).ToList();
                EMVehicleService vehicleServ = new EMVehicleService();
                //客户和客户的车辆总数
                Dictionary<string, int> dicVehicleCount = vehicleServ.SelectVehicleCount(ltCusTenantCode);
               
                EMTenant lastCreateTenant = ltAllCus.OrderByDescending(s => s.CreateTime).ElementAt(0);

                IList<ChangeCusCarWithOMViewModel> ltChildren = GetCarChildren(tenantCode, lastCreateTenant.TenantCode, ltTenantAll, dicVehicleCount);
                if (!ltChildren.IsNullOrEmpty())
                    list.AddRange(ltChildren);

                List<ChangeCusCarWithOMViewModel> vechileList = null;
                for (int j = 0; j < list.Count; j++)
                {
                    if (list[j].Children.Count == 0)
                    {
                        string stenantCode = list[j].TenantCode;

                        List<EMVehicle> veList = new VehicleDAL().GetVehicleListByTenantCode(stenantCode);
                        if (veList != null&&veList.Count>0)
                        {
                            vechileList = new List<ChangeCusCarWithOMViewModel>();
                            for (int a = 0; a < veList.Count; a++)
                            {
                                ChangeCusCarWithOMViewModel ve = new ChangeCusCarWithOMViewModel();
                                ve.TenantCode = veList[a].VehicleCode.ToString();
                                ve.TenantName = veList[a].LicenceNumber;
                                ve.iconSkin = "CarDeviceNo";
                                 
                                vechileList.Add(ve);
                            }
                            list[j].iconSkin = iconSkin;// 值为CarDeviceNo表示是车辆的上一级可以选中,为空表示车辆的上一级不可以选中
                            list[j].Children.AddRange(vechileList);
                        }
                    }
                    else
                    {
                        for (int k = 0; k < list[j].Children.Count; k++)
                        {
                            string stenantCode = list[j].Children[k].TenantCode;
                            vechileList = new List<ChangeCusCarWithOMViewModel>();
                            List<EMVehicle> veList = new VehicleDAL().GetVehicleListByTenantCode(stenantCode);
                            if (veList != null&&veList.Count>0)
                            {
                                for (int a = 0; a < veList.Count; a++)
                                {
                                    ChangeCusCarWithOMViewModel ve = new ChangeCusCarWithOMViewModel();
                                    ve.TenantCode = veList[a].VehicleCode.ToString();
                                    ve.TenantName = veList[a].LicenceNumber;
                                   
                                    ve.iconSkin = "CarDeviceNo";
                                    vechileList.Add(ve);

                                }
                                list[j].Children[k].iconSkin = iconSkin;
                                list[j].Children[k].Children.AddRange(vechileList);
                            }
                        }
                    }
                }

                return list;
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                return list;
            }
             
        }
        private IList<ChangeCusCarWithOMViewModel> GetCarChildren(string tenantCode, string lastCreateTenantCode,
          IList<EMTenant> ltTenantAll, Dictionary<string, int> dicVehicleCount) 
        {
            
            List<ChangeCusCarWithOMViewModel> list = new List<ChangeCusCarWithOMViewModel>();
            foreach (EMTenant tenant in ltTenantAll.Where(s => s.SuperTenantID == tenantCode))
            {
                ChangeCusCarWithOMViewModel vm = new ChangeCusCarWithOMViewModel
                {
                    IsLastCreated = false,
                    IsOM = tenant.TenantType == EnumTenantType.OperatingMerchant,
                    TenantCode = tenant.TenantCode,
                    TenantName = tenant.TenantName,
                    OperatorLevel = tenant.OperatorLevel,
                    Children = new List<ChangeCusCarWithOMViewModel>(),
                    RegisterUserCode = tenant.RegisterUserCode,
                    VehicleCount = 0,
                    VehicleOnlineNum = 0
                };
                
                if (!vm.IsOM)
                {
                    vm.iconSkin = "icon";
                    vm.IsLastCreated = lastCreateTenantCode == tenant.TenantCode;
                    if (dicVehicleCount.ContainsKey(vm.TenantCode))
                    {
                        vm.VehicleCount = dicVehicleCount[vm.TenantCode];
                    }
                }
                
                IList<ChangeCusCarWithOMViewModel> ltChildren = GetCarChildren(vm.TenantCode, lastCreateTenantCode, ltTenantAll, dicVehicleCount);
                if (!ltChildren.IsNullOrEmpty())
                {
                    vm.iconSkin = "pIcon";
                    vm.Children.AddRange(ltChildren);
                }
                else
                {
                    vm.iconSkin = "icon";
                }

                list.Add(vm);
            }
           
            
             return list;
        }
        /// <summary>
        /// 获取终端用户的车辆列表
        /// </summary>
        /// <param name="tenantCode"></param>
        /// <returns></returns>
        public List<ChangeCusCarWithOMViewModel> GetEndCustomerCarList(string tenantCode, string iconSkin)
        {
            List<ChangeCusCarWithOMViewModel> list = new List<ChangeCusCarWithOMViewModel>();
            ChangeCusCarWithOMViewModel car=new ChangeCusCarWithOMViewModel ();
            TenantDAL dal=new TenantDAL ();
            EMTenant emt=new EMTenant ();
            emt=dal.GetTenantBySuperTenantID(tenantCode);
            car.IsLastCreated = false;
            car.IsOM = emt.TenantType == EnumTenantType.EndCustomer;
            car.TenantCode = emt.TenantCode;
            car.TenantName = emt.TenantName;
            car.OperatorLevel = emt.OperatorLevel;
            car.Children = new List<ChangeCusCarWithOMViewModel>();
            car.RegisterUserCode = emt.RegisterUserCode;
            car.VehicleCount = 0;
            car.VehicleOnlineNum = 0;
            car.iconSkin = "pIcon";
            list.Add(car);

            List<EMVehicle> veList = new VehicleDAL().GetVehicleListByTenantCode(tenantCode);
            if (veList != null && veList.Count > 0)
            {
                List<ChangeCusCarWithOMViewModel>   vechileList = new List<ChangeCusCarWithOMViewModel>();
                for (int a = 0; a < veList.Count; a++)
                {
                    ChangeCusCarWithOMViewModel ve = new ChangeCusCarWithOMViewModel();
                    ve.TenantCode = veList[a].VehicleCode.ToString();
                    ve.TenantName = veList[a].LicenceNumber;
                    ve.iconSkin = "CarDeviceNo";

                    vechileList.Add(ve);
                }
                list[0].iconSkin = iconSkin; //值为CarDeviceNo表示是车辆的上一级可以选中,为空表示车辆的上一级不可以选中
                list[0].Children.AddRange(vechileList);
            }
            return list;
        }