From 21cce90e8d660954f0b89bfe25b9f5218dcbaacd Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期一, 12 五月 2025 00:32:34 +0800
Subject: [PATCH] 退料单(U9)上架事务

---
 Tiger.Business.WMS/Transaction/Yada/In_BIZ_U9_RECEIPT.cs |   38 ++++++++++++++++++++++----------------
 1 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/Tiger.Business.WMS/Transaction/Yada/In_BIZ_U9_RECEIPT.cs b/Tiger.Business.WMS/Transaction/Yada/In_BIZ_U9_RECEIPT.cs
index f9d0006..3d49dd0 100644
--- a/Tiger.Business.WMS/Transaction/Yada/In_BIZ_U9_RECEIPT.cs
+++ b/Tiger.Business.WMS/Transaction/Yada/In_BIZ_U9_RECEIPT.cs
@@ -21,7 +21,6 @@
     /// </summary>
     public class In_BIZ_U9_RECEIPT : WmsTask, IIn_BIZ_U9_RECEIPT
     {
-
         public IIn_BIZ_U9_RECEIPT Init(string id, string userCode, string apiHost, string orgCode)
         {
             base.Init(id, userCode, apiHost, orgCode);
@@ -71,7 +70,7 @@
                         action.LocaleMsg = Biz.L("WMS.Default.ScanItem.SnEmptyFailure");
                         return SetOutPutMqttMsg(action, input.Locale);
                     }
-                    //鍒ゆ柇鎵弿鐨勬槸鍚﹁揣鏋�
+                    //鍒ゆ柇鎵弿鐨勬槸鍚﹁揣鏋�/鍌ㄤ綅
                     var whUnit = await MainDB.Queryable<V_WH_UNIT>().Where(t => (t.SHELF_CODE.ToUpper() == input.SN || t.LOCATION_CODE.ToUpper() == input.SN) && t.AUTH_ORG == OrgCode).IncludesAllFirstLayer().FirstAsync();
                     //if (string.IsNullOrEmpty(CurScanShelf?.ShelfCode))
                     if (!whUnit.IsNullOrEmpty() || string.IsNullOrEmpty(CurScanShelf?.ShelfCode))
@@ -163,12 +162,12 @@
                     if (!inv.ItemInfo.DEFAULT_LOCATION.IsNullOrEmpty() && inv.ItemInfo.DEFAULT_LOCATION != CurScanShelf.LocationCode)
                     {
 	                    action.IsSuccessed = false;
-	                    //action.LocaleMsg = Biz.L("鐗╂枡[{0}]鍙厑璁镐笂鏋跺埌鍌ㄤ綅[{0}]锛岃閲嶆柊鎵弿鍌ㄤ綅");
+	                    //action.LocaleMsg = Biz.L("鐗╂枡[{0}]鍙厑璁镐笂鏋跺埌鍌ㄤ綅[{1}]锛岃閲嶆柊鎵弿鍌ㄤ綅");
 	                    action.LocaleMsg = Biz.L("WMS.Default.ScanItem.DefaultLocationError", inv.ItemInfo.ITEM_CODE, inv.ItemInfo.DEFAULT_LOCATION);
 	                    return SetOutPutMqttMsg(action, input.Locale);
                     }
                     //鍒ゆ柇褰撳墠鏉$爜鏄惁灞炰簬褰撳墠鏀惰揣鍗�
-                    if (CurInvItem.Items.First().TRANS_NO != CurOrder.ORDER_NO)
+                    if (inv.Items.First().TRANS_NO != CurOrder.ORDER_NO)
                     {
                         action.IsSuccessed = false;
                         //action.LocaleMsg = Biz.L("鏉$爜鎵�灞炵殑鍗曟嵁[{0}]涓嶆槸閫夋嫨鐨勬敹璐у崟[{1}]锛岃閲嶆柊鎵弿姝g‘鐨勬潯鐮佹垨閫夋嫨鍏朵粬鏀惰揣鍗�");
@@ -308,6 +307,11 @@
                     sn.STATUS = WMS_ITEM.STATUSs.InStore.GetValue();
                     sn.IS_IN = "Y";
                 }
+                //璁剧疆褰撳墠鐗╂枡鐨勯粯璁ゅ偍浣�
+                if (CurInvItem.ItemInfo.DEFAULT_LOCATION.IsNullOrEmpty())
+                {
+                    SetDefaultLocation(MainDB, CurInvItem.ItemInfo, nLocation, receiptDtl.ID.ToInt64());
+                }
                 //濡傛灉褰撳墠琛屼笂鏋跺畬鎴愭爣璁颁负寰呭鏍�
                 receiptDtl.QTY_IN = receipt.SnList.Where(q => q.LINE_NO == receiptDtl.LINE_NO && q.STATUS == WMS_ITEM.STATUSs.InStore.GetValue()).Sum(q => q.QTY);
                 if (receiptDtl.QTY_IN == receiptDtl.QTY_OK)
@@ -369,14 +373,16 @@
                 });
 
                 //瀹屾垚鎵�鏈夊鐞嗗悗浣跨敤浜嬪姟淇濆瓨鏁版嵁
