From 82b020497a6e4570a61acf262712bacb757239f3 Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期三, 19 三月 2025 10:36:42 +0800
Subject: [PATCH] 1.来料检验查询优化

---
 service/QC/LljService.cs |   74 ++++++++++++++++++++++++++++++-------
 1 files changed, 60 insertions(+), 14 deletions(-)

diff --git a/service/QC/LljService.cs b/service/QC/LljService.cs
index 64962c0..81d2ed3 100644
--- a/service/QC/LljService.cs
+++ b/service/QC/LljService.cs
@@ -23,16 +23,26 @@
         var totalCount = 0;
 
         var pageList = Db.Queryable<LLJView>()
-            .WhereIF(
-                StringUtil.IsNotNullOrEmpty(queryObj.result) &&
-                "鏈畬鎴�".Equals(queryObj.result),
-                a => a.FcheckResu == null)
-            .WhereIF(
-                StringUtil.IsNotNullOrEmpty(queryObj.result) &&
-                !"鏈畬鎴�".Equals(queryObj.result),
-                a => a.FcheckResu != null)
+            //.WhereIF(
+            //    StringUtil.IsNotNullOrEmpty(queryObj.result) &&
+            //    "鏈畬鎴�".Equals(queryObj.result),
+            //    a => (a.STATUS ?? "") != "宸叉彁浜�")
+            //    //a => (a.FcheckResu ?? "") == ""|| (a.FcheckResu ?? "") == "妫�楠屼腑")
+            //.WhereIF(
+            //    StringUtil.IsNotNullOrEmpty(queryObj.result) &&
+            //    !"鏈畬鎴�".Equals(queryObj.result),
+            //    a => (a.STATUS ?? "") == "宸叉彁浜�")
+
+            .WhereIF(!string.IsNullOrWhiteSpace(queryObj.keyword), a =>
+                a.ItemNo.Contains(queryObj.keyword) ||
+                a.ItemName.Contains(queryObj.keyword) ||
+                a.LotNo.Contains(queryObj.keyword) ||
+                a.ReleaseNo.Contains(queryObj.keyword) ||
+                a.SuppName.Contains(queryObj.keyword) 
+            )
             .WhereIF(UtilityHelper.CheckGuid(parsedGuid),
-                a => a.guid == parsedGuid)
+                a => a.guid == parsedGuid )
+            .Where(a => (a.fsubmit ?? 0) == 0)
             .OrderByDescending(a => a.CreateDate)
             .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount);
 
@@ -144,7 +154,7 @@
         {
             foreach (var item in items) item.ReleaseNo = rkjDto.releaseNo;
 
-            return db.Insertable(items).ExecuteCommand();
+            return db.Insertable(items).IgnoreColumns(true).ExecuteCommand();
         });
 
         rkjDto.items = GetItems(rkjDto.releaseNo, null);
@@ -186,16 +196,27 @@
     }
 
     public List<MesQaItemsDetectDetail5> GetItems(string? releaseNo,
-        decimal? id)
+        string? id)
     {
+        var parsedGuid = Guid.Empty;
+
+        if (id != null)
+        {
+            var isValid = Guid.TryParse(id, out parsedGuid);
+            if (!isValid)
+                throw new ApplicationException("GUID杞崲閿欒");
+        }
+
         return Db.Queryable<MesQaItemsDetectDetail5, MesQaItemsDetectDetail12>(
                 (a, b) =>
                     new JoinQueryInfos(JoinType.Left, a.Guid == b.ParentGuid))
             .Where((a, b) => a.ReleaseNo == releaseNo)
-            // .WhereIF(id > 0, (a, b) => a.Id == id)
+            .WhereIF(UtilityHelper.CheckGuid(parsedGuid),
+                (a, b) => a.Guid == parsedGuid)
             .GroupBy((a, b) => new
             {
                 a.Guid,
+                a.ParentGuid,
                 a.ReleaseNo,
                 a.FacLevel,
                 a.FcheckItem,
@@ -212,6 +233,7 @@
             }).Select((a, b) => new MesQaItemsDetectDetail5
             {
                 Guid = a.Guid,
+                ParentGuid = a.ParentGuid,
                 ReleaseNo = a.ReleaseNo,
                 CheckQyt = a.CheckQyt,
                 FacLevel = a.FacLevel,
@@ -240,6 +262,8 @@
             {
                 var item = new MesQaItemsDetectDetail12();
                 item.ParentGuid = detail.ParentGuid;
+                item.GrandpaGuid = detail.GrandpaGuid;
+                item.FcheckItem = detail.FcheckItem;
                 item.Fstand = detail.Fstand;
                 item.FcheckResu = detail.FcheckResu;
                 item.CreateBy = detail.LastupdateBy;
@@ -247,7 +271,7 @@
                 result.Add(item);
             }
 
-            return db.Insertable(result).ExecuteCommand();
+            return db.Insertable(result).PageSize(1).IgnoreColumnsNull().ExecuteCommand();
         });
 
         detail.CreateBy = detail.LastupdateBy;
@@ -299,6 +323,7 @@
                 commit += db.Updateable<MesQaItemsDetectDetail5>()
                     .SetColumns(s => s.FcheckResu == result)
                     .SetColumns(s => s.FenterQty == count)
+                    .SetColumns(s => s.FngRate == (s.CheckQyt == 0 ? (decimal?)null : (decimal?)(Convert.ToDouble(noCount) / Convert.ToDouble(count))))
                     .Where(s => s.Guid == detail.ParentGuid)
                     .ExecuteCommand();
 
@@ -431,6 +456,16 @@
             .Where(s => s.ParentGuid == parsedGuid)
             .ToList();
 
+        foreach (var mesQaItemsDetectDetail12 in rkjDto.ItemXj02s)
+        {
+            //this.formData.fupAllow && this.formData.fdownAllow && this.formData.fstand
+            mesQaItemsDetectDetail12.isNumber = true;
+            if (qsItemOqcItem.FupAllow.IsNullOrEmpty()
+                && qsItemOqcItem.FdownAllow.IsNullOrEmpty()
+                && qsItemOqcItem.Fstand == null)
+                mesQaItemsDetectDetail12.isNumber = false;
+        }
+
         return rkjDto;
     }
 
@@ -554,7 +589,7 @@
             throw new Exception("璇ユ楠屽崟宸叉彁浜�");
 
         if (mesQaItemsDetect01.FcheckDate == null)
-            throw new Exception("璇ユ娴嬪崟鏈緭鍏ユ楠屾棩鏈燂紝璇锋牳瀵广��");
+            throw new Exception("璇ユ娴嬪崟娌℃湁妫�楠屽畬鎴愶紝璇锋牳瀵广��");
 
         if (mesQaItemsDetect01.FcheckBy.IsNullOrEmpty())
             throw new Exception("璇ユ娴嬪崟鏈緭鍏ユ楠屼汉鍛橈紝璇锋牳瀵广��");
@@ -671,4 +706,15 @@
 
         return com > 0;
     }
+
+    public int[] getBadge()
+    {
+        var isNullCount = Db.Queryable<MesQaItemsDetect01>()
+            .Where(a => (a.FcheckResu ?? "") == "").Count();
+
+        var isNotNullCount = Db.Queryable<MesQaItemsDetect01>()
+            .Where(a => (a.FcheckResu ?? "") != "").Count();
+
+        return [isNullCount, isNotNullCount];
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3