using SqlSugar; using WMS.BZModels; using WMS.BZModels.Dto.KLHC.WCSCachelineDtos; using WMS.BZModels.Models.KLHC; using WMS.BZSqlSugar; using WMS.Info; namespace WMS.BZServices.KLHC { public class WCSCachelineService { private readonly Repository _WCSCachelineRepository; private readonly Repository _WCSCachelinelocRepository; private readonly Repository _wareHouserepository; public WCSCachelineService(Repository wCSCachelineRepository, Repository wareHouserepository, Repository wCSCachelinelocRepository) { _WCSCachelineRepository = wCSCachelineRepository; _wareHouserepository = wareHouserepository; _WCSCachelinelocRepository = wCSCachelinelocRepository; } public PagedInfo GetPageList(Pagination pagination, WCSCachelineQueryDto wcsCachelineQueryDto) { var predicate = Expressionable.Create(); predicate = predicate.AndIF(wcsCachelineQueryDto != null && !string.IsNullOrEmpty(wcsCachelineQueryDto?.Id), m => m.Id.ToString().Contains(wcsCachelineQueryDto.Id)); predicate = predicate.AndIF(wcsCachelineQueryDto != null && !string.IsNullOrEmpty(wcsCachelineQueryDto?.KeyWord), m => m.Id.ToString().Contains(wcsCachelineQueryDto.KeyWord) || m.TargetCacheLine.ToString().Contains(wcsCachelineQueryDto.KeyWord) || m.WheelType.Contains(wcsCachelineQueryDto.KeyWord)); predicate = predicate.AndIF(wcsCachelineQueryDto != null && !string.IsNullOrEmpty(wcsCachelineQueryDto?.LocationNo), m => m.TargetCacheLine.ToString().Contains(wcsCachelineQueryDto.LocationNo)); predicate = predicate.AndIF(wcsCachelineQueryDto != null && !string.IsNullOrEmpty(wcsCachelineQueryDto?.Truss), m => m.Truss.Contains(wcsCachelineQueryDto.Truss)); predicate = predicate.AndIF(wcsCachelineQueryDto != null && !string.IsNullOrEmpty(wcsCachelineQueryDto?.Quantity), m => m.ExistingSpoolCount.ToString().Contains(wcsCachelineQueryDto.Quantity)); predicate = predicate.AndIF(wcsCachelineQueryDto != null && !string.IsNullOrEmpty(wcsCachelineQueryDto?.WheelType), m => m.WheelType.ToString().Contains(wcsCachelineQueryDto.WheelType)); predicate = predicate.AndIF(wcsCachelineQueryDto != null && !string.IsNullOrEmpty(wcsCachelineQueryDto?.IsCompleted), m => m.IsCompleted.Equals(wcsCachelineQueryDto.IsCompleted)); predicate = predicate.AndIF(wcsCachelineQueryDto != null && !string.IsNullOrEmpty(wcsCachelineQueryDto?.IsTruss), m => m.IsTruss.Equals(wcsCachelineQueryDto.IsTruss)); predicate = predicate.AndIF(wcsCachelineQueryDto != null && wcsCachelineQueryDto.AddTimeFrom.HasValue, m => m.AddTime >= wcsCachelineQueryDto.AddTimeFrom); predicate = predicate.AndIF(wcsCachelineQueryDto != null && wcsCachelineQueryDto.AddTimeTo.HasValue, m => m.AddTime <= wcsCachelineQueryDto.AddTimeTo); predicate = predicate.AndIF(wcsCachelineQueryDto != null && !string.IsNullOrWhiteSpace(wcsCachelineQueryDto.TaskId), m => m.Id.ToString().Contains(wcsCachelineQueryDto.TaskId)); var list = _WCSCachelineRepository.Queryable().Where(predicate.ToExpression()) .ToPage(pagination); return list; } public void Delete(List ids) { if (ids == null || !ids.Any()) throw new ArgumentException("参数错误!"); var entitys = _WCSCachelineRepository.Queryable().Where(o => ids.Contains(o.Id)).ToList(); if (!entitys.Any()) { throw new ArgumentException("没有找到数据!"); } foreach (var entity in entitys) { _WCSCachelineRepository.UseTranAction(() => { _WCSCachelineRepository.Deleteable().Where(it => it.Id == entity.Id).ExecuteCommand(); _WCSCachelinelocRepository.Deleteable().Where(it => it.CacheLineId == entity.Id).ExecuteCommand(); }); } } } }