新增物料清单Excel导入功能及相关接口
新增物料清单批量导入接口,支持Excel文件上传,自动设置创建时间和状态,完善DTO字段。实现批量插入、校验物料编码、统计导入结果。补充相关依赖和命名空间。
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
using DOAN.Admin.WebApi.Filters;
|
||||
using DOAN.Model.BZFM;
|
||||
using DOAN.Model.BZFM.Dto;
|
||||
using DOAN.Model.System;
|
||||
using DOAN.Service.BZFM;
|
||||
using DOAN.Service.BZFM.IBZFMService;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MiniExcelLibs;
|
||||
|
||||
//创建时间:2025-12-25
|
||||
namespace DOAN.Admin.WebApi.Controllers.BZFM
|
||||
@@ -111,6 +113,23 @@ namespace DOAN.Admin.WebApi.Controllers.BZFM
|
||||
return SUCCESS(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导入
|
||||
/// </summary>
|
||||
/// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("importData")]
|
||||
[Log(Title = "物料清单导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)]
|
||||
[ActionPermissionFilter(Permission = "mmmaterial:import")]
|
||||
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile)
|
||||
{
|
||||
List<MmMaterialQueryDto> material = new();
|
||||
using (var stream = formFile.OpenReadStream())
|
||||
{
|
||||
material = stream.Query<MmMaterialQueryDto>(startCell: "A2").ToList();
|
||||
}
|
||||
|
||||
return SUCCESS(_MmMaterialService.Importmaterial(material));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user