feat: 新增打印任务相关功能并完善服务配置

1. 调整回调响应的Code字段类型为object以兼容更多返回值
2. 为JournalDto新增Url和QuestionNo属性
3. 为JournalPageTaskOutput新增Task字段并完善注释
4. 新增打印工作服务的发布、安装卸载脚本与README文档
5. 调整项目配置,添加运行时标识与资源拷贝配置
6. 优化程序启动逻辑,修复工作目录与日志路径问题
7. 简化日志配置,移除多余的Hangfire与AI配置项
8. 完善期刊删除逻辑,关联删除相关子数据
9. 新增期刊发布时的书页任务排序与回调地址补全逻辑
This commit is contained in:
glz
2026-07-01 10:56:18 +08:00
parent 87bc5c0e0c
commit eb4f09e391
12 changed files with 193 additions and 49 deletions

View File

@ -97,6 +97,7 @@ public class JournalPageTaskService(BaseRepository<Journal> journalRepository, O
JournalId = task.JournalId,
JournalPageId = task.JournalPageId,
No = task.No,
Task =task.Task,
Type = task.Type,
Points = task.Points,
GrowthPoint = task.GrowthPoint,

View File

@ -1,6 +1,7 @@
using Mapster;
using Microsoft.Extensions.Logging;
using QYZH.InteractiveMagazine.Common.Extensions;
using QYZH.InteractiveMagazine.Common.Helpers;
using QYZH.InteractiveMagazine.Infrastructure.OSS;
using QYZH.InteractiveMagazine.Infrastructure.RabbitMQ;
using QYZH.InteractiveMagazine.IService;
@ -225,19 +226,19 @@ public class JournalService(BaseRepository<JournalPage> JournalPageRepository,
await base.DeleteAsync(d => ids.Contains(d.Id));
await JournalPageRepository.DeleteAsync(d => ids.Contains(d.JournalId));
await JournalCatalogRepository.DeleteAsync(d => ids.Contains(d.JournalId));
// 先查询要删除的 JournalPageTask Id 列表
var taskIds = await JournalPageTaskRepository.Queryable()
.Where(d => ids.Contains(d.JournalId))
.Select(d => d.Id)
.ToListAsync();
// 删除 JournalPageTaskAnswer
if (taskIds.Any())
{
await JournalPageTaskAnswerRepository.DeleteAsync(d => taskIds.Contains(d.JournalPageTaskId));
}
// 再删除 JournalPageTask
await JournalPageTaskRepository.DeleteAsync(d => ids.Contains(d.JournalId));
return true;
@ -344,6 +345,13 @@ public class JournalService(BaseRepository<JournalPage> JournalPageRepository,
.Where(x => x.JournalId == id && !x.IsDeleted)
.OrderBy(x => x.PageNum)
.OrderBy(x => x.Sort)
.Select(x => new
{
x.Id,
x.PageNo,
x.Layout,
x.Url
})
.ToListAsync();
BusinessException.ThrowIf(pages.Count == 0, "书籍未添加任何书页,无法发布", ResultCode.UNPROCESSABLE_ENTITY);
@ -351,6 +359,22 @@ public class JournalService(BaseRepository<JournalPage> JournalPageRepository,
BusinessException.ThrowIf(!book.EndTime.HasValue, "发布结束时间不能为空", ResultCode.UNPROCESSABLE_ENTITY);
BusinessException.ThrowIf(book.EndTime < book.StartTime, "发布结束时间不能早于开始时间", ResultCode.UNPROCESSABLE_ENTITY);
var pageIds = pages.Select(x => x.Id).ToList();
var pageQuestions = await JournalPageTaskRepository.Queryable()
.Where(x => x.JournalId == id && pageIds.Contains(x.JournalPageId) && !x.IsDeleted)
.Select(x => new
{
x.JournalPageId,
x.Id,
x.No
})
.ToListAsync();
var questionIdsByPageId = pageQuestions
.GroupBy(x => x.JournalPageId)
.ToDictionary(
x => x.Key,
x => string.Join(',', x.OrderBy(q => ParseTaskNo(q.No)).Select(q => q.Id)));
var bookMessageSent = await rabbitMqService.SendAsync(new RabbitMQSendParam
{
Exchange = JournalExchange,
@ -377,7 +401,9 @@ public class JournalService(BaseRepository<JournalPage> JournalPageRepository,
BookId = id,
PageId = page.Id,
PageNo = page.PageNo,
Layout = page.Layout
Layout = page.Layout,
Url = DomainHelper.OssFullUrl(page.Url),
QuestionNo = questionIdsByPageId.GetValueOrDefault(page.Id) ?? string.Empty
}
});
BusinessException.ThrowIf(!pageMessageSent, $"发布书页消息发送失败PageId: {page.Id}", ResultCode.GLOBAL_ERROR);
@ -388,5 +414,16 @@ public class JournalService(BaseRepository<JournalPage> JournalPageRepository,
.SetColumns(s => s.UpdatedAt, DateTime.Now)
.Where(w => w.Id == id)
.ExecuteCommandAsync() > 0;
static (int First, int Second, int Third, int Fourth) ParseTaskNo(string? no)
{
var parts = no?.Split('-') ?? Array.Empty<string>();
return (GetNoPart(parts, 0), GetNoPart(parts, 1), GetNoPart(parts, 2), GetNoPart(parts, 3));
}
static int GetNoPart(string[] parts, int index)
{
return parts.Length > index && int.TryParse(parts[index], out var value) ? value : int.MaxValue;
}
}
}