| | |
| | | private readonly IDt_HostLogRepository _hostLogRepository; |
| | | private bool _IsOnline = false; |
| | | public DateTime Time { get; set; } = DateTime.Now; |
| | | private static int _currentNumber = 0; |
| | | private static readonly object _lock = new object(); |
| | | |
| | | |
| | | public SocketClientService(IDt_TaskService TaskService, IDt_TaskRepository TaskRepository, IDt_StationManagerRepository stationManagerRepository, ILogger<SocketClientService> logger, IDt_HostLogRepository hostLogRepository) |
| | |
| | | #endregion |
| | | |
| | | #region WMSä¸åHOSTæ¹æ³ |
| | | public static string Sequence() |
| | | { |
| | | // 使ç¨éç¡®ä¿çº¿ç¨å®å
¨ |
| | | lock (_lock) |
| | | { |
| | | _currentNumber++; |
| | | |
| | | // 妿è¶
è¿99999ï¼å¯ä»¥éç½®ææåºå¼å¸¸ï¼è¿ééæ©éç½® |
| | | if (_currentNumber > 99999) |
| | | { |
| | | _currentNumber = 1; |
| | | } |
| | | |
| | | return _currentNumber.ToString("D5"); |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 设å¤è¯·æ±å
¥åº å·¥åº101 |
| | |
| | | { |
| | | try |
| | | { |
| | | string str = SendandReply + "101" + BaseDal.GetSeqNo().Result.ToString("D5") + GetFieldsAsString(Agvstatus) + GetListStringOutStation(outStations) + OutStationSpare2 + "1" + GetFieldsAsString(inStation); |
| | | string str = SendandReply + "101" + Sequence() + GetFieldsAsString(Agvstatus) + GetListStringOutStation(outStations) + OutStationSpare2 + "1" + GetFieldsAsString(inStation); |
| | | clientSend(MakeStringToByteMsg(str)); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogFactory.GetLog("DeviceRequestInbound").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | string str = SendandReply + "925" + BaseDal.GetSeqNo().Result.ToString("D5"); |
| | | string str = SendandReply + "925" + Sequence(); |
| | | clientSend(MakeStringToByteMsg(str)); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogFactory.GetLog("RequestCommunication").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | string str = SendNotReply + "915" + BaseDal.GetSeqNo().Result.ToString("D5") + Command; |
| | | string str = SendNotReply + "915" + Sequence() + Command; |
| | | clientSend(MakeStringToByteMsg(str)); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogFactory.GetLog("JobReady").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | string str = SendNotReply + "913" + BaseDal.GetSeqNo().Result.ToString("D5") + Status; |
| | | string str = SendNotReply + "913" + Sequence() + Status; |
| | | clientSend(MakeStringToByteMsg(str)); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogFactory.GetLog("DeviceStateReport").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | try |
| | | { |
| | | string str = SendandReply + "917" + BaseDal.GetSeqNo().Result.ToString("D5") + Status; |
| | | string str = SendandReply + "917" + Sequence() + Status; |
| | | clientSend(MakeStringToByteMsg(str)); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogFactory.GetLog("DeviceAutoStatusReport").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | string str = SendandReply + "905" + BaseDal.GetSeqNo().Result.ToString("D5") + Status + JobOrderID + priority + FormLocation + ToLocation + TaskType + TrayCnt + PallteCode; |
| | | string str = SendandReply + "905" + Sequence() + Status + JobOrderID + priority + FormLocation + ToLocation + TaskType + TrayCnt + PallteCode; |
| | | clientSend(MakeStringToByteMsg(str)); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogFactory.GetLog("JobStartOrEnd").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | try |
| | | { |
| | | string str = SendNotReply + "907" + BaseDal.GetSeqNo().Result.ToString("D5") + Status + JobOrderID + priority + FormLocation + ToLocation + TaskType + TrayCnt + PallteCode; |
| | | string str = SendNotReply + "907" + Sequence() + Status + JobOrderID + priority + FormLocation + ToLocation + TaskType + TrayCnt + PallteCode; |
| | | clientSend(MakeStringToByteMsg(str)); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogFactory.GetLog("PalletActionReportå·¥åº907").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | try |
| | | { |
| | | string str = SendandReply + "901" + BaseDal.GetSeqNo().Result.ToString("D5") + "0" + JobOrderID + priority + FormLocation + ToLocation + TaskType + TrayCnt + PallteCode; |
| | | string str = SendandReply + "901" + Sequence() + "0" + JobOrderID + priority + FormLocation + ToLocation + TaskType + TrayCnt + PallteCode; |
| | | Dt_HostLog hostLog = new Dt_HostLog() |
| | | { |
| | | CommandID = 901, |
| | |
| | | { |
| | | LogFactory.GetLog("PalletActionReportå·¥åº901").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | |
| | | } |
| | | |
| | | public void PalletActionReportPDA(string FormLocation, string ToLocation, string TaskType, string PallteCode) |
| | | { |
| | | try |
| | | { |
| | | string str = SendandReply + "901" + BaseDal.GetSeqNo().Result.ToString("D5") + "0" + JobOrderIDPDA + priority + FormLocation + ToLocation + TaskType + TrayCnt + PallteCode; |
| | | string str = SendandReply + "901" + Sequence() + "0" + JobOrderIDPDA + priority + FormLocation + ToLocation + TaskType + TrayCnt + PallteCode; |
| | | clientSend(MakeStringToByteMsg(str)); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogFactory.GetLog("PalletActionReportPDAå·¥åº901").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | |
| | | } |
| | | |
| | | public void PalletActionReportFrie(string FormLocation, string ToLocation, string TaskType, string PallteCode) |
| | | { |
| | | try |
| | | { |
| | | string str = SendandReply + "901" + BaseDal.GetSeqNo().Result.ToString("D5") + "0" + JobOrderIDF + priority + FormLocation + ToLocation + TaskType + TrayCnt + PallteCode; |
| | | string str = SendandReply + "901" + Sequence() + "0" + JobOrderIDF + priority + FormLocation + ToLocation + TaskType + TrayCnt + PallteCode; |
| | | clientSend(MakeStringToByteMsg(str)); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogFactory.GetLog("PalletActionReportPDAå·¥åº901").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | LogFactory.GetLog("DeviceStationStatusReport").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// /// <summary> |
| | |
| | | try |
| | | { |
| | | ErrorReport(Restocking, "A", "00"); |
| | | string str = SendandReply + "105" + BaseDal.GetSeqNo().Result.ToString("D5") + "R" + JobOrderID + priority + FormLocation + ToLocation + TaskType + TrayCnt + PallteCode; |
| | | string str = SendandReply + "105" + Sequence() + "R" + JobOrderID + priority + FormLocation + ToLocation + TaskType + TrayCnt + PallteCode; |
| | | Dt_HostLog hostLog = new Dt_HostLog() |
| | | { |
| | | CommandID = 105, |
| | |
| | | { |
| | | LogFactory.GetLog("RecreateGetLocation").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | try |
| | | { |
| | | string str = SendNotReply + "981" + BaseDal.GetSeqNo().Result.ToString("D5") + message; |
| | | string str = SendNotReply + "981" + Sequence() + message; |
| | | clientSend(MakeStringToByteMsg(str)); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogFactory.GetLog("CheckSum").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | string str = SendNotReply + "985" + BaseDal.GetSeqNo().Result.ToString("D5") + Trouble + Level + Location; |
| | | string str = SendNotReply + "985" + Sequence() + Trouble + Level + Location; |
| | | |
| | | clientSend(MakeStringToByteMsg(str)); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogFactory.GetLog("ErrorReport").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | string str = SendNotReply + "104" + BaseDal.GetSeqNo().Result.ToString("D5") + Statues; |
| | | string str = SendNotReply + "104" + Sequence() + Statues; |
| | | clientSend(MakeStringToByteMsg(str)); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogFactory.GetLog("DeviceReceiveJobResponse").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// /// <summary> |
| | |
| | | try |
| | | { |
| | | ErrorReport(EmptyOutBoundconst, "A", "00"); |
| | | string str = SendandReply + "107" + BaseDal.GetSeqNo().Result.ToString("D5") + "1" + JobOrderID + priority + FormLocation + ToLocation + "O" + TrayCnt + PallteCode; |
| | | string str = SendandReply + "107" + Sequence() + "1" + JobOrderID + priority + FormLocation + ToLocation + "O" + TrayCnt + PallteCode; |
| | | Dt_HostLog hostLog = new Dt_HostLog() |
| | | { |
| | | CommandID = 107, |
| | |
| | | { |
| | | LogFactory.GetLog("EmptyOutBound").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | try |
| | | { |
| | | string str = SendNotReply + "910" + BaseDal.GetSeqNo().Result.ToString("D5") + GetFieldsAsString(AgvStatus) + X + Y; |
| | | string str = SendNotReply + "910" + Sequence() + GetFieldsAsString(AgvStatus) + X + Y; |
| | | clientSend(MakeStringToByteMsg(str)); |
| | | var hostlog = SqlSugarHelper.DbWMS.Queryable<Dt_HostLog>().Where(x => x.CommandID == 910).First(); |
| | | if (hostlog != null) |
| | | { |
| | | hostlog.ModifyDate=DateTime.Now; |
| | | SqlSugarHelper.DbWMS.Updateable(hostlog).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | Dt_HostLog hostLog = new Dt_HostLog() |
| | | { |
| | | CommandID = 910, |
| | |
| | | }; |
| | | _hostLogRepository.AddData(hostLog); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogFactory.GetLog("DeviceStatusReportResponse").InfoFormat(true, $"请æ±åæ°ï¼{JsonConvert.SerializeObject(ex.Message)}{Environment.NewLine}{ex.StackTrace}", ""); |
| | | } |
| | | finally |
| | | { |
| | | BaseDal.Db.Close(); |
| | | } |
| | | } |
| | | |