From cb23d88faf0bd112db57816c5cc02e47eb685324 Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期一, 13 一月 2025 10:56:10 +0800
Subject: [PATCH] 11

---
 service/QC/LljService.cs |   77 +++++++++++++++++++++++++-------------
 1 files changed, 51 insertions(+), 26 deletions(-)

diff --git a/service/QC/LljService.cs b/service/QC/LljService.cs
index d46b42c..fce4be8 100644
--- a/service/QC/LljService.cs
+++ b/service/QC/LljService.cs
@@ -1,12 +1,9 @@
-锘縰sing System.Data;
-using Microsoft.IdentityModel.Tokens;
+锘縰sing Microsoft.IdentityModel.Tokens;
 using NewPdaSqlServer.DB;
 using NewPdaSqlServer.Dto.service;
 using NewPdaSqlServer.entity;
 using NewPdaSqlServer.util;
 using SqlSugar;
-using DbType = System.Data.DbType;
-
 
 namespace NewPdaSqlServer.service.QC;
 
@@ -17,7 +14,7 @@
         var parsedGuid = Guid.Empty;
         if (!queryObj.id.IsNullOrEmpty())
         {
-            bool isValid = Guid.TryParse(queryObj.id, out parsedGuid);
+            var isValid = Guid.TryParse(queryObj.id, out parsedGuid);
             if (!isValid)
                 throw new ApplicationException("GUID杞崲閿欒");
         }
@@ -29,11 +26,11 @@
             .WhereIF(
                 StringUtil.IsNotNullOrEmpty(queryObj.result) &&
                 "鏈畬鎴�".Equals(queryObj.result),
-                a => a.FcheckResu == null)
+                a => (a.FcheckResu ?? "") == "")
             .WhereIF(
                 StringUtil.IsNotNullOrEmpty(queryObj.result) &&
                 !"鏈畬鎴�".Equals(queryObj.result),
-                a => a.FcheckResu != null)
+                a => (a.FcheckResu ?? "") != "")
             .WhereIF(UtilityHelper.CheckGuid(parsedGuid),
                 a => a.guid == parsedGuid)
             .OrderByDescending(a => a.CreateDate)
@@ -74,7 +71,7 @@
 
         mesQaIqcItem.ForEach(item =>
         {
-            string LEV = item.FcheckLevel switch
+            var LEV = item.FcheckLevel switch
             {
                 null => "" // 榛樿鍊�
                 ,
@@ -147,7 +144,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);
@@ -189,16 +186,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,
@@ -215,6 +223,7 @@
             }).Select((a, b) => new MesQaItemsDetectDetail5
             {
                 Guid = a.Guid,
+                ParentGuid = a.ParentGuid,
                 ReleaseNo = a.ReleaseNo,
                 CheckQyt = a.CheckQyt,
                 FacLevel = a.FacLevel,
@@ -243,6 +252,7 @@
             {
                 var item = new MesQaItemsDetectDetail12();
                 item.ParentGuid = detail.ParentGuid;
+                item.GrandpaGuid = detail.GrandpaGuid;
                 item.Fstand = detail.Fstand;
                 item.FcheckResu = detail.FcheckResu;
                 item.CreateBy = detail.LastupdateBy;
@@ -250,7 +260,7 @@
                 result.Add(item);
             }
 
-            return db.Insertable(result).ExecuteCommand();
+            return db.Insertable(result).IgnoreColumns(true).ExecuteCommand();
         });
 
         detail.CreateBy = detail.LastupdateBy;
@@ -402,12 +412,9 @@
     {
         var rkjDto = new LLJDto();
 
-        bool isValid = Guid.TryParse(id, out var parsedGuid);
+        var isValid = Guid.TryParse(id, out var parsedGuid);
 
-        if (!isValid)
-        {
-            throw new Exception("GUID杞崲閿欒");
-        }
+        if (!isValid) throw new Exception("GUID杞崲閿欒");
 
         var qsItemOqcItem =
             Db.Queryable<MesQaItemsDetectDetail5>()
@@ -436,6 +443,16 @@
         rkjDto.ItemXj02s = Db.Queryable<MesQaItemsDetectDetail12>()
             .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;
     }
@@ -502,10 +519,9 @@
     //瀛愯〃淇敼澶囨敞瀛楁
     public int saveRemarksPid(LLJDto dto)
     {
-        bool isValid = Guid.TryParse(dto.pid, out var parsedGuid);
+        var isValid = Guid.TryParse(dto.pid, out var parsedGuid);
 
         if (isValid)
-        {
             return UseTransaction(db =>
             {
                 return db.Updateable<MesQaItemsDetectDetail5>()
@@ -514,7 +530,6 @@
                     .Where(it => it.Guid == parsedGuid)
                     .ExecuteCommand();
             });
-        }
 
         throw new Exception("GUID杞崲閿欒");
     }
@@ -577,11 +592,9 @@
         {
             mesQaItemsDetectDetail5.FenterQty ??= 0;
             if (mesQaItemsDetectDetail5.FenterQty == 0)
-            {
                 throw new Exception("妫�楠岄」鐩�:" +
                                     mesQaItemsDetectDetail5.FcheckItem +
                                     " 宸插綍鍏ユ暟閲忎负0锛岃纭銆�");
-            }
         }
 
         var com = UseTransaction(db =>
@@ -643,7 +656,7 @@
                         TotalOkRkQty = SqlFunc.AggregateSum(b.OkRkqty)
                     })
                     .First();
-                
+
                 var totalQuantity = first.TotalQuantity ?? 0;
                 var totalOkRkQty = first.TotalOkRkQty ?? 0;
 
@@ -658,12 +671,13 @@
                 executeCommand += db.Updateable<MesInvItemArnDetail>()
                     .SetColumns(s => s.CheckStates == "涓嶅悎鏍煎緟瀹℃壒")
                     .SetColumns(s => s.Ischeck == 1)
-                    .SetColumns(s => s.CheckRes == mesQaItemsDetect01.FcheckResu)
+                    .SetColumns(
+                        s => s.CheckRes == mesQaItemsDetect01.FcheckResu)
                     .SetColumns(s => s.CheckDate == DateTime.Now)
                     .Where(s => s.ParentGuid == mesInvItemArn.Guid
                                 && s.ItemId == mesQaItemsDetect01.ItemId)
                     .ExecuteCommand();
-                
+
                 executeCommand += db.Updateable<MesQaItemsDetect01>()
                     .SetColumns(s => s.IqcDate == DateTime.Now)
                     .SetColumns(s => s.FcheckDate == DateTime.Now)
@@ -672,7 +686,7 @@
                     .ExecuteCommand();
             }
 
-            if (executeCommand >=3)
+            if (executeCommand >= 3)
                 return executeCommand;
 
             throw new Exception("鏇存柊澶辫触");
@@ -680,4 +694,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