From cb46c3345568c87717a36b931cb99e98cc032f5f Mon Sep 17 00:00:00 2001 From: "qianhao.xu" Date: Fri, 12 Jul 2024 16:56:15 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E6=96=99=E6=B8=85=E5=8D=95=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MES/base/Dto/BaseMaterialListDto.cs | 57 +++++++++++++++++++ .../MES/base/BaseMaterialListService.cs | 33 +++++++---- .../base/IService/IBaseMaterialListService.cs | 2 +- 3 files changed, 80 insertions(+), 12 deletions(-) diff --git a/DOAN.Model/MES/base/Dto/BaseMaterialListDto.cs b/DOAN.Model/MES/base/Dto/BaseMaterialListDto.cs index 9921ea6..4f0b954 100644 --- a/DOAN.Model/MES/base/Dto/BaseMaterialListDto.cs +++ b/DOAN.Model/MES/base/Dto/BaseMaterialListDto.cs @@ -74,5 +74,62 @@ namespace DOAN.Model.MES.base_.Dto + } + public class BaseMaterialListDto2 + { + + + public string Type_Name { get; set; } + + public string Type_Code { get; set; } + + public string SupplierName { get; set; } + + public string Id { get; set; } + + public int? FkTypeId { get; set; } + + public string Name { get; set; } + + public string Code { get; set; } + + public string CustomerCode { get; set; } + + public string Color { get; set; } + + public string Specification { get; set; } + + public string Unit { get; set; } + + public string Description { get; set; } + + public int? FkSupplierId { get; set; } + + public string ExpirationUnit { get; set; } + + public decimal ExpirationDate { get; set; } + + public int? ShelfLifeWarningDays { get; set; } + + public int? IsShelfLife { get; set; } + + public DateTime? StartTime { get; set; } + + public DateTime? StopTime { get; set; } + + public string BarCode { get; set; } + + public int? IsBatch { get; set; } + + public string CreatedBy { get; set; } + + public DateTime? CreatedTime { get; set; } + + public string UpdatedBy { get; set; } + + public DateTime? UpdatedTime { get; set; } + + + } } \ No newline at end of file diff --git a/DOAN.Service/MES/base/BaseMaterialListService.cs b/DOAN.Service/MES/base/BaseMaterialListService.cs index 212c40f..6a22c96 100644 --- a/DOAN.Service/MES/base/BaseMaterialListService.cs +++ b/DOAN.Service/MES/base/BaseMaterialListService.cs @@ -9,6 +9,7 @@ using DOAN.Repository; using DOAN.Service.MES.base_.IService; using System.Linq; using Mapster; +using DOAN.Model.MES.dev.Dto; namespace DOAN.Service.MES.base_ { @@ -23,20 +24,30 @@ namespace DOAN.Service.MES.base_ /// /// /// - public PagedInfo GetList(BaseMaterialListQueryDto parm) + public PagedInfo GetList(BaseMaterialListQueryDto parm) { var predicate = Expressionable.Create() - .AndIF(!string.IsNullOrEmpty(parm.Name),it=>it.Name == parm.Name) - .AndIF(!string.IsNullOrEmpty(parm.Code),it=>it.Code == parm.Code) - .AndIF(!string.IsNullOrEmpty(parm.CustomerCode),it=>it.CustomerCode == parm.CustomerCode) - .AndIF(!string.IsNullOrEmpty(parm.Description),it=>it.Description == parm.Description) - .AndIF(parm.FkTypeId>=0,it=>it.FkTypeId == parm.FkTypeId) - .AndIF(parm.TimeRange!=null&&parm.TimeRange.Length==2&& parm.TimeRange[0]>DateTime.MinValue, it=>it.CreatedTime >= parm.TimeRange[0]) - .AndIF(parm.TimeRange!=null&&parm.TimeRange.Length==2&& parm.TimeRange[1]>DateTime.MinValue, it=>it.CreatedTime <= parm.TimeRange[1]) ; + .AndIF(!string.IsNullOrEmpty(parm.Name), it => it.Name == parm.Name) + .AndIF(!string.IsNullOrEmpty(parm.Code), it => it.Code == parm.Code) + .AndIF(!string.IsNullOrEmpty(parm.CustomerCode), it => it.CustomerCode == parm.CustomerCode) + .AndIF(!string.IsNullOrEmpty(parm.Description), it => it.Description == parm.Description) + .AndIF(parm.FkTypeId >= 0, it => it.FkTypeId == parm.FkTypeId) + .AndIF(parm.TimeRange != null && parm.TimeRange.Length == 2 && parm.TimeRange[0] > DateTime.MinValue, it => it.CreatedTime >= parm.TimeRange[0]) + .AndIF(parm.TimeRange != null && parm.TimeRange.Length == 2 && parm.TimeRange[1] > DateTime.MinValue, it => it.CreatedTime <= parm.TimeRange[1]); - var response = Queryable() - .Where(predicate.ToExpression()) - .ToPage(parm); + var query01 = Queryable() + .Where(predicate.ToExpression()); + + var response = Context.Queryable(query01).LeftJoin((q, t) => q.FkTypeId == t.Id) + .LeftJoin((q, t, s) => q.FkSupplierId == s.Id) + .Select((q, t, s) => new BaseMaterialListDto2 + { + + Type_Name = t.Name, + Type_Code = t.Code, + SupplierName = s.SupplierName + + }, true).ToPage(parm); return response; } diff --git a/DOAN.Service/MES/base/IService/IBaseMaterialListService.cs b/DOAN.Service/MES/base/IService/IBaseMaterialListService.cs index d0233b4..f2ba2b5 100644 --- a/DOAN.Service/MES/base/IService/IBaseMaterialListService.cs +++ b/DOAN.Service/MES/base/IService/IBaseMaterialListService.cs @@ -13,7 +13,7 @@ namespace DOAN.Service.MES.base_.IService /// public interface IBaseMaterialListService : IBaseService { - PagedInfo GetList(BaseMaterialListQueryDto parm); + PagedInfo GetList(BaseMaterialListQueryDto parm); BaseMaterialList GetInfo(string Id);