From fe17d0008e295a89ed6d16610b7a108e0b6bddd5 Mon Sep 17 00:00:00 2001 From: zhangxiaofeng <1939543722@qq.com> Date: Wed, 3 Jul 2024 08:48:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/OrderController.cs | 59 ++++++++++++------- .../Extensions/PagedQueryableExtensions.cs | 2 +- 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/EntrustSettle.Api/Controllers/OrderController.cs b/EntrustSettle.Api/Controllers/OrderController.cs index ed142d9..802529f 100644 --- a/EntrustSettle.Api/Controllers/OrderController.cs +++ b/EntrustSettle.Api/Controllers/OrderController.cs @@ -85,12 +85,16 @@ namespace EntrustSettle.Api.Controllers } } - // 运踪筛选条件 - List queryBilltraceGidList = null; + // 可以查看所有数据的用户Gid列表 + var seeAllDataUserGids = AppSettings.app("Startup", "SeeAllDataUserGids"); + + PageModel result; + if (input.BillTraceState != null || input.AtaStart != null || input.AtaEnd != null) { var billtraceGidPageList = await billtraceService.AsQueryable() - .Where(x => x.IsOuter == true && x.CompID == App.User.CompanyId) + .Where(x => x.IsOuter == true) + .WhereIF(!seeAllDataUserGids.Contains(App.User.ID) && input.QueryType != 2, x => x.CompID == App.User.CompanyId) .WhereIF(input.BillTraceState == 1, x => x.StaCangDan == "Y") .WhereIF(input.BillTraceState == 2, x => x.StaHaiGuan == "Y") .WhereIF(input.BillTraceState == 3, x => x.StaTiHuo == "Y") @@ -101,25 +105,38 @@ namespace EntrustSettle.Api.Controllers .Select(x => x.GID) .ToPageListAsyncExtension(input.pageIndex, input.pageSize); - queryBilltraceGidList = billtraceGidPageList.data; + List queryBilltraceGidList = billtraceGidPageList.data; + + var tempResult = await orderService.AsQueryable() + .Where(x => queryBilltraceGidList.Contains(x.BilltraceGid)) + .WhereIF(!seeAllDataUserGids.Contains(App.User.ID) && input.QueryType != 2, x => x.CompanyId == App.User.CompanyId) // 衣国豪的账号在客户端也可以看全部数据 + .WhereIF(!string.IsNullOrWhiteSpace(input.Mblno), x => x.Mblno.Contains(input.Mblno)) + .WhereIF(!string.IsNullOrWhiteSpace(input.CompanyName), x => x.CompanyName.Contains(input.CompanyName)) + .WhereIF(!string.IsNullOrWhiteSpace(input.Remark), x => x.Remark.Contains(input.Remark)) + .WhereIF(input.ServiceType != null, x => x.ServiceType == input.ServiceType) + .WhereIF(input.Status != null, x => x.Status == (int)input.Status) + .WhereIF(input.CreateTimeStart != null, x => x.CreateTime >= input.CreateTimeStart) + .WhereIF(input.CreateTimeEnd != null, x => x.CreateTime <= input.CreateTimeEnd) + .Select() + .OrderBy("id desc") + .ToListAsync(); + result = new PageModel(input.pageIndex, billtraceGidPageList.dataCount, input.pageSize, tempResult); + } + else + { + result = await orderService.AsQueryable() + .WhereIF(!seeAllDataUserGids.Contains(App.User.ID) && input.QueryType != 2, x => x.CompanyId == App.User.CompanyId) // 衣国豪的账号在客户端也可以看全部数据 + .WhereIF(!string.IsNullOrWhiteSpace(input.Mblno), x => x.Mblno.Contains(input.Mblno)) + .WhereIF(!string.IsNullOrWhiteSpace(input.CompanyName), x => x.CompanyName.Contains(input.CompanyName)) + .WhereIF(!string.IsNullOrWhiteSpace(input.Remark), x => x.Remark.Contains(input.Remark)) + .WhereIF(input.ServiceType != null, x => x.ServiceType == input.ServiceType) + .WhereIF(input.Status != null, x => x.Status == (int)input.Status) + .WhereIF(input.CreateTimeStart != null, x => x.CreateTime >= input.CreateTimeStart) + .WhereIF(input.CreateTimeEnd != null, x => x.CreateTime <= input.CreateTimeEnd) + .Select() + .OrderBy("id desc") + .ToPageListAsyncExtension(input.pageIndex, input.pageSize); } - - // 可以查看所有数据的用户Gid列表 - var seeAllDataUserGids = AppSettings.app("Startup", "SeeAllDataUserGids"); - - PageModel result = await orderService.AsQueryable() - .WhereIF(!seeAllDataUserGids.Contains(App.User.ID) && input.QueryType != 2, x => x.CompanyId == App.User.CompanyId) // 衣国豪的账号在客户端也可以看全部数据 - .WhereIF(!string.IsNullOrWhiteSpace(input.Mblno), x => x.Mblno.Contains(input.Mblno)) - .WhereIF(!string.IsNullOrWhiteSpace(input.CompanyName), x => x.CompanyName.Contains(input.CompanyName)) - .WhereIF(!string.IsNullOrWhiteSpace(input.Remark), x => x.Remark.Contains(input.Remark)) - .WhereIF(input.ServiceType != null, x => x.ServiceType == input.ServiceType) - .WhereIF(input.Status != null, x => x.Status == (int)input.Status) - .WhereIF(input.CreateTimeStart != null, x => x.CreateTime >= input.CreateTimeStart) - .WhereIF(input.CreateTimeEnd != null, x => x.CreateTime <= input.CreateTimeEnd) - .WhereIF(queryBilltraceGidList != null, x => queryBilltraceGidList.Contains(x.BilltraceGid)) - .Select() - .OrderBy("id desc") - .ToPageListAsyncExtension(input.pageIndex, input.pageSize); //var sql = orderService.AsQueryable() //.WhereIF(!seeAllDataUserGids.Contains(App.User.ID) && input.QueryType != 2, x => x.CompanyId == App.User.CompanyId).ToSqlString(); diff --git a/EntrustSettle.Common/Extensions/PagedQueryableExtensions.cs b/EntrustSettle.Common/Extensions/PagedQueryableExtensions.cs index 72667b3..5bd062a 100644 --- a/EntrustSettle.Common/Extensions/PagedQueryableExtensions.cs +++ b/EntrustSettle.Common/Extensions/PagedQueryableExtensions.cs @@ -12,7 +12,7 @@ public static class PagedQueryableExtensions public static async Task> ToPageListAsyncExtension(this ISugarQueryable query, int pageIndex, int pageSize) { RefAsync totalCount = 0; - var data = await query.ToPageListAsync(pageIndex, pageSize, totalCount); + System.Collections.Generic.List data = await query.ToPageListAsync(pageIndex, pageSize, totalCount); return new PageModel(pageIndex, totalCount, pageSize, data); } } \ No newline at end of file