From a0d2f70a2578ad8160bf4c9b983bf6b40c0f4f77 Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周一, 26 8月 2024 13:32:22 +0800
Subject: [PATCH] 2

---
 iWara.SCADA.Code/iWare.Wms.Application/Service/Pda/PdaService.cs |   37 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/iWara.SCADA.Code/iWare.Wms.Application/Service/Pda/PdaService.cs b/iWara.SCADA.Code/iWare.Wms.Application/Service/Pda/PdaService.cs
index 655cbdd..8d5a7b4 100644
--- a/iWara.SCADA.Code/iWare.Wms.Application/Service/Pda/PdaService.cs
+++ b/iWara.SCADA.Code/iWare.Wms.Application/Service/Pda/PdaService.cs
@@ -9,6 +9,7 @@
 using Furion.DynamicApiController;
 using System.Text;
 using iWare.Wms.Core.Enum;
+using Microsoft.AspNetCore.Authorization;
 
 namespace iWare.Wms.Application.Service.Pda
 {
@@ -18,6 +19,7 @@
     //[Route("api")]
     [ApiDescriptionSettings("Pda鐩稿叧鎺ュ彛", Name = "PdaService", Order = 100)]
     [Route("api/[Controller]")]
+    [DisableOpLog]
     public class PdaService : IDynamicApiController, ITransient
     {
         private readonly IRepository<EquipmentBaseInfo, MasterDbContextLocator> _equipmentBaseInfoRep;
@@ -221,6 +223,7 @@
         /// <param name="input"></param>
         /// <returns></returns>
         [HttpGet("getWorkPieceProcess")]
+        [DisableOpLog]
         public async Task<WorkPieceProcessPdaOutput> getWorkPieceProcess([FromQuery] WorkPieceProcessPdaSearch input)
         {
             var workPieceProcesss = await _workPieceProcessRep.DetachedEntities
@@ -411,12 +414,18 @@
         /// </summary>
         /// <returns></returns>
         [HttpGet("getWorkPieceByOP80NewCode")]
+        [DisableOpLog]
+        [AllowAnonymous]
         public async Task<WorkPieceInfoOutput> getWorkPieceByOP80NewCode([FromQuery] WorkPieceByOP80NewCodeInputSearch input)
         {
 
             if (string.IsNullOrEmpty(input.OP80NewCode))
             {
-                throw Oops.Oh($"璇疯緭鍏P80鎵撳嵃鎴愬搧鐮佹垨浜岀淮鐮侊紒");
+                throw Oops.Oh($"璇疯緭鍏ユ垚鍝佺爜鎴栧伐浠剁爜锛�");
+            }
+            if (input.OP80NewCode.Length > 22)
+            {
+                throw Oops.Oh($"宸ヤ欢鐮佹垨鎴愬搧鐮亄input.OP80NewCode}闀垮害涓嶆纭紒");
             }
             string OP80NewCode = input.OP80NewCode.Trim();
             var workPieceInfo = await _workPieceInfoRep.DetachedEntities
@@ -447,6 +456,16 @@
                     OP80NewCode = OP80NewCode,
                 };
             }
+
+            //鍒ゆ柇鏄惁宸茬粡鍑哄簱
+            List<WorkPieceOutbound> db_itemModelList = await _workPieceOutboundRep.DetachedEntities.Where(w => (w.WorkPieceID == OP80NewCode || w.OP80NewCode == OP80NewCode) && w.IsDeleted == false).ToListAsync();
+            if (db_itemModelList != null && db_itemModelList.Count > 0)
+            {
+                var itemModel = db_itemModelList.First();
+                var createitme = itemModel.CreatedTime == null ? "" : (((DateTimeOffset)itemModel.CreatedTime).UtcDateTime.ToString("yyyy-MM-dd HH:mm:ss"));
+                throw Oops.Oh($"宸ヤ欢{itemModel.WorkPieceID}宸插嚭搴擄紝鍑哄簱鏃堕棿:{createitme}");
+            }
+
             return workPieceInfo;
         }
 
@@ -456,6 +475,8 @@
         /// <param name="input"></param>
         /// <returns></returns>
         [HttpPost("outBoundWorkPiece")]
+        [DisableOpLog]
+        [UnitOfWork]
         public async Task<string> outBoundWorkPiece([FromBody] OutBoundInput input)
         {
 
@@ -474,6 +495,8 @@
 
             var queryWorkPieceIDList = WorkPieceInfoLst.Select(x => x.WorkPieceID).ToList();
             List<WorkPieceOutbound> db_itemModelList = await _workPieceOutboundRep.Where(w => queryWorkPieceIDList.Contains(w.WorkPieceID) && w.IsDeleted == false).ToListAsync();
+
+            List<WorkPieceInfo> db_WorkPieceInfoList = await _workPieceInfoRep.Where(w => queryWorkPieceIDList.Contains(w.WorkPieceID) && w.IsDeleted == false).ToListAsync();
 
             foreach (var item in WorkPieceInfoLst)
             {
@@ -497,6 +520,17 @@
                     CreatedUserName = CurrentUserInfo.Name,
                 };
                 addOutBoundList.Add(outBoundLog);
+
+                var workPiece = db_WorkPieceInfoList.FirstOrDefault(w => w.WorkPieceID == item.WorkPieceID);
+                if (workPiece != null)
+                {
+                    workPiece.OutPerson = CurrentUserInfo.Name;
+                    workPiece.OutRemark = "鎾ら攢宸ヤ欢鍑哄簱";
+                    workPiece.OutTime = DateTime.Now;
+                    workPiece.IsOut = false;
+
+                    await _workPieceInfoRep.UpdateAsync(workPiece);
+                }
             }
             await _workPieceOutboundRep.InsertAsync(addOutBoundList);
             return "鍑哄簱鎴愬姛";
@@ -508,6 +542,7 @@
         /// <param name="input"></param>
         /// <returns></returns>
         [HttpPost("getOutBoundWorkPieceInfoCount")]
+        [DisableOpLog]
         public async Task<string> GetOutBoundWorkPieceInfoCount()
         {
             DateTimeOffset now = DateTimeOffset.Now; // 鑾峰彇褰撳墠鏃堕棿锛屽寘鎷椂鍖哄亸绉婚噺

--
Gitblit v1.9.3