12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using Org.BouncyCastle.Crypto;
- using SqlSugar;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- using wms.sqlsugar.model.fj;
- using WMS.BZModels;
- using WMS.BZModels.Dto.FJ.WCSCachelineDtos;
- using WMS.BZSqlSugar;
- using WMS.Info;
- namespace WMS.BZServices.FJ
- {
- public class WCSCachelineService
- {
- private readonly Repository<WCSCacheline> _WCSCachelineRepository;
- private readonly Repository<WCSCachelineloc> _WCSCachelinelocRepository;
- private readonly Repository<BaseWarehouse> _wareHouserepository;
- public WCSCachelineService(Repository<WCSCacheline> wCSCachelineRepository, Repository<BaseWarehouse> wareHouserepository, Repository<WCSCachelineloc> wCSCachelinelocRepository)
- {
- _WCSCachelineRepository = wCSCachelineRepository;
- _wareHouserepository = wareHouserepository;
- _WCSCachelinelocRepository = wCSCachelinelocRepository;
- }
- public PagedInfo<WCSCachelineDto> GetPageList(Pagination pagination, WCSCachelineQueryDto wcsCachelineQueryDto)
- {
- var predicate = Expressionable.Create<WCSCacheline>();
- 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.LocationNo.ToString().Contains(wcsCachelineQueryDto.KeyWord) || m.MatCodeList.Contains(wcsCachelineQueryDto.KeyWord) || m.TargetAddress.ToString().Contains(wcsCachelineQueryDto.KeyWord));
- predicate = predicate.AndIF(wcsCachelineQueryDto != null && !string.IsNullOrEmpty(wcsCachelineQueryDto?.LocationNo), m => m.LocationNo.ToString().Contains(wcsCachelineQueryDto.LocationNo));
- predicate = predicate.AndIF(wcsCachelineQueryDto != null && !string.IsNullOrEmpty(wcsCachelineQueryDto?.TargetAddress), m => m.TargetAddress.ToString().Contains(wcsCachelineQueryDto.TargetAddress));
- predicate = predicate.AndIF(wcsCachelineQueryDto != null && !string.IsNullOrEmpty(wcsCachelineQueryDto?.PalletizingRowId), m => m.PalletizingRowId.ToString().Contains(wcsCachelineQueryDto.PalletizingRowId));
- predicate = predicate.AndIF(wcsCachelineQueryDto != null && !string.IsNullOrEmpty(wcsCachelineQueryDto?.Put), m => m.Put.Equals(wcsCachelineQueryDto.Put));
- predicate = predicate.AndIF(wcsCachelineQueryDto != null && !string.IsNullOrEmpty(wcsCachelineQueryDto?.Quantity), m => m.Quantity.ToString().Contains(wcsCachelineQueryDto.Quantity));
- predicate = predicate.AndIF(wcsCachelineQueryDto != null && !string.IsNullOrEmpty(wcsCachelineQueryDto?.MatCodeList), m => m.MatCodeList.ToString().Contains(wcsCachelineQueryDto.MatCodeList));
- predicate = predicate.AndIF(wcsCachelineQueryDto != null && !string.IsNullOrEmpty(wcsCachelineQueryDto?.InStock), m => m.InStock.Equals(wcsCachelineQueryDto.InStock));
- predicate = predicate.AndIF(wcsCachelineQueryDto != null && !string.IsNullOrEmpty(wcsCachelineQueryDto?.IsTruss), m => m.IsTruss.Equals(wcsCachelineQueryDto.IsTruss));
- predicate = predicate.AndIF(wcsCachelineQueryDto != null && !string.IsNullOrEmpty(wcsCachelineQueryDto?.WarehouseCode), m => m.WarehouseCode.Equals(wcsCachelineQueryDto.WarehouseCode));
- 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 => SqlFunc.Subqueryable<WCSCachelineloc>().Where(s => s.CacheLineId == m.Id && s.TaskId.ToString().Contains(wcsCachelineQueryDto.TaskId)).Any());
- var list = _WCSCachelineRepository.Queryable().Where(predicate.ToExpression())
- .ToPage<WCSCacheline, WCSCachelineDto>(pagination);
- var wareHouses = _wareHouserepository.Queryable().Where(o => o.IsStop == 0).ToList();
- list.Result.ForEach(o =>
- {
- o.WarehouseName = wareHouses.FirstOrDefault(v => v.Code == o.WarehouseCode)?.Name ?? "";
- });
- 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();
- });
- }
-
- }
- public bool UpdateOvertime(List<int> ids)
- {
- if (ids == null || !ids.Any()) throw new ArgumentException("参数错误!");
- var list = _WCSCachelineRepository.Queryable().Where(o => ids.Contains(o.Id)).ToList();
- if (!list.Any())
- {
- throw new ArgumentException("没有找到该缓存信息!");
- }
- list.ForEach(o =>
- {
- o.AddTime = o.AddTime.AddHours(-12);
- o.EditTime = DateTime.Now;
- });
- var result = _WCSCachelineRepository.UpdateRange(list.ToArray());
- return result;
- }
- }
- }
|