コード例 #1
0
ファイル: MatchVisitor.cs プロジェクト: chzhxiang/hotel
        /// <summary>
        /// 获取除参数部门外的部门信息,并且根据这些部门信息获取审批与差旅政策,累加到当前ChangeInfoList上
        /// </summary>
        /// <param name="corpId"></param>
        /// <param name="removeDepartIdList"></param>
        /// <param name="changeInfoList"></param>
        /// <param name="isAllowUserInsurance"></param>
        private void AddOtherChangeInfo(string corpId, List <int> removeDepartIdList, List <CorpPolicyAndAduitChangeModel> changeInfoList, int isAllowUserInsurance)
        {
            if (changeInfoList == null)
            {
                changeInfoList = new List <CorpPolicyAndAduitChangeModel>();
            }

            List <CorpDepartmentModel> departmentModels =
                _changeInfoFactory.GetCorpDepart(corpId, removeDepartIdList);

            if (departmentModels != null && departmentModels.Count > 0)
            {
                foreach (var corpDepartmentModel in departmentModels)
                {
                    CorpPolicyAndAduitChangeModel otherChangeInfo = new CorpPolicyAndAduitChangeModel();

                    otherChangeInfo.DepartmentId         = corpDepartmentModel.Id;
                    otherChangeInfo.DepartmentName       = corpDepartmentModel.DepartName;
                    otherChangeInfo.CorpPolicyChangeList =
                        _changeInfoFactory.GetCorpPolicyChangeInfo(0, corpDepartmentModel.Id, isAllowUserInsurance);
                    otherChangeInfo.CorpAduitChangeList =
                        _changeInfoFactory.GetCorpAduitChangeInfo(0, corpDepartmentModel.Id);

                    changeInfoList.Add(otherChangeInfo);
                }
            }
        }
コード例 #2
0
ファイル: MatchVisitor.cs プロジェクト: chzhxiang/hotel
        private CorpPolicyAndAduitChangeModel GetChange(int departId, List <CustomerModel> customerList, int isAllowUserInsurance)
        {
            CorpPolicyAndAduitChangeModel changeModel = new CorpPolicyAndAduitChangeModel()
            {
                DepartmentId = departId
            };

            List <CustomerModel> customerModels = customerList.FindAll(n => n.CorpDepartID == departId);//获取部门对应的客户信息

            if (customerModels != null && customerModels.Count > 0)
            {
                changeModel.DepartmentName = customerModels[0].DepartmentName;

                List <CorpPolicyChangeModel> policyChangeList = new List <CorpPolicyChangeModel>(); //政策池子
                List <CorpAduitChangeModel>  aduitChangeList  = new List <CorpAduitChangeModel>();  //审批池子
                List <int> policyIdList = new List <int>();
                List <int> aduitIdList  = new List <int>();

                foreach (var customerModel in customerModels)
                {
                    List <CorpPolicyChangeModel> policyChangeModels =
                        _changeInfoFactory.GetCorpPolicyChangeInfo(customerModel.Cid,
                                                                   customerModel.CorpDepartID ?? 0, isAllowUserInsurance);
                    if (policyChangeModels != null && policyChangeModels.Count > 0)
                    {
                        policyChangeList.AddRange(policyChangeModels);//合并政策信息
                        policyChangeModels.ForEach(n => { policyIdList.Add(n.PolicyId); });
                    }

                    List <CorpAduitChangeModel> aduitChangeModels =
                        _changeInfoFactory.GetCorpAduitChangeInfo(customerModel.Cid, customerModel.CorpDepartID ?? 0);
                    if (aduitChangeModels != null && aduitChangeModels.Count > 0)
                    {
                        aduitChangeList.AddRange(aduitChangeModels);//合并审批规则信息
                        aduitChangeList.ForEach(n => { aduitIdList.Add(n.AduitId); });
                    }
                }

                //去除重复Id
                policyIdList = policyIdList.Distinct().ToList();
                aduitIdList  = aduitIdList.Distinct().ToList();
                changeModel.CorpPolicyChangeList = new List <CorpPolicyChangeModel>();
                changeModel.CorpAduitChangeList  = new List <CorpAduitChangeModel>();

                policyIdList.ForEach(n =>
                {
                    changeModel.CorpPolicyChangeList.Add(policyChangeList.Find(x => x.PolicyId == n));
                });
                aduitIdList.ForEach(n =>
                {
                    changeModel.CorpAduitChangeList.Add(aduitChangeList.Find(x => x.AduitId == n));
                });
            }

            return(changeModel);
        }
