using Furion.DatabaseAccessor;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using Furion.FriendlyException;
|
using iWare.Wms.Core;
|
using iWare.Wms.Core.Enum;
|
|
namespace Admin.NET.Application.Common.FindEmptyLocationFactory.Default
|
{
|
internal class ContainerFindEmptyLocationHandle : FindEmptyLocationServiceHandle
|
{
|
public ContainerFindEmptyLocationHandle(IRepository<v_empty_location, MasterDbContextLocator> v_EmptyLocationRep,
|
IRepository<WmsPlace, MasterDbContextLocator> wareLocationRep,
|
IRepository<WareTask, MasterDbContextLocator> wareTaskRep,
|
IRepository<WareContainerVsMaterial, MasterDbContextLocator> wareContainerVsMaterial,
|
IRepository<WmsContainer, MasterDbContextLocator> wareContainer,
|
IRepository<WmsContainerType, MasterDbContextLocator> wareContainerType,
|
IRepository<v_ware_inventory_by_container, MasterDbContextLocator> v_ware_inventory_by_container,
|
string containerCode, string siteCode) : base(
|
v_EmptyLocationRep,
|
wareLocationRep,
|
wareTaskRep,
|
wareContainerVsMaterial,
|
wareContainer,
|
wareContainerType,
|
v_ware_inventory_by_container,
|
containerCode,
|
siteCode)
|
{
|
|
}
|
|
protected override void DiyFilter()
|
{
|
base.DiyFilter();
|
}
|
|
protected override void QueryBaseEmptyLocationList()
|
{
|
//base.QueryBaseEmptyLocationList();
|
var container = _wareContainer.DetachedEntities.Where(u => u.ContainerCode == _containerCode).FirstOrDefault();
|
if (container == null)
|
{
|
throw Oops.Oh("小车没有配置信息");
|
}
|
WmsContainerType containerType = new WmsContainerType();
|
if (container != null)
|
{
|
containerType = _wareContainerType.Where(u => u.WareContainerTypeCode == container.ContainerTypeCode).FirstOrDefault();
|
if (containerType == null)
|
{
|
throw Oops.Oh($"查询不到小车{_containerCode}的容器类型");
|
}
|
}
|
else
|
{
|
throw Oops.Oh($"小车{_containerCode}未查询到基础信息");
|
}
|
|
//处理可入库位类型
|
var typeList = containerType.LocationType.Split(',');
|
|
//优先找远伸位有空小车的近伸位,并且托盘类型相同且为空托,空托放在同一个伸位
|
var farlocationlist = _v_ware_inventory_by_container.DetachedEntities.Where(u => u.IsLocked == false && u.DeepcellNo == DeepcellNoEnum.远伸 && u.ContainerType == containerType.WareContainerTypeCode).Select(u => u.UnionCode).ToList();
|
findEmptyLocationList = _v_EmptyLocationRep.DetachedEntities.Where(u => farlocationlist.Contains(u.UnionCode) && u.DeepcellNo == DeepcellNoEnum.近伸).ToList();
|
if (findEmptyLocationList.Count == 0)
|
{
|
//优先放远伸,放满所有远伸后放近伸
|
findEmptyLocationList = _v_EmptyLocationRep.DetachedEntities.Where(u => u.DeepcellNo == DeepcellNoEnum.远伸 && typeList.Contains(u.WareLocationTypeCode)).ToList();
|
}
|
if (findEmptyLocationList.Count == 0)
|
{
|
//优先放远伸,放满所有远伸后放近伸
|
findEmptyLocationList = _v_EmptyLocationRep.DetachedEntities.Where(u => typeList.Contains(u.WareLocationTypeCode)).ToList();
|
}
|
if (findEmptyLocationList.Count == 0 && _siteCode == "HMAX")
|
{
|
//还是没有满足的库位,找可入库位放
|
findEmptyLocationList = _v_EmptyLocationRep.DetachedEntities.Where(u => u.WareLocationTypeCode == "HMAX").ToList();
|
}
|
}
|
|
protected override void EnableLaneFilter()
|
{
|
base.EnableLaneFilter();
|
}
|
protected override void TaskOccupyFilter()
|
{
|
base.TaskOccupyFilter();
|
}
|
|
protected override void DataOrder()
|
{
|
if (findEmptyLocationList != null && findEmptyLocationList.Count > 0)
|
{
|
findEmptyLocationList = findEmptyLocationList
|
//先按照层,升序排列
|
.OrderByDescending(x => x.LayerNo + x.ColumnNo).ToList();
|
}
|
base.DataOrder();
|
}
|
}
|
}
|