diff --git a/ZR.Admin.WebApi/Controllers/CommonController.cs b/ZR.Admin.WebApi/Controllers/CommonController.cs
index c3b11e7..daede30 100644
--- a/ZR.Admin.WebApi/Controllers/CommonController.cs
+++ b/ZR.Admin.WebApi/Controllers/CommonController.cs
@@ -491,5 +491,119 @@ namespace ZR.Admin.WebApi.Controllers
}
}
}
+
+ ///
+ /// 获取workfiles文件夹大小信息
+ ///
+ ///
+ [HttpGet]
+ [Route("/getWorkfilesSize")]
+ [AllowAnonymous]
+ public IActionResult GetWorkfilesSize()
+ {
+ try
+ {
+ var workfilesPath = Path.Combine(WebHostEnvironment.WebRootPath, "workfiles");
+
+ if (!Directory.Exists(workfilesPath))
+ {
+ return ToResponse(ResultCode.FAIL, "workfiles文件夹不存在");
+ }
+
+ var result = new
+ {
+ TotalSize = GetDirectorySize(workfilesPath),
+ TotalSizeFormatted = FormatFileSize(GetDirectorySize(workfilesPath)),
+ DailyFolders = GetDailyFoldersSize(workfilesPath)
+ };
+
+ return SUCCESS(result);
+ }
+ catch (Exception ex)
+ {
+ logger.Error(ex, "获取workfiles文件夹大小信息失败");
+ return ToResponse(ResultCode.FAIL, "获取文件夹大小信息失败");
+ }
+ }
+
+ ///
+ /// 计算目录大小
+ ///
+ /// 目录路径
+ /// 目录大小(字节)
+ private long GetDirectorySize(string directoryPath)
+ {
+ long size = 0;
+ try
+ {
+ var directory = new DirectoryInfo(directoryPath);
+ var files = directory.GetFiles("*", SearchOption.AllDirectories);
+ size = files.Sum(file => file.Length);
+ }
+ catch (Exception ex)
+ {
+ logger.Error(ex, $"计算目录大小失败: {directoryPath}");
+ }
+ return size;
+ }
+
+ ///
+ /// 格式化文件大小
+ ///
+ /// 字节数
+ /// 格式化后的大小字符串
+ private string FormatFileSize(long bytes)
+ {
+ string[] sizes = { "B", "KB", "MB", "GB", "TB" };
+ double len = bytes;
+ int order = 0;
+ while (len >= 1024 && order < sizes.Length - 1)
+ {
+ order++;
+ len = len / 1024;
+ }
+ return $"{len:0.##} {sizes[order]}";
+ }
+
+ ///
+ /// 获取每日文件夹大小信息
+ ///
+ /// workfiles路径
+ /// 每日文件夹大小信息列表
+ private List