From ed05efdc17aab076146b134ebe105b6382f221d7 Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期四, 10 七月 2025 10:09:29 +0800
Subject: [PATCH] 格式化代码

---
 MES.Service/service/BasicData/MesStaffManager.cs |   86 +++++++++++++++++++------------------------
 1 files changed, 38 insertions(+), 48 deletions(-)

diff --git a/MES.Service/service/BasicData/MesStaffManager.cs b/MES.Service/service/BasicData/MesStaffManager.cs
index 9f05723..7f37ec4 100644
--- a/MES.Service/service/BasicData/MesStaffManager.cs
+++ b/MES.Service/service/BasicData/MesStaffManager.cs
@@ -43,49 +43,42 @@
     }
 
     // 鏇存柊鍛樺伐鐘舵�佺殑鏂规硶
-    private bool UpdateStaffStatus(SqlSugarScope db, decimal staffId,string status)
+    private bool UpdateStaffStatus(SqlSugarScope db, decimal staffId,
+        string status)
     {
-        var result = db.Updateable<MesStaff>().SetColumns(s => s.FforbidStatus == status).Where(s => s.Id == staffId).ExecuteCommand();
+        var result = db.Updateable<MesStaff>()
+            .SetColumns(s => s.FforbidStatus == status)
+            .Where(s => s.Id == staffId).ExecuteCommand();
 
-        if (result > 0)
-        {
-            return true;
-        }
+        if (result > 0) return true;
         throw new NotImplementedException(status == "A" ? "鍚敤澶辫触" : "绂佺敤澶辫触");
     }
 
     // 鎻掑叆鎴栨洿鏂板憳宸ョ殑鏂规硶
-    private bool InsertOrUpdateStaff(SqlSugarScope db,MesStaff entity)
+    private bool InsertOrUpdateStaff(SqlSugarScope db, MesStaff entity)
     {
-        var exists = db.Queryable<MesStaff>().Any(u => u.StaffNo == entity.StaffNo);
+        var exists = db.Queryable<MesStaff>()
+            .Any(u => u.StaffNo == entity.StaffNo);
         if (exists)
         {
             var updateStaff = db.Updateable(entity).ExecuteCommand();
-            if (updateStaff > 0)
-            {
-                return true;
-            }
+            if (updateStaff > 0) return true;
         }
         else
         {
             var insertStaff = db.Insertable(entity).ExecuteCommand();
-            if (insertStaff > 0)
-            {
-                return true;
-            }
+            if (insertStaff > 0) return true;
         }
 
         return false;
     }
 
     // 鍒犻櫎鍛樺伐鐨勬柟娉�
-    private bool DeleteStaff(SqlSugarScope db,decimal staffId)
+    private bool DeleteStaff(SqlSugarScope db, decimal staffId)
     {
-        var deleteStaff =db.Deleteable<MesStaff>().In(staffId).ExecuteCommand();
-        if (deleteStaff > 0)
-        {
-            return true;
-        }
+        var deleteStaff =
+            db.Deleteable<MesStaff>().In(staffId).ExecuteCommand();
+        if (deleteStaff > 0) return true;
 
         throw new NotImplementedException("鍙嶅鏍稿け璐�");
     }
@@ -109,9 +102,8 @@
         };
 
         if (staff.FStaffStartDate != null)
-        {
-            entity.StartDate = DateTime.ParseExact(staff.FStaffStartDate, "yyyy-MM-dd HH:mm:ss", null);
-        }
+            entity.StartDate = DateTime.ParseExact(staff.FStaffStartDate,
+                "yyyy-MM-dd HH:mm:ss", null);
 
         return entity;
     }
@@ -126,37 +118,41 @@
             var entity = GetMesStaff(s);
             entity.Type = s.Type;
             list.Add(entity);
-
         });
 
