public static ContractWorkload StatisHSDepartmentYearCategoryWorkLoad(HSDepartment department, int year, ContractCategory category) { if (department.IsHigherDepatmentHasSub() == true) // 如果当前部门是一个有下属部门的一级部门 { //Console.WriteLine("部门{0}是一个有子部门的一级部门", department.Name); return(DALContractStatistic.StatisHigherDepartmentYearCategoryWorkLoad(department, year, category)); } else if (department.IsHigherDepatmentNoSub() == true) { //Console.WriteLine("部门{0}是无子部门的一级部门", department.Name); return(DALContractStatistic.StatisDepartmentYearCategoryWorkLoad(department, year, category)); } else if (department.IsStatisTotalDepartment() == true) { //Console.WriteLine("部门{0}要求统计所有部门的总和", department.Name); return(DALContractStatistic.StatisYearCategoryWorkLoad(year, category)); } else if (department.IsStatisRegularDepartment() == true) { //Console.WriteLine("部门{0}要求统计计划任务额度", department.Name); return(DALContractStatistic.StatisYearCategoryRegularLoad(year, category)); } else if (department.IsSubDepartment() == true) // 如果当前部门是一个下属子部门 { // Console.WriteLine("部门{0}是下属子部门", department.Name); return(null); } return(null); }
public static ContractWorkload StatisHigherDepartmentYearCategoryWorkLoad(HSDepartment highDepartment, int year, ContractCategory category) { // 首先获取到当前一级部门的所有下级部门信息 List <HSDepartment> departments = DALHSDepartment.QuerySubHSDepartment(highDepartment.Id); ContractWorkload totalWorkloads = new ContractWorkload { Work = 0, Expense = 0, }; foreach (HSDepartment department in departments) { ContractWorkload workload = DALContractStatistic.StatisDepartmentYearCategoryWorkLoad(department, year, category); totalWorkloads.Work += workload.Work; totalWorkloads.Expense += workload.Expense; } return(totalWorkloads); }