diff --git a/.gitignore b/.gitignore index 9491a2f..09aaef2 100644 --- a/.gitignore +++ b/.gitignore @@ -360,4 +360,5 @@ MigrationBackup/ .ionide/ # Fody - auto-generated XML schema -FodyWeavers.xsd \ No newline at end of file +FodyWeavers.xsd +.DS_Store \ No newline at end of file diff --git a/WCS_YongFeng_CP/App.config b/WCS_YongFeng_CP/App.config index eb7e7a3..12200f2 100644 --- a/WCS_YongFeng_CP/App.config +++ b/WCS_YongFeng_CP/App.config @@ -1,7 +1,7 @@  - + - + + diff --git a/WCS_YongFeng_CP/Page/HandView/HandTask.xaml.cs b/WCS_YongFeng_CP/Page/HandView/HandTask.xaml.cs index e308ef6..daa79db 100644 --- a/WCS_YongFeng_CP/Page/HandView/HandTask.xaml.cs +++ b/WCS_YongFeng_CP/Page/HandView/HandTask.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows; +using System.Linq; +using System.Windows; namespace WCS_YongFeng { @@ -25,29 +26,63 @@ namespace WCS_YongFeng /// private void Button_Click(object sender, RoutedEventArgs e) { - var fromplace = from.Text.Trim().ToString(); - var toplace = to.Text.Trim().ToString(); + var fromloc = from.Text.Trim().ToString(); + var toloc = to.Text.Trim().ToString(); var pall = pallet.Text.Trim().ToString(); string type = ""; - if (string.IsNullOrWhiteSpace(fromplace) && !string.IsNullOrWhiteSpace(toplace)) + //if (string.IsNullOrWhiteSpace(fromplace) && !string.IsNullOrWhiteSpace(toplace)) + //{ + // fromplace = "EntranceStationA01"; + // type = E_TaskType.入库.GetIndexString(); + //} + //else if (!string.IsNullOrWhiteSpace(fromplace) && string.IsNullOrWhiteSpace(toplace)) + //{ + // toplace = "ExitStationA01"; + // type = E_TaskType.出库.GetIndexString(); + //} + //else + //{ + // MessageBox.Show("起点终点不允许都为空!"); + // return; + //} + + var fromplace = App.poseList.FirstOrDefault(x => x.wcName == fromloc); + var toplace = App.poseList.FirstOrDefault(x => x.wcName == toloc); + + + if (fromplace != null && toplace != null && fromplace.wcType == "Entrance" && toplace.wcType == "WareCell") { - fromplace = "EntranceStationA01"; type = E_TaskType.入库.GetIndexString(); } - else if (!string.IsNullOrWhiteSpace(fromplace) && string.IsNullOrWhiteSpace(toplace)) + else if (fromplace != null && toplace != null && fromplace.wcType == "EntranceExit" && toplace.wcType == "WareCell") + { + type = E_TaskType.入库1.GetIndexString(); + } + else if (fromplace != null && toplace != null && toplace.wcType == "Exit" && fromplace.wcType == "WareCell") { - toplace = "ExitStationA01"; type = E_TaskType.出库.GetIndexString(); } + else if (fromplace != null && toplace != null && toplace.wcType == "EntranceExit" && fromplace.wcType == "WareCell") + { + type = E_TaskType.出库1.GetIndexString(); + } + else if (fromplace != null && toplace != null && toplace.wcType == "WareCell" && fromplace.wcType == "WareCell") + { + type = E_TaskType.移库.GetIndexString(); + } + else if (fromplace == null && toplace != null && toplace.wcType == "WareCell") + { + fromplace = App.poseList.FirstOrDefault(x => x.wcName == "Enter_0000"); + type = E_TaskType.入库.GetIndexString(); + } else { MessageBox.Show("起点终点不允许都为空!"); return; } - - BllResult result = baseBll.CreateTask("", type, pall, fromplace, toplace, "WCS手动"); + BllResult result = baseBll.CreateTask("", type, pall, fromloc, toloc, "WCS手动"); if (result.Success) { MessageBox.Show($"手动下发任务成功,任务号:{result.Data.tNo}"); diff --git a/WCS_YongFeng_CP/Page/SrmView.xaml b/WCS_YongFeng_CP/Page/SrmView.xaml index ef3884c..77d936e 100644 --- a/WCS_YongFeng_CP/Page/SrmView.xaml +++ b/WCS_YongFeng_CP/Page/SrmView.xaml @@ -40,7 +40,7 @@ - + diff --git a/WCS_YongFeng_CP/Service/Comm/BaseBll.cs b/WCS_YongFeng_CP/Service/Comm/BaseBll.cs index 54543f3..07ea0c2 100644 --- a/WCS_YongFeng_CP/Service/Comm/BaseBll.cs +++ b/WCS_YongFeng_CP/Service/Comm/BaseBll.cs @@ -526,6 +526,49 @@ namespace WCS_YongFeng #endregion + #region 取货错处理 + /// + /// 取货错处理 + /// + /// + /// + public BllResult PickErrorExcute(string taskno) + { + var task = App.taskList.FirstOrDefault(a => a.tNo == taskno); + if (!string.IsNullOrWhiteSpace(task.tNo_WMS)) + { + ReqTaskFinish reqEmptyOut = new ReqTaskFinish() { TaskNo = task.tNo_WMS, State = 0 }; + var apiResult = WcsWebApiClient.PickErrorHandle(reqEmptyOut); + if (apiResult.Success) + { + var delResult = TaskDelete(taskno); + if (delResult.Success) + { + LogExecute.logNet.WriteDebug($"取货错处理成功,任务信息{taskno}已恢复"); + return BllResult.Sucess($"取货错处理成功,任务信息{taskno}已恢复"); + } + else + { + LogExecute.logNet.WriteError($"取货错处理失败,WCS任务恢复失败,错误原因是{delResult.Msg}"); + return BllResult.Error($"取货错处理失败,WCS任务恢复失败,错误原因是{delResult.Msg}"); + } + } + else + { + LogExecute.logNet.WriteError($"请求WMS接口取货错失败,任务号是{taskno},错误原因是{apiResult.Msg}"); + return BllResult.Error($"请求WMS接口取货错失败,任务号是{taskno},错误原因是{apiResult.Msg}"); + } + } + else + { + LogExecute.logNet.WriteError($"请求WMS接口取货错失败,WMS无此任务"); + return BllResult.Error($"请求WMS接口取货错失败,WMS无此任务"); + } + + } + + + #endregion #region 到达操作任务回传处理 /// diff --git a/WCS_YongFeng_CP/Service/Comm/LogExecute.cs b/WCS_YongFeng_CP/Service/Comm/LogExecute.cs index 8dd1044..293b2da 100644 --- a/WCS_YongFeng_CP/Service/Comm/LogExecute.cs +++ b/WCS_YongFeng_CP/Service/Comm/LogExecute.cs @@ -4,11 +4,11 @@ namespace WCS_YongFeng { public class LogExecute { - public static ILogNet logNet = new LogNetDateTime("D:\\Log\\Logs", GenerateMode.ByEveryDay); - public static ILogNet SrmlogNet = new LogNetDateTime("D:\\Log\\SrmLogs", GenerateMode.ByEveryDay); - public static ILogNet ApilogNet = new LogNetDateTime("D:\\Log\\Apilogs", GenerateMode.ByEveryDay); - public static ILogNet TibcologNet = new LogNetDateTime("D:\\Log\\Tibcologs", GenerateMode.ByEveryDay); - public static ILogNet AutoChecklogNet = new LogNetDateTime("D:\\Log\\AutoChecklogs", GenerateMode.ByEveryDay); + public static ILogNet logNet = new LogNetDateTime("C:\\Log\\Logs", GenerateMode.ByEveryDay); + public static ILogNet SrmlogNet = new LogNetDateTime("C:\\Log\\SrmLogs", GenerateMode.ByEveryDay); + public static ILogNet ApilogNet = new LogNetDateTime("C:\\Log\\Apilogs", GenerateMode.ByEveryDay); + public static ILogNet TibcologNet = new LogNetDateTime("C:\\Log\\Tibcologs", GenerateMode.ByEveryDay); + public static ILogNet AutoChecklogNet = new LogNetDateTime("C:\\Log\\AutoChecklogs", GenerateMode.ByEveryDay); public static HslCommunication.BasicFramework.SoftNumericalOrder softNumericalOrder = new HslCommunication.BasicFramework.SoftNumericalOrder("", "yyyyMMdd", 4, @"\numericalOrder.txt"); public LogExecute() diff --git a/WCS_YongFeng_CP/Service/DevicesExcute/Interface/I_Excute_S.cs b/WCS_YongFeng_CP/Service/DevicesExcute/Interface/I_Excute_S.cs index 91fd315..2772afa 100644 --- a/WCS_YongFeng_CP/Service/DevicesExcute/Interface/I_Excute_S.cs +++ b/WCS_YongFeng_CP/Service/DevicesExcute/Interface/I_Excute_S.cs @@ -28,7 +28,7 @@ public abstract BllResult DeleteTask(); - //public abstract BllResult PickErrorExcute(); + public abstract BllResult PickErrorExcute(); //public abstract BllResult PutErrorExcute(); diff --git a/WCS_YongFeng_CP/Service/DevicesExcute/SingleSrmExcute.cs b/WCS_YongFeng_CP/Service/DevicesExcute/SingleSrmExcute.cs index 94505e5..bb86fda 100644 --- a/WCS_YongFeng_CP/Service/DevicesExcute/SingleSrmExcute.cs +++ b/WCS_YongFeng_CP/Service/DevicesExcute/SingleSrmExcute.cs @@ -109,7 +109,23 @@ namespace WCS_YongFeng List TAllTask = AllTask.FindAll(a => a.NextState == E_TaskState.堆垛机取货.GetIndexInt()).OrderBy(a => a.tNo).ToList(); if (TAllTask.Count != 0 && TAllTask != null) { - var sendResult = SendTask(TAllTask[0]); + var sendTask = TAllTask[0]; + + var loc = App.poseList.First(x => x.wcName == TAllTask[0].EntrancePlace); + if (loc.Zpose == 2 || loc.Zpose == 4) + { + // 找外侧仓位 + var outLoc = App.poseList.FirstOrDefault(x => + x.Xpose == loc.Xpose + && x.Ypose == loc.Ypose + && loc.Zpose - x.Zpose == 1); + var moveTask = AllTask.Find(x => x.EntrancePlace == outLoc?.wcName); + if (moveTask != null) + { + sendTask = moveTask; + } + } + var sendResult = SendTask(sendTask); if (sendResult.Success) { LogExecute.logNet.WriteDebug($"{device.Name}任务下发成功,任务号{TAllTask[0].tNo}"); @@ -664,6 +680,49 @@ namespace WCS_YongFeng } } + /// + /// 取货错处理 + /// + /// + public override BllResult PickErrorExcute() + { + if (vM_SrmRead.Fork1_PickError && vM_SrmRead.SRM_Mode == E_SrmMode.联机.GetIndexInt() && vM_SrmRead.Fork1_State == E_SrmForkState.任务中断.GetIndexInt()) + { + var tasks = App.taskList.ToList().FindAll(a => a.PalletOrBoxNo == vM_SrmWrite.Fork1_Code); + if (tasks.Count != 1) + { + //多条任务 + LogExecute.logNet.WriteError($"{vM_SrmRead.Name},找到多条空出托盘号{vM_SrmWrite.Fork1_Code}对应的任务"); + return BllResult.Error($"{vM_SrmRead.Name},找到多条空出托盘号{vM_SrmWrite.Fork1_Code}对应的任务"); + } + else + { + var emptyoutresult = _bll.PickErrorExcute(tasks[0].tNo); + if (!emptyoutresult.Success) + { + LogExecute.logNet.WriteError($"{vM_SrmRead.Name}取货错处理失败,错误原因是:{emptyoutresult.Msg}。"); + return BllResult.Error($"{vM_SrmRead.Name}取货错处理失败,错误原因是:{emptyoutresult.Msg}。"); + } + } + // 恢复当前任务到初始状态 todo + var deleteresult = DeleteTask(); + if (deleteresult.Success) + { + LogExecute.logNet.WriteDebug($"{vM_SrmRead.Name}取货错处理成功"); + return BllResult.Sucess($"{vM_SrmRead.Name},取货错处理成功"); + } + else + { + LogExecute.logNet.WriteError($"{vM_SrmRead.Name},取货错删除堆垛机任务失败,请重试,错误原因{deleteresult.Msg}."); + return BllResult.Error($"{vM_SrmRead.Name},取货错删除堆垛机任务失败,请重试,错误原因{deleteresult.Msg}."); + } + } + else + { + LogExecute.logNet.WriteError($"{vM_SrmRead.Name}取货错处理,未存在取货错错误或未出于联机状态"); + return BllResult.Error($"{vM_SrmRead.Name}取货错处理,未存在取货错错误或未出于联机状态"); + } + } #endregion 特殊故障处理 /// diff --git a/WCS_YongFeng_CP/Service/DevicesExcute/StationDRExcute.cs b/WCS_YongFeng_CP/Service/DevicesExcute/StationDRExcute.cs index 9c9101c..69c1dc1 100644 --- a/WCS_YongFeng_CP/Service/DevicesExcute/StationDRExcute.cs +++ b/WCS_YongFeng_CP/Service/DevicesExcute/StationDRExcute.cs @@ -60,35 +60,6 @@ namespace WCS_YongFeng vM_StationDACK.PalletID = vM_StationDR.PalletID; vM_StationDACK.DeStation = device.ToPoint; - if (taskresur.ExitPlace == "WareCell") - { - ReqTaskFinish reqTaskFinish = new ReqTaskFinish() - { - TaskNo = taskresur.tNo_WMS, - State = 10, - Height = vM_StationDR.Height - }; - - //var interfaceresult = WcsWebApiClient.FinishTask(reqTaskFinish); - //if (!interfaceresult.Success) - //{ - // LogExecute.logNet.WriteError($"请求仓位时调用WMS接口失败,任务号{taskresur.tNo},高度{vM_StationDR.Height},错误原因{interfaceresult.Msg}"); - // return BllResult.Error(); ; - //} - BaseDal _baseDal = new BaseDal(); - Dictionary lstColumnValues = new Dictionary(); - //lstColumnValues.Add("ExitPlace", interfaceresult.Data.LocationCode); - lstColumnValues.Add("ExitPlace", "L-01-04-03-01"); - var updatewarecell = _baseDal.Update(lstColumnValues, a => a.tNo == taskresur.tNo); - if (!updatewarecell.Success) - { - LogExecute.logNet.WriteError($"请求仓位时更新数据库失败,任务号{taskresur.tNo},高度{vM_StationDR.Height},错误原因{updatewarecell.Msg}"); - return BllResult.Error(); ; - } - //taskresur.ExitPlace = interfaceresult.Data.LocationCode; - taskresur.ExitPlace = "L-01-04-03-01"; - } - var pose = App.poseList.FirstOrDefault(a => a.Station == device.Point); if (pose == null) { @@ -96,6 +67,56 @@ namespace WCS_YongFeng return BllResult.Sucess(); } + if (taskresur.ExitPlace == "WareCell") + { + ReqTaskFinish reqTaskFinish = new ReqTaskFinish() + { + TaskNo = taskresur.tNo_WMS, + State = 10, + Height = vM_StationDR.Height, + InPort = pose.wcName + }; + + var interfaceresult = WcsWebApiClient.FinishTask(reqTaskFinish); + if (!interfaceresult.Success) + { + LogExecute.logNet.WriteError($"请求仓位时调用WMS接口失败,任务号{taskresur.tNo},高度{vM_StationDR.Height},入库口{reqTaskFinish.InPort},错误原因{interfaceresult.Msg}"); + vM_StationDACK.MessageID = 6; + vM_StationDACK.LoadingStatus = 1; + vM_StationDACK.ScannerNr = vM_StationDR.ScannerNr; + vM_StationDACK.PalletID = vM_StationDR.PalletID; + vM_StationDACK.DeStation = device.BackPoint; + var sendtask_send = this.PutWriteAddress(); + if (sendtask_send.Success) + { + LogExecute.logNet.WriteDebug($"响应{device.Name}站台地址回退成功,托盘号{vM_StationDR.PalletID} ,目的地{vM_StationDACK.DeStation}"); + return BllResult.Sucess(); + } + + return BllResult.Sucess(); + //return BllResult.Error(); ; + } + BaseDal _baseDal = new BaseDal(); + Dictionary lstColumnValues = new Dictionary(); + lstColumnValues.Add("ExitPlace", interfaceresult.Data.LocationCode); + //lstColumnValues.Add("ExitPlace", "L-01-04-03-01"); + var updatewarecell = _baseDal.Update(lstColumnValues, a => a.tNo == taskresur.tNo); + if (!updatewarecell.Success) + { + LogExecute.logNet.WriteError($"请求仓位时更新数据库失败,任务号{taskresur.tNo},高度{vM_StationDR.Height},错误原因{updatewarecell.Msg}"); + return BllResult.Error(); ; + } + taskresur.ExitPlace = interfaceresult.Data.LocationCode; + //taskresur.ExitPlace = "L-01-04-03-01"; + } + + //var pose = App.poseList.FirstOrDefault(a => a.Station == device.Point); + //if (pose == null) + //{ + // LogExecute.logNet.WriteError($"响应{device.Name}站台地址请求失败,未找站台对应的坐标"); + // return BllResult.Sucess(); + //} + BaseDal baseDal = new BaseDal(); baseDal.BeginTran(); diff --git a/WCS_YongFeng_CP/Service/WebService/Client/WcsWebApiClient.cs b/WCS_YongFeng_CP/Service/WebService/Client/WcsWebApiClient.cs index 231d557..054f686 100644 --- a/WCS_YongFeng_CP/Service/WebService/Client/WcsWebApiClient.cs +++ b/WCS_YongFeng_CP/Service/WebService/Client/WcsWebApiClient.cs @@ -116,5 +116,15 @@ namespace WCS_YongFeng { return FormPost(reqEmptyOut, "/EmptyOut"); } + + /// + /// 取货错 + /// + /// + /// < returns > + public static BllResult PickErrorHandle(ReqTaskFinish reqEmptyOut) + { + return FormPost(reqEmptyOut, "/PickError"); + } } } \ No newline at end of file