From ca362d85ba9fd094bfe1cb6cd56189e4c7e068b3 Mon Sep 17 00:00:00 2001 From: git_rabbit Date: Thu, 15 Jan 2026 16:42:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=92=A4=E9=94=80=E5=87=BA?= =?UTF-8?q?=E5=BA=93=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MmInventoryController.cs | 31 ++++- DOAN.Model/MES/Material/Dto/MmInventoryDto.cs | 5 + .../Material/IService/IMmInventoryService.cs | 6 + .../MES/Material/MmInventoryService.cs | 109 +++++++++++++++++- 4 files changed, 148 insertions(+), 3 deletions(-) diff --git a/DOAN.Admin.WebApi/Controllers/MES/Material/productionMaterial/MmInventoryController.cs b/DOAN.Admin.WebApi/Controllers/MES/Material/productionMaterial/MmInventoryController.cs index 012666a..e59b661 100644 --- a/DOAN.Admin.WebApi/Controllers/MES/Material/productionMaterial/MmInventoryController.cs +++ b/DOAN.Admin.WebApi/Controllers/MES/Material/productionMaterial/MmInventoryController.cs @@ -141,7 +141,7 @@ namespace DOAN.Admin.WebApi.Controllers.BZFM /// [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 /// [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 } } + /// + /// 撤销单据 + /// + /// + [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; + } + } + /// /// 导入 /// diff --git a/DOAN.Model/MES/Material/Dto/MmInventoryDto.cs b/DOAN.Model/MES/Material/Dto/MmInventoryDto.cs index 70a6775..3874c28 100644 --- a/DOAN.Model/MES/Material/Dto/MmInventoryDto.cs +++ b/DOAN.Model/MES/Material/Dto/MmInventoryDto.cs @@ -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; } + } /// /// 库存表输入输出对象 diff --git a/DOAN.Service/MES/Material/IService/IMmInventoryService.cs b/DOAN.Service/MES/Material/IService/IMmInventoryService.cs index b578b38..e8b69fd 100644 --- a/DOAN.Service/MES/Material/IService/IMmInventoryService.cs +++ b/DOAN.Service/MES/Material/IService/IMmInventoryService.cs @@ -45,6 +45,12 @@ namespace DOAN.Service.BZFM.IBZFMService /// 创建出库单 成功返回ok /// string CreateOutboundReceipt(OutboundReceiptDto parm); + /// + /// 撤销单据 + /// + /// + /// + string RevokeReceipt(MmInventoryRevokeDto parm); /// /// 导入 diff --git a/DOAN.Service/MES/Material/MmInventoryService.cs b/DOAN.Service/MES/Material/MmInventoryService.cs index 02126d3..c32cb6b 100644 --- a/DOAN.Service/MES/Material/MmInventoryService.cs +++ b/DOAN.Service/MES/Material/MmInventoryService.cs @@ -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; } + + /// + /// 撤销单据,传入单据类型(1-入库单,2-出库单)和ID + /// + /// + /// 返回ok即为成功其他都是不成功 + /// + 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() + .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() + .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; + } + } } }