using iWareCc.DecomposeTask.Entity;
|
using iWareCcTest.Properties;
|
using iWareCc.Srm.Entity;
|
using iWareCommon.Common.Entity;
|
using iWareCommon.Common.EnumType;
|
using iWareCommon.Utils;
|
using iWareDataCore.ORM;
|
using iWareDataCore.TASK.Entity;
|
using iWareDataCore.TASK.EnumType;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace iWareCc.FinishStackerTask.Chain
|
{
|
public class 获取当前的堆垛机任务 : IHandler
|
{
|
/// <summary>
|
/// 该节点的下一个节点
|
/// </summary>
|
private IHandler nextHandler = null;
|
public IHandler NextHandler
|
{
|
set { nextHandler = value; }
|
}
|
|
private StackerEntity Stacker;
|
|
/// <summary>
|
/// 任务容器
|
/// </summary>
|
private PartTaskContainer DecompositionTaskContainer;
|
|
|
public 获取当前的堆垛机任务(StackerEntity stacker, PartTaskContainer decompositionTaskContainer)
|
{
|
this.Stacker = stacker;
|
this.DecompositionTaskContainer = decompositionTaskContainer;
|
}
|
|
|
public void Handle()
|
{
|
using (var dbModel = new DbModelCore())
|
{
|
try
|
{
|
var task = dbModel.TASKPartTasks.OrderBy(x => x.finishtimes).FirstOrDefault(x => x.iscurrent == (int)EYesOrNo.是 && x.isreleased == (int)EYesOrNo.是 && x.isfinished == (int)EYesOrNo.否 && x.type == (int)EPartTaskType.堆垛机任务 && x.equipid == Stacker.Equipment.Id);
|
|
if (task == null)
|
{
|
LogTextHelper.WriteLine(Resources.LogDir + @"/完成堆垛机任务/" + Stacker.Equipment.EquipName, "获取当前的堆垛机任务:{0}", "没有找到待完成的任务");
|
return;
|
}
|
|
|
task.finishtimes += 1;
|
|
dbModel.SaveChanges();
|
|
DecompositionTaskContainer.PartTask = new PartTaskEntity(task);
|
LogTextHelper.WriteLine(Resources.LogDir + @"/完成堆垛机任务/" + Stacker.Equipment.EquipName, "获取当前的堆垛机任务:{0}", DecompositionTaskContainer.PartTask.Id);
|
|
if (nextHandler != null)
|
{
|
nextHandler.Handle();
|
}
|
|
}
|
catch (Exception ex)
|
{
|
LogTextHelper.WriteLog(Resources.LogDir, this.ToString(), "Handle", ex.Message);
|
}
|
}
|
}
|
}
|
}
|