/// <summary>
        /// 根据条件获得员工基本信息列表及公司工龄 add by liudan 2009-08-07
        /// </summary>
        public List <Employee> GetEmployeeBasicInfoByBasicConditionWithCompanyAge(string employeeName,
                                                                                  EmployeeTypeEnum employeeType, int positionID, int?gradesID,
                                                                                  int departmentID, int?CompanyAgeFrom, int?CompanyAgeTo,
                                                                                  bool recursionDepartment, int employeeStatus)
        {
            List <Employee> employeeList = new List <Employee>();
            //List<Account> accountList =
            //    _IAccountBll.GetAccountByBaseCondition(employeeName, departmentID, positionID,gradesID, recursionDepartment, null);
            //foreach (Account account in accountList)
            //{
            //    Employee employee = GetEmployeeBasicInfoByAccountID(account.Id);
            //    if (employee == null)
            //    {
            //        continue;
            //    }
            //    if (employeeType != EmployeeTypeEnum.All && employeeType != employee.EmployeeType)
            //    {
            //        continue;
            //    }
            //    if (!employee.IsNeedEmployeeStatusCondition(employeeStatus))
            //    {
            //        continue;
            //    }
            //    TimeSpan ts = DateTime.Today.Subtract(employee.EmployeeDetails.Work.ComeDate);
            //    int days = Convert.ToInt32(ts.TotalDays);
            //    if ((CompanyAgeFrom != null && days < CompanyAgeFrom))
            //    {
            //        continue;
            //    }
            //    if ((CompanyAgeTo != null && days > CompanyAgeTo))
            //    {
            //        continue;
            //    }
            //    employeeList.Add(employee);
            //}
            var list = EmployeeLogic.GetEmployeeBasicInfoByBasicConditionWithCompanyAge(employeeName,
                                                                                        employeeType, positionID, gradesID,
                                                                                        departmentID, CompanyAgeFrom, CompanyAgeTo,
                                                                                        recursionDepartment, employeeStatus);

            foreach (var e in list)
            {
                employeeList.Add(EmployeeEntity.Convert(e));
            }
            return(employeeList);
        }
        public static List <Employee> GetEmployeeBasicInfoByBasicConditionRetModel(string employeeName,
                                                                                   EmployeeTypeEnum employeeType,
                                                                                   int positionID,
                                                                                   int?gradesID,
                                                                                   int departmentID,
                                                                                   int?companyID,
                                                                                   bool recursionDepartment,
                                                                                   int?powerID, int?accountID,
                                                                                   int employeeStatus, List <int> notInEmployeeType, bool?hasPlanDuty = null)
        {
            List <EmployeeEntity> list = EmployeeDA.GetEmployeeBasicInfoByBasicCondition(employeeName, (int)employeeType,
                                                                                         positionID, gradesID, companyID,
                                                                                         DepartmentLogic.GetDepartmentids(departmentID, recursionDepartment),
                                                                                         powerID == null ? null : AccountAuthDA.GetAccountAuthDepartment(accountID.Value, powerID.Value),
                                                                                         employeeStatus, notInEmployeeType, hasPlanDuty);
            var employeeList = new List <Employee>();

            foreach (EmployeeEntity employeeEntity in list)
            {
                employeeList.Add(EmployeeEntity.Convert(employeeEntity));
            }
            return(employeeList);
        }
        /// <summary>
        /// 通过条件查找员工的请假,加班,外出情况,便于人事后台查看流程流转状态
        /// </summary>
        public List <Request> GetRequestRecordByCondition(string employeeName, int departmentID, int?gradeType,
                                                          DateTime from, DateTime to, ApplicationTypeEnum applicationType,
                                                          RequestStatus applicationStatus, Account loginUser)
        {
            List <Request> applicationList = new List <Request>();

            var list = EmployeeLogic.GetEmployeeBasicInfoByBasicCondition(employeeName, EmployeeTypeEnum.All, -1,
                                                                          gradeType, departmentID, true,
                                                                          HrmisPowers.A509, loginUser.Id, -1,
                                                                          new List <int>
            {
                (int)EmployeeTypeEnum.BorrowedEmployee
            });

            List <Employee> employeeList = new List <Employee>();

            foreach (var employeeEntity in list)
            {
                employeeList.Add(EmployeeEntity.Convert(employeeEntity));
            }
            //  new GetEmployee().GetEmployeeBasicInfoByBasicCondition(employeeName, EmployeeTypeEnum.All, -1, departmentID, true, -1, gradeType);
            //if (departmentID==-1)//如果查全部员工需去掉没有查询权限的员工
            //{
            //    EmployeeList = HrmisUtility.RemoteUnAuthEmployee(EmployeeList, AuthType.HRMIS, loginUser, HrmisPowers.A509);
            //}
            for (int i = 0; i < employeeList.Count; i++)
            {
                //if (EmployeeList[i] == null || EmployeeList[i].EmployeeType == EmployeeTypeEnum.BorrowedEmployee)
                //{
                //    continue;
                //}

                //根据入职离职时间确定考勤的有效时间

                DateTime employeeFromDate = DateTime.Compare(employeeList[i].EmployeeDetails.Work.ComeDate, from) > 0
                                                ? employeeList[i].EmployeeDetails.Work.ComeDate
                                                : from;
                DateTime employeeToDate;
                if (employeeList[i].EmployeeType == EmployeeTypeEnum.DimissionEmployee &&
                    employeeList[i].EmployeeDetails.Work.DimissionInfo != null)
                {
                    employeeToDate =
                        DateTime.Compare(employeeList[i].EmployeeDetails.Work.DimissionInfo.DimissionDate, to) < 0
                            ? employeeList[i].EmployeeDetails.Work.DimissionInfo.DimissionDate
                            : to;
                }
                else
                {
                    employeeToDate = to;
                }
                if (DateTime.Compare(employeeFromDate, employeeToDate) > 0)
                {
                    continue;
                }
                employeeList[i].EmployeeAttendance = new EmployeeAttendance(employeeFromDate, employeeToDate);
                employeeList[i].EmployeeAttendance.PlanDutyDetailList = _DalRull.GetPlanDutyDetailByAccount(employeeList[i].Account.Id, employeeFromDate, employeeToDate);
                //没有考勤规则的人不会这里出现
                if (employeeList[i].EmployeeAttendance.PlanDutyDetailList == null ||
                    employeeList[i].EmployeeAttendance.PlanDutyDetailList.Count == 0)
                {
                    continue;
                }
                List <Request> applicationListTemp = new List <Request>();
                switch (applicationType)
                {
                case ApplicationTypeEnum.All:
                    applicationListTemp.AddRange(
                        GetRequestFromLeaveRequest(employeeList[i].Account.Id,
                                                   employeeList[i].EmployeeAttendance.FromDate, employeeList[i].EmployeeAttendance.ToDate,
                                                   applicationStatus));
                    applicationListTemp.AddRange(
                        GetRequestFromOutApplication(employeeList[i].Account.Id,
                                                     employeeList[i].EmployeeAttendance.FromDate, employeeList[i].EmployeeAttendance.ToDate,
                                                     applicationStatus, OutType.All));
                    applicationListTemp.AddRange(
                        GetRequestFromOverWork(employeeList[i].Account.Id,
                                               employeeList[i].EmployeeAttendance.FromDate, employeeList[i].EmployeeAttendance.ToDate,
                                               applicationStatus));
                    break;

                case ApplicationTypeEnum.LeaveRequest:
                    applicationListTemp.AddRange(
                        GetRequestFromLeaveRequest(employeeList[i].Account.Id,
                                                   employeeList[i].EmployeeAttendance.FromDate, employeeList[i].EmployeeAttendance.ToDate,
                                                   applicationStatus));
                    break;

                case ApplicationTypeEnum.InCityOut:
                    applicationListTemp.AddRange(
                        GetRequestFromOutApplication(employeeList[i].Account.Id,
                                                     employeeList[i].EmployeeAttendance.FromDate, employeeList[i].EmployeeAttendance.ToDate,
                                                     applicationStatus, OutType.InCity));
                    break;

                case ApplicationTypeEnum.OutCityOut:
                    applicationListTemp.AddRange(
                        GetRequestFromOutApplication(employeeList[i].Account.Id,
                                                     employeeList[i].EmployeeAttendance.FromDate, employeeList[i].EmployeeAttendance.ToDate,
                                                     applicationStatus, OutType.OutCity));
                    break;

                case ApplicationTypeEnum.TrainOut:
                    applicationListTemp.AddRange(
                        GetRequestFromOutApplication(employeeList[i].Account.Id,
                                                     employeeList[i].EmployeeAttendance.FromDate, employeeList[i].EmployeeAttendance.ToDate,
                                                     applicationStatus, OutType.Train));
                    break;

                case ApplicationTypeEnum.OverTime:
                    applicationListTemp.AddRange(
                        GetRequestFromOverWork(employeeList[i].Account.Id,
                                               employeeList[i].EmployeeAttendance.FromDate, employeeList[i].EmployeeAttendance.ToDate,
                                               applicationStatus));
                    break;

                default:
                    break;
                }
                foreach (Request request in applicationListTemp)
                {
                    request.Account.Name = employeeList[i].Account.Name;
                }
                applicationList.AddRange(applicationListTemp);
            }
            return(applicationList);
        }