123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- 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<WCS_CacheLine> _WCSCachelineRepository;
- private readonly Repository<WCS_CacheLineLoc> _WCSCachelinelocRepository;
- private readonly Repository<BaseWarehouse> _wareHouserepository;
- public WCSCachelineService(Repository<WCS_CacheLine> wCSCachelineRepository, Repository<BaseWarehouse> wareHouserepository, Repository<WCS_CacheLineLoc> wCSCachelinelocRepository)
- {
- _WCSCachelineRepository = wCSCachelineRepository;
- _wareHouserepository = wareHouserepository;
- _WCSCachelinelocRepository = wCSCachelinelocRepository;
- }
- public PagedInfo<WCSCachelineDto> GetPageList(Pagination pagination, WCSCachelineQueryDto wcsCachelineQueryDto)
- {
- var predicate = Expressionable.Create<WCS_CacheLine>();
- 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<WCS_CacheLine, WCSCachelineDto>(pagination);
- return list;
- }
- public void Delete(List<int> 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();
- });
- }
- }
- }
- }
|