コード例 #1
0
        /// <summary>
        /// 得到单个员工的进出记录
        /// </summary>
        private void GetInAndOutRecords()
        {
            _Employee = new GetEmployee().GetEmployeeBasicInfoByAccountID(_EmployeeId);
            List <AttendanceInAndOutRecord> records =
                _IRecord.GetAttendanceInAndOutRecordByCondition(_EmployeeId, string.Empty,
                                                                Convert.ToDateTime("1900-1-1"),
                                                                Convert.ToDateTime("2999-12-31"), InOutStatusEnum.All,
                                                                OutInRecordOperateStatusEnum.All,
                                                                Convert.ToDateTime("1900-1-1"),
                                                                Convert.ToDateTime("2999-12-31"));


            if (_Employee.EmployeeAttendance == null)
            {
                _Employee.EmployeeAttendance = new EmployeeAttendance(_TheDate, _TheDate);
            }
            _Employee.EmployeeAttendance.AttendanceInAndOutRecordList = new List <AttendanceInAndOutRecord>();
            records.Add(_Record);
            _Employee.EmployeeAttendance.AttendanceInAndOutRecordList = records;
            _Employee.EmployeeAttendance.DayAttendanceList            = new List <DayAttendance>();
            //加载排班信息
            _Employee.EmployeeAttendance.PlanDutyDetailList =
                new PlanDutyDal().GetPlanDutyDetailByAccount(_Employee.Account.Id,
                                                             _TheDate, _TheDate);
        }
コード例 #2
0
 /// <summary>
 /// 统计考勤结果,以天为单位
 /// </summary>
 private void UpdateAttendance()
 {
     //UpdateEmployeeAttendance updateEmployeeAttendance = new UpdateEmployeeAttendance(_LoginUser);
     for (int i = 0; i < AllEmployeeList.Count; i++)
     {
         //找前一天数据
         DateTime tempDate = _SearchTo.AddDays(-1);
         while (DateTime.Compare(Convert.ToDateTime(_SearchFrom.ToShortDateString()),
                                 Convert.ToDateTime(tempDate.ToShortDateString())) <= 0)
         {
             AllEmployeeList[i].EmployeeAttendance.AttendanceInAndOutRecordList =
                 _DalRecord.GetAttendanceInAndOutRecordByCondition
                     (AllEmployeeList[i].Account.Id, "", tempDate, tempDate.AddDays(1),
                     InOutStatusEnum.All, OutInRecordOperateStatusEnum.All,
                     Convert.ToDateTime("1900-1-1"), Convert.ToDateTime("2900-12-31"));
             //updateEmployeeAttendance.
             //    UpdateEmployeeDayAttendance(AllEmployeeList[i], tempDate);
             tempDate = tempDate.AddDays(-1);
         }
     }
 }
