/// <summary> /// 员工转正提醒 /// </summary> /// <param name="eGFunc"></param> private void EmployeeCheckRemindTrigger(IEnumerable <XElement> eGFunc) { try { if (eGFunc.Count() == 0) { return; } string strId = string.Empty; foreach (var item in eGFunc) { if (item.Attribute("Name").Value == "BEREGULARID") { strId = item.Attribute("Value").Value; break; } } PersonnelService svcPersonnel = new PersonnelService(); T_HR_EMPLOYEEENTRY entry = svcPersonnel.GetEmployeeEntryByEmployeeID(strId); if (entry != null) { //员工已经离职了,不需要再发员工转正提醒待办 if (entry.T_HR_EMPLOYEE.EMPLOYEESTATE == "2") { return; } string strMsg = ""; T_HR_EMPLOYEECHECK employeeCheck = new T_HR_EMPLOYEECHECK(); employeeCheck.BEREGULARID = Guid.NewGuid().ToString(); employeeCheck.T_HR_EMPLOYEE = new T_HR_EMPLOYEE(); employeeCheck.T_HR_EMPLOYEE.EMPLOYEEID = entry.T_HR_EMPLOYEE.EMPLOYEEID; employeeCheck.EMPLOYEECODE = entry.T_HR_EMPLOYEE.EMPLOYEECODE; employeeCheck.EMPLOYEENAME = entry.T_HR_EMPLOYEE.EMPLOYEECNAME; employeeCheck.PROBATIONPERIOD = entry.PROBATIONPERIOD; employeeCheck.REPORTDATE = entry.ENTRYDATE; employeeCheck.ONDUTYDATE = entry.ONPOSTDATE; employeeCheck.OWNERID = entry.OWNERID; employeeCheck.OWNERCOMPANYID = entry.OWNERCOMPANYID; employeeCheck.CREATEUSERID = entry.CREATEUSERID; employeeCheck.CHECKSTATE = "0"; svcPersonnel.EmployeeCheckAdd(employeeCheck, ref strMsg); svcPersonnel.EmployeeCheckAlarm(employeeCheck); } } catch (Exception e) { Tracer.Debug("员工转正提醒出现错误" + e.ToString()); throw e; } }
/// <summary> /// 指定转正提醒日期xml /// </summary> /// <param name="employeeCheck"></param> public void GetEmployeeCheckEngineXml(T_HR_EMPLOYEEENTRY entTemp) { DateTime dtStart = System.DateTime.Now; if (entTemp.ENTRYDATE != null) { dtStart = (DateTime)entTemp.ENTRYDATE; } string strStartTime = "10:00"; DateTime dtAlarmDay = entTemp.ENTRYDATE.Value.AddMonths(3).AddDays(-15); //3个月后提前15天提醒 if (entTemp.PROBATIONPERIOD != null) { int addMonth = int.Parse(entTemp.PROBATIONPERIOD.Value.ToString()); SalaryLoginBLL salaryBll = new SalaryLoginBLL(); var systemSetting = salaryBll.GetSystemSettingByCompanyId(entTemp.OWNERCOMPANYID); if (systemSetting != null) { int days = -int.Parse(systemSetting.PARAMETERVALUE); dtAlarmDay = entTemp.ENTRYDATE.Value.AddMonths(addMonth).AddDays(days); } else { dtAlarmDay = entTemp.ENTRYDATE.Value.AddMonths(addMonth).AddDays(-15); } } //dtStart = new DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, remindDate); List <object> objArds = new List <object>(); objArds.Add(entTemp.OWNERCOMPANYID); objArds.Add("HR"); objArds.Add("T_HR_EMPLOYEECHECK"); objArds.Add(entTemp.T_HR_EMPLOYEE.EMPLOYEEID); objArds.Add(dtAlarmDay.ToString("yyyy/MM/d")); objArds.Add(strStartTime); objArds.Add(""); objArds.Add(""); objArds.Add(entTemp.T_HR_EMPLOYEE.EMPLOYEECNAME + "试用期即将完成!"); objArds.Add(""); objArds.Add(Utility.strEngineFuncWSSite); objArds.Add("EventTriggerProcess"); objArds.Add("<Para FuncName=\"EmployeeCheckRemind\" Name=\"BEREGULARID\" Value=\"" + entTemp.T_HR_EMPLOYEE.EMPLOYEEID + "\"></Para>"); objArds.Add("Г"); objArds.Add("basicHttpBinding"); Utility.SendEngineEventTriggerData(objArds); }
public void GetEmployeeCheckEngineXml(T_HR_EMPLOYEEENTRY entity) { using (EmployeeCheckBLL bll = new EmployeeCheckBLL()) { bll.GetEmployeeCheckEngineXml(entity); } }
public void EmployeeEntryUpdate(T_HR_EMPLOYEEENTRY entity, T_HR_EMPLOYEEPOST ent) { using (EmployeeEntryBLL bll = new EmployeeEntryBLL()) { bll.EmployeeEntryUpdate(entity, ent); } }
public string AddEmployeeEntry(T_HR_EMPLOYEE employee, T_HR_EMPLOYEEENTRY entity, T_HR_EMPLOYEEPOST ent) { using (EmployeeEntryBLL bll = new EmployeeEntryBLL()) { return bll.EmployeeEntryAdd(employee, entity, ent); } }
private void InitParas() { PARENT.Children.Remove(loadbar); PARENT.Children.Add(loadbar); loadbar.Stop(); client = new PersonnelServiceClient(); client.EmployeeEntryAddCompleted += new EventHandler <System.ComponentModel.AsyncCompletedEventArgs>(client_EmployeeEntryAddCompleted); client.EmployeeAddCompleted += new EventHandler <EmployeeAddCompletedEventArgs>(client_EmployeeAddCompleted); client.EmployeeUpdateCompleted += new EventHandler <EmployeeUpdateCompletedEventArgs>(client_EmployeeUpdateCompleted); client.AddEmployeeEntryCompleted += new EventHandler <AddEmployeeEntryCompletedEventArgs>(client_AddEmployeeEntryCompleted); perclient = new PermissionServiceClient(); perclient.SysUserInfoAddORUpdateCompleted += new EventHandler <SysUserInfoAddORUpdateCompletedEventArgs>(perclient_SysUserInfoAddORUpdateCompleted); orclient = new SMT.Saas.Tools.OrganizationWS.OrganizationServiceClient(); orclient.GetPostNumberCompleted += new EventHandler <SMT.Saas.Tools.OrganizationWS.GetPostNumberCompletedEventArgs>(orclient_GetPostNumberCompleted); salaryCient = new Saas.Tools.SalaryWS.SalaryServiceClient(); salaryCient.AddSalaryPasswordCompleted += new EventHandler <System.ComponentModel.AsyncCompletedEventArgs>(salaryCient_AddSalaryPasswordCompleted); //员工入职 EmployeeEntry = new T_HR_EMPLOYEEENTRY(); //EmployeeEntry.T_HR_EMPLOYEE = Employee; EmployeeEntry.T_HR_EMPLOYEE = new T_HR_EMPLOYEE(); EmployeeEntry.T_HR_EMPLOYEE.EMPLOYEEID = Employee.EMPLOYEEID; EmployeeEntry.T_HR_EMPLOYEE.EMPLOYEECNAME = Employee.EMPLOYEECNAME; EmployeeEntry.EMPLOYEEENTRYID = Guid.NewGuid().ToString(); EmployeeEntry.CREATEUSERID = Common.CurrentLoginUserInfo.EmployeeID; EmployeeEntry.CHECKSTATE = Convert.ToInt32(CheckStates.UnSubmit).ToString(); EmployeeEntry.CREATEDATE = DateTime.Now; EmployeeEntry.ENTRYDATE = DateTime.Now; EmployeeEntry.ONPOSTDATE = DateTime.Now; EmployeeEntry.EDITSTATE = "0"; EmployeeEntry.CREATECOMPANYID = Common.CurrentLoginUserInfo.UserPosts[0].CompanyID; EmployeeEntry.CREATEDEPARTMENTID = Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID; EmployeeEntry.CREATEPOSTID = Common.CurrentLoginUserInfo.UserPosts[0].PostID; EmployeeEntry.OWNERID = Employee.EMPLOYEEID; //员工岗位 EmployeePost = new T_HR_EMPLOYEEPOST(); EmployeePost.EMPLOYEEPOSTID = Guid.NewGuid().ToString(); //EmployeePost.T_HR_EMPLOYEE = Employee; EmployeePost.T_HR_EMPLOYEE = new T_HR_EMPLOYEE(); EmployeePost.T_HR_EMPLOYEE.EMPLOYEEID = Employee.EMPLOYEEID; EmployeePost.CREATEUSERID = Common.CurrentLoginUserInfo.EmployeeID; EmployeePost.CHECKSTATE = Convert.ToInt32(CheckStates.UnSubmit).ToString(); EmployeePost.EDITSTATE = Convert.ToInt32(EditStates.UnActived).ToString(); //岗位未审核通过 无效 EmployeePost.CREATEDATE = DateTime.Now; EmployeePost.ISAGENCY = "0"; //非代理岗位 EmployeeEntry.EMPLOYEEPOSTID = EmployeePost.EMPLOYEEPOSTID; //系统用户 SysUser = new T_SYS_USER(); SysUser.SYSUSERID = Guid.NewGuid().ToString(); SysUser.STATE = "0"; txtUser.Text = Employee.EMPLOYEEENAME.Trim(); string strCarID = Employee.IDNUMBER; //if (strCarID.Length > 6) //{ // txtPwd.Password = "******"+strCarID.Substring(strCarID.Length - 6); //} //else //{ // txtPwd.Password = "******" + strCarID; //} if (strCarID.Length > 6) { txtPwd.Password = "******" + strCarID.Substring(strCarID.Length - 6); } else { txtPwd.Password = "******" + strCarID; } txtPwd.IsEnabled = false; SysUser.CREATEUSER = Common.CurrentLoginUserInfo.EmployeeID; SysUser.CREATEDATE = DateTime.Now; }
void Configclient_GetAppConfigByNameCompleted(object sender, GetAppConfigByNameCompletedEventArgs e) { //员工入职 EmployeeEntry = new T_HR_EMPLOYEEENTRY(); //EmployeeEntry.T_HR_EMPLOYEE = Employee; EmployeeEntry.T_HR_EMPLOYEE = new T_HR_EMPLOYEE(); EmployeeEntry.T_HR_EMPLOYEE.EMPLOYEEID = Employee.EMPLOYEEID; EmployeeEntry.T_HR_EMPLOYEE.EMPLOYEECNAME = Employee.EMPLOYEECNAME; EmployeeEntry.EMPLOYEEENTRYID = Guid.NewGuid().ToString(); EmployeeEntry.CREATEUSERID = Common.CurrentLoginUserInfo.EmployeeID; EmployeeEntry.CHECKSTATE = Convert.ToInt32(CheckStates.UnSubmit).ToString(); EmployeeEntry.CREATEDATE = DateTime.Now; EmployeeEntry.ENTRYDATE = DateTime.Now; EmployeeEntry.ONPOSTDATE = DateTime.Now; EmployeeEntry.EDITSTATE = "0"; EmployeeEntry.CREATECOMPANYID = Common.CurrentLoginUserInfo.UserPosts[0].CompanyID; EmployeeEntry.CREATEDEPARTMENTID = Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID; EmployeeEntry.CREATEPOSTID = Common.CurrentLoginUserInfo.UserPosts[0].PostID; EmployeeEntry.OWNERID = Employee.EMPLOYEEID; //员工岗位 EmployeePost = new T_HR_EMPLOYEEPOST(); EmployeePost.EMPLOYEEPOSTID = Guid.NewGuid().ToString(); //EmployeePost.T_HR_EMPLOYEE = Employee; EmployeePost.T_HR_EMPLOYEE = new T_HR_EMPLOYEE(); EmployeePost.T_HR_EMPLOYEE.EMPLOYEEID = Employee.EMPLOYEEID; EmployeePost.CREATEUSERID = Common.CurrentLoginUserInfo.EmployeeID; EmployeePost.CHECKSTATE = Convert.ToInt32(CheckStates.UnSubmit).ToString(); EmployeePost.EDITSTATE = Convert.ToInt32(EditStates.UnActived).ToString(); //岗位未审核通过 无效 EmployeePost.CREATEDATE = DateTime.Now; EmployeePost.ISAGENCY = "0"; //非代理岗位 EmployeeEntry.EMPLOYEEPOSTID = EmployeePost.EMPLOYEEPOSTID; //系统用户 SysUser = new T_SYS_USER(); SysUser.SYSUSERID = Guid.NewGuid().ToString(); SysUser.STATE = "0"; txtUser.Text = Employee.EMPLOYEEENAME.Trim(); string strCarID = Employee.IDNUMBER; if (e.Result == "false") { if (strCarID.Length > 6) { txtPwd.Password = "******" + strCarID.Substring(strCarID.Length - 6); } else { txtPwd.Password = "******" + strCarID; } } else { if (strCarID.Length > 6) { txtPwd.Password = "******" + strCarID.Substring(strCarID.Length - 6); } else { txtPwd.Password = "******" + strCarID; } Employee.EMAIL = Employee.EMPLOYEEENAME + "@hnhtxx.com.cn"; txtRemark.Text = "注意:默认密码为 aisino加上证件号后六位,请在完成此次保存后再修改密码"; } txtPwd.IsEnabled = false; SysUser.CREATEUSER = Common.CurrentLoginUserInfo.EmployeeID; SysUser.CREATEDATE = DateTime.Now; }
/// <summary> /// 根据传回的xml生成员工入职 /// </summary> /// <param name="eGFunc"></param> /// <returns></returns> private static string AddEmployeeEntry(IEnumerable<XElement> eGFunc) { try { if (eGFunc.Count() == 0) { return ""; } string strEmployeeID = string.Empty; string strOwnerID = string.Empty; string strOwnerPostID = string.Empty; string strOwnerDepartmentID = string.Empty; string strOwnerCompanyID = string.Empty; string Name = string.Empty; int PROBATIONPERIOD = 0; string Idnumber = string.Empty; string sex = string.Empty; string isAcceptemploied = string.Empty; string createuserid = string.Empty; foreach (var q in eGFunc) { string strName = q.Attribute("Name").Value; switch (strName) { case "EMPLOYEEID": strEmployeeID = q.Attribute("Value").Value; break; case "OWNERID": strOwnerID = q.Attribute("Value").Value; break; case "OWNERPOSTID": strOwnerPostID = q.Attribute("Value").Value; break; case "OWNERDEPARTMENTID": strOwnerDepartmentID = q.Attribute("Value").Value; break; case "OWNERCOMPANYID": strOwnerCompanyID = q.Attribute("Value").Value; break; case "NAME": Name = q.Attribute("Value").Value; break; case "IDCARDNUMBER": Idnumber = q.Attribute("Value").Value; break; case "SEX": sex = q.Attribute("Value").Value; break; case "PROBATIONPERIOD": PROBATIONPERIOD = int.Parse(q.Attribute("Value").Value); break; case "ISACCEPTEMPLOIED": isAcceptemploied = q.Attribute("Value").Value; break; case "CREATEUSERID": createuserid = q.Attribute("Value").Value; break; } } //if (isAcceptemploied != "2") //{ // return string.Empty; //} PersonnelService ser = new PersonnelService(); T_HR_EMPLOYEEENTRY entry = new T_HR_EMPLOYEEENTRY(); T_HR_EMPLOYEE employee = new T_HR_EMPLOYEE(); T_HR_EMPLOYEEPOST epost = new T_HR_EMPLOYEEPOST(); employee.EMPLOYEEID = Guid.NewGuid().ToString(); employee.EMPLOYEECNAME = Name; employee.IDNUMBER = Idnumber.Replace("{", "").Replace("}", ""); employee.OWNERCOMPANYID = strOwnerCompanyID.Replace("{", "").Replace("}", ""); employee.OWNERDEPARTMENTID = strOwnerDepartmentID.Replace("{", "").Replace("}", ""); employee.OWNERPOSTID = strOwnerPostID.Replace("{", "").Replace("}", ""); employee.OWNERID = employee.EMPLOYEEID.Replace("{", "").Replace("}", ""); employee.CREATEDATE = DateTime.Now; employee.SEX = sex; employee.CREATEUSERID = createuserid; epost.EMPLOYEEPOSTID = Guid.NewGuid().ToString(); epost.ISAGENCY = "0"; epost.CREATEDATE = DateTime.Now; epost.T_HR_POST = new T_HR_POST(); epost.T_HR_POST.POSTID = employee.OWNERPOSTID; epost.T_HR_EMPLOYEE = new T_HR_EMPLOYEE(); epost.T_HR_EMPLOYEE.EMPLOYEEID = employee.EMPLOYEEID; epost.CREATEUSERID = createuserid; epost.CHECKSTATE = "0"; entry.EMPLOYEEENTRYID = Guid.NewGuid().ToString(); entry.CHECKSTATE = "0"; entry.PROBATIONPERIOD = PROBATIONPERIOD; entry.T_HR_EMPLOYEE = new T_HR_EMPLOYEE(); entry.T_HR_EMPLOYEE.EMPLOYEEID = employee.EMPLOYEEID; entry.CREATEDATE = System.DateTime.Now; entry.EMPLOYEEPOSTID = epost.EMPLOYEEPOSTID; entry.OWNERCOMPANYID = employee.OWNERCOMPANYID; entry.OWNERDEPARTMENTID = employee.OWNERDEPARTMENTID; entry.OWNERPOSTID = employee.OWNERPOSTID; entry.OWNERID = employee.EMPLOYEEID; entry.CREATEUSERID = createuserid; ser.AddEmployeeEntry(employee, entry, epost); return entry.EMPLOYEEENTRYID; } catch (Exception e) { string abc = "<HR>Message=[" + e.Message + "]" + "<HR>Source=[" + e.Source + "]<HR>StackTrace=[" + e.StackTrace + "]<HR>TargetSite=[" + e.TargetSite + "]"; Tracer.Debug(abc); return abc; } }
/// <summary> /// 对指定公司,指定的员工,按照指定的考勤方案应用生成指定时段内的考勤初始化记录 /// </summary> /// <param name="entTemp"></param> /// <param name="entCompany"></param> /// <param name="entEmployees"></param> /// <param name="dtAsignDate"></param> /// <returns></returns> private string AsignAttendSolForEmployees(T_HR_ATTENDANCESOLUTIONASIGN entTemp, T_HR_COMPANY entCompany, List <T_HR_EMPLOYEE> entEmployees, DateTime dtAsignDate) { string strRes = string.Empty; try { decimal dWorkMode = entTemp.T_HR_ATTENDANCESOLUTION.WORKMODE.Value; string strAttendanceSolutionID = entTemp.T_HR_ATTENDANCESOLUTION.ATTENDANCESOLUTIONID; int iWorkMode = 0; int.TryParse(dWorkMode.ToString(), out iWorkMode); List <int> iWorkDays = new List <int>(); Utility.GetWorkDays(iWorkMode, ref iWorkDays); SchedulingTemplateDetailBLL bllTemplateDetail = new SchedulingTemplateDetailBLL(); List <T_HR_SCHEDULINGTEMPLATEDETAIL> entTemplateDetails = new List <T_HR_SCHEDULINGTEMPLATEDETAIL>(); var q = bllTemplateDetail.GetTemplateDetailRdListByAttendanceSolutionId(strAttendanceSolutionID); if (q == null) { Tracer.Debug("考勤初始化考勤班次不存在"); return("{NOTFOUND}"); } entTemplateDetails = q.ToList(); if (entTemplateDetails == null) { Tracer.Debug("考勤初始化考勤班次不存在"); return("{NOTFOUND}"); } if (entTemplateDetails.Count == 0) { Tracer.Debug("考勤初始化考勤班次不存在"); return("{NOTFOUND}"); } int iTotalDay = 0; //DateTime dtCheck = new DateTime(); DateTime dtStart = DateTime.Parse(dtAsignDate.ToString("yyyy-MM") + "-1"); //DateTime dtStart = DateTime.Parse("2012-10-1"); if (entTemp.STARTDATE > dtStart) { dtStart = entTemp.STARTDATE.Value; } DateTime dtInitAttandRecordEndDate = dtStart.AddMonths(1).AddDays(-1); AttendanceRecordBLL bllAttRd = new AttendanceRecordBLL(); EmployeeLevelDayCountBLL bllLevelDayCount = new EmployeeLevelDayCountBLL(); EmployeeEntryBLL bllEntry = new EmployeeEntryBLL(); LeftOfficeConfirmBLL bllConfirm = new LeftOfficeConfirmBLL(); //操作表T_HR_EMPLOYEELEVELDAYCOUNT数据的方式:0:直接逐条新增或修改; //1:先把要新增或修改的记录存到内存,然后一次性提交到数据库修改 Tracer.Debug("开始生成员工考勤初始化记录,总员工数:" + entEmployees.Count()); for (int n = 0; n < entEmployees.Count(); n++) { bool AttendNoCheck = false; try { T_HR_EMPLOYEE item_emp = entEmployees[n]; DateTime dtInitAttandRecordStartDate = new DateTime(); #region 判断是否免打卡 //如果是免打卡的用户,在这里还是需要初始化,因为结算的时候需要计算出勤天数 if (!entTemp.T_HR_ATTENDANCESOLUTIONReference.IsLoaded) { entTemp.T_HR_ATTENDANCESOLUTIONReference.Load(); } if (entTemp.T_HR_ATTENDANCESOLUTION.ATTENDANCETYPE == (Convert.ToInt32(Common.AttendanceType.NoCheck) + 1).ToString())//考勤方案设置为不考勤 { AttendNoCheck = true; Tracer.Debug("初始化员工,考勤方案设置为免打卡,员工姓名:" + entEmployees.FirstOrDefault().EMPLOYEECNAME + " 考勤方案名:" + entTemp.T_HR_ATTENDANCESOLUTION.ATTENDANCESOLUTIONNAME); } #endregion #region 初始化开始日期大于结束日期 dtInitAttandRecordStartDate = dtStart; if (dtInitAttandRecordStartDate >= dtInitAttandRecordEndDate) { Tracer.Debug("初始化员工考勤记录被跳过,dtInitAttandRecordStartDate >= dtEnd" + ",员工姓名" + item_emp.EMPLOYEECNAME); continue; } #endregion #region 判断员工状态,是否有入职记录,是否已离职,入职,离职日期 string usedAttendSolutionName = ",使用的考勤方案:" + entTemp.T_HR_ATTENDANCESOLUTION.ATTENDANCESOLUTIONNAME + ",当前线程id:" + Thread.CurrentThread.ManagedThreadId; Tracer.Debug("初始化员工考勤记录:员工状态:" + item_emp.EMPLOYEESTATE + ",员工姓名" + item_emp.EMPLOYEECNAME + usedAttendSolutionName); if (item_emp.EMPLOYEESTATE == "0") { T_HR_EMPLOYEEENTRY entEntry = bllEntry.GetEmployeeEntryByEmployeeID(item_emp.EMPLOYEEID); if (entEntry == null) { Tracer.Debug("初始化员工考勤记录被跳过,该员工入职为空" + ",员工姓名" + item_emp.EMPLOYEECNAME); continue; } TimeSpan tsStart = entEntry.ONPOSTDATE.Value - dtInitAttandRecordStartDate; TimeSpan tsEnd = dtInitAttandRecordEndDate - entEntry.ONPOSTDATE.Value; if (tsStart.Days >= 0 && tsEnd.Days >= 0) { Tracer.Debug("初始化员工考勤记录开始日期被修改:entEntry.ONPOSTDATE.Value > dtInitAttandRecordStartDate" + ",员工姓名" + item_emp.EMPLOYEECNAME + " 入职日期:" + entEntry.ENTRYDATE.Value.ToString("yyyy-MM-dd") + " 到岗日期:" + entEntry.ONPOSTDATE.Value.ToString("yyyy-MM-dd")); dtInitAttandRecordStartDate = new DateTime(entEntry.ONPOSTDATE.Value.Year, entEntry.ONPOSTDATE.Value.Month, entEntry.ONPOSTDATE.Value.Day); } if (tsEnd.Days < 0) { Tracer.Debug("初始化员工考勤记录被跳过:员工到岗日期大于考勤初始化结束日期entEntry.ONPOSTDATE.Value > dtEnd" + ",员工姓名" + item_emp.EMPLOYEECNAME + " 入职日期:" + entEntry.ENTRYDATE.Value.ToString("yyyy-MM-dd") + " 到岗日期:" + entEntry.ONPOSTDATE.Value.ToString("yyyy-MM-dd") + " 考勤初始化结束日期:" + dtInitAttandRecordEndDate); continue; } } if (item_emp.EMPLOYEESTATE == "1") { T_HR_EMPLOYEEENTRY entEntry = bllEntry.GetEmployeeEntryByEmployeeID(item_emp.EMPLOYEEID); if (entEntry == null) { Tracer.Debug("该员工入职为空" + ",员工姓名" + item_emp.EMPLOYEECNAME); continue; } if (entEntry.ONPOSTDATE.Value > dtInitAttandRecordStartDate && entEntry.ONPOSTDATE.Value < dtInitAttandRecordEndDate) { Tracer.Debug("初始化员工考勤记录开始日期被修改:entEntry.ONPOSTDATE.Value > dtInitAttandRecordStartDate" + ",员工姓名" + item_emp.EMPLOYEECNAME + " 入职日期:" + entEntry.ENTRYDATE.Value.ToString("yyyy-MM-dd") + " 到岗日期:" + entEntry.ONPOSTDATE.Value.ToString("yyyy-MM-dd")); dtInitAttandRecordStartDate = new DateTime(entEntry.ONPOSTDATE.Value.Year, entEntry.ONPOSTDATE.Value.Month, entEntry.ONPOSTDATE.Value.Day); } TimeSpan ts3 = entEntry.ONPOSTDATE.Value - dtInitAttandRecordEndDate; if (ts3.Days > 0) { Tracer.Debug("初始化员工考勤记录被跳过,员工入职日期大于本月最后一天" + ",员工姓名" + item_emp.EMPLOYEECNAME); continue; } } else if (item_emp.EMPLOYEESTATE == "2") { T_HR_LEFTOFFICECONFIRM entConfirm = bllConfirm.GetLeftOfficeConfirmByEmployeeId(item_emp.EMPLOYEEID); if (entConfirm.STOPPAYMENTDATE != null && entConfirm.STOPPAYMENTDATE.Value < dtStart) { Tracer.Debug("初始化员工考勤记录被跳过,entConfirm.STOPPAYMENTDATE !=null && entConfirm.STOPPAYMENTDATE.Value < dtStart" + ",员工姓名" + item_emp.EMPLOYEECNAME); continue; } if (entConfirm.STOPPAYMENTDATE != null && entConfirm.STOPPAYMENTDATE.Value > dtStart && entConfirm.STOPPAYMENTDATE.Value < dtInitAttandRecordEndDate) { dtInitAttandRecordEndDate = new DateTime(entConfirm.STOPPAYMENTDATE.Value.Year, entConfirm.STOPPAYMENTDATE.Value.Month, entConfirm.STOPPAYMENTDATE.Value.Day); } if (entConfirm.STOPPAYMENTDATE != null && entConfirm.STOPPAYMENTDATE.Value < dtStart) { Tracer.Debug("初始化员工考勤记录被跳过,entConfirm.STOPPAYMENTDATE != null && entConfirm.STOPPAYMENTDATE.Value < dtStart" + ",员工姓名" + item_emp.EMPLOYEECNAME); continue; } } #endregion TimeSpan ts = dtInitAttandRecordEndDate.Subtract(dtInitAttandRecordStartDate); iTotalDay = ts.Days; T_HR_SCHEDULINGTEMPLATEMASTER entTemplateMaster = entTemplateDetails[0].T_HR_SCHEDULINGTEMPLATEMASTER; int iCircleDay = 0; if (entTemplateMaster.SCHEDULINGCIRCLETYPE == (Convert.ToInt32(Common.SchedulingCircleType.Month) + 1).ToString()) { iCircleDay = 31; } else if (entTemplateMaster.SCHEDULINGCIRCLETYPE == (Convert.ToInt32(Common.SchedulingCircleType.Week) + 1).ToString()) { iCircleDay = 7; } int iPeriod = iTotalDay / iCircleDay; if (iTotalDay % iCircleDay >= 0) { iPeriod += 1; } OutPlanDaysBLL bllOutPlanDays = new OutPlanDaysBLL(); IQueryable <T_HR_OUTPLANDAYS> entOutPlanDays = bllOutPlanDays.GetOutPlanDaysRdListByEmployeeID(item_emp.EMPLOYEEID); 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 >= dtInitAttandRecordStartDate && s.ENDDATE <= dtInitAttandRecordEndDate); //IQueryable<T_HR_OUTPLANDAYS> entVacWorkDays = entOutPlanDays.Where(s => s.STARTDATE >= dtInitAttandRecordStartDate && s.ENDDATE <= dtInitAttandRecordEndDate); //例外工作日考勤初始化记录公共假期 CreateOutPlanWorkDay(entCompany, item_emp, entTemp, entTemplateDetails, entWorkDays, AttendNoCheck); //IQueryable<T_HR_OUTPLANDAYS> entVacWorkHalfDays // = entVacDays.Where(s => s.STARTDATE >= dtInitAttandRecordStartDate // && s.ENDDATE <= dtInitAttandRecordEndDate && s.ISHALFDAY=="1"); int addCount = 0; int updateCount = 0; for (int i = 0; i < iPeriod; i++) { for (int j = 0; j < iCircleDay; j++) { #region 开始生成员工考勤初始化记录 try { int m = (i * iCircleDay) + j; DateTime dtCurDate = dtInitAttandRecordStartDate.AddDays(m); if (dtCurDate > entTemp.ENDDATE.Value) { break; } bool isVacDay = false; if (iWorkDays.Contains(Convert.ToInt32(dtCurDate.DayOfWeek)) == false) { continue; } if (entVacDays.Count() > 0) { foreach (T_HR_OUTPLANDAYS item_Vac in entVacDays) { if (item_Vac.STARTDATE.Value <= dtCurDate && item_Vac.ENDDATE >= dtCurDate) { //如果是公共假期并未设置半天,设为公共假期不考勤 if (string.IsNullOrEmpty(item_Vac.ISHALFDAY)) { isVacDay = true; break; } if (!string.IsNullOrEmpty(item_Vac.ISHALFDAY) && item_Vac.ISHALFDAY == "0") { isVacDay = true; break; } else { //例外工作日考勤初始化记录(公共假期半天休息,还有半天上班也需要初始化考勤记录) } } } } if (isVacDay) { continue; } T_HR_SCHEDULINGTEMPLATEDETAIL item = entTemplateDetails.Where(c => c.SCHEDULINGDATE == (j + 1).ToString()).FirstOrDefault(); var qc = from ar in dal.GetObjects <T_HR_ATTENDANCERECORD>() where //ar.OWNERCOMPANYID == entCompany.COMPANYID && ar.EMPLOYEEID == item_emp.EMPLOYEEID && ar.ATTENDANCEDATE == dtCurDate select ar; T_HR_ATTENDANCERECORD entUpdate = qc.FirstOrDefault(); if (entUpdate == null) { T_HR_ATTENDANCERECORD entAttRd = new T_HR_ATTENDANCERECORD(); entAttRd.ATTENDANCERECORDID = System.Guid.NewGuid().ToString().ToUpper(); entAttRd.ATTENDANCESOLUTIONID = entTemp.T_HR_ATTENDANCESOLUTION.ATTENDANCESOLUTIONID; entAttRd.EMPLOYEEID = item_emp.EMPLOYEEID; entAttRd.EMPLOYEECODE = item_emp.EMPLOYEECODE; entAttRd.EMPLOYEENAME = item_emp.EMPLOYEECNAME; entAttRd.ATTENDANCEDATE = dtCurDate; //外键实体 //entAttRd.T_HR_SHIFTDEFINE = item.T_HR_SHIFTDEFINE; entAttRd.T_HR_SHIFTDEFINEReference.EntityKey = new EntityKey("TM_SaaS_OA_EFModelContext.T_HR_SHIFTDEFINE", "SHIFTDEFINEID", item.T_HR_SHIFTDEFINE.SHIFTDEFINEID); //第一段工作时间 entAttRd.FIRSTSTARTTIME = item.T_HR_SHIFTDEFINE.FIRSTSTARTTIME; entAttRd.FIRSTENDTIME = item.T_HR_SHIFTDEFINE.FIRSTENDTIME; //第二段工作时间 entAttRd.SECONDSTARTTIME = item.T_HR_SHIFTDEFINE.SECONDSTARTTIME; entAttRd.SECONDENDTIME = item.T_HR_SHIFTDEFINE.SECONDENDTIME; //第三段工作时间 entAttRd.THIRDSTARTTIME = item.T_HR_SHIFTDEFINE.THIRDSTARTTIME; entAttRd.THIRDENDTIME = item.T_HR_SHIFTDEFINE.THIRDENDTIME; //第四段工作时间 entAttRd.FOURTHENDTIME = item.T_HR_SHIFTDEFINE.FOURTHENDTIME; entAttRd.FOURTHSTARTTIME = item.T_HR_SHIFTDEFINE.FOURTHSTARTTIME; //查询公共假期设置判断是否只上半天班公共假期 var qVacDay = from ent in entVacDays where ent.STARTDATE == entAttRd.ATTENDANCEDATE select ent; if (qVacDay.Count() > 0) { var set = qVacDay.FirstOrDefault(); if (!string.IsNullOrEmpty(set.ISHALFDAY)) { if (set.ISHALFDAY == "1") { if (set.PEROID == "0")//上午 { string msg = "考勤初始化(新增)-检测到假期设置了休假(半天):" + " 员工:" + entAttRd.EMPLOYEENAME + " 日期:" + entAttRd.ATTENDANCEDATE + " 休假分段(0上午):" + set.PEROID; Tracer.Debug(msg); entAttRd.REMARK = msg; entAttRd.NEEDFRISTATTEND = "0"; //上午不上班 entAttRd.NEEDSECONDATTEND = "1"; //下午上班 } else if (set.PEROID == "1") { string msg = "考勤初始化(新增)-检测到假期设置了休假(半天):" + " 员工:" + entAttRd.EMPLOYEENAME + " 日期:" + entAttRd.ATTENDANCEDATE + " 休假分段(1下午):" + set.PEROID; Tracer.Debug(msg); entAttRd.REMARK = msg; entAttRd.NEEDFRISTATTEND = "1"; //上午上班 entAttRd.NEEDSECONDATTEND = "0"; //下午不上班 } } } } //权限 entAttRd.OWNERCOMPANYID = item_emp.OWNERCOMPANYID; entAttRd.OWNERDEPARTMENTID = item_emp.OWNERDEPARTMENTID; entAttRd.OWNERPOSTID = item_emp.OWNERPOSTID; entAttRd.OWNERID = item_emp.OWNERID; entAttRd.CREATEUSERID = entTemp.CREATEUSERID; entAttRd.CREATEDATE = DateTime.Now; entAttRd.REMARK += entTemp.REMARK; entAttRd.UPDATEUSERID = entTemp.UPDATEUSERID; entAttRd.UPDATEDATE = DateTime.Now; entAttRd.CREATECOMPANYID = entTemp.CREATECOMPANYID; entAttRd.CREATEDEPARTMENTID = entTemp.CREATEDEPARTMENTID; entAttRd.CREATEPOSTID = entTemp.CREATEPOSTID; if (AttendNoCheck) { entAttRd.ATTENDANCESTATE = "1";//免打卡员工 Tracer.Debug("设置为免打孔员工,考勤默认为已出勤," + " 员工姓名" + item_emp.EMPLOYEECNAME + " 考勤初始化日期:" + entAttRd.ATTENDANCEDATE.Value.ToString("yyyy-MM-dd") + usedAttendSolutionName); } else { entAttRd.ATTENDANCESTATE = string.Empty; //新生成的考勤记录,出勤状态为空 } Tracer.Debug("开始新增员工T_HR_ATTENDANCERECORD记录,日期:" + dtCurDate.ToString("yyyy-MM-dd") + ",员工姓名:" + item_emp.EMPLOYEECNAME + ",初始化考勤状态:" + entAttRd.ATTENDANCESTATE + usedAttendSolutionName); addCount += dal.Add(entAttRd); } else { if (AttendNoCheck) //免打孔 { entUpdate.ATTENDANCESTATE = "1"; //免打卡员工 //非免打卡员工,跳过 Tracer.Debug("设置为免打孔员工,考勤默认为已出勤," + " 员工姓名" + item_emp.EMPLOYEECNAME + " 考勤初始化日期:" + entUpdate.ATTENDANCEDATE.Value.ToString("yyyy-MM-dd") + usedAttendSolutionName); } else { if (!string.IsNullOrEmpty(entUpdate.ATTENDANCESTATE)) { Tracer.Debug("更新考勤初始化记录,已存在的考勤初始化记录状态为: " + entUpdate.ATTENDANCESTATE + " ,跳过不再生成" + ",员工姓名:" + item_emp.EMPLOYEECNAME + ",考勤状态:" + entUpdate.ATTENDANCESTATE + usedAttendSolutionName); continue; //如果存在直接跳过 } entUpdate.ATTENDANCESTATE = string.Empty; //新生成的考勤记录,出勤状态为空 } Tracer.Debug("更新考勤初始化记录,ATTENDANCESTATE考勤状态为空,日期:" + dtCurDate.ToString("yyyy-MM-dd") + ",员工姓名:" + item_emp.EMPLOYEECNAME + ",初始化考勤状态:" + entUpdate.ATTENDANCESTATE + usedAttendSolutionName); entUpdate.ATTENDANCESOLUTIONID = entTemp.T_HR_ATTENDANCESOLUTION.ATTENDANCESOLUTIONID; entUpdate.EMPLOYEEID = item_emp.EMPLOYEEID; entUpdate.EMPLOYEECODE = item_emp.EMPLOYEECODE; entUpdate.EMPLOYEENAME = item_emp.EMPLOYEECNAME; entUpdate.ATTENDANCEDATE = dtCurDate; entUpdate.T_HR_SHIFTDEFINE = item.T_HR_SHIFTDEFINE; //第一段工作时间 entUpdate.FIRSTSTARTTIME = item.T_HR_SHIFTDEFINE.FIRSTSTARTTIME; entUpdate.FIRSTENDTIME = item.T_HR_SHIFTDEFINE.FIRSTENDTIME; //第二段工作时间 entUpdate.SECONDSTARTTIME = item.T_HR_SHIFTDEFINE.SECONDSTARTTIME; entUpdate.SECONDENDTIME = item.T_HR_SHIFTDEFINE.SECONDENDTIME; //第三段工作时间 entUpdate.THIRDSTARTTIME = item.T_HR_SHIFTDEFINE.THIRDSTARTTIME; entUpdate.THIRDENDTIME = item.T_HR_SHIFTDEFINE.THIRDENDTIME; //第四段工作时间 entUpdate.FOURTHENDTIME = item.T_HR_SHIFTDEFINE.FOURTHENDTIME; entUpdate.FOURTHSTARTTIME = item.T_HR_SHIFTDEFINE.FOURTHSTARTTIME; //查询公共假期设置判断是否只上半天班 var qVacDay = from ent in entVacDays where ent.STARTDATE == entUpdate.ATTENDANCEDATE select ent; if (qVacDay.Count() > 0) { var set = qVacDay.FirstOrDefault(); if (!string.IsNullOrEmpty(set.ISHALFDAY)) { if (set.ISHALFDAY == "1") { if (set.PEROID == "0")//上午 { string msg = "考勤初始化(修改)-检测到假期设置了休假(半天):" + " 员工:" + entUpdate.EMPLOYEENAME + " 日期:" + entUpdate.ATTENDANCEDATE + " 上班分段(0上午):" + set.PEROID; Tracer.Debug(msg); entUpdate.REMARK = msg; entUpdate.NEEDFRISTATTEND = "0"; //上午不上班休息 entUpdate.NEEDSECONDATTEND = "1"; //下午上班 } else if (set.PEROID == "1") { string msg = "考勤初始化(修改)-检测到假期设置了休假(半天):" + " 员工:" + entUpdate.EMPLOYEENAME + " 日期:" + entUpdate.ATTENDANCEDATE + " 上班分段(1下午):" + set.PEROID; Tracer.Debug(msg); entUpdate.REMARK = msg; entUpdate.NEEDFRISTATTEND = "1"; //上午上班 entUpdate.NEEDSECONDATTEND = "0"; //下午不上班休息 } } } } //权限 entUpdate.OWNERCOMPANYID = item_emp.OWNERCOMPANYID; entUpdate.OWNERDEPARTMENTID = item_emp.OWNERDEPARTMENTID; entUpdate.OWNERPOSTID = item_emp.OWNERPOSTID; entUpdate.OWNERID = item_emp.OWNERID; entUpdate.REMARK += entTemp.REMARK; entUpdate.UPDATEUSERID = entTemp.UPDATEUSERID; entUpdate.UPDATEDATE = DateTime.Now; updateCount += dal.Update(entUpdate); } } catch (Exception ex) { Tracer.Debug("生成考勤初始化记录出错:" + item_emp.EMPLOYEECNAME + ex.ToString() + usedAttendSolutionName); continue; } #endregion } } //bllLevelDayCount.CalculateEmployeeLevelDayCount(entTemp, item_emp, strOperationType); //int saveCount=dal.SaveContextChanges(); Tracer.Debug(n + "生成员工:" + item_emp.EMPLOYEECNAME + " 考勤记录成功,开始日期" + dtStart.ToString("yyyy-MM-dd") + "结束日期:" + dtInitAttandRecordEndDate.ToString("yyyy-MM-dd") + "共新增考勤记录" + addCount.ToString() + " 更新记录条数:" + updateCount + usedAttendSolutionName); } catch (Exception ex) { Tracer.Debug("生成考勤初始化记录出错:" + entEmployees[n].EMPLOYEECNAME + ex.ToString()); continue; } } Tracer.Debug("生成所有员工考勤记录成功,开始日期" + dtStart.ToString("yyyy-MM-dd") + "结束日期:" + dtInitAttandRecordEndDate.ToString("yyyy-MM-dd")); strRes = "{SAVESUCCESSED}"; } catch (Exception ex) { Tracer.Debug("生成考勤初始化记录出错:" + ex.ToString()); strRes = ex.Message.ToString(); } return(strRes); }
/// <summary> /// 根据传回的xml生成员工入职 /// </summary> /// <param name="eGFunc"></param> /// <returns></returns> private static string AddEmployeeEntry(IEnumerable <XElement> eGFunc) { try { if (eGFunc.Count() == 0) { return(""); } string strEmployeeID = string.Empty; string strOwnerID = string.Empty; string strOwnerPostID = string.Empty; string strOwnerDepartmentID = string.Empty; string strOwnerCompanyID = string.Empty; string Name = string.Empty; int PROBATIONPERIOD = 0; string Idnumber = string.Empty; string sex = string.Empty; string isAcceptemploied = string.Empty; string createuserid = string.Empty; foreach (var q in eGFunc) { string strName = q.Attribute("Name").Value; switch (strName) { case "EMPLOYEEID": strEmployeeID = q.Attribute("Value").Value; break; case "OWNERID": strOwnerID = q.Attribute("Value").Value; break; case "OWNERPOSTID": strOwnerPostID = q.Attribute("Value").Value; break; case "OWNERDEPARTMENTID": strOwnerDepartmentID = q.Attribute("Value").Value; break; case "OWNERCOMPANYID": strOwnerCompanyID = q.Attribute("Value").Value; break; case "NAME": Name = q.Attribute("Value").Value; break; case "IDCARDNUMBER": Idnumber = q.Attribute("Value").Value; break; case "SEX": sex = q.Attribute("Value").Value; break; case "PROBATIONPERIOD": PROBATIONPERIOD = int.Parse(q.Attribute("Value").Value); break; case "ISACCEPTEMPLOIED": isAcceptemploied = q.Attribute("Value").Value; break; case "CREATEUSERID": createuserid = q.Attribute("Value").Value; break; } } //if (isAcceptemploied != "2") //{ // return string.Empty; //} PersonnelService ser = new PersonnelService(); T_HR_EMPLOYEEENTRY entry = new T_HR_EMPLOYEEENTRY(); T_HR_EMPLOYEE employee = new T_HR_EMPLOYEE(); T_HR_EMPLOYEEPOST epost = new T_HR_EMPLOYEEPOST(); employee.EMPLOYEEID = Guid.NewGuid().ToString(); employee.EMPLOYEECNAME = Name; employee.IDNUMBER = Idnumber.Replace("{", "").Replace("}", ""); employee.OWNERCOMPANYID = strOwnerCompanyID.Replace("{", "").Replace("}", ""); employee.OWNERDEPARTMENTID = strOwnerDepartmentID.Replace("{", "").Replace("}", ""); employee.OWNERPOSTID = strOwnerPostID.Replace("{", "").Replace("}", ""); employee.OWNERID = employee.EMPLOYEEID.Replace("{", "").Replace("}", ""); employee.CREATEDATE = DateTime.Now; employee.SEX = sex; employee.CREATEUSERID = createuserid; epost.EMPLOYEEPOSTID = Guid.NewGuid().ToString(); epost.ISAGENCY = "0"; epost.CREATEDATE = DateTime.Now; epost.T_HR_POST = new T_HR_POST(); epost.T_HR_POST.POSTID = employee.OWNERPOSTID; epost.T_HR_EMPLOYEE = new T_HR_EMPLOYEE(); epost.T_HR_EMPLOYEE.EMPLOYEEID = employee.EMPLOYEEID; epost.CREATEUSERID = createuserid; epost.CHECKSTATE = "0"; entry.EMPLOYEEENTRYID = Guid.NewGuid().ToString(); entry.CHECKSTATE = "0"; entry.PROBATIONPERIOD = PROBATIONPERIOD; entry.T_HR_EMPLOYEE = new T_HR_EMPLOYEE(); entry.T_HR_EMPLOYEE.EMPLOYEEID = employee.EMPLOYEEID; entry.CREATEDATE = System.DateTime.Now; entry.EMPLOYEEPOSTID = epost.EMPLOYEEPOSTID; entry.OWNERCOMPANYID = employee.OWNERCOMPANYID; entry.OWNERDEPARTMENTID = employee.OWNERDEPARTMENTID; entry.OWNERPOSTID = employee.OWNERPOSTID; entry.OWNERID = employee.EMPLOYEEID; entry.CREATEUSERID = createuserid; ser.AddEmployeeEntry(employee, entry, epost); return(entry.EMPLOYEEENTRYID); } catch (Exception e) { string abc = "<HR>Message=[" + e.Message + "]" + "<HR>Source=[" + e.Source + "]<HR>StackTrace=[" + e.StackTrace + "]<HR>TargetSite=[" + e.TargetSite + "]"; Tracer.Debug(abc); return(abc); } }
public decimal GetMaxDays(List <T_HR_EMPLOYEE> listEmployees, List <T_HR_EMPLOYEEENTRY> entrys, List <T_HR_EMPLOYEEPOST> employeePosts, T_HR_EMPLOYEELEVELDAYCOUNT employeeFreeCount, bool isBreak, List <T_HR_ATTENDFREELEAVE> freeLeaves) { decimal deDays = 0; try { //获取某个员工的入职信息 var qw = from ent in entrys where ent.T_HR_EMPLOYEE.EMPLOYEEID == employeeFreeCount.EMPLOYEEID select ent; //获取员工的岗位信息 var qp = from ent in employeePosts where ent.T_HR_EMPLOYEE.EMPLOYEEID == employeeFreeCount.EMPLOYEEID && ent.T_HR_EMPLOYEE.OWNERCOMPANYID == employeeFreeCount.OWNERCOMPANYID select ent; var entEmployees = from ent in listEmployees where ent.EMPLOYEEID == employeeFreeCount.EMPLOYEEID select ent; //isBreak 为true 调用处则跳出循环 if (qw == null) { isBreak = true; } if (qp == null) { isBreak = true; } if (entEmployees == null) { isBreak = true; } T_HR_EMPLOYEE entEmployee = entEmployees.FirstOrDefault(); T_HR_EMPLOYEEPOST entPost = qp.FirstOrDefault(); if (entPost == null) { isBreak = true; } T_HR_EMPLOYEEENTRY entEntry = qw.FirstOrDefault(); if (entEntry == null) { isBreak = true; } DateTime dtEntryDate = entEntry.ENTRYDATE.Value; TimeSpan tsWorkTime = DateTime.Now.Subtract(dtEntryDate); decimal dCurWorkAge = 0, dEmployeePostLevel = 0; dCurWorkAge = decimal.Round(tsWorkTime.Days / 30, 0); decimal.TryParse(entPost.POSTLEVEL.ToString(), out dEmployeePostLevel); foreach (T_HR_ATTENDFREELEAVE entAttendFreeLeave in freeLeaves) { T_HR_LEAVETYPESET entLeaveTypeSet = entAttendFreeLeave.T_HR_LEAVETYPESET; if (entLeaveTypeSet == null) { continue; } string strVacType = entLeaveTypeSet.LEAVETYPEVALUE; string strFineType = entLeaveTypeSet.FINETYPE; //如果是调休假,就不需要自动生成 if (strVacType == (Convert.ToInt32(Common.LeaveTypeValue.AdjustLeave) + 1).ToString()) { continue; } //获取假期标准的带薪假设置记录 FreeLeaveDaySetBLL bllFreeLeave = new FreeLeaveDaySetBLL(); IQueryable <T_HR_FREELEAVEDAYSET> entFreeLeaves = bllFreeLeave.GetFreeLeaveDaySetByLeaveTypeID(entLeaveTypeSet.LEAVETYPESETID); if (strFineType != (Convert.ToInt32(Common.LeaveFineType.Free) + 1).ToString()) { continue; } decimal dPostLevelStrict = 0; decimal.TryParse(entLeaveTypeSet.POSTLEVELRESTRICT, out dPostLevelStrict); if (dPostLevelStrict > dEmployeePostLevel) { continue; } if (entLeaveTypeSet.ENTRYRESTRICT == (Convert.ToInt32(Common.IsChecked.Yes) + 1).ToString()) { if (entEmployee.EMPLOYEESTATE != "1") { continue; } } if (entLeaveTypeSet.SEXRESTRICT != "2") { if (entLeaveTypeSet.SEXRESTRICT != entEmployee.SEX) { continue; } } if (!string.IsNullOrEmpty(entLeaveTypeSet.POSTLEVELRESTRICT)) { decimal dPostLeavlStrict = decimal.Parse(entLeaveTypeSet.POSTLEVELRESTRICT); } int j = -1; decimal dLeaveDay = 0; string LeaveDayName = string.Empty; if (entFreeLeaves.Count() > 0) { for (int i = 0; i < entFreeLeaves.Count(); i++) { if (entFreeLeaves.ToList()[i].MINIMONTH > dCurWorkAge) { continue; } if (entFreeLeaves.ToList()[i].MAXMONTH < dCurWorkAge) { continue; } dLeaveDay = entFreeLeaves.ToList()[i].LEAVEDAYS.Value; LeaveDayName = entLeaveTypeSet.LEAVETYPENAME; j = i; break; } } else { dLeaveDay = entLeaveTypeSet.MAXDAYS.Value; j = 1; } decimal dAddDays = 0; if (j > -1) { if (entFreeLeaves.Count() > 0) { if (j == 0) { dAddDays = dLeaveDay; } else { dAddDays = dLeaveDay - entFreeLeaves.ToList()[j - 1].LEAVEDAYS.Value; } } else { dAddDays = dLeaveDay; } } string strNumOfDecDefault = "0.5"; dAddDays = RoundOff(dAddDays, strNumOfDecDefault, 1); dLeaveDay = RoundOff(dLeaveDay, strNumOfDecDefault, 1); deDays = dAddDays; } } catch (Exception ex) { } return(deDays); }
private void InitParas() { PARENT.Children.Remove(loadbar); PARENT.Children.Add(loadbar); loadbar.Stop(); client = new PersonnelServiceClient(); client.EmployeeEntryAddCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(client_EmployeeEntryAddCompleted); client.EmployeeAddCompleted += new EventHandler<EmployeeAddCompletedEventArgs>(client_EmployeeAddCompleted); client.EmployeeUpdateCompleted += new EventHandler<EmployeeUpdateCompletedEventArgs>(client_EmployeeUpdateCompleted); client.AddEmployeeEntryCompleted += new EventHandler<AddEmployeeEntryCompletedEventArgs>(client_AddEmployeeEntryCompleted); perclient = new PermissionServiceClient(); perclient.SysUserInfoAddORUpdateCompleted += new EventHandler<SysUserInfoAddORUpdateCompletedEventArgs>(perclient_SysUserInfoAddORUpdateCompleted); orclient = new SMT.Saas.Tools.OrganizationWS.OrganizationServiceClient(); orclient.GetPostNumberCompleted += new EventHandler<SMT.Saas.Tools.OrganizationWS.GetPostNumberCompletedEventArgs>(orclient_GetPostNumberCompleted); salaryCient = new Saas.Tools.SalaryWS.SalaryServiceClient(); salaryCient.AddSalaryPasswordCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(salaryCient_AddSalaryPasswordCompleted); //员工入职 EmployeeEntry = new T_HR_EMPLOYEEENTRY(); //EmployeeEntry.T_HR_EMPLOYEE = Employee; EmployeeEntry.T_HR_EMPLOYEE = new T_HR_EMPLOYEE(); EmployeeEntry.T_HR_EMPLOYEE.EMPLOYEEID = Employee.EMPLOYEEID; EmployeeEntry.T_HR_EMPLOYEE.EMPLOYEECNAME = Employee.EMPLOYEECNAME; EmployeeEntry.EMPLOYEEENTRYID = Guid.NewGuid().ToString(); EmployeeEntry.CREATEUSERID = Common.CurrentLoginUserInfo.EmployeeID; EmployeeEntry.CHECKSTATE = Convert.ToInt32(CheckStates.UnSubmit).ToString(); EmployeeEntry.CREATEDATE = DateTime.Now; EmployeeEntry.ENTRYDATE = DateTime.Now; EmployeeEntry.ONPOSTDATE = DateTime.Now; EmployeeEntry.EDITSTATE = "0"; EmployeeEntry.CREATECOMPANYID = Common.CurrentLoginUserInfo.UserPosts[0].CompanyID; EmployeeEntry.CREATEDEPARTMENTID = Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID; EmployeeEntry.CREATEPOSTID = Common.CurrentLoginUserInfo.UserPosts[0].PostID; EmployeeEntry.OWNERID = Employee.EMPLOYEEID; //员工岗位 EmployeePost = new T_HR_EMPLOYEEPOST(); EmployeePost.EMPLOYEEPOSTID = Guid.NewGuid().ToString(); //EmployeePost.T_HR_EMPLOYEE = Employee; EmployeePost.T_HR_EMPLOYEE = new T_HR_EMPLOYEE(); EmployeePost.T_HR_EMPLOYEE.EMPLOYEEID = Employee.EMPLOYEEID; EmployeePost.CREATEUSERID = Common.CurrentLoginUserInfo.EmployeeID; EmployeePost.CHECKSTATE = Convert.ToInt32(CheckStates.UnSubmit).ToString(); EmployeePost.EDITSTATE = Convert.ToInt32(EditStates.UnActived).ToString(); //岗位未审核通过 无效 EmployeePost.CREATEDATE = DateTime.Now; EmployeePost.ISAGENCY = "0"; //非代理岗位 EmployeeEntry.EMPLOYEEPOSTID = EmployeePost.EMPLOYEEPOSTID; //系统用户 SysUser = new T_SYS_USER(); SysUser.SYSUSERID = Guid.NewGuid().ToString(); SysUser.STATE = "0"; txtUser.Text = Employee.EMPLOYEEENAME.Trim(); string strCarID = Employee.IDNUMBER; //if (strCarID.Length > 6) //{ // txtPwd.Password = "******"+strCarID.Substring(strCarID.Length - 6); //} //else //{ // txtPwd.Password = "******" + strCarID; //} if (strCarID.Length > 6) { txtPwd.Password = "******" + strCarID.Substring(strCarID.Length - 6); } else { txtPwd.Password = "******" + strCarID; } txtPwd.IsEnabled = false; SysUser.CREATEUSER = Common.CurrentLoginUserInfo.EmployeeID; SysUser.CREATEDATE = DateTime.Now; }
/// <summary> /// 根据员工ID获取员工的带薪假期的天数,调休假天数,及已休假天数。 /// </summary> /// <param name="employeeID">员工ID</param> /// <param name="date">日期</param> /// <returns></returns> public List <V_EMPLOYEELEAVE> GetEmployeeLeaveByEmployeeID(string employeeID, DateTime date) { List <V_EMPLOYEELEAVE> leaveList = new List <V_EMPLOYEELEAVE>(); try { //获取员工组织架构 EmployeeBLL employeeBll = new EmployeeBLL(); V_EMPLOYEEPOST employeePost = employeeBll.GetEmployeeDetailByID(employeeID); //获取员工的入职信息 EmployeeEntryBLL entryBll = new EmployeeEntryBLL(); T_HR_EMPLOYEEENTRY entry = entryBll.GetEmployeeEntryByEmployeeID(employeeID); DateTime entryDate = entry.ENTRYDATE.Value; int m = Utility.DateDiff(entryDate, date, "M"); string departmentID = employeePost.EMPLOYEEPOSTS[0].T_HR_POST.T_HR_DEPARTMENT.DEPARTMENTID; string comparyID = employeePost.EMPLOYEEPOSTS[0].T_HR_POST.T_HR_DEPARTMENT.T_HR_COMPANY.COMPANYID; var ent = from a in dal.GetObjects().Include("T_HR_LEAVETYPESET") join al in dal.GetObjects <T_HR_ATTENDFREELEAVE>().Include("T_HR_ATTENDANCESOLUTION").Include("T_HR_LEAVETYPESET") on a.T_HR_LEAVETYPESET.LEAVETYPESETID equals al.T_HR_LEAVETYPESET.LEAVETYPESETID join ad in dal.GetObjects <T_HR_ATTENDANCESOLUTION>() on al.T_HR_ATTENDANCESOLUTION.ATTENDANCESOLUTIONID equals ad.ATTENDANCESOLUTIONID join at in dal.GetObjects <T_HR_ATTENDANCESOLUTIONASIGN>() on ad.ATTENDANCESOLUTIONID equals at.T_HR_ATTENDANCESOLUTION.ATTENDANCESOLUTIONID where (at.ASSIGNEDOBJECTID == departmentID || at.ASSIGNEDOBJECTID == comparyID) && a.MINIMONTH <= m && a.MAXMONTH >= m select new V_EMPLOYEELEAVE() { EmployeeID = employeeID, EmployeeCode = employeePost.T_HR_EMPLOYEE.EMPLOYEECODE, EmployeeName = employeePost.T_HR_EMPLOYEE.EMPLOYEECNAME, LeaveTypeName = a.T_HR_LEAVETYPESET.LEAVETYPENAME, LeaveTypeSetID = a.T_HR_LEAVETYPESET.LEAVETYPESETID, MaxDays = a.T_HR_LEAVETYPESET.MAXDAYS.Value, FineType = a.T_HR_LEAVETYPESET.FINETYPE, IsPerfectAttendanceFactor = a.ISPERFECTATTENDANCEFACTOR, LeaveDays = a.LEAVEDAYS.Value }; leaveList = ent.Count() > 0 ? ent.ToList() : null; //获取年度考勤结算日 AttendanceSolutionAsignBLL bll = new AttendanceSolutionAsignBLL(); var tempEnt = bll.GetAttendanceSolutionAsignByEmployeeID(employeeID); string strDate = tempEnt.T_HR_ATTENDANCESOLUTION.YEARLYBALANCEDATE; string strType = tempEnt.T_HR_ATTENDANCESOLUTION.YEARLYBALANCETYPE; //结算方式 //获取加班调休假的天数 EmployeeLevelDayCountBLL leaveDaybll = new EmployeeLevelDayCountBLL(); AdjustLeaveBLL adjustbll = new AdjustLeaveBLL(); decimal leaveDays = leaveDaybll.GetLevelDayCountByEmployeeID(employeeID, date, strDate); V_EMPLOYEELEAVE leave = new V_EMPLOYEELEAVE(); ent = from a in dal.GetObjects <T_HR_LEAVETYPESET>() where !string.IsNullOrEmpty(a.LEAVETYPEVALUE) select new V_EMPLOYEELEAVE { EmployeeID = employeeID, EmployeeCode = employeePost.T_HR_EMPLOYEE.EMPLOYEECODE, EmployeeName = employeePost.T_HR_EMPLOYEE.EMPLOYEECNAME, LeaveTypeName = a.LEAVETYPENAME, LeaveTypeSetID = a.LEAVETYPESETID, MaxDays = a.MAXDAYS.Value, FineType = a.FINETYPE, LeaveDays = leaveDays }; leave = ent.Count() > 0 ? ent.FirstOrDefault() : null; if (leave != null) { leaveList.Add(leave); } //获取已休天数,并算出可休假天数 foreach (var obj in leaveList) { //剩余可休假为累计的情况 if (strType == "1") { //往年可休假的总数 decimal leaveHistoryDays = leaveDaybll.GetLevelDayCountHistoryByEmployeeID(employeeID, date, strDate); //往年已休假的总数 decimal UsedUpDays = adjustbll.GetUseUpHistory(obj.LeaveTypeSetID, obj.EmployeeID, date, strDate); obj.LeaveDays += leaveHistoryDays - UsedUpDays; } obj.UsedLeaveDays = adjustbll.GetUseUp(obj.LeaveTypeSetID, obj.EmployeeID, date, strDate); obj.UseableLeaveDays = obj.LeaveDays - obj.UsedLeaveDays; } } catch (Exception ex) { Tracer.Debug(ex.ToString()); } return(leaveList); }
private void InitParas(string strID) { client = new PersonnelServiceClient(); perclient = new PermissionServiceClient(); perclient.GetUserNameIsExistNameAddOneCompleted += new EventHandler<Saas.Tools.PermissionWS.GetUserNameIsExistNameAddOneCompletedEventArgs>(perclient_GetUserNameIsExistNameAddOneCompleted); client.GetEmployeeEntryByIDCompleted += new EventHandler<GetEmployeeEntryByIDCompletedEventArgs>(client_GetEmployeeEntryByIDCompleted); client.EmployeeEntryAddCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(client_EmployeeEntryAddCompleted); client.EmployeeEntryUpdateCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(client_EmployeeEntryUpdateCompleted); client.EmployeeEntryDeleteCompleted += new EventHandler<EmployeeEntryDeleteCompletedEventArgs>(client_EmployeeEntryDeleteCompleted); // client.GetEmployeePostByEmployeeIDCompleted += new EventHandler<GetEmployeePostByEmployeeIDCompletedEventArgs>(client_GetEmployeePostByEmployeeIDCompleted); //client.GetEmployeeByIDCompleted += new EventHandler<GetEmployeeByIDCompletedEventArgs>(client_GetEmployeeByIDCompleted); client.GetEmployeeToEngineCompleted += new EventHandler<GetEmployeeToEngineCompletedEventArgs>(client_GetEmployeeToEngineCompleted); client.GetEmployeePostByEmployeePostIDCompleted += new EventHandler<GetEmployeePostByEmployeePostIDCompletedEventArgs>(client_GetEmployeePostByEmployeePostIDCompleted); perclient = new PermissionServiceClient(); perclient.SysUserInfoAddCompleted += new EventHandler<SMT.Saas.Tools.PermissionWS.SysUserInfoAddCompletedEventArgs>(perclient_SysUserInfoAddCompleted); perclient.SysUserInfoUpdateCompleted += new EventHandler<SysUserInfoUpdateCompletedEventArgs>(perclient_SysUserInfoUpdateCompleted); perclient.GetUserByEmployeeIDCompleted += new EventHandler<GetUserByEmployeeIDCompletedEventArgs>(perclient_GetUserByEmployeeIDCompleted); orclient = new SMT.Saas.Tools.OrganizationWS.OrganizationServiceClient(); orclient.GetPostNumberCompleted += new EventHandler<SMT.Saas.Tools.OrganizationWS.GetPostNumberCompletedEventArgs>(orclient_GetPostNumberCompleted); Configclient = new HrCommonServiceClient(); Configclient.GetAppConfigByNameCompleted += new EventHandler<GetAppConfigByNameCompletedEventArgs>(Configclient_GetAppConfigByNameCompleted); client.GetEmailNameIsExistNameAddOneCompleted += new EventHandler<GetEmailNameIsExistNameAddOneCompletedEventArgs>(client_GetEmailNameIsExistNameAddOneCompleted); if (FormType == FormTypes.Browse)//|| FormType == FormTypes.Audit { // this.IsEnabled=false; EnablControl(); } if (FormType == FormTypes.Edit || FormType == FormTypes.Resubmit) { txtUser.Focus(); txtUser.IsEnabled = true; txtPwd.IsEnabled = true; txtUser.IsReadOnly = false; txtEmployeeCName.IsEnabled = true; txtEmployeeCName.IsReadOnly = false; dpEntryDate.IsEnabled = true; dpOnPostDate.IsEnabled = true; cbxPostLevel.IsEnabled = true; numPorbationperiod.IsEnabled = true; } if (FormType == FormTypes.New) { //员工岗位 EmployeePost = new T_HR_EMPLOYEEPOST(); EmployeePost.EMPLOYEEPOSTID = Guid.NewGuid().ToString(); EmployeePost.CREATEUSERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID; EmployeePost.CHECKSTATE = Convert.ToInt32(CheckStates.UnSubmit).ToString(); EmployeePost.EDITSTATE = Convert.ToInt32(EditStates.UnActived).ToString(); //EmployeePost.CHECKSTATE = Convert.ToInt32(CheckStates.Approved).ToString(); //默认审核成功 //EmployeePost.EDITSTATE = Convert.ToInt32(EditStates.Actived).ToString(); EmployeePost.CREATEDATE = DateTime.Now; //员工入职 EmployeeEntry = new T_HR_EMPLOYEEENTRY(); EmployeeEntry.EMPLOYEEENTRYID = Guid.NewGuid().ToString(); EmployeeEntry.CREATEUSERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID; EmployeeEntry.CHECKSTATE = Convert.ToInt32(CheckStates.UnSubmit).ToString(); EmployeeEntry.CREATEDATE = DateTime.Now; //系统用户 SysUser = new T_SYS_USER(); SysUser.SYSUSERID = Guid.NewGuid().ToString(); SysUser.STATE = "0"; SysUser.CREATEUSER = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID; SysUser.CREATEDATE = DateTime.Now; createUserName = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeName; SetToolBar(); Utility.InitFileLoad("EmployeeEntry", EmployeeEntry.EMPLOYEEENTRYID, FormType, uploadFile); } else { RefreshUI(RefreshedTypes.ShowProgressBar); client.GetEmployeeEntryByIDAsync(strID); Utility.InitFileLoad("EmployeeEntry", strID, FormType, uploadFile); } }
private string GetXmlString(string StrSource, T_HR_EMPLOYEEENTRY Info) { SMT.Saas.Tools.OrganizationWS.T_HR_COMPANY ownerCompany = (Application.Current.Resources["SYS_CompanyInfo"] as List<SMT.Saas.Tools.OrganizationWS.T_HR_COMPANY>).Where(s => s.COMPANYID == Info.OWNERCOMPANYID).FirstOrDefault(); SMT.Saas.Tools.OrganizationWS.T_HR_DEPARTMENT ownerDepartment = (Application.Current.Resources["SYS_DepartmentInfo"] as List<SMT.Saas.Tools.OrganizationWS.T_HR_DEPARTMENT>).Where(s => s.DEPARTMENTID == Info.OWNERDEPARTMENTID).FirstOrDefault(); SMT.Saas.Tools.OrganizationWS.T_HR_POST ownerPost = (Application.Current.Resources["SYS_PostInfo"] as List<SMT.Saas.Tools.OrganizationWS.T_HR_POST>).Where(s => s.POSTID == Info.OWNERPOSTID).FirstOrDefault(); string ownerCompanyName = string.Empty; string ownerDepartmentName = string.Empty; string ownerPostName = string.Empty; if (ownerCompany != null) { ownerCompanyName = ownerCompany.CNAME; } if (ownerDepartment != null) { ownerDepartmentName = ownerDepartment.T_HR_DEPARTMENTDICTIONARY == null ? "" : ownerDepartment.T_HR_DEPARTMENTDICTIONARY.DEPARTMENTNAME; } if (ownerPost != null) { ownerPostName = ownerPost.T_HR_POSTDICTIONARY == null ? "" : ownerPost.T_HR_POSTDICTIONARY.POSTNAME; } decimal? stateValue = Convert.ToDecimal("1"); string checkState = string.Empty; SMT.Saas.Tools.PermissionWS.T_SYS_DICTIONARY checkStateDict = (Application.Current.Resources["SYS_DICTIONARY"] as List<SMT.Saas.Tools.PermissionWS.T_SYS_DICTIONARY>).Where(s => s.DICTIONCATEGORY == "CHECKSTATE" && s.DICTIONARYVALUE == stateValue).FirstOrDefault(); checkState = checkStateDict == null ? "" : checkStateDict.DICTIONARYNAME; SMT.Saas.Tools.PermissionWS.T_SYS_DICTIONARY postLevelDict = (cbxPostLevel.SelectedItem as SMT.Saas.Tools.PermissionWS.T_SYS_DICTIONARY); List<T_SYS_USER> sysuserList = new List<T_SYS_USER>(); sysuserList.Add(SysUser); SMT.SaaS.MobileXml.MobileXml mx = new SMT.SaaS.MobileXml.MobileXml(); List<SMT.SaaS.MobileXml.AutoDictionary> AutoList = new List<SMT.SaaS.MobileXml.AutoDictionary>(); AutoList.Add(basedata("T_HR_EMPLOYEEENTRY", "CHECKSTATE", "1", checkState)); AutoList.Add(basedata("T_HR_EMPLOYEEENTRY", "EMPLOYEEID", Info.T_HR_EMPLOYEE.EMPLOYEEID, Info.T_HR_EMPLOYEE.EMPLOYEECNAME)); AutoList.Add(basedata("T_HR_EMPLOYEEENTRY", "POSTLEVEL", EmployeePost.POSTLEVEL.ToString(), postLevelDict == null ? "" : postLevelDict.DICTIONARYNAME)); AutoList.Add(basedata("T_HR_EMPLOYEEENTRY", "EMPLOYEECNAME", Info.T_HR_EMPLOYEE.EMPLOYEECNAME, Info.T_HR_EMPLOYEE.EMPLOYEECNAME)); AutoList.Add(basedata("T_HR_EMPLOYEEENTRY", "OWNER", Info.T_HR_EMPLOYEE.EMPLOYEECNAME, Info.T_HR_EMPLOYEE.EMPLOYEECNAME)); AutoList.Add(basedata("T_HR_EMPLOYEEENTRY", "CREATEUSERNAME", createUserName, createUserName)); AutoList.Add(basedata("T_HR_EMPLOYEEENTRY", "EMPLOYEEPOSTID", Info.EMPLOYEEPOSTID, lkPost.TxtLookUp.Text)); //AutoList.Add(basedata("T_OA_APPROVALINFO", "OWNERCOMPANYID", approvalInfo.OWNERCOMPANYID, StrCompanyName)); //AutoList.Add(basedata("T_OA_APPROVALINFO", "OWNERDEPARTMENTID", approvalInfo.OWNERDEPARTMENTID, StrDepartmentName)); //AutoList.Add(basedata("T_OA_APPROVALINFO", "OWNERPOSTID", approvalInfo.OWNERPOSTID, StrPostName)); //AutoList.Add(basedata("T_OA_APPROVALINFO", "TYPEAPPROVAL", approvalInfo.TYPEAPPROVAL, StrApprovalTypeName)); //AutoList.Add(basedata("T_OA_APPROVALINFO", "CONTENT", approvalInfo.APPROVALID, approvalInfo.APPROVALID)); //AutoList.Add(basedata("T_OA_APPROVALINFO", "AttachMent", approvalInfo.APPROVALID, approvalInfo.APPROVALID)); AutoList.Add(basedata("T_HR_EMPLOYEEENTRY", "OWNERCOMPANYID", Info.OWNERCOMPANYID, ownerCompanyName)); AutoList.Add(basedata("T_HR_EMPLOYEEENTRY", "OWNERDEPARTMENTID", Info.OWNERDEPARTMENTID, ownerDepartmentName)); AutoList.Add(basedata("T_HR_EMPLOYEEENTRY", "OWNERPOSTID", Info.OWNERPOSTID, ownerPostName)); string a = mx.TableToXml(Info, sysuserList, StrSource, AutoList); return a; }