| | |
| | | using WIDESEAWCS_DTO; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; |
| | | using WIDESEAWCS_DTO.Telescopic; |
| | | using Microsoft.AspNetCore.Mvc.ModelBinding; |
| | | |
| | | namespace WIDESEAWCS_TelescopicService |
| | | { |
| | | public class MaintenanceService : ServiceBase<Dt_Maintenance, IRepository<Dt_Maintenance>>, IMaintenanceService |
| | | { |
| | | public IRepository<Dt_Maintenance> Repository => BaseDal; |
| | | public readonly IRepository<Dt_MaintenanceTeam> _team; |
| | | private readonly IRepository<Sys_User> _user; |
| | | |
| | | public MaintenanceService(IRepository<Dt_Maintenance> BaseDal, IRepository<Sys_User> user) : base(BaseDal) |
| | | public MaintenanceService(IRepository<Dt_Maintenance> BaseDal, IRepository<Sys_User> user, IRepository<Dt_MaintenanceTeam> team) : base(BaseDal) |
| | | { |
| | | _user = user; |
| | | _team = team; |
| | | } |
| | | |
| | | |
| | |
| | | a.CardNumber, |
| | | a.Userteam, |
| | | a.HeadImageUrl, |
| | | b.IsPossible |
| | | a.Dept_Id, |
| | | b.IsPossible, |
| | | |
| | | |
| | | }).ToPageList(pagination.pageIndex, pagination.pageSize, ref totalCount); |
| | | return new WebResponseContent |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | // ç¬¬ä¸æ¥ï¼èªå¨æ¸
çè¿ææ£ä¿®ç¶æ |
| | | var today = DateTime.Today; |
| | | var recordsToUpdate = Db.Queryable<Dt_Maintenance>() |
| | | .Where(b => b.MaintenancStartTime != null && |
| | | b.MaintenancStartTime.Value.Date < today) // Assuming 0 is false |
| | | .ToList(); |
| | | |
| | | if (recordsToUpdate.Count > 0) |
| | | { |
| | | foreach (var record in recordsToUpdate)//æ´æ° |
| | | { |
| | | 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"); // å
çé IsPossible 为 true çæ°æ® |
| | | .Where((a, b) => b.IsPossible == "true"); // Filter IsPossible true first |
| | | |
| | | // 妿æä¾äºæç´¢å
³é®åï¼åè¿è¡æ¨¡ç³æ¥è¯¢ |
| | | // æç´¢å
³é®å |
| | | if (!string.IsNullOrEmpty(pagination.searchKeyword)) |
| | | { |
| | | query = query.Where((a, b) => |
| | | a.UserTrueName.Contains(pagination.searchKeyword) || // æçå®å§åæ¨¡ç³æç´¢ |
| | | a.Userteam.Contains(pagination.searchKeyword)); // æç¨æ·çç»æ¨¡ç³æç´¢ |
| | | a.UserTrueName.Contains(pagination.searchKeyword) || |
| | | a.Userteam.Contains(pagination.searchKeyword)); |
| | | } |
| | | |
| | | // 妿æä¾äº status åæ°ï¼åæç¶æçé |
| | | if (pagination.status.HasValue)//çä»·ifï¼statusï¼=nullï¼ |
| | | // ç¶æåæ° |
| | | if (pagination.status.HasValue) |
| | | { |
| | | query = query.Where((a, b) => b.MaintenanceStatus == pagination.status.Value); |
| | | } |
| | | |
| | | |
| | | |
| | | var result = query |
| | | .Select((a, b) => new |
| | |
| | | b.MaintenanceDate, |
| | | b.IsPossible, |
| | | }) |
| | | .ToPageList(pagination.pageIndex, pagination.pageSize, ref totalCount); // å页 |
| | | .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 |
| | | } |
| | | }; |
| | |
| | | try |
| | | { |
| | | var mon = BaseDal.QueryFirst(x => x.ID == id); |
| | | if (mon==null) |
| | | { |
| | | return new WebResponseContent { Status = false, Message = "æ æ³æ´æ¹ï¼æ²¡ææ¾å°è¯¥ç¨æ·" }; |
| | | } |
| | | var sysuer = _user.QueryData(x => x.UserName == mon.UserAccount).FirstOrDefault(); |
| | | |
| | | if (ispossible == "true") |
| | | { |
| | | mon.IsPossible = "true"; |
| | | mon.MaintenanceDate = DateTime.Now; |
| | | BaseDal.UpdateData(mon); |
| | | var recording = new Dt_MaintenanceTeam |
| | | { |
| | | OperatorName = sysuer.UserTrueName, |
| | | TeamName = sysuer.RoleName, |
| | | DistributionTime = DateTime.Now, |
| | | Creater = "admin", |
| | | CreateDate = DateTime.Now, |
| | | |
| | | }; |
| | | _team.AddData(recording); |
| | | } |
| | | else |
| | | { |
| | | mon.IsPossible = "false"; |
| | | BaseDal.UpdateData(mon); |
| | | } |
| | | |
| | | |
| | | return new WebResponseContent { Status = true, Data = mon }; |
| | | } |
| | | catch (Exception ex) |