From 0455bf50d8721a65437c1e9a5477d64499761502 Mon Sep 17 00:00:00 2001 From: 南骏 池 <chiffly@163.com> Date: 星期五, 30 五月 2025 14:46:17 +0800 Subject: [PATCH] 1.首检功能”制热性能“表格生成。 --- service/QC/IpqcService.cs | 124 ++++++++++++++++++++++++++-------------- 1 files changed, 80 insertions(+), 44 deletions(-) diff --git a/service/QC/IpqcService.cs b/service/QC/IpqcService.cs index 3165c8d..4a34a12 100644 --- a/service/QC/IpqcService.cs +++ b/service/QC/IpqcService.cs @@ -169,58 +169,94 @@ public dynamic CreateByWomdaa(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.inOrderGuid1?.ToString())) - throw new ArgumentException("妫�楠屽崟GUID涓嶈兘涓虹┖", nameof(query.inOrderGuid1)); - - if (string.IsNullOrEmpty(query.DAA001?.ToString())) - throw new ArgumentException("宸ュ崟鍙蜂笉鑳戒负绌�", nameof(query.inOrderGuid1)); - - var _strMsg = ""; - var _status = -1; - - using (var conn = new SqlConnection(DbHelperSQL.strConn)) - using (var cmd = new SqlCommand("ipqc_createByWomdaa", conn)) { - try + if (query == null) throw new ArgumentNullException(nameof(query)); + + if (string.IsNullOrEmpty(query.userAccount?.ToString())) + throw new ArgumentException("鐢ㄦ埛璐﹀彿涓嶈兘涓虹┖", nameof(query.userAccount)); + + if (string.IsNullOrEmpty(query.inOrderGuid1?.ToString())) + throw new ArgumentException("妫�楠屽崟GUID涓嶈兘涓虹┖", nameof(query.inOrderGuid1)); + + if (string.IsNullOrEmpty(query.DAA001?.ToString())) + throw new ArgumentException("宸ュ崟鍙蜂笉鑳戒负绌�", nameof(query.inOrderGuid1)); + + var _strMsg = ""; + var _status = -1; + + using (var conn = new SqlConnection(DbHelperSQL.strConn)) + using (var cmd = new SqlCommand("ipqc_createByWomdaa", conn)) { - conn.Open(); - cmd.CommandType = CommandType.StoredProcedure; - - SqlParameter[] parameters = + try { - new("@po_outMsg", SqlDbType.NVarChar, 150) { Direction = ParameterDirection.Output }, - new("@po_outStatus", SqlDbType.Int) { Direction = ParameterDirection.Output }, - new("@pi_user", SqlDbType.NVarChar, 150) { Value = query.userAccount }, - new("@pi_OrderGuid1", SqlDbType.UniqueIdentifier) { Value = Guid.Parse(query.inOrderGuid1.ToString()) }, - new("@pi_DAA001", SqlDbType.NVarChar, 150) { Value = query.DAA001.ToString() }, - new("@pi_inP1", SqlDbType.NVarChar, 20) { Value = query.pi_inP1 ?? DBNull.Value }, - new("@pi_inP2", SqlDbType.NVarChar, 20) { Value = query.pi_inP2 ?? DBNull.Value } - }; + conn.Open(); + cmd.CommandType = CommandType.StoredProcedure; - cmd.Parameters.AddRange(parameters); - cmd.ExecuteNonQuery(); + SqlParameter[] parameters = + { + new("@po_outMsg", SqlDbType.NVarChar, 150) { Direction = ParameterDirection.Output }, + new("@po_outStatus", SqlDbType.Int) { Direction = ParameterDirection.Output }, + new("@pi_user", SqlDbType.NVarChar, 150) { Value = query.userAccount }, + new("@pi_OrderGuid1", SqlDbType.UniqueIdentifier) { Value = Guid.Parse(query.inOrderGuid1.ToString()) }, + new("@pi_DAA001", SqlDbType.NVarChar, 150) { Value = query.DAA001.ToString() }, + new("@pi_inP1", SqlDbType.NVarChar, 20) { Value = query.pi_inP1 ?? DBNull.Value }, + new("@pi_inP2", SqlDbType.NVarChar, 20) { Value = query.pi_inP2 ?? DBNull.Value } + }; - _strMsg = parameters[0].Value?.ToString() ?? ""; - _status = Convert.ToInt32(parameters[1].Value ?? -1); + cmd.Parameters.AddRange(parameters); + cmd.ExecuteNonQuery(); - if (_status <= 0) throw new Exception(_strMsg); + _strMsg = parameters[0].Value?.ToString() ?? ""; + _status = Convert.ToInt32(parameters[1].Value ?? -1); - return new + if (_status <= 0) throw new Exception(_strMsg); + + return new + { + message = _strMsg, + status = _status + }; + } + catch (Exception ex) { - message = _strMsg, - status = _status - }; - } - catch (Exception ex) - { - throw new Exception($"妫�楠屽崟鏇存柊澶辫触锛歿ex.Message}"); + throw new Exception($"妫�楠屽崟鏇存柊澶辫触锛歿ex.Message}"); + } } } -} + + public int UpdateTableConfig(string selectedWater, string selectedFlow, string tableData, string mxguid) + { + var sqlParams = new List<SugarParameter> { + new("@selectedWater", selectedWater), + new("@selectedFlow", selectedFlow), + new("@tableData", tableData), + new("@mxguid", mxguid) + }; + + var sql = @"UPDATE MES_QA_ITEMS_DETECT_DETAIL5 + SET ipqc_zrxn_sel1 = @selectedWater, + ipqc_zrxn_sel2 = @selectedFlow, + ipqc_zrxn_table = @tableData + WHERE guid = @mxguid"; + + return Db.Ado.ExecuteCommand(sql, sqlParams); + } + + public dynamic GetTableConfig(string mxguid) + { + var sqlParams = new List<SugarParameter> { + new("@mxguid", mxguid) + }; + + var sql = @"SELECT ipqc_zrxn_sel1,ipqc_zrxn_sel2,ipqc_zrxn_table + FROM MES_QA_ITEMS_DETECT_DETAIL5 + WHERE guid = @mxguid"; + + var result = Db.Ado.SqlQuery<dynamic>(sql, sqlParams).FirstOrDefault(); + + if (result == null) + throw new Exception("閰嶇疆淇℃伅鏌ヨ缁撴灉涓虹┖"); + + return result; + } } \ No newline at end of file -- Gitblit v1.9.3