From 8390b66312a4fa11641b6216bb32c7715d18303c Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期四, 28 八月 2025 10:05:21 +0800
Subject: [PATCH] Merge branch 'master' of http://git.gs-mes.com:8080/r/~tjx/NewPdaSqlServer

---
 service/Wom/WomdaaManager.cs |  520 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 492 insertions(+), 28 deletions(-)

diff --git a/service/Wom/WomdaaManager.cs b/service/Wom/WomdaaManager.cs
index 1f552d6..e5a8733 100644
--- a/service/Wom/WomdaaManager.cs
+++ b/service/Wom/WomdaaManager.cs
@@ -203,8 +203,8 @@
         //    })
         //    .ToList();
 
-        var sql =string.Format(@"SELECT c.item_no ItemNo,c.item_name ItemName,c.item_model ItemModel,b.dab006 FQty,b.dab007 SQty,b.dab006 - b.dab007 DSQty ,
-       dbo.F_QX_GETRECODEPOTSE(B.dab003) as RecoKw
+        var sql =string.Format(@"SELECT c.item_no ItemNo,c.item_name ItemName,c.item_model ItemModel,b.dab006 FQty,b.dab007 SQty,b.dab006 - b.dab007 DSQty ,C.item_id FMaterialId ,
+       dbo.F_QX_GETRECODEPOTSE(B.dab003,'','','') as RecoKw
     FROM WOMDAB B
     LEFT JOIN WOMDAA A ON A.guid = B.daaGuid
     LEFT JOIN MES_ITEMS C ON  B.dab003 = C.item_id
@@ -265,32 +265,41 @@
     /// <returns></returns>
     public dynamic getZsBarInfo(dynamic query)
     {
+        if (query == null)
+            throw new ArgumentNullException(nameof(query), "鍙傛暟瀵硅薄涓嶈兘涓簄ull");
 
-        var sql = string.Format(@"SELECT TOP 1 A.barCode AS zsBarcode,
-             D.name AS lineName,
-             D.line_no,
-             B.daa001,
-             C.item_no,
-             C.item_name,
-             C.item_model,
-             A.quantity as barQty,
-             B.daa008 as sumQty,
-             isnull((SELECT count(1) FROM WORK_COLLECT WHERE processNo = '{0}' AND ABOUT_GUID = A.ABOUT_GUID),0) AS finQty,
-             isnull((SELECT TOP 1 processNo FROM WORK_COLLECT WHERE  WORK_COLLECT.barCode = '{1}' AND checkResult = '鈭�' ORDER BY WORK_COLLECT.createDate DESC ),'') AS lastGx
-FROM WORK_TRAC_CODE A
-         LEFT JOIN WOMDAA B ON A.ABOUT_GUID = B.guid
-         LEFT JOIN MES_ITEMS C ON B.daa002 = C.item_id
-         LEFT JOIN MES_WORKSHOP_LINE D ON A.lineId = D.id
-WHERE A.barCode = '{1}'", query.GX, query.Zsbarcode);
+        if (string.IsNullOrEmpty(query.Zsbarcode?.ToString()))
+            throw new ArgumentException("杩芥函鐮佷笉鑳戒负绌�", nameof(query.Zsbarcode));
 
-        var ZsBarInfo = Db.Ado.SqlQuery<dynamic>(sql);
+        if (string.IsNullOrEmpty(query.GX?.ToString()))
+            throw new ArgumentException("宸ュ簭涓嶈兘涓虹┖", nameof(query.GX));
 
-        if (ZsBarInfo.Count < 1)
+        var parameters = new[]
+    {
+        new SugarParameter("@pi_trac_barcode", query.Zsbarcode),
+        new SugarParameter("@pi_gx", query.GX),
+        new SugarParameter("@inP1", null),
+        new SugarParameter("@inP2", null),
+        new SugarParameter("@inP3", null),
+        new SugarParameter("@inP4", null)
+    };
+
+        try
         {
-            throw new Exception($"璇ヨ拷婧爜{query.Zsbarcode}涓嶅瓨鍦ㄤ笉瀛樺湪");
-        }
+            var ZsBarInfo = Db.Ado.SqlQuery<dynamic>("EXEC prc_pda_scll_selZsBarInfo @pi_trac_barcode,@pi_gx,@inP1,@inP2,@inP3,@inP4", parameters);
 
-        return ZsBarInfo;
+            if (ZsBarInfo.Count < 1)
+            {
+                throw new Exception($"璇ヨ拷婧爜{query.Zsbarcode}涓嶅瓨鍦ㄦ垨宸茬粦瀹�");
+            }
+
+            return ZsBarInfo;
+        }
+        catch (Exception ex)
+        {
+            // 淇濈暀鍘熸湁寮傚父澶勭悊閫昏緫
+            throw new Exception($"{ex.Message}");
+        }
     }
 
     //鑾峰彇鐢熶骇
@@ -301,12 +310,44 @@
          LEFT JOIN WORK_TRAC_CODE B ON A.barCode = B.barCode
          LEFT JOIN SYS_USER C ON C.ACCOUNT = A.createBy
          LEFT JOIN MES_WORKSHOP_LINE D ON B.lineId = D.id
-WHERE A.barCode = '{0}'", query.Zsbarcode);
+WHERE A.barCode = '{0}'
+ORDER BY A.createDate", query.Zsbarcode);
 
         var Traceability = Db.Ado.SqlQuery<dynamic>(sql);
 
         return Traceability;
     }
+
+    /// <summary>
+    /// 鑾峰彇鐗╂枡鐩稿叧鏉$爜淇℃伅
+    /// </summary>
+    /// <param name="unity"></param>
+    /// <returns></returns>
+    /// <exception cref="Exception"></exception>
+    public dynamic GetBarKwByItem(dynamic unity)
+    {
+        if (unity == null) 
+            throw new ArgumentNullException(nameof(unity), "鍙傛暟瀵硅薄涓嶈兘涓簄ull");
+
+        if (string.IsNullOrEmpty(unity.itemId?.ToString()))
+            throw new ArgumentException("鐗╂枡ID涓嶈兘涓虹┖", nameof(unity.itemId));
+
+        try
+        {
+            var parameters = new List<SugarParameter>
+            {
+                new SugarParameter("@itemId", unity.itemId)
+            };
+
+            return Db.Ado.SqlQuery<dynamic>("EXEC prc_pda_scll_selBarMx @itemId", parameters);
+        }
+        catch (Exception ex)
+        {
+            throw new Exception($"鑾峰彇鏉$爜淇℃伅澶辫触锛歿ex.Message}");
+        }
+
+    }
+
 
     public dynamic ProductBinding(dynamic query)
     {
@@ -384,7 +425,7 @@
         if (string.IsNullOrEmpty(query.Kbbarcode?.ToString()))
             throw new ArgumentException("鍗℃澘鏉$爜涓嶅厑璁镐负绌�", nameof(query.userName));
 
-        var sql = string.Format(@"SELECT OLDQTY,
+        var sql = string.Format(@"SELECT QUANTITY,
        ISNULL((SELECT COUNT(1) FROM MES_INV_ITEM_BARCODES_TBMX WHERE ABOUT_TB_BARCODE = '{0}'), 0) AS YSum,
        DAA001
 FROM MES_INV_ITEM_BARCODES A LEFT JOIN WOMDAA B ON A.ABOUT_GUID = B.guid
@@ -678,7 +719,8 @@
             {
                 a.Daa001,
                 a.CaaGuid,
-                a.Daa008
+                a.Daa008,
+                a.Daa021
             }).First();
 
         if (womdaa?.Daa001 == null) throw new Exception("宸ュ崟鍙蜂笉瀛樺湪");
@@ -745,6 +787,7 @@
         var dto = new XcslResultDto
         {
             GD_Num = womdaa.Daa008,
+            workNo = womdaa.Daa021,
             XcslItemList = XcslItem,
             XcslWjsBarList = XcslWjsBar,
             XcslYjsBarList = XcslYjsBar
@@ -758,6 +801,7 @@
     public class XcslResultDto
     {
         public int? GD_Num { get; set; }
+        public string? workNo { get; set; }
         public List<dynamic> XcslItemList { get; set; }
         public List<dynamic> XcslWjsBarList { get; set; }
         public List<dynamic> XcslYjsBarList { get; set; }
@@ -899,7 +943,7 @@
         var sql2 = new StringBuilder(@"
         SELECT '['+DAA001+']['+DAA021+']' AS daaInfo,DAA001,DAA021
         FROM WOMDAA
-        WHERE daa018 NOT IN ('W:瀹屽伐', 'D:寰呭紑宸�')");
+        WHERE daa018 <>'W:瀹屽伐'");
 
         if (!string.IsNullOrWhiteSpace(unity.selectKey?.ToString()))
         {
@@ -933,7 +977,8 @@
             {
                 a.Daa001,
                 a.CaaGuid,
-                a.Daa008
+                a.Daa008,
+                a.Daa021
             }).First();
 
         if (womdaa?.Daa001 == null) throw new Exception("宸ュ崟鍙蜂笉瀛樺湪");
@@ -1009,6 +1054,7 @@
         var dto = new XcslResultDto
         {
             GD_Num = womdaa.Daa008,
+            workNo = womdaa.Daa021,
             XcslItemList = XcslItem,
             XcslWjsBarList = XcslWjsBar,
             XcslYjsBarList = XcslYjsBar
@@ -1082,4 +1128,422 @@
         }
     }
 
+
+    /// <summary>
+    /// 鍐呯鏍稿锛氳幏鍙栧悗鐩栫爜瀵瑰簲浜у搧淇℃伅
+    /// </summary>
+    /// <param name="query"></param>
+    /// <returns></returns>
+    public dynamic getHgBarInfo(dynamic query)
+    {
+
+        var sql = string.Format(@"DECLARE @ZsBar varchar(100)
+SELECT TOP 1 @ZsBar= ABOUT_TRAC_BARCODE FROM MES_INV_ITEM_BARCODES_TBMX WHERE ITEM_BARCODE = '{1}'
+SELECT TOP 1 A.barCode AS zsBarcode,
+             D.name AS lineName,
+             D.line_no,
+             B.daa001,
+             C.item_no,
+             C.item_name,
+             C.item_model,
+             A.quantity as barQty,
+             B.daa008 as sumQty,
+             isnull((SELECT count(1) FROM WORK_COLLECT WHERE processNo = '{0}' AND ABOUT_GUID = A.ABOUT_GUID),0) AS finQty,
+             isnull((SELECT TOP 1 processNo FROM WORK_COLLECT WHERE  WORK_COLLECT.barCode = @ZsBar AND ISNULL(checkResult,'') = '鈭�' AND  ISNULL(barCodeStatus,1) = 1 ORDER BY WORK_COLLECT.createDate DESC ),'') AS lastGx
+FROM WORK_TRAC_CODE A
+         LEFT JOIN WOMDAA B ON A.ABOUT_GUID = B.guid
+         LEFT JOIN MES_ITEMS C ON B.daa002 = C.item_id
+         LEFT JOIN MES_WORKSHOP_LINE D ON A.lineId = D.id
+WHERE A.barCode = @ZsBar", query.GX, query.Zsbarcode);
+
+        var ZsBarInfo = Db.Ado.SqlQuery<dynamic>(sql);
+
+        if (ZsBarInfo.Count < 1)
+        {
+            throw new Exception($"璇ュ悗鐩栫爜{query.Zsbarcode}涓嶅瓨鍦ㄦ垨鏈粦瀹�");
+        }
+
+        return ZsBarInfo;
+    }
+
+    /// <summary>
+    /// 鍐呯鏍稿锛氭牴鎹祦姘寸爜鑾峰彇鐢熶骇灞ュ巻
+    /// </summary>
+    /// <param name="query"></param>
+    /// <returns></returns>
+    public dynamic getTraceabilityByLsBar(dynamic query)
+    {
+        var sql = string.Format(@"SELECT processNo, A.barCode, B.lineId, line_no, name AS lineName, checkResult, C.USER_NAME
+FROM WORK_COLLECT A
+         LEFT JOIN WORK_TRAC_CODE B ON A.barCode = B.barCode
+         LEFT JOIN SYS_USER C ON C.ACCOUNT = A.createBy
+         LEFT JOIN MES_WORKSHOP_LINE D ON B.lineId = D.id
+WHERE A.barCode =  (SELECT TOP 1 ABOUT_TRAC_BARCODE FROM MES_INV_ITEM_BARCODES_TBMX WHERE ITEM_BARCODE = '{0}')
+ORDER BY A.createDate", query.Zsbarcode);
+
+        var Traceability = Db.Ado.SqlQuery<dynamic>(sql);
+
+        return Traceability;
+    }
+
+    /// <summary>
+    /// 鍐呯鏍稿锛氭壂鐮佹牳瀵�
+    /// </summary>
+    /// <param name="query"></param>
+    /// <returns></returns>
+    /// <exception cref="ArgumentNullException"></exception>
+    /// <exception cref="ArgumentException"></exception>
+    /// <exception cref="Exception"></exception>
+    public dynamic ScanNxhd(dynamic query)
+    {
+        if (query == null) throw new ArgumentNullException(nameof(query), "鍙傛暟瀵硅薄涓嶈兘涓� null");
+
+        // 2. 浣跨敤 string.IsNullOrEmpty 鐩存帴鍒ゆ柇瀛楃涓插睘鎬э紙閬垮厤 NullReferenceException锛�
+        if (string.IsNullOrEmpty(query.userName?.ToString()))
+            throw new ArgumentException("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖", nameof(query.userName));
+
+        if (string.IsNullOrEmpty(query.ZsBar?.ToString()))
+            throw new ArgumentException("鍚庣洊鐮佷笉鍏佽涓虹┖", nameof(query.ZsBar));
+
+        if (string.IsNullOrEmpty(query.LsBar?.ToString()))
+            throw new ArgumentException("绠辨潯鐮佷笉鍏佽涓虹┖", nameof(query.LsBar));
+
+        var _strMsg = "";
+        var _intSum = "";
+        using (var conn = new SqlConnection(DbHelperSQL.strConn))
+        {
+            using (var cmd = new SqlCommand("prc_pda_Scan_Nxhd", conn))
+            {
+                try
+                {
+                    conn.Open();
+                    cmd.CommandType = CommandType.StoredProcedure;
+                    SqlParameter[] parameters =
+                    {
+                        new("@pi_user", SqlDbType.NVarChar, 100) { Value = query.userName },
+                        new("@pi_hg_barcode", SqlDbType.NVarChar, 100) { Value = query.ZsBar },
+                        new("@pi_x_barcode", SqlDbType.NVarChar, 100) { Value = query.LsBar },
+                        new("@po_outMsg", SqlDbType.NVarChar, 2000) { Direction = ParameterDirection.Output },
+                        new("@po_outStatus", SqlDbType.Int) { Direction = ParameterDirection.Output }
+                    };
+
+                    foreach (var parameter in parameters)
+                        cmd.Parameters.Add(parameter);
+
+                    cmd.ExecuteNonQuery();
+
+                    _strMsg = parameters[3].Value?.ToString() ?? "";
+                    _intSum = parameters[4].Value?.ToString() ?? "-1";
+
+                    var result = Convert.ToInt32(_intSum);
+                    if (result <= 0) throw new Exception(_strMsg);
+
+                    var dto = new
+                    {
+                        message = _strMsg,
+                        status = result,
+                        tracBarcode = query.ZsBar
+                    };
+
+                    return dto;
+                }
+                catch (Exception ex)
+                {
+                    throw new Exception(ex.Message);
+                }
+                finally
+                {
+                    conn.Close();
+                }
+            }
+        }
+    }
+
+    /// <summary>
+    /// 鍐呯鏍稿锛氭壂鐮佹牳瀵�
+    /// </summary>
+    /// <param name="query"></param>
+    /// <returns></returns>
+    /// <exception cref="ArgumentNullException"></exception>
+    /// <exception cref="ArgumentException"></exception>
+    /// <exception cref="Exception"></exception>
+    public dynamic ScanFgbd(dynamic query)
+    {
+        if (query == null) throw new ArgumentNullException(nameof(query), "鍙傛暟瀵硅薄涓嶈兘涓� null");
+
+        if (string.IsNullOrEmpty(query.userName?.ToString()))
+            throw new ArgumentException("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖", nameof(query.userName));
+
+        if (string.IsNullOrEmpty(query.HgBar?.ToString())) 
+            throw new ArgumentException("鍚庣洊鐮佷笉鍏佽涓虹┖", nameof(query.HgBar));
+
+        if (string.IsNullOrEmpty(query.FgBar?.ToString())) 
+            throw new ArgumentException("杩斿伐鐮佷笉鍏佽涓虹┖", nameof(query.FgBar));
+
+        var _strMsg = "";
+        var _intSum = "";
+        using (var conn = new SqlConnection(DbHelperSQL.strConn))
+        {
+            using (var cmd = new SqlCommand("prc_pda_Scan_Fgbd", conn))
+            {
+                try
+                {
+                    conn.Open();
+                    cmd.CommandType = CommandType.StoredProcedure;
+                    SqlParameter[] parameters =
+                    {
+                        new("@pi_user", SqlDbType.NVarChar, 100) { Value = query.userName },
+                        new("@pi_fg_barcode", SqlDbType.NVarChar, 100) { Value = query.FgBar },
+                        new("@pi_ls_barcode", SqlDbType.NVarChar, 100) { Value = query.HgBar },//鍚庣洊/娴佹按
+                        new("@po_outMsg", SqlDbType.NVarChar, 2000) { Direction = ParameterDirection.Output },
+                        new("@po_outStatus", SqlDbType.Int) { Direction = ParameterDirection.Output }
+                    };
+
+                    foreach (var parameter in parameters)
+                        cmd.Parameters.Add(parameter);
+
+                    cmd.ExecuteNonQuery();
+
+                    _strMsg = parameters[3].Value?.ToString() ?? "";
+                    _intSum = parameters[4].Value?.ToString() ?? "-1";
+
+                    var result = Convert.ToInt32(_intSum);
+                    if (result <= 0) throw new Exception(_strMsg);
+
+                    var dto = new
+                    {
+                        message = _strMsg,
+                        status = result,
+                        tracBarcode = query.ZsBar
+                    };
+
+                    return dto;
+                }
+                catch (Exception ex)
+                {
+                    throw new Exception(ex.Message);
+                }
+                finally
+                {
+                    conn.Close();
+                }
+            }
+        }
+    }
+
+    /// <summary>
+    /// 鑾峰彇AGV绾夸綋鍒楄〃
+    /// </summary>
+    /// <param name="unity"></param>
+    /// <returns></returns>
+    /// <exception cref="Exception"></exception>
+    public dynamic GetAgvXt(dynamic unity)
+    {
+
+        var sqlParams = new List<SugarParameter> { };
+
+        var sql2 = new StringBuilder(@"SELECT NAME,line_no FROM MES_WORKSHOP_LINE WHERE isAgv = 1 ORDER BY line_no");
+
+
+        var XtItem = Db.Ado.SqlQuery<dynamic>(sql2.ToString(), sqlParams);
+
+        if (XtItem == null)
+        {
+            throw new Exception("鏃犲搴擜GV缁戝畾绾夸綋淇℃伅锛�");
+        }
+
+        return XtItem;
+    }
+
+    /// <summary>
+    /// AGV閫佹
+    /// </summary>
+    /// <param name="query"></param>
+    /// <returns></returns>
+    /// <exception cref="ArgumentNullException"></exception>
+    /// <exception cref="ArgumentException"></exception>
+    /// <exception cref="Exception"></exception>
+    public dynamic HandleAGVInspection(dynamic query)
+    {
+        if (query == null) throw new ArgumentNullException(nameof(query));
+
+        if (string.IsNullOrEmpty(query.userAccount?.ToString()))
+            throw new ArgumentException("鐢ㄦ埛璐﹀彿涓嶈兘涓虹┖", nameof(query.userAccount));
+
+        if (string.IsNullOrEmpty(query.KbBar?.ToString()))
+            throw new ArgumentException("鍗℃澘鏉$爜涓嶈兘涓虹┖", nameof(query.KbBar));
+
+        using (var conn = new SqlConnection(DbHelperSQL.strConn))
+        {
+            using (var cmd = new SqlCommand("prc_pda_AgvSj", conn))
+            {
+                cmd.CommandType = CommandType.StoredProcedure;
+                var parameters = new SqlParameter[]
+                {
+                    new("@pi_user", SqlDbType.NVarChar, 100) { Value = query.userAccount },
+                    new("@pi_kb_barcode", SqlDbType.NVarChar, 100) { Value = query.KbBar },
+                    new("@outMsg", SqlDbType.NVarChar, 2500) { Direction = ParameterDirection.Output },
+                    new("@outSum", SqlDbType.Int) { Direction = ParameterDirection.Output }
+                };
+
+                cmd.Parameters.AddRange(parameters);
+                conn.Open();
+                cmd.ExecuteNonQuery();
+
+                var result = new
+                {
+                    message = parameters[2].Value?.ToString(),
+                    status = Convert.ToInt32(parameters[3].Value)
+                };
+
+                if (result.status <= 0)
+                    throw new Exception(result.message);
+
+                return result;
+            }
+        }
+    }
+
+    public dynamic HandleAGVCall(dynamic query)
+    {
+        if (query == null) throw new ArgumentNullException(nameof(query));
+
+        if (string.IsNullOrEmpty(query.userAccount?.ToString()))
+            throw new ArgumentException("鐢ㄦ埛璐﹀彿涓嶈兘涓虹┖", nameof(query.userAccount));
+
+        if (string.IsNullOrEmpty(query.XtNum?.ToString()))
+            throw new ArgumentException("绾夸綋缂栧彿涓嶈兘涓虹┖", nameof(query.XtNum));
+
+        using (var conn = new SqlConnection(DbHelperSQL.strConn))
+        {
+            using (var cmd = new SqlCommand("prc_pda_AgvHj", conn))
+            {
+                cmd.CommandType = CommandType.StoredProcedure;
+                var parameters = new SqlParameter[]
+                {
+                    new("@pi_user", SqlDbType.NVarChar, 100) { Value = query.userAccount },
+                    new("@pi_xtNum", SqlDbType.NVarChar, 100) { Value = query.XtNum },
+                    new("@outMsg", SqlDbType.NVarChar, 2500) { Direction = ParameterDirection.Output },
+                    new("@outSum", SqlDbType.Int) { Direction = ParameterDirection.Output }
+                };
+
+                cmd.Parameters.AddRange(parameters);
+                conn.Open();
+                cmd.ExecuteNonQuery();
+
+                var result = new
+                {
+                    message = parameters[2].Value?.ToString(),
+                    status = Convert.ToInt32(parameters[3].Value)
+                };
+
+                if (result.status <= 0)
+                    throw new Exception(result.message);
+
+                return result;
+            }
+        }
+    }
+
+
+    public dynamic HandleAgvJy(dynamic query)
+    {
+        if (query == null) throw new ArgumentNullException(nameof(query));
+        
+        // 鍙傛暟楠岃瘉寮哄寲
+        if (string.IsNullOrEmpty(query.userAccount?.ToString()))
+            throw new ArgumentException("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖", nameof(query.userAccount));
+        
+        if (string.IsNullOrEmpty(query.KbBar?.ToString()))
+            throw new ArgumentException("鍗℃澘鏉$爜涓嶅厑璁镐负绌�", nameof(query.KbBar));
+        
+        if (string.IsNullOrEmpty(query.jyz?.ToString()))
+            throw new ArgumentException("妫�楠岀粨鏋滀笉鍏佽涓虹┖", nameof(query.jyz));
+
+        var _strMsg = "";
+        var _intSum = "";
+        
+        using (var conn = new SqlConnection(DbHelperSQL.strConn))
+        {
+            using (var cmd = new SqlCommand("prc_pda_AgvJy", conn))
+            {
+                cmd.CommandType = CommandType.StoredProcedure;
+                
+                // 娣诲姞瀛樺偍杩囩▼鍙傛暟
+                SqlParameter[] parameters = 
+                {
+                    new("@pi_user", SqlDbType.NVarChar, 100) { Value = query.userAccount },
+                    new("@pi_kbBarcode", SqlDbType.NVarChar, 100) { Value = query.KbBar },
+                    new("@pi_jyz", SqlDbType.NVarChar, 100) { Value = query.jyz },
+                    new("@outMsg", SqlDbType.NVarChar, 2500) { Direction = ParameterDirection.Output },
+                    new("@outSum", SqlDbType.Int) { Direction = ParameterDirection.Output }
+                };
+                
+                foreach (var parameter in parameters)
+                    cmd.Parameters.Add(parameter);
+                
+                conn.Open();
+                cmd.ExecuteNonQuery();
+                
+                _strMsg = parameters[3].Value?.ToString() ?? "";
+                _intSum = parameters[4].Value?.ToString() ?? "-1";
+
+                var result = Convert.ToInt32(_intSum);
+                if (result <= 0) throw new Exception(_strMsg);
+
+                return new 
+                {
+                    message = _strMsg,
+                    status = result,
+                    kbBarcode = query.KbBar
+                };
+            }
+        }
+    }
+
+    public dynamic HandleAgvRk(dynamic query)
+    {
+        if (query == null) throw new ArgumentNullException(nameof(query));
+
+        if (string.IsNullOrEmpty(query.userAccount?.ToString()))
+            throw new ArgumentException("鐢ㄦ埛璐﹀彿涓嶈兘涓虹┖", nameof(query.userAccount));
+
+        if (string.IsNullOrEmpty(query.KbBar?.ToString()))
+            throw new ArgumentException("鍗℃澘鏉$爜涓嶈兘涓虹┖", nameof(query.KbBar));
+
+        if (string.IsNullOrEmpty(query.Postition?.ToString()))
+            throw new ArgumentException("妤煎眰浣嶇疆涓嶈兘涓虹┖", nameof(query.Postition));
+
+        using (var conn = new SqlConnection(DbHelperSQL.strConn))
+        {
+            using (var cmd = new SqlCommand("prc_pda_AgvRk", conn))
+            {
+                cmd.CommandType = CommandType.StoredProcedure;
+                var parameters = new SqlParameter[]
+                {
+                    new("@pi_user", SqlDbType.NVarChar, 100) { Value = query.userAccount },
+                    new("@pi_kb_barcode", SqlDbType.NVarChar, 100) { Value = query.KbBar },
+                    new("@pi_kb_Postition", SqlDbType.NVarChar, 100) { Value = query.Postition },
+                    new("@outMsg", SqlDbType.NVarChar, 2500) { Direction = ParameterDirection.Output },
+                    new("@outSum", SqlDbType.Int) { Direction = ParameterDirection.Output }
+                };
+
+                cmd.Parameters.AddRange(parameters);
+                conn.Open();
+                cmd.ExecuteNonQuery();
+
+                var result = new
+                {
+                    message = parameters[3].Value?.ToString(),
+                    status = Convert.ToInt32(parameters[4].Value)
+                };
+
+                if (result.status <= 0)
+                    throw new Exception(result.message);
+
+                return result;
+            }
+        }
+    }
+
 }
\ No newline at end of file

--
Gitblit v1.9.3