From b2e04d15e8284aa23af89200075b6fd52a77477e Mon Sep 17 00:00:00 2001
From: z8018 <1282578289@qq.com>
Date: 星期四, 08 五月 2025 14:50:36 +0800
Subject: [PATCH] 1

---
 project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/MaintenanceService.cs |   69 ++++++++++++++++++++++++++++------
 1 files changed, 56 insertions(+), 13 deletions(-)

diff --git a/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/MaintenanceService.cs b/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/MaintenanceService.cs
index 561685d..bd1cb30 100644
--- a/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/MaintenanceService.cs
+++ b/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/MaintenanceService.cs
@@ -13,20 +13,30 @@
 using WIDESEAWCS_DTO;
 using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
 using WIDESEAWCS_DTO.Telescopic;
+using SqlSugar.DistributedSystem.Snowflake;
+using System.IO;
 
 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;   
         }
 
 
+
+        /// <summary>
+        /// 璁剧疆妫�淇潈闄�
+        /// </summary>
+        /// <param name="pagination"></param>
+        /// <returns></returns>
         public WebResponseContent ShowMaintence(PaginationDTO pagination)
         {
             try
@@ -110,28 +120,47 @@
         {
             try
             {
+                // 绗竴姝ワ細鑷姩娓呯悊杩囨湡妫�淇姸鎬�
+                var today = DateTime.Today;
+                var recordsToUpdate = Db.Queryable<Dt_Maintenance>()
+                    .Where(b => b.MaintenancStartTime != null &&
+                                b.MaintenancStartTime.Value.Date < today  ) 
+                    .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"); // 灞曠ず杩愯妫�淇殑
 
-                // 濡傛灉鎻愪緵浜嗘悳绱㈠叧閿瓧锛屽垯杩涜妯$硦鏌ヨ
+                // 鎼滅储鍏抽敭瀛�
                 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);
                 }
 
-                // 濡傛灉涓嶆槸绠$悊鍛橈紝鏍规嵁閮ㄩ棬杩囨护
+                // 濡傛灉涓嶆槸绠$悊鍛橈紝璇锋寜閮ㄩ棬杩囨护
                 if (pagination.account != "admin")
                 {
                     var currentUser = _user.Db.Queryable<Sys_User>()
@@ -144,7 +173,6 @@
                     }
 
                     int? deptId = currentUser.Dept_Id;
-
                     query = query.Where((a, b) => a.Dept_Id == deptId);
                 }
 
@@ -158,16 +186,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
                     }
                 };
@@ -193,11 +221,26 @@
             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
                 {

--
Gitblit v1.9.3