From c5de0d98241f8c8349fa38851b77efcfc61e4d26 Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期二, 29 七月 2025 15:42:00 +0800
Subject: [PATCH] 前端代码

---
 项目代码/后端/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/MaintenanceService.cs |  130 +++++-------------------------------------
 1 files changed, 17 insertions(+), 113 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/\345\220\216\347\253\257/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/MaintenanceService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/\345\220\216\347\253\257/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/MaintenanceService.cs"
index bd567dd..9a78cf8 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/\345\220\216\347\253\257/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/MaintenanceService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/\345\220\216\347\253\257/WCS/WIDESEAWCS_Server/WIDESEAWCS_TelescopicService/MaintenanceService.cs"
@@ -235,11 +235,12 @@
             {
                 // 1. 鏌ユ壘鐩爣鐢ㄦ埛锛堣琚己鍒朵笅绾跨殑浜猴級
                 var maint = BaseDal.QueryData().FirstOrDefault(x => x.ID == id);
-                var sysuer = _user.QueryData(x => x.UserName == maint.UserAccount).FirstOrDefault();//user琛�
-                if (maint == null || sysuer==null)
+                if (maint==null)
                 {
                     return new WebResponseContent { Status = false, Message = "娌℃湁鎵惧埌璇ョ敤鎴�" };
                 }
+                var sysuer = _user.QueryData(x => x.UserName == maint.UserAccount).FirstOrDefault();//user琛�
+               
                
 
                 // 2. 鏌ユ壘褰撳墠鐧诲綍鐢ㄦ埛锛堟墽琛屾搷浣滅殑浜猴級
@@ -262,6 +263,8 @@
                 maint.MaintenanceStatus = 0;  // 鏀瑰彉鐘舵�佷负涓嬬嚎
                 BaseDal.UpdateData(maint);
 
+                var ip = LocalIP?.Replace("::ffff:", "") ?? ""; // 濡傛灉 LocalIP 鏄� null锛宨p 浼氭槸 ""
+
                 // 5. 璁板綍鎿嶄綔鏃ュ織
                 var recording = new Dt_MaintenanceTeam
                 {
@@ -270,7 +273,7 @@
                     OperatorName = sysuer.UserTrueName,  // 鎿嶄綔浜哄鍚�
                     TeamName = sysuer.RoleName,         // 鎿嶄綔浜鸿鑹�
                     DistributionTime = DateTime.Now,
-                    IPAddress = LocalIP,
+                    IPAddress = ip,
                 };
                 _team.AddData(recording);
 
@@ -499,108 +502,6 @@
 
 
 
-
-        ///// <summary>
-        ///// 寮�濮嬫淇�
-        ///// </summary>
-        ///// <param name="account">璐﹀彿</param>
-        ///// <param name="LocalIP">閭e彴鐢佃剳鐧诲叆鐨刬p鍦板潃</param>
-        ///// <returns></returns>
-        //public WebResponseContent StartMaintenceTask(string account,string LocalIP)
-        //{
-        //    try
-        //    {
-        //        var user = BaseDal.QueryData();
-        //        var maint = user.Where(x =>x.UserAccount == account).FirstOrDefault();
-        //        var sysuer = _user.QueryData(x => x.UserName == account).FirstOrDefault();//鐢ㄦ埛琛�
-        //        if (maint == null || sysuer == null)
-        //        {
-        //            return new WebResponseContent { Status = false, Message = "娌℃湁鎵惧埌璇ョ敤鎴�" };
-        //        }
-        //        if (maint.IsLeader!=1)//濡傛灉璇ョ敤鎴蜂笉鏄彮闀匡紝閭d箞瑕佺瓑鐝暱鍏堝仛锛屼粬鎵嶅彲浠ュ仛
-        //        {
-        //            bool leaderStarted = user.Any(x =>x.Roleid == maint.Roleid &&x.IsLeader == 1 &&x.MaintenanceStatus == 1); //娌℃壘鍒拌偗瀹氭槸false
-        //            if (!leaderStarted)
-        //            {
-        //                return new WebResponseContent { Status = false, Message = "璇风瓑寰呯粍闀垮紑濮嬫淇�" };
-        //            }
-
-        //        }
-        //       //濡傛灉婊¤冻涓嬮潰鐨勬潯浠跺氨寮�濮�
-        //        maint.MaintenancStartTime = DateTime.Now;//璁板綍寮�濮嬫椂闂�
-        //        maint.MaintenanceStatus = 1;//鏇存敼鐘舵��
-        //        BaseDal.UpdateData(maint);
-        //        //鎻掑叆璁板綍琛�
-        //        var recording = new Dt_MaintenanceTeam  //娣诲姞璁板綍
-        //        {
-        //            OperatorName = sysuer.UserTrueName,
-        //            TeamName = sysuer.RoleName,
-        //            DistributionTime = DateTime.Now,
-        //            IPAddress= LocalIP,
-        //            //Creater = "admin",
-        //            //CreateDate = DateTime.Now,
-        //        };
-        //        _team.AddData(recording);
-
-        //        return new WebResponseContent { Status = true, Data = maint,Message="寮�濮嬫淇�" };
-        //    }
-        //    catch (Exception ex)
-        //    {
-        //        return new WebResponseContent { Status = false, Message = "閿欒淇℃伅锛�" + ex.Message };
-        //    }
-        //}
-
-
-        ///// <summary>
-        ///// 缁撴潫妫�淇�
-        ///// </summary>MaintenanceStatus 0浠h〃妫�淇畬鎴�  1浠h〃妫�淇腑
-        ///// <param name="account"></param>
-        ///// <returns></returns>
-        //public WebResponseContent StopMaintenanceTask(string account)
-        //{
-        //    try
-        //    {
-        //        var user = BaseDal.QueryData();//妫�淇〃
-        //        var maint = user.Where(x => x.UserAccount == account).FirstOrDefault();
-        //        var sysuer = _user.QueryData(x => x.UserName == account).FirstOrDefault();//鐢ㄦ埛琛�
-        //        if (maint == null || sysuer == null)
-        //        {
-        //            return new WebResponseContent { Status = false, Message = "娌℃湁鎵惧埌璇ョ敤鎴�" };
-        //        }
-        //        if (maint.IsLeader == 1)//濡傛灉璇ョ敤鎴锋槸鐝暱锛岄偅涔堣绛夊叏閮ㄤ汉閮芥淇畬鎴愶紝浠栨墠鍙互缁撴潫妫�淇�
-        //        {
-        //            //鍏堟煡鎵炬墍鏈夌敤鎴风殑缁勬槸閭d釜缁勭殑锛岀粍鍛樼姸鎬佹湁涓�涓笉鏄�1               
-        //            // 鏌ユ壘鍚岀粍鏈畬鎴愮殑缁勫憳锛圛sLeader=0 && MaintenanceStatus=1锛�
-        //            bool hasUnfinishedMembers = user.Any(x =>x.Roleid == maint.Roleid && x.IsLeader == 0 &&
-        //                x.MaintenanceStatus == 1); //锛欰ny()鏈変竴涓弧瓒冲氨杩斿洖true琛ㄧず瀛樺湪婊¤冻鏉′欢鐨勮褰�
-        //            if (hasUnfinishedMembers)
-        //            {
-        //                return new WebResponseContent { Status = false, Message = "杩樻湁缁勫憳鏈畬鎴愬綋鍓嶆壒娆℃淇�" };
-        //            }
-        //        }
-        //        //濡傛灉婊¤冻涓嬮潰鐨勬潯浠跺氨寮�濮�
-        //        maint.MaintenancEendTime = DateTime.Now;//璁板綍缁撴潫鏃堕棿
-        //        maint.MaintenanceStatus = 0;//鏇存敼鐘舵��
-        //        BaseDal.UpdateData(maint);
-        //        ////鎻掑叆璁板綍琛�
-        //        //var recording = new Dt_MaintenanceTeam  //娣诲姞璁板綍
-        //        //{
-        //        //    OperatorName = sysuer.UserTrueName,
-        //        //    TeamName = sysuer.RoleName,
-        //        //    DistributionTime = DateTime.Now,
-        //        //    EndTime=DateTime.Now,
-        //        //};
-        //        //_team.AddData(recording);
-
-        //        return new WebResponseContent { Status = true, Data = maint, Message = "瀹屾垚妫�淇�" };
-        //    }
-        //    catch (Exception ex)
-        //    {
-        //        return new WebResponseContent { Status = false, Message = "閿欒淇℃伅锛�" + ex.Message };
-        //    }
-        //}
-
-
         /// <summary>
         /// 寮�濮嬫淇�
         /// </summary>
@@ -639,12 +540,14 @@
                     }
 
                 }
