public static ManagementTraineePayStandard CreateFirstStandard(string emplid)
        {
            EmployeeInfo employee = EmployeeInfo.GetFromCache(emplid);

            if (employee == null)
            {
                return(null);
            }

            ManagementTraineePayStandard item = GetManagementTraineePayStandard(emplid, 0);

            if (item == null)
            {
                //获取管培生基本信息
                ManagementTraineeInfo traineeInfo = ManagementTraineeInfo.GetManagementTraineeInfo(emplid);
                if (traineeInfo != null)
                {
                    int year = Convert.ToInt32(traineeInfo.届别);
                    item = AddManagementTraineePayStandard(emplid, employee.姓名, year, 3, 0);

                    item.年份     = year;
                    item.季度     = 3;
                    item.增幅     = 0;
                    item.年薪     = traineeInfo.年薪;
                    item.月薪     = Convert.ToInt32((item.年薪 * (decimal)10000.0) / (decimal)12.0);
                    item.开始执行时间 = new DateTime(item.年份, 7, 1);

                    item.Save();
                }
            }
            return(item);
        }
        //计算季度差
        int GetQuarterInterval(ManagementTraineePayStandard item)
        {
            int x = this.年份 - item.年份;
            int y = this.季度 - item.季度;

            return(x * 4 + y);
        }
        protected override void OnSaving()
        {
            ManagementTraineePayStandard found = GetManagementTraineePayStandard(this.员工编号, this.年份, this.季度);

            if (found != null && found.标识 != this.标识)
            {
                throw new Exception("本期已存在该员工的第 " + 提资序数 + " 次的提资标准,不能重复创建。");
            }
            else
            {
                base.OnSaving();
            }

            MANAGEMENT_TRAINEE_PAY_STANDARD_CACHE.Set(CacheKey, this, TimeSpan.FromHours(1));
        }
        public static ManagementTraineePayStandard GetEffective(string empNo, DateTime date)
        {
            GroupOperator criteria = new GroupOperator(GroupOperatorType.And,
                                                       new BinaryOperator("员工编号", empNo, BinaryOperatorType.Equal),
                                                       new BinaryOperator("开始执行时间", date, BinaryOperatorType.LessOrEqual)
                                                       );

            XPCollection objset = new XPCollection(MyHelper.XpoSession, typeof(ManagementTraineePayStandard), criteria, new SortProperty("开始执行时间", SortingDirection.Descending));

            if (objset.Count > 0)
            {
                ManagementTraineePayStandard item = (ManagementTraineePayStandard)objset[0];
                return(item);
            }
            else
            {
                return(null);
            }
        }
        public static ManagementTraineePayStandard AddManagementTraineePayStandard(string emplid, string name, int year, int quarter, int time)
        {
            ManagementTraineePayStandard item = GetManagementTraineePayStandard(emplid, year, quarter);

            if (item == null)
            {
                item      = new ManagementTraineePayStandard();
                item.标识   = Guid.NewGuid();
                item.员工编号 = emplid;
                item.姓名   = name;
                item.年份   = year;
                item.季度   = quarter;
                item.提资序数 = time;
                item.创建人  = AccessController.CurrentUser.姓名;
                item.创建时间 = DateTime.Now;
                item.Save();
            }
            return(item);
        }
Пример #6
0
        private void ShowRiseRateForm(FormParameters formParams)
        {
            string division = (string)formParams.Parameters[0];
            string grade    = (string)formParams.Parameters[1];
            string type     = (string)formParams.Parameters[2];

            UpStepType ust = ManagementTraineePayStandard.GetUpStepType(division, grade, type);

            switch (ust)
            {
            case UpStepType.五年两段三类:
                RiseRate52Form riseRate52Form = new RiseRate52Form(division, grade, type);
                riseRate52Form.Owner = this;
                riseRate52Form.ShowDialog();
                break;

            case UpStepType.五年两段四类:
                RiseRate51Form riseRate51Form = new RiseRate51Form(division, grade, type);
                riseRate51Form.Owner = this;
                riseRate51Form.ShowDialog();
                break;

            case UpStepType.五年三段四类:
                RiseRate53Form riseRate62Form = new RiseRate53Form(division, grade, type);
                riseRate62Form.Owner = this;
                riseRate62Form.ShowDialog();
                break;

            case UpStepType.七年两段五类:
                RiseRate71Form riseRate71Form = new RiseRate71Form(division, grade, type);
                riseRate71Form.Owner = this;
                riseRate71Form.ShowDialog();
                break;

            case UpStepType.七年三段五类:
                RiseRate72Form riseRate72Form = new RiseRate72Form(division, grade, type);
                riseRate72Form.Owner = this;
                riseRate72Form.ShowDialog();
                break;
            }
        }
