| using IWareCC.CacheInfo.Container; | 
| using IWareCC.ORM; | 
| using IWareCC.Properties; | 
| using IWareCC.SRM.Entity; | 
| using IWareCommon.Enum.Common; | 
| using IWareCommon.Enum.Srm; | 
| using IWareCommon.Help; | 
| using IWareCommon.Util; | 
| using System; | 
| using System.Collections.Generic; | 
| using System.Linq; | 
| using System.Text; | 
| using System.Threading; | 
| using System.Threading.Tasks; | 
|   | 
| namespace IWareCC.SRM.Handle.FinishStackerTaskAuto | 
| { | 
|     public class 等待堆垛机完成任务 : IHandler | 
|     { | 
|         /// <summary> | 
|         /// 该节点的下一个节点 | 
|         /// </summary> | 
|         private IHandler nextHandler = null; | 
|         public IHandler NextHandler | 
|         { | 
|             set { nextHandler = value; } | 
|         } | 
|         private SrmEntity Stacker; | 
|         /// <summary> | 
|         /// 任务容器 | 
|         /// </summary> | 
|         private PartTaskContainer DecompositionTaskContainer; | 
|         public 等待堆垛机完成任务(SrmEntity stacker, PartTaskContainer decompositionTaskContainer) | 
|         { | 
|             this.Stacker = stacker; | 
|             this.DecompositionTaskContainer = decompositionTaskContainer; | 
|         } | 
|         public void Handle() | 
|         { | 
|             using (var dbModel = new DbModel()) | 
|             { | 
|                 try | 
|                 { | 
|                     if (Stacker.WTaskNo != int.Parse(DecompositionTaskContainer.DecompositionTask.taskcode)) | 
|                     { | 
|                         LogTextHelper.WriteLine(Resources.LogDir + @"/完成堆垛机任务/" + Stacker.SrmName, "等待堆垛机完成任务WCSId={0},STAKERID={1}:{2}", DecompositionTaskContainer.DecompositionTask.id, Stacker.WTaskNo, "任务号不匹配"); | 
|                         string msg = String.Format("任务号不一致,发送任务号:{0},设备任务号:{1}", DecompositionTaskContainer.DecompositionTask.taskcode, Stacker.WTaskNo); | 
|                         if (DecompositionTaskContainer.DecompositionTask.filereason != msg) | 
|                         { | 
|                             DecompositionTaskContainer.DecompositionTask.filereason = msg; | 
|                             dbModel.SaveChanges(); | 
|                         } | 
|                         return; | 
|                     } | 
|                     if (!Stacker.RTaskFinish) | 
|                     { | 
|                         LogTextHelper.WriteLine(Resources.LogDir + @"/完成堆垛机任务/" + Stacker.SrmName, "等待堆垛机完成任务:{0}", "任务执行中..."); | 
|                         string msg = "任务执行中..."; | 
|                         if (DecompositionTaskContainer.DecompositionTask.filereason != msg) | 
|                         { | 
|                             DecompositionTaskContainer.DecompositionTask.filereason = msg; | 
|                             dbModel.SaveChanges(); | 
|                         } | 
|                         return; | 
|                     } | 
|                     var flag1 = Stacker.WriteValue(Stacker.OpcWriteItems.TaskFinishConfirm, (int)EYesOrNo.是); | 
|                     if (!flag1) | 
|                     { | 
|                         LogTextHelper.WriteLine(Resources.LogDir + @"/完成堆垛机任务/" + Stacker.SrmName, "等待堆垛机完成任务:{0}", "发送OPC失败"); | 
|                         return; | 
|                     } | 
|                     LogTextHelper.WriteLine(Resources.LogDir + @"/完成堆垛机任务/" + Stacker.SrmName, "等待堆垛机完成任务:{0}", "任务已完成"); | 
|                     if (nextHandler != null) | 
|                     { | 
|                         nextHandler.Handle(); | 
|                     } | 
|                 } | 
|                 catch (Exception ex) | 
|                 { | 
|                     LogTextHelper.WriteLog(Resources.LogDir, this.ToString(), "Handle", ex.Message); | 
|                 } | 
|             } | 
|         } | 
|     } | 
| } |