From 547436626cfe9cb01ae95b0bde9886b9cf46a9f2 Mon Sep 17 00:00:00 2001 From: qinchulong <qinchulong@hnkhzn.com> Date: 星期日, 02 三月 2025 23:51:05 +0800 Subject: [PATCH] 第一版完成 --- 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/GZJ/GZJJob.cs | 140 ++++++++++++++++++++++++---------------------- 1 files changed, 72 insertions(+), 68 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/GZJ/GZJJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/GZJ/GZJJob.cs" index 03eda49..1ebe252 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/GZJ/GZJJob.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/GZJ/GZJJob.cs" @@ -21,10 +21,12 @@ 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 @@ -36,18 +38,33 @@ 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) @@ -65,12 +82,12 @@ 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; } @@ -78,7 +95,7 @@ { 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); @@ -96,7 +113,7 @@ { 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; } @@ -104,7 +121,7 @@ { 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); @@ -134,70 +151,57 @@ { _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> - /// 浠诲姟瀹炰綋杞崲鎴愬懡浠odel - /// </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; - } - - } - - } -- Gitblit v1.9.3