From b544d5cccd76735e034c8055918a50927b437474 Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期二, 10 十一月 2026 08:29:04 +0800
Subject: [PATCH] fix: 维护模式重复进入失败与按钮灰死 + Broker 并发验证用例

---
 Plugin.TestResult/Util/PNUtil.cs |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/Plugin.TestResult/Util/PNUtil.cs b/Plugin.TestResult/Util/PNUtil.cs
index 0b80a8b..d7bf7ec 100644
--- a/Plugin.TestResult/Util/PNUtil.cs
+++ b/Plugin.TestResult/Util/PNUtil.cs
@@ -1,4 +1,7 @@
 锘縰sing HMI.Core.Util;
+using log4net;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 using Plugin.TestResult_WPF;
 using System;
 using System.Net.Http;
@@ -15,13 +18,14 @@
 
     public class PNUtil
     {
-        public static bool GetPN(string mesAddress, string sn, out string pn, out string msg)
+        public static bool GetPN(string mesAddress, string stationName, string sn, out string pn, out string msg)
         {
             pn = null;
             msg = string.Empty;
             try
             {
-                string json = $"{{\"csn\":\"{sn}\",\"station_name\":\"OP170Burn-In鑰佸寲\"}}";
+                //OP170Burn-In鑰佸寲
+                string json = $"{{\"csn\":\"{sn}\",\"station_name\":\"{stationName}\"}}";
                 HttpClient val = new HttpClient();
                 ViewControl.Logger.Debug($"Get PN Send: [{json}]");
                 try
@@ -52,5 +56,53 @@
                 return false;
             }
         }
+
+
+        public static bool CheckIn(ILog log, string mesAddress, string stationName, string sn, out bool needCheckIn, out string msg)
+        {
+            JObject data = new JObject();
+            data.Add("cmd", "QUERY_RECORD");
+            data.Add("p", "UOP");
+
+            data.Add("sn", sn);
+            data.Add("station_name", stationName);
+            data.Add("op", "A0000001");
+
+            needCheckIn = false;
+            msg = string.Empty;
+            string sendData = string.Empty;
+            string resData = null;
+            try
+            {
+                sendData = data.ToString(Formatting.None);
+                using (HttpClient val = new HttpClient())
+                {
+                    StringContent val2 = new StringContent(sendData, Encoding.UTF8, "application/json");
+                    HttpResponseMessage result = val.PostAsync("http://" + mesAddress + "/mes-module-system-2.1.1/lixun/api/checkIn", (HttpContent)(object)val2).Result;
+                    result.EnsureSuccessStatusCode();
+                    resData = result.Content.ReadAsStringAsync().Result;
+                    JObject httpResult = JObject.Parse(resData);
+
+                    log.Info("CheckIn Send: " + httpResult.Value<string>("sendStr"));
+                    log.Info("CheckIn Receive: " + httpResult.Value<string>("receiveStr"));
+                    log.Info("CheckIn Get: " + resData);
+
+                    msg = httpResult.Value<string>("msg");
+                    if (httpResult.Value<int>("code") == 200)
+                    {
+                        needCheckIn = httpResult.Value<bool>("needCheckIn");
+                        return true;
+                    }
+                    log.Error("CheckIn Error: " + msg);
+                    return false;
+                }
+            }
+            catch (Exception ex)
+            {
+                msg = ex.Message + " in " + ex.StackTrace + ".SendStr: " + sendData + ",ResultStr: " + resData;
+                log.Error("CheckIn Unknow Error: " + msg);
+                return false;
+            }
+        }
     }
 }

--
Gitblit v1.9.1