+               
+                var ip = LocalIP?.Replace("::ffff:", "") ?? ""; // 濡傛灉 LocalIP 鏄� null锛宨p 浼氭槸 ""
                 //濡傛灉婊¤冻涓嬮潰鐨勬潯浠跺氨寮�濮�
                 maint.MaintenancStartTime = DateTime.Now;//璁板綍寮�濮嬫椂闂�
                 maint.MaintenanceStatus = 1;//鏇存敼鐘舵��
-                maint.IPAddress = LocalIP;//鏇存敼ip鍦板潃
+                maint.IPAddress = ip;//鏇存敼ip鍦板潃
                 BaseDal.UpdateData(maint);
-                var address = _ipaddress.QueryData(x=>x.IPaddress== LocalIP).FirstOrDefault();
+                var address = _ipaddress.QueryData(x=>x.IPaddress== ip).FirstOrDefault();
                 var addressIp = "";
                 if (address!=null) //鎵惧埌浜�
                 {
@@ -652,7 +555,7 @@
                 }
                 else
                 {
-                    addressIp = LocalIP;
+                    addressIp = ip;
                 }
                 //鎻掑叆璁板綍琛�
                 var recording = new Dt_MaintenanceTeam  //娣诲姞璁板綍
@@ -660,7 +563,7 @@
                     Account = account,
                     MaintenanceStatus=1,
                     OperatorName = sysuer.UserTrueName,