-        var groupBy = list.GroupBy(s => s.Type).ToDictionary(g => g.Key, g => g.ToList());
+        var groupBy = list.GroupBy(s => s.Type)
+            .ToDictionary(g => g.Key, g => g.ToList());
         return UseTransaction(db =>
         {
             foreach (var staffGroup in groupBy)
                 switch (staffGroup.Key)
                 {
                     case "0":
-                        if (!UpdateStaffStatusBatch(db, staffGroup.Value,"A")) // 鎵归噺鍚敤鍛樺伐
+                        if (!UpdateStaffStatusBatch(db, staffGroup.Value,
+                                "A")) // 鎵归噺鍚敤鍛樺伐
                             throw new NotImplementedException("鍚敤澶辫触");
                         break;
                     case "1":
-                        if (!UpdateStaffStatusBatch(db, staffGroup.Value,"B")) // 鎵归噺绂佺敤鍛樺伐
+                        if (!UpdateStaffStatusBatch(db, staffGroup.Value,
+                                "B")) // 鎵归噺绂佺敤鍛樺伐
                             throw new NotImplementedException("绂佺敤澶辫触");
                         break;
                     case "2":
-                        if (!InsertStaffBatch(db,staffGroup.Value)) // 鎵归噺鎻掑叆鍛樺伐
+                        if (!InsertStaffBatch(db, staffGroup.Value)) // 鎵归噺鎻掑叆鍛樺伐
                             throw new NotImplementedException("鎻掑叆澶辫触");
                         break;
                     case "3":
-                        if (!DeleteStaffBatch(db,staffGroup.Value)) // 鎵归噺鍒犻櫎鍛樺伐
+                        if (!DeleteStaffBatch(db, staffGroup.Value)) // 鎵归噺鍒犻櫎鍛樺伐
                             throw new NotImplementedException("鍒犻櫎澶辫触");
                         break;
                     case "4":
-                        if (!InsertOrUpdateBatch(db,staffGroup.Value)) // 鎵归噺鎻掑叆鎴栨洿鏂板憳宸�
+                        if (!InsertOrUpdateBatch(db,
+                                staffGroup.Value)) // 鎵归噺鎻掑叆鎴栨洿鏂板憳宸�
                             throw new NotImplementedException("鍚屾澶辫触");
                         break;
                     default:
-                        throw new ArgumentNullException($"type娌℃湁{staffGroup.Key}杩欎釜绫诲瀷鐨勫弬鏁�");
+                        throw new ArgumentNullException(
+                            $"type娌℃湁{staffGroup.Key}杩欎釜绫诲瀷鐨勫弬鏁�");
                 }
 
             return 1;
@@ -164,21 +160,21 @@
     }
 
     // 鎵归噺鏇存柊鍛樺伐鐘舵�佺殑鏂规硶
-    private bool UpdateStaffStatusBatch(SqlSugarScope db,List<MesStaff> staffList, string status)
+    private bool UpdateStaffStatusBatch(SqlSugarScope db,
+        List<MesStaff> staffList, string status)
     {
         var ids = staffList.Select(it => it.Id).ToArray();
-        var result = db.Updateable<MesStaff>().SetColumns(s => s.FforbidStatus == status).Where(s => ids.Contains(s.Id)).ExecuteCommand();
+        var result = db.Updateable<MesStaff>()
+            .SetColumns(s => s.FforbidStatus == status)
+            .Where(s => ids.Contains(s.Id)).ExecuteCommand();
 
-        if (result > 0)
-        {
-            return true;
-        }
+        if (result > 0) return true;
 
         throw new NotImplementedException(status == "A" ? "鍚敤澶辫触" : "绂佺敤澶辫触");
     }
 
     // 鎵归噺鎻掑叆鍛樺伐鐨勬柟娉�
-    private bool InsertStaffBatch(SqlSugarScope db,List<MesStaff> staffList)
+    private bool InsertStaffBatch(SqlSugarScope db, List<MesStaff> staffList)
     {
         var userInsert = staffList.FindAll(s => s.Type == "INSERT");
         var executeCommand = db.Insertable(userInsert).ExecuteCommand();
@@ -193,10 +189,7 @@
     private bool DeleteStaffBatch(SqlSugarScope db, List<MesStaff> staffList)
     {
         var ids = staffList.Select(it => it.Id).ToArray();
-        if (db.Deleteable<MesStaff>().In(ids).ExecuteCommand() > 0)
-        {
-            return true;
-        }
+        if (db.Deleteable<MesStaff>().In(ids).ExecuteCommand() > 0) return true;
 
         throw new ArgumentNullException("鍙嶅鏍稿け璐�");
     }
@@ -207,10 +200,7 @@
         foreach (var staff in staffList)
         {
             var entity = staffList.First(s => s.StaffNo == staff.StaffNo);
-            if (!InsertOrUpdateStaff(db, entity))
-            {
-                return false;
-            }
+            if (!InsertOrUpdateStaff(db, entity)) return false;
         }
 
         return true;

--
Gitblit v1.9.3