Browse Source

修复下载商品图片路径不正确问题20240817

ingredientmanage
gwbvipvip 4 months ago
parent
commit
e30bbb9765
1 changed files with 19 additions and 19 deletions
  1. +19
    -19
      BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs

+ 19
- 19
BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs View File

@@ -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)


Loading…
Cancel
Save