| | |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using AutoMapper; |
| | | using SqlSugar; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | |
| | | public IRepository<Dt_Loginhsy> Repository => BaseDal; |
| | | private readonly IRepository<Sys_User> _user; |
| | | |
| | | public LoginhsyService(IRepository<Dt_Loginhsy> BaseDal) : base(BaseDal) |
| | | public LoginhsyService(IRepository<Sys_User> user, IRepository<Dt_Loginhsy> BaseDal) : base(BaseDal) |
| | | { |
| | | |
| | | _user = user; |
| | | } |
| | | |
| | | public WebResponseContent LoginRecord(PaginationDTO pagination) |
| | |
| | | var sys = _user.Db.Queryable<Sys_User>(); |
| | | var main = Db.Queryable<Dt_Loginhsy>(); |
| | | |
| | | //æ¨¡ç³æ¥è¯¢ |
| | | var query = sys.InnerJoin<Dt_Loginhsy>((a, b) => a.UserName == b.UserName); |
| | | if (!string.IsNullOrEmpty(pagination.searchKeyword)) |
| | | { |
| | | query = query.Where((a, b) => |
| | | a.UserTrueName.Contains(pagination.searchKeyword) || |
| | | a.Userteam.Contains(pagination.searchKeyword) || |
| | | b.OpCenten.Contains(pagination.searchKeyword) |
| | | ); |
| | | b.OpCenten.Contains(pagination.searchKeyword)); |
| | | } |
| | | |
| | | //æ¶é´æ¥è¯¢ |
| | | if (pagination.startDate.HasValue && pagination.endDate.HasValue) |
| | | { |
| | | query = query.Where((a, b) => b.LoginTiem >= pagination.startDate.Value && b.LoginTiem <= pagination.endDate.Value);//ç»å
¥æ¶é´ |
| | | query = query.Where((a, b) => b.LoginTiem >= pagination.startDate.Value && b.LoginTiem <= pagination.endDate.Value); |
| | | } |
| | | var result=query |
| | | .Select((a, b) => new |
| | | |
| | | // æåºå¤ç |
| | | if (!string.IsNullOrEmpty(pagination.sortField)) |
| | | { |
| | | //isAscï¼è¿æ¯ä¸ä¸ªå¸å°å¼ï¼å¤ææåºæ¯ååº (true)"asc" ,è¿æ¯éåº (false) "desc" |
| | | var isAsc = pagination.sortOrder?.ToLower() == "asc";//pagination.sortOrder ä¸ä¸ºç©ºï¼åè°ç¨ ToLower() æ¹æ³å°å
¶è½¬ä¸ºå°å忝 |
| | | |
| | | query = pagination.sortField.ToLower() switch |
| | | { |
| | | //妿isAsc 为tureå°±æ§è¡query.OrderBy((a, b) => b.LoginTiem, OrderByType.Asc)ååºæåºï¼ |
| | | //å¦æä¸ºfaleså°±æ§è¡query.OrderBy((a, b) => b.LoginTiem, OrderByType.Desc)éåºæåº |
| | | "logintiem" => isAsc ? query.OrderBy((a, b) => b.LoginTiem, OrderByType.Asc) |
| | | : query.OrderBy((a, b) => b.LoginTiem, OrderByType.Desc), |
| | | |
| | | "outtiem" => isAsc ? query.OrderBy((a, b) => b.OutTiem, OrderByType.Asc) |
| | | : query.OrderBy((a, b) => b.OutTiem, OrderByType.Desc), |
| | | |
| | | //"usertruename" => isAsc ? query.OrderBy((a, b) => a.UserTrueName, OrderByType.Asc) |
| | | //: query.OrderBy((a, b) => a.UserTrueName, OrderByType.Desc), |
| | | _ => query.OrderBy((a, b) => b.LoginTiem, OrderByType.Desc) // é»è®¤æç»å
¥æ¶é´éåº |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | // é»è®¤æ LoginTiem éåº |
| | | query = query.OrderBy((a, b) => b.LoginTiem, OrderByType.Desc); |
| | | } |
| | | |
| | | // 妿䏿¯ç®¡çåï¼æ ¹æ®é¨é¨è¿æ»¤ |
| | | if (pagination.account != "admin") |
| | | { |
| | | var currentUser = _user.Db.Queryable<Sys_User>() |
| | | .Where(u => u.UserName == pagination.account) |
| | | .First(); |
| | | |
| | | if (currentUser == null) |
| | | { |
| | | return new WebResponseContent { Status = false, Data = "æªè·åå°ç¨æ·ä¿¡æ¯" }; |
| | | } |
| | | |
| | | int? deptId = currentUser.Dept_Id; |
| | | |
| | | query = query.Where((a, b) => a.Dept_Id == deptId); |
| | | } |
| | | |
| | | |
| | | //è¿åç»æ |
| | | var result = query.Select((a, b) => new |
| | | { |
| | | a.User_Id, |
| | | a.UserTrueName, |
| | |
| | | b.OutTiem, |
| | | b.OpCenten, |
| | | }).ToPageList(pagination.pageIndex, pagination.pageSize, ref totalCount); |
| | | |
| | | return new WebResponseContent |
| | | { |
| | | Status = true, |
| | | Data = new |
| | | { |
| | | TotalCount = totalCount,//æ»æ° |
| | | PageIndex = pagination.pageIndex,//é¡µæ° |
| | | PageSize = pagination.pageSize,//ä¸é¡µå¤å°ä¸ªæ°æ® |
| | | TotalCount = totalCount, // æ»æ° |
| | | PageIndex = pagination.pageIndex, // é¡µæ° |
| | | PageSize = pagination.pageSize, // ä¸é¡µå¤å°ä¸ªæ°æ® |
| | | Items = result |
| | | } |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | return new WebResponseContent { Status = true, Message = "é误" + ex }; |
| | | return new WebResponseContent { Status = false, Message = "é误: " + ex.Message }; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public WebResponseContent OutLoginTime(int id) |
| | | |
| | | |
| | | public WebResponseContent OutLoginTime(string account) |
| | | { |
| | | try |
| | | { |
| | | var log = BaseDal.QueryFirst(x => x.ID == id); |
| | | var log = BaseDal.QueryData(x=>x.UserName== account).OrderByDescending(x=>x.UserName).FirstOrDefault(); |
| | | if (log==null) |
| | | { |
| | | return new WebResponseContent { Status = false, Message = "失败" }; |