From c5a3cfd2cd3e140892fc93cc52902b5b204a50d5 Mon Sep 17 00:00:00 2001
From: hao <1836460075@qq.com>
Date: 星期六, 23 八月 2025 10:03:01 +0800
Subject: [PATCH] Merge branch 'master' of http://43.142.96.171:8080/r/~yhj/HM_JK

---
 StandardInterface/MES.Service/Dto/service/XJPageResult.cs |    6 ++
 StandardInterface/MES.Service/service/QC/LljService.cs    |  107 ++++++++++++++++++++---------------
 StandardInterface/MES.Service/Modes/V_LljUser.cs          |   23 +++++++
 StandardInterface/MES.Service/Modes/LtsLlj.cs             |    6 ++
 4 files changed, 97 insertions(+), 45 deletions(-)

diff --git a/StandardInterface/MES.Service/Dto/service/XJPageResult.cs b/StandardInterface/MES.Service/Dto/service/XJPageResult.cs
index 71220c0..fd8e155 100644
--- a/StandardInterface/MES.Service/Dto/service/XJPageResult.cs
+++ b/StandardInterface/MES.Service/Dto/service/XJPageResult.cs
@@ -15,4 +15,10 @@
 
     public string? fsubmit { get; set; }
 
+    /// <summary>
+    /// 鎼滅储鏉′欢绱㈠紩锛岀敤浜庢寚瀹氭悳绱㈠摢涓瓧娈�
+    /// 0: 椤圭洰(涓嶇瓫閫�), 1: 鐗╂枡缂栧彿, 2: 鐗╂枡鍚嶇О, 3: 渚涘簲鍟�, 4: 鍒拌揣鍗曞彿, 5: 妫�楠屽崟鍙�, 6: 鐗╂枡瑙勬牸
+    /// </summary>
+    public int? selectedIndex { get; set; }
+
 }
\ No newline at end of file
diff --git a/StandardInterface/MES.Service/Modes/LtsLlj.cs b/StandardInterface/MES.Service/Modes/LtsLlj.cs
index 710ac3d..1c07f99 100644
--- a/StandardInterface/MES.Service/Modes/LtsLlj.cs
+++ b/StandardInterface/MES.Service/Modes/LtsLlj.cs
@@ -233,6 +233,12 @@
     [SugarColumn(IsIgnore = true)]
     public int? InspectionItemCount { get; set; }
 
+    /// <summary>
+    ///     缁存姢浜哄憳璐﹀彿锛堟潵鑷猇_LLJ_USER瑙嗗浘锛岄潪鏁版嵁搴撳瓧娈碉級
+    /// </summary>
+    [SugarColumn(IsIgnore = true)]
+    public string? Fcode { get; set; }
+
 
 
 }
\ No newline at end of file
diff --git a/StandardInterface/MES.Service/Modes/V_LljUser.cs b/StandardInterface/MES.Service/Modes/V_LljUser.cs
new file mode 100644
index 0000000..a981769
--- /dev/null
+++ b/StandardInterface/MES.Service/Modes/V_LljUser.cs
@@ -0,0 +1,23 @@
+using SqlSugar;
+
+namespace MES.Service.Modes;
+
+/// <summary>
+/// V_LLJ_USER 瑙嗗浘妯″瀷
+/// 鐢ㄤ簬鏌ヨ鐗╂枡鏄惁琚淮鎶や互鍙婄淮鎶や汉鍛樹俊鎭�
+/// </summary>
+[SugarTable("V_LLJ_USER")]
+public class V_LljUser
+{
+    /// <summary>
+    /// 缁存姢浜哄憳璐﹀彿
+    /// </summary>
+    [SugarColumn(ColumnName = "FCODE")]
+    public string? Fcode { get; set; }
+
+    /// <summary>
+    /// 鐗╂枡缂栧彿
+    /// </summary>
+    [SugarColumn(ColumnName = "ITEM_NO")]
+    public string? ItemNo { get; set; }
+}
diff --git a/StandardInterface/MES.Service/service/QC/LljService.cs b/StandardInterface/MES.Service/service/QC/LljService.cs
index 2e9fae5..34a4694 100644
--- a/StandardInterface/MES.Service/service/QC/LljService.cs
+++ b/StandardInterface/MES.Service/service/QC/LljService.cs
@@ -24,62 +24,79 @@
 
         var totalCount = 0;
 
