| | |
| | | using Newtonsoft.Json; |
| | | using 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 |
| | |
| | | /// </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 |
| | | } |
| | | |
| | | if (task.method.ToLower() == "end") //AGVä»»å¡ç»æ |
| | | Dt_CZInfo_mes CZInfotlist = _task_CZInfoRepository.QueryFirst(x => x.CurrentStatue == "4"); |
| | | if (CZInfotlist != null) |
| | | { |
| | | CZInfotlist.CurrentStatue = "5"; |
| | | _task_CZInfoRepository.UpdateData(CZInfotlist); |
| | | } |
| | | |
| | | //todo |
| | | //_taskRepository.QueryFirst(x=>x.SourceAddress == task.) |
| | | WCS_Set("3022"); //ä¸ç®¡æ¯å¦æåå
¥æåï¼é½å®æagvä»»å¡ |
| | | return response = new AGVResponBase |
| | | { |
| | | code = "0", |
| | | message = "æå", |
| | | reqCode = task.reqCode |
| | | }; |
| | | |
| | | } |
| | | |
| | | if (task.method.ToString() == "end") //AGVä»»å¡ç»æåé¦ |
| | | { |
| | | //å¹¶è¿è¡ä¿®æ¹ä»»å¡ä¸ºå®æ |
| | | Dt_CZInfo_mes CZInfotlist = _task_CZInfoRepository.QueryFirst(x => x.CurrentStatue == "5"); |
| | | |
| | | //è°åè¾é线æ¥å£ï¼åé¦è¾éçº¿å®æä¿¡å· |
| | | 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 content.OK(); |
| | | |
| | | //åè° |
| | | return response = new AGVResponBase |
| | | { |
| | | code = "0", |
| | | message = "æå", |
| | | reqCode = task.reqCode |
| | | }; |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |