1
czw
2025-07-07 10791386189bc9382fbcb9e8819cd80c6e708976
1
2个文件已修改
50 ■■■■■ 已修改文件
HnSx/Build/Project/代码/VS自定义类/AutoThread.cs 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HnSx/Build/Project/代码/界面事件.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HnSx/Build/Project/´úÂë/VS×Ô¶¨ÒåÀà/AutoThread.cs
@@ -120,7 +120,6 @@
        /// <param name="action"></param>
        public void ThreadSettingInit(Tag tag)
        {
            LogHelper.Info("<<<<<<<<<<<<<<<<<<<....Running....>>>>>>>>>>>>>>>");
        }
        public async void ThreadwebSoc()
@@ -141,6 +140,7 @@
                            var b = WebSocketClientWithReconnect.Instance?.SendAsync($"He >>GGG{i}").Result;
                            Console.WriteLine("发送完成!!" + b);
                        }
                    Thread.Sleep(1000);
                }
            }
            catch (Exception ex)
@@ -156,10 +156,10 @@
                if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                {
                    Console.WriteLine($"ip= {ip.ToString()}");
                    //new HttpServer(ip.ToString()).HttpServerRun();
                    new HttpServer(ip.ToString()).HttpServerRun();
                    //new TcpServer(ip.ToString());
                    //var server = new EnhancedWebSocketServer($"http://{ip.ToString()}:8809/").StartAsync();
                    new WebSocketClientWithReconnect($"ws://{ip.ToString()}:8809/socket").StartAsync();
                    //var server = new EnhancedWebSocketServer($"http://{ip.ToString()}:8809/").StartAsync(); http://10.20.66.121:18080
                    new WebSocketClientWithReconnect($"ws://10.20.66.121:18080/socket").StartAsync();
                    WebSocketClientWithReconnect.Instance.OnMessageReceived += (msg) =>
                    {
                        reportWeightinfo.channel.Writer.TryWrite(JsonConvert.DeserializeObject<ReportWeightInfoResponse>(msg));
@@ -180,7 +180,7 @@
        public static string _listenerPrefix = "";
        public HttpServer(string ip)
        {
            _listenerPrefix = $"http://{ip}:8807/";
            _listenerPrefix = $"http://{ip}:8808/";
        }
        public void HttpServerRun()
        {
@@ -256,12 +256,29 @@
                        {
                            switch (path)
                            {
                                case "/api/Wcs/GetTask":
                                    {
                                        statusCode = System.Net.HttpStatusCode.OK;
                                        return JsonConvert.SerializeObject(new
                                        {
                                            å‡ºå…¥ç§»åº“任务 = lstr,
                                            ç®±ä½“分发任务 = putConveyorTasks
                                        });
                                        break;
                                    }
                                case "/api/Wcs/RemoveTask":
                                    {
                                        statusCode = System.Net.HttpStatusCode.OK;
                                        lstr.RemoveAll(x => x.PalletId == requestJson);
                                        putConveyorTasks.RemoveAll(x => x.PalletId == requestJson);
                                        break;
                                    }
                                ///任务下发--WMS-->WC
                                case "/api/Wcs/sendTask":
                                    {
                                        statusCode = System.Net.HttpStatusCode.OK;
                                        var req = JsonConvert.DeserializeObject<SendTaskRequest>(requestJson);
                                        if (lstr.Find(x => x.PalletId == req.Data.Header.PalletId) != null)
                                        if (req.Data == null || lstr.Find(x => x.GroupTaskSequence == req.Data.Header.GroupTaskSequence && x.GroupTaskId == req.Data.Header.GroupTaskId) != null)
                                            return JsonConvert.SerializeObject(new SendTaskResponse
                                            {
                                                Response = new ResponseData
@@ -269,11 +286,12 @@
                                                    Return = new ReturnInfo
                                                    {
                                                        ReturnCode = "0001",
                                                        ReturnDesc = "托盘重复下发!!!",
                                                        ReturnDesc = req.Data == null ? "无任务下发!" : "任务重复下发!",
                                                        ReturnFlag = "0"
                                                    }
                                                }
                                            });
                                        lstr.Add(req.Data.Header);
                                        return JsonConvert.SerializeObject(new SendTaskResponse
                                        {
                                            Response = new ResponseData
@@ -291,8 +309,8 @@
                                case "/api/Wcs/stockInException":
                                    {
                                        statusCode = System.Net.HttpStatusCode.OK;
                                        var f = lstr.FirstOrDefault();
                                        var str = apiHelper.Post("http://10.20.66.121:18080/datahubjson/wcs/?method=stockinException", JsonConvert.SerializeObject(new StockInExceptionRequest
                                        var f = string.IsNullOrEmpty(requestJson) ? lstr.FirstOrDefault() : lstr.Find(x => x.PalletId == requestJson);
                                        var str = apiHelper.Post("http://10.20.66.121:18080/datahubjson/wcs/?method=STOCKINEXCEPTION", JsonConvert.SerializeObject(new StockInExceptionRequest
                                        {
                                            Data = new StockInExceptionData
                                            {
@@ -316,11 +334,10 @@
                                case "/api/Wcs/taskFeedback":
                                    {
                                        statusCode = System.Net.HttpStatusCode.OK;
                                        foreach (var statu in new List<string> { "", "" })
                                        //foreach (var statu in new List<string> { "", "" })
                                        {
                                            var f = lstr.FirstOrDefault();
                                            var str = apiHelper.Post("http://10.20.66.121:18080/datahubjson/wcs/?method=taskFeedback", JsonConvert.SerializeObject(new TaskFeedbackRequest
                                            var f = string.IsNullOrEmpty(requestJson) ? lstr.FirstOrDefault() : lstr.Find(x => x.PalletId == requestJson);
                                            var str = apiHelper.Post("http://10.20.66.121:18080/datahubjson/wcs/?method=TASKFEEDBACK", JsonConvert.SerializeObject(new TaskFeedbackRequest
                                            {
                                                Data = new TaskFeedbackData
                                                {
@@ -349,7 +366,7 @@
                                case "/api/Wcs/stockInInteraction":
                                    {
                                        statusCode = System.Net.HttpStatusCode.OK;
                                        var str = apiHelper.Post("http://10.20.66.121:18080/datahubjson/wcs/?method=stockInInteraction", JsonConvert.SerializeObject(new StockInInteractionRequest
                                        var str = apiHelper.Post("http://10.20.66.121:18080/datahubjson/wcs/?method=STOCKININTERACTION", JsonConvert.SerializeObject(new StockInInteractionRequest
                                        {
                                            Data = new StockInInteractionData
                                            {
@@ -405,7 +422,7 @@
                                case "/api/Wcs/palletStackerInteraction":
                                    {
                                        statusCode = System.Net.HttpStatusCode.OK;
                                        var str = apiHelper.Post("http://10.20.66.121:18080/datahubjson/wcs/?method=palletStackerInteraction", JsonConvert.SerializeObject(new PalletStackerInteractionRequest
                                        var str = apiHelper.Post("http://10.20.66.121:18080/datahubjson/wcs/?method=PALLETSTACKERINTERACTION", JsonConvert.SerializeObject(new PalletStackerInteractionRequest
                                        {
                                            Data = new PalletStackerInteractionData
                                            {
@@ -792,7 +809,7 @@
        public event Action<string> OnMessageReceived = msg => Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss.fff")}>>>Received: {msg}");
        public event Action OnConnected = () => Console.WriteLine("Connected to server");
        public event Action OnDisconnected = () => Console.WriteLine("Disconnected from server");
        public event Action OnDisconnected = () => Console.WriteLine("Disconnected from webSocket server");
        public event Action<Exception> OnError = ex => Console.WriteLine($"Error: {ex.Message}");
        public WebSocketClientWithReconnect(string serverUrl, int reconnectDelayMs = 5000)
HnSx/Build/Project/´úÂë/½çÃæÊ¼þ.cs
@@ -48,6 +48,7 @@
                //HttpSvcHost.Prefixes.Add("http://127.0.0.1:8808/");
                //HttpSvcHost.Start();
                //HttpSvcHost.BeginGetContext(HttpSvcListenerCallback, null);
                LogHelper.Info("<<<<<<<<<<<<<<<<<<<....Running....>>>>>>>>>>>>>>>");
            }
            catch (Exception ex)
            {