public List <CorpPassengerCustomerModel> GetCorpPassengerCustomer(List <int> contactList) { List <ContactInfoModel> contactInfoModels = _getContactBll.GetContactByContactId(contactList); List <CustomerModel> customerModels = _customerBll.GetCustomerByCidList(contactInfoModels.Select(n => n.Cid ?? 0).ToList()); List <int> corpDepartIdList = customerModels.Select(x => x.CorpDepartID ?? 0).ToList(); List <CorpDepartmentEntity> departments = _corpDepartmentDal.Query <CorpDepartmentEntity>( n => corpDepartIdList.Contains(n.Id)).ToList(); List <CorpDepartmentModel> corpDepartmentModels = Mapper.Map <List <CorpDepartmentEntity>, List <CorpDepartmentModel> >(departments); List <CorpPassengerCustomerModel> corpPassengerCustomerModels = new List <CorpPassengerCustomerModel>(); foreach (var customer in customerModels) { CorpPassengerCustomerModel corpPassengerCustomerModel = new CorpPassengerCustomerModel().ConvertFatherToSon(customer); corpPassengerCustomerModel.Department = corpDepartmentModels.Find(n => n.Id == (customer.CorpDepartID ?? 0)); corpPassengerCustomerModels.Add(corpPassengerCustomerModel); } return(corpPassengerCustomerModels); }
public List <CorpDepartmentModel> GetCorpDepartmentByCorpId(string corpId) { List <CorpDepartmentEntity> corpDepartmentEntities = _corpDepartmentDal.Query <CorpDepartmentEntity>(n => n.CorpId == corpId && n.IsDel.ToUpper() == "F", true) .ToList(); return(Mapper.Map <List <CorpDepartmentEntity>, List <CorpDepartmentModel> >(corpDepartmentEntities)); }
/// <summary> /// 获取当前公司下的除参数外的所有部门 /// </summary> /// <param name="corpId"></param> /// <param name="removeDepartIdList"></param> /// <returns></returns> public List <CorpDepartmentModel> GetCorpDepart(string corpId, List <int> removeDepartIdList) { IQueryable <CorpDepartmentEntity> queryable = _corpDepartmentDal.Query <CorpDepartmentEntity>(n => n.CorpId.ToUpper() == corpId.ToUpper() && n.IsDel.ToUpper() == "F", true); if (removeDepartIdList != null && removeDepartIdList.Count > 0) { queryable = queryable.Where(n => !removeDepartIdList.Contains(n.Id)).AsNoTracking(); } List <CorpDepartmentEntity> list = queryable.ToList(); return(Mapper.Map <List <CorpDepartmentEntity>, List <CorpDepartmentModel> >(list)); }
private List <CustomerModel> Convert(List <CustomerInfoEntity> customerInfoEntities, List <CustomerUnionInfoEntity> customerUnionInfoEntities) { List <string> corpIdList = new List <string>(); List <CorporationModel> corporationModels = new List <CorporationModel>(); #region 获取部门信息 List <int> departIdList = new List <int>(); List <CorpDepartmentModel> corpDepartmentModels = new List <CorpDepartmentModel>(); customerInfoEntities.ForEach(n => { if (n.CorpDepartID.HasValue) { departIdList.Add(n.CorpDepartID.Value); } if (!string.IsNullOrEmpty(n.CorpID)) { corpIdList.Add(n.CorpID); } }); if (departIdList.Count > 0) { departIdList = departIdList.Distinct().ToList(); List <CorpDepartmentEntity> corpDepartmentEntities = _corpDepartmentDal.Query <CorpDepartmentEntity>(n => departIdList.Contains(n.Id)).ToList(); corpDepartmentModels = Mapper.Map <List <CorpDepartmentEntity>, List <CorpDepartmentModel> >(corpDepartmentEntities); } #endregion #region 部门信息 if (corpIdList.Count > 0) { corpIdList = corpIdList.Distinct().ToList(); List <CorporationEntity> corporationEntities = _corporationDal.Query <CorporationEntity>(n => corpIdList.Contains(n.CorpId)).ToList(); corporationModels = Mapper.Map <List <CorporationEntity>, List <CorporationModel> >(corporationEntities); } #endregion List <CustomerModel> customerModels = new List <CustomerModel>(); foreach (var customerInfoEntity in customerInfoEntities) { CustomerModel customerModel = Mapper.Map <CustomerInfoEntity, CustomerModel>(customerInfoEntity); if (!string.IsNullOrEmpty(customerModel.CorpID)) { if (customerModel.CorpDepartID.HasValue) { customerModel.CorpDepartment = corpDepartmentModels.Find(n => n.Id == customerModel.CorpDepartID.Value); } customerModel.Corporation = corporationModels.Find(n => n.CorpId.ToLower() == customerModel.CorpID.ToLower()); } CustomerUnionInfoEntity customerUnionInfoEntity = customerUnionInfoEntities?.Find(n => n.Cid == customerInfoEntity.Cid); if (customerUnionInfoEntity != null) { customerModel.Cid = customerUnionInfoEntity.Cid; customerModel.CPCID = customerUnionInfoEntity.CPCID; customerModel.CheckType = customerUnionInfoEntity.CheckType; customerModel.CorpDepartIDList = customerUnionInfoEntity.CorpDepartIDList; customerModel.CustomerFrom = customerUnionInfoEntity.CustomerFrom; customerModel.GrantCPCID = customerUnionInfoEntity.GrantCPCID; customerModel.GrantEndDate = customerUnionInfoEntity.GrantEndDate; customerModel.GrantStartDate = customerUnionInfoEntity.GrantStartDate; customerModel.IsCheckU8 = customerUnionInfoEntity.IsCheckU8; customerModel.IsSupplier = customerUnionInfoEntity.IsSupplier; customerModel.TelTime = customerUnionInfoEntity.TelTime; } customerModels.Add(customerModel); } return(customerModels); }