From f823dfb7eb29ef7ec8b9900f17fe357c91792502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E6=A2=93=E5=BD=AD?= Date: Mon, 18 May 2026 11:49:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=81=E4=B9=A6=E5=8D=95=E4=BD=8D=E8=B5=8B?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Event/EventScoreService.cs | 52 +++++++++++++++---- YD_Event.Application/YD_Event.Application.xml | 4 +- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/YD_Event.Application/Event/EventScoreService.cs b/YD_Event.Application/Event/EventScoreService.cs index 310a26d..4dd2124 100644 --- a/YD_Event.Application/Event/EventScoreService.cs +++ b/YD_Event.Application/Event/EventScoreService.cs @@ -850,6 +850,22 @@ public class EventScoreService : BaseService, ITransient }) .ToListAsync(); + // 预加载所有相关的单位认证数据 + var merchantCertIds = allPersonsWithTeam + .Where(p => p.MerchantCertificationId.HasValue) + .Select(p => p.MerchantCertificationId.Value) + .Distinct() + .ToList(); + + Dictionary merchantNameDict = new Dictionary(); + if (merchantCertIds.Any()) + { + var merchantCerts = await _merchantCertificationRepository.AsQueryable() + .Where(mc => merchantCertIds.Contains(mc.Id) && !mc.DeleteMark) + .ToListAsync(); + merchantNameDict = merchantCerts.ToDictionary(mc => mc.Id, mc => mc.MerchantName); + } + // 处理 PersonIds:将负的 Id 转换为 UserId,然后尝试找到或创建对应的 EventRegistrationPerson var processedPersonIds = new List(); var userIdToNewPersonId = new Dictionary(); @@ -1135,8 +1151,16 @@ public class EventScoreService : BaseService, ITransient isNewCert = true; } + // 获取单位名称 + string unitName = string.Empty; + if (person.MerchantCertificationId.HasValue && + merchantNameDict.TryGetValue(person.MerchantCertificationId.Value, out var merchantName)) + { + unitName = merchantName; + } + // 构建占位符数据(传递合并后的姓名) - var placeholderData = BuildPlaceholderData(person.Person, resultRecord, combinedNames); + var placeholderData = BuildPlaceholderData(person.Person, resultRecord, unitName, combinedNames); // 生成 PDF 证书 try @@ -1200,8 +1224,16 @@ public class EventScoreService : BaseService, ITransient isNewCert = true; } + // 获取单位名称 + string unitName = string.Empty; + if (person.MerchantCertificationId.HasValue && + merchantNameDict.TryGetValue(person.MerchantCertificationId.Value, out var merchantName)) + { + unitName = merchantName; + } + // 构建占位符数据(教练/领队没有成绩记录) - var placeholderData = BuildPlaceholderDataForCoachLeader(person.Person); + var placeholderData = BuildPlaceholderDataForCoachLeader(person.Person, unitName); // 生成 PDF 证书 try @@ -1288,7 +1320,7 @@ public class EventScoreService : BaseService, ITransient /// /// 构建运动员占位符数据 /// - private Dictionary BuildPlaceholderData(EventRegistrationPerson person, EventResult result, string combinedNames = null) + private Dictionary BuildPlaceholderData(EventRegistrationPerson person, EventResult result, string unitName, string combinedNames = null) { var displayName = string.IsNullOrEmpty(combinedNames) ? person.Name : combinedNames; var data = new Dictionary @@ -1304,9 +1336,9 @@ public class EventScoreService : BaseService, ITransient ["成绩"] = result.Score, ["rank"] = result.Rank.ToString(), ["名次"] = GetRankText(result.Rank), - ["danwei"] = person.ProjectName ?? "个人", - ["单位"] = "上海跃动文化科技有限公司", - ["参赛单位"] = "上海跃动文化科技有限公司" + ["danwei"] = unitName ?? "个人", + ["单位"] = unitName ?? "个人", + ["参赛单位"] = unitName ?? "个人" }; // 添加日期信息 @@ -1323,7 +1355,7 @@ public class EventScoreService : BaseService, ITransient /// /// 构建教练/领队占位符数据 /// - private Dictionary BuildPlaceholderDataForCoachLeader(EventRegistrationPerson person) + private Dictionary BuildPlaceholderDataForCoachLeader(EventRegistrationPerson person, string unitName) { var data = new Dictionary { @@ -1332,9 +1364,9 @@ public class EventScoreService : BaseService, ITransient ["group"] = person.GroupName, ["组别"] = person.GroupName, ["项目组别"] = person.GroupName, - ["danwei"] = person.ProjectName ?? "个人", - ["单位"] = person.ProjectName ?? "个人", - ["参赛单位"] = person.ProjectName ?? "个人" + ["danwei"] = unitName ?? "个人", + ["单位"] = unitName ?? "个人", + ["参赛单位"] = unitName ?? "个人" }; // 添加日期信息 diff --git a/YD_Event.Application/YD_Event.Application.xml b/YD_Event.Application/YD_Event.Application.xml index f5f573e..8c9f53f 100644 --- a/YD_Event.Application/YD_Event.Application.xml +++ b/YD_Event.Application/YD_Event.Application.xml @@ -8873,12 +8873,12 @@ 页面类型:1-运动员页面,2-教练页面,3-领队页面 允许的人员类型列表 - + 构建运动员占位符数据 - + 构建教练/领队占位符数据