From d64b68abdd17e2fc2f3f23c6ba57d2e72a85ec73 Mon Sep 17 00:00:00 2001 From: glz <694770232@qq.com> Date: Mon, 29 Jun 2026 10:39:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E3=80=81=E7=82=B9=E9=98=B5ID=E5=8F=8A?= =?UTF-8?q?=E6=89=93=E5=8D=B0=E5=B7=A5=E5=85=B7=E7=9B=B8=E5=85=B3=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 更新WebApi和WorkService的配置文件中的微信AppId、AppSecret 2. 修改WorkService的DotId配置为新的点阵ID 3. 新增打印工具所需的授权xml文件 4. 重构打印工具调用逻辑,修复路径问题并优化命令执行方式 --- .../appsettings.json | 4 +-- .../Consumers/AutoDotCodeConsumer.cs | 19 ++++++----- .../sublic_license_1761.211.21.48_10000.xml | 32 +++++++++++++++++++ .../appsettings.json | 2 +- 4 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 QYZH.InteractiveMagazine.WorkService/PrintToolV2.7/sublic_license_1761.211.21.48_10000.xml diff --git a/QYZH.InteractiveMagazine.WebApi/appsettings.json b/QYZH.InteractiveMagazine.WebApi/appsettings.json index d7f928a..259451a 100644 --- a/QYZH.InteractiveMagazine.WebApi/appsettings.json +++ b/QYZH.InteractiveMagazine.WebApi/appsettings.json @@ -22,8 +22,8 @@ "ClientProvidedName": "Custom connection name" }, "WeChatSettings": { - "AppId": "wx5d8f281c2fd6594c", - "AppSecret": "974f45e4a0aaa075278db0477d0bd8b6" + "AppId": "wx5d8f281c2fd6594c1", + "AppSecret": "974f45e4a0aaa075278db0477d0bd8b61" }, "Serilog": { "MinimumLevel": { diff --git a/QYZH.InteractiveMagazine.WorkService/Consumers/AutoDotCodeConsumer.cs b/QYZH.InteractiveMagazine.WorkService/Consumers/AutoDotCodeConsumer.cs index b867997..819fe15 100644 --- a/QYZH.InteractiveMagazine.WorkService/Consumers/AutoDotCodeConsumer.cs +++ b/QYZH.InteractiveMagazine.WorkService/Consumers/AutoDotCodeConsumer.cs @@ -16,6 +16,7 @@ namespace QYZH.InteractiveMagazine.WorkService.Consumers; /// public class AutoDotCodeConsumer(IConfiguration configuration, IServiceScopeFactory scopeFactory, + IWebHostEnvironment webHostEnvironment, ILogger logger, IHttpClientFactory httpClientFactory, OssService ossService @@ -78,7 +79,7 @@ public class AutoDotCodeConsumer(IConfiguration configuration, #region 调用铺码程序 // 从配置中获取点阵文件Id - var dotId = configuration.GetValue("PrintConfig:DotId", 683790963662917); + var dotId = configuration.GetValue("PrintConfig:DotId", 765837655859269); var dotfile = await dBContext.Queryable().FirstAsync(x => x.Id == dotId, cancellationToken); if (dotfile == null) @@ -87,9 +88,10 @@ public class AutoDotCodeConsumer(IConfiguration configuration, return; } - var exePath = AppDomain.CurrentDomain.BaseDirectory + "PrintToolV2.7\\PrintTool.exe"; + var printToolDirectory = Path.Combine(webHostEnvironment.ContentRootPath, "PrintToolV2.7"); + var exePath = Path.Combine(printToolDirectory, "PrintTool.exe"); - var xmlPath = AppDomain.CurrentDomain.BaseDirectory + $"PrintToolV2.7\\{dotfile.FileName}"; + var xmlPath = Path.Combine(printToolDirectory, dotfile.FileName); #region 注释说明 @@ -151,7 +153,8 @@ public class AutoDotCodeConsumer(IConfiguration configuration, // 从第一个开始执行,连续铺码N条(N为书籍页数) string pageStr = "{" + $"[{dotFileDetailList[0].PageName},{pageNumMax}]" + "}"; - var cmd = $"PrintTool.exe -sMode=Generate -sPDF={uploadFilePath} -sLIC={xmlPath} -pStart=1 -oPDF={downloadFilePath} -dPageAddr=1 -dPrint={dPrint} -dDotSize=40 -dType=0 -dOutFile=0 -dControlPageNum={pageStr}"; + var arguments = $"-sMode=Generate -sPDF=\"{uploadFilePath}\" -sLIC=\"{xmlPath}\" -pStart=1 -oPDF=\"{downloadFilePath}\" -dPageAddr=1 -dPrint={dPrint} -dDotSize=40 -dType=0 -dOutFile=0 -dControlPageNum={pageStr}"; + var cmd = $"\"{exePath}\" {arguments}"; logger.LogInformation($"执行PrintTool.exe 的命令: {cmd}"); @@ -160,9 +163,9 @@ public class AutoDotCodeConsumer(IConfiguration configuration, { p.StartInfo = new ProcessStartInfo { - WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory + "PrintToolV2.7", - FileName = "cmd.exe", - Arguments = "/c " + cmd, // /c参数表示执行后关闭 + WorkingDirectory = printToolDirectory, + FileName = exePath, + Arguments = arguments, UseShellExecute = false, //是否使用操作系统shell启动 RedirectStandardInput = true, //接受来自调用程序的输入信息 RedirectStandardOutput = true, //由调用程序获取输出信息 @@ -336,4 +339,4 @@ internal class CallbackUpdateJournalStatusResponse public bool Result { get; set; } public bool IsSuccess { get; set; } -} \ No newline at end of file +} diff --git a/QYZH.InteractiveMagazine.WorkService/PrintToolV2.7/sublic_license_1761.211.21.48_10000.xml b/QYZH.InteractiveMagazine.WorkService/PrintToolV2.7/sublic_license_1761.211.21.48_10000.xml new file mode 100644 index 0000000..1b75c8c --- /dev/null +++ b/QYZH.InteractiveMagazine.WorkService/PrintToolV2.7/sublic_license_1761.211.21.48_10000.xml @@ -0,0 +1,32 @@ + + + + + + + + + diff --git a/QYZH.InteractiveMagazine.WorkService/appsettings.json b/QYZH.InteractiveMagazine.WorkService/appsettings.json index a50d7b8..80e5596 100644 --- a/QYZH.InteractiveMagazine.WorkService/appsettings.json +++ b/QYZH.InteractiveMagazine.WorkService/appsettings.json @@ -68,6 +68,6 @@ //"CallBackApiUrl": "http://192.168.20.150:8000/api/icr/page/callbackupdatepageno", // 测试环境 打印成功回调API地址修改打印状态 //"CallBackApiUrl": "https://zyb.qyzhjy.com/zybback/api/icr/page/callbackupdatepageno", // 正式环境 打印成功回调API地址修改打印状态 //这个ID执行的xml文件是:sublic_license_1761.172.8.16_1000.xml,如果想执行sublic_license_1761.211.21.48_10000.xml 换成 765837655859269 ---暂时没有导入页码 - "DotId": 683790963662917 + "DotId": 765837655859269 } }