コード例 #3
0
        ///<summary>
        ///</summary>
        ///<param name="from"></param>
        ///<param name="to"></param>
        ///<param name="accountList"></param>
        ///<param name="loginUser"></param>
        public void UpdateAttendanceForOperator(DateTime from, DateTime to,
                                                List <Account> accountList, Account loginUser)
        {
            //UpdateEmployeeAttendance updateEmployeeAttendance = new UpdateEmployeeAttendance(loginUser);

            List <Employee> AllEmployeeList = new List <Employee>();
            GetEmployee     getEmployee     = new GetEmployee();

            foreach (Account account in accountList)
            {
                AllEmployeeList.Add(getEmployee.GetEmployeeBasicInfoByAccountID(account.Id));
            }
            for (int i = 0; i < AllEmployeeList.Count; i++)
            {
                //找前一天数据
                DateTime tempDate = to;
                while (DateTime.Compare(Convert.ToDateTime(from.ToShortDateString()),
                                        Convert.ToDateTime(tempDate.ToShortDateString())) <= 0)
                {
                    AllEmployeeList[i] = _DalEmployee.GetEmployeeByAccountID(AllEmployeeList[i].Account.Id);
                    AllEmployeeList[i].EmployeeAttendance = new Model.EmployeeAttendance.AttendanceStatistics.EmployeeAttendance
                                                                (tempDate.AddDays(-1), tempDate);
                    AllEmployeeList[i].EmployeeAttendance.AttendanceInAndOutRecordList =
                        _DalRecord.GetAttendanceInAndOutRecordByCondition
                            (AllEmployeeList[i].Account.Id, "",
                            Convert.ToDateTime(tempDate.ToShortDateString() + " 00:00:00"),
                            Convert.ToDateTime(tempDate.ToShortDateString() + " 23:59:59"),
                            InOutStatusEnum.All, OutInRecordOperateStatusEnum.All,
                            Convert.ToDateTime("1900-1-1"), Convert.ToDateTime("2900-12-31"));
                    AllEmployeeList[i].EmployeeAttendance.DoorCardNo =
                        _DalEmployee.GetEmployeeBasicInfoByAccountID(AllEmployeeList[i].Account.Id).EmployeeAttendance.
                        DoorCardNo;
                    AllEmployeeList[i].EmployeeAttendance.PlanDutyDetailList =
                        new PlanDutyDal().GetPlanDutyDetailByAccount(
                            AllEmployeeList[i].Account.Id,
                            Convert.ToDateTime(tempDate.ToShortDateString() + " 00:00:00"),
                            Convert.ToDateTime(tempDate.ToShortDateString() + " 23:59:59"));

                    //updateEmployeeAttendance.
                    //    UpdateEmployeeDayAttendance(AllEmployeeList[i], tempDate);
                    tempDate = tempDate.AddDays(-1);
                }
            }
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        public List <Employee> GetAttendanceOutInRecordByCondition(string employeeName, int?gradesId, int departmentID,
                                                                   DateTime from, DateTime to, OutInTimeConditionEnum outInTimeCondition)
        {
            List <Employee> retEmployeeList = new List <Employee>();

            //List<Account> accountList = _IAccountBll.GetAccountByBaseCondition(employeeName, departmentID, -1, gradesId, true, null);
            //if (departmentID == -1)
            //{
            //    accountList = Tools.RemoteUnAuthAccount(accountList, AuthType.HRMIS, _LoginUser, HrmisPowers.A503);
            //}

            //_GetEmployee = new GetEmployee();
            //List<Employee> EmployeeList = _GetEmployee.GetEmployeeAttendenceInfoByAccountList(accountList, EmployeeTypeEnum.All, -1);
            int?powerID = null;

            if (departmentID == -1)
            {
                powerID = HrmisPowers.A503;
            }

            var EmployeeList = EmployeeLogic.GetEmployeeBasicInfoByBasicConditionRetModel(employeeName,
                                                                                          EmployeeTypeEnum.All, -1, gradesId, departmentID, null, true, powerID, _LoginUser.Id, -1,
                                                                                          new List <int>()
            {
                (int)EmployeeTypeEnum.BorrowedEmployee
            }, true);

            for (int i = 0; i < EmployeeList.Count; i++)
            {
                if (EmployeeList[i].EmployeeType == EmployeeTypeEnum.BorrowedEmployee)
                {
                    continue;
                }
                ////获取排班信息
                //EmployeeList[i].EmployeeAttendance.PlanDutyDetailList =
                //    new PlanDutyDal().GetPlanDutyDetailByAccount(
                //    EmployeeList[i].Account.Id, from, to);
                ////如果员工没有排班信息
                //if (EmployeeList[i].EmployeeAttendance.PlanDutyDetailList == null
                //    || EmployeeList[i].EmployeeAttendance.PlanDutyDetailList.Count == 0)
                //{
                //    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.FromDate = employeeFromDate;
                EmployeeList[i].EmployeeAttendance.ToDate   = employeeToDate;
                EmployeeList[i].EmployeeAttendance.AttendanceInAndOutRecordList =
                    _dalAttendanceInAndOutRecord.GetAttendanceInAndOutRecordByCondition(EmployeeList[i].Account.Id, "",
                                                                                        from, to, InOutStatusEnum.All,
                                                                                        OutInRecordOperateStatusEnum.All,
                                                                                        Convert.ToDateTime("1900-1-1"),
                                                                                        Convert.ToDateTime("2900-12-31"));

                //日详细
                EmployeeList[i].EmployeeAttendance.DayAttendanceList = new List <DayAttendance>();
                EmployeeList[i].EmployeeAttendance.DayAttendanceList.AddRange(new GetBadAttendance(_LoginUser).GetCalendarByEmployee(EmployeeList[i].Account.Id,
                                                                                                                                     EmployeeList[i].EmployeeAttendance.FromDate,
                                                                                                                                     EmployeeList[i].EmployeeAttendance.ToDate, AttendanceTypeEmnu.All));

                //请假
                EmployeeList[i].EmployeeAttendance.DayAttendanceList.AddRange(
                    new GetLeaveRequest().GetCalendarByEmployee(EmployeeList[i].Account.Id, from, to));

                //加班
                EmployeeList[i].EmployeeAttendance.DayAttendanceList.AddRange(
                    new GetOverWork().GetCalendarByEmployee(EmployeeList[i].Account.Id, from, to));

                //外出
                EmployeeList[i].EmployeeAttendance.DayAttendanceList.AddRange(
                    new GetOutApplication().GetCalendarByEmployee(EmployeeList[i].Account.Id, from, to));

                //统计考勤
                EmployeeList[i].EmployeeAttendance.InAndOutStatistics(employeeFromDate);
                if (EmployeeList[i].EmployeeAttendance.IsOutInTimeCondition(outInTimeCondition, true))
                {
                    retEmployeeList.Add(EmployeeList[i]);
                }
            }
            return(retEmployeeList);
        }
コード例 #5
0
        /// <summary>
        /// 获得员工的考勤信息
        /// </summary>
        /// <param name="employee"></param>
        /// <param name="FromDate"></param>
        /// <param name="ToDate"></param>
        private static bool GetEmployeeAttendanceInfo(Employee employee, DateTime FromDate, DateTime ToDate)
        {
            if (employee.EmployeeType == EmployeeTypeEnum.BorrowedEmployee)
            {
                return(false);
            }
            //根据入职离职时间确定考勤的有效时间
            DateTime employeeFromDate = DateTime.Compare(employee.EmployeeDetails.Work.ComeDate, FromDate) > 0
                                            ? employee.EmployeeDetails.Work.ComeDate
                                            : FromDate;
            DateTime employeeToDate;

            if (employee.EmployeeType == EmployeeTypeEnum.DimissionEmployee && employee.EmployeeDetails.Work.DimissionInfo != null)
            {
                employeeToDate =
                    DateTime.Compare(employee.EmployeeDetails.Work.DimissionInfo.DimissionDate, ToDate) < 0
                        ? employee.EmployeeDetails.Work.DimissionInfo.DimissionDate
                        : ToDate;
            }
            else
            {
                employeeToDate = ToDate;
            }
            employeeToDate = employeeToDate.AddDays(1).AddSeconds(-1);
            if (DateTime.Compare(employeeFromDate, employeeToDate) > 0)
            {
                return(false);
            }
            employee.EmployeeAttendance = new EmployeeAttendance(employeeFromDate, employeeToDate);
            //打卡信息
            employee.EmployeeAttendance.AttendanceInAndOutRecordList =
                _dalAttendanceInAndOutRecord.GetAttendanceInAndOutRecordByCondition(employee.Account.Id, "",
                                                                                    employeeFromDate,
                                                                                    employeeToDate,
                                                                                    InOutStatusEnum.All,
                                                                                    OutInRecordOperateStatusEnum.All,
                                                                                    Convert.ToDateTime("1900-1-1"),
                                                                                    Convert.ToDateTime("2900-12-31"));
            //考勤规则
            employee.EmployeeAttendance.PlanDutyDetailList =
                _IPlanDutyDal.GetPlanDutyDetailByAccount(employee.Account.Id, employeeFromDate, employeeToDate);
            //迟到早退旷工详情
            employee.EmployeeAttendance.DayAttendanceList.AddRange(
                _GetBadAttendance.GetCalendarByEmployee(employee.Account.Id,
                                                        employee.EmployeeAttendance.FromDate,
                                                        employee.EmployeeAttendance.ToDate, AttendanceTypeEmnu.All));
            //请假详情
            employee.EmployeeAttendance.DayAttendanceList.AddRange(
                _GetLeaveRequest.GetCalendarByEmployee(employee.Account.Id,
                                                       employee.EmployeeAttendance.FromDate,
                                                       employee.EmployeeAttendance.ToDate));
            //加班外出申请
            employee.EmployeeAttendance.DayAttendanceList.AddRange(
                _GetOutApplication.GetCalendarByEmployee(employee.Account.Id,
                                                         employee.EmployeeAttendance.FromDate,
                                                         employee.EmployeeAttendance.ToDate));
            employee.EmployeeAttendance.DayAttendanceList.AddRange(
                _GetOverWork.GetCalendarByEmployee(employee.Account.Id,
                                                   employee.EmployeeAttendance.FromDate,
                                                   employee.EmployeeAttendance.ToDate));
            return(true);
        }
コード例 #6
0
        private int ImportDate(DataTable dt)
        {
            List <Employee> employeeList = new List <Employee>();
            DateTime        dt_Now       = DateTime.Now;

            //Employee employee
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                _Name = GetItem(dt, i, _NameColumn);
                if (string.IsNullOrEmpty(_Name))
                {
                    continue;
                }
                Employee employee = employeeList.Find(FindEmployee);
                if (employee == null)
                {
                    Account account = _IAccountBll.GetAccountByName(_Name);
                    //如果系统里没有该员工或者该员工在系统中没有门禁卡卡号
                    if (account == null)
                    {
                        continue;
                    }
                    employee = getEmployee.GetEmployeeAttendenceInfoByAccountID(account.Id);
                    if (employee == null)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(employee.EmployeeAttendance.DoorCardNo))
                    {
                        continue;
                    }
                    employee.EmployeeAttendance.AttendanceInAndOutRecordList = new List <AttendanceInAndOutRecord>();
                    employeeList.Add(employee);
                }
                AttendanceInAndOutRecord attendanceInAndOutRecord = new AttendanceInAndOutRecord();
                attendanceInAndOutRecord.IOStatus = GetInOutStatusByInOutName(GetItem(dt, i, _InOutColumn));
                try
                {
                    var      date = Convert.ToDateTime(GetItem(dt, i, _DateColumn));
                    DateTime time;
                    if (DateTime.TryParse(GetItem(dt, i, _TimeColumn), out time))
                    {
                        attendanceInAndOutRecord.IOTime = new DateTime(date.Year, date.Month, date.Day, time.Hour, time.Minute, time.Second);
                    }
                    else
                    {
                        attendanceInAndOutRecord.IOTime = Convert.ToDateTime(date.ToString("yyyy-MM-dd") + " " + GetItem(dt, i, _TimeColumn));
                    }
                }
                catch
                {
                    continue;
                }
                attendanceInAndOutRecord.OperateStatus = OutInRecordOperateStatusEnum.ImportByOperator;
                attendanceInAndOutRecord.OperateTime   = dt_Now;
                //判断读取中是否有重复记录 add by liudan 2009-09-19
                List <AttendanceInAndOutRecord> sqlRecords =
                    attendanceInAndOutRecordDal.GetAttendanceInAndOutRecordByCondition(employee.Account.Id,
                                                                                       employee.EmployeeAttendance.
                                                                                       DoorCardNo,
                                                                                       Convert.ToDateTime("1900-12-31"),
                                                                                       Convert.ToDateTime("2999-12-31"),
                                                                                       InOutStatusEnum.All,
                                                                                       OutInRecordOperateStatusEnum.All,
                                                                                       Convert.ToDateTime("1900-12-31"),
                                                                                       Convert.ToDateTime("2999-12-31"));
                bool isFind = false;
                foreach (AttendanceInAndOutRecord records in sqlRecords)
                {
                    if (attendanceInAndOutRecord.IOStatus.Equals(records.IOStatus) &&
                        attendanceInAndOutRecord.IOTime.Equals(records.IOTime))
                    {
                        isFind = true;
                    }
                }
                if (!isFind)
                {
                    employee.EmployeeAttendance.AttendanceInAndOutRecordList.Add(attendanceInAndOutRecord);
                    count = count + 1;
                }
            }
            attendanceInAndOutRecordDal.InsertAttendanceInAndOutRecordList(employeeList);
            return(employeeList.Count);
        }