using Furion.DatabaseAccessor; using Furion.FriendlyException; using iWare.Wms.Core; using iWare.Wms.Core.Enum; namespace Admin.NET.Application.Common.FindEmptyLocationFactory.Default { internal class MaterialFindEmptyLocationHandle : FindEmptyLocationServiceHandle { public MaterialFindEmptyLocationHandle(IRepository v_EmptyLocationRep, IRepository wareLocationRep, IRepository wareTaskRep, IRepository wareContainerVsMaterial, IRepository wareContainer, IRepository wareContainerType, IRepository 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() { var container = _wareContainer.DetachedEntities.Where(u => u.ContainerCode == _containerCode).FirstOrDefault(); WmsContainerType containerType = new WmsContainerType(); if (container != null) { containerType = _wareContainerType.DetachedEntities.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() { base.DataOrder(); } } }