| | |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_ISystemServices; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_IWMSPart; |
| | | using WIDESEAWCS_Model.Models; |
| | | using WIDESEAWCS_QuartzJob; |
| | | using WIDESEAWCS_QuartzJob.DeviceBase; |
| | | using WIDESEAWCS_QuartzJob.StackerCrane.Enum; |
| | | using WIDESEAWCS_TaskInfoService; |
| | | using WIDESEAWCS_Tasks.OHT; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | |
| | | private readonly Idt_ErrormsginfoService _ErrormsginfoService; |
| | | private readonly IRepository<dt_stationInfo> _dt_stationInfoRepository; |
| | | private readonly IRepository<Dt_Task> _dt_taskRepositiry; |
| | | private readonly ILocationInfoService _locationInfoService; |
| | | private readonly IRepository<dt_storagemode> _storagemodeRepository; |
| | | private readonly IRepository<dt_outstockinfo> _outStockRepository; |
| | | private readonly IRepository<dt_batchInfo> _batchInfoRepository; |
| | | private readonly IRepository<Dt_StockInfo> _StockInfoRepository; |
| | | |
| | | WebSocketServer _webSocketServer; |
| | | public GZJJob(ITaskService taskService, WebSocketServer webSocketServer, Idt_ErrormsginfoService errormsginfoService, |
| | | Idt_StationinfoService stationinfoService, |
| | | IRepository<dt_stationInfo> dt_stationInfoRepository, |
| | | IRepository<Dt_Task> dt_taskRepositiry) |
| | | IRepository<Dt_Task> dt_taskRepositiry, |
| | | ILocationInfoService locationInfoService, |
| | | IRepository<dt_outstockinfo> outStockRepository, |
| | | IRepository<dt_storagemode> storagemodeRepository, |
| | | IRepository<dt_batchInfo> batchInfoRepository, |
| | | IRepository<Dt_StockInfo> StockInfoRepository) |
| | | { |
| | | _taskService = taskService;//注å
¥ |
| | | _webSocketServer = webSocketServer; |
| | | _ErrormsginfoService = errormsginfoService; |
| | | _dt_stationInfoRepository = dt_stationInfoRepository; |
| | | _dt_taskRepositiry = dt_taskRepositiry; |
| | | _locationInfoService = locationInfoService; |
| | | _storagemodeRepository = storagemodeRepository; |
| | | _outStockRepository = outStockRepository; |
| | | _batchInfoRepository = batchInfoRepository; |
| | | _StockInfoRepository = StockInfoRepository; |
| | | } |
| | | |
| | | public Task Execute(IJobExecutionContext context) |
| | |
| | | throw new Exception($"è§æ´æºæå
¥ä½¿ç¨ä¿¡å·ä¸ºfalse"); |
| | | } |
| | | Dt_Task task = new Dt_Task(); |
| | | |
| | | var storagemode = _storagemodeRepository.QueryFirst(v=>v.Id==1); |
| | | if (OHTJob.oHTReadData.R_RGVMode && OHTJob.oHTReadData.R_DK_isready)//RGVä¸ææ¨¡å¼ï¼ä¸ä¸è·¨æ¶åæä¸æä¿¡å· |
| | | { |
| | | var station=_dt_stationInfoRepository.QueryFirst(v=>v.msg== "ä¸è·¨æ¶å"); |
| | | task.SourceAddress = station.Row + "-" + station.Column + "-1"; |
| | | task.TargetAddress = ""; |
| | | task.TargetAddress = _locationInfoService.GetInLocation(storagemode.storagemode).LocationCode; |
| | | task.Grade = 1; |
| | | task.Remark = (int)MateTypeEnum.ZiChan; |
| | | } |
| | |
| | | { |
| | | var station = _dt_stationInfoRepository.QueryFirst(v => v.msg == "西跨æ¶å"); |
| | | task.SourceAddress = station.Row + "-" + station.Column + "-1"; |
| | | task.TargetAddress = ""; |
| | | task.TargetAddress = _locationInfoService.GetInLocation(storagemode.storagemode).LocationCode; |
| | | var DKstation = _dt_stationInfoRepository.QueryFirst(v => v.msg == "ä¸è·¨æ¶å"); |
| | | string address= DKstation.Row + "-" + DKstation.Column + "-1"; |
| | | var oldtask = _dt_taskRepositiry.QueryFirst(v=>v.SourceAddress== address); |
| | |
| | | { |
| | | var station = _dt_stationInfoRepository.QueryFirst(v => v.msg == "西跨æ¶å"); |
| | | task.SourceAddress = station.Row + "-" + station.Column + "-1"; |
| | | task.TargetAddress = ""; |
| | | task.TargetAddress = _locationInfoService.GetInLocation(storagemode.storagemode).LocationCode; |
| | | task.Grade = 1; |
| | | task.Remark = (int)MateTypeEnum.WaiGou; |
| | | } |
| | |
| | | { |
| | | var station = _dt_stationInfoRepository.QueryFirst(v => v.msg == "ä¸è·¨æ¶å"); |
| | | task.SourceAddress = station.Row + "-" + station.Column + "-1"; |
| | | task.TargetAddress = ""; |
| | | task.TargetAddress = _locationInfoService.GetInLocation(storagemode.storagemode).LocationCode; |
| | | var XKstation = _dt_stationInfoRepository.QueryFirst(v => v.msg == "西跨æ¶å"); |
| | | string address= XKstation.Row + "-" + XKstation.Column + "-1"; |
| | | var oldtask = _dt_taskRepositiry.QueryFirst(v => v.SourceAddress == address); |
| | |
| | | { |
| | | _ErrormsginfoService.UpdateErrorMsg(ex.Message, 2); |
| | | } |
| | | |
| | | try |
| | | { |
| | | #region çæåºåºä»»å¡ |
| | | var isout = _outStockRepository.QueryFirst(v => v.Id == 1); |
| | | if (isout.isout != 1) |
| | | { |
| | | throw new Exception($"å½åç³»ç»è®¾ç½®ä¸ºä¸åºåºæ¨¡å¼"); |
| | | } |
| | | if (!OHTJob.oHTReadData.R_ZXJ_isWork) |
| | | { |
| | | throw new Exception($"æ´å½¢æºæå
¥ä½¿ç¨ä¿¡å·ä¸ºfalse"); |
| | | } |
| | | if (!OHTJob.oHTReadData.R_ZXJ_TCMode || OHTJob.oHTReadData.R_HC_isReadyWork) |
| | | { |
| | | throw new Exception($"æ´å½¢æºä¸å±äºå¤©è½¦ä¸ææ¨¡å¼æå¤©è½¦æ¾æ¿ä¿¡å·ä¸ºfalse"); |
| | | } |
| | | //æ¥è¯¢å½å任塿± 䏿¯å¦åå¨åºåºä»»å¡ï¼åºåºä»»å¡åªè½åå¨ä¸æ¡ |
| | | var oldtask = _dt_taskRepositiry.QueryFirst(v => v.TaskType == (int)TaskOutboundTypeEnum.Outbound); |
| | | if (oldtask != null) |
| | | { |
| | | throw new Exception($"å½å任塿± ä¸å·²åå¨ä¸æ¡åºåºä»»å¡"); |
| | | } |
| | | //æ¥è¯¢å½åéè¦åºåºçæ¹æ¬¡å·ï¼ä»¥ååºåºç©æç±»å |
| | | var batch = _batchInfoRepository.QueryFirst(v => v.Id == 1); |
| | | //æ¥è¯¢åºåç©æåºåä¿¡æ¯ |
| | | var stocks = _StockInfoRepository.QueryData(v => v.Remark == batch.materType && v.BatchNo == batch.OutBatch).OrderBy(v => v.CreateDate).ToList(); |
| | | if (stocks.Count <= 0) |
| | | { |
| | | throw new Exception($"å½ååºå䏿²¡æã{batch.materType}ãï¼0èªäº§ 1å¤è´ï¼ä¸æ¹æ¬¡ä¸ºã{batch.OutBatch}ãçç©æ"); |
| | | } |
| | | //æ¥è¯¢ç»ç¹ç«å°ä¿¡æ¯ |
| | | var station = _dt_stationInfoRepository.QueryFirst(v => v.msg == "æ´å½¢æºæ¾æä½"); |
| | | //å¼å§åå»ºä»»å¡ |
| | | Dt_Task outtask = new Dt_Task(); |
| | | outtask.Roadway = "TC01"; |
| | | outtask.TaskType = (int)TaskOutboundTypeEnum.Outbound; |
| | | outtask.TaskState = (int)TaskOutStatusEnum.OutNew; |
| | | outtask.SourceAddress = stocks[0].LocationCode; |
| | | outtask.TargetAddress = station.Row + "-" + station.Column + "-1"; ; |
| | | outtask.Grade = 1; |
| | | outtask.Remark = batch.materType; |
| | | _dt_taskRepositiry.AddData(outtask); |
| | | #endregion |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _ErrormsginfoService.UpdateErrorMsg(ex.Message, 3); |
| | | } |
| | | } |
| | | |
| | | |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// ä»»å¡å®ä½è½¬æ¢æå½ä»¤Model |
| | | /// </summary> |
| | | /// <param name="task">ä»»å¡å®ä½</param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public OHTTaskCommand? ConvertToOHTTaskCommand([NotNull] Dt_Task task) |
| | | { |
| | | OHTTaskCommand oHtTaskCommand = new OHTTaskCommand(); |
| | | |
| | | oHtTaskCommand.W_Task_Type = 1; |
| | | oHtTaskCommand.W_Load_Layer = 0; |
| | | oHtTaskCommand.W_Pick_Line = 1; |
| | | |
| | | string[] SourceCodes = task.SourceAddress.Split("-"); |
| | | if (SourceCodes.Length == 3) |
| | | { |
| | | oHtTaskCommand.W_Pick_Line = Convert.ToInt16(SourceCodes[1]); |
| | | oHtTaskCommand.W_Put_Column = Convert.ToInt16(SourceCodes[2]); |
| | | oHtTaskCommand.W_Put_Layer = Convert.ToInt16(SourceCodes[3]); |
| | | } |
| | | else |
| | | { |
| | | //æ°æ®é
ç½®é误 |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"任塿ºå°åé
ç½®é误ï¼"); |
| | | return null; |
| | | } |
| | | string[] targetCodes = task.TargetAddress.Split("-"); |
| | | if (targetCodes.Length == 3) |
| | | { |
| | | oHtTaskCommand.W_Put_Line = Convert.ToInt16(targetCodes[1]); |
| | | oHtTaskCommand.W_Put_Column = Convert.ToInt16(targetCodes[2]); |
| | | oHtTaskCommand.W_Put_Layer = Convert.ToInt16(targetCodes[3]); |
| | | } |
| | | else |
| | | { |
| | | //æ°æ®é
ç½®é误 |
| | | _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"ä»»å¡ç®æ å°åé
ç½®é误"); |
| | | return null; |
| | | } |
| | | return oHtTaskCommand; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// è·åä»»å¡ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private Dt_Task? GetTask() |
| | | { |
| | | Dt_Task task; |
| | | task = _taskService.QueryStackerCraneTask("R01"); |
| | | return task; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |