|
|
|
@ -16,6 +16,9 @@ using Admin.Core.Model.Sys;
|
|
|
|
|
|
|
|
|
|
namespace Admin.Core.Service
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* 货道
|
|
|
|
|
**/
|
|
|
|
|
public class BaseSpaceInfoServices : BaseServices<BaseSpaceInfo>, IBaseSpaceInfoServices
|
|
|
|
|
{
|
|
|
|
|
private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(BaseSpaceInfoServices));
|
|
|
|
@ -107,5 +110,100 @@ namespace Admin.Core.Service
|
|
|
|
|
return spaceInfo;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 出库通过物料类型获取指定货道
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 出库通过物料类型获取指定货道
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="store"></param>
|
|
|
|
|
/// <param name="materialType"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<BaseSpaceInfo> OutStoreGetSpaceInfoByMaterialCode(string store, string materialType)
|
|
|
|
|
{
|
|
|
|
|
BaseSpaceInfo spaceInfo = null;
|
|
|
|
|
List<BaseSpaceInfo> spaceInfos;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//Expression<Func<BaseSpaceInfo, bool>> exp = s1 => true;
|
|
|
|
|
spaceInfos = await _baseSpaceInfoRepository.QueryAsync(x => x.StoreCode == store && x.MaterialType == materialType && x.SpaceStatus == 1 && x.SpaceStock > 0);//相同型号、启用状态、库存不为空的货道信息
|
|
|
|
|
|
|
|
|
|
logHelper.Info($"根据仓库{store};物料:{materialType};获取到的货道信息:{spaceInfos.ToJson()}");
|
|
|
|
|
logHelper.Info($"仓库{store};物料:{materialType};匹配的入库货道信息:{spaceInfos.ToJson()}");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("出库通过物料类型获取货道信息异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return spaceInfo;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 出库过滤逻辑
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 出库过滤逻辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="spaceInfos"></param>
|
|
|
|
|
public BaseSpaceInfo outStoreFilter(List<BaseSpaceInfo> spaceInfos)
|
|
|
|
|
{
|
|
|
|
|
BaseSpaceInfo spaceInfo = null;
|
|
|
|
|
if (spaceInfos.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
//获取库存最少的货道(优先清空货道)
|
|
|
|
|
spaceInfo = spaceInfos.Where(x => x.SpaceStock > 0).OrderBy(x => x.SpaceStock).First();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
logHelper.Info("出库过滤未获取到匹配的货道信息");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return spaceInfo;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 通过货道编号获取货道信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过货道编号获取货道信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="store"></param>
|
|
|
|
|
/// <param name="spaceCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<BaseSpaceInfo> GetSpaceInfoBySpaceCode(string store, string spaceCode)
|
|
|
|
|
{
|
|
|
|
|
BaseSpaceInfo spaceInfo = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
spaceInfo = await _baseSpaceInfoRepository.FirstAsync(x => x.StoreCode == store && x.SpaceCode == spaceCode);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("通过货道编号获取货道信息异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return spaceInfo;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 更新货道信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新货道信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="spaceInfo"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<bool> UpdateSpaceInfo(BaseSpaceInfo spaceInfo)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
result = await _baseSpaceInfoRepository.UpdateAsync(spaceInfo);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("更新货道信息异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|