From 874ceff175a7308da045943fb7def1f6c6560a51 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期二, 26 三月 2024 11:31:08 +0800 Subject: [PATCH] 优化NG任务触发逻辑 --- /dev/null | 42 ------ 代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/新文件夹/OutboundTask_a.cs | 137 +++++++++--------- 代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/RestockHCJ.cs | 3 代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/StationTask.cs | 30 ---- 代码管理/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs | 3 代码管理/PCS/WCS_Server/WIDESEA_WCS/Common/Gantry.cs | 99 ++++++++----- 代码管理/PCS/WCS_Server/WIDESEA_WCS/Services/WCS/Partial/VV_DispatchService.cs | 2 代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/新文件夹/RestockHCJ_a.cs | 80 +++++++++++ 8 files changed, 216 insertions(+), 180 deletions(-) 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 d0c8b7a..f78df0c 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" @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Security.Cryptography.Xml; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; @@ -407,7 +408,7 @@ WriteDBLog.Error(name, $"璇诲彇妗佹灦淇℃伅锛歕n杞﹁疆SN鍙蜂负绌�", "PCS"); continue; } - + //var Wheel_id = DBExtension.Read(details.Where(x => x.plcdetail_name == "R_Wheel_id").First(), client).ToString(); var Detail = mes_DetailRepository.FindFirst(x => x.SN == Wheel_SN); @@ -418,7 +419,7 @@ #endregion continue; } - var Head = mes_HeadRepository.FindFirst(x => x.jobID == Detail.jobID); + var Head = mes_HeadRepository.FindFirst(x => x.jobID == Detail.jobID && x.processCode == "17"); if (Head == null) { #region 鏃ュ織璁板綍 @@ -600,23 +601,34 @@ if (Stationinfo == null) { #region 涓嬫枡浣嶆潯浠朵笉鍖归厤鐩存帴瑙﹀彂鍏ュ簱浠诲姟 - var stationinfos = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).ToList(); - foreach (var stationinfo in stationinfos) + //var stationinfos = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).ToList(); + //foreach (var stationinfo in stationinfos) + //{ + // agvtask(stationinfoRepository, stationinfo, (wheel == null ? wheel1.e : wheel.e), name == "3鍗曞厓涓嬫枡鍖�" ? "TaskType_OutsourceInbound" : "TaskType_Inbound"); + //} + #endregion + + + #region 瑙﹀彂NG浠诲姟 + var NG = Stations.Where(x => x.enable && x.stationCode == NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).FirstOrDefault(); + if (NG != null) { - agvtask(stationinfoRepository, stationinfo, (wheel == null ? wheel1.e : wheel.e), name == "3鍗曞厓涓嬫枡鍖�" ? "TaskType_OutsourceInbound" : "TaskType_Inbound"); + if (NG.stationType != mes_Head.drawingNo) + agvtask(stationinfoRepository, NG, (wheel == null ? wheel1.e : wheel.e), "TaskType_OutsourceInbound"); } #endregion Stationinfo = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity == 0).FirstOrDefault(); + #region 娌℃墭鐩樺彲鐢�,瑙﹀彂鍏ュ簱浠诲姟 - //if (Stationinfo == null) - //{ - // var stationinfos = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).ToList(); - // foreach (var stationinfo in stationinfos) - // { - // agvtask(stationinfoRepository, stationinfo, (wheel == null ? wheel1.e : wheel.e), name == "3鍗曞厓涓嬫枡鍖�" ? "TaskType_OutsourceInbound" : "TaskType_Inbound"); - // } - //} + if (Stationinfo == null) + { + var stationinfos = Stations.Where(x => x.enable && x.stationCode != NGStation && x.location_state == LocationStateEnum.Stroge.ToString() && x.quantity > 0).ToList(); + foreach (var stationinfo in stationinfos) + { + agvtask(stationinfoRepository, stationinfo, (wheel == null ? wheel1.e : wheel.e), name == "3鍗曞厓涓嬫枡鍖�" ? "TaskType_OutsourceInbound" : "TaskType_Inbound"); + } + } #endregion #region MyRegion @@ -695,29 +707,31 @@ else if ((Int16)PartStatus == 2) { dt_stationinfo Stationinfo = null; - if (mes_Detail.heatID != null) - { - Stationinfo = Stations - .Where(x => x.enable - && x.stationCode == NGStation - && x.location_state == LocationStateEnum.Stroge.ToString() - && x.quantity < 5 - && x.stationType == mes_Head.drawingNo - && x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray") - && x.Number == mes_Detail.jobID - && x.heatNumber == mes_Detail.heatID).FirstOrDefault(); - } - else - { - Stationinfo = Stations - .Where(x => x.enable - && x.stationCode == NGStation - && x.location_state == LocationStateEnum.Stroge.ToString() - && x.quantity < 5 - && x.stationType == mes_Head.drawingNo - && x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray") - && x.Number == mes_Detail.jobID).FirstOrDefault(); - } + //if (mes_Detail.heatID != null) + //{ + // Stationinfo = Stations + //.Where(x => x.enable + //&& x.stationCode == NGStation + //&& x.location_state == LocationStateEnum.Stroge.ToString() + //&& x.quantity < 5 + //&& x.stationType == mes_Head.drawingNo + //&& x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray") + //&& x.Number == mes_Detail.jobID + //&& x.heatNumber == mes_Detail.heatID).FirstOrDefault(); + //} + //else + //{ + //var tray_type = "SmallTray"; + //if ((wheel == null ? wheel1.e : wheel.e) > 1100) tray_type = "LargeTray"; + Stationinfo = Stations + .Where(x => x.enable + && x.stationCode == NGStation + && x.location_state == LocationStateEnum.Stroge.ToString() + && x.quantity < 5 + && x.stationType == mes_Head.drawingNo + && x.tray_type == ((wheel == null ? wheel1.e : wheel.e) < 1100 ? "SmallTray" : "LargeTray") + /*&& x.Number == mes_Detail.jobID*/).FirstOrDefault(); + //} if (Stationinfo == null) { @@ -864,10 +878,19 @@ var task = agvtaskRepository.Find(x => x.agv_fromaddress == stationinfo.stationCode).FirstOrDefault(); if (task != null) return; - var mes_Head = mes_HeadRepository.FindFirst(x => x.jobID == stationinfo.Number); + var mes_Head = mes_HeadRepository.Find(x => x.jobID == stationinfo.Number).FirstOrDefault(); + if (mes_Head == null) + { + stationinfo.remark = "瑙﹀彂鍏ュ簱浠诲姟,浣嗘湭鎵惧埌宸ュ崟澶磋〃锛�"; + stationinfo.location_state = LocationStateEnum.Abnormal.ToString(); + stationinfoRepository.Update(stationinfo, true); + return; + } dt_stationinfo TargetLocation = null; int CompeletedNum = Convert.ToInt32(mes_Head.quantity) - Convert.ToInt32(mes_Head.finishNum); + if (mes_Head.quantity <= 50) tasktype = "TaskType_OutsourceInbound"; + if (tasktype == "TaskType_OutsourceInbound") TargetLocation = StationTask.GetEmptyLocation(stationinfoRepository); else if (tasktype == "TaskType_Inbound") @@ -895,7 +918,7 @@ agv_TrayStatus = stationinfo.tray_status }; agvtaskRepository.Add(agvtask, true); - stationinfo.location_state = LocationStateEnum.Busy.ToString(); + stationinfo.location_state = LocationStateEnum.InBusy.ToString(); stationinfoRepository.Update(stationinfo, true); TargetLocation.location_state = LocationStateEnum.InBusy.ToString(); TargetLocation.stationType = agvtask.agv_materielid; diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs" index 2fbcfb5..27aa48e 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob.cs" @@ -36,7 +36,8 @@ //EmptyTrayTask.InEmptyTrayTask();搴撳唴绌烘墭浠诲姟 StationTask.CreateTask(); - OutboundTask.CreateOutboundTask(); + //OutboundTask.CreateOutboundTask(); + OutboundTask_a.CreateOutboundTask(); ReplaceTray.ReplaceTrayTask(); RestockHCJ.HCJGetBarcode(); EmptyTrayTask.CreateEmptyTrayTask(); diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob_a.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob_a.cs" deleted file mode 100644 index 940a55b..0000000 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Jobs/Task/AutoTaskJob_a.cs" +++ /dev/null @@ -1,42 +0,0 @@ -锘縰sing Quartz; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using WIDESEA_WCS.Jobs; -using WIDESEA_WCS.JobsPart.Common; -using WIDESEA_WCS.JobsPart.Common.鏂版枃浠跺す; -using WIDESEA_WCS.WCSClient; -using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; - -namespace WIDESEA_WCS -{ - [DisallowConcurrentExecution] - public class AutoTaskJob_a : JobBase, IJob - { - /// <summary> - /// 鑷姩浠诲姟 - /// </summary> - Createplcinfodetail Creation = new Createplcinfodetail(); - public Task Execute(IJobExecutionContext context) - { - try - { - ExecuteJob(context, DoAction); - } - catch { } - return Task.CompletedTask; - } - - private void DoAction(IJobExecutionContext context) - { - StationTask.CreateTask(); - OutboundTask_a.CreateOutboundTask(); - ReplaceTray.ReplaceTrayTask(); - RestockHCJ.HCJGetBarcode(); - EmptyTrayTask.CreateEmptyTrayTask(); - AutoUpdateWork.FinishMesWork(); - } - } -} 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 98b94fe..14b31a9 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" @@ -43,7 +43,7 @@ var area = task.agv_Traytype == "SmallTray" ? "11" : "10"; //鎵�1搴撳尯鐨勭┖鎵樹綅 var EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 && x.stationCode.Contains("A") && x.location_state == "Stroge"/*LocationStateEnum.Stroge.ToString()*/ && x.enable) - .OrderBy(x => x.line).OrderByDescending(x => x.column).FirstOrDefault(); + .OrderBy(x => x.column).OrderBy(x => x.line).FirstOrDefault(); #region 涓�涓尯鍩熷彧鑳芥湁涓�涓┖鎵樹换鍔� //bool ok = false; @@ -55,6 +55,7 @@ #endregion if (EmptyStation == null) EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 && x.stationCode.Contains(area == "10" ? "D" : "C") && x.enable).OrderByDescending(x => x.column).FirstOrDefault(); + if (EmptyStation == null) continue; #region 搴撳唴瀛樺湪浠诲姟鍗犵敤 if (EmptyStation.location_state == LocationStateEnum.Busy.ToString()) continue; diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/StationTask.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/StationTask.cs" index 188a1ef..ef73816 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/StationTask.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/StationTask.cs" @@ -79,36 +79,6 @@ //todo 瀵绘壘鍙斁璐у鍗忔斁璐у彴 tasktype = "TaskType_OutsourceInbound"; TargetLocation = GetEmptyLocation(stationinfoRepository); - #region MyRegion - //if (TargetLocation != null) - //{ - // dt_agvtask agvtask = new dt_agvtask() - // { - // agv_fromaddress = item.stationCode, - // agv_id = Guid.NewGuid(), - // agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), - // agv_grade = 1, - // agv_createtime = DateTime.Now, - // agv_taskstate = "Create", - // agv_materielid = item.stationType, - // agv_qty = item.quantity, - // agv_tasktype = "TaskType_OutsourceInbound", - // agv_toaddress = TargetLocation.stationCode, - // agv_userid = "绯荤粺", - // bindSN = item.bindSN, - // agv_worktype = Convert.ToInt32(mesinfo.processCode), - // agv_materbarcode = mesinfo.materialCode, - // agv_Traytype = item.tray_type, - // jobID = item.Number, - // agv_TrayStatus = item.tray_status - // }; - - // agvtaskRepository.Add(agvtask, true); - // TargetLocation.location_state = LocationStateEnum.Busy.ToString(); - // TargetLocation.stationType = agvtask.agv_materielid; - // stationinfoRepository.Update(TargetLocation, true); - //} - #endregion } else diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/OutboundTask_a.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/OutboundTask_a.cs" index bb62e0d..fefec01 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/OutboundTask_a.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/OutboundTask_a.cs" @@ -17,7 +17,7 @@ using static FreeSql.Internal.GlobalFilter; using static System.Collections.Specialized.BitVector32; -namespace WIDESEA_WCS.JobsPart.Common.鏂版枃浠跺す +namespace WIDESEA_WCS.JobsPart.Common { public class OutboundTask_a { @@ -35,7 +35,7 @@ Idt_inventoryRepository inventoryRepository = new dt_inventoryRepository(context); Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context); - var mes_heads = mes_HeadRepository.Find(x => x.processCode == "28").OrderBy(x => x.expectedStartTime).ToList(); + var mes_heads = mes_HeadRepository.Find(x => x.processCode == "28").OrderByDescending(x => x.CreateTime).ToList(); foreach (var mes_head in mes_heads) { #region 鏍规嵁宸ュ崟瀛愯〃鏌ユ壘搴撳瓨 @@ -48,9 +48,12 @@ var Station = stationinfoRepository.Find(x => x.stationCode == inventory.stationCode).FirstOrDefault(); if (Station != null) { - var stationinfos = stationinfoRepository.Find(x => x.line == Station.line && x.area == Station.area && x.quantity > 0 && x.enable && x.location_state == LocationStateEnum.Stroge.ToString()).OrderByDescending(x => x.column).ToList(); - foreach (var stationinfo in stationinfos) + var stationinfo = stationinfoRepository.Find(x => x.line == Station.line && x.area == Station.area && x.enable && x.quantity > 0).OrderByDescending(x => x.column).FirstOrDefault(); + + if (stationinfo != null) { + if (stationinfo.location_state == LocationStateEnum.OutBusy.ToString() || stationinfo.location_state != LocationStateEnum.Stroge.ToString()) continue; + if (string.IsNullOrEmpty(stationinfo.bindSN)) { stationinfo.remark = "杞﹁疆SN鍙蜂俊鎭紓甯�"; @@ -68,75 +71,73 @@ } #region 璐т綅杞﹁疆鍏ㄩ儴鍖呭惈鍦ㄥ伐鍗曞唴鍒欎笅鍙戜换鍔� - bool OK = false; + //bool OK = false; foreach (var SN in lists) { - OK = mes_DetailRepository.Find(x => x.jobID == mes_head.jobID && x.SN == SN).Any(); - } - if (OK) - { - dt_agvtask agvtask = new dt_agvtask() - { - agv_fromaddress = stationinfo.stationCode, - agv_id = Guid.NewGuid(), - agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), - agv_grade = 1, - agv_createtime = DateTime.Now, - agv_taskstate = "Queue", - agv_materielid = stationinfo.stationType, - agv_qty = stationinfo.quantity, - agv_tasktype = "TaskType_Outbound", - agv_toaddress = "", - agv_userid = "绯荤粺", - bindSN = stationinfo.bindSN, - jobID = mes_head.jobID, - agv_worktype = Convert.ToInt32(mes_head.processCode), - agv_materbarcode = mes_head.materialCode, - agv_Traytype = stationinfo.tray_type, - agv_TrayStatus = stationinfo.tray_status - }; - stationinfo.location_state = LocationStateEnum.OutBusy.ToString(); - stationinfoRepository.Update(stationinfo, true); - agvtaskRepository.Add(agvtask, true); - WriteDBLog.Success("鍒涘缓鍑哄簱浠诲姟", $"浠诲姟缂栧彿锛歿agvtask.agv_tasknum}", "PCS"); - continue; - } - #endregion + if (!mes_DetailRepository.Find(x => x.jobID == mes_head.jobID && x.SN.Contains(SN)).Any()) return; - #region 璐т綅杞﹁疆鏈変竴涓寘鍚湪宸ュ崟鍐呭垯涓嬪彂浠诲姟 - //foreach (var SN in lists) - //{ - // if (mes_DetailRepository.Find(x => x.jobID == mes_head.jobID && x.SN == SN).Any()) - // { - // dt_agvtask agvtask = new dt_agvtask() - // { - // agv_fromaddress = stationinfo.stationCode, - // agv_id = Guid.NewGuid(), - // agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), - // agv_grade = 2, - // agv_createtime = DateTime.Now, - // agv_taskstate = "Queue", - // agv_materielid = stationinfo.stationType, - // agv_qty = stationinfo.quantity, - // agv_tasktype = "TaskType_Outbound", - // agv_toaddress = "", - // agv_userid = "绯荤粺", - // bindSN = stationinfo.bindSN, - // jobID = mes_head.jobID, - // agv_worktype = Convert.ToInt32(mes_head.processCode), - // agv_materbarcode = mes_head.materialCode, - // agv_Traytype = stationinfo.tray_type, - // agv_TrayStatus = stationinfo.tray_status - // }; - // stationinfo.location_state = LocationStateEnum.OutBusy.ToString(); - // stationinfoRepository.Update(stationinfo, true); - // agvtaskRepository.Add(agvtask, true); - // WriteDBLog.Success("鍒涘缓鍑哄簱浠诲姟", $"浠诲姟缂栧彿锛歿agvtask.agv_tasknum}", "PCS"); - // continue; - // } - //} + } + dt_agvtask agvtask = new dt_agvtask() + { + agv_fromaddress = stationinfo.stationCode, + agv_id = Guid.NewGuid(), + agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), + agv_grade = 1, + agv_createtime = DateTime.Now, + agv_taskstate = "Queue", + agv_materielid = stationinfo.stationType, + agv_qty = stationinfo.quantity, + agv_tasktype = "TaskType_Outbound", + agv_toaddress = "", + agv_userid = "绯荤粺", + bindSN = stationinfo.bindSN, + jobID = mes_head.jobID, + agv_worktype = Convert.ToInt32(mes_head.processCode), + agv_materbarcode = mes_head.materialCode, + agv_Traytype = stationinfo.tray_type, + agv_TrayStatus = stationinfo.tray_status + }; + stationinfo.location_state = LocationStateEnum.OutBusy.ToString(); + stationinfoRepository.Update(stationinfo, true); + agvtaskRepository.Add(agvtask, true); + WriteDBLog.Success("鍒涘缓鍑哄簱浠诲姟", $"浠诲姟缂栧彿锛歿agvtask.agv_tasknum}", "PCS"); + continue; #endregion } + + #region 璐т綅杞﹁疆鏈変竴涓寘鍚湪宸ュ崟鍐呭垯涓嬪彂浠诲姟 + //foreach (var SN in lists) + //{ + // if (mes_DetailRepository.Find(x => x.jobID == mes_head.jobID && x.SN == SN).Any()) + // { + // dt_agvtask agvtask = new dt_agvtask() + // { + // agv_fromaddress = stationinfo.stationCode, + // agv_id = Guid.NewGuid(), + // agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"), + // agv_grade = 2, + // agv_createtime = DateTime.Now, + // agv_taskstate = "Queue", + // agv_materielid = stationinfo.stationType, + // agv_qty = stationinfo.quantity, + // agv_tasktype = "TaskType_Outbound", + // agv_toaddress = "", + // agv_userid = "绯荤粺", + // bindSN = stationinfo.bindSN, + // jobID = mes_head.jobID, + // agv_worktype = Convert.ToInt32(mes_head.processCode), + // agv_materbarcode = mes_head.materialCode, + // agv_Traytype = stationinfo.tray_type, + // agv_TrayStatus = stationinfo.tray_status + // }; + // stationinfo.location_state = LocationStateEnum.OutBusy.ToString(); + // stationinfoRepository.Update(stationinfo, true); + // agvtaskRepository.Add(agvtask, true); + // WriteDBLog.Success("鍒涘缓鍑哄簱浠诲姟", $"浠诲姟缂栧彿锛歿agvtask.agv_tasknum}", "PCS"); + // continue; + // } + //} + #endregion } } } diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/RestockHCJ_a.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/RestockHCJ_a.cs" new file mode 100644 index 0000000..ff9cd71 --- /dev/null +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/\346\226\260\346\226\207\344\273\266\345\244\271/RestockHCJ_a.cs" @@ -0,0 +1,80 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; +using WIDESEA_Comm; +using WIDESEA_Comm.LogInfo; +using WIDESEA_Core.BaseProvider; +using WIDESEA_Core.EFDbContext; +using WIDESEA_Entity.DomainModels; +using WIDESEA_WCS.IRepositories; +using WIDESEA_WCS.Repositories; +using WIDESEA_WCS.WCSClient; +using WIDESEA_WMS.IRepositories; +using WIDESEA_WMS.IServices; +using WIDESEA_WMS.Repositories; + +namespace WIDESEA_WCS.JobsPart.Common +{ + public class RestockHCJ_a + { + /// <summary> + /// 鏇存柊闃熷垪浠诲姟 + /// </summary> + public static void HCJGetBarcode() + { + try + { + VOLContext Context = new VOLContext(); + Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(Context); + Idt_agvtaskRepository agvtaskService = new dt_agvtaskRepository(Context); + var tasks = agvtaskService.Find(x => x.agv_taskstate == "Queue").OrderBy(x => x.agv_createtime).ToList(); + foreach (var task in tasks) + { + if (task.agv_tasktype == "TaskType_EmptyPallet")//绌烘墭浠诲姟 + { + if (task.agv_fromaddress == "") + { + var Pipeline_client = PLCClient.Clients.FirstOrDefault(t => t.PLCName == "閾炬潯鏈�"); + if (Pipeline_client == null) throw new Exception("閾炬潯鏈鸿皟搴︽湇鍔℃湭寮�鍚紒"); + if (!Pipeline_client.IsConnected) throw new Exception("涓庨摼鏉℃満杩炴帴瓒呮椂锛�"); + var area = task.agv_Traytype == "SmallTray" ? "11" : "10"; + + #region 鏌ユ壘涓�搴撳尯鐨勭┖鎵樼洏搴撲綅 + var EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 && x.stationCode.Contains("A") && x.enable).OrderBy(x => x.column).OrderBy(x => x.line).FirstOrDefault(); + if (EmptyStation == null) return; + if (EmptyStation == null) + EmptyStation = stationinfoRepository.Find(x => x.area == area && x.quantity > 0 && x.stationCode.Contains("A") && x.location_state == LocationStateEnum.Stroge.ToString() && x.enable).OrderBy(x => x.line).OrderBy(x => x.column).FirstOrDefault(); + #endregion + + } + } + 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.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; + } + } + } + } + } + catch (Exception ex) + { + WriteDBLog.Error("鏇存柊闃熷垪浠诲姟", $"閿欒淇℃伅锛歿ex.Message}", "PCS"); + } + } + } +} diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Services/WCS/Partial/VV_DispatchService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Services/WCS/Partial/VV_DispatchService.cs" index 9bc063c..0cc4927 100644 --- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Services/WCS/Partial/VV_DispatchService.cs" +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/Services/WCS/Partial/VV_DispatchService.cs" @@ -63,6 +63,8 @@ { if (!scheduler.IsRun()) { + WIDESEA.Helper.GetToken(); + var cooRes = CoonPLC(); var startRes = SrartScheduler(); if (startRes.Status) -- Gitblit v1.9.3