From 7ca0d964d2df19bf56e8a8a96f34f26a139b078d Mon Sep 17 00:00:00 2001
From: zrg <z1873@LAPTOP-EAVL132E>
Date: 星期五, 27 二月 2026 15:23:57 +0800
Subject: [PATCH] 增加异常工艺参数预警通知
---
DingDingMsg/MesMessage/GeTuiService.cs | 150 ++++++++++++++++++++++++++++++++++++-------------
1 files changed, 109 insertions(+), 41 deletions(-)
diff --git a/DingDingMsg/MesMessage/GeTuiService.cs b/DingDingMsg/MesMessage/GeTuiService.cs
index 3988dcf..75713f7 100644
--- a/DingDingMsg/MesMessage/GeTuiService.cs
+++ b/DingDingMsg/MesMessage/GeTuiService.cs
@@ -2,7 +2,9 @@
using com.igetui.api.openservice.igetui;
using com.igetui.api.openservice.igetui.template;
using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
using System;
+using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data;
@@ -15,6 +17,8 @@
private static readonly string APPID = "X3I10VqaROAH8C7ElIc1L5";
private static readonly string APPKEY = "V425beWn5K65BcOYKTcXx8";
private static readonly string MASTERSECRET = "LOXAgRbXS98NxHKUXmlJQ";
+ static DBHelper oCN = new DBHelper();
+ static DataSet ds = new DataSet();
// 娉ㄦ剰锛氫笉鍐嶅0鏄庨潤鎬� IGtPush 瀛楁锛岄伩鍏嶇被鍨嬪垵濮嬪寲寮傚父
@@ -23,61 +27,112 @@
/// </summary>
public static void PubishSingle(int HInterID)
{
+
+
try
{
- DataSet ds = new DataSet();
- DBHelper oCN = new DBHelper();
+ JObject NameMsgKVP = new JObject();
ds = oCN.RunProcReturn($@"
- select * from h_v_OA_WorkLinkBillAllList where hmainid = {HInterID};
+ select * from h_v_OA_WorkLinkBillAllList where hmainid = {HInterID}
select * from Gy_UserClientIdRelation
", "h_v_OA_WorkLinkBillAllList");
-
- if (ds.Tables[0].Rows.Count == 0) return;
-
- DataRow billRow = ds.Tables[0].Rows[0];
- string title = billRow["涓婚"].ToString();
- string content = billRow["鍐呭"].ToString();
- string sendType = billRow["鍙戦�佺被鍨�"].ToString();
- string receiver = billRow["鎺ユ敹浜�"].ToString();
- string ccReceiver = billRow["鎶勯�佹帴鏀朵汉"].ToString();
-
- // 鍒涘缓閫氱煡妯℃澘
- var template = GetNotificationTemplate(
- title,
- content,
- "/pages/ZLGL/OA_WorkLink/OA_WorkLinkBillQuery",
- "0"
- );
-
- bool anySuccess = false;
-
- // 閬嶅巻鎵�鏈夊鎴风ID
- foreach (DataRow userRow in ds.Tables[1].Rows)
+ NotificationTemplate template = null;
+ ConcurrentDictionary<string, List<string>> userClientIDDictionary = new ConcurrentDictionary<string, List<string>>();
+ // 灏嗙敤鎴疯澶囧叧鑱旇〃 鏀堕泦涓� Map
+ if (ds.Tables[1].Rows.Count > 0)
{
- string userName = userRow["HUserName"].ToString();
- string clientId = userRow["HClientID"].ToString();
-
- bool needPush = sendType == "鍏叡" ||
- userName == receiver ||
- userName == ccReceiver;
-
- if (needPush)
+ foreach (DataRow row in ds.Tables[1].Rows)
{
- bool success = PushMessageToSingle(template, clientId);
- if (success) anySuccess = true;
+ if (userClientIDDictionary.ContainsKey(row["HUserName"].ToString()))
+ {
+ userClientIDDictionary[row["HUserName"].ToString()].Add(row["HClientID"].ToString());
+ }
+ else
+ {
+ userClientIDDictionary.TryAdd(row["HUserName"].ToString(), new List<string>() { row["HClientID"].ToString() });
+ }
}
}
-
- if (!anySuccess)
+ if (ds.Tables[0].Rows.Count > 0)
{
- // 鎺ㄩ�佸け璐ワ紝澶囩敤鏂规锛氫娇鐢� RabbitMQ 鎴� WebSocket
- DBHelper.CustomWriteLog("涓帹鎺ㄩ�佸け璐ワ紙鍙兘鍐呯綉鍘熷洜锛夛紝灏濊瘯澶囩敤鏂规", DateTime.Now.ToString("yyyy-MM-dd"));
- // WebSocketServer.PushOne(HInterID);
+ string title = ds.Tables[0].Rows[0]["涓婚"].ToString();
+ string content = ds.Tables[0].Rows[0]["鍐呭"].ToString();
+ template = GetNotificationTemplate(title, content, "/pages/ZLGL/OA_WorkLink/OA_WorkLinkBillQuery", "0"); // 璺宠浆鍒板伐浣滆仈绯诲崟鏌ヨ椤甸潰
+
+ bool pushSuccess = false;
+ // 骞挎挱
+ if (ds.Tables[0].Rows[0]["鍙戦�佺被鍨�"].ToString() == "鍏叡")
+ {
+ string rule = GetSystemRule();
+ if (rule == "鍗庤垷")
+ {
+ // 鎺ㄩ�佺粰鎺ユ敹浜� 鍜� 鎶勯�佷汉
+ foreach (DataRow row in ds.Tables[0].Rows)
+ {
+ List<string> clientIDList = new List<string>();
+ if (userClientIDDictionary.ContainsKey(row["鎺ユ敹浜�"].ToString()))
+ {
+ clientIDList = userClientIDDictionary[row["鎺ユ敹浜�"].ToString()];
+ }
+ else if (userClientIDDictionary.ContainsKey(row["鎶勯�佹帴鏀朵汉"].ToString()))
+ {
+ clientIDList = userClientIDDictionary[row["鎶勯�佹帴鏀朵汉"].ToString()];
+ }
+
+
+ foreach (string clientID in clientIDList)
+ {
+ pushSuccess = PushMessageToSingle(template, clientID);
+
+ }
+ }
+ }
+ else
+ {
+ // 閬嶅巻 鍏ㄦ帹閫�
+ foreach (DataRow row in ds.Tables[1].Rows)
+ {
+ pushSuccess = PushMessageToSingle(template, row["HClientID"].ToString());
+ }
+ }
+ }
+ else // 鍗曠嫭鎺ㄩ��
+ {
+ // 鎺ㄩ�佺粰鎺ユ敹浜� 鍜� 鎶勯�佷汉
+ foreach (DataRow row in ds.Tables[0].Rows)
+ {
+ List<string> clientIDList = new List<string>();
+ if (userClientIDDictionary.ContainsKey(row["鎺ユ敹浜�"].ToString()))
+ {
+ clientIDList = userClientIDDictionary[row["鎺ユ敹浜�"].ToString()];
+ }
+ else if (userClientIDDictionary.ContainsKey(row["鎶勯�佹帴鏀朵汉"].ToString()))
+
+ {
+ clientIDList = userClientIDDictionary[row["鎶勯�佹帴鏀朵汉"].ToString()];
+ }
+
+
+ foreach (string clientID in clientIDList)
+ {
+ pushSuccess = PushMessageToSingle(template, clientID);
+
+ }
+ }
+ }
+
+ if (!pushSuccess)
+ {
+ // 涓帹 鎺ㄩ�佷笉鎴愬姛(鍐呯綉鐜) 浣跨敤webSocket杩涜鎺ㄩ��
+ // TODO: 浣跨敤 rabbitMQ 瀹炵幇娑堟伅闃熷垪
+ // WebSocketServer.PushOne(HInterID);
+ }
}
}
catch (Exception ex)
{
- DBHelper.CustomWriteLog($"PubishSingle 寮傚父: {ex}", DateTime.Now.ToString("yyyy-MM-dd"));
+ DBHelper.CustomWriteLog(ex.ToString(), DateTime.Now.ToString("yyyy-MM-dd"));
+ return;
}
}
@@ -150,5 +205,18 @@
return template;
}
+
+ /// <summary>
+ /// 鑾峰彇绯荤粺鍙傛暟 OA_AndengFlowRule_XT 鐨勫��
+ /// </summary>
+ private static string GetSystemRule()
+ {
+ string sql = "select HValue from xt_SystemParameter where HKey='WMS_CampanyName'";
+ DataSet ds = oCN.RunProcReturn(sql, "xt_SystemParameter");
+ if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
+ return ds.Tables[0].Rows[0]["HValue"].ToString();
+ return null;
+ }
+
}
}
\ No newline at end of file
--
Gitblit v1.9.1