From 452ec2a2e75264515a9b315d1965db3069433d82 Mon Sep 17 00:00:00 2001
From: bklLiudl <673013083@qq.com>
Date: 星期四, 11 七月 2024 08:31:48 +0800
Subject: [PATCH] 采购单据

---
 Wms/WMS.BLL/BllAsnServer/ProcurePlanServer.cs |   71 +++++++++++++----------------------
 1 files changed, 26 insertions(+), 45 deletions(-)

diff --git a/Wms/WMS.BLL/BllAsnServer/ProcurePlanServer.cs b/Wms/WMS.BLL/BllAsnServer/ProcurePlanServer.cs
index a446852..48381e9 100644
--- a/Wms/WMS.BLL/BllAsnServer/ProcurePlanServer.cs
+++ b/Wms/WMS.BLL/BllAsnServer/ProcurePlanServer.cs
@@ -5,6 +5,7 @@
 using System;
 using System.Collections.Generic;
 using System.Text;
+using System.Threading.Tasks;
 using WMS.BLL.LogServer;
 using WMS.DAL;
 using WMS.Entity.BllAsnEntity;
@@ -30,52 +31,32 @@
         /// <param name="model"></param>
         /// <param name="count"></param>
         /// <returns></returns>
-        public List<ProcurePlanNoticeDto> GetProcurePlanNoticeList(ProcurePlanNoticeVm model, out int count)
+        public async Task<List<ProcurePlanNoticeDto>> GetProcurePlanNoticeList(ProcurePlanNoticeVm model, RefAsync<int> count)
         {
-            string sqlString = string.Empty;
-            string sqlCount = string.Empty;
-            string sqlPub = string.Empty;
-            try
-            {
-                sqlCount += "SELECT DISTINCT COUNT(tb1.ID) FROM BllProcurePlanNotice AS tb1 ";
-                sqlString += "SELECT DISTINCT tb1.*,tb3.RealName as CreateUserName,tb4.RealName as UpdateUserName FROM BllProcurePlanNotice AS tb1 ";
-                sqlPub += "LEFT JOIN BllProcurePlanNoticeDetail AS tb2 ON tb1.Id = tb2.ParentId ";
-                sqlPub += "LEFT JOIN SysUserInfor AS tb3 ON tb1.CreateUser = tb3.Id ";
-                sqlPub += "LEFT JOIN SysUserInfor AS tb4 ON tb1.UpdateUser = tb4.Id ";
-                sqlPub += $"WHERE tb1.IsDel = '0' ";
-                sqlPub += $"AND tb2.SkuNo LIKE '%{model.SkuNo}%' AND tb2.SkuName LIKE '%{model.SkuName}%' ";
-                sqlPub += $"AND tb2.CustomerName  LIKE '%{model.CustomerName}%' ";
-                if (!string.IsNullOrEmpty(model.Status))
-                {
-                    sqlPub += $"AND tb1.Status = '{model.Status}' ";
-                }
-                if (!string.IsNullOrEmpty(model.StartTime))
-                {
-                    sqlPub += $"AND tb1.CreateTime >= '{model.StartTime}' ";
-                }
-                if (!string.IsNullOrEmpty(model.EndTime))
-                {
-                    sqlPub += $"AND tb1.CreateTime <= '{model.EndTime}' ";
-                }
-                sqlCount += sqlPub;
-                sqlPub += " order by tb1.Id desc ";
-                if (model.Page == 0)
-                {
-                    model.Page = 1;
-                }
-                sqlString += sqlPub + $" offset {((model.Page - 1) * model.Limit)} rows fetch next {model.Limit} rows only;";
-
-                var com = new Common();
-                count = com.GetRowCount(sqlCount);
-
-                var modelList = Db.Ado.SqlQuery<ProcurePlanNoticeDto>(sqlString);
-
-                return modelList;
-            }
-            catch (Exception ex)
-            {
-                throw ex;
-            }
+            var modelList = await Db.Queryable<BllProcurePlanNotice>()
+                .LeftJoin<BllProcurePlanNoticeDetail>((tb1, tb2) => tb1.Id == tb2.ParentId)
+                .LeftJoin<SysUserInfor>((tb1, tb2, tb3) => tb1.CreateUser == tb3.Id)
+                .LeftJoin<SysUserInfor>((tb1, tb2, tb3, tb4) => tb1.UpdateUser == tb4.Id)
+                .WhereIF(!string.IsNullOrWhiteSpace(model.Status), tb1 => tb1.Status == model.Status)
+                .WhereIF(!string.IsNullOrWhiteSpace(model.StartTime), tb1 => tb1.CreateTime >= Convert.ToDateTime(model.StartTime))
+                .WhereIF(!string.IsNullOrWhiteSpace(model.EndTime), tb1 => tb1.CreateTime <= Convert.ToDateTime(model.EndTime).AddDays(1))
+                .WhereIF(!string.IsNullOrWhiteSpace(model.SkuName), (tb1,tb2) => tb2.SkuName.Contains(model.SkuName))
+                .Where(tb1 => tb1.IsDel == "0")
+                .OrderByDescending(tb1 => tb1.Id)
+                .Distinct()
+                .Select((tb1, tb2, tb3, tb4) => new ProcurePlanNoticeDto() {
+                    Id = tb1.Id,
+                    Status = tb1.Status,
+                    OrderCode = tb1.OrderCode,
+                    UserName = tb1.UserName,
+                    CompleteTime = tb1.CompleteTime,
+                    CreateTime = tb1.CreateTime,
+                    CreateUserName = tb3.RealName,
+                    UpdateTime = tb1.UpdateTime.ToString(),
+                    UpdateUserName = tb4.RealName
+                }).ToPageListAsync(model.Page, model.Limit, count);
+             
+            return modelList;
         }
         /// <summary>
         /// 鑾峰彇閲囪喘鍗曟槑缁嗕俊鎭�

--
Gitblit v1.8.0