///// <summary> ///// 移除离职人员 ///// </summary> ///// <param name="EmployeeList"></param> ///// <param name="dt"></param> ///// <returns></returns> //public List<Employee> RemoveDimissionhAndBorrowed(List<Employee> EmployeeList, DateTime dt) //{ // List<Employee> returnEmployee = new List<Employee>(); // DateTime dtFrom = new DateTime(dt.Year, dt.Month, 1); // DateTime dtTo = dtFrom.AddMonths(1).AddDays(-1); // for (int i = 0; i < EmployeeList.Count; i++) // { // //外借员工 // if (EmployeeList[i].EmployeeType == EmployeeTypeEnum.BorrowedEmployee) // { // continue; // } // //根据入职离职时间 // Employee employee = _GetEmployee.GetEmployeeBasicInfoByAccountID(EmployeeList[i].Account.Id); // if (employee.EmployeeDetails == null || employee.EmployeeDetails.Work == null) // { // continue; // } // DateTime employeeFromDate = DateTime.Compare(employee.EmployeeDetails.Work.ComeDate, dtFrom) > 0 // ? employee.EmployeeDetails.Work.ComeDate // : dtFrom; // DateTime employeeToDate; // if (employee.EmployeeType == EmployeeTypeEnum.DimissionEmployee && // employee.EmployeeDetails.Work.DimissionInfo != null) // { // employeeToDate = // DateTime.Compare(employee.EmployeeDetails.Work.DimissionInfo.DimissionDate, dtTo) < 0 // ? employee.EmployeeDetails.Work.DimissionInfo.DimissionDate // : dtTo; // } // else // { // employeeToDate = dtTo; // } // if (DateTime.Compare(employeeFromDate, employeeToDate) > 0) // { // continue; // } // returnEmployee.Add(EmployeeList[i]); // } // return returnEmployee; //} /// <summary> /// 统计某个时间段内的某个部门以及其所有子部门的员工的薪资情况 /// </summary> /// <param name="startDt">统计的开始时间</param> /// <param name="endDt">统计的结束时间</param> /// <param name="departmentID">统计的部门编号</param> /// <param name="item">统计项--帐套项的List</param> /// <returns></returns> /// <param name="companyID"></param> /// <param name="isIncludeChildDeptMember"></param> /// <param name="loginUser"></param> public List <EmployeeSalaryAverageStatistics> AverageStatistics(DateTime startDt, DateTime endDt, int departmentID, AccountSetPara item, int companyID, bool isIncludeChildDeptMember, Account loginUser) { List <EmployeeSalaryAverageStatistics> iRet = new List <EmployeeSalaryAverageStatistics>(); //划分月份 List <DateTime> Months = SplitMonth(startDt, endDt); //查出每个月份月底这个时间点的,某一部门及其所有子部门(包括改过名字部门) List <Department> AllDepartment = GetAllDepartment(Months, departmentID); AllDepartment = Tools.RemoteUnAuthDeparetment(AllDepartment, AuthType.HRMIS, loginUser, HrmisPowers.A607); //构建返回的List foreach (Department department in AllDepartment) { EmployeeSalaryAverageStatistics employeeSalaryAverageStatistics = new EmployeeSalaryAverageStatistics(); employeeSalaryAverageStatistics.Department = department; EmployeeSalaryStatisticsItem employeeSalaryStatisticsSumItem = new EmployeeSalaryStatisticsItem(); employeeSalaryStatisticsSumItem.ItemID = item.AccountSetParaID; employeeSalaryStatisticsSumItem.ItemName = item.AccountSetParaName; EmployeeSalaryStatisticsItem employeeSalaryStatisticsAverageItem = new EmployeeSalaryStatisticsItem(); employeeSalaryStatisticsAverageItem.ItemName = item.AccountSetParaName + "均值"; EmployeeSalaryStatisticsItem employeeSalaryStatisticsEmployeeCountItem = new EmployeeSalaryStatisticsItem(); employeeSalaryStatisticsEmployeeCountItem.ItemName = "人数"; employeeSalaryAverageStatistics.SumItem = employeeSalaryStatisticsSumItem; employeeSalaryAverageStatistics.AverageItem = employeeSalaryStatisticsAverageItem; employeeSalaryAverageStatistics.EmployeeCountItem = employeeSalaryStatisticsEmployeeCountItem; iRet.Add(employeeSalaryAverageStatistics); } //计算每个月 for (int j = 0; j < Months.Count; j++) { //得到这个月的所有部门 List <Department> departmentList = _GetDepartmentHistory.GetDepartmentNoStructByDateTime(Months[j]); departmentList = Tools.RemoteUnAuthDeparetment(departmentList, AuthType.HRMIS, loginUser, HrmisPowers.A607); List <Employee> EmployeesSourceTemp = _GetEmployee.GetEmployeeWithCurrentMonthDimissionEmployee( new HrmisUtility().StartMonthByYearMonth(Months[j]), companyID); EmployeesSourceTemp = HrmisUtility.RemoteUnAuthEmployee(EmployeesSourceTemp, AuthType.HRMIS, loginUser, HrmisPowers.A607); //List<Employee> EmployeesSource = RemoveDimissionAndBorrowed(EmployeesSourceTemp, Months[j]); List <Account> accountSource = EmployeeUtility.GetAccountListFromEmployeeList(EmployeesSourceTemp); for (int k = 0; k < AllDepartment.Count; k++) { //查找这个月,这个部门中的所有人,包括子部门 AllDepartment[k].Members = FindAllEmployeeByDepAndTime(departmentList, AllDepartment[k], Months[j], accountSource, isIncludeChildDeptMember); //累计计算每月员工个数 iRet[k].EmployeeCountItem.CalculateValue = iRet[k].EmployeeCountItem.CalculateValue + AllDepartment[k].Members.Count; //循环部门里的员工 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; } iRet[k].SumItem.CalculateValue = iRet[k].SumItem.CalculateValue + accountSetItem.CalculateResult; } } } for (int k = 0; k < AllDepartment.Count; k++) { //计算平均值 if (iRet[k].EmployeeCountItem.CalculateValue == 0) { iRet[k].AverageItem.CalculateValue = 0; } else { iRet[k].AverageItem.CalculateValue = iRet[k].SumItem.CalculateValue / iRet[k].EmployeeCountItem.CalculateValue; } //计算每月平均员工人数 iRet[k].EmployeeCountItem.CalculateValue = iRet[k].EmployeeCountItem.CalculateValue / Months.Count; iRet[k].AverageItem.CalculateValue = Convert.ToDecimal(iRet[k].AverageItem.CalculateValue.ToString("0.00")); iRet[k].EmployeeCountItem.CalculateValue = Convert.ToDecimal(iRet[k].EmployeeCountItem.CalculateValue.ToString("0.00")); iRet[k].SumItem.CalculateValue = Convert.ToDecimal(iRet[k].SumItem.CalculateValue.ToString("0.00")); } return(iRet); }
/// <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); }
/// <summary> /// 统计某个时间段内的某个部门以及其所有子部门的员工的报销统计情况 /// </summary> /// <param name="startDt">统计的开始时间</param> /// <param name="endDt">统计的结束时间</param> /// <param name="departmentID">统计的部门编号</param> /// <returns></returns> /// <param name="companyID"></param> /// <param name="isIncludeChildDeptMember"></param> /// <param name="loginUser"></param> public List <EmployeeReimburseStatistics> DepartmentStatistics(DateTime startDt, DateTime endDt, int departmentID, int companyID, bool isIncludeChildDeptMember, Account loginUser) { List <EmployeeReimburseStatistics> iRet = new List <EmployeeReimburseStatistics>(); //划分月份 List <DateTime> Months = SplitMonth(startDt, endDt); //查出每个月份月底这个时间点的,某一部门及其所有子部门(包括改过名字部门) List <Department> AllDepartment = GetAllDepartment(Months, departmentID); AllDepartment = Tools.RemoteUnAuthDeparetment(AllDepartment, AuthType.HRMIS, loginUser, HrmisPowers.A903); //构建返回的List foreach (Department department in AllDepartment) { EmployeeReimburseStatistics EmployeeReimburseStatistics = new EmployeeReimburseStatistics(); EmployeeReimburseStatistics.Department = department; iRet.Add(EmployeeReimburseStatistics); } //得到这个月的所有部门 List <Department> departmentList = _GetDepartmentHistory.GetDepartmentNoStructByDateTime(endDt); departmentList = Tools.RemoteUnAuthDeparetment(departmentList, AuthType.HRMIS, loginUser, HrmisPowers.A903); List <Employee> EmployeesSource = _GetEmployeeHistory.GetAllEmployeeByDepartmentAndDateTime(AllDepartment[0].Id, endDt, true); if (companyID != -1) { for (int x = 0; x < EmployeesSource.Count; x++) { if ( EmployeesSource[x].EmployeeDetails == null || EmployeesSource[x].EmployeeDetails.Work == null || EmployeesSource[x].EmployeeDetails.Work.Company == null || EmployeesSource[x].EmployeeDetails.Work.Company.Id != companyID) { EmployeesSource.RemoveAt(x); x--; } } } List <Account> accountSource = EmployeeUtility.GetAccountListFromEmployeeList(EmployeesSource); for (int k = 0; k < AllDepartment.Count; k++) { //查找这个部门中的所有人,包括子部门 AllDepartment[k].Members = FindAllEmployeeByDepAndTime(departmentList, AllDepartment[k], accountSource, isIncludeChildDeptMember); //循环部门里的员工 foreach (Account account in AllDepartment[k].AllMembers) { CalculateEmployeeReimburse(iRet[k], account.Id, startDt, endDt); } } AddTotleItem(iRet); if (!isIncludeChildDeptMember) { CaculateSumReimburseStatistics(iRet, isIncludeChildDeptMember); } return(iRet); }