-                    TeamName = sysuer.RoleName,
+                    TeamName = sysuer.Userteam,
                     DistributionTime = DateTime.Now,
                     IPAddress = addressIp,
                 };
@@ -718,7 +621,7 @@
                             return new WebResponseContent
                             {
                                 Status = false,
-                                Message = "鎮ㄦ槸鏈�鍚庝竴涓湪鍦虹殑缁勯暱锛岃绛夊緟鎵�鏈夌粍鍛樺畬鎴愭淇悗鍐嶇粨鏉�"
+                                Message = "鎮ㄦ槸鏈�鍚庝竴涓湪鍦虹殑涓�绾т汉鍛橈紝璇风瓑寰呮墍鏈変簩绾т汉鍛樺畬鎴愭淇悗鍐嶇粨鏉�"
                             };
                         }
                     }
@@ -727,7 +630,8 @@
                 //{
                 //    return new WebResponseContent { Status = false, Message = "鎿嶄綔璁惧涓嶅悓锛岃鍥炲埌鍘熸湰璁惧鍐嶇偣鍑荤粨鏉熸淇�" };
                 //}
-                var address = _ipaddress.QueryData(x => x.IPaddress == LocalIP).FirstOrDefault();
+                var ip = LocalIP?.Replace("::ffff:", "") ?? ""; // 濡傛灉 LocalIP 鏄� null锛宨p 浼氭槸 ""
+                var address = _ipaddress.QueryData(x => x.IPaddress == ip).FirstOrDefault();
                 var addressIp = "";
                 if (address != null) //鎵惧埌浜�
                 {
@@ -735,7 +639,7 @@
                 }
                 else
                 {
-                    addressIp = LocalIP;
+                    addressIp = ip;
                 }
 
                 // 鏇存柊褰撳墠鐢ㄦ埛鐨勬淇姸鎬�
@@ -749,7 +653,7 @@
                     Account = account,
                     MaintenanceStatus = 0,
                     OperatorName = sysuer.UserTrueName,
-                    TeamName = sysuer.RoleName,
+                    TeamName = sysuer.Userteam,
                     IPAddress = addressIp,
                     EndTime = DateTime.Now,
                 };

--
Gitblit v1.9.3