出入库功能模块
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
using DOAN.Admin.WebApi.Filters;
|
||||
using DOAN.Model;
|
||||
using DOAN.Model.BZFM;
|
||||
using DOAN.Model.BZFM.Dto;
|
||||
using DOAN.Model.System;
|
||||
using DOAN.Model.System.Dto;
|
||||
using DOAN.Service.BZFM;
|
||||
using DOAN.Service.BZFM.IBZFMService;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MiniExcelLibs;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
//创建时间:2025-12-25
|
||||
namespace DOAN.Admin.WebApi.Controllers.BZFM
|
||||
@@ -123,13 +127,65 @@ namespace DOAN.Admin.WebApi.Controllers.BZFM
|
||||
[ActionPermissionFilter(Permission = "mmmaterial:import")]
|
||||
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile)
|
||||
{
|
||||
List<MmMaterialQueryDto> material = new();
|
||||
List<MmMaterial> material = new();
|
||||
using (var stream = formFile.OpenReadStream())
|
||||
{
|
||||
material = stream.Query<MmMaterialQueryDto>(startCell: "A2").ToList();
|
||||
material = stream.Query<MmMaterial>(startCell: "A2").ToList();
|
||||
}
|
||||
|
||||
return SUCCESS(_MmMaterialService.Importmaterial(material));
|
||||
}
|
||||
|
||||
/// <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<MmMaterialQueryDto>();
|
||||
var result = DownloadImportTemplate(sample, "material");
|
||||
return ExportExcel(result.Item2, result.Item1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户导出
|
||||
/// </summary>
|
||||
/// <param name="material"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("export")]
|
||||
[Log(Title = "物料清单导出", BusinessType = BusinessType.EXPORT)]
|
||||
[ActionPermissionFilter(Permission = "mmmaterial:export")]
|
||||
public IActionResult MaterialExport([FromQuery] MmMaterialQueryDto material)
|
||||
{
|
||||
var list = _MmMaterialService.SelectMaterialList(material, new PagerInfo(1, 10000));
|
||||
|
||||
var data = (list?.Result ?? new List<MmMaterial>());
|
||||
|
||||
// Build list of dictionaries to control column titles and format dates
|
||||
var exportList = data.Select(x => new Dictionary<string, object>
|
||||
{
|
||||
["物料编码"] = x.MaterialCode,
|
||||
["物料名称"] = x.MaterialName,
|
||||
["规格"] = x.Specification,
|
||||
["物料分类编码"] = x.CategoryCode,
|
||||
["物料分类名称"] = x.CategoryName,
|
||||
["计量单位"] = x.Unit,
|
||||
["物料类型"] = x.Type,
|
||||
["供应商编码"] = x.SupplierCode,
|
||||
["供应商名称"] = x.SupplierName,
|
||||
["安全库存"] = x.SafetyStock,
|
||||
["状态"] = x.Status,
|
||||
["创建时间"] = x.CreatedTime.HasValue ? x.CreatedTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : string.Empty,
|
||||
["更新时间"] = x.UpdatedTime.HasValue ? x.UpdatedTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : string.Empty,
|
||||
["描述"] = x.Description
|
||||
}).ToList();
|
||||
|
||||
var result = ExportExcelMini(exportList, "material", "物料清单");
|
||||
return ExportExcel(result.Item2, result.Item1);
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
DOAN.Admin.WebApi/wwwroot/ImportTemplate/material.xlsx
Normal file
BIN
DOAN.Admin.WebApi/wwwroot/ImportTemplate/material.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user