From 90e42f99c2b3a4b8226e9a6951c2b7b9a968df10 Mon Sep 17 00:00:00 2001
From: zyf <1071160500@qq.com>
Date: 星期五, 22 八月 2025 14:38:46 +0800
Subject: [PATCH] 入库检新增销售订单号

---
 MES.Service/service/QC/RKJService.cs |  532 +++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 411 insertions(+), 121 deletions(-)

diff --git a/MES.Service/service/QC/RKJService.cs b/MES.Service/service/QC/RKJService.cs
index 8656f8a..886d05b 100644
--- a/MES.Service/service/QC/RKJService.cs
+++ b/MES.Service/service/QC/RKJService.cs
@@ -67,107 +67,165 @@
     //鏍规嵁妫�楠屾爣鍑嗘潵璁$畻妫�楠屼釜鏁�
     public List<QsItemOqcItem> SetItems(string itemNo, decimal quantity)
     {
+        // 鍙傛暟楠岃瘉
+        if (string.IsNullOrWhiteSpace(itemNo))
+            throw new ArgumentException("鐗╂枡缂栧彿涓嶈兘涓虹┖", nameof(itemNo));
+
+        if (quantity <= 0)
+            throw new ArgumentException("鏁伴噺蹇呴』澶т簬0", nameof(quantity));
+
         var db = SqlSugarHelper.GetInstance();
 
-        var count = db.Queryable<MesQa>().Where(s => s.QsType == "3"
-            && s.ItemNo == itemNo && s.Fsubmit == 1).Count();
+        // 楠岃瘉鐗╂枡鏄惁瀛樺湪妫�楠屾爣鍑�
+        var count = db.Queryable<MesQa>()
+            .Where(s => s.QsType == "3" && s.ItemNo == itemNo && s.Fsubmit == 1)
+            .Count();
 
-        if (count <= 0) return [];
+        if (count <= 0)
+            return [];
 
-        var qsItemOqcItems = db
-            .Queryable<MesQualityStandard>()
-            .Where(b => b.QsType == "3"
-                        && b.ItemNo == itemNo).Select(
-                b => new QsItemOqcItem
-                {
-                    ProjName = b.ProjName,
-                    ItemMod = b.ItemMod,
-                    InspectionMethod = b.InspectionMethod,
-                    UsingInstruments = b.UsingInstruments,
-                    LevelNum = SqlFunc.IsNull(
-                        SqlFunc.IsNull(b.LevelNum * b.InspectionLevel, 1),
-                        b.InspectionLevel),
-                    MaxValue = b.MaxValue,
-                    StandardValue = b.StandardValue,
-                    MinValue = b.MinValue,
-                    Notes = b.Notes,
-                    FcheckLevel = b.FcheckLevel,
-                    FacLevel = b.FacLevel,
-                    QsCode = b.QsCode,
-                    QsName = b.QsName,
-                    Result = "鏈娴�",
-                    isCheck = 0,
-                    Picture = b.Picture,
-                    Picturename = b.Picturename
-                }).ToList();
-
-        qsItemOqcItems.ForEach(item =>
-        {
-            string LEV = null;
-            switch (item.FcheckLevel)
+        // 鑾峰彇璐ㄩ噺鏍囧噯
+        var qsItemOqcItems = db.Queryable<MesQualityStandard>()
+            .Where(b => b.QsType == "3" && b.ItemNo == itemNo)
+            .Select(b => new QsItemOqcItem
             {
-                case string s when s.Contains("S1"):
-                    LEV = "B.FLEVEL_S1";
-                    break;
-                case string s when s.Contains("S2"):
-                    LEV = "B.FLEVEL_S2";
-                    break;
-                case string s when s.Contains("S3"):
-                    LEV = "B.FLEVEL_S3";
-                    break;
-                case string s when s.Contains("S4"):
-                    LEV = "B.FLEVEL_S4";
-                    break;
-                case string s when s.Contains("(I)"):
-                    LEV = "B.FLEVEL_I";
-                    break;
-                case string s when s.Contains("(II)"):
-                    LEV = "B.FLEVEL_II";
-                    break;
-                case string s when s.Contains("(III)"):
-                    LEV = "B.FLEVEL_III";
-                    break;
-                default:
-                    LEV = ""; // 榛樿鍊�
-                    break;
+                ProjName = b.ProjName,
+                ItemMod = b.ItemMod,
+                InspectionMethod = b.InspectionMethod,
+                UsingInstruments = b.UsingInstruments,
+                LevelNum = SqlFunc.IsNull(
+                    SqlFunc.IsNull(b.LevelNum * b.InspectionLevel, 1),
+                    b.InspectionLevel),
+                MaxValue = b.MaxValue,
+                StandardValue = b.StandardValue,
+                MinValue = b.MinValue,
+                Notes = b.Notes,
+                FcheckLevel = b.FcheckLevel,
+                FacLevel = b.FacLevel,
+                QsCode = b.QsCode,
+                QsName = b.QsName,
+                Result = "鏈娴�",
+                isCheck = 0,
+                Picture = b.Picture,
+                Picturename = b.Picturename
+            }).ToList();
+
+        if (!qsItemOqcItems.Any())
+            return [];
+
+        // 澶勭悊姣忎釜妫�楠岄」鐩�
+        foreach (var item in qsItemOqcItems)
+        {
+            try
+            {
+                ProcessQualityItem(db, item, quantity);
             }
-
-            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='" +
-                item.QsCode + "' AND B.LOT_FROM<= " + quantity + "   AND " +
-                quantity + "<=B.LOT_TO";
-
-            var maxBillNo = db.Ado.SqlQuerySingle<string>(sql);
-
-
-            var result = ExtractSubstring(item.FacLevel, '(', ')');
-
-
-            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= '" +
-                  item.QsCode + "'  AND SAMPLE_SIZE_WORD= '" + maxBillNo + "'";
-            var resultClass = db.Ado.SqlQuerySingle<ResultClass>(sql);
-
-            item.LevelNum = resultClass.FSAMPLE_SIZE_WORD;
-            item.FreQty = resultClass.Result;
-        });
+            catch (Exception ex)
+            {
+                // 璁板綍閿欒浣嗙户缁鐞嗗叾浠栭」鐩�
+                item.LevelNum = 1; // 璁剧疆榛樿鍊�
+                item.FreQty = 0;
+                item.Notes = $"澶勭悊寮傚父: {ex.Message}";
+            }
+        }
 
         return qsItemOqcItems;
     }
 