コード例 #3
0
ファイル: MatchVisitor.cs プロジェクト: chzhxiang/hotel
        /// <summary>
        /// 针对所有临时客人的匹配规则
        /// </summary>
        /// <param name="matchBll"></param>
        /// <returns></returns>
        public MatchCorpPolicyAndAduitResultModel DoMatch(AllTemporaryBll matchBll)
        {
            /**
             * 不存在冲突,允许下一步
             * 如果要选择差旅政策或审批规则,按照当前预定人的政策和审批规则
             * **/

            MatchCorpPolicyAndAduitResultModel resultModel = new MatchCorpPolicyAndAduitResultModel()
            {
                IsConflict     = false,
                ChangeInfoList = new List <CorpPolicyAndAduitChangeModel>()
            };

            //按照当前预定人的政策和审批规则
            if (matchBll.BookingCustomerModel.CorpDepartID.HasValue &&
                !string.IsNullOrEmpty(matchBll.BookingCustomerModel.DepartmentName))
            {
                CorpPolicyAndAduitChangeModel changeInfo = new CorpPolicyAndAduitChangeModel();
                changeInfo.DepartmentId         = matchBll.BookingCustomerModel.CorpDepartID;
                changeInfo.DepartmentName       = matchBll.BookingCustomerModel.DepartmentName;
                changeInfo.CorpPolicyChangeList =
                    _changeInfoFactory.GetCorpPolicyChangeInfo(matchBll.BookingCustomerModel.Cid,
                                                               matchBll.BookingCustomerModel.CorpDepartID.Value, matchBll.IsAllowUserInsurance);
                changeInfo.CorpAduitChangeList =
                    _changeInfoFactory.GetCorpAduitChangeInfo(matchBll.BookingCustomerModel.Cid,
                                                              matchBll.BookingCustomerModel.CorpDepartID.Value);
                resultModel.ChangeInfoList.Add(changeInfo);

                //放开部门限制
                AddOtherChangeInfo(matchBll.BookingCustomerModel.CorpID,
                                   new List <int>()
                {
                    matchBll.BookingCustomerModel.CorpDepartID.Value
                }, resultModel.ChangeInfoList,
                                   matchBll.IsAllowUserInsurance);


                #region 获取项目成本中心
                List <ProjectNameEntity> projectNameEntities = _projectNameDal.Query <ProjectNameEntity>(
                    n => n.CorpId.ToLower() == matchBll.BookingCustomerModel.CorpID.ToLower() && n.IsDelete == "F")
                                                               .ToList();
                List <int> projectIdList = projectNameEntities.Select(n => n.ProjectId)
                                           .Distinct()
                                           .ToList();



                if (projectIdList != null && projectIdList.Count > 0)
                {
                    resultModel.ProjectChangeInfoList = new List <CorpPolicyAndAduitChangeProjectModel>();

                    foreach (var projectId in projectIdList)
                    {
                        var project = projectNameEntities.Find(n => n.ProjectId == projectId);
                        CorpPolicyAndAduitChangeProjectModel p = new CorpPolicyAndAduitChangeProjectModel();
                        p.ProjectId            = projectId;
                        p.ProjectName          = project.ProjectName;
                        p.CorpPolicyChangeList =
                            _changeInfoFactory.GetCorpPolicyChangeInfoByProjectId(projectId,
                                                                                  matchBll.IsAllowUserInsurance);
                        p.CorpAduitChangeList = _changeInfoFactory.GetCorpAduitChangeInfoByProjectId(projectId);

                        resultModel.ProjectChangeInfoList.Add(p);
                    }
                }
                #endregion
            }



            return(resultModel);
        }