Exemplo n.º 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));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 针对同一部门的匹配规则
        /// </summary>
        /// <param name="matchBll"></param>
        /// <returns></returns>
        public MatchCorpPolicyAndAduitResultModel DoMatch(SameDepartmentBll matchBll)
        {
            /**
             * 如果当前乘客的差旅或者审批规则都一致,则不冲突;有冲突的时候,获取对应的乘客的差旅和审批规则
             */
            if (matchBll.CustomerList == null)
            {
                throw new Exception("未找到乘客对应的信息");
            }

            MatchCorpPolicyAndAduitResultModel resultModel = new MatchCorpPolicyAndAduitResultModel()
            {
                IsConflict     = true,//默认冲突
                ChangeInfoList = new List <CorpPolicyAndAduitChangeModel>()
            };

            if (matchBll.CustomerList[0].CorpDepartID.HasValue)
            {
                var changeInfo = GetChange(matchBll.CustomerList[0].CorpDepartID.Value, matchBll.CustomerList, matchBll.IsAllowUserInsurance);
                resultModel.ChangeInfoList.Add(changeInfo);

                List <int> policyIdList = new List <int>();
                List <int> aduitIdList  = new List <int>();

                if (changeInfo != null)
                {
                    if (changeInfo.CorpPolicyChangeList != null && changeInfo.CorpPolicyChangeList.Count > 0)
                    {
                        changeInfo.CorpPolicyChangeList.ForEach(n => { policyIdList.Add(n.PolicyId); });
                    }

                    if (changeInfo.CorpAduitChangeList != null && changeInfo.CorpAduitChangeList.Count > 0)
                    {
                        changeInfo.CorpAduitChangeList.ForEach(n => { aduitIdList.Add(n.AduitId); });
                    }
                }

                if (policyIdList.Count == 1 && aduitIdList.Count == 1)//当前只存在一条政策并且一条审批规则的时候,设置不冲突
                {
                    resultModel.IsConflict            = false;
                    resultModel.DefaultPolicyId       = policyIdList[0];
                    resultModel.DefaultAduitId        = aduitIdList[0];
                    resultModel.DefaultDepartmentId   = resultModel.ChangeInfoList[0].DepartmentId;
                    resultModel.DefaultDepartmentName = resultModel.ChangeInfoList[0].DepartmentName;

                    var temp =
                        changeInfo?.CorpPolicyChangeList?.Find(n => n.PolicyId == resultModel.DefaultPolicyId.Value);

                    resultModel.DefaultInsuranceLimit     = temp?.ViolateNPolicyValI;
                    resultModel.DefaultViolateTPolicyValQ = temp?.ViolateTPolicyValQ;
                    resultModel.DefaultViolateTPolicyValM = temp?.ViolateTPolicyValM;
                    resultModel.DefaultViolateTPolicyValS = temp?.ViolateTPolicyValS;
                }

                if (policyIdList.Count == 0 && aduitIdList.Count == 0)//当政策和审批规则都不存在的时候,设置不冲突
                {
                    resultModel.IsConflict = false;
                }
                //放开部门限制
                AddOtherChangeInfo(matchBll.CustomerList[0].CorpID,
                                   new List <int>()
                {
                    matchBll.CustomerList[0].CorpDepartID.Value
                }, 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);
        }