using Edu.Model.Entity.User; using Edu.Model.ViewModel.User; using System.Collections.Generic; using System.Linq; namespace Edu.Repository.User { /// <summary> /// 特殊日期扩展信息 /// </summary> public partial class Rb_technicaldatesRepository : BaseRepository<RB_Technicaldates> { /// <summary> /// 获取特殊打卡日期 /// </summary> /// <param name="empId">员工id</param> /// <param name="RB_Department_Id">部门id</param> /// <param name="date">打卡日期</param> /// <returns></returns> public RB_Technicaldates_Extend GetSpecialDate(int empId, int RB_Department_Id, string date) { string where = ""; if (empId > 0) { where += $" or t.EmployeeId={empId} "; } if (RB_Department_Id > 0) { where += $" or t.RB_Department_Id={RB_Department_Id} "; } return Get<RB_Technicaldates_Extend>($@"SELECT * from rb_technicaldates t where DATE(t.Date) = '{date}' and (t.AttendanceId = (SELECT a.Id from rb_attendance a INNER JOIN (SELECT e.RB_Branch_id,e.RB_Group_id from rb_employee e where e.EmployeeId = {empId}) as e on e.RB_Branch_id =a.RB_BranchId and e.RB_Group_id =a.RB_GroupId) {where}) ").ToList().FirstOrDefault(); } /// <summary> /// 获取特殊打卡日期列表 ld 2020/05/25 调整 /// </summary> /// <param name="empId">员工id</param> /// <param name="date">打卡日期</param> /// <returns></returns> public List<RB_Technicaldates_Extend> GetSpecialDateList(int empId, string date) { return Get<RB_Technicaldates_Extend>($@"SELECT * from rb_technicaldates t where DATE(t.Date) = '{date}' and t.AttendanceId = (SELECT a.Id from rb_attendance a INNER JOIN (SELECT e.RB_Branch_id,e.RB_Group_id from rb_employee e where e.EmployeeId = {empId}) as e on e.RB_Branch_id =a.RB_BranchId and e.RB_Group_id =a.RB_GroupId)").ToList(); } /// <summary> /// 获取公司该天是否需要打卡 /// </summary> /// <param name="Branch"></param> /// <param name="date"></param> /// <returns></returns> public RB_Technicaldates_Extend GetSpecialDateToBranch(int Branch, string date) { return Get<RB_Technicaldates_Extend>($@"SELECT * from rb_technicaldates t where DATE(t.Date) = '{date}' and t.AttendanceId = (SELECT a.Id from rb_attendance a where a.RB_BranchId={Branch})").ToList().FirstOrDefault(); } /// <summary> /// 获取公司该天是否需要打卡 /// </summary> /// <param name="Branch"></param> /// <param name="date"></param> /// <returns></returns> public List<RB_Technicaldates_Extend> GetSpecialDateToBranchList(int Branch, string date) { return Get<RB_Technicaldates_Extend>($@"SELECT * from rb_technicaldates t where DATE(t.Date) = '{date}' and t.AttendanceId = (SELECT a.Id from rb_attendance a where a.RB_BranchId={Branch})").ToList(); } /// <summary> /// 获取特殊打卡日期 /// </summary> /// <param name="empId">员工id</param> /// <returns></returns> public List<RB_Technicaldates_Extend> GetSpecialDateList(int empId) { return Get<RB_Technicaldates_Extend>($@"SELECT * from rb_technicaldates t where t.AttendanceId = (SELECT a.Id from rb_attendance a INNER JOIN (SELECT e.RB_Branch_id,e.RB_Group_id from rb_employee e where e.EmployeeId = {empId}) as e on e.RB_Branch_id =a.RB_BranchId and e.RB_Group_id =a.RB_GroupId)").ToList(); } } }