From e9a84a2ca945afa4693306045bc244973ebe9835 Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期五, 13 三月 2026 13:44:28 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Service/GeTuiService.cs |  119 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 109 insertions(+), 10 deletions(-)

diff --git a/WebAPI/Service/GeTuiService.cs b/WebAPI/Service/GeTuiService.cs
index 164895e..5a3a75d 100644
--- a/WebAPI/Service/GeTuiService.cs
+++ b/WebAPI/Service/GeTuiService.cs
@@ -9,6 +9,7 @@
 using Newtonsoft.Json;
 using com.igetui.api.openservice.igetui.template;
 using com.igetui.api.openservice.igetui;
+using System.Collections.Concurrent;
 
 namespace WebAPI.Service
 {
@@ -28,6 +29,9 @@
         // 鎺ㄩ�佹湇鍔″疄渚�
         private static IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);
 
+        private static Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
+
+
         // 鍗曟潯娑堟伅鎺ㄩ��
         public static void PubishSingle(int HInterID)
         {
@@ -38,33 +42,126 @@
             {
                 JObject NameMsgKVP = new JObject();
                 ds = oCN.RunProcReturn($@"
-                    select * from h_v_OA_WorkLinkBillAllList where hmainid = {HInterID}
+                   select 
+                    CASE WHEN a.HBillStatus <= 1 THEN '鍒涘缓' WHEN a.HBillStatus = 2 THEN '宸插鏍�' WHEN a.HBillStatus = 3 THEN '宸插叧闂�'
+                                    WHEN a.HBillStatus = 4 THEN '宸蹭綔搴�' WHEN a.HBillStatus = 9 THEN '宸插畬鎴�' ELSE '' END AS 鍗曟嵁鐘舵��, 
+                                   a.HBillNo AS 鍗曟嵁鍙�, a.HBillType AS 鍗曟嵁绫诲瀷, CONVERT(varchar(10), a.HDate, 120) AS 鏃ユ湡, a.HRemark AS 琛ㄥご澶囨敞, 
+                                   a.HDeptID, 
+                                   a.HSendMan AS 鍙戦�佷汉, a.HReceiveMan AS 鎺ユ敹浜�,
+                                    a.HCopyMan AS 鎵�鏈夋妱閫佷汉, a.HHasten AS 鍌績娆℃暟, a.HLevel AS 绱ф�ョ▼搴�, 
+                                   a.HContext AS 涓婚, a.HDescription AS 鍐呭, a.HSendType AS 鍙戦�佺被鍨�, a.HEvaluateStatusID, 
+                                   a.HCommDate AS 寤鸿瀹屾垚鏃ユ湡, 
+                                   a.HRelationInterID AS 鍏宠仈鍗曟嵁鍐呯爜, a.HRelationEntryID AS 鍏宠仈鍗曟嵁瀛愬唴鐮�, a.HRelationBillType AS 鍏宠仈鍗曟嵁绫诲瀷, 
+                                   a.HRelationBillNo AS 鍏宠仈鍗曟嵁鍙�, a.HMaker AS 鍒跺崟浜�, a.HMakeDate AS 鍒跺崟鏃ユ湡, a.HChecker AS 瀹℃牳浜�, 
+                                   a.HCheckDate AS 瀹℃牳鏃ユ湡, a.HUpDater AS 淇敼浜�, a.HUpDateDate AS 淇敼鏃ユ湡, a.HCloseMan AS 鍏抽棴浜�, 
+                                   a.HCloseDate AS 鍏抽棴鏃ユ湡, a.HDeleteMan AS 浣滃簾浜�, a.HDeleteDate AS 浣滃簾鏃ユ湡, a.HBillType
+                    from OA_WorkLinkBillMain a where HInterID = {HInterID}
                     select * from Gy_UserClientIdRelation
-                ", "h_v_OA_WorkLinkBillAllList");
+                ", "OA_WorkLinkBillMain");
                 NotificationTemplate template = null;
+                ConcurrentDictionary<string, List<string>> userClientIDDictionary = new ConcurrentDictionary<string, List<string>>();
+                // 灏嗙敤鎴疯澶囧叧鑱旇〃 鏀堕泦涓� Map
+                if (ds.Tables[1].Rows.Count > 0)
+                {
+                    foreach (DataRow row in ds.Tables[1].Rows)
+                    {
+                        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(ds.Tables[0].Rows.Count > 0)
                 {
                     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() == "鍏叡")
                     {
-                        // 閬嶅巻 鍏ㄦ帹閫�
-                        foreach(DataRow row in ds.Tables[1].Rows)
+                        string sReturn = "";
+                        if (oSystemParameter.ShowBill(ref sReturn) == true)
                         {
-                            PushMessageToSingle(template, row["HClientID"].ToString());
+                             if (oSystemParameter.omodel.WMS_CampanyName == "鍗庤垷")
+                             {
+                                // 鑾峰彇鎺ユ敹浜哄拰鎶勯�佷汉鏁扮粍
+                                string HReceiveMan = ds.Tables[0].Rows[0]["鎺ユ敹浜�"].ToString();
+                                string[] HCopyManList = ds.Tables[0].Rows[0]["鎶勯�佷汉"].ToString().Split(',');
+                                // 鎺ㄩ�佺粰鎺ユ敹浜� 鍜� 鎶勯�佷汉
+
+                                List<string> clientIDList = new List<string>();
+                                if (userClientIDDictionary.ContainsKey(HReceiveMan))
+                                {
+                                    clientIDList.AddRange(userClientIDDictionary[HReceiveMan]);
+                                }
+
+                                foreach(string HCopyMan in HCopyManList)
+                                {
+                                    // 鎺ユ敹浜� 鍜� 鎶勯�佷汉鐩稿悓鏃�, 涓嶉噸澶嶅彂閫�
+                                    if(HCopyMan == HReceiveMan)
+                                    {
+                                        continue;
+                                    }
+                                    if (userClientIDDictionary.ContainsKey(HCopyMan))
+                                    {
+                                        clientIDList.AddRange(userClientIDDictionary[HCopyMan]);
+                                    }
+                                }
+
+                                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 // 鍗曠嫭鎺ㄩ��
                     {
+                        // 鑾峰彇鎺ユ敹浜哄拰鎶勯�佷汉鏁扮粍
+                        string HReceiveMan = ds.Tables[0].Rows[0]["鎺ユ敹浜�"].ToString();
+                        string[] HCopyManList = ds.Tables[0].Rows[0]["鎶勯�佷汉"].ToString().Split(',');
                         // 鎺ㄩ�佺粰鎺ユ敹浜� 鍜� 鎶勯�佷汉
-                        foreach (DataRow row in ds.Tables[1].Rows)
+
+                        List<string> clientIDList = new List<string>();
+                        if (userClientIDDictionary.ContainsKey(HReceiveMan))
                         {
-                            if(ds.Tables[0].Rows[0]["鎺ユ敹浜�"].ToString() == row["HUserName"].ToString()
-                                || ds.Tables[0].Rows[0]["鎶勯�佹帴鏀朵汉"].ToString() == row["HUserName"].ToString())
-                            PushMessageToSingle(template, row["HClientID"].ToString());
+                            clientIDList.AddRange(userClientIDDictionary[HReceiveMan]);
                         }
+
+                        foreach (string HCopyMan in HCopyManList)
+                        {
+                            if (userClientIDDictionary.ContainsKey(HCopyMan))
+                            {
+                                clientIDList.AddRange(userClientIDDictionary[HCopyMan]);
+                            }
+                        }
+
+                        foreach (string clientID in clientIDList)
+                        {
+                            pushSuccess = PushMessageToSingle(template, clientID);
+
+                        }
+                    }
+
+                    if(!pushSuccess)
+                    {
+                        // 涓帹 鎺ㄩ�佷笉鎴愬姛(鍐呯綉鐜) 浣跨敤webSocket杩涜鎺ㄩ��
+                        // TODO: 浣跨敤 rabbitMQ 瀹炵幇娑堟伅闃熷垪
+                        // WebSocketServer.PushOne(HInterID);
                     }
                 }
             }
@@ -76,7 +173,7 @@
         }
 
         // 鍗曟帹 浣跨敤閫氱煡娑堟伅妯″瀷
-        private static void PushMessageToSingle(NotificationTemplate template, string ClientID)
+        private static bool PushMessageToSingle(NotificationTemplate template, string ClientID)
         {
 
             IGtPush push = new IGtPush(HOST, APPKEY, MASTERSECRET);
@@ -100,6 +197,7 @@
                 LogService.Write("-----------------------------------------------");
                 LogService.Write("-----------------------------------------------");
                 LogService.Write("----------------鏈嶅姟绔繑鍥炵粨鏋滐細" + pushResult);
+                return true;
             }
             catch (RequestException e)
             {
@@ -109,6 +207,7 @@
                 LogService.Write("-----------------------------------------------");
                 LogService.Write("-----------------------------------------------");
                 LogService.Write("----------------鏈嶅姟绔繑鍥炵粨鏋滐細" + pushResult);
+                return false;  
             }
         }
 

--
Gitblit v1.9.1