!提交代码
This commit is contained in:
104
WCS.WebApi/Controllers/MatBaseInfoController.cs
Normal file
104
WCS.WebApi/Controllers/MatBaseInfoController.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MiniExcelLibs;
|
||||
using NPOI.SS.UserModel;
|
||||
using SqlSugar;
|
||||
using System.Xml.Linq;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Services.Service;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
using WCS.WebApi.Helper;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 接口记录
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class MatBaseInfoController : ControllerBase
|
||||
{
|
||||
public IMatBaseInfoService _matBaseInfoService { get; set; }
|
||||
|
||||
public MatBaseInfoController(IMatBaseInfoService matBaseInfoService)
|
||||
{
|
||||
_matBaseInfoService = matBaseInfoService;
|
||||
}
|
||||
|
||||
[Route("getMatBaseInfo")]
|
||||
[HttpPost(Name = "getMatBaseInfo")]
|
||||
public async Task<ResponseBase> getMatBaseInfo(GetMatBaseInfoRequest request)
|
||||
{
|
||||
return await _matBaseInfoService.getMatBaseInfo(request);
|
||||
}
|
||||
|
||||
[HttpPost("exportMatBaseInfo")]
|
||||
public async Task<IActionResult> exportMatBaseInfo(GetMatBaseInfoRequest request)
|
||||
{
|
||||
var result = await _matBaseInfoService.exportMatBaseInfo(request);
|
||||
var data = result.Data?.Lists;
|
||||
var columns = new[]
|
||||
{
|
||||
new ExportableColumn("序号","RowNumber"),
|
||||
new ExportableColumn("物料编码","MatCode"),
|
||||
new ExportableColumn("名称","MatName"),
|
||||
new ExportableColumn("规格","MatSpec"),
|
||||
new ExportableColumn("单位","MatUnit"),
|
||||
new ExportableColumn("客户","MatCustomer"),
|
||||
new ExportableColumn("状态","IsEnableStr"),
|
||||
new ExportableColumn("更新人","ModifyUser"),
|
||||
new ExportableColumn("更新时间", "ModifyTime"),
|
||||
};
|
||||
if (data == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
else
|
||||
return ExportExcelHelper.Export("导出数据", columns, data);
|
||||
}
|
||||
|
||||
[HttpPost("importMatBaseInfo")]
|
||||
public async Task<ResponseBase> importMatBaseInfo([FromForm] IFormFile excelFile, [FromForm] string userName, [FromForm] string deviceType)
|
||||
{
|
||||
//文件校验
|
||||
if (excelFile == null || excelFile.Length == 0)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "导入失败:文件无有效内容!"
|
||||
};
|
||||
}
|
||||
//
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
await excelFile.CopyToAsync(stream);
|
||||
stream.Position = 0;
|
||||
var list = MiniExcelLibs.MiniExcel.Query<MatBaseInfoImportModel>(stream, "物料管理", ExcelType.XLSX).ToList();
|
||||
return await _matBaseInfoService.importMatBaseInfo(list, userName, deviceType);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("addOrUpdateMatBaseInfo")]
|
||||
public async Task<ResponseCommon<object>> addOrUpdateMatBaseInfo(AddMatBaseInfoRequest<MatBaseInfo> request)
|
||||
{
|
||||
return await _matBaseInfoService.addOrUpdateMatBaseInfo(request);
|
||||
}
|
||||
|
||||
[HttpPost("deleteMatBaseInfo")]
|
||||
public async Task<ResponseCommon<object>> deleteMatBaseInfo(DeleteMatBaseInfosRequest request)
|
||||
{
|
||||
return await _matBaseInfoService.deleteMatBaseInfo(request);
|
||||
}
|
||||
|
||||
[HttpPost("getMatCodeList")]
|
||||
public async Task<ResponseCommon<List<string>>> getMatCodeList(GetMatCodeListRequest request)
|
||||
{
|
||||
return await _matBaseInfoService.getMatCodeList(request);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user