From a6bd05dffcc8c5eba260915c84c889bd2760ac61 Mon Sep 17 00:00:00 2001 From: zzj <31836194@qq.com> Date: Wed, 24 Jan 2024 10:52:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=A1=A8=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Gz_Amounts/Gz_AmountsService.cs | 64 +++++++++++-------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/Gz_Amounts/Gz_AmountsService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/Gz_Amounts/Gz_AmountsService.cs index 5ade36507..b0f6b55ba 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/Gz_Amounts/Gz_AmountsService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/PersonnelManagement/Gz_Amounts/Gz_AmountsService.cs @@ -342,43 +342,51 @@ namespace Learun.Application.TwoDevelopment.PersonnelManagement var items = this.BaseRepository("CollegeMIS").FindList(x => x.IsShow == true).ToList(); - var xmId = items.FirstOrDefault(x => x.Name == "职员姓名").Id; - var deptCodeId = items.FirstOrDefault(x => x.Name == "部门代码").Id; - var deptId = items.FirstOrDefault(x => x.Name == "部门名称").Id; - var ptcId = items.FirstOrDefault(x => x.Name == "职员类型代码").Id; - var ptId = items.FirstOrDefault(x => x.Name == "职员类型").Id; - var sendId = items.FirstOrDefault(x => x.Name == "发放时间").Id; - var sendCountId = items.FirstOrDefault(x => x.Name == "发放次数").Id; - var kchjId = items.FirstOrDefault(x => x.Name == "扣款合计").Id; - var sfhjId = items.FirstOrDefault(x => x.Name == "实发合计").Id; - var bzId = items.FirstOrDefault(x => x.Name == "备注").Id; - var shrId = items.FirstOrDefault(x => x.Name == "审核人").Id; + if (items.Any()) + { + var xmId = items.FirstOrDefault(x => x.Name == "职员姓名").Id; + var deptCodeId = items.FirstOrDefault(x => x.Name == "部门代码").Id; + var deptId = items.FirstOrDefault(x => x.Name == "部门名称").Id; + var ptcId = items.FirstOrDefault(x => x.Name == "职员类型代码").Id; + var ptId = items.FirstOrDefault(x => x.Name == "职员类型").Id; + var sendId = items.FirstOrDefault(x => x.Name == "发放时间").Id; + var sendCountId = items.FirstOrDefault(x => x.Name == "发放次数").Id; + var kchjId = items.FirstOrDefault(x => x.Name == "扣款合计").Id; + var sfhjId = items.FirstOrDefault(x => x.Name == "实发合计").Id; + var bzId = items.FirstOrDefault(x => x.Name == "备注").Id; + var shrId = items.FirstOrDefault(x => x.Name == "审核人").Id; - var itemId = items.Select(x => x.Id).ToArray(); + var itemId = items.Select(x => x.Id).ToArray(); - var q = this.BaseRepository("CollegeMIS").FindList(x => itemId.Contains(x.ItemId) && ((yearStart == yearEnd && x.Year == yearStart && x.Month >= monthStart && x.Month <= monthEnd) || (yearStart < yearEnd && (x.Year == yearStart && x.Month >= monthStart) || (x.Year == yearEnd && x.Month <= monthEnd) || (x.Year > yearStart && x.Year < yearEnd)))); + var q = this.BaseRepository("CollegeMIS").FindList(x => itemId.Contains(x.ItemId) && ((yearStart == yearEnd && x.Year == yearStart && x.Month >= monthStart && x.Month <= monthEnd) || (yearStart < yearEnd && (x.Year == yearStart && x.Month >= monthStart) || (x.Year == yearEnd && x.Month <= monthEnd) || (x.Year > yearStart && x.Year < yearEnd)))); - var query = q.GroupBy(x => new { x.UserNo, x.Year, x.Month }); - pagination.records = query.Count(); + var query = q.GroupBy(x => new { x.UserNo, x.Year, x.Month }); + pagination.records = query.Count(); - var ls = query.Select(x => new Gz_AmountsCols { UserNo = x.Key.UserNo, Year = x.Key.Year ?? 0, Month = x.Key.Month ?? 0, RealName = x.FirstOrDefault(a => a.ItemId == xmId)?.OriVal ?? "", DeptCode = x.FirstOrDefault(a => a.ItemId == deptCodeId)?.OriVal ?? "", DeptName = x.FirstOrDefault(a => a.ItemId == deptId)?.OriVal ?? "", PersonTypeCode = x.FirstOrDefault(a => a.ItemId == ptcId)?.OriVal ?? "", PersonType = x.FirstOrDefault(a => a.ItemId == ptId)?.OriVal ?? "", SendDate = x.FirstOrDefault(a => a.ItemId == sendId)?.OriVal ?? "", SendCount = x.FirstOrDefault(a => a.ItemId == sendCountId)?.OriVal ?? "", TotalDeduction = x.FirstOrDefault(a => a.ItemId == kchjId)?.OriVal ?? "", TotalSend = x.FirstOrDefault(a => a.ItemId == sfhjId)?.OriVal ?? "", TotalSendDecimal = x.FirstOrDefault(a => a.ItemId == sfhjId)?.Amount ?? 0, Remark = x.FirstOrDefault(a => a.ItemId == bzId)?.OriVal ?? "", Reviewer = x.FirstOrDefault(a => a.ItemId == shrId)?.OriVal ?? "" }); + var ls = query.Select(x => new Gz_AmountsCols { UserNo = x.Key.UserNo, Year = x.Key.Year ?? 0, Month = x.Key.Month ?? 0, RealName = x.FirstOrDefault(a => a.ItemId == xmId)?.OriVal ?? "", DeptCode = x.FirstOrDefault(a => a.ItemId == deptCodeId)?.OriVal ?? "", DeptName = x.FirstOrDefault(a => a.ItemId == deptId)?.OriVal ?? "", PersonTypeCode = x.FirstOrDefault(a => a.ItemId == ptcId)?.OriVal ?? "", PersonType = x.FirstOrDefault(a => a.ItemId == ptId)?.OriVal ?? "", SendDate = x.FirstOrDefault(a => a.ItemId == sendId)?.OriVal ?? "", SendCount = x.FirstOrDefault(a => a.ItemId == sendCountId)?.OriVal ?? "", TotalDeduction = x.FirstOrDefault(a => a.ItemId == kchjId)?.OriVal ?? "", TotalSend = x.FirstOrDefault(a => a.ItemId == sfhjId)?.OriVal ?? "", TotalSendDecimal = x.FirstOrDefault(a => a.ItemId == sfhjId)?.Amount ?? 0, Remark = x.FirstOrDefault(a => a.ItemId == bzId)?.OriVal ?? "", Reviewer = x.FirstOrDefault(a => a.ItemId == shrId)?.OriVal ?? "" }); - if (!qj["keyword"].IsEmpty()) - { - var k = qj["keyword"].ToString(); - ls = ls.Where(x => x.UserNo.Contains(k) || x.RealName.Contains(k)); + if (!qj["keyword"].IsEmpty()) + { + var k = qj["keyword"].ToString(); + ls = ls.Where(x => x.UserNo.Contains(k) || x.RealName.Contains(k)); + } + if (!qj["department"].IsEmpty()) + { + var dept = qj["department"].ToString(); + ls = ls.Where(x => x.DeptCode == dept); + } + + totalSend = ls.Sum(x => x.TotalSendDecimal); + + var rs = ls.Skip(skip).Take(pagination.rows); + return rs; } - if (!qj["department"].IsEmpty()) + else { - var dept = qj["department"].ToString(); - ls = ls.Where(x => x.DeptCode == dept); + totalSend = 0; + return new List(); } - totalSend = ls.Sum(x => x.TotalSendDecimal); - - var rs = ls.Skip(skip).Take(pagination.rows); - return rs; - } catch (Exception ex) {