| | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 人员监控 |
| | | /// 人员监控(数字大屏) |
| | | /// </summary> |
| | | /// <param name="pageIndex"></param> |
| | | /// <param name="pageSize"></param> |
| | | /// <param name="searchKeyword"></param> |
| | | /// <returns></returns>(这个没有用到了) |
| | | /// <returns></returns> |
| | | public WebResponseContent PersonnelMonitoring(PaginationDTO pagination) |
| | | { |
| | | try |
| | | { |
| | | // 第一步:自动清理过期检修状态 |
| | | var today = DateTime.Today; |
| | | var recordsToUpdate = Db.Queryable<Dt_Maintenance>() |
| | | .Where(b => b.MaintenanceDate != null && |
| | | b.MaintenanceDate.Value.Date < today ) |
| | | .ToList(); |
| | | |
| | | if (recordsToUpdate.Count > 0) |
| | | { |
| | | foreach (var record in recordsToUpdate)//更新 |
| | | { |
| | | record.MaintenanceDate = null;//清空检修日期 |
| | | record.MaintenancStartTime = null;//清空开始时间 |
| | | record.MaintenancEendTime = null;//清空结束时间 |
| | | record.MaintenanceStatus = 0; // Set to false |
| | | record.IsPossible = "NULL"; //更改状态为false不运行检修//默认为NULL |
| | | } |
| | | Db.Updateable(recordsToUpdate).ExecuteCommand(); |
| | | } |
| | | |
| | | int totalCount = 0; |
| | | var sys = _user.Db.Queryable<Sys_User>(); |
| | | var main = Db.Queryable<Dt_Maintenance>(); |
| | | |
| | | |
| | | var query = sys.InnerJoin<Dt_Maintenance>((a, b) => a.UserName == b.UserAccount) |
| | | .Where((a, b) => b.IsPossible == "true"); // 展示运行检修的 |
| | | .Where((a, b) => b.MaintenanceStatus==1); // 展示运行检修的 |
| | | |
| | | // 搜索关键字 |
| | | if (!string.IsNullOrEmpty(pagination.searchKeyword)) |
| | |
| | | a.Userteam.Contains(pagination.searchKeyword)); |
| | | } |
| | | |
| | | // 状态参数 |
| | | if (pagination.status.HasValue) |
| | | { |
| | | query = query.Where((a, b) => b.MaintenanceStatus == pagination.status.Value); |
| | | } |
| | | |
| | | // 如果不是管理员,请按部门过滤 |
| | | 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); |
| | | } |
| | | //// 状态参数 |
| | | //if (pagination.status.HasValue) //多传一个状态 |
| | | //{ |
| | | // query = query.Where((a, b) => b.MaintenanceStatus == pagination.status.Value); |
| | | //} |
| | | |
| | | var result = query |
| | | .Select((a, b) => new |
| | | { |
| | | a.UserTrueName, |
| | | a.Userteam, |
| | | a.HeadImageUrl, |
| | | b.MaintenanceStatus, |
| | | b.MaintenanceDate, |
| | | b.IsPossible, |
| | | a.Userteam,//班组 |
| | | a.Unit,//单位 |
| | | b.MaintenanceStatus,//检修状态 |
| | | b.CreateDate,//日期 |
| | | b.MaintenancStartTime,//开始时间 |
| | | }) |
| | | .ToPageList(pagination.pageIndex, pagination.pageSize, ref totalCount); |
| | | |