From e30bbb9765e5fa3840dd28a0cb699058b5d64877 Mon Sep 17 00:00:00 2001 From: gwbvipvip Date: Sat, 17 Aug 2024 09:30:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8B=E8=BD=BD=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=9B=BE=E7=89=87=E8=B7=AF=E5=BE=84=E4=B8=8D=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E9=97=AE=E9=A2=9820240817?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataBase/Services/GoodsService.cs | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs index 83cd4d0..db37bfa 100644 --- a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs +++ b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs @@ -2525,7 +2525,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services dataRow.CreateCell(3).SetCellValue(goodInfo.Price.ToString()); dataRow.CreateCell(4).SetCellValue(goodInfo.IsWeigh ? "是" : "否"); dataRow.CreateCell(5).SetCellValue(goodInfo.Descritption); - if (!string.IsNullOrWhiteSpace(goodInfo.ImgUrl)) + if (!string.IsNullOrWhiteSpace(goodInfo.ImgUrl) && goodInfo.ImgUrl.Contains("http")) await InsertImage(goodSheet, goodInfo.ImgUrl, 1, 6); var actions = actionList.Where(t => t.GoodsId == goodInfo.Id && t.DeviceId == exportDto.DeviceId).OrderBy(a => a.Order).ThenBy(b => b.Sort).GroupBy(c => c.GoodsAttributeId); foreach (var action in actions) @@ -2686,25 +2686,25 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services HttpResponseMessage response = await client.GetAsync(imagePath); if (response.IsSuccessStatusCode) { - if (response.IsSuccessStatusCode) - { - using HttpContent content = response.Content; - imageData = await content.ReadAsByteArrayAsync(); - } - else - { - imageData = null; - } + using HttpContent content = response.Content; + imageData = await content.ReadAsByteArrayAsync(); + } + else + { + imageData = null; + } + if (imageData != null) + { + // 添加图片到工作表 + int pictureIdx = sheet.Workbook.AddPicture(imageData, PictureType.JPEG); + // 创建图片位置 + IDrawing patriarch = sheet.CreateDrawingPatriarch(); + XSSFClientAnchor anchor = new(0, 0, 0, 0, columnIndex, rowIndex, columnIndex + 1, rowIndex + 1); + anchor.AnchorType = AnchorType.MoveAndResize; + IPicture picture = patriarch.CreatePicture(anchor, pictureIdx); + // 自动调整图片大小 + //picture.Resize(); } - // 添加图片到工作表 - int pictureIdx = sheet.Workbook.AddPicture(imageData, PictureType.JPEG); - // 创建图片位置 - IDrawing patriarch = sheet.CreateDrawingPatriarch(); - XSSFClientAnchor anchor = new(0, 0, 0, 0, columnIndex, rowIndex, columnIndex + 1, rowIndex + 1); - anchor.AnchorType = AnchorType.MoveAndResize; - IPicture picture = patriarch.CreatePicture(anchor, pictureIdx); - // 自动调整图片大小 - //picture.Resize(); } public static async Task DownloadRemoteFile(string url, string tempFolder, string fileName)