From 5e11da1d662cd0c629ab2d854de2e5babb399ca3 Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期日, 22 九月 2024 09:14:51 +0800
Subject: [PATCH] 来料检验的分页

---
 MES.Service/service/QC/RKJService.cs |  101 +++++++++++++++++++++++++++++++-------------------
 1 files changed, 63 insertions(+), 38 deletions(-)

diff --git a/MES.Service/service/QC/RKJService.cs b/MES.Service/service/QC/RKJService.cs
index aeca6d4..b77c146 100644
--- a/MES.Service/service/QC/RKJService.cs
+++ b/MES.Service/service/QC/RKJService.cs
@@ -54,13 +54,14 @@
 
 
     //鑾峰彇宸ュ崟鍙�
-    public List<RKJDaa001> GetDaa001s(string lineNo)
+    public List<RkDaa002> GetDaa001s(string lineNo)
     {
         var db = SqlSugarHelper.GetInstance();
-        return db.Queryable<RKJDaa001>()
-            .Where(t => t.LineNo == lineNo)
-            .OrderBy(t => t.BillNo, OrderByType.Desc)
-            .ToList();
+        // return db.Queryable<RKJDaa001>()
+        //     .Where(t => t.LineNo == lineNo)
+        //     .OrderBy(t => t.BillNo, OrderByType.Desc)
+        //     .ToList();
+        return null;
     }
 
     //鏍规嵁妫�楠屾爣鍑嗘潵璁$畻妫�楠屼釜鏁�
@@ -131,6 +132,8 @@
                     break;
             }
 
+            if (string.IsNullOrEmpty(LEV)) throw new Exception("妫�楠屾按骞崇淮鎶ょ殑涓嶆纭�");
+
             var sql =
                 "SELECT " + LEV +
                 " FROM MES_QM_AQL1 A LEFT JOIN MES_QM_AQL2 B ON B.AQL1_ID=A.ID WHERE A.SAMPLE_SIZE_NO='" +
@@ -139,9 +142,13 @@
 
             var maxBillNo = db.Ado.SqlQuerySingle<string>(sql);
 
+            if (string.IsNullOrEmpty(maxBillNo))
+                throw new Exception("娌℃湁" + quantity + "杩欎釜鑼冨洿鐨勬娊鏍峰熀鍑�");
 
             var result = ExtractSubstring(item.FacLevel, '(', ')');
 
+            if (string.IsNullOrEmpty(result))
+                throw new Exception("缁存姢鐨勬帴鏀舵按骞充笉姝g‘锛屽簲璇ユ槸0.010---(AQL_0_0010)鍍忚繖鏍风殑");
 
             sql = "SELECT FSAMPLE_SIZE_WORD, " + result +
                   " Result FROM MES_QM_AQL1 A LEFT JOIN MES_QM_AQL3 C ON C.AQL1_ID=A.ID WHERE A.SAMPLE_SIZE_NO= '" +
@@ -401,9 +408,9 @@
                 .ExecuteCommand();
         });
 
-        if (FcheckResu.Equals("涓嶅悎鏍�"))
-            //鑷姩鐢熸垚鍏ュ簱妫�寮傚父瀵圭瓥
-            saveDetect02(detail.Gid, detail.CreateBy);
+        // if (FcheckResu.Equals("涓嶅悎鏍�"))
+        //     //鑷姩鐢熸垚鍏ュ簱妫�寮傚父瀵圭瓥
+        //     saveDetect02(detail.Gid, detail.CreateBy);
 
         return useTransactionWithOracle;
     }
@@ -453,52 +460,60 @@
     }
 
 