+    private void ProcessQualityItem(ISqlSugarClient db, QsItemOqcItem item,
+        decimal quantity)
+    {
+        // 楠岃瘉蹇呰瀛楁
+        if (string.IsNullOrWhiteSpace(item.FcheckLevel) ||
+            string.IsNullOrWhiteSpace(item.QsCode))
+        {
+            item.LevelNum = 1;
+            item.FreQty = 0;
+            return;
+        }
+
+        // 鑾峰彇妫�楠岀骇鍒搴旂殑鏁版嵁搴撳瓧娈�
+        var levelField = GetLevelField(item.FcheckLevel);
+
+        // 浣跨敤鍙傛暟鍖栨煡璇㈤槻姝QL娉ㄥ叆
+        var sql =
+            $"SELECT {levelField} FROM MES_QM_AQL1 A LEFT JOIN MES_QM_AQL2 B ON B.AQL1_ID = A.ID " +
+            $"WHERE A.SAMPLE_SIZE_NO = @QsCode AND B.LOT_FROM <= @Quantity AND @Quantity <= B.LOT_TO";
+
+        var aqlResult = db.Ado.SqlQuerySingle<string>(sql,
+            new { QsCode = item.QsCode, Quantity = quantity });
+
+        if (string.IsNullOrWhiteSpace(aqlResult))
+        {
+            item.LevelNum = 1;
+            item.FreQty = 0;
+            return;
+        }
+
+        // 鎻愬彇FacLevel涓殑鍊�
+        var facLevelValue = ExtractSubstring(item.FacLevel ?? "", '(', ')');
+        if (string.IsNullOrWhiteSpace(facLevelValue))
+        {
+            item.LevelNum =
+                decimal.TryParse(aqlResult, out var level) ? level : 1;
+            item.FreQty = 0;
+            return;
+        }
+
+        // 鑾峰彇鏍锋湰澶у皬鍜岀粨鏋�
+        var resultSql =
+            $"SELECT FSAMPLE_SIZE_WORD, {facLevelValue} as Result FROM MES_QM_AQL1 A " +
+            $"LEFT JOIN MES_QM_AQL3 C ON C.AQL1_ID = A.ID " +
+            $"WHERE A.SAMPLE_SIZE_NO = @QsCode AND SAMPLE_SIZE_WORD = @LevelValue";
+
+        var resultQuery = db.Ado.SqlQuerySingle<ResultClass>(resultSql,
+            new { QsCode = item.QsCode, LevelValue = aqlResult });
+
+        if (resultQuery != null)
+        {
+            item.LevelNum = resultQuery.FSAMPLE_SIZE_WORD;
+            item.FreQty = resultQuery.Result;
+        }
+        else
+        {
+            item.LevelNum = 1;
+            item.FreQty = 0;
+        }
+    }
+
+    private string GetLevelField(string checkLevel)
+    {
+        if (string.IsNullOrWhiteSpace(checkLevel))
+            return "B.FLEVEL_S1";
+
+        return checkLevel switch
+        {
+            var s when s.Contains("S1") => "B.FLEVEL_S1",
+            var s when s.Contains("S2") => "B.FLEVEL_S2",
+            var s when s.Contains("S3") => "B.FLEVEL_S3",
+            var s when s.Contains("S4") => "B.FLEVEL_S4",
+            var s when s.Contains("(I)") => "B.FLEVEL_I",
+            var s when s.Contains("(II)") => "B.FLEVEL_II",
+            var s when s.Contains("(III)") => "B.FLEVEL_III",
+            _ => "B.FLEVEL_S1"
+        };
+    }
+
     private string ExtractSubstring(string input, char startChar, char endChar)
     {
-        var startIndex = input.IndexOf(startChar);
-        var endIndex = input.IndexOf(endChar, startIndex);
-
-        if (startIndex == -1 || endIndex == -1)
-            // 濡傛灉鏈壘鍒拌捣濮嬪瓧绗︽垨缁撴潫瀛楃锛屽垯杩斿洖绌哄瓧绗︿覆鎴栬�呮姏鍑哄紓甯革紝鏍规嵁瀹為檯鎯呭喌閫夋嫨
+        if (string.IsNullOrWhiteSpace(input))
             return string.Empty;
-        // 鎴栬�呮姏鍑哄紓甯�
-        // throw new ArgumentException("Start or end character not found");
-        // 鎻愬彇瀛愬瓧绗︿覆
+
+        var startIndex = input.IndexOf(startChar);
+        var endIndex = input.IndexOf(endChar, startIndex + 1);
+
+        if (startIndex == -1 || endIndex == -1 || endIndex <= startIndex)
+            return string.Empty;
+
         var length = endIndex - startIndex - 1;
+        if (length <= 0)
+            return string.Empty;
+
         return input.Substring(startIndex + 1, length);
     }
 
