Ejemplo n.º 1
0
        /// <summary>
        /// 计算PositionStatistics总计
        /// </summary>
        /// <param name="employeeSalaryStatisticsList"></param>
        private static void CaculateSumPositionStatistics(List <EmployeeSalaryStatistics> employeeSalaryStatisticsList)
        {
            EmployeeSalaryStatistics sumEmployeeSalaryStatistics = new EmployeeSalaryStatistics();

            sumEmployeeSalaryStatistics.Position         = new Position(0, "总计", null);
            sumEmployeeSalaryStatistics.Position.Members = new List <Account>();
            sumEmployeeSalaryStatistics.EmployeeSalaryStatisticsItemList = new List <EmployeeSalaryStatisticsItem>();
            if (employeeSalaryStatisticsList.Count <= 0)
            {
                return;
            }
            foreach (EmployeeSalaryStatisticsItem employeeSalaryStatisticsItem in employeeSalaryStatisticsList[0].EmployeeSalaryStatisticsItemList)
            {
                EmployeeSalaryStatisticsItem sumEmployeeSalaryStatisticsItem = new EmployeeSalaryStatisticsItem();
                sumEmployeeSalaryStatisticsItem.ItemID   = employeeSalaryStatisticsItem.ItemID;
                sumEmployeeSalaryStatisticsItem.ItemName = employeeSalaryStatisticsItem.ItemName;
                sumEmployeeSalaryStatistics.EmployeeSalaryStatisticsItemList.Add(sumEmployeeSalaryStatisticsItem);
            }
            foreach (EmployeeSalaryStatistics employeeSalaryStatistics in employeeSalaryStatisticsList)
            {
                sumEmployeeSalaryStatistics.Position.Members.AddRange(employeeSalaryStatistics.Position.Members);
                for (int i = 0; i < sumEmployeeSalaryStatistics.EmployeeSalaryStatisticsItemList.Count; i++)
                {
                    sumEmployeeSalaryStatistics.EmployeeSalaryStatisticsItemList[i].CalculateValue +=
                        employeeSalaryStatistics.EmployeeSalaryStatisticsItemList[i].CalculateValue;
                }
            }
            employeeSalaryStatisticsList.Add(sumEmployeeSalaryStatistics);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 计算总计
        /// </summary>
        /// <param name="employeeSalaryStatisticsList"></param>
        /// <param name="isIncludeChildDeptMember"></param>
        private static void CaculateSumDepartmentStatistics(List <EmployeeSalaryStatistics> employeeSalaryStatisticsList, bool isIncludeChildDeptMember)
        {
            EmployeeSalaryStatistics sumEmployeeSalaryStatistics = new EmployeeSalaryStatistics();

            sumEmployeeSalaryStatistics.Department         = new Department(0, "总计");
            sumEmployeeSalaryStatistics.Department.Members = new List <Account>();
            sumEmployeeSalaryStatistics.EmployeeSalaryStatisticsItemList = new List <EmployeeSalaryStatisticsItem>();
            if (employeeSalaryStatisticsList.Count <= 0)
            {
                return;
            }
            foreach (EmployeeSalaryStatisticsItem employeeSalaryStatisticsItem in employeeSalaryStatisticsList[0].EmployeeSalaryStatisticsItemList)
            {
                EmployeeSalaryStatisticsItem sumEmployeeSalaryStatisticsItem = new EmployeeSalaryStatisticsItem();
                sumEmployeeSalaryStatisticsItem.ItemID   = employeeSalaryStatisticsItem.ItemID;
                sumEmployeeSalaryStatisticsItem.ItemName = employeeSalaryStatisticsItem.ItemName;
                sumEmployeeSalaryStatistics.EmployeeSalaryStatisticsItemList.Add(sumEmployeeSalaryStatisticsItem);
            }
            foreach (EmployeeSalaryStatistics employeeSalaryStatistics in employeeSalaryStatisticsList)
            {
                if (isIncludeChildDeptMember
                    &&
                    IsDeptInEmployeeSalaryStatisticsList(employeeSalaryStatistics.Department.ParentDepartment.Id,
                                                         employeeSalaryStatisticsList))
                //如果累积到上级部门的 则此方法只需累加第一层部门的所有CalculateValue
                {
                    continue;
                }
                sumEmployeeSalaryStatistics.Department.Members.AddRange(employeeSalaryStatistics.Department.Members);
                for (int i = 0; i < sumEmployeeSalaryStatistics.EmployeeSalaryStatisticsItemList.Count; i++)
                {
                    sumEmployeeSalaryStatistics.EmployeeSalaryStatisticsItemList[i].CalculateValue +=
                        employeeSalaryStatistics.EmployeeSalaryStatisticsItemList[i].CalculateValue;
                }
            }
            employeeSalaryStatisticsList.Add(sumEmployeeSalaryStatistics);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据部门分组
        /// </summary>
        /// <param name="startDt"></param>
        /// <param name="endDt"></param>
        /// <param name="departmentID"></param>
        /// <param name="item"></param>
        /// <param name="companyID"></param>
        /// <param name="isIncludeChildDeptMember"></param>
        /// <returns></returns>
        /// <param name="loginUser"></param>
        public List <EmployeeSalaryStatistics> TimeSpanStatisticsGroupByDepartment(DateTime startDt, DateTime endDt, int departmentID,
                                                                                   AccountSetPara item, int companyID, bool isIncludeChildDeptMember, Account loginUser)
        {
            List <EmployeeSalaryStatistics> iRet = new List <EmployeeSalaryStatistics>();
            //划分月份
            List <DateTime> Months = SplitMonth(startDt, endDt);
            //查出每个月份月底这个时间点的,某一部门及其所有子部门(包括改过名字部门)
            List <Department> AllDepartment = GetAllDepartment(Months, departmentID);

            AllDepartment = Tools.RemoteUnAuthDeparetment(AllDepartment, AuthType.HRMIS, loginUser, HrmisPowers.A607);

            //计算每个月
            for (int j = 0; j < Months.Count; j++)
            {
                EmployeeSalaryStatistics employeeSalaryStatistics = new EmployeeSalaryStatistics();
                employeeSalaryStatistics.SalaryDay = Months[j];
                employeeSalaryStatistics.EmployeeSalaryStatisticsItemList = new List <EmployeeSalaryStatisticsItem>();

                //得到这个月的所有部门
                List <Department> departmentList = _GetDepartmentHistory.GetDepartmentNoStructByDateTime(Months[j]);
                departmentList =
                    Tools.RemoteUnAuthDeparetment(departmentList, AuthType.HRMIS, loginUser, HrmisPowers.A607);
                List <Employee> EmployeesSource =
                    _GetEmployee.GetEmployeeWithCurrentMonthDimissionEmployee(
                        new HrmisUtility().StartMonthByYearMonth(Months[j]), companyID);
                EmployeesSource =
                    HrmisUtility.RemoteUnAuthEmployee(EmployeesSource, AuthType.HRMIS, loginUser, HrmisPowers.A607);
                List <Account> accountSource = EmployeeUtility.GetAccountListFromEmployeeList(EmployeesSource);
                for (int k = 0; k < AllDepartment.Count; k++)
                {
                    EmployeeSalaryStatisticsItem employeeSalaryStatisticsItem = new EmployeeSalaryStatisticsItem();
                    employeeSalaryStatisticsItem.ItemName = AllDepartment[k].DepartmentName;
                    employeeSalaryStatisticsItem.ItemID   = AllDepartment[k].DepartmentID;
                    //查找这个月,这个部门中的所有人,包括子部门
                    AllDepartment[k].Members =
                        FindAllEmployeeByDepAndTime(departmentList, AllDepartment[k], Months[j], accountSource, isIncludeChildDeptMember);

                    //循环部门里的员工
                    foreach (Account account in AllDepartment[k].AllMembers)
                    {
                        //查找某时,某人的薪资历史
                        EmployeeSalaryHistory employeeSalaryHistory =
                            _GetEmployeeAccountSet.GetEmployeeSalaryHistoryByEmployeeIdAndDateTime
                                (account.Id, Months[j]);
                        if (employeeSalaryHistory == null ||
                            employeeSalaryHistory.EmployeeAccountSet == null ||
                            employeeSalaryHistory.EmployeeAccountSet.Items == null)
                        {
                            continue;
                        }
                        AccountSetItem accountSetItem =
                            employeeSalaryHistory.EmployeeAccountSet.FindAccountSetItemByParaID(item.AccountSetParaID);
                        if (accountSetItem == null)
                        {
                            continue;
                        }
                        employeeSalaryStatisticsItem.CalculateValue =
                            employeeSalaryStatisticsItem.CalculateValue + accountSetItem.CalculateResult;
                    }
                    employeeSalaryStatistics.EmployeeSalaryStatisticsItemList.Add(employeeSalaryStatisticsItem);
                }
                iRet.Add(employeeSalaryStatistics);
            }
            return(iRet);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 根据帐套项分组
        /// </summary>
        /// <param name="startDt"></param>
        /// <param name="endDt"></param>
        /// <param name="departmentID"></param>
        /// <param name="companyID"></param>
        /// <param name="items"></param>
        /// <returns></returns>
        /// <param name="loginUser"></param>
        public List <EmployeeSalaryStatistics> TimeSpanStatisticsGroupByParameter(DateTime startDt, DateTime endDt,
                                                                                  int departmentID, List <AccountSetPara> items, int companyID, Account loginUser)
        {
            List <EmployeeSalaryStatistics> iRet = new List <EmployeeSalaryStatistics>();

            #region 划分月份

            List <DateTime> Months = SplitMonth(startDt, endDt);
            //计算每个月
            for (int j = 0; j < Months.Count; j++)
            {
                EmployeeSalaryStatistics employeeSalaryStatistics = new EmployeeSalaryStatistics();
                employeeSalaryStatistics.SalaryDay = Months[j];

                employeeSalaryStatistics.EmployeeSalaryStatisticsItemList = new List <EmployeeSalaryStatisticsItem>();

                for (int i = 0; i < items.Count; i++)
                {
                    EmployeeSalaryStatisticsItem item = new EmployeeSalaryStatisticsItem();
                    item.ItemID   = items[i].AccountSetParaID;
                    item.ItemName = items[i].AccountSetParaName;
                    employeeSalaryStatistics.EmployeeSalaryStatisticsItemList.Add(item);
                }

                iRet.Add(employeeSalaryStatistics);
            }

            #endregion

            for (int j = 0; j < Months.Count; j++)
            {
                //根据月份、部门获取当时的部门
                List <Department> itsSource =
                    _GetDepartmentHistory.GetDepartmentListStructByDepartmentIDAndDateTime(departmentID, Months[j]);
                itsSource =
                    Tools.RemoteUnAuthDeparetment(itsSource, AuthType.HRMIS, loginUser, HrmisPowers.A607);
                //根据月份获取当时的员工信息
                List <Employee> EmployeesSource =
                    _GetEmployee.GetEmployeeWithCurrentMonthDimissionEmployee(
                        new HrmisUtility().StartMonthByYearMonth(Months[j]), companyID);
                EmployeesSource =
                    HrmisUtility.RemoteUnAuthEmployee(EmployeesSource, AuthType.HRMIS, loginUser, HrmisPowers.A607);
                //遍历部门,找到当时该部门的员工,然后分别获取当月的发薪历史
                foreach (Department department in itsSource)
                {
                    List <Employee> employees = FindEmployee(EmployeesSource, department);

                    foreach (Employee employee in employees)
                    {
                        EmployeeSalaryHistory employeeSalaryHistory =
                            _GetEmployeeAccountSet.GetEmployeeSalaryHistoryByEmployeeIdAndDateTime(employee.Account.Id,
                                                                                                   Months[j]);
                        if (employeeSalaryHistory == null ||
                            employeeSalaryHistory.EmployeeAccountSet == null ||
                            employeeSalaryHistory.EmployeeAccountSet.Items == null)
                        {
                            continue;
                        }
                        //循环每一个需要统计的项,累加结果
                        for (int i = 0; i < iRet[j].EmployeeSalaryStatisticsItemList.Count; i++)
                        {
                            AccountSetItem accountSetItem =
                                employeeSalaryHistory.EmployeeAccountSet.FindAccountSetItemByParaID(
                                    iRet[j].EmployeeSalaryStatisticsItemList[i].ItemID);
                            if (accountSetItem == null)
                            {
                                continue;
                            }
                            iRet[j].EmployeeSalaryStatisticsItemList[i].CalculateValue += accountSetItem.CalculateResult;
                        }
                    }
                }
            }
            return(iRet);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 按照职位,统计某个时间段内的某个部门以及其所有子部门的员工的薪资情况
        /// </summary>
        /// <param name="startDt">统计的开始时间</param>
        /// <param name="endDt">统计的结束时间</param>
        /// <param name="departmentID">统计的部门编号</param>
        /// <param name="items">统计项--帐套项的List</param>
        /// <returns></returns>
        /// <param name="companyID"></param>
        /// <param name="loginUser"></param>
        public List <EmployeeSalaryStatistics> PositionStatistics(DateTime startDt, DateTime endDt, int departmentID,
                                                                  List <AccountSetPara> items, int companyID, Account loginUser)
        {
            List <EmployeeSalaryStatistics> iRet = new List <EmployeeSalaryStatistics>();
            List <EmployeeSalary>           employeeSalaryList = new List <EmployeeSalary>();
            List <Employee> employeeList = new List <Employee>();

            if (items != null && items.Count > 0)
            {
                //按月拆分
                List <DateTime> monthLastDays = SplitMonth(startDt, endDt);

                foreach (DateTime day in monthLastDays)
                {
                    //根据月份、部门获取当时的部门
                    List <Department> itsSource =
                        _GetDepartmentHistory.GetDepartmentListStructByDepartmentIDAndDateTime(departmentID, day);
                    itsSource =
                        Tools.RemoteUnAuthDeparetment(itsSource, AuthType.HRMIS, loginUser, HrmisPowers.A607);
                    //根据月份获取当时的员工信息
                    List <Employee> EmployeesSource =
                        _GetEmployee.GetEmployeeWithCurrentMonthDimissionEmployee(new HrmisUtility().StartMonthByYearMonth(day), companyID);
                    EmployeesSource =
                        HrmisUtility.RemoteUnAuthEmployee(EmployeesSource, AuthType.HRMIS, loginUser, HrmisPowers.A607);
                    //遍历部门,找到当时该部门的员工,然后分别获取当月的发薪历史
                    foreach (Department department in itsSource)
                    {
                        List <Employee> employees = FindEmployee(EmployeesSource, department);
                        employeeList.AddRange(employees);

                        foreach (Employee employee in employees)
                        {
                            EmployeeSalary employeeSalary = new EmployeeSalary(employee.Account.Id);
                            employeeSalary.Employee = employee;
                            employeeSalary.EmployeeSalaryHistoryList = new List <EmployeeSalaryHistory>();
                            employeeSalary.EmployeeSalaryHistoryList.Add(
                                _GetEmployeeAccountSet.GetEmployeeSalaryHistoryByEmployeeIdAndDateTime(
                                    employee.Account.Id,
                                    day));
                            employeeSalaryList.Add(employeeSalary);
                        }
                    }
                }

                //根据所有员工信息,筛选出当时的所有职位
                List <Position> positionList = GetPositionListFromEmployeeList(employeeList);
                //遍历所有职位,按照帐套项分别计算
                foreach (Position position in positionList)
                {
                    EmployeeSalaryStatistics employeeSalaryStatistics = new EmployeeSalaryStatistics();
                    employeeSalaryStatistics.Position = position;
                    employeeSalaryStatistics.EmployeeSalaryStatisticsItemList = new List <EmployeeSalaryStatisticsItem>();

                    for (int i = 0; i < items.Count; i++)
                    {
                        EmployeeSalaryStatisticsItem item = new EmployeeSalaryStatisticsItem();
                        item.ItemID         = items[i].AccountSetParaID;
                        item.ItemName       = items[i].AccountSetParaName;
                        item.CalculateValue = CalculateByPosition(position, items[i], employeeSalaryList);
                        employeeSalaryStatistics.EmployeeSalaryStatisticsItemList.Add(item);
                    }

                    iRet.Add(employeeSalaryStatistics);
                }
            }
            CaculateSumPositionStatistics(iRet);
            return(iRet);
        }