-    public List<QsItemOqcReq> getPage(XJPageResult queryObj)
+    public (List<QsItemOqcReq> items, int TotalCount) getPage(
+        XJPageResult queryObj)
     {
         var db = SqlSugarHelper.GetInstance();
 
-        var id = Convert.ToDecimal(queryObj.id);
+        var totalCount = 0;
 
-        string[]? lineNo = null;
-
-        if (StringUtil.IsNotNullOrEmpty(queryObj.createUser))
-            lineNo = _baseService.getUserLineNo(queryObj.createUser);
-
-        return db.Queryable<QsItemOqcReq, RKJDaa001>((a, b) =>
-                new JoinQueryInfos(JoinType.Left, a.BillNo == b.BillNo))
-            .WhereIF(lineNo != null && lineNo.Length > 0,
-                (a, b) => lineNo.Contains(b.LineNo))
+        var qsItemOqcReqs = db
+            .Queryable<QsItemOqcReq, MesItems, MesInvItemIns, MesInvTransaction,
+                RKJDaa001, Womdaa>(
+                (a, b, c, ca, m, da) => new JoinQueryInfos(
+                    JoinType.Left, a.ItemNo == b.ItemNo,
+                    JoinType.Left, a.BillNo == c.BillNo,
+                    JoinType.Left,
+                    c.TransctionNo == ca.TransactionNo.ToString() &&
+                    c.Company == ca.Company &&
+                    c.Factory == ca.Factory,
+                    JoinType.Left, c.Id == m.ItemInId && a.ItemNo == m.ItemNo,
+                    JoinType.Left, da.Daa001 == c.RbillNo
+                ))
+            .WhereIF(!string.IsNullOrEmpty(queryObj.id),
+                (a, b, c, ca, m, da) => a.Id.ToString() == queryObj.id)
             .WhereIF(
                 StringUtil.IsNotNullOrEmpty(queryObj.result) &&
                 "鏈畬鎴�".Equals(queryObj.result),
-                (a, b) => a.FcheckResu == null)
+                (a, b, c, ca, m, da) => a.FcheckResu == null)
             .WhereIF(
                 StringUtil.IsNotNullOrEmpty(queryObj.result) &&
                 !"鏈畬鎴�".Equals(queryObj.result),
-                (a, b) => a.FcheckResu != null)
-            .WhereIF(id > 0, (a, b) => a.Id == id)
-            .Select((a, b) => new QsItemOqcReq
+                (a, b, c, ca, m, da) => a.FcheckResu != null)
+            .Select((a, b, c, ca, m, da) => new QsItemOqcReq
             {
-                Id = a.Id,
-                ReleaseNo = a.ReleaseNo,
                 BillNo = a.BillNo,
-                LineName = b.LineNo,
-                Quantity = b.Quantity,
-                CreateBy = a.CreateBy,
+                Remarks = a.Remarks,
+                Id = a.Id,
                 CreateDate = a.CreateDate,
-                ItemNo = a.ItemNo,
-                Mocode = b.Mocode,
-                BoardModel = b.BoardModel,
-                TaskNo = b.TaskNo,
+                CreateBy = a.CreateBy,
                 FcheckResu = a.FcheckResu,
+                ItemNo = a.ItemNo,
                 FcheckBy = a.FcheckBy,
                 FcheckDate = a.FcheckDate,
-                MoidNum = a.MoidNum,
-                BoardName = b.BoardName,
-                ColorName = b.ColorName,
-                Remarks = a.Remarks
-            }).OrderBy(a => a.CreateDate, OrderByType.Desc)
-            .ToPageList(queryObj.PageIndex, queryObj.Limit);
+                ReleaseNo = a.ReleaseNo,
+                ItemName = b.ItemName,
+                ItemModel = b.ItemModel,
+                Dab001 = m.LotNo,
+                ItemInId = m.ItemInId,
+                Daa015 = da.Daa015,
+                LineNo = c.LineNo,
+                Quantity = m.Quantity
+            })
+            .OrderBy(a => a.CreateDate, OrderByType.Desc)
+            .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount);
+
+        return (qsItemOqcReqs, totalCount);
     }
 
     //鍒犻櫎涓昏〃骞朵笖杩炵骇鍒犻櫎瀛愯〃鍜屽瓩琛�
@@ -561,6 +576,8 @@
 
     public int UpdateQSItemDetail(QsItemOqcItemDetail detail)
     {
+        if (isRk(detail.ItemInId)) throw new Exception("宸叉湁鏉$爜鍏ュ簱锛屼笉鍏佽淇敼妫�楠岀粨鏋�");
+
         var withOracle = SqlSugarHelper.UseTransactionWithOracle(db =>
         {
             return db.Updateable<QsItemOqcItemDetail>()
@@ -581,6 +598,14 @@
         return withOracle;
     }
 
+    //淇敼缁撴灉鍓嶉獙璇佹槸鍚﹀叆搴�
+    private bool isRk(decimal? ItemInId)
+    {
+        var db = SqlSugarHelper.GetInstance();
+        return db.Queryable<MesInvItemInCDetails>()
+            .Where(s => s.ItemInId == ItemInId).Count() > 0;
+    }
+
 
     //涓昏〃淇敼澶囨敞瀛楁
     public int saveRemarksGid(RKJDto dto)

--
Gitblit v1.9.3