diff --git a/YLErpDAL/Modules/ClientModule/ClientQueryService.cs b/YLErpDAL/Modules/ClientModule/ClientQueryService.cs index 58f59b41..14edc1d4 100644 --- a/YLErpDAL/Modules/ClientModule/ClientQueryService.cs +++ b/YLErpDAL/Modules/ClientModule/ClientQueryService.cs @@ -1,4 +1,4 @@ -using Autofac.Features.Indexed; +using Autofac.Features.Indexed; using Autofac.Features.OwnedInstances; using BaseOUDAL; using ClosedXML; @@ -452,12 +452,23 @@ namespace YLErp.Modules.ClientModule clientLinq.ApprovalRole = roles.Where(x => x.Id == clientLinq.ProcessRoleId)?.FirstOrDefault()?.Name; if (clientLinq.ApprovalStatus == "审批中") { - if (clientLinq.auditLog.OptType.Contains("开户审批")) + // 添加空值检查并记录日志 + if (clientLinq.auditLog != null) { - clientLinq.ApprovalStatus = GetApprovalStatus(openProcessList.ToList(), clientLinq.ApprovalStatus, clientLinq.ApprovalOrderId, clientLinq.ProcessOrderBranch); + if (clientLinq.auditLog.OptType.Contains("开户审批")) + { + clientLinq.ApprovalStatus = GetApprovalStatus(openProcessList.ToList(), clientLinq.ApprovalStatus, clientLinq.ApprovalOrderId, clientLinq.ProcessOrderBranch); + } + else + { + clientLinq.ApprovalStatus = GetApprovalStatus(clientProcessList.ToList(), clientLinq.ApprovalStatus, clientLinq.ApprovalOrderId, clientLinq.ProcessOrderBranch); + } } else { + // 记录auditLog为空的情况,便于后续调试 + LogFactory.GetLogger("ClientQueryService").Error("ClientQueryService.SearchList: auditLog is null for client id: " + clientLinq.id + ", ApprovalOrderId: " + clientLinq.ApprovalOrderId + ", ProcessOrderBranch: " + clientLinq.ProcessOrderBranch + ", ApprovalStatus: " + clientLinq.ApprovalStatus); + // 当auditLog为空时,无法判断是否为开户审批,按一般审批流程处理 clientLinq.ApprovalStatus = GetApprovalStatus(clientProcessList.ToList(), clientLinq.ApprovalStatus, clientLinq.ApprovalOrderId, clientLinq.ProcessOrderBranch); } }