diff --git a/WarehouseMgr/Tnb.WarehouseMgr/ExcelDataImportManager.cs b/WarehouseMgr/Tnb.WarehouseMgr/ExcelDataImportManager.cs
deleted file mode 100644
index 062cc44a..00000000
--- a/WarehouseMgr/Tnb.WarehouseMgr/ExcelDataImportManager.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using JNPF.FriendlyException;
-using Microsoft.AspNetCore.Http;
-using NPOI.HSSF.UserModel;
-using NPOI.SS.UserModel;
-using NPOI.XSSF.UserModel;
-
-namespace Tnb.WarehouseMgr
-{
- public class ExcelDataImportManager : BaseWareHouseService
- {
- ///
- /// 解析Excel到内存
- ///
- ///
- ///
- protected Task>> ImportExcelToMemory(IFormFile file)
- {
- int rowIndex = 1;
- List>? dics = new();
- IWorkbook? workbook = null;
- try
- {
- using (Stream stream = file.OpenReadStream())
- {
- // 2007版本
- if (file.Name.IndexOf(".xlsx") > 0)
- {
- workbook = new XSSFWorkbook(stream);
- }
- else if (file.Name.IndexOf(".xls") > 0)
- {
- workbook = new HSSFWorkbook(stream);
- }
-
- ISheet? sheet = workbook?.GetSheetAt(0);
- if (workbook == null || sheet == null) throw Oops.Bah("无导入数据");
- if (sheet?.LastRowNum <= 1) throw Oops.Bah("无导入数据");
-
- ICellStyle style = workbook.CreateCellStyle();
- IFont font = workbook.CreateFont();
- font.Color = IndexedColors.Black.Index; // 将字体颜色设置为黑色
- style.SetFont(font);
- var nameRow = sheet?.GetRow(0);
- if (nameRow != null)
- {
- Dictionary dic = new Dictionary();
- List columns = new List();
- columns = nameRow.Cells.Select(x => x.StringCellValue).ToList();
- columns.ForEach(x =>
- {
- var strings = x.Split(new char[2] { '(', ')' }, StringSplitOptions.RemoveEmptyEntries);
- x = strings[1];
- });
- if (columns?.Count > 0)
- {
- for (rowIndex = 1; rowIndex <= sheet?.LastRowNum; rowIndex++)
- {
- var row = sheet?.GetRow(rowIndex);
- if (row != null)
- {
- foreach (var col in columns)
- {
- ICell cell = row.GetCell(columns.IndexOf(col));
- dic.Add(col, cell.StringCellValue);
- }
- dics.Add(dic);
- }
- }
- if (dics == null) throw new AppFriendlyException("输入的数据为空", 500);
- }
- }
- }
- }
- catch (Exception)
- {
- //return Task.FromResult(dics);
- throw;
- }
- return Task.FromResult(dics);
- }
-
- public async Task GenImportTemplate(params string[] fields)
- {
- return null;
- }
- }
-}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs
index 9e529e65..2e8fd185 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs
@@ -37,6 +37,7 @@ using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Entities.Dto.Outputs;
using Tnb.WarehouseMgr.Entities.Enums;
+using Tnb.WarehouseMgr.Entities.Exceptions;
using Tnb.WarehouseMgr.Interfaces;
namespace Tnb.WarehouseMgr
@@ -164,8 +165,15 @@ namespace Tnb.WarehouseMgr
{
JNPF.Logging.Log.Error("齐套出库,新增时出现错误", ex);
await curDb.Ado.RollbackTranAsync();
+ TimedTaskErrorInfo ei = new()
+ {
+ RequestURL = App.HttpContext?.Request?.Path,
+ RequestMethod = App.HttpContext?.Request?.Method,
+ userIdentity = curUser,
+ };
+ var timedTaskEx = ex.ToTimedTaskException(ei);
cts?.Cancel();
- throw;
+ throw timedTaskEx;
}
}
///
@@ -265,8 +273,15 @@ namespace Tnb.WarehouseMgr
catch (Exception ex)
{
JNPF.Logging.Log.Error("齐套出库,待配送时出现错误", ex);
+ TimedTaskErrorInfo ei = new()
+ {
+ RequestURL = App.HttpContext?.Request?.Path,
+ RequestMethod = App.HttpContext?.Request?.Method,
+ userIdentity = curUser,
+ };
+ var timedTaskEx = ex.ToTimedTaskException(ei);
cts?.Cancel();
- throw;
+ throw timedTaskEx;
}
}