入库记录导入导出

库存导入导出
This commit is contained in:
2026-01-09 10:53:37 +08:00
parent fdcb5b5200
commit 29ced372cb
9 changed files with 719 additions and 11 deletions

View File

@@ -1,8 +1,10 @@
using Microsoft.AspNetCore.Mvc;
using DOAN.Model.BZFM.Dto;
using DOAN.Model.BZFM;
using DOAN.Service.BZFM.IBZFMService;
using DOAN.Admin.WebApi.Filters;
using DOAN.Model;
using DOAN.Model.BZFM;
using DOAN.Model.BZFM.Dto;
using DOAN.Service.BZFM;
using DOAN.Service.BZFM.IBZFMService;
using Microsoft.AspNetCore.Mvc;
//创建时间2025-12-24
namespace DOAN.Admin.WebApi.Controllers.BZFM
@@ -190,5 +192,57 @@ namespace DOAN.Admin.WebApi.Controllers.BZFM
}
/// <summary>
/// 导入
/// </summary>
/// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
/// <returns></returns>
[HttpPost("importData")]
[Log(Title = "库存管理导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)]
[ActionPermissionFilter(Permission = "mminventory:import")]
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile)
{
//return SUCCESS(_MmMaterialService.Importmaterial(material));
if (formFile == null)
{
return SUCCESS(null);
}
ImportResultDto response = _MmInventoryService.ImportInventory(formFile, HttpContext.GetName());
return SUCCESS(response);
}
/// <summary>
/// 下载库存导入模板
/// </summary>
/// <returns></returns>
[HttpGet("importTemplate")]
[Log(Title = "库存模板", BusinessType = BusinessType.EXPORT)]
[AllowAnonymous]
public IActionResult ImportTemplateExcel()
{
// create an empty sample list of export DTO to generate header row
var sample = new List<MmInventoryExcelDto>();
var result = DownloadImportTemplate(sample, "inventory");
return ExportExcel(result.Item2, result.Item1);
}
/// <summary>
/// 库存导出
/// </summary>
/// <param name="inventory"></param>
/// <returns></returns>
[HttpGet("export")]
[Log(Title = "物料清单导出", BusinessType = BusinessType.EXPORT)]
[ActionPermissionFilter(Permission = "mminventory:export")]
public IActionResult MaterialExport([FromQuery] MmInventoryQueryDto inventory)
{
var list = _MmInventoryService.SelectInventoryList(inventory, new PagerInfo(1, 10000));
var data = (list?.Result ?? new List<MmInventoryExcelDto>());
var result = ExportExcelMini(data, "inventory", "库存管理");
return ExportExcel(result.Item2, result.Item1);
}
}
}

View File

@@ -1,8 +1,10 @@
using Microsoft.AspNetCore.Mvc;
using DOAN.Model.BZFM.Dto;
using DOAN.Model.BZFM;
using DOAN.Service.BZFM.IBZFMService;
using DOAN.Admin.WebApi.Filters;
using DOAN.Model;
using DOAN.Model.BZFM;
using DOAN.Model.BZFM.Dto;
using DOAN.Service.BZFM;
using DOAN.Service.BZFM.IBZFMService;
using Microsoft.AspNetCore.Mvc;
//创建时间2025-12-25
namespace DOAN.Admin.WebApi.Controllers.BZFM
@@ -98,5 +100,57 @@ namespace DOAN.Admin.WebApi.Controllers.BZFM
return ToResponse(_MmRecordInboundService.Delete(idArr));
}
/// <summary>
/// 导入
/// </summary>
/// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
/// <returns></returns>
[HttpPost("importData")]
[Log(Title = "入库记录导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)]
[ActionPermissionFilter(Permission = "mmrecordinbound:import")]
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile)
{
if (formFile == null)
{
return SUCCESS(null);
}
ImportResultDto response = _MmRecordInboundService.ImportRecordinbound(formFile, HttpContext.GetName());
return SUCCESS(response);
}
/// <summary>
/// 下载入库记录导入模板
/// </summary>
/// <returns></returns>
[HttpGet("importTemplate")]
[Log(Title = "入库记录模板", BusinessType = BusinessType.EXPORT)]
[AllowAnonymous]
public IActionResult ImportTemplateExcel()
{
// create an empty sample list of export DTO to generate header row
var sample = new List<MmRecordinboundExcelDto>();
var result = DownloadImportTemplate(sample, "recordinbound");
return ExportExcel(result.Item2, result.Item1);
}
/// <summary>
/// 入库记录导出
/// </summary>
/// <param name="recordinbound"></param>
/// <returns></returns>
[HttpGet("export")]
[Log(Title = "入库记录导出", BusinessType = BusinessType.EXPORT)]
[ActionPermissionFilter(Permission = "mmrecordinbound:export")]
public IActionResult MaterialExport([FromQuery] MmRecordInboundQueryDto recordinbound)
{
var list = _MmRecordInboundService.SelectRecordinboundList(recordinbound, new PagerInfo(1, 10000));
var data = (list?.Result ?? new List<MmRecordinboundExcelDto>());
var result = ExportExcelMini(data, "recordinbound", "入库记录");
return ExportExcel(result.Item2, result.Item1);
}
}
}