using iWareCc.Cache.Entity;
|
using iWareCc.DecomposeTask.Entity;
|
using iWareCcTest.Properties;
|
using iWareCommon.Common.Entity;
|
using iWareCommon.Utils;
|
using iWareDataCore.ORM;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Data.SqlClient;
|
using iWareDataCore.BASE.EnumType;
|
|
|
namespace iWareCc.DecomposeTask.Strategy.出库任务.Chain
|
{
|
public class 寻找满足库存条件的库位 : IHandler
|
{
|
private MainTaskContainer LogisticalTaskContainer;
|
private PlaceContainer PlaceContainer;
|
private ResultContainer ResultContainer;
|
/// <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)
|
{
|
LogTextHelper.WriteLine(Resources.LogDir + @"/分解任务流程", "寻找满足库存条件的库位:{0}", "未找到待分解任务");
|
ResultContainer.Msg = "未找到待分解任务";
|
return;
|
}
|
|
var task = LogisticalTaskContainer.MainTask;
|
///为被锁定的物料库位
|
var placeMaterial = dbModel.BASEPlaceMaterialViews.FirstOrDefault(x => x.materialcode == task.MaterialCode && x.placetypename == EPlaceType.普通库位.ToString());
|
|
if (placeMaterial == null)
|
{
|
LogTextHelper.WriteLine(Resources.LogDir + @"/分解任务流程", "寻找指定数量的物料的库位:{0}", "没有找到合适的库位");
|
ResultContainer.Msg = "没有找到合适的库位";
|
return;
|
}
|
PlaceContainer.Place = CacheEntity.Places.FirstOrDefault(x => x.Id == placeMaterial.placeid);
|
|
LogTextHelper.WriteLine(Resources.LogDir + @"/分解任务流程", "寻找指定数量的物料的库位:{0}", PlaceContainer.Place.Code);
|
|
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);
|
}
|
}
|
}
|
}
|
}
|