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 ResultContainer ResultContainer;
|
private MainTaskContainer LogisticalTaskContainer;
|
private PartTaskContainer DecompositionTaskContainer;
|
private PlaceContainer PlaceContainer;
|
|
/// <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;
|
}
|
|
var sourcePlace = CacheEntity.Places.FirstOrDefault(x => x.PlaceTypeName == "gate11");//"输送机始端库口"
|
var toPlace = CacheEntity.Places.FirstOrDefault(x => x.PlaceTypeName == "gate12");//"输送机末端库口"
|
var equipment = CacheEntity.Equipments.FirstOrDefault(x => x.EquipName == "conveyor1");//入库输送机
|
|
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 = sourcePlace.Code,
|
SourcePlaceId = sourcePlace.Id,
|
ToPlace = toPlace.Code,
|
ToPlaceId = toPlace.Id,
|
Status = (int)EPartTaskStatus.未开始,
|
CreateTime = DateTime.Now,
|
UpdateTime = DateTime.Now,
|
EquipId = equipment.Id,
|
EquipName = equipment.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 = PlaceContainer.Place.Id,
|
NextNode=(int)EInstorgNextNode.gate13,
|
IsLots = LogisticalTaskContainer.MainTask.IsLots
|
};
|
|
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);
|
}
|
}
|
}
|
}
|