From dce06906b2757824ad6ecfd02c1ff04ee8e9ad20 Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期四, 08 五月 2025 14:19:19 +0800
Subject: [PATCH] 1111

---
 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/MaintenanceService.cs |   70 +++++++++++++++++++++++++++++------
 1 files changed, 58 insertions(+), 12 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/MaintenanceService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/MaintenanceService.cs"
index 8a0db39..0219037 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/MaintenanceService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/MaintenanceService.cs"
@@ -13,17 +13,20 @@
 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;   
         }
 
 
@@ -53,7 +56,10 @@
                                a.CardNumber,
                                a.Userteam,
                                a.HeadImageUrl,
-                               b.IsPossible
+                               a.Dept_Id,
+                               b.IsPossible,
+                              
+                               
                            }).ToPageList(pagination.pageIndex, pagination.pageSize, ref totalCount);
                 return new WebResponseContent
                 {
@@ -87,26 +93,48 @@
         {
             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涓嶈繍琛屾淇�//榛樿涓篘ULL
+                    }
+                    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锛坰tatus锛�=null锛�
+                // 鐘舵�佸弬鏁�
+                if (pagination.status.HasValue)
                 {
                     query = query.Where((a, b) => b.MaintenanceStatus == pagination.status.Value);
                 }
+
+                
 
                 var result = query
                     .Select((a, b) => new
@@ -118,16 +146,16 @@
                         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
                     }
                 };
@@ -153,17 +181,35 @@
             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)

--
Gitblit v1.9.3