You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
3.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using Microsoft.Extensions.Logging;
using SlnMesnac.Model.domain;
namespace SlnMesnac.Repository.service.Impl
{
public class BaseSpaceinfoServiceImpl:IBaseSpaceinfoService
{
private readonly ILogger<BaseSpaceinfo> _logger;
private readonly Repository<BaseSpaceinfo> _rep;
public BaseSpaceinfoServiceImpl(ILogger<BaseSpaceinfo> logger, Repository<BaseSpaceinfo> rep)
{
_logger = logger;
_rep = rep;
}
/// <summary>
/// 获取指定的货道信息
/// </summary>
/// <param name="spaceinfos"></param>
/// <param name="whereExpression"></param>
/// <exception cref="InvalidOperationException"></exception>
public void GetSpaceInfosByExpression(out List<BaseSpaceinfo> spaceinfos, Expression<Func<BaseSpaceinfo, bool>> whereExpression = null)
{
try
{
var exp = whereExpression != null ? whereExpression : x=>1==1;
spaceinfos = _rep.GetList(exp);
}
catch (Exception e)
{
throw new InvalidOperationException($"获取所有已下线成品信息异常:{e.Message}");
}
}
/// <summary>
/// 根据物料类型获取指定仓库的货道信息
/// </summary>
/// <param name="spaceinfo"></param>
/// <param name="storeCode"></param>
/// <param name="materialType"></param>
/// <exception cref="ArgumentException"></exception>
public void GetSpaceInfoByMaterialType(out List<BaseSpaceinfo> spaceinfos, string storeCode, string materialType)
{
if (string.IsNullOrEmpty(storeCode))
{
throw new ArgumentException($"根据物料类型获取指定仓库的货道信息异常:仓库编号为空");
}
if (string.IsNullOrEmpty(materialType))
{
throw new ArgumentException($"根据物料类型获取指定仓库的货道信息异常:物料类型为空");
}
try
{
spaceinfos = _rep.GetList(x => x.StoreCode == storeCode && x.MaterialType == materialType);
}
catch (Exception e)
{
throw new InvalidOperationException($"根据物料类型获取指定仓库的货道信息异常:{e.Message}");
}
}
/// <summary>
/// 更新货道信息
/// </summary>
/// <param name="spaceinfos"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public bool UpdateSpaceInfo(List<BaseSpaceinfo> spaceinfos)
{
bool result = false;
try
{
result = _rep.UpdateRange(spaceinfos);
}
catch (Exception e)
{
throw new InvalidOperationException($"更新货道信息异常:{e.Message}");
}
return result;
}
}
}