From f3ec4fe9c98a87b42b00b6ac4790fe156a32aa6b Mon Sep 17 00:00:00 2001 From: huanghongfeng <huanghongfeng@hnkhzn.com> Date: 星期四, 19 六月 2025 16:53:20 +0800 Subject: [PATCH] 最新 --- 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/AGV/Partial/agvCallback.cs | 124 ++++++++++++++++++++++++++++++++++++---- 1 files changed, 110 insertions(+), 14 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/AGV/Partial/agvCallback.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/AGV/Partial/agvCallback.cs" index 6f6cb00..e4d985d 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/AGV/Partial/agvCallback.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/AGV/Partial/agvCallback.cs" @@ -1,12 +1,20 @@ -锘縰sing Newtonsoft.Json; +锘縰sing AngleSharp.Io; +using Mapster; +using Newtonsoft.Json; using System; +using System.Collections; using System.Collections.Generic; using System.Linq; +using System.Reflection.Metadata; using System.Text; using System.Threading.Tasks; +using WIDESEA_Comm; using WIDESEA_Comm.AGVTask; using WIDESEA_Core; +using WIDESEA_Core.Const; +using WIDESEA_Core.Helper; using WIDESEA_Model.Models; +using WIDESEA_StorageBasicRepository; using WIDESEA_StorageTaskRepository; namespace WIDESEA_StoragIntegrationServices @@ -18,38 +26,126 @@ /// </summary> /// <param name="taskRespon"></param> /// <returns></returns> - public WebResponseContent agvCallback(object taskRespon) + public AGVResponBase agvCallback(object taskRespon) { - WebResponseContent content = new WebResponseContent(); - agvTask task = new agvTask(); + + AGVResponBase response = null; + + ContainerTask task = new ContainerTask(); try { - task = JsonConvert.DeserializeObject<agvTask>(taskRespon.ToString()); + task = JsonConvert.DeserializeObject<ContainerTask>(taskRespon.ToString()); + if (task == null) { - throw new Exception("AGV璋冪敤鎺ュ彛澶辫触锛氭棤璇锋眰鍙傛暟"); + LogFactory.GetLog("AGV浠诲姟鍥炶皟").Info(true, $"鍥炶皟澶辫触锛屾湭鑳借鍙栧埌agv璋冨彇鍙傛暟"); } - if (task.method.ToLower() == "apply") //AGV鏀炬枡鐢宠 + if (task.method.ToString() == "outbin2") //AGV鍙栨枡瀹屾垚 { - //todo + Dt_CZInfo_mes CZInfotlist = _task_CZInfoRepository.QueryFirst(x => x.CurrentStatue == "4"); + if (CZInfotlist != null) + { + CZInfotlist.CurrentStatue = "5"; + _task_CZInfoRepository.UpdateData(CZInfotlist); + } + + WCS_Set("3022"); //涓嶇鏄惁鏈夊啓鍏ユ垚鍔燂紝閮藉畬鎴恆gv浠诲姟 + return response = new AGVResponBase + { + code = "0", + message = "鎴愬姛", + reqCode = task.reqCode + }; + } - if (task.method.ToLower() == "end") //AGV浠诲姟缁撴潫 + if (task.method.ToString() == "end") //AGV浠诲姟缁撴潫鍙嶉 { + //骞惰繘琛屼慨鏀逛换鍔′负瀹屾垚 + Dt_CZInfo_mes CZInfotlist = _task_CZInfoRepository.QueryFirst(x => x.CurrentStatue == "5"); - //todo - //_taskRepository.QueryFirst(x=>x.SourceAddress == task.) + //璋冨彇杈撻�佺嚎鎺ュ彛锛屽弽棣堣緭閫佺嚎瀹屾垚淇″彿 + WCS_Set(CZInfotlist.AGVaddres); + + + if(CZInfotlist != null) + { + CZInfotlist.CurrentStatue = "6"; + _task_CZInfoRepository.UpdateData(CZInfotlist); + + Dt_CZInfo_mes_hty stockInfo_Hty = CZInfotlist.Adapt<Dt_CZInfo_mes_hty>(); + _CZInfo_Mes_HtyRepository.AddData(stockInfo_Hty); + _task_CZInfoRepository.DeleteData(CZInfotlist); + } + + + + //鍥炶皟 + return response = new AGVResponBase + { + code = "0", + message = "鎴愬姛", + reqCode = task.reqCode + }; } - - return content.OK(); + LogFactory.GetLog("AGV浠诲姟鍥炶皟").Info(true, $"鍥炶皟鎴愬姛"); + return response; } catch (Exception ex) { - return content.Error($"AGV鍥炶皟寮傚父:{ex.Message}"); + LogFactory.GetLog("AGV浠诲姟鍥炶皟").Info(true, $"鍥炶皟澶辫触锛岄敊璇俊鎭細{ex.Message}"); + return response = new AGVResponBase + { + code = "1", + message = $"澶辫触,鍘熷洜锛歿ex.Message}", + reqCode = task.reqCode + }; } } + + public bool WCS_Set(string CutAddress) + { + try + { + //璋冨彇wcs鎺ュ彛锛屽啓鍏ヨ緭閫佺嚎淇″彿 SetPlcResponState + var configs = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress); + var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.WCSIPAddress)?.ConfigValue; + var ReceiveByWMSTask = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.SetPlcResponState)?.ConfigValue; + if (ReceiveByWMSTask == null || ipAddress == null) + { + throw new Exception("WMS IP 鏈厤缃�"); + } + var wmsIpAddrss = ipAddress + ReceiveByWMSTask; + + var respon = HttpHelper.Post(wmsIpAddrss, JsonConvert.SerializeObject(CutAddress)); //http://localhost:9291/api/Task/ReceiveTask, + + if (respon != null) + { + WebResponseContent respone = JsonConvert.DeserializeObject<WebResponseContent>(respon.ToString()); + if (respone.Status) + { + return true; + } + else + { + return false; + } + } + else + { + return false; + } + + } + catch (Exception ex) + { + return false; + throw; + } + } + } } -- Gitblit v1.9.3