/// <summary> /// 根据考勤规则进行分流数据,符合条件的放在考勤表中,并将所有的数据更新状态 /// </summary> /// <param name="addressArea"></param> /// <param name="defaultRule"></param> /// <param name="limit"></param> /// <returns></returns> public void ByPassAttAsync(string addressArea = "", bool defaultRule = true, int limit = 100) { var sortDic = new Dictionary <string, string>(); sortDic.Add("AttendanceTime", "a"); var searchDic = new Dictionary <string, string>(); searchDic.Add("s_1_Status", "0");//状态是0的(未交换) if (!string.IsNullOrEmpty(addressArea)) { searchDic.Add("s_1_SegmentAddressArea", addressArea); } Expression <Func <T, bool> > expression = whereHelper.GetExpression(searchDic); List <T> alllist = service.GetList(limit, sortDic, expression); ManagePostAttRuleBusiness managePostAttRuleBusiness = new ManagePostAttRuleBusiness(this._options); //默认使用缺省考勤规则 ManagePostAttRule rule = managePostAttRuleBusiness.GetPostAttRule(); string amStart, amEnd, pmStart, pmEnd; long IntervalHours; DateTime attendanceTime; ////需要新增到考勤表的集合 //List<S> inRuleList = new List<S>(); alllist.ForEach((item) => { item.StatusTime = DateTime.Now; if (!defaultRule) { rule = managePostAttRuleBusiness.GetPostAttRule(item.CorpType, item.PostType); } amStart = rule.AmStart; amEnd = rule.AmEnd; pmStart = rule.PmStart; pmEnd = rule.PmEnd; IntervalHours = rule.IntervalHours; attendanceTime = item.AttendanceTime; //1、判断是否符合考勤时间段规则 if ( (attendanceTime >= Convert.ToDateTime($"{attendanceTime.ToString("yyyy-MM-dd")} {amStart}") && attendanceTime <= Convert.ToDateTime($"{attendanceTime.ToString("yyyy-MM-dd")} {amEnd}")) || (attendanceTime >= Convert.ToDateTime($"{attendanceTime.ToString("yyyy-MM-dd")} {pmStart}") && attendanceTime >= Convert.ToDateTime($"{attendanceTime.ToString("yyyy-MM-dd")} {pmStart}")) ) { //2、判断间隔小时是否满足 sortDic = new Dictionary <string, string>(); sortDic.Add("AttendanceTime", "d"); searchDic = new Dictionary <string, string>(); searchDic.Add("s_1_PersonGUID", item.PersonGUID); if (attendanceTime.AddHours(-IntervalHours) < Convert.ToDateTime($"{attendanceTime.ToString("yyyy-MM-dd")} {amStart}")) { searchDic.Add("s_3_AttendanceTime", $"{attendanceTime.ToString("yyyy-MM-dd")} {amStart},{attendanceTime}"); } else { searchDic.Add("s_3_AttendanceTime", $"{attendanceTime.AddHours(-IntervalHours)},{attendanceTime}"); } var oldList = serviceS.GetList(1, sortDic, whereHelperS.GetExpression(searchDic)); if (null != oldList && oldList.Count > 0)//两个小时内有考勤数据,更新历史表状态为-1 { item.Status = -1; service.Update(item.Id, item); } else//新增到考勤表,并更新历史表状态为1 { item.Status = 1; service.Update(item.Id, item); //inRuleList.Add(item); S s = _mapper.Map <S>(item); serviceS.Add(s); } } else//更新历史表状态为-2 { item.Status = -2; service.Update(item.Id, item); } }); }
public IEnumerable <Models.Entity.Student> GetStudents(StudentSearch search) { return(service.GetList(c => string.IsNullOrEmpty(search.Name) || c.FirstName == search.Name)); }