/// <summary> /// 周文斌添加 /// 获取一个时间段内的考勤方案, /// 例如:员工请假从5月10-8月30日 /// 这里跨越了5,6,7,8三个月的考勤时间段 /// StartToEndDate的格式为:StartDate|EndDate; yyyy-MM-dd|yyyy-MM-dd /// /// </summary> /// <param name="EmployeeID"></param> /// <param name="StartToEndDate"></param> /// <returns></returns> public List <T_HR_ATTENDANCESOLUTION> GetAttendenceSolutionByEmployeeIDAndStartDateAndEndDate(string EmployeeID, List <string> StartToEndDate) { List <T_HR_ATTENDANCESOLUTION> solutionList = new List <T_HR_ATTENDANCESOLUTION>(); foreach (string str in StartToEndDate) { DateTime StartDate = Convert.ToDateTime(str.Split('|')[0]); DateTime EndDate = Convert.ToDateTime(str.Split('|')[1]); AttendanceSolutionDAL dalAttendanceSolution = new AttendanceSolutionDAL(); T_HR_ATTENDANCESOLUTION entAttSol = dalAttendanceSolution.GetAttendanceSolutionByEmployeeIDAndDate(EmployeeID, StartDate, EndDate); if (entAttSol != null) { solutionList.Add(entAttSol); } else { StartDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-01")); AttendanceSolutionAsignBLL bllAttSolAsign = new AttendanceSolutionAsignBLL(); T_HR_ATTENDANCESOLUTIONASIGN entAttSolAsign = bllAttSolAsign.GetAttendanceSolutionAsignByEmployeeIDAndDate(EmployeeID, StartDate); solutionList.Add(entAttSolAsign.T_HR_ATTENDANCESOLUTION); } } return(solutionList); }
/// <summary> /// 根据考勤初始化记录获取考勤方案,获取不到则获取员工最新分配的考勤方案 /// </summary> /// <param name="strEmployeeID">员工ID</param> /// <param name="dtStart">考勤记录参考起始日期</param> /// <param name="dtEnd">考勤记录参考截止日期</param> /// <returns></returns> public T_HR_ATTENDANCESOLUTION GetAttendanceSolutionByEmployeeIDAndDate(string strEmployeeID, DateTime dtStart, DateTime dtEnd) { if (string.IsNullOrEmpty(strEmployeeID)) { return(null); } AttendanceSolutionDAL dalAttendanceSolution = new AttendanceSolutionDAL(); T_HR_ATTENDANCESOLUTION entAttSol = dalAttendanceSolution.GetAttendanceSolutionByEmployeeIDAndDate(strEmployeeID, dtStart, dtEnd); if (entAttSol == null) { dtStart = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-01")); AttendanceSolutionAsignBLL bllAttSolAsign = new AttendanceSolutionAsignBLL(); T_HR_ATTENDANCESOLUTIONASIGN entAttSolAsign = bllAttSolAsign.GetAttendanceSolutionAsignByEmployeeIDAndDate(strEmployeeID, dtStart); if (entAttSolAsign == null) { return(null); } return(entAttSolAsign.T_HR_ATTENDANCESOLUTION); } return(entAttSol); }
/// <summary> /// 将定时触发考勤初始化记录生成的配置信息存入引擎 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnInitAttendRdByEngine_Click(object sender, EventArgs e) { if (Session["LOGINUSER"] == null) { plLogin.Visible = true; plManage.Visible = false; return; } //待发布 DateTime dtStart = DateTime.Parse(DateTime.Now.ToString("yyyy-MM") + "-1"); T_HR_ATTENDANCESOLUTIONASIGN entTemp = new T_HR_ATTENDANCESOLUTIONASIGN(); entTemp.STARTDATE = dtStart; AttRdSvc.GetAttendSolAsignForOutEngineXml(entTemp); }
private T_HR_ATTENDANCESOLUTION GetAttendanceSolution(string employeeid, DateTime?dtOTStartDate) { if (dtOTStartDate == null || string.IsNullOrWhiteSpace(employeeid)) { return(null); } AttendanceSolutionAsignBLL bllAttSolAsign = new AttendanceSolutionAsignBLL(); T_HR_ATTENDANCESOLUTIONASIGN entAttSolAsign = bllAttSolAsign.GetAttendanceSolutionAsignByEmployeeIDAndDate(employeeid, dtOTStartDate.Value); if (entAttSolAsign == null) { return(null); } return(entAttSolAsign.T_HR_ATTENDANCESOLUTION); }
/// <summary> /// 根据员工ID获取其应用的考勤方案(解决一个员工在系统内多个公司入职的情况) /// </summary> /// <param name="strEmployeeID"></param> /// <returns></returns> public T_HR_ATTENDANCESOLUTION GetAttendanceSolutionByEmployeeID(string strCompanyID, string strEmployeeID) { if (string.IsNullOrEmpty(strCompanyID) || string.IsNullOrEmpty(strEmployeeID)) { return(null); } AttendanceSolutionAsignBLL bllAttendSolAsign = new AttendanceSolutionAsignBLL(); T_HR_ATTENDANCESOLUTIONASIGN entAttendSolAsign = bllAttendSolAsign.GetAttendanceSolutionAsignByEmployeeID(strCompanyID, strEmployeeID); if (entAttendSolAsign == null) { return(null); } return(entAttendSolAsign.T_HR_ATTENDANCESOLUTION); }
/// <summary> /// 计算外出确认时长 /// </summary> /// <param name="strEmployeeId"></param> /// <param name="dtOTStart"></param> /// <param name="dtOTEnd"></param> /// <param name="dOverTimeHours"></param> /// <returns></returns> public string CalculateOverTimeHours(string strEmployeeId, DateTime dtOTStart, DateTime dtOTEnd, ref string dOverTimeHours) { string strRes = string.Empty; decimal dTotalOverTimeHours = 0; DateTime dtStart, dtEnd = new DateTime(); dtStart = dtOTStart; dtEnd = dtOTEnd; //DateTime.TryParse(dtOTStart.ToString("yyyy-MM-dd"), out dtStart); //获取请假起始日期 //DateTime.TryParse(dtOTEnd.ToString("yyyy-MM-dd"), out dtEnd); //获取请假截止日期 AttendanceSolutionAsignBLL bllAttendSolAsign = new AttendanceSolutionAsignBLL(); T_HR_ATTENDANCESOLUTIONASIGN entAttendSolAsign = bllAttendSolAsign.GetAttendanceSolutionAsignByEmployeeIDAndDate(strEmployeeId, dtStart); if (entAttendSolAsign == null) { //当前员工没有分配考勤方案,无法提交请假申请 return("没有找到员工分配的考勤方案!"); } //获取考勤方案 T_HR_ATTENDANCESOLUTION entAttendSol = entAttendSolAsign.T_HR_ATTENDANCESOLUTION; decimal dWorkTimePerDay = entAttendSol.WORKTIMEPERDAY.Value; decimal dWorkMode = entAttendSol.WORKMODE.Value; int iWorkMode = 0; int.TryParse(dWorkMode.ToString(), out iWorkMode);//获取工作制(工作天数/周) List <int> iWorkDays = new List <int>(); Utility.GetWorkDays(iWorkMode, ref iWorkDays); OutPlanDaysBLL bllOutPlanDays = new OutPlanDaysBLL(); IQueryable <T_HR_OUTPLANDAYS> entOutPlanDays = bllOutPlanDays.GetOutPlanDaysRdListByEmployeeID(strEmployeeId); string strVacDayType = (Convert.ToInt32(Common.OutPlanDaysType.Vacation) + 1).ToString(); string strWorkDayType = (Convert.ToInt32(Common.OutPlanDaysType.WorkDay) + 1).ToString(); IQueryable <T_HR_OUTPLANDAYS> entVacDays = entOutPlanDays.Where(s => s.DAYTYPE == strVacDayType); IQueryable <T_HR_OUTPLANDAYS> entWorkDays = entOutPlanDays.Where(s => s.DAYTYPE == strWorkDayType && s.STARTDATE >= dtStart && s.ENDDATE <= dtEnd); SchedulingTemplateDetailBLL bllTemplateDetail = new SchedulingTemplateDetailBLL(); IQueryable <T_HR_SCHEDULINGTEMPLATEDETAIL> entTemplateDetails = bllTemplateDetail.GetTemplateDetailRdListByAttendanceSolutionId(entAttendSol.ATTENDANCESOLUTIONID); T_HR_SCHEDULINGTEMPLATEMASTER entTemplateMaster = entTemplateDetails.FirstOrDefault().T_HR_SCHEDULINGTEMPLATEMASTER; dtEnd = new DateTime(dtEnd.Year, dtEnd.Month, dtEnd.Day, dtEnd.Hour, dtEnd.Minute, 0); dtStart = new DateTime(dtStart.Year, dtStart.Month, dtStart.Day, dtStart.Hour, dtStart.Minute, 0); TimeSpan ts = dtEnd.Subtract(dtStart); int iOTDays = ts.Days; string strMsg = string.Empty; dTotalOverTimeHours = iOTDays * dWorkTimePerDay + ts.Hours; if (dTotalOverTimeHours > 0) { dOverTimeHours = Math.Round(dTotalOverTimeHours, 0) + "小时"; } if (ts.Minutes > 0) { dOverTimeHours = dOverTimeHours + ts.Minutes + "分"; } return(strRes + strMsg); }
public string OutApplySetValue(string msg, T_HR_OUTAPPLYCONFIRM entity) { if (!entity.T_HR_OUTAPPLYRECORDReference.IsLoaded) { entity.T_HR_OUTAPPLYRECORDReference.Load(); } #region 非当天往返或者实际返回未打卡,设置外出结束时间为当天下班时间 if (entity.T_HR_OUTAPPLYRECORD.ISSAMEDAYRETURN == "0" || entity.ENDDATE == new DateTime(2001, 1, 1)) // { if (GetAttendanceSolution(entity.EMPLOYEEID, entity.T_HR_OUTAPPLYRECORD.STARTDATE) == null) { return("未获取到用户的考勤方案,保存失败"); } AttendanceSolutionAsignBLL bllAttendSolAsign = new AttendanceSolutionAsignBLL(); T_HR_ATTENDANCESOLUTIONASIGN entAttendSolAsign = bllAttendSolAsign.GetAttendanceSolutionAsignByEmployeeIDAndDate(entity.EMPLOYEEID, entity.T_HR_OUTAPPLYRECORD.STARTDATE.Value); if (entAttendSolAsign.T_HR_ATTENDANCESOLUTION == null) { //当前员工没有分配考勤方案,无法提交外出申请 msg = msg + "当前员工没有分配考勤方案,无法提交外出申请"; Tracer.Debug(msg); return(msg); } else { var entAttendSol = entAttendSolAsign.T_HR_ATTENDANCESOLUTION; var tempMaster = from ent in dal.GetObjects <T_HR_SCHEDULINGTEMPLATEMASTER>() where ent.TEMPLATEMASTERID == entAttendSol.T_HR_SCHEDULINGTEMPLATEMASTER.TEMPLATEMASTERID select ent; if (!entAttendSol.T_HR_SCHEDULINGTEMPLATEMASTERReference.IsLoaded) { entAttendSol.T_HR_SCHEDULINGTEMPLATEMASTERReference.Load(); } var entsched = from a in dal.GetObjects <T_HR_SCHEDULINGTEMPLATEMASTER>() join b in dal.GetObjects <T_HR_SCHEDULINGTEMPLATEDETAIL>() on a.TEMPLATEMASTERID equals b.T_HR_SCHEDULINGTEMPLATEMASTER.TEMPLATEMASTERID join c in dal.GetObjects <T_HR_SHIFTDEFINE>() on b.T_HR_SHIFTDEFINE.SHIFTDEFINEID equals c.SHIFTDEFINEID where a.TEMPLATEMASTERID == entAttendSol.T_HR_SCHEDULINGTEMPLATEMASTER.TEMPLATEMASTERID select c; if (entsched.Count() > 0) { var defineTime = entsched.FirstOrDefault(); DateTime ShiftFirstStartTime = new DateTime(); if (defineTime.NEEDTHIRDOFFCARD == "2" && !string.IsNullOrEmpty(defineTime.THIRDENDTIME)) { ShiftFirstStartTime = DateTime.Parse(defineTime.THIRDENDTIME);//设置3段打卡,第2段下班打卡时间:一般为17:50 } else if (defineTime.NEEDSECONDOFFCARD == "2" && !string.IsNullOrEmpty(defineTime.SECONDENDTIME)) { ShiftFirstStartTime = DateTime.Parse(defineTime.SECONDENDTIME);//设置2段打卡,第2段下班打卡时间:一般为17:50 } else { msg = msg + "外出申请班次定义设置错误,没有找到下班时间定义" + " 考勤方案名:" + entAttendSolAsign.T_HR_ATTENDANCESOLUTION.ATTENDANCESOLUTIONNAME; Tracer.Debug(msg); return(msg); } DateTime dtstar = entity.T_HR_OUTAPPLYRECORD.STARTDATE.Value; DateTime ShiftstartDateAndTime = new DateTime(dtstar.Year, dtstar.Month, dtstar.Day , ShiftFirstStartTime.Hour, ShiftFirstStartTime.Minute, ShiftFirstStartTime.Second); if (entity.ENDDATE == new DateTime(2001, 1, 1))//实际出发时间选择为未打卡不计算外出时长 { entity.ENDDATE = ShiftstartDateAndTime; } } else { msg = msg + "外出申请班次定义未找到" + " 考勤方案名:" + entAttendSolAsign.T_HR_ATTENDANCESOLUTION.ATTENDANCESOLUTIONNAME; Tracer.Debug(msg); return(msg); } } if (entity.ENDDATE == null) { msg = msg + "外出申请为非当天往返,但是结束时间未找到,请检查考勤方案排版设置是否正确。" + " 考勤方案名:" + entAttendSolAsign.T_HR_ATTENDANCESOLUTION.ATTENDANCESOLUTIONNAME; Tracer.Debug(msg); return(msg); } } #endregion #region 计算外出时长 string strMsg = string.Empty; // string dTotalHours = string.Empty; if (entity.STARTDATE == new DateTime(2001, 1, 1))//实际出发时间选择为未打卡不计算外出时长 { entity.OUTAPLLYTIMES = "外出确认实际出发时间未打卡"; } else { strMsg = CalculateOverTimeHours(entity.EMPLOYEEID, entity.STARTDATE.Value, entity.ENDDATE.Value, ref dTotalHours); entity.OUTAPLLYTIMES = dTotalHours.ToString(); } #endregion return(strMsg); }
/// <summary> /// 重新初始化考勤记录,强制删除未提交签卡记录,异常考勤,考勤记录,重新初始化考勤 /// </summary> /// <param name="objType"></param> /// <param name="objId"></param> /// <param name="dtStar"></param> /// <param name="dtEnd"></param> /// <param name="DealType">0处理免打卡人员,1处理打卡人员,2处理所有</param> /// <returns></returns> public string CompulsoryInitialization(string objType, string objId, DateTime dtStar, DateTime dtEnd, string DealType) { string strMsg = string.Empty; try { //List<T_HR_EMPLOYEE> employees = new List<T_HR_EMPLOYEE>(); EmployeeBLL empbll = new EmployeeBLL(); AttendanceSolutionAsignBLL bll = new AttendanceSolutionAsignBLL(); switch (objType) { case "0": var employees = from ent in dal.GetObjects <T_HR_EMPLOYEE>() join ep in dal.GetObjects <T_HR_EMPLOYEEPOST>() on ent.EMPLOYEEID equals ep.T_HR_EMPLOYEE.EMPLOYEEID join p in dal.GetObjects <T_HR_POST>() on ep.T_HR_POST.POSTID equals p.POSTID where ep.ISAGENCY == "0" && //主岗位 ep.EDITSTATE == "1" && //生效中 ep.CHECKSTATE == "2" && //审核通过 p.COMPANYID == objId select ent; if (employees.Count() > 0) { foreach (var emp in employees) { T_HR_ATTENDANCESOLUTIONASIGN entAttendanceSolution = bll.GetAttendanceSolutionAsignByEmployeeIDAndDate(emp.EMPLOYEEID, dtStar); if (DealType == "0") //如果是处理需要打卡人员的记录,跳过免打卡记录员工 { if (entAttendanceSolution.T_HR_ATTENDANCESOLUTION.ATTENDANCETYPE != (Convert.ToInt32(Common.AttendanceType.NoCheck) + 1).ToString()) // { Tracer.Debug("" + emp.EMPLOYEECNAME + entAttendanceSolution.T_HR_ATTENDANCESOLUTION.ATTENDANCESOLUTIONNAME + "," + entAttendanceSolution.T_HR_ATTENDANCESOLUTION.ATTENDANCETYPE); continue; } } else if (DealType == "1") //如果是处理免打卡人员的记录,跳过打卡人员 { if (entAttendanceSolution.T_HR_ATTENDANCESOLUTION.ATTENDANCETYPE == (Convert.ToInt32(Common.AttendanceType.NoCheck) + 1).ToString()) // { Tracer.Debug("" + emp.EMPLOYEECNAME + entAttendanceSolution.T_HR_ATTENDANCESOLUTION.ATTENDANCESOLUTIONNAME + "," + entAttendanceSolution.T_HR_ATTENDANCESOLUTION.ATTENDANCETYPE); continue; } } else { } strMsg = "开始强制删除考勤初始化记录,员工姓名:" + emp.EMPLOYEECNAME; var q = from ent in dal.GetObjects <T_HR_ATTENDANCERECORD>() where ent.EMPLOYEEID == emp.EMPLOYEEID && ent.ATTENDANCEDATE >= dtStar && ent.ATTENDANCEDATE <= dtEnd select ent; if (q.Count() > 0) { List <T_HR_ATTENDANCERECORD> attlist = q.ToList(); RemoveWrongSignRds(attlist); foreach (var att in attlist) { dal.Delete(att); strMsg += "强制删除考勤初始化记录,员工姓名:" + att.EMPLOYEENAME + " 考勤日期:" + att.ATTENDANCEDATE.ToString() + " 考勤状态:" + att.ATTENDANCESTATE; Tracer.Debug("强制删除考勤初始化记录,员工姓名:" + att.EMPLOYEENAME + " 考勤日期:" + att.ATTENDANCEDATE.ToString() + " 考勤状态:" + att.ATTENDANCESTATE); } } bll.AsignAttendanceSolutionForEmployeeByDate(emp, dtStar); strMsg += "强制删除考勤初始化记录,初始化考勤记录成功!,员工姓名:" + emp.EMPLOYEECNAME; Tracer.Debug("强制删除考勤初始化记录,初始化考勤记录成功!,员工姓名:" + emp.EMPLOYEECNAME); } } ; break; case "4": //employees.Add(empbll.GetEmployeeByID(objId)); break; } } catch (Exception ex) { Tracer.Debug(ex.ToString()); } return(strMsg); }
/// <summary> /// 考勤方案到期提醒 /// </summary> /// <param name="eGFunc"></param> private void ATTENDANCESOLUTIONASIGNRemindTrigger(IEnumerable <XElement> eGFunc) { try { SMT.Foundation.Log.Tracer.Debug("考勤方案分配到期提醒开始"); if (eGFunc.Count() == 0) { return; } string strId = string.Empty; foreach (var item in eGFunc) { if (item.Attribute("Name").Value == "ATTENDANCESOLUTIONASIGNID") { strId = item.Attribute("Value").Value; break; } } AttendanceSolutionAsignBLL attSolutionAsigBll = new AttendanceSolutionAsignBLL(); T_HR_ATTENDANCESOLUTIONASIGN attensolutionAsin = attSolutionAsigBll.GetAttendanceSolutionAsignByID(strId); if (attensolutionAsin != null) { if (attensolutionAsin.ENDDATE >= DateTime.Now.AddDays(-8) && attensolutionAsin.CHECKSTATE == "2") { T_HR_ATTENDANCESOLUTIONASIGN entity = new T_HR_ATTENDANCESOLUTIONASIGN(); Utility.CloneEntity(attensolutionAsin, entity); entity.ATTENDANCESOLUTIONASIGNID = Guid.NewGuid().ToString(); entity.CHECKSTATE = "0"; entity.CREATEDATE = DateTime.Now; entity.UPDATEDATE = DateTime.Now; entity.STARTDATE = entity.ENDDATE.Value.AddDays(1); entity.ENDDATE = entity.ENDDATE.Value.AddYears(1); entity.REMARK = "自动定时触发的考勤方案分配 " + DateTime.Now; //entity.T_HR_ATTENDANCESOLUTION = attensolutionAsin.T_HR_ATTENDANCESOLUTION; if (attensolutionAsin.T_HR_ATTENDANCESOLUTION != null) { entity.T_HR_ATTENDANCESOLUTIONReference.EntityKey = new System.Data.EntityKey("SMT_HRM_EFModelContext.T_HR_ATTENDANCESOLUTION" , "ATTENDANCESOLUTIONID", attensolutionAsin.T_HR_ATTENDANCESOLUTION.ATTENDANCESOLUTIONID); } string msg = "此考勤方案分配将于" + attensolutionAsin.ENDDATE.Value.ToString("yyyy-MM-dd") + "失效,请修改失效时间!"; bool t = attSolutionAsigBll.AddAlarmAttend(entity, msg); if (t) { Tracer.Debug("自动定时触发的考勤方案分配 添加成功,方案名:" + attensolutionAsin.T_HR_ATTENDANCESOLUTION.ATTENDANCESOLUTIONNAME); } else { Tracer.Debug("自动定时触发的考勤方案分配 添加失败,方案名:" + attensolutionAsin.T_HR_ATTENDANCESOLUTION.ATTENDANCESOLUTIONNAME); } } else { SMT.Foundation.Log.Tracer.Debug("考勤方案到期时间为:" + attensolutionAsin.ENDDATE.ToString() + ",不自动生成考勤方案分配。"); } } else { SMT.Foundation.Log.Tracer.Debug("没有获取到考勤方案分配"); } } catch (Exception ex) { SMT.Foundation.Log.Tracer.Debug("考勤方案分配到期提醒出现错误:" + ex.ToString()); } }
public void GetAttendSolAsignForOutEngineXml(T_HR_ATTENDANCESOLUTIONASIGN entTemp) { using (AttendanceSolutionAsignBLL bll = new AttendanceSolutionAsignBLL()) { bll.GetAttendSolAsignForOutEngineXml(entTemp); } }
public string ModifyAttendanceSolutionAsign(T_HR_ATTENDANCESOLUTIONASIGN entTemp) { using (AttendanceSolutionAsignBLL bllAttendanceSolutionAsign = new AttendanceSolutionAsignBLL()) return bllAttendanceSolutionAsign.ModifyAttSolAsign(entTemp); }
/// <summary> /// 获取指定员工的实际销假天数(实际销假天数=销假天数-公休假天数-每周休息天数),实际销假时长(按小时计,实际销假合计时长=非整天销假时长-当日作息间隙休息时间+整天销假时长) /// </summary> /// <param name="strCancelLeaveId">当前销假记录的ID</param> /// <param name="strEmployeeID">员工ID</param> /// <param name="dtLeaveStartTime">销假起始时间</param> /// <param name="dtLeaveEndTime">销假截止时间</param> /// <param name="dLeaveDay">实际销假天数</param> /// <param name="dLeaveTime">实际销假时长</param> /// <param name="dLeaveTotalTime">实际销假合计时长</param> public string GetRealCancelLeaveDayByEmployeeIdAndDate(string strCancelLeaveId, string strEmployeeID, DateTime dtCancelLeaveStartTime, DateTime dtCancelLeaveEndTime, ref decimal dCancelLeaveDay, ref decimal dCancelLeaveTime, ref decimal dCancelLeaveTotalTime) { string strMsg = string.Empty; try { T_HR_EMPLOYEECANCELLEAVE entCancelLeaveRecord = GetEmployeeCancelLeaveByID(strCancelLeaveId); bool flag = false; if (entCancelLeaveRecord != null) { if (entCancelLeaveRecord.STARTDATETIME == dtCancelLeaveStartTime && entCancelLeaveRecord.ENDDATETIME == dtCancelLeaveEndTime) { if (entCancelLeaveRecord.LEAVEDAYS == null) { dCancelLeaveDay = 0; } else { dCancelLeaveDay = entCancelLeaveRecord.LEAVEDAYS.Value; } if (entCancelLeaveRecord.LEAVEHOURS == null) { dCancelLeaveTime = 0; } else { dCancelLeaveTime = entCancelLeaveRecord.LEAVEHOURS.Value; } if (entCancelLeaveRecord.TOTALHOURS == null) { dCancelLeaveTotalTime = 0; } else { dCancelLeaveTotalTime = entCancelLeaveRecord.TOTALHOURS.Value; } flag = true; } } if (flag) { return(strMsg); } DateTime dtStart, dtEnd = new DateTime(); decimal dTotalLeaveDay = 0; //起止时间的时长 DateTime.TryParse(dtCancelLeaveStartTime.ToString("yyyy-MM-dd"), out dtStart); //获取销假起始日期 DateTime.TryParse(dtCancelLeaveEndTime.ToString("yyyy-MM-dd"), out dtEnd); //获取销假截止日期 AttendanceSolutionAsignBLL bllAttendSolAsign = new AttendanceSolutionAsignBLL(); T_HR_ATTENDANCESOLUTIONASIGN entAttendSolAsign = bllAttendSolAsign.GetAttendanceSolutionAsignByEmployeeIDAndDate(strEmployeeID, dtStart); if (entAttendSolAsign == null) { //当前员工没有分配考勤方案,无法提交销假申请 return("{NONEXISTASIGNEDATTENSOL}"); } //获取考勤方案 T_HR_ATTENDANCESOLUTION entAttendSol = entAttendSolAsign.T_HR_ATTENDANCESOLUTION; decimal dWorkTimePerDay = entAttendSol.WORKTIMEPERDAY.Value; decimal dWorkMode = entAttendSol.WORKMODE.Value; int iWorkMode = 0; int.TryParse(dWorkMode.ToString(), out iWorkMode);//获取工作制(工作天数/周) List <int> iWorkDays = new List <int>(); Utility.GetWorkDays(iWorkMode, ref iWorkDays);//获取每周上班天数 OutPlanDaysBLL bllOutPlanDays = new OutPlanDaysBLL(); IQueryable <T_HR_OUTPLANDAYS> entOutPlanDays = bllOutPlanDays.GetOutPlanDaysRdListByEmployeeID(strEmployeeID); string strVacDayType = (Convert.ToInt32(Common.OutPlanDaysType.Vacation) + 1).ToString(); string strWorkDayType = (Convert.ToInt32(Common.OutPlanDaysType.WorkDay) + 1).ToString(); IQueryable <T_HR_OUTPLANDAYS> entVacDays = entOutPlanDays.Where(s => s.DAYTYPE == strVacDayType); //IQueryable<T_HR_OUTPLANDAYS> entWorkDays = entOutPlanDays.Where(s => s.DAYTYPE == strWorkDayType && s.STARTDATE >= dtStart && s.ENDDATE <= dtEnd); // 销假时间要在开始时间和结束时间之间 //注释掉没考虑某一区间的情况 //IQueryable<T_HR_OUTPLANDAYS> entWorkDays = entOutPlanDays.Where(s => s.DAYTYPE == strWorkDayType && s.STARTDATE <= dtStart && s.ENDDATE >= dtEnd); //条件过滤有四种情况 //1:在区间内 //2:大于开始时间且结束时间小于销假结束时间 //3:开始日期大于 销假开始日期且结束日期处于有效期之间 //4:开始日期小于销假开始日期且结束日期在开始时间和结束时间 IQueryable <T_HR_OUTPLANDAYS> entWorkDays = entOutPlanDays.Where(s => s.DAYTYPE == strWorkDayType && ((s.STARTDATE <= dtStart && s.ENDDATE >= dtEnd) || (s.STARTDATE >= dtStart && s.ENDDATE <= dtEnd) || (s.STARTDATE >= dtStart && s.STARTDATE <= dtEnd && s.ENDDATE >= dtEnd) || (s.STARTDATE <= dtStart && s.ENDDATE >= dtStart && s.ENDDATE <= dtEnd))); SchedulingTemplateDetailBLL bllTemplateDetail = new SchedulingTemplateDetailBLL(); IQueryable <T_HR_SCHEDULINGTEMPLATEDETAIL> entTemplateDetails = bllTemplateDetail.GetTemplateDetailRdListByAttendanceSolutionId(entAttendSol.ATTENDANCESOLUTIONID); T_HR_SCHEDULINGTEMPLATEMASTER entTemplateMaster = entTemplateDetails.FirstOrDefault().T_HR_SCHEDULINGTEMPLATEMASTER; TimeSpan ts = dtEnd.Subtract(dtStart); decimal dVacDay = 0, dWorkDay = 0; decimal dLeaveFirstDayTime = 0, dLeaveLastDayTime = 0, dLeaveFirstLastTime = 0;//请假第一天的时长,请假最后一天的时长,请假首尾两天合计时长 if (dtCancelLeaveStartTime != dtCancelLeaveEndTime) { EmployeeLeaveRecordBLL bllLeaveRecord = new EmployeeLeaveRecordBLL(); bllLeaveRecord.CalculateNonWholeDayLeaveTime(dtCancelLeaveStartTime, dtStart, entTemplateMaster, entTemplateDetails, entVacDays, entWorkDays, iWorkDays, "S", ref dLeaveFirstDayTime); bllLeaveRecord.CalculateNonWholeDayLeaveTime(dtCancelLeaveEndTime, dtEnd, entTemplateMaster, entTemplateDetails, entVacDays, entWorkDays, iWorkDays, "E", ref dLeaveLastDayTime); dLeaveFirstLastTime = dLeaveFirstDayTime + dLeaveLastDayTime; if (dtStart == dtEnd) { dLeaveFirstLastTime = dLeaveFirstLastTime - dWorkTimePerDay * 60; } } else { dLeaveFirstLastTime = dWorkTimePerDay * 60; } dTotalLeaveDay = ts.Days; if (ts.Days > 0) { //取得总的请假天数(此天数扣除了首尾两天的时间,根据请假的情况,可能包含了公休假及周假天数,扣除首尾两天的计算只适合请三天以上的) int iDays = ts.Days - 1; dTotalLeaveDay = iDays; for (int i = 0; i < iDays; i++) { int j = i + 1; bool isVacDay = false; DateTime dtCurDate = dtStart.AddDays(j); if (iWorkDays.Contains(Convert.ToInt32(dtCurDate.DayOfWeek)) == false) { dVacDay += 1; } if (entVacDays.Count() > 0) { foreach (T_HR_OUTPLANDAYS item_Vac in entVacDays) { if (item_Vac.STARTDATE.Value <= dtCurDate && item_Vac.ENDDATE >= dtCurDate) { isVacDay = true; break; } } } if (isVacDay) { dVacDay += 1; } if (entWorkDays.Count() > 0) { foreach (T_HR_OUTPLANDAYS item_Work in entWorkDays) { if (item_Work.STARTDATE.Value <= dtCurDate && item_Work.ENDDATE >= dtCurDate) { dWorkDay += 1; break; } } } } } dCancelLeaveDay = dTotalLeaveDay - dVacDay + dWorkDay; //请假天数 = 请假天数-首尾两天 - 总休假天数 + 休假调剂工作天数 decimal dTempTime = decimal.Round((dLeaveFirstLastTime) / 60, 1); if (dTempTime >= dWorkTimePerDay) { decimal dTempDay = decimal.Round(dTempTime / dWorkTimePerDay, 2); string[] strList = dTempDay.ToString().Split('.'); if (strList.Length == 2) { dCancelLeaveDay += decimal.Parse(strList[0].ToString()); dCancelLeaveTime = dTempTime - dWorkTimePerDay * decimal.Parse(strList[0].ToString()); } else { dCancelLeaveDay += dTempDay; } } else if (dTempTime < dWorkTimePerDay) { dCancelLeaveTime = dTempTime; } dCancelLeaveTotalTime = dCancelLeaveDay * dWorkTimePerDay + dCancelLeaveTime; } catch (Exception ex) { strMsg = ex.Message; Utility.SaveLog(ex.ToString()); } return(strMsg); }
/// <summary> /// 将定时触发考勤初始化记录生成的配置信息存入引擎 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnInitAttendRdByEngine_Click(object sender, EventArgs e) { if (Session["LOGINUSER"] == null) { plLogin.Visible = true; plManage.Visible = false; return; } //待发布 DateTime dtStart = DateTime.Parse(DateTime.Now.ToString("yyyy-MM") + "-1"); T_HR_ATTENDANCESOLUTIONASIGN entTemp = new T_HR_ATTENDANCESOLUTIONASIGN(); entTemp.STARTDATE = dtStart; AttRdSvc.GetAttendSolAsignForOutEngineXml(entTemp); }
/// <summary> /// 根据主键索引,获得指定的考勤方案应用以便查看编辑 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void clientAtt_GetAttendanceSolutionAsignByIDCompleted(object sender, GetAttendanceSolutionAsignByIDCompletedEventArgs e) { if (e.Error == null) { entAttendanceSolutionAsign = e.Result; SetDateTime(entAttendanceSolutionAsign.STARTDATE, entAttendanceSolutionAsign.ENDDATE); if (FormType == FormTypes.Resubmit) { entAttendanceSolutionAsign.CHECKSTATE = Convert.ToInt32(CheckStates.UnSubmit).ToString(); } this.DataContext = entAttendanceSolutionAsign; if (entAttendanceSolutionAsign.ASSIGNEDOBJECTTYPE == (Convert.ToInt32(AssignedObjectType.Company) + 1).ToString()) { clientOrg.GetCompanyByIdAsync(entAttendanceSolutionAsign.ASSIGNEDOBJECTID); } else if (entAttendanceSolutionAsign.ASSIGNEDOBJECTTYPE == (Convert.ToInt32(AssignedObjectType.Department) + 1).ToString()) { string pkId = entAttendanceSolutionAsign.CREATECOMPANYID; if (string.IsNullOrEmpty(pkId)) { clientOrg.GetDepartmentByIdAsync(entAttendanceSolutionAsign.ASSIGNEDOBJECTID); } else { clientAtt.GetAttendanceSolutionAsignRdListByCreateCompanyIdAsync(pkId); } } else if (entAttendanceSolutionAsign.ASSIGNEDOBJECTTYPE == (Convert.ToInt32(AssignedObjectType.Post) + 1).ToString()) { clientOrg.GetPostByIdAsync(entAttendanceSolutionAsign.ASSIGNEDOBJECTID); } else if (entAttendanceSolutionAsign.ASSIGNEDOBJECTTYPE == (Convert.ToInt32(AssignedObjectType.Personnel) + 1).ToString()) { string[] sArray = entAttendanceSolutionAsign.ASSIGNEDOBJECTID.Split(','); ObservableCollection<string> strIds = new ObservableCollection<string>(); foreach(string strId in sArray) { strIds.Add(strId); } clientPer.GetEmployeeByIDsAsync(strIds); } lkAttSol.IsEnabled = false; cbxkAssignedObjectType.IsEnabled = false; lkAssignObject.IsEnabled = false; //if (entAttendanceSolutionAsign.CHECKSTATE != Convert.ToInt32(CheckStates.UnSubmit).ToString()) //{ // //this.IsEnabled = false; //} } else { RefreshUI(RefreshedTypes.HideProgressBar); Utility.ShowCustomMessage(MessageTypes.Error, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr(e.Error.Message)); } RefreshUI(RefreshedTypes.AuditInfo); SetToolBar(); }
/// <summary> /// 表单初始化 /// </summary> private void InitForm() { entAttendanceSolutionAsign = new T_HR_ATTENDANCESOLUTIONASIGN(); entAttendanceSolutionAsign.ATTENDANCESOLUTIONASIGNID = System.Guid.NewGuid().ToString().ToUpper(); //权限控制 entAttendanceSolutionAsign.OWNERCOMPANYID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyID; entAttendanceSolutionAsign.OWNERDEPARTMENTID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID; entAttendanceSolutionAsign.OWNERPOSTID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].PostID; entAttendanceSolutionAsign.OWNERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID; //2010年2月11日, 11:37:35,目前暂未实现登录部分,人员相关数据为假定值 entAttendanceSolutionAsign.CREATEDATE = DateTime.Now; entAttendanceSolutionAsign.CREATEUSERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID; entAttendanceSolutionAsign.UPDATEDATE = System.DateTime.Now; entAttendanceSolutionAsign.UPDATEUSERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID; //页面初始化加载的临时数据 entAttendanceSolutionAsign.ASSIGNEDOBJECTTYPE = "0"; entAttendanceSolutionAsign.ASSIGNEDOBJECTID = string.Empty; entAttendanceSolutionAsign.T_HR_ATTENDANCESOLUTION = new T_HR_ATTENDANCESOLUTION(); entAttendanceSolutionAsign.STARTDATE = DateTime.Parse(DateTime.Now.AddMonths(1).ToString("yyyy-MM") + "-01"); entAttendanceSolutionAsign.ENDDATE = DateTime.Parse(DateTime.Now.Year + "-12-31"); //审核 entAttendanceSolutionAsign.CHECKSTATE = Convert.ToInt32(SMT.SaaS.FrameworkUI.CheckStates.UnSubmit).ToString(); this.DataContext = entAttendanceSolutionAsign; }
/// <summary> /// 考勤方案到期提醒 /// </summary> /// <param name="eGFunc"></param> private void ATTENDANCESOLUTIONASIGNRemindTrigger(IEnumerable<XElement> eGFunc) { try { SMT.Foundation.Log.Tracer.Debug("考勤方案分配到期提醒开始"); if (eGFunc.Count() == 0) { return; } string strId = string.Empty; foreach (var item in eGFunc) { if (item.Attribute("Name").Value == "ATTENDANCESOLUTIONASIGNID") { strId = item.Attribute("Value").Value; break; } } AttendanceSolutionAsignBLL attSolutionAsigBll = new AttendanceSolutionAsignBLL(); T_HR_ATTENDANCESOLUTIONASIGN attensolutionAsin = attSolutionAsigBll.GetAttendanceSolutionAsignByID(strId); if (attensolutionAsin != null) { if (attensolutionAsin.ENDDATE >= DateTime.Now.AddDays(-8) && attensolutionAsin.CHECKSTATE == "2") { T_HR_ATTENDANCESOLUTIONASIGN entity= new T_HR_ATTENDANCESOLUTIONASIGN(); Utility.CloneEntity(attensolutionAsin, entity); entity.ATTENDANCESOLUTIONASIGNID = Guid.NewGuid().ToString(); entity.CHECKSTATE = "0"; entity.CREATEDATE = DateTime.Now; entity.UPDATEDATE = DateTime.Now; entity.STARTDATE = entity.ENDDATE.Value.AddDays(1); entity.ENDDATE = entity.ENDDATE.Value.AddYears(1); entity.REMARK = "自动定时触发的考勤方案分配 "+DateTime.Now; //entity.T_HR_ATTENDANCESOLUTION = attensolutionAsin.T_HR_ATTENDANCESOLUTION; if (attensolutionAsin.T_HR_ATTENDANCESOLUTION != null) { entity.T_HR_ATTENDANCESOLUTIONReference.EntityKey = new System.Data.EntityKey("TM_SaaS_OA_EFModelContext.T_HR_ATTENDANCESOLUTION" , "ATTENDANCESOLUTIONID", attensolutionAsin.T_HR_ATTENDANCESOLUTION.ATTENDANCESOLUTIONID); } string msg = "此考勤方案分配将于"+attensolutionAsin.ENDDATE.Value.ToString("yyyy-MM-dd")+"失效,请修改失效时间!"; bool t = attSolutionAsigBll.AddAlarmAttend(entity, msg); if (t) { Tracer.Debug("自动定时触发的考勤方案分配 添加成功,方案名:" + attensolutionAsin.T_HR_ATTENDANCESOLUTION.ATTENDANCESOLUTIONNAME); } else { Tracer.Debug("自动定时触发的考勤方案分配 添加失败,方案名:" + attensolutionAsin.T_HR_ATTENDANCESOLUTION.ATTENDANCESOLUTIONNAME); } } else { SMT.Foundation.Log.Tracer.Debug("考勤方案到期时间为:" + attensolutionAsin.ENDDATE.ToString() + ",不自动生成考勤方案分配。"); } } else { SMT.Foundation.Log.Tracer.Debug("没有获取到考勤方案分配"); } } catch (Exception ex) { SMT.Foundation.Log.Tracer.Debug("考勤方案分配到期提醒出现错误:" + ex.ToString()); } }