抛光库导入

This commit is contained in:
2024-10-29 17:35:32 +08:00
parent 08b25e0633
commit eb97591d9c
7 changed files with 137 additions and 22 deletions

View File

@@ -1,9 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using MiniExcelLibs;
using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters;
using ZR.Model;
using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
using ZR.Model.System;
using ZR.Model.System.Dto;
using ZR.Service.mes.wms;
using ZR.Service.mes.wms.IService;
@@ -216,5 +218,38 @@ namespace ZR.Admin.WebApi.Controllers
var response = _WmPolishInventoryService.GetPartNumber();
return SUCCESS(response);
}
/// <summary>
/// 抛光导入模板下载
/// </summary>
/// <returns></returns>
[HttpGet("importTemplate")]
[Log(Title = "抛光模板", BusinessType = BusinessType.EXPORT, IsSaveRequestData = true, IsSaveResponseData = false)]
[AllowAnonymous]
public IActionResult ImportTemplateExcel()
{
(string, string) result = DownloadImportTemplate("抛光仓库盘点模板");
return ExportExcel(result.Item2, result.Item1);
}
/// <summary>
/// 导入
/// </summary>
/// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
/// <returns></returns>
[HttpPost("importData")]
[Log(Title = "抛光盘点导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)]
[AllowAnonymous]
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile)
{
List<WmPolishInventoryExportDto> importList = new();
using (var stream = formFile.OpenReadStream())
{
importList = stream.Query<WmPolishInventoryExportDto>(startCell: "A1").ToList();
}
return SUCCESS(_WmPolishInventoryService.ImportExcel(importList));
}
}
}