yuanrf 17 godzin temu
rodzic
commit
cac507bcfa
1 zmienionych plików z 47 dodań i 10 usunięć
  1. 47 10
      OASystem/OASystem.Api/Controllers/GroupsController.cs

+ 47 - 10
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -11913,7 +11913,7 @@ FROM
                         }
                         else dic.Add("SubZS", "0.00");
                         //删除多余行
-                        while (table1!=null && table1.Rows.Count > table1Row)
+                        while (table1 != null && table1.Rows.Count > table1Row)
                         {
                             table1.Rows.RemoveAt(table1Row);
                         }
@@ -32382,7 +32382,11 @@ ORDER BY
             return Ok(JsonView(true, $"成功删除 {deletedCount} 张图片", updatedImgs));
         }
 
-
+        /// <summary>
+        /// 会务流程word下载
+        /// </summary>
+        /// <param name="Dto"></param>
+        /// <returns></returns>
         [HttpPost]
         public async Task<IActionResult> InspectionReportFileDown(InspectionReportFileDownDto Dto)
         {
@@ -32408,7 +32412,7 @@ ORDER BY
             var doc = new Document(templatePath);
 
             var chiList = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
-                .Where(x => x.IsDel == 0 && x.Diid == Dto.Diid)
+                .Where(x => x.IsDel == 0 && x.Diid == Dto.Diid && x.PriceType > 0 && x.Unit > 0)
                 .Select(x => new
                 {
                     x.Index,
@@ -33030,15 +33034,48 @@ ORDER BY
             {
                 if (!string.IsNullOrEmpty(item.Imgs))
                 {
-                    var imgList = item.Imgs.Split(',');
-                    foreach (var img in imgList)
+                    var imgList = item.Imgs.Split(',').Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
+                    string baseUrl = AppSettingsHelper.Get("ConferenceCostImageBaseUrl");
+                    string basePath = AppSettingsHelper.Get("ConferenceCostImageBasePath");
+
+                    foreach (var imgUrl in imgList)
                     {
-                        //http路径转本地文件路径
-                        var localPath = img.Replace(AppSettingsHelper.Get("ConferenceCostImageBaseUrl"), AppSettingsHelper.Get("ConferenceCostImageBasePath"));
-                        if (System.IO.File.Exists(localPath))
+                        try
+                        {
+                            string localPath = "";
+
+                            // 判断是否为完整URL
+                            if (imgUrl.StartsWith("http://") || imgUrl.StartsWith("https://"))
+                            {
+                                // 尝试从URL转换为本地路径
+                                if (imgUrl.Contains("/child/"))
+                                {
+                                    var pathPart = imgUrl.Substring(imgUrl.IndexOf("/child/"));
+                                    localPath = Path.Combine(basePath, pathPart.TrimStart('/').Replace("/", "\\"));
+                                }
+                            }
+                            else
+                            {
+                                // 文件名,构造本地路径
+                                localPath = Path.Combine(basePath, "child", item.Index.ToString(), imgUrl);
+                            }
+
+                            if (!string.IsNullOrEmpty(localPath) && System.IO.File.Exists(localPath))
+                            {
+                                _logger.LogInformation($"-----------------------");
+                                _logger.LogInformation($"删除图片: {localPath}");
+                                System.IO.File.Delete(localPath);
+                                _logger.LogInformation($"删除成功");
+                                _logger.LogInformation($"-----------------------");
+                            }
+                            else
+                            {
+                                _logger.LogWarning($"图片文件不存在或路径为空: {imgUrl} -> {localPath}");
+                            }
+                        }
+                        catch (Exception ex)
                         {
-                            _logger.LogInformation($"删除图片: {localPath}");
-                            System.IO.File.Delete(localPath);
+                            _logger.LogError(ex, $"删除图片失败: {imgUrl}");
                         }
                     }
                 }