From cd8182d8fefc55c245400936b6330a00e866adbd Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期二, 24 十二月 2024 21:25:06 +0800
Subject: [PATCH] 优化标准上下架

---
 Tiger.Business.WMS/Transaction/Out_Default.cs |   51 +++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/Tiger.Business.WMS/Transaction/Out_Default.cs b/Tiger.Business.WMS/Transaction/Out_Default.cs
index 88d5500..cd5dfb3 100644
--- a/Tiger.Business.WMS/Transaction/Out_Default.cs
+++ b/Tiger.Business.WMS/Transaction/Out_Default.cs
@@ -35,15 +35,16 @@
         public string OrgCode { get; set; }
         public Inventory CurInvItem { get; set; }
         public ScanShelfInfo CurScanShelf { get; set; }
+        public string Command { get; set; } = "Normal";
         #endregion
 
         #region Functions
         /// <summary>
-        /// 鎵弿鐗╂枡骞跺鏍革紝濡傛灉鏄櫤鑳借揣鏋跺垯浜伅鎻愰啋鍌ㄤ綅
+        /// 鎵弿鍏ュ彛
         /// </summary>
-        public async Task<ApiAction<DefaultScanItemOutput>> ScanItem(BaseInput input)
+        public async Task<ApiAction<ScanOutput>> Scan(BaseInput input)
         {
-            var action = new ApiAction<DefaultScanItemOutput>();
+            var action = new ApiAction<ScanOutput>();
             try
             {
                 if (input.SN.IsNullOrEmpty())
@@ -51,9 +52,31 @@
                     action.IsSuccessed = false;
                     //action.LocaleMsg = Biz.L("鏉$爜涓嶈兘涓虹┖");
                     action.LocaleMsg = Biz.L("WMS.Default.ScanItem.SnEmptyFailure");
-                    return action;
+                    return SetOutPutMqttMsg(action, input.Locale);
                 }
+                //鎵弿鐗╂枡骞跺鏍�
+                {
+                    action = await ScanItem(input);
+                }
+            }
+            catch (Exception ex)
+            {
+                //鍙栨秷褰撳墠鎿嶄綔
+                ResetInfo();
+                //action.CatchExceptionWithLog(ex, $"鎵弿[{input.SN}]寮傚父");
+                action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.Scan.ScanException", input.SN));
+            }
+            return SetOutPutMqttMsg(action, input.Locale);
+        }
 
+        /// <summary>
+        /// 鎵弿鐗╂枡骞跺鏍革紝濡傛灉鏄櫤鑳借揣鏋跺垯浜伅鎻愰啋鍌ㄤ綅
+        /// </summary>
+        public async Task<ApiAction<ScanOutput>> ScanItem(BaseInput input)
+        {
+            var action = new ApiAction<ScanOutput>(new ScanOutput() { Command = Command });
+            try
+            {
                 //瑙f瀽鏉$爜
                 Result<IInventory> result = WMS_ITEM_Biz.WmsItem.Get(input.SN, input.AuthOption, true);
                 if (!result.IsSuccessed)
@@ -125,7 +148,7 @@
                     throw dbTran.ErrorException;
                 }
 
-                action.Data = new DefaultScanItemOutput()
+                action.Data.Data = new DefaultScanItemOutput()
                 {
                     SN = CurInvItem.SN,
                     ItemCode = CurInvItem.ItemInfo.ITEM_CODE,
@@ -138,13 +161,13 @@
                     ScanAfCut = CurInvItem.Warehouse.SCAN_AF_CUT
                 };
                 //action.LocaleMsg = Biz.L($"鎵弿鏉$爜[{0}]浠庡偍浣峓{1}]涓嬫灦鎴愬姛");
-                action.LocaleMsg = Biz.L("WMS.Default.ScanItem.TakeDownSucceeded", action.Data.SN, action.Data.locationCode);
+                action.LocaleMsg = Biz.L("WMS.Default.ScanItem.TakeDownSucceeded", CurInvItem.SN, CurInvItem.Location?.LOCATION_CODE);
             }
             catch (Exception ex)
             {
                 ResetInfo();
                 //action.CatchExceptionWithLog(ex, $"鎵弿鏉$爜[{input.SN}]澶嶆牳寮傚父");
-                action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanItem.ScanException", action.Data.SN));
+                action.CatchExceptionWithLog(ex, Biz.L("WMS.Default.ScanItem.ScanException", input.SN));
             }
             return action;
         }
@@ -152,9 +175,9 @@
         /// <summary>
         /// 鎵弿璐ф灦鎴栬�呭偍浣�(渚涗寒鐏揣鏋朵娇鐢�)
         /// </summary>
-        public async Task<ApiAction<ScanShelfInfo>> ScanShelf(string Code)
+        public async Task<ApiAction<ScanOutput>> ScanShelf(string Code)
         {
-            var action = new ApiAction<ScanShelfInfo>();
+            var action = new ApiAction<ScanOutput>();
             try
             {
                 if (Code.IsNullOrEmpty())
@@ -177,14 +200,13 @@
                     CurScanShelf.WarehouseCode = whUnit.WH_CODE;
                     CurScanShelf.RegionCode = whUnit.REGION_CODE;
                     CurScanShelf.ShelfCode = whUnit.SHELF_CODE;
-                    CurScanShelf.LocationCode = whUnit.LOCATION_CODE;
                     CurScanShelf.ShelfType = whUnit.SHELF_TYPE;
                     CurScanShelf.IsSmartRack = true;
                 }
-                // 鎵弿鍌ㄤ綅浠g爜
+                // 鎵弿搴撲綅浠g爜
                 else
                 {
-                    var nLocation = await Biz.Db.Queryable<V_WH_UNIT>().Where(t => t.LOCATION_CODE.ToUpper() == Code.ToUpper() && t.AUTH_ORG == OrgCode).FirstAsync();
+                    var nLocation = await Biz.Db.Queryable<V_WH_UNIT>().Where(t => t.LOCATION_CODE.ToUpper() == Code.ToUpper() && t.AUTH_ORG == OrgCode).IncludesAllFirstLayer().FirstAsync();
                     if (nLocation == null)
                     {
                         action.IsSuccessed = false;
@@ -210,7 +232,7 @@
                     //        return action;
                     //    }
                     //}
-
+                    CurScanShelf.Shelf = nLocation.Shelf;
                     CurScanShelf.Location = nLocation.Location;
                     CurScanShelf.WarehouseCode = nLocation.WH_CODE;
                     CurScanShelf.RegionCode = nLocation.REGION_CODE;
@@ -222,7 +244,7 @@
                 CurScanShelf.IsScanShelf = true;
                 //action.LocaleMsg = Biz.L("鎵弿璐ф灦/鍌ㄤ綅[{0}]鎴愬姛");
                 action.LocaleMsg = Biz.L("WMS.Default.ScanShelf.ScanSucceeded", Code);
-                action.Data = CurScanShelf;
+                action.Data.Data = CurScanShelf;
             }
             catch (Exception ex)
             {
@@ -242,6 +264,7 @@
         public override void ResetInfo()
         {
             base.ResetInfo();
+            Command = null;
             CurInvItem = null;
             CurScanShelf = null;
         }

--
Gitblit v1.9.3