/// <summary> /// 复制父级实体到子级实体 /// </summary> /// <param name="entity"></param> /// <returns></returns> public QueryTraTravelModel ConvertParentToSon(BaseQueryTravelModel entity) { var parentType = typeof(BaseQueryTravelModel); var properties = parentType.GetProperties(); foreach (var propertie in properties) { if (propertie.CanRead && propertie.CanWrite) { propertie.SetValue(this, propertie.GetValue(entity, null), null); } } return(this); }
/// <summary> /// 根据cid,获取查询行程视图 /// </summary> /// <param name="cid"></param> /// <returns></returns> public BaseQueryTravelModel GetQueryTravelView(int cid) { BaseQueryTravelModel queryTravelModel = new BaseQueryTravelModel(); CustomerInfoModel customerInfoModel = _customerBll.GetCustomerByCid(cid); queryTravelModel.IsMaster = "F"; //默认为该客户非预订员 queryTravelModel.IsCorpSystemCustomer = "T"; //默认是差旅系统客户 CorporationModel corporationModel = null; if (!string.IsNullOrEmpty(customerInfoModel.CorpId)) { corporationModel = _corporationBll.GetCorpInfoByCorpId(customerInfoModel.CorpId); } if (corporationModel != null && corporationModel.IsAmplitudeCorp == "T") { #region 如果是预订员,则获取当前预定的部门信息 if (!string.IsNullOrEmpty(customerInfoModel.IsMaster) && customerInfoModel.IsMaster.ToUpper() == "T") { queryTravelModel.IsMaster = "T"; queryTravelModel.DepartmentList = new List <CorpDepartmentModel>(); List <int> departIds = new List <int>(); CustomerUnionInfoModel customerUnionInfoModel = _customerUnionBll.GetCustomerUnionByCid(customerInfoModel.Cid); if (!string.IsNullOrEmpty(customerUnionInfoModel.CorpDepartIDList)) //0:全部 -1外宾部 { string[] departStrings = customerUnionInfoModel.CorpDepartIDList.Split(','); departIds.AddRange(departStrings.Select(departString => Convert.ToInt32(departString))); } else { //如果是NULL,则默认0,-1 departIds.Add(0); departIds.Add(-1); } if (departIds.Contains(0)) //全部部门 { List <CorpDepartmentModel> departmentModels = _corpDepartmentBll.GetCorpDepartmentByCorpId(customerInfoModel.CorpId); departmentModels.ForEach( n => queryTravelModel.DepartmentList.Add(new CorpDepartmentModel() { Id = n.Id, DepartName = n.DepartName })); } else { List <CorpDepartmentModel> departmentModels = _corpDepartmentBll.GetCorpDepartmentByIds(departIds); departmentModels.ForEach( n => queryTravelModel.DepartmentList.Add(new CorpDepartmentModel() { Id = n.Id, DepartName = n.DepartName })); } if (queryTravelModel.DepartmentList.Count > 0) { //判断部门中是否存在员工,不存在则剔除 List <CustomerInfoModel> departCustomerInfoModels = _customerBll.GetCustomerByDepartId(departIds); if (departCustomerInfoModels != null && departCustomerInfoModels.Count > 0) { for (int i = 0; i < queryTravelModel.DepartmentList.Count; i++) { if ( departCustomerInfoModels.FindAll( n => n.CorpDepartId == queryTravelModel.DepartmentList[i].Id).Count == 0) { queryTravelModel.DepartmentList.RemoveAt(i); } } } } if (departIds.Contains(-1)) //外宾部门 { queryTravelModel.DepartmentList.Add(new CorpDepartmentModel() { Id = -1, DepartName = "外宾部" }); } if (departIds.Count == 1 && departIds.Contains(0))//只有全部部门的时候,追加外宾,对前端网站维护进行容错处理 { queryTravelModel.DepartmentList.Add(new CorpDepartmentModel() { Id = -1, DepartName = "外宾部" }); } } #endregion } else { queryTravelModel.IsMaster = "F"; queryTravelModel.IsCorpSystemCustomer = "F"; } return(queryTravelModel); }