Files
kunshan-bzfm-mes-backend/DOAN.Admin.WebApi/Controllers/MES/Material/productionMaterial/MmInventoryController.cs
2026-01-15 16:42:04 +08:00

293 lines
9.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
{
/// <summary>
/// 库存表
/// </summary>
[Verify]
[Route("mes/productionMaterial/MmInventory")]
public class MmInventoryController : BaseController
{
/// <summary>
/// 库存表接口
/// </summary>
private readonly IMmInventoryService _MmInventoryService;
public MmInventoryController(IMmInventoryService MmInventoryService)
{
_MmInventoryService = MmInventoryService;
}
/// <summary>
/// 查询库存表列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpGet("list")]
[ActionPermissionFilter(Permission = "mminventory:list")]
public IActionResult QueryMmInventory([FromQuery] MmInventoryQueryDto parm)
{
var response = _MmInventoryService.GetList(parm);
return SUCCESS(response);
}
/// <summary>
/// 查询库存表详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
[HttpGet("{Id}")]
[ActionPermissionFilter(Permission = "mminventory:query")]
public IActionResult GetMmInventory(int Id)
{
var response = _MmInventoryService.GetInfo(Id);
var info = response.Adapt<MmInventoryDto>();
return SUCCESS(info);
}
/// <summary>
/// 添加库存表
/// </summary>
/// <returns></returns>
[HttpPost]
[ActionPermissionFilter(Permission = "mminventory:add")]
[Log(Title = "添加库存表", BusinessType = BusinessType.INSERT)]
public IActionResult AddMmInventory([FromBody] MmInventoryDto parm)
{
var modal = parm.Adapt<MmInventory>().ToCreate(HttpContext);
var response = _MmInventoryService.AddMmInventory(modal);
return SUCCESS(response);
}
/// <summary>
/// 更新库存表
/// </summary>
/// <returns></returns>
[HttpPut]
[ActionPermissionFilter(Permission = "mminventory:edit")]
[Log(Title = "更新库存", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdateMmInventory([FromBody] MmInventoryDto parm)
{
var modal = parm.Adapt<MmInventory>().ToUpdate(HttpContext);
var response = _MmInventoryService.UpdateMmInventory(modal);
return ToResponse(response);
}
/// <summary>
/// 删除库存表
/// </summary>
/// <returns></returns>
[HttpPost("delete/{ids}")]
[ActionPermissionFilter(Permission = "mminventory:delete")]
[Log(Title = "删除库存", BusinessType = BusinessType.DELETE)]
public IActionResult DeleteMmInventory([FromRoute] string ids)
{
var idArr = Tools.SplitAndConvert<int>(ids);
return ToResponse(_MmInventoryService.Delete(idArr));
}
/// <summary>
/// 获取物料清单下拉数据
/// </summary>
/// <returns></returns>
[HttpPost("GetMaterialOption")]
public IActionResult GetMaterialOption()
{
var response = _MmInventoryService.GetMaterialOption();
return SUCCESS(response);
}
/// <summary>
/// 获取库位下拉数据
/// </summary>
/// <returns></returns>
[HttpPost("GetLocationOption")]
public IActionResult GetLocationOption()
{
var response = _MmInventoryService.GetLocationOption();
return SUCCESS(response);
}
/// <summary>
/// 获取出/入库操作类型下拉数据
/// </summary>
/// <returns></returns>
[HttpPost("GetTransactionOption")]
public IActionResult GetTransactionOption()
{
var response = _MmInventoryService.GetTransactionOption();
return SUCCESS(response);
}
/// <summary>
/// 创建入库单
/// </summary>
/// <returns></returns>
[HttpPost("CreateInboundReceipt")]
[AllowAnonymous]
[Log(Title = "创建入库单", BusinessType = BusinessType.INSERT)]
public IActionResult CreateInboundReceipt([FromBody] InboundReceiptDto parm)
{
try
{
string response = _MmInventoryService.CreateInboundReceipt(parm);
if (response == "ok")
{
return ToResponse(new ApiResult(200, "ok"));
}
else
{
return ToResponse(new ApiResult(500, response));
}
}
catch (Exception)
{
throw;
}
}
/// <summary>
/// 创建出库单
/// </summary>
/// <returns></returns>
[HttpPost("CreateOutboundReceipt")]
[AllowAnonymous]
[Log(Title = "创建出库单", BusinessType = BusinessType.INSERT)]
public IActionResult CreateOutboundReceipt([FromBody] OutboundReceiptDto parm)
{
try
{
string response = _MmInventoryService.CreateOutboundReceipt(parm);
if (response == "ok")
{
return ToResponse(new ApiResult(200, "ok"));
}
else
{
return ToResponse(new ApiResult(500, response));
}
}
catch (Exception)
{
throw;
}
}
/// <summary>
/// 撤销单据
/// </summary>
/// <returns></returns>
[HttpPost("RevokeReceipt")]
[AllowAnonymous]
[Log(Title = "撤销单据", BusinessType = BusinessType.INSERT)]
public IActionResult RevokeReceipt([FromBody] MmInventoryRevokeDto parm)
{
try
{
string response = _MmInventoryService.RevokeReceipt(parm);
if (response == "ok")
{
return ToResponse(new ApiResult(200, "ok"));
}
else
{
return ToResponse(new ApiResult(500, response));
}
}
catch (Exception)
{
throw;
}
}
/// <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);
}
/// <summary>
/// 获取出/入库记录数据
/// </summary>
/// <returns></returns>
[HttpPost("GetInOrOutRecord")]
public IActionResult GetInOrOutRecord([FromBody] MmInventoryRecordQueryDto parm)
{
var response = _MmInventoryService.GetInOrOutRecord(parm);
return SUCCESS(response);
}
}
}