From 1225fbcf6dd197c39853e2cb0f70c7318836abcb Mon Sep 17 00:00:00 2001
From: zs <zhousong@weben-smart.com>
Date: 周一, 19 5月 2025 16:53:12 +0800
Subject: [PATCH] 仓库信息高级查询

---
 HIAWms/server/src/CMS.Plugin.HIAWms.Application/Implements/WmsPlaceAppService.cs |   68 ++++++++++++++++++++++++++++------
 1 files changed, 56 insertions(+), 12 deletions(-)

diff --git a/HIAWms/server/src/CMS.Plugin.HIAWms.Application/Implements/WmsPlaceAppService.cs b/HIAWms/server/src/CMS.Plugin.HIAWms.Application/Implements/WmsPlaceAppService.cs
index 69f8c26..864e7c2 100644
--- a/HIAWms/server/src/CMS.Plugin.HIAWms.Application/Implements/WmsPlaceAppService.cs
+++ b/HIAWms/server/src/CMS.Plugin.HIAWms.Application/Implements/WmsPlaceAppService.cs
@@ -4,6 +4,8 @@
 using CMS.Plugin.HIAWms.Domain.Shared.WmsPlaces;
 using CMS.Plugin.HIAWms.Domain.WmsPlaces;
 using CmsQueryExtensions;
+using CmsQueryExtensions.Extension;
+using System.Linq.Expressions;
 using System.Text.RegularExpressions;
 using Volo.Abp;
 using Volo.Abp.Application.Dtos;
@@ -32,8 +34,12 @@
         return ObjectMapper.Map<WmsPlace, WmsPlaceDto>(await _wmsplaceRepository.GetAsync(id));
     }
 
-    /// <inheritdoc />
-    public virtual async Task<PagedResultDto<WmsPlaceDto>> GetListAsync(GetWmsMaterialInfoInput input)
+    /// <summary> 
+    /// 鍒嗛〉鑾峰彇搴撲綅淇℃伅 
+    /// </summary> 
+    /// <param name="input"></param> 
+    /// <returns></returns> 
+    public virtual async Task<PagedResultDto<WmsPlaceDto>> GetListAsync(GetWmsPlaceInput input)
     {
         Check.NotNull(input, nameof(input));
 
@@ -42,14 +48,41 @@
             input.Sorting = nameof(WmsPlace.Sort);
         }
 
-        var specification = new WmsPlaceSpecification(input.Name);
-        var place = ObjectMapper.Map<GetWmsMaterialInfoInput, WmsPlace>(input);
-        var count = await _wmsplaceRepository.GetCountAsync(place,input.Filter, specification);
-        var list = await _wmsplaceRepository.GetListAsync(place, input.Sorting, input.MaxResultCount,  input.SkipCount, input.Filter, specification);
+        #region 鍔ㄦ�佹瀯閫犳煡璇㈡潯浠�  
+
+        //鍔ㄦ�佹瀯閫犳煡璇㈡潯浠�  
+        var whereConditions = DynamicGetQueryParams(input);
+
+        #endregion
+
+        var count = await _wmsplaceRepository.GetCountAsync(whereConditions);
+        var list = await _wmsplaceRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount);
 
         return new PagedResultDto<WmsPlaceDto>(count, ObjectMapper.Map<List<WmsPlace>, List<WmsPlaceDto>>(list));
     }
 
+    /// <summary>  
+    /// 鍔ㄦ�佹瀯閫犳煡璇㈡潯浠�  
+    /// </summary>  
+    /// <param name="input">杈撳叆鍙傛暟</param>  
+    /// <returns></returns>  
+    private FunReturnResultModel<Expression<Func<WmsPlace, bool>>> DynamicGetQueryParams(GetWmsPlaceInput input)
+    {
+        //鍔ㄦ�佹瀯閫犳煡璇㈡潯浠�  
+        var whereConditions = WhereConditionsExtensions.GetWhereConditions<WmsPlace, GetWmsPlaceInput>(input);
+        if (!whereConditions.IsSuccess)
+        {
+            throw new Exception("鍔ㄦ�佹瀯閫犳煡璇㈡潯浠跺け璐�:" + whereConditions.ErrMsg);
+        }
+
+        //涔熷彲鍐嶆鑷畾涔夋瀯寤烘煡璇㈡潯浠�  
+        Expression<Func<WmsPlace, bool>> extendExpression = a => a.IsDeleted == false;
+        // 浣跨敤 System.Linq.PredicateBuilder 鐨� And 
+        var pres = (System.Linq.Expressions.Expression<Func<WmsPlace, bool>>)(whereConditions.data);
+        whereConditions.data = System.Linq.PredicateBuilder.And(pres, extendExpression);
+
+        return whereConditions;
+    }
     /// <inheritdoc />
     public virtual async Task<WmsPlaceDto> CreateAsync(WmsPlaceCreateDto input)
     {
@@ -286,8 +319,12 @@
         }
     }
 
-    /// <inheritdoc />
-    public async Task<(Dictionary<string, object> Sheets, string FileName)> ExportAsync(GetWmsMaterialInfoInput input)
+    /// <summary> 
+    /// 瀵煎嚭搴撲綅淇℃伅 
+    /// </summary> 
+    /// <param name="input"></param> 
+    /// <returns></returns> 
+    public async Task<(Dictionary<string, object> Sheets, string FileName)> ExportAsync(GetWmsPlaceInput input)
     {
         Check.NotNull(input, nameof(input));
 
@@ -296,9 +333,16 @@
             input.Sorting = nameof(WmsPlace.Sort);
         }
 
-        var specification = new WmsPlaceSpecification(input.Name);
-        var place = ObjectMapper.Map<GetWmsMaterialInfoInput, WmsPlace>(input);
-        var list = await _wmsplaceRepository.GetListAsync(place, input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter, specification, includeDetails: true);
+        #region 鍔ㄦ�佹瀯閫犳煡璇㈡潯浠�  
+
+        //鍔ㄦ�佹瀯閫犳煡璇㈡潯浠�  
+        var whereConditions = DynamicGetQueryParams(input);
+
+        #endregion
+
+
+
+        var list = await _wmsplaceRepository.GetListAsync(whereConditions, input.Sorting, input.MaxResultCount, input.SkipCount, includeDetails: true);
         var result = ObjectMapper.Map<List<WmsPlace>, List<WmsPlaceDto>>(list);
 
         var sheets = new Dictionary<string, object>
@@ -306,7 +350,7 @@
             ["閰嶇疆"] = ExportHelper.ConvertListToExportData(result),
         };
 
-        var fileName = result.Count > 1 ? "WmsPlace鍒楄〃" : result.Count == 1 ? result.First()?.PlaceNo : "WmsPlace妯$増";
+        var fileName = "搴撲綅淇℃伅";
         return (sheets, fileName);
     }
 

--
Gitblit v1.9.3