From 86c6a1651795676219683797a33ae61531e769d5 Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期六, 09 八月 2025 17:01:19 +0800
Subject: [PATCH] 11

---
 MES.Service/service/QC/SJService.cs |  128 +++++++++++++++++++++++++++++++++---------
 1 files changed, 101 insertions(+), 27 deletions(-)

diff --git a/MES.Service/service/QC/SJService.cs b/MES.Service/service/QC/SJService.cs
index 50e6160..56acb22 100644
--- a/MES.Service/service/QC/SJService.cs
+++ b/MES.Service/service/QC/SJService.cs
@@ -3,6 +3,9 @@
 using MES.Service.Modes;
 using MES.Service.util;
 using SqlSugar;
+using DbType = System.Data.DbType;
+using System.Data;
+using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
 
 namespace MES.Service.service.QC;
 
@@ -34,11 +37,13 @@
     }
 
     //鑾峰彇鎵�鏈夋暟鎹垎椤�
-    public List<SJPageResult> getPage(SJPageResult queryObj)
+    public (List<SJPageResult> items, int totalCount) getPage(SJPageResult queryObj)
     {
         var db = SqlSugarHelper.GetInstance();
 
         string[]? lineNo = null;
+
+        int totalCount = 0;
 
         //if (StringUtil.IsNotNullOrEmpty(queryObj.StatusUser))
         //    lineNo = _baseService.getUserLineNo(queryObj.StatusUser);
@@ -52,15 +57,15 @@
             .WhereIF(
                 StringUtil.IsNotNullOrEmpty(queryObj.Result) &&
                 "鏈畬鎴�".Equals(queryObj.Result),
-                a => a.Remarks == queryObj.Result)
+                a => a.FSubmit == "0")
             .WhereIF(
                 StringUtil.IsNotNullOrEmpty(queryObj.Result) &&
                 !"鏈畬鎴�".Equals(queryObj.Result),
-                a => a.Remarks != "鏈畬鎴�")
-            .OrderBy(a => a.BillNo, OrderByType.Desc)
-            .ToPageList(queryObj.PageIndex, queryObj.Limit);
+                a => a.FSubmit == "1")
+            .OrderBy(a => a.CreateTime, OrderByType.Desc);
+        var items = data.ToPageList(queryObj.PageIndex, queryObj.Limit,ref totalCount);
 
-        return data;
+        return (items, totalCount);
     }
 
 
@@ -223,7 +228,7 @@
         item.Items = getQSItems(qsItemIpiReq.Id, null);
         var sjPageResult = new SJPageResult
             { Id = item.From.Id, Limit = 1, PageIndex = 1 };
-        item.Result = getPage(sjPageResult)[0];
+        item.Result = getPage(sjPageResult).items[0];
 
         return item;
     }
@@ -347,28 +352,28 @@
         if (icount == 0) return 1;
 
         //瀹為檯涓暟绛変簬鐞嗚涓暟鏃跺妫�楠屽崟杩涜鍒ゅ畾
-        if (sum == icount)
-        {
-            result = 0;
+        //if (sum == icount)
+        //{
+        //    result = 0;
 
-            //鑾峰彇杩欎釜妫�楠屽崟涓嬬殑鎵�鏈夊悎鏍肩殑妫�楠岀粨鏋�
-            passCount = db.Queryable<QsItemIpiItemDetail>()
-                .Where(s => s.Gid == detail.Gid && s.Fstand == "鈭�").Count();
+        //    //鑾峰彇杩欎釜妫�楠屽崟涓嬬殑鎵�鏈夊悎鏍肩殑妫�楠岀粨鏋�
+        //    passCount = db.Queryable<QsItemIpiItemDetail>()
+        //        .Where(s => s.Gid == detail.Gid && s.Fstand == "鈭�").Count();
 
-            //鍚堟牸鐨勬楠岀粨鏋滅瓑浜庢�绘楠屾暟瑙嗕负鍚堟牸
-            if (icount == passCount) result = 1;
+        //    //鍚堟牸鐨勬楠岀粨鏋滅瓑浜庢�绘楠屾暟瑙嗕负鍚堟牸
+        //    if (icount == passCount) result = 1;
 
-            useTransactionWithOracle += SqlSugarHelper.UseTransactionWithOracle(
-                db =>
-                {
-                    return db.Updateable<QsItemIpiReq>()
-                        .SetColumns(s => s.IsPass == result)
-                        .SetColumns(s => s.StatusUser == detail.CreateBy)
-                        .SetColumns(s => s.CompleteTime == DateTime.Now)
-                        .Where(s => s.Id == detail.Gid)
-                        .ExecuteCommand();
-                });
-        }
+        //    useTransactionWithOracle += SqlSugarHelper.UseTransactionWithOracle(
+        //        db =>
+        //        {
+        //            return db.Updateable<QsItemIpiReq>()
+        //                .SetColumns(s => s.IsPass == result)
+        //                .SetColumns(s => s.StatusUser == detail.CreateBy)
+        //                .SetColumns(s => s.CompleteTime == DateTime.Now)
+        //                .Where(s => s.Id == detail.Gid)
+        //                .ExecuteCommand();
+        //        });
+        //}
 
         return useTransactionWithOracle;
     }
