/// <summary> /// 各部门设备信息(包括收入、支出、服务人次) /// </summary> /// <returns>各部门设备信息</returns> public List <DepartPerformanceModel> IncomeExpenseByDepartment(string date) { List <DepartPerformanceModel> models = new List <DepartPerformanceModel>(); DepartPerformanceModel model = null; int curYear = DateTime.Today.Year; if (!string.IsNullOrEmpty(date)) { curYear = Convert.ToDateTime(date).Year; } if (WebConfig.ISDEMO) { curYear = new DateTime(2019, 11, 12).Year; } int lastYear = curYear - 1; DataTable dtEquipmentCount = this.equipmentDao.GetEquipmentInfoCountsByDepartment(); List <ServiceHisCountInfo> serviceInfosThisYear = this.serviceHisDao.GetServiceHisCountsByDepartment(curYear); List <ServiceHisCountInfo> accessoryExpensesThisYear = this.serviceHisDao.GetAccessoryExpenseByDepartment(curYear); List <ServiceHisCountInfo> serviceInfosLastYear = this.serviceHisDao.GetServiceHisCountsByDepartment(lastYear); List <ServiceHisCountInfo> accessoryExpensesLastYear = this.serviceHisDao.GetAccessoryExpenseByDepartment(lastYear); ServiceHisCountInfo serviceInfo = null; foreach (DataRow dr in dtEquipmentCount.Rows) { model = new DepartPerformanceModel(); model.Department = LookupManager.GetDepartments(SQLUtil.ConvertInt(dr["DepartmentID"])); model.EquipmentCount = SQLUtil.ConvertInt(dr["Counts"]); model.EquipmentAmount = SQLUtil.ConvertDouble(dr["Amounts"]); serviceInfo = (from ServiceHisCountInfo temp in serviceInfosThisYear where temp.ObjectID == model.Department.ID select temp).FirstOrDefault(); if (serviceInfo != null) { model.ServiceCount = serviceInfo.ServiceCount; model.Incomes = serviceInfo.Incomes; } serviceInfo = (from ServiceHisCountInfo temp in accessoryExpensesThisYear where temp.ObjectID == model.Department.ID select temp).FirstOrDefault(); if (serviceInfo != null) { model.Expenses = serviceInfo.Expenses; } serviceInfo = (from ServiceHisCountInfo temp in serviceInfosLastYear where temp.ObjectID == model.Department.ID select temp).FirstOrDefault(); if (serviceInfo != null) { model.LastIncomes = serviceInfo.Incomes; } serviceInfo = (from ServiceHisCountInfo temp in accessoryExpensesLastYear where temp.ObjectID == model.Department.ID select temp).FirstOrDefault(); if (serviceInfo != null) { model.LastExpenses = serviceInfo.Expenses; } models.Add(model); } return(models); }