Explorar o código

工资计算 PersonnelModuleController 增加耗时

leiy hai 1 ano
pai
achega
51895f8dad
Modificáronse 1 ficheiros con 10 adicións e 13 borrados
  1. 10 13
      OASystem/OASystem.Api/Controllers/PersonnelModuleController.cs

+ 10 - 13
OASystem/OASystem.Api/Controllers/PersonnelModuleController.cs

@@ -14,6 +14,7 @@ using OASystem.Infrastructure.Repositories.PersonnelModule;
 using SqlSugar;
 using StackExchange.Redis;
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.Globalization;
 
 namespace OASystem.API.Controllers
@@ -217,7 +218,8 @@ namespace OASystem.API.Controllers
         public async Task<IActionResult> SalaryCalculatorAsync(SalaryCalculatorDto dto)
         {
             Result result = new Result();
-
+            Stopwatch sw = new Stopwatch();
+            sw.Start();
             //参数处理
             string ymFormat = "yyyy-MM";
             DateTime yearMonthDt;
@@ -294,7 +296,8 @@ namespace OASystem.API.Controllers
                     ).ToList();
             #endregion
 
-            return Ok(JsonView(true,"操作成功!", wageSheetItems));
+            sw.Stop();
+            return Ok(JsonView(true, "操作成功! 耗时:" + sw.ElapsedMilliseconds + "ms", wageSheetItems));
         }
 
 
@@ -307,11 +310,8 @@ namespace OASystem.API.Controllers
         public async Task<IActionResult> SalaryCalculatorSingleAsync(SalaryCalculatorSingleDto dto)
         {
             Result result = new Result();
-
-            try
-            {
-
-           
+            Stopwatch sw = new Stopwatch();
+            sw.Start();
 
             //参数处理
             string ymFormat = "yyyy-MM";
@@ -373,13 +373,10 @@ namespace OASystem.API.Controllers
                 }
             ).ToList();
                 #endregion
-                return Ok(JsonView(true, "操作成功!", wageSheetItems[0]));
-            }
-            catch (Exception ex)
-            {
-                return Ok(JsonView(false, ex.Message));
-            }
 
+            sw.Stop();
+                return Ok(JsonView(true, "操作成功!耗时:"+ sw.ElapsedMilliseconds +"ms", wageSheetItems[0]));
+           
             
         }
         #endregion