From b727409bf046acea9533065da35e8e3872cac783 Mon Sep 17 00:00:00 2001 From: 南骏 池 <chiffly@163.com> Date: 星期五, 22 八月 2025 10:54:32 +0800 Subject: [PATCH] 1.生产领料库位信息查询 --- service/Wom/WomdaaManager.cs | 322 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 320 insertions(+), 2 deletions(-) diff --git a/service/Wom/WomdaaManager.cs b/service/Wom/WomdaaManager.cs index f2ee0f5..9f640c8 100644 --- a/service/Wom/WomdaaManager.cs +++ b/service/Wom/WomdaaManager.cs @@ -203,7 +203,7 @@ // }) // .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 , + 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 @@ -309,6 +309,37 @@ 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) { if (query == null) throw new ArgumentNullException(nameof(query), "鍙傛暟瀵硅薄涓嶈兘涓� null"); @@ -385,7 +416,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 @@ -1219,4 +1250,291 @@ } } + /// <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