using iWareCc.Cache.Entity;
|
using iWareCc.Conveyor.EnumType;
|
using iWareCc.DecomposeTask.Entity;
|
using iWareCc.Properties;
|
using iWareCommon.Common.Entity;
|
using iWareCommon.Common.EnumType;
|
using iWareCommon.Utils;
|
using iWareDataCore.BASE.EnumType;
|
using iWareDataCore.ORM;
|
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 PlaceContainer PlaceContainer;
|
|
|
/// <summary>
|
/// 该节点的下一个节点
|
/// </summary>
|
private IHandler nextHandler = null;
|
public IHandler NextHandler
|
{
|
set { nextHandler = value; }
|
}
|
|
|
public 寻找空库位(ResultContainer resultContainer, MainTaskContainer logisticalTaskContainer, PlaceContainer placeContainer)
|
{
|
this.ResultContainer = resultContainer;
|
this.LogisticalTaskContainer = logisticalTaskContainer;
|
this.PlaceContainer = placeContainer;
|
}
|
|
public void Handle()
|
{
|
using (var dbModel = new DbModelCore())
|
{
|
try
|
{
|
if (LogisticalTaskContainer.MainTask == null)
|
{
|
ResultContainer.Msg = "未找到待分解任务";
|
LogTextHelper.WriteLine(Resources.LogDir + @"/分解任务流程", "寻找空库位:{0}", ResultContainer.Msg);
|
return;
|
}
|
//按照层列原则利用库位
|
|
var alerm = CacheEntity.Conveyors.Find(x => x.Equipment.EquipName == "conveyor1").Gates.Find(x => x.Place.PlaceTypeName == "alarm");
|
var emptyPlace = dbModel.BASEEmptyPlaceViews.Where(x => x.isexecute == (int)EYesOrNo.否 && x.islock == (int)EYesOrNo.否 && x.typeid == 4 && x.status == (int)EPlaceStatus.空库位).OrderBy(x => new { x.layer, x.col }).FirstOrDefault();
|
if (emptyPlace == null)
|
{
|
ResultContainer.Msg = "未找到空库位";
|
alerm.SendGateAlarmTask((int)ESendCode.入库库位不足);
|
LogTextHelper.WriteLine(Resources.LogDir + @"/分解任务流程", "寻找空库位:{0}", ResultContainer.Msg);
|
return;
|
}
|
|
PlaceContainer.Place = CacheEntity.Places.FirstOrDefault(x => x.Id == emptyPlace.id);
|
|
LogTextHelper.WriteLine(Resources.LogDir + @"/分解任务流程", "寻找空库位:{0}", PlaceContainer.Place.Code);
|
|
if (nextHandler != null)
|
{
|
nextHandler.Handle();
|
}
|
}
|
catch (Exception ex)
|
{
|
|
ResultContainer.Msg = ex.Message;
|
LogTextHelper.WriteLog(Resources.LogDir, this.ToString(), "Handle", ex.Message);
|
}
|
}
|
}
|
}
|
}
|