//任务输送到某一位置后,通知更新状态。【入库口任务到位,密集存储道穿过到位】 public override void Execute() { int[] data = null; try { string positionName = string.Empty; int taskID = 0; object state = AutomationContext.Read(memoryServiceName, memoryItemName); object obj = ObjectUtil.GetObjects(state); if (obj is Array) { Array arrayObj = (Array)obj; if (arrayObj.Length == 2) { positionName = arrayObj.GetValue(0).ToString(); taskID = Convert.ToInt32(arrayObj.GetValue(1)); } } if (positionName == string.Empty || positionName == "0" || taskID == 0) return; data = new int[] { Convert.ToInt32(positionName), taskID }; using (TransactionScopeManager TM = new TransactionScopeManager(true, IsolationLevel.Serializable)) { positionDal.TransactionScopeManager = TM; taskDal.TransactionScopeManager = TM; int positionID = positionDal.GetPositionIDByPositionName(positionName); int currentPositionID = taskDal.GetCurrentPositionID(taskID); int nextPositionID = taskDal.GetNextPositionID(taskID); int endPositionID = taskDal.GetEndPositionID(taskID); if (positionID != 0 && currentPositionID != endPositionID && positionID == nextPositionID) { positionDal.UpdateHasGoodsToTrue(positionID); taskDal.UpdateTaskPosition(taskID, positionID); taskDal.UpdateTaskPositionStateToArrived(taskID); if (positionID == endPositionID) { string orderType = taskDal.GetOrderType(taskID); if (orderType == "03")//出库单 { if (!AutomationContext.Write(memoryServiceName1, memoryItemName1, new int[] { taskID, positionID })) { AutomationContext.Write(memoryServiceName, memoryItemName, data); Logger.Error(string.Format("{0} 完成[{1}]任务失败!", Name, taskID)); return; } } else if (orderType == "04")//盘点单 { if (!AutomationContext.Write(memoryServiceName1, memoryItemName2, new int[] { taskID, positionID })) { AutomationContext.Write(memoryServiceName, memoryItemName, data); Logger.Error(string.Format("{0} 完成[{1}]任务失败!", Name, taskID)); return; } } else { if (!AutomationContext.Write(memoryServiceName, memoryItemName3, taskID)) { AutomationContext.Write(memoryServiceName, memoryItemName, data); Logger.Error(string.Format("{0} 完成[{1}]任务失败!", Name, taskID)); return; } } } TM.Commit(); } else { Logger.Error(string.Format("{0} 处理[{1}]任务到达失败,到达位置{2}与任务不符!", Name, taskID,positionName)); } } } catch (Exception ex) { if (data != null) { AutomationContext.Write(memoryServiceName, memoryItemName, data); } Logger.Error("TaskArriveDataProcess 出错,原因:" + ex.Message + "/n" + ex.StackTrace); } }
private void FinishTask() { try { if (CurrentTask != null) { using (TransactionScopeManager TM = new TransactionScopeManager(true, IsolationLevel.Serializable)) { TaskDal taskDal = new TaskDal(); PositionDal positionDal = new PositionDal(); taskDal.TransactionScopeManager = TM; positionDal.TransactionScopeManager = TM; positionDal.UpdateHasGoodsToFalse(CurrentTask.CurrentPositionID); positionDal.UpdateHasGoodsToTrue(CurrentTask.NextPositionID); taskDal.UpdateTaskPosition(CurrentTask.ID, CurrentTask.NextPositionID); taskDal.UpdateTaskPositionStateToArrived(CurrentTask.ID); taskDal.UpdateTaskStateToWaiting(CurrentTask.ID); if (CurrentTask.NextPositionID == CurrentTask.EndPositionID && (CurrentTask.TaskType == "03" || CurrentTask.EndPositionType != "03") && (CurrentTask.TaskType == "03" || CurrentTask.EndPositionType != "04"))//小品种,异型烟,由手持PDA完成; { if (CurrentTask.TaskType == "02") { string orderType = taskDal.GetOrderType(CurrentTask.ID); string orderID = taskDal.GetOrderID(CurrentTask.ID); int allotID = taskDal.GetAllotID(CurrentTask.ID); string originCellCode = taskDal.GetOriginCellCode(CurrentTask.ID); string targetCellCode = taskDal.GetTargetCellCode(CurrentTask.ID); string originStorageCode = taskDal.GetOriginStorageCode(CurrentTask.ID); string targetStorageCode = taskDal.GetTargetStorageCode(CurrentTask.ID); RestClient rest = new RestClient(); if (!rest.FinishTask(CurrentTask.ID, orderType, orderID, allotID,originCellCode,targetCellCode, originStorageCode, targetStorageCode)) { Logger.Error(string.Format("{0} 完成[{1}]任务失败!", Name, CurrentTask.ID)); return; } else { taskDal.UpdateTaskStateToExecuted(CurrentTask.ID); } } else { if (!Ops.Write(memoryServiceName, memoryItemName, CurrentTask.ID)) { Logger.Error(string.Format("{0} 完成[{1}]任务失败!", Name, CurrentTask.ID)); return; } } } TM.Commit(); CurrentTask = null; CurrentTaskFactory = null; } } } catch (Exception ex) { Logger.Error("SRM.FinishTask 出错,原因:" + ex.Message + "/n" + ex.StackTrace); } }
//任务输送到某一位置后,通知更新状态。【入库口任务到位,密集存储道穿过到位】 public override void Execute() { int[] data = null; try { string positionName = string.Empty; int taskID = 0; object state = AutomationContext.Read(memoryServiceName, memoryItemName); object obj = ObjectUtil.GetObjects(state); if (obj is Array) { Array arrayObj = (Array)obj; if (arrayObj.Length == 2) { positionName = arrayObj.GetValue(0).ToString(); taskID = Convert.ToInt32(arrayObj.GetValue(1)); } } if (positionName == string.Empty || positionName == "0" || taskID == 0) { return; } data = new int[] { Convert.ToInt32(positionName), taskID }; using (TransactionScopeManager TM = new TransactionScopeManager(true, IsolationLevel.Serializable)) { positionDal.TransactionScopeManager = TM; taskDal.TransactionScopeManager = TM; int positionID = positionDal.GetPositionIDByPositionName(positionName); int currentPositionID = taskDal.GetCurrentPositionID(taskID); int nextPositionID = taskDal.GetNextPositionID(taskID); int endPositionID = taskDal.GetEndPositionID(taskID); if (positionID != 0 && currentPositionID != endPositionID && positionID == nextPositionID) { positionDal.UpdateHasGoodsToTrue(positionID); taskDal.UpdateTaskPosition(taskID, positionID); taskDal.UpdateTaskPositionStateToArrived(taskID); if (positionID == endPositionID) { string orderType = taskDal.GetOrderType(taskID); if (orderType == "03")//出库单 { if (!AutomationContext.Write(memoryServiceName1, memoryItemName1, new int[] { taskID, positionID })) { AutomationContext.Write(memoryServiceName, memoryItemName, data); Logger.Error(string.Format("{0} 完成[{1}]任务失败!", Name, taskID)); return; } } else if (orderType == "04")//盘点单 { if (!AutomationContext.Write(memoryServiceName1, memoryItemName2, new int[] { taskID, positionID })) { AutomationContext.Write(memoryServiceName, memoryItemName, data); Logger.Error(string.Format("{0} 完成[{1}]任务失败!", Name, taskID)); return; } } else { if (!AutomationContext.Write(memoryServiceName, memoryItemName3, taskID)) { AutomationContext.Write(memoryServiceName, memoryItemName, data); Logger.Error(string.Format("{0} 完成[{1}]任务失败!", Name, taskID)); return; } } } TM.Commit(); } else { Logger.Error(string.Format("{0} 处理[{1}]任务到达失败,到达位置{2}与任务不符!", Name, taskID, positionName)); } } } catch (Exception ex) { if (data != null) { AutomationContext.Write(memoryServiceName, memoryItemName, data); } Logger.Error("TaskArriveDataProcess 出错,原因:" + ex.Message + "/n" + ex.StackTrace); } }
public override void Execute() { try { int productID = 0, quantity = 0; object state = AutomationContext.Read(memoryServiceName, memoryItemName); object obj = ObjectUtil.GetObjects(state); if (obj is Array) { Array arrayObj = (Array)obj; if (arrayObj.Length == 2) { productID = Convert.ToInt32(arrayObj.GetValue(0)); quantity = Convert.ToInt32(arrayObj.GetValue(1)); } } if (productID == 0 || quantity == 0) return; state = AutomationContext.Read(plcServiceName, I_Whole_Pallet_StockIn_Scan_Request); state = ObjectUtil.GetObject(state); if (state == null || !Convert.ToBoolean(state)) return; if (!ScanManagerView.InitCigaretteScanInfoStack()) return; var scanInfo = CigaretteScanInfoStack .Where(c => c.Value.ProductNo == productID && c.Value.State == "0") .Select(c=> c.Value) .FirstOrDefault(); if (scanInfo == null) { Logger.Info("当前整托盘入库品牌已经由件烟扫码开始进行扫码或没有扫码任务!"); return; } using (TransactionScopeManager TM = new TransactionScopeManager(true, IsolationLevel.Serializable)) { taskDal.TransactionScopeManager = TM; int taskID = taskDal.GetTask(productID, quantity); if (taskID != 0) { string positionName = taskDal.GetTaskNextPosition(taskID); if (positionName != string.Empty) { int[] data = new int[] { taskID, Convert.ToInt32(positionName), 1 }; AutomationContext.Write(plcServiceName, O_Whole_Pallet_StockIn_Task_Info, data); Thread.Sleep(sleepTime); obj = AutomationContext.Read(plcServiceName, I_Whole_Pallet_StockIn_Task_Info); obj = ObjectUtil.GetObjects(obj); if (obj is Array) { Array arrayObj = (Array)obj; if (arrayObj.Length == 3 && data[0] == Convert.ToInt32(arrayObj.GetValue(0)) && data[1] == Convert.ToInt32(arrayObj.GetValue(1)) && data[2] == Convert.ToInt32(arrayObj.GetValue(2))) { //更新任务状态为,到达当前位置; taskDal.UpdateTaskPositionStateToArrived(taskID); AutomationContext.Write(plcServiceName, O_Whole_Pallet_StockIn_Task_Info_Complete, 1); TM.Commit(); scanInfo.ScanQuantity += quantity; AutomationContext.Write(memoryServiceName1, memoryItemName1, CigaretteScanInfoStack); Logger.Info(string.Format("任务号[{0}]整托盘入库成功!",taskID)); return; } } } } Logger.Info(string.Format("整托盘入库失败,简码:[{0}],数量: [{0}]", productID, quantity)); } } catch (Exception ex) { Logger.Error("WholePalletTaskRequestProcess 出错,原因:" + ex.Message + "/n" + ex.StackTrace); } }
//码垛完成后申请分配入库任务; public override void Execute() { try { int productID = 0, quantity = 0, taskID = 0; object state = AutomationContext.Read(plcServiceName, I_StockIn_Task_Info_Request); object obj = ObjectUtil.GetObjects(state); if (obj is Array) { Array arrayObj = (Array)obj; if (arrayObj.Length == 2) { productID = Convert.ToInt32(arrayObj.GetValue(0)); quantity = Convert.ToInt32(arrayObj.GetValue(1)); } } if (productID == 0 || quantity == 0) { return; } int[] data = new int[] { productID, quantity }; string msg = "TaskRequest : "; for (int i = 0; i < data.Length; i++) msg += string.Format("[{0}]", data[i]); Logger.Info(msg); using (TransactionScopeManager TM = new TransactionScopeManager(true, IsolationLevel.Serializable)) { taskDal.TransactionScopeManager = TM; taskID = taskDal.GetTask(productID, quantity); if (taskID != 0) { string positionName = taskDal.GetTaskNextPosition(taskID); if (positionName != string.Empty) { data = new int[] { taskID, Convert.ToInt32(positionName), 1 }; AutomationContext.Write(plcServiceName, O_StockIn_Task_Info, data); Thread.Sleep(sleepTime); obj = AutomationContext.Read(plcServiceName, I_StockIn_Task_Info); obj = ObjectUtil.GetObjects(obj); if (obj is Array) { Array arrayObj = (Array)obj; if (arrayObj.Length == 3 && data[0] == Convert.ToInt32(arrayObj.GetValue(0)) && data[1] == Convert.ToInt32(arrayObj.GetValue(1)) && data[2] == Convert.ToInt32(arrayObj.GetValue(2))) { //更新任务状态为,到达当前位置; taskDal.UpdateTaskPositionStateToArrived(taskID); AutomationContext.Write(plcServiceName, O_StockIn_Task_Info_Complete, 1); TM.Commit(); } } } } } } catch (Exception ex) { Logger.Error("TaskRequestProcess 出错,原因:" + ex.Message + "/n" + ex.StackTrace); } }
private void FinishTask() { try { if (CurrentTask != null) { using (TransactionScopeManager TM = new TransactionScopeManager(true, IsolationLevel.Serializable)) { TaskDal taskDal = new TaskDal(); PositionDal positionDal = new PositionDal(); taskDal.TransactionScopeManager = TM; positionDal.TransactionScopeManager = TM; positionDal.UpdateHasGoodsToFalse(CurrentTask.CurrentPositionID); positionDal.UpdateHasGoodsToTrue(CurrentTask.NextPositionID); taskDal.UpdateTaskPosition(CurrentTask.ID, CurrentTask.NextPositionID); taskDal.UpdateTaskPositionStateToArrived(CurrentTask.ID); taskDal.UpdateTaskStateToWaiting(CurrentTask.ID); if (CurrentTask.NextPositionID == CurrentTask.EndPositionID && (CurrentTask.TaskType == "03" || CurrentTask.EndPositionType != "03") && (CurrentTask.TaskType == "03" || CurrentTask.EndPositionType != "04")) //小品种,异型烟,由手持PDA完成; { if (CurrentTask.TaskType == "02") { string orderType = taskDal.GetOrderType(CurrentTask.ID); string orderID = taskDal.GetOrderID(CurrentTask.ID); int allotID = taskDal.GetAllotID(CurrentTask.ID); string originCellCode = taskDal.GetOriginCellCode(CurrentTask.ID); string targetCellCode = taskDal.GetTargetCellCode(CurrentTask.ID); string originStorageCode = taskDal.GetOriginStorageCode(CurrentTask.ID); string targetStorageCode = taskDal.GetTargetStorageCode(CurrentTask.ID); RestClient rest = new RestClient(); if (!rest.FinishTask(CurrentTask.ID, orderType, orderID, allotID, originCellCode, targetCellCode, originStorageCode, targetStorageCode)) { Logger.Error(string.Format("{0} 完成[{1}]任务失败!", Name, CurrentTask.ID)); return; } else { taskDal.UpdateTaskStateToExecuted(CurrentTask.ID); } } else { if (!Ops.Write(memoryServiceName, memoryItemName, CurrentTask.ID)) { Logger.Error(string.Format("{0} 完成[{1}]任务失败!", Name, CurrentTask.ID)); return; } } } TM.Commit(); CurrentTask = null; CurrentTaskFactory = null; } } } catch (Exception ex) { Logger.Error("SRM.FinishTask 出错,原因:" + ex.Message + "/n" + ex.StackTrace); } }
//码垛完成后申请分配入库任务; public override void Execute() { try { int productID = 0, quantity = 0, taskID = 0; object state = AutomationContext.Read(plcServiceName, I_StockIn_Task_Info_Request); object obj = ObjectUtil.GetObjects(state); if (obj is Array) { Array arrayObj = (Array)obj; if (arrayObj.Length == 2) { productID = Convert.ToInt32(arrayObj.GetValue(0)); quantity = Convert.ToInt32(arrayObj.GetValue(1)); } } if (productID == 0 || quantity == 0) { return; } int[] data = new int[] { productID, quantity }; string msg = "TaskRequest : "; for (int i = 0; i < data.Length; i++) { msg += string.Format("[{0}]", data[i]); } Logger.Info(msg); using (TransactionScopeManager TM = new TransactionScopeManager(true, IsolationLevel.Serializable)) { taskDal.TransactionScopeManager = TM; taskID = taskDal.GetTask(productID, quantity); if (taskID != 0) { string positionName = taskDal.GetTaskNextPosition(taskID); if (positionName != string.Empty) { data = new int[] { taskID, Convert.ToInt32(positionName), 1 }; AutomationContext.Write(plcServiceName, O_StockIn_Task_Info, data); Thread.Sleep(sleepTime); obj = AutomationContext.Read(plcServiceName, I_StockIn_Task_Info); obj = ObjectUtil.GetObjects(obj); if (obj is Array) { Array arrayObj = (Array)obj; if (arrayObj.Length == 3 && data[0] == Convert.ToInt32(arrayObj.GetValue(0)) && data[1] == Convert.ToInt32(arrayObj.GetValue(1)) && data[2] == Convert.ToInt32(arrayObj.GetValue(2))) { //更新任务状态为,到达当前位置; taskDal.UpdateTaskPositionStateToArrived(taskID); AutomationContext.Write(plcServiceName, O_StockIn_Task_Info_Complete, 1); TM.Commit(); } } } } } } catch (Exception ex) { Logger.Error("TaskRequestProcess 出错,原因:" + ex.Message + "/n" + ex.StackTrace); } }
public override void Execute() { try { int productID = 0, quantity = 0; object state = AutomationContext.Read(memoryServiceName, memoryItemName); object obj = ObjectUtil.GetObjects(state); if (obj is Array) { Array arrayObj = (Array)obj; if (arrayObj.Length == 2) { productID = Convert.ToInt32(arrayObj.GetValue(0)); quantity = Convert.ToInt32(arrayObj.GetValue(1)); } } if (productID == 0 || quantity == 0) { return; } state = AutomationContext.Read(plcServiceName, I_Whole_Pallet_StockIn_Scan_Request); state = ObjectUtil.GetObject(state); if (state == null || !Convert.ToBoolean(state)) { return; } if (!ScanManagerView.InitCigaretteScanInfoStack()) { return; } var scanInfo = CigaretteScanInfoStack .Where(c => c.Value.ProductNo == productID && c.Value.State == "0") .Select(c => c.Value) .FirstOrDefault(); if (scanInfo == null) { Logger.Info("当前整托盘入库品牌已经由件烟扫码开始进行扫码或没有扫码任务!"); return; } using (TransactionScopeManager TM = new TransactionScopeManager(true, IsolationLevel.Serializable)) { taskDal.TransactionScopeManager = TM; int taskID = taskDal.GetTask(productID, quantity); if (taskID != 0) { string positionName = taskDal.GetTaskNextPosition(taskID); if (positionName != string.Empty) { int[] data = new int[] { taskID, Convert.ToInt32(positionName), 1 }; AutomationContext.Write(plcServiceName, O_Whole_Pallet_StockIn_Task_Info, data); Thread.Sleep(sleepTime); obj = AutomationContext.Read(plcServiceName, I_Whole_Pallet_StockIn_Task_Info); obj = ObjectUtil.GetObjects(obj); if (obj is Array) { Array arrayObj = (Array)obj; if (arrayObj.Length == 3 && data[0] == Convert.ToInt32(arrayObj.GetValue(0)) && data[1] == Convert.ToInt32(arrayObj.GetValue(1)) && data[2] == Convert.ToInt32(arrayObj.GetValue(2))) { //更新任务状态为,到达当前位置; taskDal.UpdateTaskPositionStateToArrived(taskID); AutomationContext.Write(plcServiceName, O_Whole_Pallet_StockIn_Task_Info_Complete, 1); TM.Commit(); scanInfo.ScanQuantity += quantity; AutomationContext.Write(memoryServiceName1, memoryItemName1, CigaretteScanInfoStack); Logger.Info(string.Format("任务号[{0}]整托盘入库成功!", taskID)); return; } } } } Logger.Info(string.Format("整托盘入库失败,简码:[{0}],数量: [{0}]", productID, quantity)); } } catch (Exception ex) { Logger.Error("WholePalletTaskRequestProcess 出错,原因:" + ex.Message + "/n" + ex.StackTrace); } }