From 716435e1177c454a9cd652fae35769a0ef9a3b7c Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期四, 13 二月 2025 10:10:39 +0800
Subject: [PATCH] 1.成品入库(初步) 2.仓库入参新增字段备注 3.采购入库,其他入库主表新增仓库id 4.其他出库优化

---
 service/Warehouse/MesItemQtrkManager.cs |   34 ++++++++++++++++++++++------------
 1 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/service/Warehouse/MesItemQtrkManager.cs b/service/Warehouse/MesItemQtrkManager.cs
index b5d74c2..8c75e6d 100644
--- a/service/Warehouse/MesItemQtrkManager.cs
+++ b/service/Warehouse/MesItemQtrkManager.cs
@@ -131,7 +131,7 @@
 
         if (barcode == null) throw new Exception("鏉$爜涓嶅瓨鍦�,璇锋牳瀵癸紒");
 
-        if (barcode.ComeFlg != 3) throw new Exception("鏉$爜涓嶆槸鍏朵粬鍏ュ簱鏉$爜,鏃犳硶鐢ㄥ叾浠栧叆搴擄紒");
+        //if (barcode.ComeFlg != 3) throw new Exception("鏉$爜涓嶆槸鍏朵粬鍏ュ簱鏉$爜,鏃犳硶鐢ㄥ叾浠栧叆搴擄紒");
 
         // 楠岃瘉鏉$爜鏄惁宸插湪搴撳瓨涓�
         var stockCount = Db.Queryable<MesInvItemStocks>()
@@ -170,11 +170,14 @@
             // 鏌ヨ鏄惁瀛樺湪鏈叆搴撶殑鍏ュ簱鍗�
             var existingInv = db.Queryable<MesInvItemIns>()
                 .Where(x => x.Status == 0
+                            && x.InsDate.Value.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd")
                             && x.TransctionNo == transactionNo.ToString()
-                            && x.CbillNo == p_bill_no
-                            && x.SuppNo == barcode.SuppNo
+                            && x.TaskNo == p_bill_no
+                            //&& x.CbillNo == p_bill_no
+                            && x.BillTypeId == billTypeId
+                            && x.DepotsId == Convert.ToInt64(c_depot_id))
                             // && x.DepotsCode == c_depot_code)
-                            && x.DepotsId == c_depot_id)
+                            //&& x.SuppNo == barcode.SuppNo)
                 .First();
 
             var newId = Guid.Empty;
@@ -183,7 +186,7 @@
             if (existingInv == null)
             {
                 newId = Guid.NewGuid();
-                billNo = BillNo.GetBillNo("INV_IN_OTHER");
+                billNo = BillNo.GetBillNo("QTRK(鍏朵粬鍏ュ簱鍗�)");
 
                 barcode.UrgentFlag ??= false;
 
@@ -200,11 +203,15 @@
                     CreateDate = DateTime.Now,
                     LastupdateBy = c_user,
                     LastupdateDate = DateTime.Now,
-                    UrgentFlag = barcode.UrgentFlag.Value ? (byte)1 : (byte)0,
+                    UrgentFlag = barcode.UrgentFlag.Value ? "1" : "0",
                     CbillNo = p_bill_no,
                     Fstatus = 0,
                     Status = 0,
-                    Reason = qtrk.Qt010
+                    Reason = qtrk.Qt010,
+                    TaskNo = p_bill_no,
+                    DepotsId = Convert.ToInt64(c_depot_id) ,
+                    InType = "鍏朵粬鍏ュ簱"
+
                 }).IgnoreColumns(true).ExecuteCommand();
             }
             else
@@ -217,8 +224,9 @@
             var existingItem = db.Queryable<MesInvItemInCItems>()
                 .Where(x => x.ItemInId == newId
                             && x.ItemId == barcode.ItemId
-                            && x.WorkNo == barcode.WorkNo
-                            && x.WorkLine == barcode.WorkLine)
+                            && x.DepotId == c_depot_id.ToString()
+                             )
+                //&& x.DepotCode =
                 .First();
 
             if (existingItem == null)
@@ -246,7 +254,8 @@
                     Remark = barcode.Memo,
                     EbelnK3id = barcode.EbelnK3id,
                     LineK3id = barcode.LineK3id,
-                    ItemId = barcode.ItemId
+                    ItemId = barcode.ItemId,
+                    DepotId = c_depot_id.ToString()
                 }).IgnoreColumns(true).ExecuteCommand();
             else
                 // 瀛樺湪鍒欐洿鏂版暟閲�
@@ -274,7 +283,7 @@
                 LotNo = barcode.LotNo,
                 SuppId = barcode.SuppId,
                 SuppNo = barcode.SuppNo,
-                DepotId = c_depot_id,
+                DepotId = Convert.ToInt64(c_depot_id),
                 DepotCode = c_depot_code,
                 DepotSectionCode = p_section_code,
                 ItemSname = barcode.ItemSname,
@@ -377,7 +386,8 @@
             // 鏇存柊鐢宠鍗曟槑缁嗗凡鍏ュ簱鏁伴噺
             res += db.Updateable<MesItemQtrrDetail>()
                 .SetColumns(x => x.Qd008 == (x.Qd008 ?? 0) + barcode.Quantity)
-                .Where(x => x.Guid == barcode.Guid)
+                .Where(x => x.QtrkGuid == qtrk.Guid &&
+                x.ItemId == barcode.ItemId.ToString())
                 .ExecuteCommand();
 
             // 妫�鏌ユ槸鍚﹀畬鍏ㄥ叆搴撳苟鏇存柊鐘舵��

--
Gitblit v1.9.3