using iWareCc.Cache.Entity;
|
using iWareCc.DecomposeTask.Entity;
|
using iWareCc.Properties;
|
using iWareCommon.Common.Entity;
|
using iWareCommon.Common.EnumType;
|
using iWareCommon.Utils;
|
using iWareDataCore.DEV.EnumType;
|
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.DecomposeTask.Strategy.出库任务.Chain
|
{
|
public class 生成堆垛机任务 : IHandler
|
{
|
private MainTaskContainer LogisticalTaskContainer;
|
private PartTaskContainer DecompositionTaskContainer;
|
private PlaceContainer PlaceContainer;
|
private ResultContainer ResultContainer;
|
|
/// <summary>
|
/// 该节点的下一个节点
|
/// </summary>
|
private IHandler nextHandler = null;
|
public IHandler NextHandler
|
{
|
set { nextHandler = value; }
|
}
|
|
public 生成堆垛机任务(ResultContainer resultContainer, MainTaskContainer logisticalTaskContainer, PartTaskContainer decompositionTaskContainer, PlaceContainer placeContainer)
|
{
|
this.ResultContainer = resultContainer;
|
this.LogisticalTaskContainer = logisticalTaskContainer;
|
this.DecompositionTaskContainer = decompositionTaskContainer;
|
this.PlaceContainer = placeContainer;
|
}
|
|
public void Handle()
|
{
|
|
try
|
{
|
if (LogisticalTaskContainer.MainTask == null)
|
{
|
ResultContainer.Msg = "未找到待分解任务";
|
LogTextHelper.WriteLine(Resources.LogDir + @"/分解任务流程", "生成堆垛机任务:{0}", "未找到待分解任务");
|
return;
|
}
|
|
if (PlaceContainer.Place == null)
|
{
|
ResultContainer.Msg = "未找到起始位置";
|
LogTextHelper.WriteLine(Resources.LogDir + @"/分解任务流程", "生成堆垛机任务:{0}", "未找到起始位置");
|
return;
|
}
|
string stackerName = Enum.GetName(typeof(EEquipmentCnName), EEquipmentCnName.stacker1);
|
var stacker = CacheEntity.Equipments.FirstOrDefault(x => x.EquipName == stackerName);
|
var toPlace = CacheEntity.Places.FirstOrDefault(x => x.PlaceTypeName== "gate21");
|
|
DecompositionTaskContainer.PartTask = new PartTaskEntity
|
{
|
Type = (int)EPartTaskType.堆垛机任务,
|
MainTaskId = LogisticalTaskContainer.MainTask.Id,
|
MainTaskType = LogisticalTaskContainer.MainTask.TaskType,
|
TaskNo = LogisticalTaskContainer.MainTask.TaskNo,
|
SysCode = LogisticalTaskContainer.MainTask.SysCode,
|
ExecutionSequence = 1,
|
SourcePlace = PlaceContainer.Place.Code,
|
SourcePlaceId = PlaceContainer.Place.Id,
|
SourcePosx = (int)PlaceContainer.Place.Row,
|
SourcePosy = (int)PlaceContainer.Place.Layer,
|
SourcePosz = (int)PlaceContainer.Place.Col,
|
ToPlace = toPlace.Code,
|
ToPlaceId = toPlace.Id,
|
ToPosx = (int)toPlace.Row,
|
ToPosy = (int)toPlace.Layer,
|
ToPosz = (int)toPlace.Col,
|
Status = (int)EPartTaskStatus.未开始,
|
CreateTime = DateTime.Now,
|
UpdateTime = DateTime.Now,
|
EquipId = stacker.Id,
|
EquipName = stacker.EquipName,
|
TaskProcessStatus = (int)ESrmState.未知,
|
VoidLabel = (int)EYesOrNo.否,
|
Priority = 100,
|
IsMoveTask = (int)EYesOrNo.否,
|
ProcessCardNumber = LogisticalTaskContainer.MainTask.ProcessCardNumber,
|
PackageNo = LogisticalTaskContainer.MainTask.PackageNo,
|
MaterialCode = LogisticalTaskContainer.MainTask.MaterialCode,
|
Quantity = LogisticalTaskContainer.MainTask.Quantity,
|
TargetPlaceId=416
|
};
|
|
LogTextHelper.WriteLine(Resources.LogDir + @"/分解任务流程", "生成堆垛机任务:{0}", DecompositionTaskContainer.PartTask.TaskNo);
|
|
|
if (nextHandler != null)
|
{
|
nextHandler.Handle();
|
}
|
}
|
catch (Exception ex)
|
{
|
ResultContainer.Msg = ex.Message;
|
LogTextHelper.WriteLine(Resources.LogDir + @"/分解任务流程", "生成堆垛机任务:{0}", ex.Message);
|
LogTextHelper.WriteLog(Resources.LogDir, this.ToString(), "Handle", ex.Message);
|
}
|
|
}
|
}
|
}
|