From 6173979a0c8518e6f3785063e9bfe8c8aa960c6d Mon Sep 17 00:00:00 2001
From: tjx <t2856754968@163.com>
Date: 星期三, 15 十月 2025 10:02:03 +0800
Subject: [PATCH] 异常处置单的修改,取消获取OA数据
---
DevApp/Gs.DevApp/DevFrm/QC/MesQcExceptional.cs | 137 +++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 130 insertions(+), 7 deletions(-)
diff --git a/DevApp/Gs.DevApp/DevFrm/QC/MesQcExceptional.cs b/DevApp/Gs.DevApp/DevFrm/QC/MesQcExceptional.cs
index 26ca0ad..968593e 100644
--- a/DevApp/Gs.DevApp/DevFrm/QC/MesQcExceptional.cs
+++ b/DevApp/Gs.DevApp/DevFrm/QC/MesQcExceptional.cs
@@ -252,16 +252,20 @@
// 鑾峰彇褰撳墠鏄庣粏琛岀殑GUID
Guid? _guid = UtilityHelper.ToGuid(row["guid"].ToString());
// 娣诲姞鏄庣粏椤瑰埌璇锋眰瀵硅薄
+ // 璇存槑锛�
+ // 鈶� 鏃ч�昏緫浣跨敤 row["process"].ToString()锛屽悗鍙板彧瑕佹妸鍒楀悕鏀规垚 processName/gs003 鎴栧瓨鍦ㄥぇ灏忓啓宸紓锛屽氨浼氭姏鍑� 鈥淐olumn 'process' does not belong to table鈥� 寮傚父锛�
+ // 鈶� GetRowString 浼氬湪 DataTable 涓寜涓嶅尯鍒嗗ぇ灏忓啓鐨勬柟寮忛�愪釜鍖归厤鍊欓�夊垪鍚嶏紝骞舵妸 DBNull/null 缁熶竴杞崲涓虹┖瀛楃涓诧紝鍏煎涓嶅悓鎺ュ彛涓庡巻鍙叉暟鎹紱
+ // 鈶� 瀛楁鍒楄〃鎻愪緵澶氫釜鍊欓�夊�硷紙process/processName/processDesc/processWay/gs003锛夛紝纭繚鍚庣瀛楁鍛藉悕璋冩暣鏃朵粛鑳芥垚鍔熶繚瀛樸��
_obj.list.Add(new
{
Guid = _guid,
- BatchQty = (row["batchQty"].ToString()), // 鎵规鏁伴噺
- GfRkqty = (row["gfRkqty"].ToString()), // 鍚堟牸鍏ュ簱鏁伴噺
- LfRkqtyz = (row["lfRkqty"].ToString()), // 涓嶅悎鏍煎叆搴撴暟閲�
- HandResult = (row["handResult"].ToString()), // 閫夊埆绫诲瀷
- ChooseType = (row["chooseType"].ToString()), // 澶勭悊鎰忚
- Process = (row["process"].ToString()), // 閫�鏂欐柟寮�
-
+ BatchQty = GetRowString(row, "batchQty"), // 鎵规鏁伴噺
+ GfRkqty = GetRowString(row, "gfRkqty"), // 鍚堟牸鍏ュ簱鏁�
+ LfRkqtyz = GetRowString(row, "lfRkqty"), // 涓存斁鍏ュ簱鏁�
+ HandResult = GetRowString(row, "handResult"), // 閫夊埆鎰忚
+ ChooseType = GetRowString(row, "chooseType"), // 寮傚父绫诲埆
+ Process = GetRowString(row, "process", "processName", "processDesc", "processWay", "gs003"), // 閫�鏂欐柟寮�
+
});
}
}
@@ -430,6 +434,7 @@
// 灏嗘槑缁嗘暟鎹殑JSON鏁扮粍杞崲涓篋ataTable锛堥�傚悎浣滀负缃戞牸鎺т欢鐨勬暟鎹簮锛�
DataTable dt = JsonConvert.DeserializeObject<DataTable>(array.ToString());
+ EnsureProcessColumn(dt);
// 鑻ユ槑缁嗘暟鎹瓨鍦紙DataTable琛屾暟>0锛�
if (dt.Rows.Count > 0)
@@ -465,6 +470,124 @@
}
}
/// <summary>
+ /// 缁熶竴灏佽 DataRow 瀛楁璇诲彇閫昏緫锛氭寜鐓у�欓�夊垪鍚嶅垪琛ㄤ緷娆℃煡鎵剧湡瀹炲垪锛屽拷鐣ュぇ灏忓啓骞惰閬� DBNull銆�
+ /// </summary>
+ /// <param name="row">褰撳墠寰幆鍒扮殑 DataRow锛岃嫢涓� null 鐩存帴杩斿洖绌哄瓧绗︿覆銆�</param>
+ /// <param name="columnCandidates">鎸変紭鍏堢骇鎺掑垪鐨勫�欓�夊垪鍚嶉泦鍚堬紙渚嬪 process/processName/gs003锛夈��</param>
+ /// <returns>鍖归厤鍒扮殑鍒楀�硷紱鑻ユ墍鏈夊�欓�夊垪鍧囦笉瀛樺湪鎴栧�间负 DBNull锛屽垯杩斿洖 string.Empty銆�</returns>
+ /// <remarks>
+ /// MesQcExceptional 鐨勪繚瀛樺姩浣滀緷璧栬鏂规硶锛屼互鍏煎鍚庣鎺ュ彛瀛楁鏀瑰悕鎴栧ぇ灏忓啓宸紓锛岄伩鍏嶅啀娆″嚭鐜� 鈥淐olumn 'process' does not belong to table鈥� 寮傚父銆�
+ /// </remarks>
+ private static string GetRowString(DataRow row, params string[] columnCandidates)
+ {
+ if (row == null || row.Table == null || columnCandidates == null)
+ return string.Empty;
+
+ foreach (var candidate in columnCandidates)
+ {
+ if (string.IsNullOrEmpty(candidate))
+ continue;
+ var match = FindMatchingColumn(row.Table, candidate);
+ if (!string.IsNullOrEmpty(match))
+ return NormalizeValue(row[match]);
+ }
+
+ return string.Empty;
+ }
+
+ private static string FindMatchingColumn(DataTable table, string columnName)
+ {
+ if (table == null || string.IsNullOrEmpty(columnName))
+ return null;
+
+ foreach (DataColumn column in table.Columns)
+ {
+ if (string.Equals(column.ColumnName, columnName, StringComparison.OrdinalIgnoreCase))
+ return column.ColumnName;
+ }
+
+ return null;
+ }
+
+ private static string FindFirstAvailableColumn(DataTable table, params string[] candidates)
+ {
+ if (table == null || candidates == null)
+ return null;
+
+ foreach (var candidate in candidates)
+ {
+ var match = FindMatchingColumn(table, candidate);
+ if (!string.IsNullOrEmpty(match))
+ return match;
+ }
+
+ return null;
+ }
+
+ private static bool HasColumnExact(DataTable table, string columnName)
+ {
+ if (table == null || string.IsNullOrEmpty(columnName))
+ return false;
+
+ foreach (DataColumn column in table.Columns)
+ {
+ if (string.Equals(column.ColumnName, columnName, StringComparison.Ordinal))
+ return true;
+ }
+
+ return false;
+ }
+
+ private static void CopyColumn(DataTable table, string sourceColumnName, string targetColumnName)
+ {
+ if (table == null || string.IsNullOrEmpty(sourceColumnName) || string.IsNullOrEmpty(targetColumnName))
+ return;
+
+ if (!HasColumnExact(table, targetColumnName))
+ table.Columns.Add(targetColumnName, typeof(string));
+
+ foreach (DataRow row in table.Rows)
+ {
+ row[targetColumnName] = NormalizeValue(row[sourceColumnName]);
+ }
+ }
+
+ /// <summary>
+ /// 鍦ㄧ粦瀹� gvMx1 鏄庣粏鍓嶇‘淇� DataTable 涓瓨鍦ㄥ悕涓� process 鐨勫垪锛�
+ /// 1. 浼樺厛澶嶇敤涓嶅尯鍒嗗ぇ灏忓啓鍖归厤鍒扮殑鍚屽悕鍒楋紝淇濊瘉 GridColumn23 鐨勭粦瀹氫笉鍙楀奖鍝嶏紱
+ /// 2. 鑻ユ棤鍚屽悕鍒楋紝鍒欏皾璇曚娇鐢ㄥ父瑙佸埆鍚嶏紙processName/processDesc/processWay/gs003锛夊鍒剁敓鎴愶紱
+ /// 3. 鑻ヤ粛鏃犳硶瀹氫綅鏈夋晥鍒楋紝鍒欏垱寤虹┖鐨� process 鍒楋紝閬垮厤鍓嶇璁块棶鏃舵姏鍑哄垪涓嶅瓨鍦ㄥ紓甯搞��
+ /// </summary>
+ /// <param name="table">鎺ュ彛杩斿洖鐨勬槑缁� DataTable銆�</param>
+ private static void EnsureProcessColumn(DataTable table)
+ {
+ if (table == null)
+ return;
+
+ var existing = FindMatchingColumn(table, "process");
+ if (!string.IsNullOrEmpty(existing))
+ {
+ if (!HasColumnExact(table, "process"))
+ CopyColumn(table, existing, "process");
+ return;
+ }
+
+ var fallback = FindFirstAvailableColumn(table, "processName", "processDesc", "processWay", "gs003");
+ if (string.IsNullOrEmpty(fallback))
+ {
+ if (!HasColumnExact(table, "process"))
+ table.Columns.Add("process", typeof(string));
+ return;
+ }
+
+ CopyColumn(table, fallback, "process");
+ }
+
+ private static string NormalizeValue(object value)
+ {
+ return value == null || value == DBNull.Value ? string.Empty : value.ToString();
+ }
+ /// <summary>
/// 宸ュ叿鏉′簨浠�
/// </summary>
/// <param name="inFieldValue"></param>
--
Gitblit v1.9.3