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 _logger; private readonly Repository _rep; public BaseSpaceinfoServiceImpl(ILogger logger, Repository rep) { _logger = logger; _rep = rep; } /// /// 获取指定的货道信息 /// /// /// /// public void GetSpaceInfosByExpression(out List spaceinfos, Expression> whereExpression = null) { try { var exp = whereExpression != null ? whereExpression : x=>1==1; spaceinfos = _rep.GetList(exp); } catch (Exception e) { throw new InvalidOperationException($"获取所有已下线成品信息异常:{e.Message}"); } } /// /// 根据物料类型获取指定仓库的货道信息 /// /// /// /// /// public void GetSpaceInfoByMaterialType(out List 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}"); } } /// /// 更新货道信息 /// /// /// /// public bool UpdateSpaceInfo(List spaceinfos) { bool result = false; try { result = _rep.UpdateRange(spaceinfos); } catch (Exception e) { throw new InvalidOperationException($"更新货道信息异常:{e.Message}"); } return result; } } }