From 90b264c675155d6fb921d256f2de48ad398845c6 Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周四, 20 6月 2024 13:25:38 +0800
Subject: [PATCH] 2

---
 iWara.SCADA.Code/iWare.Wms.Application/Service/WorkPieceOutbound/WorkPieceOutboundService.cs |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/iWara.SCADA.Code/iWare.Wms.Application/Service/WorkPieceOutbound/WorkPieceOutboundService.cs b/iWara.SCADA.Code/iWare.Wms.Application/Service/WorkPieceOutbound/WorkPieceOutboundService.cs
index a3c2b34..141c83c 100644
--- a/iWara.SCADA.Code/iWare.Wms.Application/Service/WorkPieceOutbound/WorkPieceOutboundService.cs
+++ b/iWara.SCADA.Code/iWare.Wms.Application/Service/WorkPieceOutbound/WorkPieceOutboundService.cs
@@ -21,13 +21,15 @@
     [DisableOpLog]
     public class WorkPieceOutboundService : IWorkPieceOutboundService, IDynamicApiController, ITransient
     {
-        private readonly IRepository<WorkPieceOutbound,MasterDbContextLocator> _workPieceOutboundRep;
-
+        private readonly IRepository<WorkPieceOutbound, MasterDbContextLocator> _workPieceOutboundRep;
+        private readonly IRepository<WorkPieceInfo, MasterDbContextLocator> _workPieceInfoRep;
 
         public WorkPieceOutboundService(
-            IRepository<WorkPieceOutbound,MasterDbContextLocator> workPieceOutboundRep
+            IRepository<WorkPieceInfo, MasterDbContextLocator> workPieceInfoRep,
+            IRepository<WorkPieceOutbound, MasterDbContextLocator> workPieceOutboundRep
         )
         {
+            _workPieceInfoRep = workPieceInfoRep;
             _workPieceOutboundRep = workPieceOutboundRep;
         }
 
@@ -86,7 +88,7 @@
             if (!isExist) throw Oops.Oh(ErrorCode.D3000);
 
             var workPieceOutbound = input.Adapt<WorkPieceOutbound>();
-            await _workPieceOutboundRep.UpdateAsync(workPieceOutbound,ignoreNullValues:true);
+            await _workPieceOutboundRep.UpdateAsync(workPieceOutbound, ignoreNullValues: true);
         }
 
         /// <summary>
@@ -117,19 +119,32 @@
         /// <param name="input"></param>
         /// <returns></returns>
         [HttpPost("revoke")]
+        [UnitOfWork]
         public async Task Revoke(List<DeleteWorkPieceOutboundInput> input)
         {
-            foreach (var item in input) {
+            foreach (var item in input)
+            {
                 var workPieceOutbound = await _workPieceOutboundRep.FirstOrDefaultAsync(u => u.Id == item.Id);
                 if (workPieceOutbound == null)
                 {
                     throw Oops.Oh("宸ヤ欢鍑哄簱淇℃伅涓嶅瓨鍦�");
                 }
                 workPieceOutbound.IsDeleted = true;
-                workPieceOutbound.Remark = workPieceOutbound.Remark??""+"鎾ら攢鍙戣揣";
+                workPieceOutbound.Remark = workPieceOutbound.Remark ?? "" + "鎾ら攢鍙戣揣";
                 await _workPieceOutboundRep.UpdateAsync(workPieceOutbound);
+
+                var workPiece = await _workPieceInfoRep.FirstOrDefaultAsync(u => u.WorkPieceID == workPieceOutbound.WorkPieceID);
+                if (workPiece != null)
+                {
+                    workPiece.OutPerson = CurrentUserInfo.Name;
+                    workPiece.OutRemark = "鎾ら攢宸ヤ欢鍑哄簱";
+                    workPiece.OutTime = DateTime.Now;
+                    workPiece.IsOut = false;
+
+                    await _workPieceInfoRep.UpdateAsync(workPiece);
+                }
             }
-            
+
         }
 
     }

--
Gitblit v1.9.3