-                action = DoIfFinish(action, input.Locale, () =>
-                {
-                    //璁剧疆褰撳墠鐗╂枡鐨勯粯璁ゅ偍浣�
-                    if (CurInvItem.ItemInfo.DEFAULT_LOCATION.IsNullOrEmpty())
-                    {
-                        SetDefaultLocation(MainDB, CurInvItem.ItemInfo, nLocation);
-                    }
-                });
+                action = DoIfFinish(action, input.Locale
+                    //, () =>
+                    //{
+                    //    //璁剧疆褰撳墠鐗╂枡鐨勯粯璁ゅ偍浣�
+                    //    if (CurInvItem.ItemInfo.DEFAULT_LOCATION.IsNullOrEmpty())
+                    //    {
+                    //        SetDefaultLocation(MainDB, CurInvItem.ItemInfo, nLocation, receiptDtl.ID.ToInt64());
+                    //    }
+                    //}
+                 );
                 //if (!action.Data.Data.IsNullOrEmpty() && action.Data.Data is DefaultInStoreOutput)
                 //{
                 //    (action.Data.Data as DefaultInStoreOutput).OrderInfo = receipt;
@@ -537,13 +543,13 @@
             var action = new ApiAction<PageAble<BIZ_U9_RECEIPT>>();
             var query = Biz.DataSource["YadaU9C"].Client.Queryable<mes_ReturnedDocInfo>().Where(q => q.Status == 3)
                                     .WhereIF(!input.OrderNo.IsNullOrEmpty(), q => q.DocNo.Contains(input.OrderNo) || SqlFunc.Subqueryable<mes_AsnDocInfo>().Where(a => a.AsnId == q.SrcASNDocId && q.DocNo.Contains(input.OrderNo)).Any())
-                                    .OrderBy(q => q.DocNo).ToPage(input.pageIndex, input.pageSize);
+                                    .OrderBy(q => q.DocNo).Select(q => new { q.DocNo, q.Status, q.StatusName }).Distinct().ToList();
 
-            action.Data = await MainDB.Queryable<BIZ_U9_RECEIPT>().Where(q => query.data.Select(o => o.DocNo).Contains(q.ORDER_NO)).ToPageAsync(input.pageIndex, input.pageSize);
+            action.Data = await MainDB.Queryable<BIZ_U9_RECEIPT>().Where(q => query.Select(o => o.DocNo).Contains(q.ORDER_NO)).ToPageAsync(input.pageIndex, input.pageSize);
             foreach (var order in action.Data.data)
             {
-                order.ERP_STATUS_CODE = query.data.FirstOrDefault(q => q.DocNo == order.ORDER_NO)?.Status.ToString();
-                order.ERP_STATUS_NAME = query.data.FirstOrDefault(q => q.DocNo == order.ORDER_NO)?.StatusName;
+                order.ERP_STATUS_CODE = query.FirstOrDefault(q => q.DocNo == order.ORDER_NO)?.Status.ToString();
+                order.ERP_STATUS_NAME = query.FirstOrDefault(q => q.DocNo == order.ORDER_NO)?.StatusName;
             }
             MainDB.Updateable(action.Data.data, UserCode).UpdateColumns(q => new { q.UPDATE_TIME, q.UPDATE_USER, q.ERP_STATUS_CODE, q.ERP_STATUS_NAME }).ExecuteCommand();
             return action;

--
Gitblit v1.9.3