fix: 显式注册面单 PDF 服务与 ILabelPdfRenderer,修复打印激活失败

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zzh 2026-07-18 19:19:44 +08:00
parent 8929ebc5b3
commit e1f40ce36c
4 changed files with 10 additions and 6 deletions

View File

@ -1,14 +1,13 @@
using System.Globalization;
using System.Text.Json;
using Fake.Application;
using Fake.DependencyInjection;
namespace Oms.Application.Labeling.Hiprint;
/// <summary>
/// 将 hiprint TemplateJson 转为中间绘制 IR。
/// </summary>
public sealed class HiprintTemplateParser : ITransientDependency
public sealed class HiprintTemplateParser
{
private static readonly JsonSerializerOptions JsonOptions = new()
{

View File

@ -1,4 +1,3 @@
using Fake.DependencyInjection;
using QuestPDF.Fluent;
using QuestPDF.Helpers;
using QuestPDF.Infrastructure;
@ -8,7 +7,7 @@ namespace Oms.Application.Labeling.Hiprint;
/// <summary>
/// QuestPDF 实现的面单渲染器。
/// </summary>
public sealed class QuestPdfLabelRenderer(HiprintTemplateParser parser) : ILabelPdfRenderer, ITransientDependency
public sealed class QuestPdfLabelRenderer(HiprintTemplateParser parser) : ILabelPdfRenderer
{
private static int _licenseConfigured;

View File

@ -1,5 +1,4 @@
using Fake.Application;
using Fake.DependencyInjection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
using Oms.Application.Dtos.Orders;
@ -22,7 +21,7 @@ public sealed class LabelPdfGenerationService(
ISystemOtherConfigRepository systemOtherConfigRepository,
IOrderRepository orderRepository,
IWebHostEnvironment webHostEnvironment,
ILogger<LabelPdfGenerationService> logger) : ITransientDependency
ILogger<LabelPdfGenerationService> logger)
{
public async Task<LabelPdfGenerateResult> GenerateAndPersistAsync(
Order order,

View File

@ -10,6 +10,8 @@ using Oms.Application.Helpers;
using Oms.Application.Integrations.SmallBagTrack;
using Oms.Application.Integrations.Itfx;
using Oms.Application.Integrations.PlatformShop;
using Oms.Application.Labeling;
using Oms.Application.Labeling.Hiprint;
using Oms.Application.Shared;
using Oms.Application.Workers;
using Oms.Domain;
@ -52,6 +54,11 @@ public class OmsApplicationModule : FakeModule
RedisHelper.Init(redisOptions, showLogInfo: Debugger.IsAttached);
// 面单 PDF:显式注册接口,避免约定注册未暴露 ILabelPdfRenderer 导致激活失败
context.Services.AddTransient<HiprintTemplateParser>();
context.Services.AddTransient<ILabelPdfRenderer, QuestPdfLabelRenderer>();
context.Services.AddTransient<LabelPdfGenerationService>();
context.Services.AddOmsSmallBagTrack(configuration);
context.Services.AddOmsItfxIntegration(configuration);
context.Services.AddOmsPlatformShopIntegration(configuration);