@@ -390,7 +395,7 @@
 
         detail.CreateBy = detail.UpdateBy;
 
-        withOracle += autoResult(detail);
+        // withOracle += autoResult(detail);
 
         return withOracle;
     }
@@ -455,4 +460,73 @@
 
         return withOracle;
     }
+
+    public bool SJQaSubmit(QsItem item)
+    {
+
+        if (item == null)
+            throw new ArgumentNullException(nameof(item), "璐ㄦ椤规暟鎹笉鑳戒负绌�");
+
+        if (string.IsNullOrWhiteSpace(item.userNo))
+            throw new ArgumentException("鐢ㄦ埛缂栧彿涓嶈兘涓虹┖", nameof(item.userNo));
+
+        var (factory, company) = UserUtil.GetFactory(item.userNo);
+        try
+        {
+            // 瀹氫箟杈撳嚭鍙傛暟
+            var outputResult = new SugarParameter("o_Result", null, DbType.Int32, ParameterDirection.Output,
+                4000);
+
+            var outputMessage = new SugarParameter("o_Msg", null, DbType.String, ParameterDirection.Output, 4000);
+
+            // 瀹氫箟杈撳叆鍙傛暟
+            var parameters = new List<SugarParameter>
+         {
+
+             new("p_Id", item.gid, DbType.Int32,ParameterDirection.Input),
+             new("p_Flag", 1, DbType.Int32,ParameterDirection.Input),
+             new("p_User", item.userNo, DbType.String, ParameterDirection.Input),
+             outputResult,
+             outputMessage
+         };
+
+            var db = SqlSugarHelper.GetInstance();
+
+            // 浣跨敤 SqlSugar 鎵ц瀛樺偍杩囩▼
+            db.Ado.ExecuteCommand(
+                "BEGIN PRC_WOMDAA_SJ_UPDATE_RES(:p_Id,:p_Flag,:p_User,:o_Result, :o_Msg); END;",
+                parameters.ToArray());
+
+            // 鑾峰彇杈撳嚭鍙傛暟鐨勫��
+            var resultValue = outputResult.Value?.ToString();
+            var messageValue = outputMessage.Value?.ToString();
+
+            if ("1".Equals(resultValue)) { throw new Exception(messageValue); }
+            if ("0".Equals(resultValue)) { throw new Exception(messageValue); }
+
+            return true;
+        }
+        catch (Exception ex)
+        {
+            throw new Exception(ex.Message);
+        }
+    }
+
+    /// <summary>
+    /// 鏇存柊QsItemIpiItem鐨処sPass鍊�
+    /// </summary>
+    /// <param name="id">QsItemIpiItem鐨処D</param>
+    /// <param name="isPass">IsPass鐨勫��(0琛ㄧず涓嶅悎鏍�,1琛ㄧず鍚堟牸)</param>
+    /// <returns>鏇存柊褰卞搷鐨勮鏁�</returns>
+    public int UpdateQsItemIpiItemIsPass(decimal id, decimal isPass)
+    {
+        return SqlSugarHelper.UseTransactionWithOracle(db =>
+        {
+            return db.Updateable<QsItemIpiItem>()
+                .SetColumns(s => s.IsPass == isPass)
+                .Where(s => s.Id == id)
+                .ExecuteCommand();
+        });
+    }
+
 }
\ No newline at end of file

--
Gitblit v1.9.3