Beispiel #1
0
        public MatchCorpPolicyAndAduitResultModel Match(MatchCorpPolicyAndAduitModel model)
        {
            BaseMatchBll matchBll = null;

            if (model.PassengerCidList == null || model.PassengerCidList.Count == 0) //都是临时客人的情况
            {
                CustomerModel bookingCustomerModel = _getCustomerBll.GetCustomerByCid(model.BookingCid);
                matchBll = new AllTemporaryBll(null, null, bookingCustomerModel, model.IsAllowUserInsurance);
            }
            else
            {
                //根据乘客人id获取部门Id
                List <CustomerModel> customerModels = _getCustomerBll.GetCustomerByCidList(model.PassengerCidList);
                List <int>           departIdList   = new List <int>();
                customerModels.ForEach(n =>
                {
                    if (n.CorpDepartID.HasValue)
                    {
                        departIdList.Add(n.CorpDepartID.Value);
                    }
                });

                departIdList = departIdList.Distinct().ToList();
                if (departIdList.Count == 1) //只有一个部门id,则认为是相同部门
                {
                    matchBll = new SameDepartmentBll(model.PassengerCidList, customerModels, model.IsAllowUserInsurance);
                }
                else
                {
                    matchBll = new DiffDepartmentBll(model.PassengerCidList, customerModels, model.IsAllowUserInsurance);
                }
            }

            IMatchVisitor matchVisitor = new MatchVisitor(_changeInfoFactory, _projectNameDal);

            return(matchBll.DoMatch(matchVisitor));
        }
Beispiel #2
0
        /// <summary>
        /// 针对不同部门的匹配规则
        /// </summary>
        /// <param name="matchBll"></param>
        /// <returns></returns>
        public MatchCorpPolicyAndAduitResultModel DoMatch(DiffDepartmentBll matchBll)
        {
            /**
             * 存在冲突,不许下一步,必须变更规则
             * 获取所有部门下的规则信息
             */

            if (matchBll.CustomerList == null)
            {
                throw new Exception("未找到乘客对应的信息");
            }

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

            //循环遍历乘客信息,获取对应的差旅政策和审批规则
            List <int> departIdList = new List <int>();//部门id信息

            matchBll.CustomerList.ForEach(n => { departIdList.Add(n.CorpDepartID ?? 0); });
            departIdList = departIdList.Distinct().ToList(); //去除重复部门id

            foreach (int departId in departIdList)           //循环部门id
            {
                var changeInfo = GetChange(departId, matchBll.CustomerList, matchBll.IsAllowUserInsurance);
                resultModel.ChangeInfoList.Add(changeInfo);
            }

            //放开部门限制
            AddOtherChangeInfo(matchBll.CustomerList[0].CorpID, departIdList, resultModel.ChangeInfoList,
                               matchBll.IsAllowUserInsurance);

            #region 获取项目成本中心
            string corpId = matchBll.CustomerList[0].CorpID.ToLower();
            List <ProjectNameEntity> projectNameEntities = _projectNameDal.Query <ProjectNameEntity>(
                n => n.CorpId.ToLower() == corpId && 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);
        }