/// <summary> /// 根据员工ID和时间获取出差申请记录 /// </summary> /// <param name="strEmployeeId"></param> /// <param name="dtTempDate"></param> /// <returns></returns> //public T_HR_EMPLOYEEEVECTIONRECORD GetEmployeeEvectionRdByEmployeeIdAndDate(string strEmployeeId, DateTime? dtstart,DateTime dtend) //{ // var q=from ent in dal.GetObjects() // where ent.STARTDATE>=dtstart && ent.ENDDATE<=dtend // select ent; //} /// <summary> /// 批量新增出差记录 /// </summary> /// <param name="entTempList"></param> public void AddEvectionRdList(List <T_HR_EMPLOYEEEVECTIONRECORD> entTempList) { try { EmployeeEvectionRecordBLL bll = new EmployeeEvectionRecordBLL(); if (entTempList == null) { return; } if (entTempList.Count() == 0) { return; } foreach (T_HR_EMPLOYEEEVECTIONRECORD entTemp in entTempList) { bll.EmployeeEvectionRecordADD(entTemp); } } catch (Exception ex) { Utility.SaveLog(ex.ToString()); } }
/// <summary> /// 根据传入员工ID和月份(年-月:2011-6),更新指定月份员工作息记录 /// </summary> /// <param name="strEmployeeID"></param> public void UpdateAttendRecordByEmployeeIdWithEvectionRecord(string strEmployeeID, string strCurMonth) { try { if (string.IsNullOrWhiteSpace(strEmployeeID) || string.IsNullOrWhiteSpace(strCurMonth)) { return; } DateTime dtCheck = new DateTime(); DateTime dtStart = new DateTime(), dtEnd = new DateTime(); DateTime.TryParse(strCurMonth + "-1", out dtStart); if (dtStart <= dtCheck) { return; } dtEnd = dtStart.AddMonths(1).AddDays(-1); IQueryable <T_HR_ATTENDANCERECORD> entAttRds = GetAttendanceRecordByEmployeeIDAndDate(strEmployeeID, dtStart, dtEnd); EmployeeEvectionRecordBLL bllEvection = new EmployeeEvectionRecordBLL(); IQueryable <T_HR_EMPLOYEEEVECTIONRECORD> entEvectionRds = bllEvection.GetEmployeeEvectionRecordsByEmployeeIdAndDate(strEmployeeID, dtStart); if (entAttRds == null || entEvectionRds == null) { return; } if (entAttRds.Count() == 0 || entEvectionRds.Count() == 0) { return; } List <T_HR_EMPLOYEEEVECTIONRECORD> entCheckEvectionRds = entEvectionRds.ToList(); List <T_HR_ATTENDANCERECORD> entCheckAttRds = new List <T_HR_ATTENDANCERECORD>(); foreach (T_HR_ATTENDANCERECORD item in entAttRds) { bool bIsEvection = false; foreach (T_HR_EMPLOYEEEVECTIONRECORD checkItem in entCheckEvectionRds) { DateTime dtCheckStart = DateTime.Parse(checkItem.STARTDATE.Value.ToString("yyyy-MM-dd")); DateTime dtCheckEnd = DateTime.Parse(checkItem.ENDDATE.Value.ToString("yyyy-MM-dd")); if (dtCheckStart <= item.ATTENDANCEDATE && dtCheckEnd >= item.ATTENDANCEDATE) { bIsEvection = true; break; } } if (!bIsEvection) { continue; } if (item.ATTENDANCESTATE == (Convert.ToInt32(Common.AttendanceState.Travel) + 1).ToString()) { continue; } item.ATTENDANCESTATE = (Convert.ToInt32(Common.AttendanceState.Travel) + 1).ToString(); ModifyAttRd(item); entCheckAttRds.Add(item); } if (entCheckAttRds.Count() > 0) { RemoveWrongSignRds(entCheckAttRds); } } catch (Exception ex) { Utility.SaveLog(ex.ToString()); } }
/// <summary> /// 检查员工请假出差情况 /// </summary> /// <param name="entAttRd">当天的考勤初始化记录</param> /// <param name="entClockInRds">打卡原始记录</param> /// <param name="strMsg">处理结果的消息</param> /// <param name="bIsAbnorm">是否出现考勤异常的标志(true/false)</param> private void CheckEvectionRecordAndLeaveRecordAttendState(string EMPLOYEEID, DateTime dtStartDate, DateTime dtEndDate, ref string strMsg, ref bool bIsAbnorm) { try { dtEndDate = dtEndDate.AddDays(1).AddSeconds(-1); //获取请假记录使用的起止时间 //DateTime dtStartDate = entAttRd.ATTENDANCEDATE.Value; //DateTime dtEndDate = entAttRd.ATTENDANCEDATE.Value.AddDays(1).AddSeconds(-1); #region 启动出差处理考勤异常的线程 //查询出差记录,检查当天存在出差情况 EmployeeEvectionRecordBLL bllEvectionRd = new EmployeeEvectionRecordBLL(); var entityEvections = from ent in dal.GetObjects <T_HR_EMPLOYEEEVECTIONRECORD>() where ent.EMPLOYEEID == EMPLOYEEID && ent.CHECKSTATE == "2" && ( (ent.STARTDATE <= dtStartDate && ent.ENDDATE >= dtStartDate) || (ent.STARTDATE <= dtEndDate && ent.ENDDATE >= dtEndDate) || (ent.STARTDATE >= dtStartDate && ent.ENDDATE <= dtEndDate) ) select ent; //如果有出差记录,就判断出差是否为全天 if (entityEvections.Count() > 0) { foreach (var ent in entityEvections) { //出差消除异常 string attState = (Convert.ToInt32(Common.AttendanceState.Travel) + 1).ToString(); DealEmployeeAbnormRecord(EMPLOYEEID, ent.STARTDATE.Value, ent.ENDDATE.Value, attState); } } #endregion #region 启动请假处理考勤异常的线程 //查询请假记录,检查当天存在请假情况 EmployeeLeaveRecordBLL bllLeaveRd = new EmployeeLeaveRecordBLL(); IQueryable <T_HR_EMPLOYEELEAVERECORD> entLeaveRds = from e in dal.GetObjects <T_HR_EMPLOYEELEAVERECORD>().Include("T_HR_LEAVETYPESET") where e.EMPLOYEEID == EMPLOYEEID && e.CHECKSTATE == "2" && ( (e.STARTDATETIME <= dtStartDate && e.ENDDATETIME >= dtStartDate) || (e.STARTDATETIME <= dtEndDate && e.ENDDATETIME >= dtEndDate) || (e.STARTDATETIME >= dtStartDate && e.ENDDATETIME <= dtEndDate) ) select e; var sql = ((System.Data.Objects.ObjectQuery)entLeaveRds).ToTraceString(); sql.ToString(); if (entLeaveRds.Count() > 0) { foreach (var ent in entLeaveRds) { //请假消除异常 string attState = (Convert.ToInt32(Common.AttendanceState.Leave) + 1).ToString(); DealEmployeeAbnormRecord(ent.EMPLOYEEID, ent.STARTDATETIME.Value, ent.ENDDATETIME.Value, attState); } } #endregion #region 启动外出申请处理考勤异常的线程 //查询请假记录,检查当天存在请假情况 var entOutApplyRds = from ent in dal.GetObjects <T_HR_OUTAPPLYRECORD>() where ent.EMPLOYEEID == EMPLOYEEID && ent.CHECKSTATE == "2" && ( (ent.STARTDATE <= dtStartDate && ent.ENDDATE >= dtStartDate) || (ent.STARTDATE <= dtEndDate && ent.ENDDATE >= dtEndDate) || (ent.STARTDATE >= dtStartDate && ent.ENDDATE <= dtEndDate) ) select ent; if (entOutApplyRds.Count() > 0) { foreach (var ent in entOutApplyRds) { //外出申请消除异常 string attState = (Convert.ToInt32(Common.AttendanceState.OutApply) + 1).ToString(); DealEmployeeAbnormRecord(ent.EMPLOYEEID, ent.STARTDATE.Value, ent.ENDDATE.Value, attState); } } #endregion } catch (Exception ex) { Tracer.Debug("员工打卡记录导入检查员工请假出差情况异常:" + ex.ToString()); } strMsg = "{SAVESUCCESSED}"; }