From 44709668c91a392dd0c346d6a15b07144ebf41ea Mon Sep 17 00:00:00 2001
From: zs <zhousong@weben-smart.com>
Date: 周三, 30 4月 2025 19:55:29 +0800
Subject: [PATCH] 库位条件查询

---
 HIAWms/server/src/CMS.Plugin.HIAWms.Application.Contracts/Dtos/WmsStores/GetWmsStoresInput.cs    |   10 ++++++++++
 HIAWms/server/src/CMS.Plugin.HIAWms.Domain/WmsStores/IWmsStoreRepository.cs                      |    4 ++--
 HIAWms/server/src/CMS.Plugin.HIAWms.EntityFrameworkCore/Repositories/EfCoreWmsStoreRepository.cs |    8 ++++++--
 HIAWms/server/src/CMS.Plugin.HIAWms.Application/Implements/WmsStoreAppService.cs                 |   13 ++++++++-----
 4 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/HIAWms/server/src/CMS.Plugin.HIAWms.Application.Contracts/Dtos/WmsStores/GetWmsStoresInput.cs b/HIAWms/server/src/CMS.Plugin.HIAWms.Application.Contracts/Dtos/WmsStores/GetWmsStoresInput.cs
index 37f3e7e..0d3d180 100644
--- a/HIAWms/server/src/CMS.Plugin.HIAWms.Application.Contracts/Dtos/WmsStores/GetWmsStoresInput.cs
+++ b/HIAWms/server/src/CMS.Plugin.HIAWms.Application.Contracts/Dtos/WmsStores/GetWmsStoresInput.cs
@@ -16,4 +16,14 @@
     /// Gets or sets the name.
     /// </summary>
     public string Name { get; set; }
+
+    /// <summary>
+    /// 浠撳簱浠g爜
+    /// </summary>
+    public string? StoreCode { get; set; }
+
+    /// <summary>
+    /// 浠撳簱鍚嶇О
+    /// </summary>
+    public string? StoreName { get; set; }
 }
diff --git a/HIAWms/server/src/CMS.Plugin.HIAWms.Application/Implements/WmsStoreAppService.cs b/HIAWms/server/src/CMS.Plugin.HIAWms.Application/Implements/WmsStoreAppService.cs
index ae4d559..522c3b5 100644
--- a/HIAWms/server/src/CMS.Plugin.HIAWms.Application/Implements/WmsStoreAppService.cs
+++ b/HIAWms/server/src/CMS.Plugin.HIAWms.Application/Implements/WmsStoreAppService.cs
@@ -7,6 +7,7 @@
 using Volo.Abp.Application.Dtos;
 using Volo.Abp.Data;
 using Volo.Abp.ObjectExtending;
+using CMS.Plugin.HIAWms.Domain.Shared.Util;
 
 namespace CMS.Plugin.HIAWms.Application.Implements;
 
@@ -41,8 +42,9 @@
         }
 
         var specification = new WmsStoreSpecification(input.Name);
-        var count = await _wmsstoreRepository.GetCountAsync(input.Filter, specification);
-        var list = await _wmsstoreRepository.GetListAsync(input.Sorting, input.MaxResultCount,  input.SkipCount, input.Filter, specification);
+        var store = ObjectMapper.Map<GetWmsStoresInput, WmsStore>(input);
+        var count = await _wmsstoreRepository.GetCountAsync(store,input.Filter, specification);
+        var list = await _wmsstoreRepository.GetListAsync(store,input.Sorting, input.MaxResultCount,  input.SkipCount, input.Filter, specification);
 
         return new PagedResultDto<WmsStoreDto>(count, ObjectMapper.Map<List<WmsStore>, List<WmsStoreDto>>(list));
     }
@@ -150,7 +152,7 @@
     /// <inheritdoc />
     public virtual async Task AdjustSortAsync(Guid id, int sort)
     {
-        var list = await _wmsstoreRepository.GetListAsync(nameof(WmsStore.Sort));
+        var list = await _wmsstoreRepository.GetListAsync(null,nameof(WmsStore.Sort));
         if (list != null && list.Any())
         {
             var initSort = 1;
@@ -283,12 +285,13 @@
         }
 
         var specification = new WmsStoreSpecification(input.Name);
-        var list = await _wmsstoreRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter, specification, includeDetails: true);
+        var store = ObjectMapper.Map<GetWmsStoresInput, WmsStore>(input);
+        var list = await _wmsstoreRepository.GetListAsync(store, input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter, specification, includeDetails: true);
         var result = ObjectMapper.Map<List<WmsStore>, List<WmsStoreDto>>(list);
 
         var sheets = new Dictionary<string, object>
         {
-            ["閰嶇疆"] = result.Select(x => x.GetExportData()).ToList(),
+            ["閰嶇疆"] = ExportHelper.ConvertListToExportData(result),
         };
 
         var fileName = result.Count > 1 ? "WmsStore鍒楄〃" : result.Count == 1 ? result.First()?.StoreCode : "WmsStore妯$増";
