本次提交为物料库存管理模块增加了出入库单据的创建接口(入库单、出库单),并补充了物料及出入库类型下拉选项接口。新增了相关DTO数据结构,服务接口与实现,完善了库存变更的业务流程,所有操作均支持事务控制,提升了数据一致性和系统健壮性。
183 lines
5.4 KiB
C#
183 lines
5.4 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
||
using DOAN.Model.BZFM.Dto;
|
||
using DOAN.Model.BZFM;
|
||
using DOAN.Service.BZFM.IBZFMService;
|
||
using DOAN.Admin.WebApi.Filters;
|
||
|
||
//创建时间: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("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;
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
} |