-        var pageList = db.Queryable<LtsLlj, IqcBefore, SysUser,
-                IqcBeforeFrom, SysUser, SysUser>((a, b,
-                    e, f, g, i) =>
-                new JoinQueryInfos(JoinType.Left, a.ItemId == b.ItemId,
-                    JoinType.Left, a.CreateBy == e.Fcode,
-                    JoinType.Left, f.Id == b.Pid,
-                    JoinType.Left, f.Sid == Convert.ToDecimal(g.Fid),
-                    JoinType.Left, f.CheckUser == i.Fcode
-                ))
+        var pageList = db.Queryable<LtsLlj, V_LljUser>((a, v) =>
+                new JoinQueryInfos(JoinType.Left, a.ItemNo == v.ItemNo))
             .WhereIF(
                 StringUtil.IsNotNullOrEmpty(queryObj.result) &&
                 "鏈畬鎴�".Equals(queryObj.result),
-                (a, b,
-                    e, f, g, i) => a.FcheckResu == null)
+                (a, v) => a.FcheckResu == null)
             .WhereIF(
                 StringUtil.IsNotNullOrEmpty(queryObj.result) &&
                 !"鏈畬鎴�".Equals(queryObj.result),
-                (a, b,
-                    e, f, g, i) => a.FcheckResu != null)
-            .WhereIF(id > 0, (a, b,
-                    e, f, g, i) => a.Id == id)
-            .WhereIF(queryObj.createUser != "PL017" && queryObj.createUser != "HMLYY" && queryObj.UserIndex == "0", (a, b,
-                    e, f, g, i) => (g.Fcode == queryObj.createUser || i.Fcode == queryObj.createUser || 
-                                   (g.Fcode == null && i.Fcode == null)))//鍒ゆ柇姝ゅ崟鐨勬楠屽憳锛屾垨鑰呮楠屼负绌哄氨鏄剧ず姝ゅ崟鎹�
+                (a, v) => a.FcheckResu != null)
+            .WhereIF(id > 0, (a, v) => a.Id == id)
+            // 鏉冮檺鎺у埗锛歅L017銆丠MLYY銆丠MCS 鍙互鐪嬪埌鎵�鏈夊崟鎹紝鍏朵粬鐢ㄦ埛闇�瑕佹牴鎹墿鏂欑淮鎶ゆ儏鍐靛垽鏂�
+            .WhereIF(queryObj.createUser != "PL017" && queryObj.createUser != "HMLYY" && queryObj.createUser != "HMCS" && queryObj.UserIndex == "0", 
+                (a, v) => 
+                    // 濡傛灉鐗╂枡琚淮鎶わ紝鍙湁缁存姢浜哄憳鍙互鐪嬪埌
+                    (v.Fcode != null && v.Fcode == queryObj.createUser) ||
+                    // 濡傛灉鐗╂枡鏈缁存姢锛屾墍鏈変汉閮藉彲浠ョ湅鍒�
+                    (v.Fcode == null))
 