@@ -233,9 +291,11 @@
             xj.CreateBy = userNo;
             xj.CreateDate = DateTime.Now;
 
-            var pid = db.Insertable(xj).ExecuteReturnIdentity();
+            // var pid = db.Insertable(xj).ExecuteReturnIdentity();
 
-            xj.Id = pid;
+            var pid = (int)xj.Id;
+
+            // xj.Id = pid;
 
             rkjDto.gid = pid;
 
@@ -355,8 +415,8 @@
             result = 1;
         else if (count - passCount < QsItemOqcItem.FreQty) result = 1;
 
-        var useTransactionWithOracle = SqlSugarHelper.UseTransactionWithOracle(
-            db =>
+        var useTransactionWithOracle =
+            SqlSugarHelper.UseTransactionWithOracle(db =>
             {
                 var commit = 0;
                 commit += db.Updateable<QsItemOqcItem>()
@@ -454,48 +514,70 @@
     }
 
 
-    public List<QsItemOqcReq> getPage(XJPageResult queryObj)
+    public (List<QsItemOqcReq> items, int TotalCount) GetPage(
+        XJPageResult queryObj)
     {
         var db = SqlSugarHelper.GetInstance();
+        var totalCount = 0;
 
-        return db
-            .Queryable<QsItemOqcReq, Womdaa, MesItems, MesInvItemIns, Womdab,
-                MesInvTransaction, RKJDaa001>(
-                (a, da, b, c, d, ca, m) => new JoinQueryInfos(
-                    JoinType.Left, da.Daa001 == a.BillNo,
-                    JoinType.Left, a.ItemId == b.Id,
-                    JoinType.Left, a.BillNo == c.BillNo,
-                    JoinType.Left, c.CbillNo == d.Dab001,
-                    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
+
+        var query = db
+            .Queryable<QsItemOqcReq, MesItems, Womdaa, MesLine, SysUser,Womcaa>((a, b,
+                    da, c, us, ca) =>
+                new JoinQueryInfos(
+                    JoinType.Left, a.ItemNo == b.ItemNo, // 鍏宠仈鐗╂枡淇℃伅
+                    JoinType.Left, a.BillNo == da.Daa001, // 鍏宠仈宸ュ崟淇℃伅
+                    JoinType.Left, da.Daa021 == ca.Caa020,//浠诲姟鍗曪紝鐢ㄤ簬鏌ヨ閿�鍞鍗曞彿
+                    JoinType.Left, da.Daa015 == c.LineNo, // 鍏宠仈宸ュ崟淇℃伅
+                    JoinType.Left, us.Fcode == a.CreateBy // 鍏宠仈宸ュ崟淇℃伅
                 ))
-            .Select((a, da, b, c, d, ca, m) => new QsItemOqcReq
+            // 鐢ㄦ埛绾夸綋杩囨护鏉′欢
+            //.WhereIF(lineNo != null && lineNo.Length > 0 && !"PL017".Equals(queryObj.createUser),
+            //    (a, b, da) => lineNo.Contains(da.Daa015))
+            // ID绮剧‘鏌ヨ
+            .WhereIF(!string.IsNullOrEmpty(queryObj.id),
+                (a, b, da, c, us) => a.Id.ToString() == queryObj.id)
+            // 瀹屾垚鐘舵�佽繃婊�
+            .WhereIF("鏈畬鎴�".Equals(queryObj.result),
+                (a, b, da, c, us) => a.Fsubmit == null || a.Fsubmit == 0)
+            .WhereIF(!"鏈畬鎴�".Equals(queryObj.result),
+                (a, b, da, c, us) => a.Fsubmit == 1)
+            // 鎼滅储鏉′欢锛堢墿鏂欏悕绉�/缂栧彿锛�
+            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue),
+                (a, b, da, c, us) =>
+                    b.ItemName.ToLower()
+                        .Contains(queryObj.SearchValue.ToLower()) ||
+                    a.ItemNo.ToLower().Contains(queryObj.SearchValue.ToLower()))
+            // 鏌ヨ瀛楁
+            .Select((a, b, da, c, us, ca) => new QsItemOqcReq
             {
-                BillNo = a.BillNo,
-                Remarks = a.Remarks,
                 Id = a.Id,
+                BillNo = a.BillNo,
+                ItemNo = a.ItemNo,
+                ItemName = b.ItemName,
+                ItemModel = b.ItemModel,
                 CreateDate = a.CreateDate,
                 CreateBy = a.CreateBy,
+                CreateUser = us.Fname,
                 FcheckResu = a.FcheckResu,
-                ItemNo = a.ItemNo,
                 FcheckBy = a.FcheckBy,
                 FcheckDate = a.FcheckDate,
                 ReleaseNo = a.ReleaseNo,
-                // 娣诲姞鍏朵粬瀛楁
-                // 濡傛灉鍦� QsItemOqcReq 涓畾涔変簡棰濆瀛楁锛屽垯闇�瑕佸皢瀹冧滑璧嬪��
-                // 渚嬪:
-                ItemName = b.ItemName,
-                ItemModel = b.ItemModel,
-                TaskNo = c.TaskNo,
-                CbillNo = c.CbillNo,
-                Dab001 = d.Dab001,
-                Daa015 = da.Daa015,
-                LineNo = c.LineNo,
-                Quantity = m.Quantity
-            }).OrderBy(a => a.CreateDate, OrderByType.Desc)
-            .ToPageList(queryObj.PageIndex, queryObj.Limit);
+                Remarks = a.Remarks,
+                Daa015 = da.Daa015, // 宸ュ崟绾夸綋
+                Fsubmit = a.Fsubmit,
+                Quantity = da.Daa008,
+                LineNo = c.LineName,
+                SaleOederNo = ca.Caa015
+            })
+            // 鎺掑簭
+            .OrderBy(a => a.CreateDate, OrderByType.Desc);
+
+        // 鍒嗛〉鏌ヨ
+        var result = query.ToPageList(queryObj.PageIndex, queryObj.Limit,
+            ref totalCount);
+
+        return (result, totalCount);
     }
 
     //鍒犻櫎涓昏〃骞朵笖杩炵骇鍒犻櫎瀛愯〃鍜屽瓩琛�
@@ -518,6 +600,18 @@
         });
 
         return withOracle;
