From 1b8d10dbb20b513be61556021f8f471e506d92c3 Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期二, 08 十月 2024 09:48:57 +0800
Subject: [PATCH] 1

---
 MES.Service/service/QC/RKJService.cs |   51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 50 insertions(+), 1 deletions(-)

diff --git a/MES.Service/service/QC/RKJService.cs b/MES.Service/service/QC/RKJService.cs
index 5ca88ff..00b78f9 100644
--- a/MES.Service/service/QC/RKJService.cs
+++ b/MES.Service/service/QC/RKJService.cs
@@ -483,6 +483,10 @@
 
         var barCodes = mesInvItemInsList.Select(s => s.ItemBarcode).ToList();
 
+        var count = db.Queryable<MesInvItemBarcodes>()
+            .Where(s => barCodes.Contains(s.ItemBarcode) && s.WorkFlg == 0)
+            .Count();
+
         var gxId = mesInvItemInsList.Select(s => s.MesScgdGxId).ToList();
 
         var sumQty = mesInvItemInsList.Sum(s => s.Quantity);
@@ -494,6 +498,23 @@
                 .SetColumns(s => s.CheckFlag == "鈭�")
                 .Where(s => gxId.Contains(s.Id))
                 .ExecuteCommand();
+
+            if (count <= 0) return;
+            
+            //鍙栨秷mes_inv_item_barcodes 鐨勬姤宸ユ爣璇� WORK_FLG 浣跨敤鏉$爜
+            var executeCommand = db.Updateable<MesInvItemBarcodes>()
+                .SetColumns(a => a.WorkFlg == 1)
+                .Where(a => barCodes.Contains(a.ItemBarcode))
+                .ExecuteCommand();
+
+            if (executeCommand > 0)
+            {
+                //womdaa 宸茬敓浜ч噺 DAA011鍔犲洖鏉$爜鎶ュ伐鏁伴噺
+                db.Updateable<Womdaa>()
+                    .SetColumns(b => b.Daa011 == b.Daa011 + sumQty)
+                    .Where(b => b.Daa001 == qsItemOqcReq.Daa001)
+                    .ExecuteCommand();
+            }
         }
         else if ("涓嶅悎鏍�".Equals(FcheckResu))
         {
@@ -608,6 +629,7 @@
             .Select((a, b, c, ca, m, da, z) => new QsItemOqcReq
             {
                 BillNo = a.BillNo,
+                Fsubmit = a.Fsubmit,
                 Remarks = a.Remarks,
                 Id = a.Id,
                 CreateDate = a.CreateDate,
@@ -623,7 +645,8 @@
                 ItemInId = m.ItemInId,
                 Daa015 = da.Daa015,
                 LineNo = c.LineNo,
-                Quantity = m.Quantity
+                Quantity = m.Quantity,
+                Bgr = c.Bgr
             })
             .OrderBy(a => a.CreateDate, OrderByType.Desc)
             .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount);
@@ -807,4 +830,30 @@
 
         return Convert.ToInt32(rkjDto.gid);
     }
+
+    public int cleanReqResult(RKJDto dto)
+    {
+        if (isRk(dto.gid)) throw new Exception("宸叉湁鏉$爜鍏ュ簱锛屼笉鍏佽娓呴櫎妫�楠岀粨鏋�");
+
+
+        return SqlSugarHelper.UseTransactionWithOracle(db =>
+        {
+            return db.Updateable<QsItemOqcReq>()
+                .SetColumns(s => s.FcheckResu == null)
+                .Where(s => s.Id == dto.gid).ExecuteCommand();
+        });
+    }
+
+    private bool isRk(int? gid)
+    {
+        var db = SqlSugarHelper.GetInstance();
+        return db.Queryable<QsItemOqcReq, MesInvItemIns, MesInvItemInCDetails2,MesInvItemStocks>(
+                (a, b, c,d) => new JoinQueryInfos(
+                    JoinType.Inner, a.BillNo == b.BillNo,
+                    JoinType.Inner, b.Id == c.ItemInId,
+                    JoinType.Inner,c.ItemBarcode == d.ItemBarcode
+                ))
+            .Where((a, b, c,d) => a.Id == gid)
+            .Count() > 0;
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3