From c3b8825e0d0cc99aeb5cc380ace9259adbc69304 Mon Sep 17 00:00:00 2001 From: qinchulong <qinchulong@hnkhzn.com> Date: 星期一, 03 三月 2025 22:02:49 +0800 Subject: [PATCH] 1 --- 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/GZJ/GZJJob.cs | 194 +++++++++++++++++++++++++++++++----------------- 1 files changed, 125 insertions(+), 69 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..549a68f 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" @@ -15,16 +15,19 @@ using System.Reflection; using System.Text; using System.Threading.Tasks; +using WIDESEAWCS_Common.LocationEnum; using WIDESEAWCS_Common.TaskEnum; using WIDESEAWCS_Communicator; using WIDESEAWCS_Core.BaseRepository; 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 +39,39 @@ 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; + private readonly IRepository<Dt_LocationInfo> _LocationInfoRepository; + private readonly IUnitOfWorkManage _unitOfWorkManage; 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, + IRepository<Dt_LocationInfo> LocationInfoRepository, + IUnitOfWorkManage unitOfWorkManage) { _taskService = taskService;//娉ㄥ叆 _webSocketServer = webSocketServer; _ErrormsginfoService = errormsginfoService; _dt_stationInfoRepository = dt_stationInfoRepository; _dt_taskRepositiry = dt_taskRepositiry; + _locationInfoService = locationInfoService; + _storagemodeRepository = storagemodeRepository; + _outStockRepository = outStockRepository; + _batchInfoRepository = batchInfoRepository; + _StockInfoRepository = StockInfoRepository; + _LocationInfoRepository = LocationInfoRepository; + _unitOfWorkManage = unitOfWorkManage; } public Task Execute(IJobExecutionContext context) @@ -65,12 +89,13 @@ 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 +103,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 +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; task.Grade = 1; task.Remark = (int)MateTypeEnum.WaiGou; } @@ -104,7 +129,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); @@ -122,10 +147,23 @@ { throw new Exception($"瑙勬暣鏈哄綋鍓嶄俊鍙蜂笉婊¤冻鍏ュ簱浠诲姟鐢熸垚鏉′欢"); } + //鏌ユ壘鐩搁偦鐨勫簱浣� + Dt_LocationInfo Towlocation = new Dt_LocationInfo(); + var Onelocation = _LocationInfoRepository.QueryFirst(v => v.LocationCode == task.TargetAddress); + if (Onelocation.Depth == 1) + { + Towlocation = _LocationInfoRepository.QueryFirst(v => v.Row == Onelocation.Row && v.Column == Onelocation.Column && v.Depth == 2); + } + else + { + Towlocation = _LocationInfoRepository.QueryFirst(v => v.Row == Onelocation.Row && v.Column == Onelocation.Column && v.Depth == 1); + } + task.NextAddress = Towlocation.LocationCode; task.Roadway = "TC01"; task.TaskType = (int)TaskInboundTypeEnum.Inbound; task.TaskState = (int)TaskInStatusEnum.InNew; - + task.PalletCode = "text"; + task.CurrentAddress = "text"; _dt_taskRepositiry.AddData(task); #endregion @@ -134,70 +172,88 @@ { _ErrormsginfoService.UpdateErrorMsg(ex.Message, 2); } + + try + { + #region 鐢熸垚鍑哄簱浠诲姟 + if (!OHTJob.oHTReadData.R_ZXJ_isWork) + { + throw new Exception($"鏁村舰鏈烘姇鍏ヤ娇鐢ㄤ俊鍙蜂负false"); + } + var isout = _outStockRepository.QueryFirst(v => v.Id == 1); + if (isout.isout != 1) + { + throw new Exception($"褰撳墠绯荤粺璁剧疆涓轰笉鍑哄簱妯″紡"); + } + 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 && v.StockStatus==0) + .OrderBy(v => v.CreateDate).ToList(); + if (stocks.Count <= 0) + { + throw new Exception($"褰撳墠搴撳瓨涓病鏈夈�恵batch.materType}銆戯紙0鑷骇 1澶栬喘锛変笖鎵规涓恒�恵batch.OutBatch}銆戠殑鐗╂枡"); + } + //鏌ヨ璐т綅 + var locaOne=_LocationInfoRepository.QueryFirst(v=>v.LocationCode== stocks[0].LocationCode); + //鏌ヨ鐩搁偦鐨勮揣浣� + Dt_LocationInfo locaTow = new Dt_LocationInfo(); + if (locaOne.Depth==1) + { + locaTow = _LocationInfoRepository.QueryFirst(v => v.Row == locaOne.Row &&v.Column== locaOne.Column && v.Depth==2); + } + else + { + locaTow = _LocationInfoRepository.QueryFirst(v => v.Row == locaOne.Row && v.Column == locaOne.Column && v.Depth == 1); + } + locaOne.LocationStatus = (int)LocationStatusEnum.Lock; + locaTow.LocationStatus = (int)LocationStatusEnum.Lock; + //鏌ヨ鐩搁偦鐨勫簱瀛� + var BBstock = _StockInfoRepository.QueryFirst(v=>v.LocationCode== locaTow.LocationCode); + BBstock.StockStatus = 1; + stocks[0].StockStatus = 1; + //鏌ヨ缁堢偣绔欏彴淇℃伅 + 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.NextAddress = locaTow.LocationCode; + outtask.Grade = 1; + outtask.WMSId = 3; + outtask.Remark = batch.materType; + outtask.PalletCode = "text"; + outtask.CurrentAddress = "text"; + + _unitOfWorkManage.BeginTran(); + _LocationInfoRepository.UpdateData(locaOne); + _LocationInfoRepository.UpdateData(locaTow); + _StockInfoRepository.UpdateData(BBstock); + _dt_taskRepositiry.AddData(outtask); + _StockInfoRepository.UpdateData(stocks[0]); + _unitOfWorkManage.CommitTran(); + #endregion + } + catch (Exception ex) + { + _unitOfWorkManage.RollbackTran(); + _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