-            //鍔犵瓫閫夋潯浠�,鏍规嵁渚涘簲鍟嗭紝鐗╂枡缂栫爜锛岀墿鏂欏悕绉版悳绱�
-            //.WhereIF(queryObj.SearchValue!=null && queryObj.SearchValue!="", (a) => a.SuppName == queryObj.SearchValue|| a.ItemName == queryObj.SearchValue || a.ItemNo == queryObj.SearchValue )
-            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue),
-                (a, b,
-                    e, f, g, i) => a.SuppName.ToLower()
-                         .Contains(queryObj.SearchValue.ToLower())
-                     || a.ItemName.ToLower()
-                         .Contains(queryObj.SearchValue.ToLower())
-                     || a.ItemNo.ToLower()
-                         .Contains(queryObj.SearchValue.ToLower())
-                     || a.LotNo.ToLower()
-                        .Contains(queryObj.SearchValue.ToLower())
-                     || a.ReleaseNo.ToLower()
-                        .Contains(queryObj.SearchValue.ToLower())
-                     || a.ItemModel.ToLower()
-                        .Contains(queryObj.SearchValue.ToLower()))
-            //  .OrderByDescending((a, b,
-
-            .OrderBy("CASE WHEN a.EMERGENCY = 1 THEN 0 ELSE 1 END, CASE WHEN a.STATUS = '宸叉彁浜�' THEN 0 ELSE 1 END, a.IQC_DATE desc, a.ID asc")
+            //鍔犵瓫閫夋潯浠�,鏍规嵁閫夋嫨鐨勬悳绱㈠瓧娈佃繘琛岀簿纭悳绱�
+            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 1, // 鐗╂枡缂栧彿鎼滅储
+                (a, v) => a.ItemNo != null && a.ItemNo.ToLower().Contains(queryObj.SearchValue.ToLower()))
+            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 2, // 鐗╂枡鍚嶇О鎼滅储
+                (a, v) => a.ItemName != null && a.ItemName.ToLower().Contains(queryObj.SearchValue.ToLower()))
+            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 3, // 渚涘簲鍟嗘悳绱�
+                (a, v) => a.SuppName != null && a.SuppName.ToLower().Contains(queryObj.SearchValue.ToLower()))
+            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 4, // 鍒拌揣鍗曞彿鎼滅储
+                (a, v) => a.LotNo != null && a.LotNo.ToLower().Contains(queryObj.SearchValue.ToLower()))
+            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 5, // 妫�楠屽崟鍙锋悳绱�
+                (a, v) => a.ReleaseNo != null && a.ReleaseNo.ToLower().Contains(queryObj.SearchValue.ToLower()))
+            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 6, // 鐗╂枡瑙勬牸鎼滅储
+                (a, v) => a.ItemModel != null && a.ItemModel.ToLower().Contains(queryObj.SearchValue.ToLower()))
+            .Select((a, v) => new LtsLlj
+            {
+                Id = a.Id,
+                ItemNo = a.ItemNo,
+                ItemName = a.ItemName,
+                ItemModel = a.ItemModel,
+                SuppName = a.SuppName,
+                LotNo = a.LotNo,
+                ReleaseNo = a.ReleaseNo,
+                FcheckResu = a.FcheckResu,
+                CreateDate = a.CreateDate,
+                FcovertQty = a.FcovertQty,
+                DEPARTMENTNAME = a.DEPARTMENTNAME,
+                FngDesc = a.FngDesc,
+                UrgentFlag = a.UrgentFlag,
+                Ftype = a.Ftype,
+                LotNo1 = a.LotNo1,
+                EMERGENCY = a.EMERGENCY,
+                Status = a.Status,
+                IqcDate = a.IqcDate,
+                // 娣诲姞缁存姢浜哄憳淇℃伅
+                Fcode = v.Fcode
+            })
+            .OrderBy("CASE WHEN EMERGENCY = 1 THEN 0 ELSE 1 END, CASE WHEN STATUS = '宸叉彁浜�' THEN 0 ELSE 1 END, IQC_DATE desc, ID asc")
             .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount);
 
-        // 涓烘瘡涓楠屽崟娣诲姞妫�楠岄」鐩暟閲忎俊鎭�
-        foreach (var item in pageList)
+        // 鎵归噺鑾峰彇妫�楠岄」鐩暟閲忥紝閬垮厤N+1鏌ヨ闂
+        if (pageList.Any())
         {
-            // 鑾峰彇璇ユ楠屽崟鐨勬楠岄」鐩暟閲�
-            var itemCount = db.Queryable<MesQaItemsDetectDetail5>()
-                .Where(x => x.ReleaseNo == item.ReleaseNo)
-                .Count();
+            var releaseNos = pageList.Select(x => x.ReleaseNo).Distinct().ToList();
             
-            // 璁剧疆妫�楠岄」鐩暟閲�
-            item.InspectionItemCount = itemCount;
+            // 涓烘瘡涓楠屽崟璁剧疆妫�楠岄」鐩暟閲忓拰NewFngDesc瀛楁
+            foreach (var item in pageList)
+            {
+                var count = db.Queryable<MesQaItemsDetectDetail5>()
+                    .Where(x => x.ReleaseNo == item.ReleaseNo)
+                    .Count();
+                item.InspectionItemCount = count;
+                
+                item.NewFngDesc = item.FngDesc; 
+            }
         }
         
         var emergencyValues = pageList.Select(item => item.EMERGENCY).ToList(); 

--
Gitblit v1.9.3