From c020f31a67fc5aa5644511bddff075f7ecc85234 Mon Sep 17 00:00:00 2001 From: qinchulong <qinchulong@hnkhzn.com> Date: 星期二, 27 五月 2025 15:35:27 +0800 Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/HuaYiZhongHeng/ZhongHeLiTiKu --- 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_StockRepository/StockInfoRepository.cs | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 105 insertions(+), 0 deletions(-) diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockRepository/StockInfoRepository.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockRepository/StockInfoRepository.cs" new file mode 100644 index 0000000..adef8e2 --- /dev/null +++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockRepository/StockInfoRepository.cs" @@ -0,0 +1,105 @@ +锘縰sing Org.BouncyCastle.Crypto; +using SqlSugar; +using SqlSugar.Extensions; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WIDESEA_Core.BaseRepository; +using WIDESEA_Core.Enums; +using WIDESEA_DTO.Stock; +using WIDESEA_IBasicRepository; +using WIDESEA_IStockRepository; +using WIDESEA_Model.Models; + +namespace WIDESEA_StockRepository +{ + public class StockInfoRepository : RepositoryBase<Dt_StockInfo>, IStockInfoRepository + { + public StockInfoRepository(IUnitOfWorkManage unitOfWorkManage) : base(unitOfWorkManage) + { + } + + public List<StockViewDTO> GetAllStockViews() + { + ISugarQueryable<Dt_LocationInfo> sugarQueryable = Db.Queryable<Dt_LocationInfo>(); + ISugarQueryable<Dt_StockInfo> sugarQueryable1 = Db.Queryable<Dt_StockInfo>(); + + return sugarQueryable.InnerJoin(sugarQueryable1, (a, b) => a.LocationCode == b.LocationCode).Select((a, b) => new StockViewDTO + { + AreaId = a.AreaId, + LocationCode = b.LocationCode, + Column = a.Column, + CreateDate = b.CreateDate, + Creater = b.Creater, + Depth = a.Depth, + EnalbeStatus = a.EnableStatus, + IsFull = b.IsFull, + Layer = a.Layer, + LocationName = a.LocationName, + LocationStatus = a.LocationStatus, + LocationType = a.LocationType, + Modifier = b.Modifier, + ModifyDate = b.ModifyDate, + PalletCode = b.PalletCode, + StockRemark = b.Remark, + RoadwayNo = a.RoadwayNo, + Row = a.Row, + StockId = b.Id, + StockStatus = b.StockStatus, + Details = b.Details, + }).Includes(x => x.Details).ToList(); + } + + public Dt_StockInfo GetStockInfo(string palletCode) + { + return Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First(); + } + + public List<Dt_StockInfo> GetStockInfos(string materielCode) + { + return Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.Details.Any(v => v.MaterielCode == materielCode)).ToList(); + //ISugarQueryable<Dt_LocationInfo> sugarQueryable = Db.Queryable<Dt_LocationInfo>(); + //ISugarQueryable<Dt_StockInfo> sugarQueryable1 = Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.Details.Any(v => v.MaterielCode == materielCode)); + //return sugarQueryable.InnerJoin(sugarQueryable1, (a, b) => a.LocationCode == b.LocationCode).Select((a, b) => b).Includes(x => x.Details).ToList(); + } + + public List<Dt_StockInfo> GetStockInfos(string materielCode, List<string> locationCodes) + { + return Db.Queryable<Dt_StockInfo>().Where(x => locationCodes.Contains(x.LocationCode)).Includes(x => x.Details).Where(x => x.Details.Any(v => v.MaterielCode == materielCode)).ToList(); + + + //ISugarQueryable<Dt_LocationInfo> sugarQueryable = Db.Queryable<Dt_LocationInfo>().Where(x => locationCodes.Contains(x.LocationCode)); + //ISugarQueryable<Dt_StockInfo> sugarQueryable1 = Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.Details.Any(v => v.MaterielCode == materielCode)); + //return sugarQueryable.InnerJoin(sugarQueryable1, (a, b) => a.LocationCode == b.LocationCode).Select((a, b) => b).OrderBy(a => a.CreateDate).Includes(a => a.Details).ToList(); + } + + public List<Dt_StockInfo> GetStockInfosByIds(List<int> ids) + { + return Db.Queryable<Dt_StockInfo>().Where(x => ids.Contains(x.Id)).Includes(x => x.Details).ToList(); + } + + public List<Dt_StockInfo> GetStockInfosByPalletCodes(List<string> palletCodes) + { + return Db.Queryable<Dt_StockInfo>().Where(x => palletCodes.Contains(x.PalletCode)).Includes(x => x.Details).ToList(); + } + + public List<Dt_StockInfo> GetStockInfosExclude(string materielCode, List<string> palletCodes) + { + return Db.Queryable<Dt_StockInfo>().Where(x => !palletCodes.Contains(x.PalletCode)).Includes(x => x.Details).Where(x => x.Details.Any(v => v.MaterielCode == materielCode)).ToList(); + } + + public bool UpdateDataWithDetail(Dt_StockInfo stockInfo) + { + return Db.UpdateNav(stockInfo).Include(x => x.Details).ExecuteCommand(); + } + + public Dt_StockInfo GetPalletStockInfo(string roadwayNo) + { + //ISugarQueryable<string> locationCodes = Db.Queryable<Dt_LocationInfo>().Where(x => x.RoadwayNo == roadwayNo && x.LocationStatus == LocationStatusEnum.Pallet.ObjToInt() && (x.EnalbeStatus == LocationEnalbeStatusEnum.OnlyOut.ObjToInt() || LocationEnalbeStatusEnum.Normal.ObjToInt() == x.EnalbeStatus)).Select(x => x.LocationCode); + + return Db.Queryable<Dt_StockInfo>().Where(x => x.StockStatus == StockStatusEmun.宸插叆搴�.ObjToInt() && SqlFunc.Subqueryable<Dt_LocationInfo>().Where(v => v.LocationCode == x.LocationCode && v.RoadwayNo == roadwayNo && v.LocationStatus == LocationStatusEnum.Pallet.ObjToInt() && (v.EnableStatus == EnableStatusEnum.OnlyOut.ObjToInt() || EnableStatusEnum.Normal.ObjToInt() == v.EnableStatus)).Any()).OrderBy(x => x.ModifyDate).First(); + } + } +} -- Gitblit v1.9.3