From f4e84a98facb28bbfc63343c81095a9787812e27 Mon Sep 17 00:00:00 2001 From: 南骏 池 <chiffly@163.com> Date: 星期六, 30 八月 2025 16:25:51 +0800 Subject: [PATCH] 1.PDA分组织 --- service/Wom/WomdaaManager.cs | 1050 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 966 insertions(+), 84 deletions(-) diff --git a/service/Wom/WomdaaManager.cs b/service/Wom/WomdaaManager.cs index 066314a..5d43f56 100644 --- a/service/Wom/WomdaaManager.cs +++ b/service/Wom/WomdaaManager.cs @@ -1,5 +1,6 @@ 锘縰sing System.Data; using System.Data.SqlClient; +using System.Text; using Masuit.Tools; using Microsoft.SqlServer.Server; using NewPdaSqlServer.DB; @@ -16,7 +17,7 @@ //杩欓噷闈㈠啓鐨勪唬鐮佷笉浼氱粰瑕嗙洊,濡傛灉瑕侀噸鏂扮敓鎴愯鍒犻櫎 WomdaaManager.cs //鑾峰彇宸ュ崟鍙� - public List<string> GetProductionPickDaa001(WarehouseQuery query) + public List<string> GetProductionPickDaa001(WarehouseQuery query, dynamic requestInfo) { var sql = "SELECT DAA001 FROM WOMDAA A LEFT JOIN (SELECT COUNT(1) UN_NUM, PID FROM WOMDAB WHERE DAB006 > DAB007 GROUP BY DAB002) B ON A.GUID = B.daaGuid WHERE DAA001 = " + @@ -27,7 +28,7 @@ } //鏍规嵁宸ュ崟鍙疯繑鍥炰骇鍝佸瀷鍙峰拰寰呴鐗╂枡 - public ProductionPickDto GetItemsByDaa001(WarehouseQuery query) + public ProductionPickDto GetItemsByDaa001(WarehouseQuery query, dynamic requestInfo) { return getDaa001(query); } @@ -109,6 +110,7 @@ var _strMsg = ""; var _intSum = ""; + var _cfBar = "";//鎷嗗垎鍚庢潯鐮� using (var conn = new SqlConnection(DbHelperSQL.strConn)) { using (var cmd = new SqlCommand("[prc_pda_SCLL_CF]", conn)) @@ -119,8 +121,9 @@ cmd.CommandType = CommandType.StoredProcedure; SqlParameter[] parameters = { - new("@outMsg", SqlDbType.NVarChar, 300), + new("@outMsg", SqlDbType.NVarChar, 2000), new("@outSum", SqlDbType.NVarChar, 300), + new("@outCfBar", SqlDbType.NVarChar, 300), new("@c_User", query.userName), new("@p_biLL_no", query.daa001), new("@p_item_barcode", query.barcode), @@ -128,11 +131,13 @@ }; parameters[0].Direction = ParameterDirection.Output; parameters[1].Direction = ParameterDirection.Output; + parameters[2].Direction = ParameterDirection.Output; foreach (var parameter in parameters) cmd.Parameters.Add(parameter); cmd.ExecuteNonQuery(); _strMsg = parameters[0].Value.ToString(); _intSum = parameters[1].Value.ToString(); + _cfBar = parameters[2].Value.ToString(); var result = Convert.ToInt32(_intSum); @@ -141,7 +146,8 @@ var dto = new ProductionPickDto { daa001 = query.daa001, - barcode = query.barcode + barcode = query.barcode,//鍘熸潯鐮� + cfBarcode = _cfBar//鎷嗗垎鍚庢潯鐮� }; return dto; @@ -197,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 @@ -259,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}"); + } } //鑾峰彇鐢熶骇 @@ -295,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) { @@ -378,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 @@ -402,7 +449,7 @@ public dynamic getKbBarMxInfo(dynamic query) { - var sql = string.Format(@"SELECT ITEM_BARCODE, QUANTITY,item_no,item_name,item_model + var sql = string.Format(@"SELECT ITEM_BARCODE, QUANTITY,item_no,item_name,item_model,weight FROM MES_INV_ITEM_BARCODES_TBMX A LEFT JOIN WOMDAA B ON B.daa001 = A.DAA_001 LEFT JOIN MES_ITEMS C ON C.item_id = B.daa002 @@ -415,22 +462,88 @@ } /// <summary> - /// 鑾峰彇鍗℃澘鏄庣粏淇℃伅 + /// 鑾峰彇绠辨槑缁嗕俊鎭� /// </summary> /// <param name="query"></param> /// <returns></returns> public dynamic getXBarInfo(dynamic query) { - var sql1 = string.Format(@"SELECT 1 FROM MES_INV_ITEM_BARCODES_TBMX WHERE ITEM_BARCODE = '{0}' ", query.Xbarcode); + //var sql1 = string.Format(@"SELECT 1 FROM MES_INV_ITEM_BARCODES_TBMX WHERE ITEM_BARCODE = '{0}' ", query.Xbarcode); - var IS_CZ = Db.Ado.SqlQuery<dynamic>(sql1); + //var IS_CZ = Db.Ado.SqlQuery<dynamic>(sql1); - if (IS_CZ.Count < 1) + //if (IS_CZ.Count < 1) + //{ + // throw new Exception($"璇ョ鏉$爜[{query.Xbarcode}]涓嶅瓨鍦紒"); + //} + + + // 鏍¢獙瀛樺偍杩囩▼ + if (string.IsNullOrEmpty(query.KbBar?.ToString())) + throw new ArgumentException("鍗℃澘鏉$爜涓嶅厑璁镐负绌�", nameof(query.KbBar)); + // 鏍¢獙瀛樺偍杩囩▼ + if (string.IsNullOrEmpty(query.Xbarcode?.ToString())) + throw new ArgumentException("绠辨潯鐮佷笉鍏佽涓虹┖", nameof(query.Xbarcode)); + + var successRecords = new List<dynamic>(); + using (var conn = new SqlConnection(DbHelperSQL.strConn)) { - throw new Exception($"璇ョ鏉$爜[{query.Xbarcode}]涓嶅瓨鍦紒"); + conn.Open(); + using (var transaction = conn.BeginTransaction()) // 寮�鍚簨鍔� + { + try + { + + using (var cmd = new SqlCommand("prc_pda_Xbar_binding_JY", conn, transaction)) + { + cmd.CommandType = CommandType.StoredProcedure; + SqlParameter[] parameters = + { + new("@pi_user", SqlDbType.NVarChar, 100) { Value = query.userName }, + new("@pi_kb_barcode", SqlDbType.NVarChar, 100) { Value = query.KbBar }, + new("@pi_ls_barcode", SqlDbType.NVarChar, 100) { Value = query.Xbarcode }, + 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(); + + var _strMsg = parameters[3].Value?.ToString() ?? ""; + var _intSum = parameters[4].Value?.ToString() ?? "-1"; + + var result = Convert.ToInt32(_intSum); + if (result <= 0) + { + //transaction.Rollback(); + throw new Exception(_strMsg); + //return new { + // status = result, + // message = $"鎿嶄綔鍥炴粴锛歿_strMsg}", + // failedBarcode = xBar.iteM_BARCODE, + // successCount = successRecords.Count + //}; + } + + } + + transaction.Commit(); // 鍏ㄩ儴鎴愬姛鎻愪氦浜嬪姟 + } + catch (Exception ex) + { + transaction.Rollback(); + throw new Exception($"寮傚父淇℃伅 锛歿ex.Message}"); + } + finally + { + conn.Close(); + } + } } - var sql2 = string.Format(@"SELECT ITEM_BARCODE, QUANTITY,item_no,item_name,item_model,'0' as is_hedui + var sql2 = string.Format(@"SELECT ITEM_BARCODE, QUANTITY,item_no,item_name,item_model,'0' as is_hedui FROM MES_INV_ITEM_BARCODES_TBMX A LEFT JOIN WOMDAA B ON B.daa001 = A.DAA_001 LEFT JOIN MES_ITEMS C ON C.item_id = B.daa002 @@ -536,7 +649,7 @@ public dynamic SubmitKbInspection(dynamic query) { if (query == null) throw new ArgumentNullException(nameof(query), "鍙傛暟瀵硅薄涓嶈兘涓� null"); - + // 鍙傛暟鏍¢獙 if (string.IsNullOrEmpty(query.userAccount?.ToString())) throw new ArgumentException("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖", nameof(query.userAccount)); @@ -593,7 +706,7 @@ //鏍规嵁宸ュ崟鍙疯繑鍥炰骇鍝佸瀷鍙峰拰寰呴鐗╂枡 - public ProductionPickDto GetItemsXcsl(WarehouseQuery query) + public XcslResultDto GetItemsXcsl(WarehouseQuery query) { if (string.IsNullOrEmpty(query.daa001)) throw new Exception("宸ュ崟鍙蜂负绌�"); @@ -605,63 +718,832 @@ .Select((a, i) => new { a.Daa001, - a.CaaGuid + a.CaaGuid, + a.Daa008, + a.Daa021 }).First(); if (womdaa?.Daa001 == null) throw new Exception("宸ュ崟鍙蜂笉瀛樺湪"); - 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 - FROM WOMDAB B - LEFT JOIN WOMDAA A ON A.guid = B.daaGuid - LEFT JOIN MES_ITEMS C ON B.dab003 = C.item_id - LEFT JOIN WOMCAB D ON B.erpid = D.ERPID - WHERE daa001 = '{0}' AND ISSUE_TYPE = 1 ORDER BY DAB002", query.daa001); + // 浣跨敤鍙傛暟鍖栨煡璇㈤槻姝QL娉ㄥ叆 + var sqlParams = new List<SugarParameter> { new("@daa001", query.daa001) }; - var womdabs = Db.Ado.SqlQuery<ItemDetailModel>(sql); + var sql1 = @"SELECT A.item_out_no, + SUM(B.QUANTITY) AS BL_Num, + ISNULL(Sub.JS_Sum, 0) AS JS_Num, -- 浣跨敤LEFT JOIN瀛愭煡璇㈢殑缁撴灉 + C.item_no, + C.item_name, + C.item_model, + D.USER_NAME +FROM MES_INV_ITEM_OUTS A + LEFT JOIN MES_INV_ITEM_OUT_C_DETAILS B ON A.GUID = B.ITEM_OUT_ID + LEFT JOIN MES_ITEMS C ON B.ITEM_ID = C.item_id + LEFT JOIN SYS_USER D ON A.create_by = D.ACCOUNT +-- 鏂板LEFT JOIN鑱氬悎瀛愭煡璇� + LEFT JOIN (SELECT B1.ITEM_ID, + SUM(B1.QUANTITY) AS JS_Sum + FROM MES_INV_ITEM_OUTS A1 + LEFT JOIN MES_INV_ITEM_OUT_C_DETAILS B1 ON A1.GUID = B1.ITEM_OUT_ID + WHERE A1.out_type = '鐢熶骇棰嗘枡' + AND A1.task_no = @daa001 + AND ISNULL(B1.IS_XCSL, '0') = 1 + GROUP BY B1.ITEM_ID -- 鎸塈TEM_ID鎻愬墠鑱氬悎 +) AS Sub ON Sub.ITEM_ID = C.item_id +WHERE A.out_type = '鐢熶骇棰嗘枡' + AND A.task_no = @daa001 +GROUP BY A.item_out_no, + C.item_no, + C.item_name, + C.item_model, + D.USER_NAME, + C.item_id, + ISNULL(Sub.JS_Sum, 0);"; + + var XcslItem = Db.Ado.SqlQuery<dynamic>(sql1, sqlParams); + + var sql2 = @"SELECT B.ITEM_BARCODE ,B.QUANTITY,C.item_no,C.item_name,D.USER_NAME,A.create_date +FROM MES_INV_ITEM_OUTS A +LEFT JOIN MES_INV_ITEM_OUT_C_DETAILS B ON A.GUID = B.ITEM_OUT_ID +LEFT JOIN MES_ITEMS C ON B.ITEM_ID = C.item_id +LEFT JOIN SYS_USER D ON A.create_by = D.ACCOUNT +WHERE out_type = '鐢熶骇棰嗘枡' +AND A.task_no = @daa001 +AND ISNULL(IS_XCSL,'0') = 0"; + + var XcslWjsBar = Db.Ado.SqlQuery<dynamic>(sql2, sqlParams); + + var sql3 = @"SELECT B.ITEM_BARCODE ,B.QUANTITY,C.item_no,C.item_name,D.USER_NAME,B.XCSL_CREATE_DATE +FROM MES_INV_ITEM_OUTS A +LEFT JOIN MES_INV_ITEM_OUT_C_DETAILS B ON A.GUID = B.ITEM_OUT_ID +LEFT JOIN MES_ITEMS C ON B.ITEM_ID = C.item_id +LEFT JOIN SYS_USER D ON B.XCSL_CREATE_BY = D.ACCOUNT +WHERE out_type = '鐢熶骇棰嗘枡' +AND A.task_no = @daa001 +AND ISNULL(IS_XCSL,'0') = 1"; + + var XcslYjsBar = Db.Ado.SqlQuery<dynamic>(sql3, sqlParams); - var DS_list = womdabs.Where(s => s.DSQty > 0).ToList(); - - var YS_list = womdabs.Where(s => s.SQty > 0).ToList(); - - var mesInvItemOutCDetailsList = Db - .Queryable<MesInvItemOutCDetails, MesItems, MesDepots> - ((a, b, c) => - new JoinQueryInfos( - JoinType.Inner, a.ItemId == b.Id, - JoinType.Inner, c.DepotId == a.DepotId - )) - .Where((a, b, c) => a.WorkNo == query.daa001) - .Select((a, b, c) => new MesInvItemOutCDetails - { - ItemName = b.ItemName, - ItemNo = b.ItemNo, - ItemId = a.ItemId, - DepotId = a.DepotId, - WorkNo = a.WorkNo, - DepotName = c.DepotName, - Quantity = a.Quantity - }) - .ToList(); - - var womcaa = Db.Queryable<Womcaa>().Where(s => s.Guid == womdaa.CaaGuid) - .First(); - - if (womcaa == null) + var dto = new XcslResultDto { - throw new Exception("鐢熶骇浠诲姟鍗曚笉瀛樺湪"); - } + GD_Num = womdaa.Daa008, + workNo = womdaa.Daa021, + XcslItemList = XcslItem, + XcslWjsBarList = XcslWjsBar, + XcslYjsBarList = XcslYjsBar - var dto = new ProductionPickDto - { - daa001 = womdaa.Daa001, - PlanNo = womcaa.Caa020, - items = DS_list, - Ysitems = YS_list - // yisao = mesInvItemOutCDetailsList }; return dto; } + + // 鐜板満鏀舵枡灞曠ず鍒楄〃 + 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; } + } + + + public dynamic ScanXcsl(dynamic query) + { + if (query == null) throw new ArgumentNullException(nameof(query), "鍙傛暟瀵硅薄涓嶈兘涓� null"); + + // 鍙傛暟鏍¢獙锛堟牴鎹瓨鍌ㄨ繃绋嬫柊澧炲弬鏁帮級 + if (string.IsNullOrEmpty(query.userAccount?.ToString())) + throw new ArgumentException("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖", nameof(query.userAccount)); + + if (string.IsNullOrEmpty(query.Bar?.ToString())) + throw new ArgumentException("鐗╂枡鏉$爜涓嶅厑璁镐负绌�", nameof(query.Bar)); + + if (string.IsNullOrEmpty(query.DAA001?.ToString())) + throw new ArgumentException("宸ュ崟鍗曞彿涓嶅厑璁镐负绌�", nameof(query.DAA001)); + + var _strMsg = ""; + var _status = -1; + using (var conn = new SqlConnection(DbHelperSQL.strConn)) + { + using (var cmd = new SqlCommand("prc_pda_ScanXcsl", conn)) + { + try + { + conn.Open(); + cmd.CommandType = CommandType.StoredProcedure; + // 鏍规嵁瀛樺偍杩囩▼璋冩暣鍙傛暟椤哄簭鍜屽懡鍚� + SqlParameter[] parameters = + { + new("@pi_user", SqlDbType.NVarChar, 100) { Value = query.userAccount }, + new("@pi_barcode", SqlDbType.NVarChar, 100) { Value = query.Bar }, + new("@pi_daa001", SqlDbType.NVarChar, 100) { Value = query.DAA001 }, + 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() ?? ""; + _status = Convert.ToInt32(parameters[4].Value ?? -1); + + if (_status <= 0) throw new Exception(_strMsg); + + return new + { + message = _strMsg, + status = _status, + daa001 = query.DAA001, + barCode = query.Bar + }; + } + catch (Exception ex) + { + throw new Exception($"浜х嚎鏀舵枡澶辫触锛歿ex.Message}"); + } + finally + { + conn.Close(); + } + } + } + } + + + public dynamic GetWeightByXt(dynamic query) + { + if (query == null) throw new ArgumentNullException(nameof(query), "鍙傛暟瀵硅薄涓嶈兘涓簄ull"); + + // 鍙傛暟鏍¢獙 + if (string.IsNullOrEmpty(query.userName?.ToString())) + throw new ArgumentException("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖", nameof(query.userName)); + + if (string.IsNullOrEmpty(query.LsBar?.ToString())) + throw new ArgumentException("鍗℃澘鏉$爜涓嶅厑璁镐负绌�", nameof(query.LsBar)); + + var _strMsg = ""; + var _status = -1; + var _weight = "0"; + + using (var conn = new SqlConnection(DbHelperSQL.strConn)) + { + using (var cmd = new SqlCommand("prc_pda_Xbar_chenzhong", conn)) + { + try + { + conn.Open(); + cmd.CommandType = CommandType.StoredProcedure; + + SqlParameter[] parameters = + { + new("@pi_user", SqlDbType.NVarChar, 100) { Value = query.userName }, + new("@pi_ls_barcode", SqlDbType.NVarChar, 100) { Value = query.LsBar }, + new("@po_outMsg", SqlDbType.NVarChar, 2000) { Direction = ParameterDirection.Output }, + new("@po_outStatus", SqlDbType.Int) { Direction = ParameterDirection.Output }, + new("@po_outWeight", SqlDbType.NVarChar, 100) { Direction = ParameterDirection.Output } + }; + + cmd.Parameters.AddRange(parameters); + cmd.ExecuteNonQuery(); + + _strMsg = parameters[2].Value?.ToString() ?? ""; + _status = Convert.ToInt32(parameters[3].Value ?? -1); + _weight = parameters[4].Value?.ToString() ?? "0"; + + if (_status <= 0) throw new Exception(_strMsg); + + return new + { + message = _strMsg, + status = _status, + weight = _weight, + barCode = query.Bar + }; + } + catch (Exception ex) + { + throw new Exception($"浜у搧绉伴噸澶辫触锛歿ex.Message}"); + } + finally + { + conn.Close(); + } + } + } + } + + public dynamic GetXcslDaa(dynamic unity) + { + + var sqlParams = new List<SugarParameter> { }; + + var sql2 = new StringBuilder(@" + SELECT '['+DAA001+']['+DAA021+']' AS daaInfo,DAA001,DAA021 + FROM WOMDAA + WHERE daa018 <>'W:瀹屽伐'"); + + if (!string.IsNullOrWhiteSpace(unity.selectKey?.ToString())) + { + sqlParams.Add(new("@selectKey", unity.selectKey)); + sql2.Append(@" + AND (DAA001 LIKE '%' + @selectKey + '%' + OR DAA021 LIKE '%' + @selectKey + '%')"); + } + + var XcslItem = Db.Ado.SqlQuery<dynamic>(sql2.ToString(), sqlParams); + + if (XcslItem == null) + { + throw new Exception("璇ユ潯浠朵笅鏃犲搴斿伐鍗曚俊鎭紝璇烽噸鏂拌緭鍏ワ紒"); + } + + return XcslItem; + } + + + public XcslResultDto GetItemsXctl(WarehouseQuery query) + { + if (string.IsNullOrEmpty(query.daa001)) throw new Exception("宸ュ崟鍙蜂负绌�"); + + var womdaa = Db.Queryable<Womdaa, MesItems>((a, i) => + new JoinQueryInfos(JoinType.Left, + a.Daa002 == i.ItemId.ToString())) + .Where((a, i) => a.Daa001 == query.daa001 + && a.Fstatus == 1) + .Select((a, i) => new + { + a.Daa001, + a.CaaGuid, + a.Daa008, + a.Daa021 + }).First(); + + if (womdaa?.Daa001 == null) throw new Exception("宸ュ崟鍙蜂笉瀛樺湪"); + + // 浣跨敤鍙傛暟鍖栨煡璇㈤槻姝QL娉ㄥ叆 + var sqlParams = new List<SugarParameter> { new("@daa001", query.daa001) }; + + var sql1 = @"SELECT A.item_out_no, + SUM(B.QUANTITY) AS BL_Num, + ISNULL(SL_SUM.JS_Sum, 0) AS JS_Num, + ISNULL(TL_SUM.JS_Sum, 0) AS TR_Num, + C.item_no, + C.item_name, + C.item_model +FROM MES_INV_ITEM_OUTS A + LEFT JOIN MES_INV_ITEM_OUT_C_DETAILS B ON A.GUID = B.ITEM_OUT_ID + LEFT JOIN MES_ITEMS C ON B.ITEM_ID = C.item_id + LEFT JOIN SYS_USER D ON A.create_by = D.ACCOUNT + LEFT JOIN (SELECT B1.ITEM_ID, + SUM(B1.QUANTITY) AS JS_Sum + FROM MES_INV_ITEM_OUTS A1 + LEFT JOIN MES_INV_ITEM_OUT_C_DETAILS B1 ON A1.GUID = B1.ITEM_OUT_ID + WHERE A1.out_type = '鐢熶骇棰嗘枡' + AND A1.task_no = @daa001 + AND ISNULL(B1.IS_XCSL, '0') = 1 + GROUP BY B1.ITEM_ID +) AS SL_SUM ON SL_SUM.ITEM_ID = C.item_id + LEFT JOIN (SELECT B1.ITEM_ID, + SUM(B1.QUANTITY) AS JS_Sum + FROM MES_INV_ITEM_OUTS A1 + LEFT JOIN MES_INV_ITEM_OUT_C_DETAILS B1 ON A1.GUID = B1.ITEM_OUT_ID + WHERE A1.out_type = '鐢熶骇棰嗘枡' + AND A1.task_no = @daa001 + AND ISNULL(B1.IS_CXTR, '0') = 1 + GROUP BY B1.ITEM_ID +) AS TL_SUM ON TL_SUM.ITEM_ID = C.item_id +WHERE A.out_type = '鐢熶骇棰嗘枡' + AND A.task_no = @daa001 +GROUP BY A.item_out_no, + C.item_no, + C.item_name, + C.item_model, + D.USER_NAME, + C.item_id, + ISNULL(SL_SUM.JS_Sum, 0), + ISNULL(TL_SUM.JS_Sum, 0);"; + + var XcslItem = Db.Ado.SqlQuery<dynamic>(sql1, sqlParams); + + var sql2 = @"SELECT B.ITEM_BARCODE ,B.QUANTITY,C.item_no,C.item_name,D.USER_NAME,A.create_date +FROM MES_INV_ITEM_OUTS A +LEFT JOIN MES_INV_ITEM_OUT_C_DETAILS B ON A.GUID = B.ITEM_OUT_ID +LEFT JOIN MES_ITEMS C ON B.ITEM_ID = C.item_id +LEFT JOIN SYS_USER D ON A.create_by = D.ACCOUNT +WHERE out_type = '鐢熶骇棰嗘枡' +AND A.task_no = @daa001 +AND ISNULL(IS_CXTR,'0') = 0"; + + var XcslWjsBar = Db.Ado.SqlQuery<dynamic>(sql2, sqlParams); + + var sql3 = @"SELECT B.ITEM_BARCODE ,B.QUANTITY,C.item_no,C.item_name,D.USER_NAME,B.CXTR_CREATE_DATE +FROM MES_INV_ITEM_OUTS A +LEFT JOIN MES_INV_ITEM_OUT_C_DETAILS B ON A.GUID = B.ITEM_OUT_ID +LEFT JOIN MES_ITEMS C ON B.ITEM_ID = C.item_id +LEFT JOIN SYS_USER D ON B.CXTR_CREATE_BY = D.ACCOUNT +WHERE out_type = '鐢熶骇棰嗘枡' +AND A.task_no = @daa001 +AND ISNULL(IS_CXTR,'0') = 1"; + + var XcslYjsBar = Db.Ado.SqlQuery<dynamic>(sql3, sqlParams); + + + var dto = new XcslResultDto + { + GD_Num = womdaa.Daa008, + workNo = womdaa.Daa021, + XcslItemList = XcslItem, + XcslWjsBarList = XcslWjsBar, + XcslYjsBarList = XcslYjsBar + + }; + + return dto; + } + + public dynamic ScanXctl(dynamic query) + { + if (query == null) throw new ArgumentNullException(nameof(query), "鍙傛暟瀵硅薄涓嶈兘涓� null"); + + // 鍙傛暟鏍¢獙锛堟牴鎹瓨鍌ㄨ繃绋嬫柊澧炲弬鏁帮級 + if (string.IsNullOrEmpty(query.userAccount?.ToString())) + throw new ArgumentException("鐢ㄦ埛鍚嶄笉鍏佽涓虹┖", nameof(query.userAccount)); + + if (string.IsNullOrEmpty(query.Bar?.ToString())) + throw new ArgumentException("鐗╂枡鏉$爜涓嶅厑璁镐负绌�", nameof(query.Bar)); + + if (string.IsNullOrEmpty(query.DAA001?.ToString())) + throw new ArgumentException("宸ュ崟鍗曞彿涓嶅厑璁镐负绌�", nameof(query.DAA001)); + + var _strMsg = ""; + var _status = -1; + using (var conn = new SqlConnection(DbHelperSQL.strConn)) + { + using (var cmd = new SqlCommand("prc_pda_ScanXctl", conn)) + { + try + { + conn.Open(); + cmd.CommandType = CommandType.StoredProcedure; + // 鏍规嵁瀛樺偍杩囩▼璋冩暣鍙傛暟椤哄簭鍜屽懡鍚� + SqlParameter[] parameters = + { + new("@pi_user", SqlDbType.NVarChar, 100) { Value = query.userAccount }, + new("@pi_barcode", SqlDbType.NVarChar, 100) { Value = query.Bar }, + new("@pi_daa001", SqlDbType.NVarChar, 100) { Value = query.DAA001 }, + 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() ?? ""; + _status = Convert.ToInt32(parameters[4].Value ?? -1); + + if (_status <= 0) throw new Exception(_strMsg); + + return new + { + message = _strMsg, + status = _status, + daa001 = query.DAA001, + barCode = query.Bar + }; + } + catch (Exception ex) + { + throw new Exception($"浜х嚎鏀舵枡澶辫触锛歿ex.Message}"); + } + finally + { + conn.Close(); + } + } + } + } + + + /// <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