添加撤销出库功能

This commit is contained in:
2026-01-15 16:42:04 +08:00
parent 8435e0ed27
commit ca362d85ba
4 changed files with 148 additions and 3 deletions

View File

@@ -141,7 +141,7 @@ namespace DOAN.Admin.WebApi.Controllers.BZFM
/// <returns></returns>
[HttpPost("CreateInboundReceipt")]
[AllowAnonymous]
[Log(Title = "入库单", BusinessType = BusinessType.INSERT)]
[Log(Title = "创建入库单", BusinessType = BusinessType.INSERT)]
public IActionResult CreateInboundReceipt([FromBody] InboundReceiptDto parm)
{
try
@@ -168,7 +168,7 @@ namespace DOAN.Admin.WebApi.Controllers.BZFM
/// <returns></returns>
[HttpPost("CreateOutboundReceipt")]
[AllowAnonymous]
[Log(Title = "出库单", BusinessType = BusinessType.INSERT)]
[Log(Title = "创建出库单", BusinessType = BusinessType.INSERT)]
public IActionResult CreateOutboundReceipt([FromBody] OutboundReceiptDto parm)
{
try
@@ -189,6 +189,33 @@ namespace DOAN.Admin.WebApi.Controllers.BZFM
}
}
/// <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>

View File

@@ -16,6 +16,11 @@ namespace DOAN.Model.BZFM.Dto
public string SupplierName { get; set; }
public string BatchNo { get; set; }
}
public class MmInventoryRevokeDto
{
public int Id { get; set; }
public int Type { get; set; }
}
/// <summary>
/// 库存表输入输出对象

View File

@@ -45,6 +45,12 @@ namespace DOAN.Service.BZFM.IBZFMService
/// 创建出库单 成功返回ok
/// </summary>
string CreateOutboundReceipt(OutboundReceiptDto parm);
/// <summary>
/// 撤销单据
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
string RevokeReceipt(MmInventoryRevokeDto parm);
/// <summary>
/// 导入

View File

@@ -776,7 +776,7 @@ namespace DOAN.Service.BZFM
Operator = it.Operator,
CreatedTime = it.CreatedTime,
Workorder = it.Workorder,
OrderNo = it.OrderNo
OrderNo = it.OrderNo,
})
.OrderByDescending(it => it.CreatedTime)
.ToPage(parm);
@@ -784,5 +784,112 @@ namespace DOAN.Service.BZFM
return result;
}
/// <summary>
/// 撤销单据,传入单据类型(1-入库单2-出库单)和ID
/// </summary>
/// <param name="parm"></param>
/// <returns>返回ok即为成功其他都是不成功</returns>
/// <exception cref="NotImplementedException"></exception>
public string RevokeReceipt(MmInventoryRevokeDto parm)
{
try
{
int _type = parm.Type;
int _id = parm.Id;
if (_type < -1 && _id < -1)
{
return $"传入参数有误,请检查:type-{_type},id-{_id}";
}
// type == 1 入库单
if (_type == 1)
{
MmRecordInbound recordInbound = Context
.Queryable<MmRecordInbound>()
.Where(it => it.Id == _id)
.First();
if (recordInbound == null)
{
return $"无此入库记录,请检查:type-{_type},id-{_id}";
}
if (recordInbound.Remarks == "已撤销")
{
return $"此记录已撤销过,不可重复撤销";
}
//做出库红单
InboundReceiptDto revokeRecepitDto = new()
{
ReceiptType = 2,
MaterialCode = recordInbound.MaterialCode,
BatchNo = recordInbound.BatchNo,
LocationCode = recordInbound.LocationCode,
WarehouseCode = recordInbound.WarehouseCode,
SupplierCode = recordInbound.SupplierCode,
StoveCode = recordInbound.StoveCode,
Workorder = recordInbound.Workorder,
Operator = recordInbound.Operator,
Quantity = recordInbound.Quantity,
TransactionType = "入库红单",
Remarks = $"撤销操作,入库单号:{recordInbound.InboundNo}",
};
string result = CreateInboundReceipt(revokeRecepitDto);
if (result == "ok")
{
recordInbound.Remarks = "已撤销";
Context.Updateable(recordInbound).ExecuteCommand();
return result;
}
else
{
return result;
}
}
else
{
MmRecordOutbound recordOutbound = Context
.Queryable<MmRecordOutbound>()
.Where(it => it.Id == _id)
.First();
if (recordOutbound == null)
{
return $"无此出库记录,请检查:type-{_type},id-{_id}";
}
if (recordOutbound.Remarks == "已撤销")
{
return $"此记录已撤销过,不可重复撤销";
}
//做出库红单
OutboundReceiptDto revokeRecepitDto = new()
{
ReceiptType = 2,
MaterialCode = recordOutbound.MaterialCode,
BatchNo = recordOutbound.BatchNo,
LocationCode = recordOutbound.LocationCode,
WarehouseCode = recordOutbound.WarehouseCode,
OrderNo = recordOutbound.OrderNo,
Workorder = recordOutbound.Workorder,
Operator = recordOutbound.Operator,
Quantity = recordOutbound.Quantity,
TransactionType = "出库红单",
Remarks = $"撤销操作,出库单号:{recordOutbound.OutboundNo}",
};
string result = CreateOutboundReceipt(revokeRecepitDto);
if (result == "ok")
{
recordOutbound.Remarks = "已撤销";
Context.Updateable(recordOutbound).ExecuteCommand();
return result;
}
else
{
return result;
}
}
}
catch (Exception e)
{
return e.Message;
}
}
}
}