2026-01-09 10:53:37 +08:00
|
|
|
|
using DOAN.Admin.WebApi.Filters;
|
|
|
|
|
|
using DOAN.Model;
|
2025-12-24 19:09:42 +08:00
|
|
|
|
using DOAN.Model.BZFM;
|
2026-01-09 10:53:37 +08:00
|
|
|
|
using DOAN.Model.BZFM.Dto;
|
|
|
|
|
|
using DOAN.Service.BZFM;
|
2025-12-24 19:09:42 +08:00
|
|
|
|
using DOAN.Service.BZFM.IBZFMService;
|
2026-01-09 10:53:37 +08:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2025-12-24 19:09:42 +08:00
|
|
|
|
|
|
|
|
|
|
//创建时间:2025-12-24
|
|
|
|
|
|
namespace DOAN.Admin.WebApi.Controllers.BZFM
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 库存表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[Verify]
|
2025-12-25 14:27:40 +08:00
|
|
|
|
[Route("mes/productionMaterial/MmInventory")]
|
2025-12-24 19:09:42 +08:00
|
|
|
|
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);
|
2026-01-13 15:08:05 +08:00
|
|
|
|
|
2025-12-24 19:09:42 +08:00
|
|
|
|
var info = response.Adapt<MmInventoryDto>();
|
|
|
|
|
|
return SUCCESS(info);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加库存表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
|
[ActionPermissionFilter(Permission = "mminventory:add")]
|
2026-01-13 14:32:20 +08:00
|
|
|
|
[Log(Title = "添加库存表", BusinessType = BusinessType.INSERT)]
|
2025-12-24 19:09:42 +08:00
|
|
|
|
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")]
|
2026-01-13 14:32:20 +08:00
|
|
|
|
[Log(Title = "更新库存", BusinessType = BusinessType.UPDATE)]
|
2025-12-24 19:09:42 +08:00
|
|
|
|
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")]
|
2026-01-13 14:32:20 +08:00
|
|
|
|
[Log(Title = "删除库存", BusinessType = BusinessType.DELETE)]
|
2026-01-13 15:08:05 +08:00
|
|
|
|
public IActionResult DeleteMmInventory([FromRoute] string ids)
|
2025-12-24 19:09:42 +08:00
|
|
|
|
{
|
|
|
|
|
|
var idArr = Tools.SplitAndConvert<int>(ids);
|
|
|
|
|
|
|
|
|
|
|
|
return ToResponse(_MmInventoryService.Delete(idArr));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-29 11:43:25 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取物料清单下拉数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("GetMaterialOption")]
|
|
|
|
|
|
public IActionResult GetMaterialOption()
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = _MmInventoryService.GetMaterialOption();
|
|
|
|
|
|
|
2025-12-29 13:56:52 +08:00
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
2026-01-13 15:08:05 +08:00
|
|
|
|
|
2025-12-29 13:56:52 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取库位下拉数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("GetLocationOption")]
|
|
|
|
|
|
public IActionResult GetLocationOption()
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = _MmInventoryService.GetLocationOption();
|
|
|
|
|
|
|
2025-12-29 11:43:25 +08:00
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
2026-01-13 15:08:05 +08:00
|
|
|
|
|
2025-12-29 11:43:25 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取出/入库操作类型下拉数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("GetTransactionOption")]
|
|
|
|
|
|
public IActionResult GetTransactionOption()
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = _MmInventoryService.GetTransactionOption();
|
|
|
|
|
|
|
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 创建入库单
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("CreateInboundReceipt")]
|
|
|
|
|
|
[AllowAnonymous]
|
2026-01-15 16:42:04 +08:00
|
|
|
|
[Log(Title = "创建入库单", BusinessType = BusinessType.INSERT)]
|
2025-12-29 11:43:25 +08:00
|
|
|
|
public IActionResult CreateInboundReceipt([FromBody] InboundReceiptDto parm)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
string response = _MmInventoryService.CreateInboundReceipt(parm);
|
2026-01-13 15:08:05 +08:00
|
|
|
|
if (response == "ok")
|
2025-12-29 11:43:25 +08:00
|
|
|
|
{
|
|
|
|
|
|
return ToResponse(new ApiResult(200, "ok"));
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return ToResponse(new ApiResult(500, response));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 创建出库单
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("CreateOutboundReceipt")]
|
|
|
|
|
|
[AllowAnonymous]
|
2026-01-15 16:42:04 +08:00
|
|
|
|
[Log(Title = "创建出库单", BusinessType = BusinessType.INSERT)]
|
2025-12-29 11:43:25 +08:00
|
|
|
|
public IActionResult CreateOutboundReceipt([FromBody] OutboundReceiptDto parm)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
string response = _MmInventoryService.CreateOutboundReceipt(parm);
|
2026-01-15 16:42:04 +08:00
|
|
|
|
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);
|
2025-12-29 11:43:25 +08:00
|
|
|
|
if (response == "ok")
|
|
|
|
|
|
{
|
|
|
|
|
|
return ToResponse(new ApiResult(200, "ok"));
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return ToResponse(new ApiResult(500, response));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-09 10:53:37 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 导入
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("importData")]
|
2026-01-13 15:08:05 +08:00
|
|
|
|
[Log(
|
|
|
|
|
|
Title = "库存管理导入",
|
|
|
|
|
|
BusinessType = BusinessType.IMPORT,
|
|
|
|
|
|
IsSaveRequestData = false,
|
|
|
|
|
|
IsSaveResponseData = true
|
|
|
|
|
|
)]
|
2026-01-09 10:53:37 +08:00
|
|
|
|
[ActionPermissionFilter(Permission = "mminventory:import")]
|
|
|
|
|
|
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile)
|
|
|
|
|
|
{
|
|
|
|
|
|
//return SUCCESS(_MmMaterialService.Importmaterial(material));
|
|
|
|
|
|
if (formFile == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SUCCESS(null);
|
|
|
|
|
|
}
|
2026-01-13 15:08:05 +08:00
|
|
|
|
ImportResultDto response = _MmInventoryService.ImportInventory(
|
|
|
|
|
|
formFile,
|
|
|
|
|
|
HttpContext.GetName()
|
|
|
|
|
|
);
|
2026-01-09 10:53:37 +08:00
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
2026-01-13 13:57:56 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取出/入库记录数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("GetInOrOutRecord")]
|
2026-01-13 15:08:05 +08:00
|
|
|
|
public IActionResult GetInOrOutRecord([FromBody] MmInventoryRecordQueryDto parm)
|
2026-01-13 13:57:56 +08:00
|
|
|
|
{
|
|
|
|
|
|
var response = _MmInventoryService.GetInOrOutRecord(parm);
|
|
|
|
|
|
|
|
|
|
|
|
return SUCCESS(response);
|
|
|
|
|
|
}
|
2026-01-28 14:52:32 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 出货操作
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("Shipment")]
|
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
|
[Log(Title = "出货操作", BusinessType = BusinessType.INSERT)]
|
|
|
|
|
|
public IActionResult Shipment([FromBody] ShipmentDto parm)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
string response = _MmInventoryService.Shipment(parm);
|
|
|
|
|
|
if (response == "ok")
|
|
|
|
|
|
{
|
|
|
|
|
|
return ToResponse(new ApiResult(200, "ok"));
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return ToResponse(new ApiResult(500, response));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-12-24 19:09:42 +08:00
|
|
|
|
}
|
2026-01-13 15:08:05 +08:00
|
|
|
|
}
|