diff --git a/HIAWms/server/src/CMS.Plugin.HIAWms.Domain/WmsStores/IWmsStoreRepository.cs b/HIAWms/server/src/CMS.Plugin.HIAWms.Domain/WmsStores/IWmsStoreRepository.cs
index ca8f8d6..8796ec5 100644
--- a/HIAWms/server/src/CMS.Plugin.HIAWms.Domain/WmsStores/IWmsStoreRepository.cs
+++ b/HIAWms/server/src/CMS.Plugin.HIAWms.Domain/WmsStores/IWmsStoreRepository.cs
@@ -41,7 +41,7 @@
     /// <param name="includeDetails">if set to <c>true</c> [include details].</param>
     /// <param name="cancellationToken">The cancellation token.</param>
     /// <returns></returns>
-    Task<List<WmsStore>> GetListAsync(string sorting = null, int maxResultCount = int.MaxValue,  int skipCount = 0, string filter = null, Specification<WmsStore> specification = null, bool includeDetails = false, CancellationToken cancellationToken = default);
+    Task<List<WmsStore>> GetListAsync(WmsStore? store, string sorting = null, int maxResultCount = int.MaxValue,  int skipCount = 0, string filter = null, Specification<WmsStore> specification = null, bool includeDetails = false, CancellationToken cancellationToken = default);
 
     /// <summary>
     /// Gets the count asynchronous.
@@ -50,5 +50,5 @@
     /// <param name="specification">The specification.</param>
     /// <param name="cancellationToken">The cancellation token.</param>
     /// <returns></returns>
-    Task<long> GetCountAsync(string filter = null, Specification<WmsStore> specification = null, CancellationToken cancellationToken = default);
+    Task<long> GetCountAsync(WmsStore? store, string filter = null, Specification<WmsStore> specification = null, CancellationToken cancellationToken = default);
 }
diff --git a/HIAWms/server/src/CMS.Plugin.HIAWms.EntityFrameworkCore/Repositories/EfCoreWmsStoreRepository.cs b/HIAWms/server/src/CMS.Plugin.HIAWms.EntityFrameworkCore/Repositories/EfCoreWmsStoreRepository.cs
index e08ffe5..cbfdde4 100644
--- a/HIAWms/server/src/CMS.Plugin.HIAWms.EntityFrameworkCore/Repositories/EfCoreWmsStoreRepository.cs
+++ b/HIAWms/server/src/CMS.Plugin.HIAWms.EntityFrameworkCore/Repositories/EfCoreWmsStoreRepository.cs
@@ -52,7 +52,7 @@
     }
 
     /// <inheritdoc />
-    public async Task<List<WmsStore>> GetListAsync(string sorting = null, int maxResultCount = int.MaxValue, int skipCount = 0, string filter = null, Specification<WmsStore> specification = null, bool includeDetails = false, CancellationToken cancellationToken = default)
+    public async Task<List<WmsStore>> GetListAsync(WmsStore? store, string sorting = null, int maxResultCount = int.MaxValue, int skipCount = 0, string filter = null, Specification<WmsStore> specification = null, bool includeDetails = false, CancellationToken cancellationToken = default)
     {
         specification ??= new WmsStoreSpecification();
         return await (await GetDbSetAsync())
@@ -60,19 +60,23 @@
             .Where(specification.ToExpression())
             .Where(x => !x.IsDeleted)
             .WhereIf(!filter.IsNullOrWhiteSpace(), u => u.StoreCode.Contains(filter))
+            .WhereIf(!string.IsNullOrEmpty(store.StoreCode),u=>u.StoreCode.Contains(store.StoreCode))
+            .WhereIf(!string.IsNullOrEmpty(store.StoreName),u=>u.StoreName.Contains(store.StoreName))
             .OrderBy(sorting.IsNullOrEmpty() ? nameof(WmsStore.Sort) : sorting)
             .PageBy(skipCount, maxResultCount)
             .ToListAsync(GetCancellationToken(cancellationToken));
     }
 
     /// <inheritdoc />
-    public async Task<long> GetCountAsync(string filter = null, Specification<WmsStore> specification = null, CancellationToken cancellationToken = default)
+    public async Task<long> GetCountAsync(WmsStore? store, string filter = null, Specification<WmsStore> specification = null, CancellationToken cancellationToken = default)
     {
         specification ??= new WmsStoreSpecification();
         return await (await GetQueryableAsync())
             .Where(specification.ToExpression())
             .Where(x => !x.IsDeleted)
             .WhereIf(!filter.IsNullOrWhiteSpace(), u => u.StoreCode.Contains(filter))
+            .WhereIf(!string.IsNullOrEmpty(store.StoreCode), u => u.StoreCode.Contains(store.StoreCode))
+            .WhereIf(!string.IsNullOrEmpty(store.StoreName), u => u.StoreName.Contains(store.StoreName))
             .CountAsync(cancellationToken: GetCancellationToken(cancellationToken));
     }
 

--
Gitblit v1.9.3