1
czw
8 天以前 28accb402ff845f554493c0e0d6a3e5234d00628
HnSx/Build/Project/´úÂë/VS×Ô¶¨ÒåÀà/AutoThread.cs
@@ -128,6 +128,7 @@
            //将数据缓存到内存。
            try
            {
                return;
                Thread.Sleep(1000);
                while (true)
                {
@@ -184,22 +185,23 @@
                    new HttpServer(ip.ToString()).HttpServerRun();
                    //new TcpServer(ip.ToString());
                    //var server = new EnhancedWebSocketServer($"http://{ip.ToString()}:8809/").StartAsync(); http://10.20.66.121:18080
                    new WebSocketClientWithReconnect($"ws://10.20.66.121:20001/socket").StartAsync();
                    //new WebSocketClientWithReconnect($"ws://10.20.66.121:20001/socket").StartAsync();
                    new WebSocketClientWithReconnect($"ws://10.20.66.121:20001/datahubjson/websocket/").StartAsync();
                    //new WebSocketClientWithReconnect($"ws://{ip.ToString()}:8809/socket").StartAsync();
                    WebSocketClientWithReconnect.Instance.OnMessageReceived += (msg) =>
                    {
                        //reportWeightinfo.channel.Writer.TryWrite(JsonConvert.DeserializeObject<ReportWeightInfoResponse>(msg));
                        reportWeightinfo.channel.Writer.TryWrite(new ReportWeightInfoResponse
                        {
                            Response = new ReportWeightInfoResponseData
                            {
                                Return = new ReportWeightInfoReturnInfo
                                {
                                    returnCode = "0000",
                                    sortingChute = msg
                                }
                            }
                        });
                        reportWeightinfo.channel.Writer.TryWrite(msg);
                        //reportWeightinfo.channel.Writer.TryWrite(new ReportWeightInfoResponse
                        //{
                        //    Response = new ReportWeightInfoResponseData
                        //    {
                        //        Return = new ReportWeightInfoReturnInfo
                        //        {
                        //            returnCode = "0000",
                        //            sortingChute = msg
                        //        }
                        //    }
                        //});
                    };
                    break;
                }
@@ -547,7 +549,7 @@
                                                Return = new ReturnInfo
                                                {
                                                    returnCode = "0000",
                                                    returnDesc = "",
                                                    returnDesc = "ok",
                                                    returnFlag = "1"
                                                }
                                            }
@@ -629,7 +631,7 @@
                                                        {
                                                            returnCode = "0000",
                                                            returnFlag = "1",
                                                            returnDesc="ok"
                                                            returnDesc = "ok"
                                                        }
                                                    }
                                                });
@@ -703,7 +705,7 @@
                                                        Return = new PutConveyorTaskReturnInfo
                                                        {
                                                            returnCode = "0000",
                                                            returnDesc="ok",
                                                            returnDesc = "ok",
                                                            returnFlag = "1"
                                                        }
                                                    }
@@ -749,9 +751,10 @@
                                                    }
                                                }
                                            };
                                            string requeeee = string.IsNullOrEmpty(requestJson) ? JsonConvert.SerializeObject(req) : requestJson;
                                            //Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss.fff")}>>>GGG{i}");
                                            LogHelper.Info(JsonConvert.SerializeObject(req));
                                            var b = WebSocketClientWithReconnect.Instance?.SendAsync(JsonConvert.SerializeObject(req)).Result;
                                            LogHelper.Info(requeeee);
                                            var b = WebSocketClientWithReconnect.Instance?.SendAsync(requeeee).Result;
                                            Console.WriteLine(req.data.header.deliveryNo + "发送完成!!" + b);
                                            if (b == true)
                                            {
@@ -1610,7 +1613,7 @@
                /// <summary>
                /// è¿”回描述
                /// </summary>
                public string returnDesc { get; set; }
                public string returnDesc { get; set; } = "ok";
                /// <summary>
                /// è¿”回标记 - 1:成功, 0:失败
@@ -2206,9 +2209,9 @@
        }
        public class reportWeightinfo
        {
            public static Channel<ReportWeightInfoResponse> channel = Channel.CreateUnbounded<ReportWeightInfoResponse>();
            public static Channel<string> channel = Channel.CreateUnbounded<string>();
            internal static async Task<ReportWeightInfoReturnInfo> GetChinnnl()
            internal static async Task<string> GetChinnnl()
            {
                //var response = await reportWeightinfo.channel.Reader.ReadAllAsync();// foreach (var response in reportWeightinfo.channel.Reader.ReadAllAsync())
                //{
@@ -2218,10 +2221,10 @@
                {
                    while (reportWeightinfo.channel.Reader.TryRead(out var response))
                    {
                        return response?.Response?.Return ?? new ReportWeightInfoReturnInfo { returnCode = "0001", sortingChute = "0", returnDesc = "返回为空。" };
                        return response;/// response?.Response?.Return ?? new ReportWeightInfoReturnInfo { returnCode = "0001", sortingChute = "0", returnDesc = "返回为空。" };
                    }
                }
                return new ReportWeightInfoReturnInfo { returnCode = "0001", sortingChute = "0", returnDesc = "返回为空。" };
                return "返回为空"; new ReportWeightInfoReturnInfo { returnCode = "0001", sortingChute = "0", returnDesc = "返回为空。" };
            }
            /// <summary>