Пример #7
0
        //更新到正式表
        public void UpdateToFormalTable()
        {
            if (this.内容不同的字段.Count > 0)
            {
                return;
            }

            ManagementTraineePayStandard m = ManagementTraineePayStandard.GetManagementTraineePayStandard(this.员工编号, this.年份, this.季度);

            if (m == null)
            {
                m    = new ManagementTraineePayStandard();
                m.标识 = Guid.NewGuid();
            }
            this.CopyWatchMember(m);
            m.姓名     = 员工信息.姓名;
            m.提资序数   = this.提资序数;
            m.增幅     = this.增幅;
            m.月薪     = this.月薪;
            m.开始执行时间 = this.开始执行时间;
            m.备注     = this.备注;
            m.创建人    = this.录入人;
            m.创建时间   = DateTime.Now;
            m.Save();

            //更新生效标记
            if (!this.已生效)
            {
                this.生效时间 = DateTime.Now;
                this.Save();

                ManagementTraineePayStandardInput opposite = 另一人录入的记录;
                opposite.生效时间 = DateTime.Now;
                opposite.Save();
            }
        }
Пример #8
0
        public static ManagementTraineePayStandardInput AddManagementTraineePayStandardInput(string emplid, int year, int quarter, int order, int time, bool isVerify, bool copyEffective)
        {
            ManagementTraineePayStandardInput item = GetManagementTraineePayStandardInput(emplid, year, quarter, isVerify);

            if (item == null)
            {
                item = new ManagementTraineePayStandardInput();

                if (copyEffective)
                {
                    //将当前的管培生信息带进来
                    ManagementTraineePayStandard effectiveManagementTraineePayStandard = ManagementTraineePayStandard.GetManagementTraineePayStandard(emplid, year, quarter);
                    if (effectiveManagementTraineePayStandard != null)
                    {
                        item.CopyEffective = copyEffective;
                        effectiveManagementTraineePayStandard.CopyWatchMember(item);
                    }
                }

                DateTime 年度开始 = new DateTime(year, 1, 1);

                item.标识     = Guid.NewGuid();
                item.员工编号   = emplid;
                item.年份     = year;
                item.季度     = quarter;
                item.开始执行时间 = 年度开始.AddMonths(3 * (quarter - 1));
                item.序号     = order;
                item.提资序数   = time;
                item.是验证录入  = isVerify;
                item.录入人    = "";
                item.录入时间   = DateTime.Now;

                item.Save();
            }
            return(item);
        }
        public static List <ManagementTraineeSalaryPlan> GeneratePlanList(string division, string grade, string type, string level)
        {
            List <ManagementTraineeSalaryPlan> planList = new List <ManagementTraineeSalaryPlan>();

            int year_count    = ManagementTraineePayStandard.GetStepStartYear(division, grade, type, -1);
            int quarter_total = year_count * 4;

            List <ManagementTraineePayRiseStandard> standards = ManagementTraineePayRiseStandard.GetManagementTraineePayRiseStandardList(division, grade, type, level);

            int[] rise_flag_a_arr = new int[] {
                0, 0, 1, 0, //第一年
                1, 0, 1, 0, //第二年
                1, 0, 1, 0, //第三年
                1, 0, 1, 0, //第四年
                1, 0, 1, 0, //第五年
                1, 0, 1, 0, //第六年
                1, 0, 0, 0  //第七年
            };
            int[] rise_flag_b_arr = new int[] {
                0, 0, 1, 0, //第一年
                1, 0, 0, 1, //第二年
                0, 0, 1, 0, //第三年
                0, 1, 0, 0, //第四年
                1, 0, 0, 1, //第五年
                0, 0, 1, 0, //第六年
                1, 0, 0, 0  //第七年
            };

            int[] rise_flag_c_arr = new int[] {
                0, 0, 1, 0, //第一年
                1, 0, 0, 0, //第二年
                1, 0, 0, 0, //第三年
                1, 0, 0, 0, //第四年
                1, 0, 0, 0, //第五年
                1, 0, 0, 0, //第六年
                1, 0, 0, 0  //第七年
            };

            int     time             = 0; //提资序数
            decimal last_year_salary = 0; //上一期年薪

            for (int i = 0; i < quarter_total; i++)
            {
                bool riseFlag = false; //提资标记
                //获取当前季度所处的节点
                double step = ManagementTraineePayStandard.GetStep(division, grade, type, i);

                if (level == "A")
                {
                    riseFlag = rise_flag_a_arr[i] == 1;
                }
                if (level == "B")
                {
                    riseFlag = rise_flag_b_arr[i] == 1;
                }
                if (level == "C")
                {
                    riseFlag = rise_flag_c_arr[i] == 1;
                }

                if (step < 1 && step != 0)
                {
                    riseFlag = false;
                }
                if (riseFlag && time < 10000)
                {
                    time++;                           //如果提资,序数+1
                }
                //升阶(满足升阶条件,先升阶,每阶+100, 满阶是 10000)
                //2018-9-21 进入二阶段以后,达到也要达到提资时间间隔才能提资
                if (step >= 2 && time < 100 && riseFlag)
                {
                    time = 100;
                }
                if (step == 0)
                {
                    time = 10000; riseFlag = true;
                }

                ManagementTraineePayRiseStandard currStandard = standards.Find(a => a.提资序数 == time); //当前标准
                if (currStandard != null)
                {
                    decimal rise_rate   = 0;
                    decimal year_salary = 0;

                    //计算年薪和增幅
                    if (currStandard.提资方式 == (int)RiseType.金额)
                    {
                        year_salary = currStandard.年薪;
                        if (last_year_salary > 0)
                        {
                            rise_rate = 100 * ((decimal)(year_salary - last_year_salary) / (decimal)last_year_salary);
                            rise_rate = Math.Round(rise_rate, 1, MidpointRounding.AwayFromZero);
                        }
                    }
                    else
                    {
                        if (riseFlag) //如果提资
                        {
                            rise_rate   = currStandard.增幅;
                            year_salary = Math.Round(last_year_salary * (100 + rise_rate) * (decimal)0.01, 1, MidpointRounding.AwayFromZero);
                        }
                        else
                        {
                            year_salary = last_year_salary;
                        }
                    }

                    ManagementTraineeSalaryPlan item = new ManagementTraineeSalaryPlan();
                    item.届别   = division;
                    item.岗位级别 = grade;
                    item.能力级别 = level;
                    item.专业属性 = type;
                    item.季度序数 = i;
                    item.年度序数 = i / 4;
                    item.季度年薪 = year_salary;
                    if (riseFlag && rise_rate > 0)
                    {
                        item.增幅 = rise_rate.ToString("#0.#") + "%";
                        if (time == 10000 && step != 0)
                        {
                            item.增幅 = "";
                        }
                    }
                    planList.Add(item);

                    last_year_salary = year_salary;
                }
            }
            //统计年薪
            foreach (ManagementTraineeSalaryPlan item in planList)
            {
                List <ManagementTraineeSalaryPlan> list = planList.FindAll(a => a.年度序数 == item.年度序数);
                item.年薪 = Math.Round(list.Sum(a => a.季度年薪) / (decimal)4.0, 1, MidpointRounding.AwayFromZero);
            }
            return(planList);
        }
        public static ManagementTraineePayStandard GetManagementTraineePayStandard(Guid id)
        {
            ManagementTraineePayStandard obj = (ManagementTraineePayStandard)Session.DefaultSession.GetObjectByKey(typeof(ManagementTraineePayStandard), id);

            return(obj);
        }
        public static List <ManagementTraineePayStandard> CreatePayStandards(string emplid, int year)
        {
            EmployeeInfo employee = EmployeeInfo.GetFromCache(emplid);

            if (employee == null)
            {
                return(null);
            }

            //获取管培生基本信息
            ManagementTraineeInfo traineeInfo = ManagementTraineeInfo.GetManagementTraineeInfo(emplid);

            if (traineeInfo == null)
            {
                return(null);
            }

            DateTime start = new DateTime(year, 7, 1);
            ManagementTraineePayStandard first = CreateFirstStandard(emplid);
            //获取本年度评定前最后一次提资记录(增幅 > 0)
            ManagementTraineePayStandard latest = GetLatestRise(emplid, start);

            //如果没有找到提资记录,自动创建第一年的提资记录
            if (latest == null)
            {
                //第一年,已第一条记录为基准
                if (year == traineeInfo.入职时间.Year)
                {
                    latest = first;
                }
                else
                {
                    //创建入职当年的工资标准
                    CreatePayStandards(emplid, traineeInfo.入职时间.Year);
                    latest = GetLatestRise(emplid, start);
                }
            }
            if (latest == null)
            {
                return(null);                //如果找不到上一期提资记录,没法继续创建提资记录
            }
            //获取年度评定
            ManagementTraineeAbility ability = ManagementTraineeAbility.GetManagementTraineeAbility(emplid, year);
            string level = "A";
            string type  = traineeInfo.岗位级别 == "一级" ? traineeInfo.岗位类型 : traineeInfo.专业属性;
            //每年评定后自动产生后面四个季度的提资记录
            List <ManagementTraineePayStandard> list = new List <ManagementTraineePayStandard>();

            for (int i = 0; i < 4; i++)
            {
                decimal rise_rate    = 0;
                decimal year_salary  = latest.年薪;
                int     month_salary = latest.月薪;
                int     time         = -999; //如果次数是 -999 表示此季度不提资

                int quarter  = (i + 2) % 4 + 1;
                int the_year = quarter <= 2 ? year + 1 : year;

                int m = the_year - first.年份;
                int n = quarter - first.季度;
                int q = m * 4 + n; //距离起薪季度数

                int      x = the_year - latest.年份;
                int      y = quarter - latest.季度;
                int      quarterInterval = x * 4 + y; //距离最后一次提资季度数
                DateTime excuteStartTime = latest.开始执行时间.AddMonths(3 * quarterInterval);

                //获取提资序数
                //(第一年每半年固定提资)
                if (q <= 4)
                {
                    if (q == 2) //第一次提资
                    {
                        time = 1;
                    }
                    if (q == 4) //第二次提资
                    {
                        time = 2;
                    }
                }
                else
                {
                    if (ability == null)
                    {
                        continue;                  //如果还没有评定
                    }
                    level = ability.能力级别;
                    //默认本次提资序数=上一次提资序数+1
                    switch (level)
                    {
                    case "A":
                        if (quarterInterval >= 2)
                        {
                            time = latest.提资序数 + 1;
                        }
                        break;

                    case "B":
                        if (quarterInterval >= 3)
                        {
                            time = latest.提资序数 + 1;
                        }
                        break;

                    case "C":
                        if (quarterInterval >= 4)
                        {
                            time = latest.提资序数 + 1;
                        }
                        break;
                    }
                    //升阶(满足升阶条件,先升阶,每阶+100, 满阶是 10000)
                    double step = GetStep(traineeInfo.届别, traineeInfo.岗位级别, type, q);
                    if (step == 0)
                    {
                        time = 10000;
                    }
                    //2018-9-21 进入二阶段以后,达到也要达到提资时间间隔才能提资
                    if (step >= 2 && time > 0 && time < 100)
                    {
                        time = 100;
                    }
                }

                if (time == -999)
                {
                    continue;
                }

                ManagementTraineePayRiseStandard standard = ManagementTraineePayRiseStandard.GetManagementTraineePayRiseStandard(traineeInfo.届别, traineeInfo.岗位级别, type, level, time);
                if (standard == null)
                {
                    continue;                   //找不到提资标准
                }
                //获取增幅、年薪和月薪
                if (standard.提资方式 == (int)RiseType.金额)
                {
                    year_salary = standard.年薪;
                    rise_rate   = 100 * ((decimal)(year_salary - latest.年薪) / (decimal)latest.年薪);
                    rise_rate   = Math.Round(rise_rate, 1, MidpointRounding.AwayFromZero);
                }
                else
                {
                    rise_rate   = standard.增幅;
                    year_salary = Math.Round(latest.年薪 * (100 + rise_rate) * (decimal)0.01, 1, MidpointRounding.AwayFromZero);
                }

                month_salary = Convert.ToInt32((year_salary * (decimal)10000.0) / (decimal)12.0);

                ManagementTraineePayStandard new_item = AddManagementTraineePayStandard(emplid, employee.姓名, the_year, quarter, time);
                if (new_item != null)
                {
                    new_item.季度     = quarter;
                    new_item.年份     = the_year;
                    new_item.增幅     = rise_rate;
                    new_item.年薪     = year_salary;
                    new_item.月薪     = month_salary;
                    new_item.开始执行时间 = excuteStartTime;
                    new_item.Save();

                    list.Add(new_item);
                    latest = new_item;
                }
                if (time == 10000)
                {
                    break;                //已经满阶,退出
                }
            }
            return(list);
        }
        //获取值指定管培生月薪表
        public static List <ManagementTraineeSalary> GetMonthlySalaryList(ManagementTraineeInfo trainee, int year)
        {
            List <ManagementTraineeSalary> list = new List <ManagementTraineeSalary>();

            if (trainee == null)
            {
                return(list);
            }

            //获取本年所有提资记录
            List <ManagementTraineePayStandard> standards = ManagementTraineePayStandard.GetManagementTraineePayStandards(trainee.员工编号);

            standards = standards.OrderByDescending(a => a.开始执行时间).ToList(); //倒序, 以便按时间找到的第一条记录就是执行的记录
            ManagementTraineePayStandard last_rise = null;

            if (standards.Count > 0)
            {
                //上月标准(去年最后一次提资)
                ManagementTraineePayStandard prev = standards.Find(a => a.开始执行时间 < new DateTime(year, 1, 1));
                //最近一次评定
                ManagementTraineeAbility last_ability = ManagementTraineeAbility.GetLastAbility(trainee.员工编号);
                //最近一次提资
                last_rise = standards[0]; //最后一次提资
                //构造月薪记录
                for (int i = 1; i <= 12; i++)
                {
                    ManagementTraineeSalary salary = new ManagementTraineeSalary();
                    DateTime start = new DateTime(year, i, 1);
                    ManagementTraineePayStandard effectiveStandard = standards.Find(a => a.开始执行时间 <= start);
                    //如果有执行标准
                    if (effectiveStandard != null)
                    {
                        salary.员工编号  = trainee.员工编号;
                        salary.姓名    = trainee.姓名;
                        salary.年份    = year;
                        salary.季度    = (int)((i - 0.5) / 3) + 1;
                        salary.月份    = i;
                        salary.专业属性  = trainee.专业属性;
                        salary.管培生信息 = trainee;
                        salary.年薪    = effectiveStandard.年薪;
                        salary.月薪    = effectiveStandard.月薪;
                        if (prev != null && salary.年薪 > prev.年薪)
                        {
                            salary.增幅 = effectiveStandard.增幅.ToString("#0.##") + "%";
                        }

                        if (salary.年薪 > 0)
                        {
                            salary.年薪_万元 = salary.年薪.ToString("#0.#");
                        }

                        //不能超过最后一次提资记录的那个季度,
                        int x = salary.年份 - last_rise.年份;
                        int y = salary.季度 - last_rise.季度;
                        if (x * 4 + y <= 0)
                        {
                            list.Add(salary);
                        }
                        else
                        {
                            if (last_ability != null)
                            {
                                int m = salary.年份 - last_ability.年度;
                                int n = salary.季度 - 3;
                                if (m * 4 + n < 4)
                                {
                                    list.Add(salary);
                                }
                            }
                        }
                        prev = effectiveStandard;
                    }
                }
            }
            return(list);
        }