+    }
+
+    public int saveNotesPid(RKJDto dto)
+    {
+        return SqlSugarHelper.UseTransactionWithOracle(db =>
+        {
+            return db.Updateable<QsItemOqcItem>()
+                .SetColumns(it =>
+                    it.Notes == dto.Remarks) //SetColumns鏄彲浠ュ彔鍔犵殑 鍐�2涓氨2涓瓧娈佃祴鍊�
+                .Where(it => it.Id == dto.pid)
+                .ExecuteCommand();
+        });
     }
 
 
@@ -618,11 +712,207 @@
         });
     }
 
+    // 鍘熷saveItem鏂规硶锛堝凡浼樺寲锛屽浠界増鏈湪saveItemOriginal锛�
     public int saveItem(RKJDto rkjDto)
     {
         var items = rkjDto.items;
         var userNo = rkjDto.userNo;
 
+        return SqlSugarHelper.UseTransactionWithOracle(db =>
+        {
+            var commit = 0;
+
+            // 1. 娓呯┖鐜版湁鐨勬楠岃缁嗚褰曪紙瀛欒〃锛�
+            commit += db.Deleteable<QsItemOqcItemDetail>()
+                .Where(s => s.Gid == rkjDto.gid)
+                .ExecuteCommand();
+
+            // 2. 娓呯┖鐜版湁鐨勬楠岄」鐩褰曪紙瀛愯〃锛�
+            commit += db.Deleteable<QsItemOqcItem>()
+                .Where(s => s.Pid == rkjDto.gid)
+                .ExecuteCommand();
+
+            // 3. 鎵归噺鎻掑叆items
+            foreach (var item in items) item.Pid = rkjDto.gid;
+            commit += db.Insertable(items).ExecuteCommand();
+
+            // 4. 鑾峰彇闇�瑕佸鐞嗙殑妫�楠岄」鐩紙鍙煡璇㈠繀瑕佸瓧娈垫彁鍗囨�ц兘锛�
+            var processItems = db.Queryable<QsItemOqcItem>()
+                .Where(s => s.Pid == rkjDto.gid &&
+                            s.MaxValue == null && s.StandardValue == null &&
+                            s.MinValue == null)
+                .Select(s => new { s.Id, s.LevelNum })
+                .ToList();
+
+            if (!processItems.Any())
+            {
+                return Convert.ToInt32(rkjDto.gid);
+            }
+
+            // 5. 鎵归噺鍒涘缓鎵�鏈塓sItemOqcItemDetail
+            var allDetails = new List<QsItemOqcItemDetail>();
+            foreach (var item in processItems)
+            {
+                var levelNum = (int)(item.LevelNum ?? 1);
+                for (int i = 0; i < levelNum; i++)
+                {
+                    allDetails.Add(new QsItemOqcItemDetail
+                    {
+                        Gid = rkjDto.gid,
+                        Pid = item.Id,
+                        Fstand = "鈭�",
+                        FcheckResu = "1",
+                        CreateBy = userNo,
+                        CreateDate = DateTime.Now
+                    });
+                }
+            }
+
+            // 6. 鎵归噺鎻掑叆鎵�鏈塪etails
+            if (allDetails.Any())
+            {
+                commit += db.Insertable(allDetails).ExecuteCommand();
+            }
+
+            // 7. 鎵归噺鏇存柊IsPass鐘舵�佷负鍚堟牸锛堝洜涓烘墍鏈塪etail閮芥槸鍚堟牸鐨勶級
+            var itemIds = processItems.Select(x => x.Id).ToList();
+            if (itemIds.Any())
+            {
+                commit += db.Updateable<QsItemOqcItem>()
+                    .SetColumns(s => s.IsPass == 1)
+                    .Where(s => itemIds.Contains(s.Id))
+                    .ExecuteCommand();
+            }
+
+            // 8. 妫�鏌ュ苟鏇存柊涓绘楠屽崟鐘舵��
+            commit += UpdateMainInspectionStatus(db, rkjDto.gid, userNo);
+
+            return Convert.ToInt32(rkjDto.gid);
+        });
+    }
+
+    private int UpdateMainInspectionStatus(ISqlSugarClient db, decimal? gid,
+        string userNo)
+    {
+        // 妫�鏌ユ槸鍚﹁繕鏈夋湭瀹屾垚鐨勬楠岄」鐩�
+        var unfinishedCount = db.Queryable<QsItemOqcItem>()
+            .Where(s => s.Pid == gid && s.IsPass == null)
+            .Count();
+
+        if (unfinishedCount > 0)
+        {
+            return 0; // 杩樻湁鏈畬鎴愮殑椤圭洰锛屼笉鏇存柊涓绘楠屽崟鐘舵��
+        }
+
+        // 鑾峰彇妫�楠屽崟鐨勬楠岄」鐩�绘暟鍜屽悎鏍兼暟
+        var totalCount = db.Queryable<QsItemOqcItem>()
+            .Where(s => s.Pid == gid)
+            .Count();
+
+        if (totalCount == 0)
+        {
+            return 0; // 娌℃湁妫�楠岄」鐩�
+        }
+
+        var passedCount = db.Queryable<QsItemOqcItem>()
+            .Where(s => s.Pid == gid && s.IsPass == 1)
+            .Count();
+
+        // 纭畾妫�楠岀粨鏋�
+        var checkResult = totalCount == passedCount ? "鍚堟牸" : "涓嶅悎鏍�";
+
+        // 鏇存柊涓绘楠屽崟鐘舵��
+        var updateResult = db.Updateable<QsItemOqcReq>()
+            .SetColumns(s => s.FcheckResu == checkResult)
+            .SetColumns(s => s.FcheckDate == DateTime.Now)
+            .SetColumns(s => s.FcheckBy == userNo)
+            .SetColumns(s => s.LastupdateBy == userNo)
+            .SetColumns(s => s.LastupdateDate == DateTime.Now)
+            .Where(s => s.Id == gid)
+            .ExecuteCommand();
+
+        // 濡傛灉妫�楠屼笉鍚堟牸锛岀敓鎴愬紓甯稿绛栬褰�
+        if (checkResult.Equals("涓嶅悎鏍�"))
+        {
+            GenerateQualityIssueRecord(db, gid, userNo);
+        }
+
+        return updateResult;
+    }
+
+    private void GenerateQualityIssueRecord(ISqlSugarClient db, decimal? gid,
+        string userNo)
+    {
+        try
+        {
+            var qsItemOqcReq = db.Queryable<QsItemOqcReq>()
+                .Single(s => s.Id == gid);
+
+            if (qsItemOqcReq == null) return;
+
+            var mesInvItemIns = db.Queryable<MesInvItemIns>()
+                .Single(s => s.BillNo == qsItemOqcReq.BillNo);
+
+            if (mesInvItemIns == null) return;
+
+            var mesSchemeResult = db.Queryable<Womdaa>()
+                .Single(s => s.Daa001 == mesInvItemIns.CbillNo);
+
+            if (mesSchemeResult == null) return;
+
+            var entity = new MesQaItemsDetect02
+            {
+                LineNo = mesSchemeResult.Daa015,
+                ReleaseNo = qsItemOqcReq.ReleaseNo,
+                LotNo = qsItemOqcReq.BillNo,
+                FcheckDate = qsItemOqcReq.FcheckDate,
+                FcheckMemo = qsItemOqcReq.Remarks,
+                Gid = qsItemOqcReq.Id,
+                FcheckResu = "涓嶅悎鏍�",
+                FcheckLevel = "涓ラ噸",
+                CreateDate = DateTime.Now,
+                Factory = "10000",
+                Company = "1000",
+                Ftype = "4",
+                Fversion = 0,
+                Modify1Flag = 0,
+                IpqcStatus = 0,
+                Fsubmit = 1,
+                CreateBy = userNo,
+                FcheckBy = userNo
+            };
+
+            db.Insertable(entity).ExecuteCommand();
+        }
+        catch (Exception ex)
+        {
+            // 璁板綍寮傚父浣嗕笉褰卞搷涓绘祦绋�
+            // 鍙互鑰冭檻娣诲姞鏃ュ織璁板綍
+            Console.WriteLine($"鐢熸垚璐ㄩ噺寮傚父璁板綍澶辫触: {ex.Message}");
+        }
+    }
+
+    public int IqcQaSubmit(RKJDto dto)
+    {
+        SqlSugarHelper.UseTransactionWithOracle(db =>
+        {
+           return db.Updateable<QsItemOqcReq>()
+                .SetColumns(a => a.Fsubmit == 1)
+                .SetColumns(a => a.FsubmitBy == dto.userNo)
+                .SetColumns(a => a.FsubmitDate == DateTime.Now)
+                .Where(a => a.ReleaseNo == dto.releaseNo)
+                .ExecuteCommand();
+        });
+
+        return 0;
+    }
+
+    // 澶囦唤锛氬師濮嬬増鏈殑saveItem鏂规硶
+    public int saveItemOriginal(RKJDto rkjDto)
+    {
+        var items = rkjDto.items;
+        var userNo = rkjDto.userNo;
+
         SqlSugarHelper.UseTransactionWithOracle(db =>
         {
             foreach (var item in items) item.Pid = rkjDto.gid;

--
Gitblit v1.9.3