From 25698020def2aba0db3bc6807ceef325ed4ea8b1 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期一, 06 五月 2024 12:47:06 +0800 Subject: [PATCH] 修改队列任务逻辑 --- 代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs | 275 +++++++++++++++++++++--------- 代码管理/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs | 17 + 代码管理/PCS/WCS_Server/WIDESEA_Comm/TaskEnum/AGVJobEnum.cs | 34 +++ 代码管理/PCS/WCS_Server/WIDESEA_Comm/StateEnum/TrayEnum.cs | 38 ++++ 代码管理/PCS/WCS_Server/WIDESEA_Comm/TaskEnum/AGVTaskStateEnum.cs | 74 ++++++++ 代码管理/PCS/WCS_Server/WIDESEA_Comm/TaskEnum/AGVTaskTypeEnum.cs | 54 ++++++ 代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/GetStation/EmptyPalletStation.cs | 25 +- 7 files changed, 411 insertions(+), 106 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Comm/StateEnum/TrayEnum.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Comm/StateEnum/TrayEnum.cs" new file mode 100644 index 0000000..bc79452 --- /dev/null +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Comm/StateEnum/TrayEnum.cs" @@ -0,0 +1,38 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WIDESEA_Comm +{ + /// <summary> + /// 鎵樼洏鐘舵�� + /// </summary> + public enum TrayStateEnum + { + /// <summary> + /// 绌烘墭鐩� + /// </summary> + EmptyTray, + /// <summary> + /// 婊℃墭鐩� + /// </summary> + StrogeTray + + } + /// <summary> + /// 鎵樼洏绫诲瀷 + /// </summary> + public enum TrayTypeEnum + { + /// <summary> + /// 灏忔墭鐩� + /// </summary> + SmallTray, + /// <summary> + /// 澶ф墭鐩� + /// </summary> + LargeTray, + } +} diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Comm/TaskEnum/AGVJobEnum.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Comm/TaskEnum/AGVJobEnum.cs" new file mode 100644 index 0000000..bd42efd --- /dev/null +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Comm/TaskEnum/AGVJobEnum.cs" @@ -0,0 +1,34 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; + +namespace WIDESEA_Common +{ + public enum AGVJobEnum + { + /// <summary> + /// 鏂颁换鍔� + /// </summary> + newTaskEnum = 1, + /// <summary> + /// 鍙栨秷浠诲姟 + /// </summary> + cancelTaskEnum = 2, + /// <summary> + /// 鍙樻洿浠诲姟 + /// </summary> + changeTaskEnum = 3, + /// <summary> + /// 涓嬪彂浠诲姟寮傚父 + /// </summary> + newTaskExp = 11, + /// <summary> + /// 鍙栨秷浠诲姟寮傚父 + /// </summary> + cancelTaskExp = 12, + /// <summary> + /// 鍙樻洿浠诲姟寮傚父 + /// </summary> + changeTaskExp = 13, + } +} diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Comm/TaskEnum/AGVTaskStateEnum.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Comm/TaskEnum/AGVTaskStateEnum.cs" new file mode 100644 index 0000000..c0b3374 --- /dev/null +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Comm/TaskEnum/AGVTaskStateEnum.cs" @@ -0,0 +1,74 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; + +namespace WIDESEA_Common +{ + public enum AGVTaskStateEnum + { + /// <summary> + /// 宸蹭笅鍙戝緟鍥炲 + /// </summary> + Wait, + /// <summary> + /// 璧风偣鎵ц涓� + /// </summary> + Executing = 1, + /// <summary> + /// 璧风偣宸插畬鎴� + /// </summary> + Complete = 2, + /// <summary> + /// 缁堢偣鎵ц涓� + /// </summary> + Executing1 = 3, + /// <summary> + /// 缁堢偣宸插畬鎴� + /// </summary> + Complete1 = 4, + /// <summary> + /// 宸蹭笅鍙� + /// </summary> + SendOut, + /// <summary> + /// 宸插垱寤烘湭鎵ц + /// </summary> + Create, + /// <summary> + /// 寮傚父 + /// </summary> + Abnormal, + /// <summary> + /// 缂栬緫涓� + /// </summary> + Editing, + /// <summary> + /// 鏇存敼浠诲姟绛夌骇寮傚父锛圧CS鏀跺埌鐨勭幇鏈変换鍔℃洿鏀规寚浠ゆ棤娉曟墽琛岋級 + /// </summary> + EditAbnormal, + /// <summary> + /// 鎵ц寮傚父锛圧CS宸叉敹鍒版柊涓嬪彂鐨勪换鍔′絾鏃犳硶鎵ц锛� + /// </summary> + ExecutAbnormal, + /// <summary> + /// 鍙栨秷 + /// </summary> + Cancel, + /// <summary> + /// 寰呭彇娑� + /// </summary> + WaitCancel, + /// <summary> + /// 鍙栨秷寮傚父锛圧CS鏀跺埌鐨勭幇鏈変换鍔″彇娑堟寚浠ゆ棤娉曟墽琛岋級 + /// </summary> + CancelAbnormal, + /// <summary> + /// 鍙栨秷寰呭洖澶� + /// </summary> + WaitReply, + /// <summary> + /// 闃熷垪涓� + /// </summary> + Queue, + } +} diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Comm/TaskEnum/AGVTaskTypeEnum.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Comm/TaskEnum/AGVTaskTypeEnum.cs" new file mode 100644 index 0000000..79366ed --- /dev/null +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_Comm/TaskEnum/AGVTaskTypeEnum.cs" @@ -0,0 +1,54 @@ +锘縰sing System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; + +namespace WIDESEA_Common +{ + public enum AGVTaskTypeEnum + { + /// <summary> + /// 閫佹弧鏂欐灦 + /// </summary> + //SendFull = 1, + /// <summary> + /// 鍙栫┖鏂欐灦 + /// </summary> + //TakeEmpty = 2, + /// <summary> + /// 寰呮搴撳叆搴� + /// </summary> + [Description("寰呮搴撳叆搴�")] + TaskType_Inbound = 1, + /// <summary> + /// 寰呮搴撳嚭搴� + /// </summary> + [Description("寰呮搴撳嚭搴�")] + TaskType_Outbound = 2, + /// <summary> + /// 澶栧崗搴撳叆搴� + /// </summary> + [Description("澶栧崗搴撳叆搴�")] + TaskType_OutsourceInbound = 3, + /// <summary> + /// 澶栧崗搴撳嚭搴� + /// </summary> + [Description("澶栧崗搴撳嚭搴�")] + TaskType_OutsourceOutbound = 4, + /// <summary> + /// 寰呮搴撳唴绉诲簱 + /// </summary> + [Description("寰呮搴撳唴绉诲簱")] + TaskType_Carry, + /// <summary> + /// 寰呮绉诲簱澶栧崗 + /// </summary> + [Description("寰呮绉诲簱澶栧崗")] + TaskType_OutsourceCarry, + /// <summary> + /// 琛ョ┖鎵樹换鍔� + /// </summary> + [Description("琛ョ┖鎵樹换鍔�")] + TaskType_EmptyPallet, + } +} diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs" index c5d9223..25bf15f 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs" @@ -404,6 +404,15 @@ } #endregion + var Stations = stationinfoRepository.Find(x => x.area == PipelineJob.area_code(name)).OrderBy(x => x.lastUpdateTime).ToList(); + + #region 涓嬫枡浣嶆槸鍚︿负绌虹姸鎬佸悓姝ョ粰妗佹灦 + foreach (var station in Stations) + { + client.WriteByOrder(station.stationCode, station.location_state != LocationStateEnum.Stroge.ToString(), name); + } + #endregion + if (finished && !updatefinished) { client.WriteByOrder("W_Enabl_Load", false, name);//鏄惁鍏佽 @@ -551,14 +560,6 @@ #endregion - var Stations = stationinfoRepository.Find(x => x.area == PipelineJob.area_code(name)).OrderBy(x => x.lastUpdateTime).ToList(); - - #region 涓嬫枡浣嶆槸鍚︿负绌虹姸鎬佸悓姝ョ粰妗佹灦 - foreach (var station in Stations) - { - client.WriteByOrder(station.stationCode, station.location_state != LocationStateEnum.Stroge.ToString(), name); - } - #endregion #region MyRegion //var currentAreaNr = (Int16)DBExtension.Read(details.Where(x => x.plcdetail_name == "W_Are00aNr").First(), client); diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/GetStation/EmptyPalletStation.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/GetStation/EmptyPalletStation.cs" index 5d86ef2..9b62cbd 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/GetStation/EmptyPalletStation.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/GetStation/EmptyPalletStation.cs" @@ -60,9 +60,9 @@ #region 浼樺厛鍑�3搴撳尯鍐呯┖鎵樼洏 if (area == "11") { - EmptyStation = stationinfoRepository.Find(x => x.quantity > 0 && x.stationCode == "C01004001" /*&& x.location_state == "Stroge"*/ && x.tray_status == "EmptyTray" && x.enable).FirstOrDefault(); + EmptyStation = stationinfoRepository.Find(x => x.quantity > 0 && x.stationCode == "C01004002" /*&& x.location_state == "Stroge"*/ && x.tray_status == "EmptyTray" && x.enable).FirstOrDefault(); if (EmptyStation == null) - EmptyStation = stationinfoRepository.Find(x => x.quantity > 0 && x.stationCode == "C01005001"/* && x.location_state == "Stroge"*/ && x.tray_status == "EmptyTray" && x.enable).FirstOrDefault(); + EmptyStation = stationinfoRepository.Find(x => x.quantity > 0 && x.stationCode == "C01005002"/* && x.location_state == "Stroge"*/ && x.tray_status == "EmptyTray" && x.enable).FirstOrDefault(); if (EmptyStation != null) EmptyStation = stationinfoRepository.Find(x => x.quantity > 0 && x.area == EmptyStation.area && x.line == EmptyStation.line /*&& x.location_state == "Stroge"*/ && x.tray_status == "EmptyTray" && x.enable).OrderByDescending(x => x.column).FirstOrDefault(); if (EmptyStation != null)//绌烘墭璐т綅涓嶄负绌哄垽鏂槸鍚﹀瓨鍦ㄥ叾浠栦换鍔� @@ -143,15 +143,16 @@ Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context); #region 鏌ユ壘绌烘墭鐩樺簱鍖� - if (stationinfoRepository.Find(x => x.area == area && x.location_state == LocationStateEnum.Busy.ToString()).Any() && area != "10") + //if (stationinfoRepository.Find(x => x.area == area && x.location_state == LocationStateEnum.Busy.ToString()).Any() && area != "10") + if (stationinfoRepository.Find(x => x.stationCode == "A01001001" && x.quantity == 5 && x.location_state == LocationStateEnum.Stroge.ToString()).Any()) { - var EmptyStation = stationinfoRepository.Find(x => x.stationCode == "C01005001" && x.location_state == LocationStateEnum.Empty.ToString()).FirstOrDefault(); + var EmptyStation = stationinfoRepository.Find(x => x.stationCode == "C01005002" && x.location_state == LocationStateEnum.Empty.ToString()).FirstOrDefault(); if (EmptyStation != null) { if (!stationinfoRepository.Find(x => x.line == EmptyStation.line && x.area == EmptyStation.area && x.location_state != LocationStateEnum.Empty.ToString()).Any()) return EmptyStation; } - EmptyStation = stationinfoRepository.Find(x => x.quantity > 0 && x.stationCode == "C01005001" && x.location_state == "Stroge" && x.tray_status == "EmptyTray" && x.enable).FirstOrDefault(); + EmptyStation = stationinfoRepository.Find(x => x.quantity > 0 && x.stationCode == "C01005002" && x.location_state == "Stroge" && x.tray_status == "EmptyTray" && x.enable).FirstOrDefault(); if (EmptyStation != null) stationinfo = Station(EmptyStation, stationinfoRepository); @@ -161,31 +162,25 @@ if (EmptyStation.quantity == 5) { - EmptyStation = stationinfoRepository.Find(x => x.stationCode == "C01004001" && x.location_state == LocationStateEnum.Empty.ToString()).FirstOrDefault(); + EmptyStation = stationinfoRepository.Find(x => x.stationCode == "C01004002" && x.location_state == LocationStateEnum.Empty.ToString()).FirstOrDefault(); if (EmptyStation != null) { if (!stationinfoRepository.Find(x => x.line == EmptyStation.line && x.area == EmptyStation.area && x.location_state != LocationStateEnum.Empty.ToString()).Any()) return EmptyStation; } - EmptyStation = stationinfoRepository.Find(x => x.quantity > 0 && x.stationCode == "C01004001" && x.location_state == "Stroge" && x.tray_status == "EmptyTray" && x.enable).FirstOrDefault(); + EmptyStation = stationinfoRepository.Find(x => x.quantity > 0 && x.stationCode == "C01004002" && x.location_state == "Stroge" && x.tray_status == "EmptyTray" && x.enable).FirstOrDefault(); if (EmptyStation != null) stationinfo = Station(EmptyStation, stationinfoRepository); } } else { + if (stationinfoRepository.Find(x => x.area == area && x.location_state == LocationStateEnum.Busy.ToString()).Any()) return stationinfo; stationinfo = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 && x.enable).OrderBy(x => x.column).FirstOrDefault(); if (stationinfo != null) - { if (stationinfo.quantity < 5) return stationinfo; - else - stationinfo = stationinfoRepository.Find(x => x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderByDescending(x => x.column).FirstOrDefault(); - } - else - { - stationinfo = stationinfoRepository.Find(x => x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderByDescending(x => x.column).FirstOrDefault(); - } + stationinfo = stationinfoRepository.Find(x => x.area == area && x.location_state == LocationStateEnum.Empty.ToString() && x.enable).OrderByDescending(x => x.column).FirstOrDefault(); } #endregion diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs" index 2825cc2..83dd24b 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs" @@ -1,11 +1,14 @@ -锘縰sing System; +锘縰sing OfficeOpenXml.FormulaParsing.Excel.Functions.Text; +using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; using WIDESEA_Comm; using WIDESEA_Comm.LogInfo; +using WIDESEA_Common; using WIDESEA_Core.BaseProvider; using WIDESEA_Core.EFDbContext; using WIDESEA_Entity.DomainModels; @@ -31,104 +34,210 @@ try { VOLContext Context = new VOLContext(); - Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context); - IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(Context); Idt_agvtaskRepository agvtaskService = new dt_agvtaskRepository(Context); - var tasks = agvtaskService.Find(x => x.agv_taskstate == "Queue").OrderByDescending(x => x.agv_grade).ThenBy(x => x.agv_createtime).ToList(); - foreach (var task in tasks) + + #region 闃熷垪浠诲姟 + var agvtasks = agvtaskService.Find(x => x.agv_taskstate == AGVTaskStateEnum.Queue.ToString()).ToList(); + + var AGVTaskTypes = Enum.GetNames(typeof(AGVTaskTypeEnum)); + foreach (var AGVTaskType in AGVTaskTypes) { - try + var agvtask = agvtasks.Where(x => x.agv_tasktype == AGVTaskType).OrderByDescending(x => x.agv_grade).ThenBy(x => x.agv_createtime).FirstOrDefault(); + if (agvtask != null) UpdateQueue(agvtaskService, agvtask); + } + #endregion + + #region MyRegion + //var tasks = agvtaskService.Find(x => x.agv_taskstate == "Queue").OrderByDescending(x => x.agv_grade).ThenBy(x => x.agv_createtime).ToList(); + //foreach (var task in tasks) + //{ + // try + // { + // if (task.agv_tasktype == "TaskType_EmptyPallet")//绌烘墭浠诲姟 + // { + // if (task.agv_fromaddress == "" && DateTime.Now - task.agv_createtime >= TimeSpan.FromMinutes(2)) + // { + // if (task.agv_tasknum.Contains("_")) + // { + // string mainTaskNum = task.agv_tasknum.Split('_')[0]; + // if (agvtaskService.Find(x => x.agv_tasknum == mainTaskNum && task.agv_taskstate != "Executing" && task.agv_taskstate != "Create").Any() || !agvtaskService.Find(x => x.agv_tasknum == mainTaskNum).Any()) + // GetStation.EmptyPalletStation(task); + // } + // else + // GetStation.EmptyPalletStation(task); + + // WriteDBLog.Success("鏇存柊绌烘墭闃熷垪浠诲姟", $"浠诲姟缂栧彿锛歿task.agv_tasknum}", "PCS"); + // continue; + // } + // } + // else if (task.agv_tasktype == "TaskType_OutsourceInbound" || task.agv_tasktype == "TaskType_Inbound")//澶栧崗搴撳叆搴�/AB搴撳叆搴� + // { + // if (task.agv_toaddress == "") + // { + // var stationinfo = stationinfoRepository.Find(x => x.stationCode == task.agv_fromaddress).FirstOrDefault(); + // var work = workinfoRepository.Find(x => x.workOrder == stationinfo.Number && x.drawingNo == stationinfo.stationType && x.heatID == stationinfo.heatNumber && x.processCode == "17").FirstOrDefault(); + // var TargetLocation = task.agv_tasktype == "TaskType_Inbound" ? GetLocation.GetEmptyLocation(stationinfoRepository, work, task) : StationTask.GetEmptyLocation(stationinfoRepository); + // if (TargetLocation != null) + // { + // if (agvtaskService.Find(x => x.agv_toaddress == TargetLocation.stationCode).Any()) continue; + // task.agv_taskstate = "Create"; + // task.agv_toaddress = TargetLocation.stationCode; + // TargetLocation.location_state = LocationStateEnum.InBusy.ToString(); + // TargetLocation.billetID = stationinfo.billetID; + // TargetLocation.stationType = task.agv_materielid; + // TargetLocation.heatNumber = stationinfo.heatNumber; + // TargetLocation.Number = task.jobID; + // stationinfoRepository.Update(TargetLocation, true); + // agvtaskService.Update(task, true); + // WriteDBLog.Success("鏇存柊鍏ュ簱闃熷垪浠诲姟", $"浠诲姟缂栧彿锛歿task.agv_tasknum}", "PCS"); + // continue; + // } + // } + // } + // else if (task.agv_tasktype == "TaskType_OutsourceOutbound" || task.agv_tasktype == "TaskType_Outbound")//澶栧崗搴撳嚭搴�/AB搴撳嚭搴� + // { + // if (task.agv_toaddress == "") + // { + // var EmptyStations = stationinfoRepository.Find(x => x.stationCode.Contains("S01001") && (x.tray_status == "EmptyTray" || x.location_state == "Empty") && x.enable).ToList(); + // foreach (var EmptyStation in EmptyStations) + // { + // if (agvtaskService.Find(x => x.agv_toaddress == EmptyStation.stationCode).Any()) continue; + // task.agv_taskstate = "Create"; + // task.agv_toaddress = EmptyStation.stationCode; + // EmptyStation.location_state = LocationStateEnum.Busy.ToString(); + // stationinfoRepository.Update(EmptyStation, true); + // agvtaskService.Update(task, true); + // WriteDBLog.Success("鏇存柊鍑哄簱闃熷垪浠诲姟", $"浠诲姟缂栧彿锛歿task.agv_tasknum}", "PCS"); + // return; + // } + // } + // } + // else if (task.agv_tasktype == "TaskType_OutsourceCarry")//绉诲簱澶栧崗 + // { + // if (task.agv_toaddress == "") + // { + // var TargetLocation = StationTask.GetEmptyLocation(stationinfoRepository); + // if (TargetLocation != null) + // { + // if (agvtaskService.Find(x => x.agv_toaddress == TargetLocation.stationCode).Any()) continue; + + // task.agv_taskstate = "Create"; + // task.agv_toaddress = TargetLocation.stationCode; + // TargetLocation.location_state = LocationStateEnum.OutBusy.ToString(); + // TargetLocation.stationType = task.agv_materielid; + // stationinfoRepository.Update(TargetLocation, true); + // agvtaskService.Update(task, true); + // WriteDBLog.Success("鏇存柊绉诲簱澶栧崗闃熷垪浠诲姟", $"浠诲姟缂栧彿锛歿task.agv_tasknum}", "PCS"); + // continue; + // } + // } + // } + // } + // catch (Exception ex) + // { + // //WriteDBLog.Error("鏇存柊闃熷垪浠诲姟", $"閿欒淇℃伅锛歿ex.Message}", "PCS"); + // WriteLog.Write_Log("鏇存柊闃熷垪浠诲姟", "鏇存柊澶辫触", "", $"閿欒淇℃伅锛歿ex.Message}"); + // } + //} + #endregion + + } + catch (Exception ex) + { + WriteDBLog.Error("鏇存柊闃熷垪浠诲姟", $"閿欒淇℃伅锛歿ex.Message}", "PCS"); + } + } + + public static void UpdateQueue(Idt_agvtaskRepository agvtaskService, dt_agvtask agvtask) + { + VOLContext Context = new VOLContext(); + Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context); + IVV_Mes_WorkinfoRepository workinfoRepository = new VV_Mes_WorkinfoRepository(Context); + try + { + if (agvtask.agv_tasktype == AGVTaskTypeEnum.TaskType_EmptyPallet.ToString())//绌烘墭浠诲姟 + { + if (agvtask.agv_fromaddress == "" && DateTime.Now - agvtask.agv_createtime >= TimeSpan.FromMinutes(2)) { - if (task.agv_tasktype == "TaskType_EmptyPallet")//绌烘墭浠诲姟 + if (agvtask.agv_tasknum.Contains("_")) { - if (task.agv_fromaddress == "" && DateTime.Now - task.agv_createtime >= TimeSpan.FromMinutes(2)) - { - if (task.agv_tasknum.Contains("_")) - { - string mainTaskNum = task.agv_tasknum.Split('_')[0]; - if (agvtaskService.Find(x => x.agv_tasknum == mainTaskNum && task.agv_taskstate != "Executing" && task.agv_taskstate != "Create").Any() || !agvtaskService.Find(x => x.agv_tasknum == mainTaskNum).Any()) - GetStation.EmptyPalletStation(task); - } - else - GetStation.EmptyPalletStation(task); + string mainTaskNum = agvtask.agv_tasknum.Split('_')[0]; + if (agvtaskService.Find(x => x.agv_tasknum == mainTaskNum && agvtask.agv_taskstate != AGVTaskStateEnum.Executing.ToString() && agvtask.agv_taskstate != AGVTaskStateEnum.Create.ToString()).Any() || !agvtaskService.Find(x => x.agv_tasknum == mainTaskNum).Any()) + GetStation.EmptyPalletStation(agvtask); + } + else + GetStation.EmptyPalletStation(agvtask); - WriteDBLog.Success("鏇存柊绌烘墭闃熷垪浠诲姟", $"浠诲姟缂栧彿锛歿task.agv_tasknum}", "PCS"); - continue; - } - } - else if (task.agv_tasktype == "TaskType_OutsourceInbound" || task.agv_tasktype == "TaskType_Inbound")//澶栧崗搴撳叆搴�/AB搴撳叆搴� + WriteDBLog.Success("鏇存柊绌烘墭闃熷垪浠诲姟", $"浠诲姟缂栧彿锛歿agvtask.agv_tasknum}", "PCS"); + } + } + else if (agvtask.agv_tasktype == AGVTaskTypeEnum.TaskType_OutsourceInbound.ToString() || agvtask.agv_tasktype == AGVTaskTypeEnum.TaskType_Inbound.ToString())//澶栧崗搴撳叆搴�/AB搴撳叆搴� + { + if (agvtask.agv_toaddress == "") + { + var stationinfo = stationinfoRepository.Find(x => x.stationCode == agvtask.agv_fromaddress).FirstOrDefault(); + var work = workinfoRepository.Find(x => x.workOrder == stationinfo.Number && x.drawingNo == stationinfo.stationType && x.heatID == stationinfo.heatNumber && x.processCode == "17").FirstOrDefault(); + var TargetLocation = agvtask.agv_tasktype == AGVTaskTypeEnum.TaskType_Inbound.ToString() ? GetLocation.GetEmptyLocation(stationinfoRepository, work, agvtask) : StationTask.GetEmptyLocation(stationinfoRepository); + if (TargetLocation != null) { - if (task.agv_toaddress == "") + if (!agvtaskService.Find(x => x.agv_toaddress == TargetLocation.stationCode).Any()) { - var stationinfo = stationinfoRepository.Find(x => x.stationCode == task.agv_fromaddress).FirstOrDefault(); - var work = workinfoRepository.Find(x => x.workOrder == stationinfo.Number && x.drawingNo == stationinfo.stationType && x.heatID == stationinfo.heatNumber && x.processCode == "17").FirstOrDefault(); - var TargetLocation = task.agv_tasktype == "TaskType_Inbound" ? GetLocation.GetEmptyLocation(stationinfoRepository, work, task) : StationTask.GetEmptyLocation(stationinfoRepository); - if (TargetLocation != null) - { - if (agvtaskService.Find(x => x.agv_toaddress == TargetLocation.stationCode).Any()) continue; - task.agv_taskstate = "Create"; - task.agv_toaddress = TargetLocation.stationCode; - TargetLocation.location_state = LocationStateEnum.InBusy.ToString(); - TargetLocation.billetID = stationinfo.billetID; - TargetLocation.stationType = task.agv_materielid; - TargetLocation.heatNumber = stationinfo.heatNumber; - TargetLocation.Number = task.jobID; - stationinfoRepository.Update(TargetLocation, true); - agvtaskService.Update(task, true); - WriteDBLog.Success("鏇存柊鍏ュ簱闃熷垪浠诲姟", $"浠诲姟缂栧彿锛歿task.agv_tasknum}", "PCS"); - continue; - } - } - } - else if (task.agv_tasktype == "TaskType_OutsourceOutbound" || task.agv_tasktype == "TaskType_Outbound")//澶栧崗搴撳嚭搴�/AB搴撳嚭搴� - { - if (task.agv_toaddress == "") - { - var EmptyStations = stationinfoRepository.Find(x => x.stationCode.Contains("S01001") && (x.tray_status == "EmptyTray" || x.location_state == "Empty") && x.enable).ToList(); - foreach (var EmptyStation in EmptyStations) - { - if (agvtaskService.Find(x => x.agv_toaddress == EmptyStation.stationCode).Any()) continue; - task.agv_taskstate = "Create"; - task.agv_toaddress = EmptyStation.stationCode; - EmptyStation.location_state = LocationStateEnum.Busy.ToString(); - stationinfoRepository.Update(EmptyStation, true); - agvtaskService.Update(task, true); - WriteDBLog.Success("鏇存柊鍑哄簱闃熷垪浠诲姟", $"浠诲姟缂栧彿锛歿task.agv_tasknum}", "PCS"); - return; - } - } - } - else if (task.agv_tasktype == "TaskType_OutsourceCarry")//绉诲簱澶栧崗 - { - if (task.agv_toaddress == "") - { - var TargetLocation = StationTask.GetEmptyLocation(stationinfoRepository); - if (TargetLocation != null) - { - if (agvtaskService.Find(x => x.agv_toaddress == TargetLocation.stationCode).Any()) continue; - - task.agv_taskstate = "Create"; - task.agv_toaddress = TargetLocation.stationCode; - TargetLocation.location_state = LocationStateEnum.OutBusy.ToString(); - TargetLocation.stationType = task.agv_materielid; - stationinfoRepository.Update(TargetLocation, true); - agvtaskService.Update(task, true); - WriteDBLog.Success("鏇存柊绉诲簱澶栧崗闃熷垪浠诲姟", $"浠诲姟缂栧彿锛歿task.agv_tasknum}", "PCS"); - continue; - } + agvtask.agv_taskstate = AGVTaskStateEnum.Create.ToString(); + agvtask.agv_toaddress = TargetLocation.stationCode; + TargetLocation.location_state = LocationStateEnum.InBusy.ToString(); + TargetLocation.billetID = stationinfo.billetID; + TargetLocation.stationType = agvtask.agv_materielid; + TargetLocation.heatNumber = stationinfo.heatNumber; + TargetLocation.Number = agvtask.jobID; + stationinfoRepository.Update(TargetLocation, true); + agvtaskService.Update(agvtask, true); + WriteDBLog.Success("鏇存柊鍏ュ簱闃熷垪浠诲姟", $"浠诲姟缂栧彿锛歿agvtask.agv_tasknum}", "PCS"); } } } - catch (Exception ex) + } + else if (agvtask.agv_tasktype == AGVTaskTypeEnum.TaskType_OutsourceOutbound.ToString() || agvtask.agv_tasktype == AGVTaskTypeEnum.TaskType_Outbound.ToString())//澶栧崗搴撳嚭搴�/AB搴撳嚭搴� + { + if (agvtask.agv_toaddress == "") { - //WriteDBLog.Error("鏇存柊闃熷垪浠诲姟", $"閿欒淇℃伅锛歿ex.Message}", "PCS"); - WriteLog.Write_Log("鏇存柊闃熷垪浠诲姟","鏇存柊澶辫触", "", $"閿欒淇℃伅锛歿ex.Message}"); + var EmptyStations = stationinfoRepository.Find(x => x.stationCode.Contains("S01001") && (x.tray_status == TrayStateEnum.EmptyTray.ToString() || x.location_state == LocationStateEnum.Empty.ToString()) && x.enable).ToList(); + foreach (var EmptyStation in EmptyStations) + { + if (agvtaskService.Find(x => x.agv_toaddress == EmptyStation.stationCode).Any()) continue; + agvtask.agv_taskstate = AGVTaskStateEnum.Create.ToString(); + agvtask.agv_toaddress = EmptyStation.stationCode; + EmptyStation.location_state = LocationStateEnum.Busy.ToString(); + stationinfoRepository.Update(EmptyStation, true); + agvtaskService.Update(agvtask, true); + WriteDBLog.Success("鏇存柊鍑哄簱闃熷垪浠诲姟", $"浠诲姟缂栧彿锛歿agvtask.agv_tasknum}", "PCS"); + return; + } + } + } + else if (agvtask.agv_tasktype == AGVTaskTypeEnum.TaskType_OutsourceCarry.ToString())//绉诲簱澶栧崗 + { + if (agvtask.agv_toaddress == "") + { + var TargetLocation = StationTask.GetEmptyLocation(stationinfoRepository); + if (TargetLocation != null) + { + if (!agvtaskService.Find(x => x.agv_toaddress == TargetLocation.stationCode).Any()) + { + agvtask.agv_taskstate = AGVTaskStateEnum.Create.ToString(); + agvtask.agv_toaddress = TargetLocation.stationCode; + TargetLocation.location_state = LocationStateEnum.OutBusy.ToString(); + TargetLocation.stationType = agvtask.agv_materielid; + stationinfoRepository.Update(TargetLocation, true); + agvtaskService.Update(agvtask, true); + WriteDBLog.Success("鏇存柊绉诲簱澶栧崗闃熷垪浠诲姟", $"浠诲姟缂栧彿锛歿agvtask.agv_tasknum}", "PCS"); + } + } } } } catch (Exception ex) { - WriteDBLog.Error("鏇存柊闃熷垪浠诲姟", $"閿欒淇℃伅锛歿ex.Message}", "PCS"); + WriteLog.Write_Log("鏇存柊闃熷垪浠诲姟", "鏇存柊澶辫触", "", $"閿欒淇℃伅锛歿ex.Message}"); } } } -- Gitblit v1.9.3