From 12e1777f47bc6a88aee70973fc4a69f634e4c4c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Thu, 11 Apr 2024 10:49:33 +0800 Subject: [PATCH] TestResut2Res --- .../ViewModel/Request/QueryResultVM.cs | 22 ++++++++++- ProductionSystem_Service/TResult2Service.cs | 38 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/ProductionSystem_Model/ViewModel/Request/QueryResultVM.cs b/ProductionSystem_Model/ViewModel/Request/QueryResultVM.cs index 9a078c5..1a0daa4 100644 --- a/ProductionSystem_Model/ViewModel/Request/QueryResultVM.cs +++ b/ProductionSystem_Model/ViewModel/Request/QueryResultVM.cs @@ -1,4 +1,7 @@ -namespace ProductionSystem_Model.ViewModel.Request +using System; +using System.Collections.Generic; + +namespace ProductionSystem_Model.ViewModel.Request { public class QueryResultVM : BaseQuery { @@ -6,4 +9,21 @@ public string ProductCode { get; set; } } + + + public class TestResut2Vm : BaseQuery + { + public string ProductType { get; set; } + + public string ProductCode { get; set; } + + public string BeginTime { get; set; } + + public string EndTime { get; set; } + } + + + + + } diff --git a/ProductionSystem_Service/TResult2Service.cs b/ProductionSystem_Service/TResult2Service.cs index 46725ba..a7ce1b7 100644 --- a/ProductionSystem_Service/TResult2Service.cs +++ b/ProductionSystem_Service/TResult2Service.cs @@ -1,5 +1,9 @@ using ProductionSystem_Log; using ProductionSystem_Model.DbModel; +using ProductionSystem_Model.ViewModel.Request; + +using SqlSugar; + using System; using System.Collections.Generic; using System.Linq; @@ -37,5 +41,39 @@ namespace ProductionSystem_Service { return db.Queryable().Where(m => m.ProductType == productType && m.ProductBarcode == productBarcode).First(); } + + + public TestResut2Res Query(TestResut2Vm vm) + { + int totalRecord = 0; + var iq= db.Queryable(). + WhereIF(!string.IsNullOrEmpty(vm.ProductType), x => x.ProductType == vm.ProductType) + .WhereIF(!string.IsNullOrEmpty(vm.ProductCode),x=>x.ProductBarcode == vm.ProductCode) + .WhereIF(!string.IsNullOrEmpty(vm.BeginTime),x=>x.CreateTime>=Convert.ToDateTime(vm.BeginTime)) + .WhereIF(!string.IsNullOrEmpty(vm.EndTime),xy=> xy.CreateTime <= Convert.ToDateTime(vm.EndTime)) + .ToPageList(vm.PageIndex,vm.PageSize, ref totalRecord); + + + int totalPage = (totalRecord + vm.PageSize - 1) / vm.PageSize; + + + TestResut2Res testResut2Res = new TestResut2Res(); + testResut2Res.Total= totalPage; + testResut2Res.Data = iq; + testResut2Res.Next = totalPage > vm.PageIndex; + + return testResut2Res; + + + } + } + + public class TestResut2Res + { + public int Total { get; set; } + + public bool Next { get; set; } + public List Data + { get; set; } } }