From 2b66f8389394b85a509b0805075f0cc55b18f049 Mon Sep 17 00:00:00 2001 From: git_rabbit Date: Sat, 20 Dec 2025 10:26:54 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4BarTender=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E5=B9=B6=E6=9B=B4=E6=96=B0=E6=95=B0=E6=8D=AE=E5=BA=93=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除了对BarTender的COM引用及相关代码逻辑,更新了 `appsettings.Development.json`中的数据库连接配置,替换为 新的远程服务器信息。新增`global.json`文件以指定.NET SDK 版本为8.0.416,确保项目运行环境一致性。保留了对NPOI和 QuestPDF的依赖支持。 切换数据库连接并移除BarTender依赖,锁定SDK版本 本次提交主要内容: - 数据库连接切换至 115.190.214.62,并同步更新代码生成连接字符串。 - 移除 BarTender 相关 COM 组件依赖及打印实现,PrintTicketsByTemplate 方法暂时返回 null。 - 新增 global.json,锁定 .NET SDK 版本为 8.0.416,确保开发环境一致性。 --- .../appsettings.Development.json | 6 +- DOAN.Service/DOAN.Service.csproj | 11 --- .../MES/Product/ProWorkorderService.cs | 89 ++++++++++--------- global.json | 6 ++ 4 files changed, 54 insertions(+), 58 deletions(-) create mode 100644 global.json diff --git a/DOAN.Admin.WebApi/appsettings.Development.json b/DOAN.Admin.WebApi/appsettings.Development.json index c14f0d2..08518f3 100644 --- a/DOAN.Admin.WebApi/appsettings.Development.json +++ b/DOAN.Admin.WebApi/appsettings.Development.json @@ -2,8 +2,8 @@ "dbConfigs": [ { // 远程测试服务器 - // "Conn": "Data Source=127.0.0.1;User ID=root;Password=123456;Initial Catalog=bzfm_mes;Port=3306", - "Conn": "Data Source=139.224.232.211;User ID=root;Password=doantech123;Initial Catalog=bzfm_mes;Port=3308", + // "Conn": "Data Source=127.0.0.1;User ID=root;Password=123456;Initial Catalog=bzfm_mes;Port=3306", + "Conn": "Data Source=115.190.214.62;User ID=bzfm_mes;Password=rSRGTzccN2ZQtnas;Initial Catalog=bzfm_mes;Port=3308", // "Conn": "Data Source=192.168.0.58;User ID=root;Password=123456;Initial Catalog=bzfm_mes;Port=3306", "DbType": 0, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3,PgSql = 4 "ConfigId": "0", //多租户唯一标识 @@ -14,7 +14,7 @@ //代码生成数据库配置 "CodeGenDbConfig": { //代码生成连接字符串,注意{dbName}为固定格式,不要填写数据库名 - "Conn": "Data Source=139.224.232.211;User ID=root;Password=doantech123;Initial Catalog={dbName};Port=3308", + "Conn": "Data Source=115.190.214.62;User ID=root;Password=rSRGTzccN2ZQtnas;Initial Catalog={dbName};Port=3308", "DbType": 0, "IsAutoCloseConnection": true, "DbName": "bzfm_mes" //代码生成默认连接数据库,Oracle库是实例的名称 diff --git a/DOAN.Service/DOAN.Service.csproj b/DOAN.Service/DOAN.Service.csproj index e609a5f..0bea15a 100644 --- a/DOAN.Service/DOAN.Service.csproj +++ b/DOAN.Service/DOAN.Service.csproj @@ -8,17 +8,6 @@ 1591 - - - tlbimp - 1 - 10 - d58562c1-e51b-11cf-8941-00a024a9083f - 0 - false - true - - diff --git a/DOAN.Service/MES/Product/ProWorkorderService.cs b/DOAN.Service/MES/Product/ProWorkorderService.cs index 383950d..34fcf9c 100644 --- a/DOAN.Service/MES/Product/ProWorkorderService.cs +++ b/DOAN.Service/MES/Product/ProWorkorderService.cs @@ -2,7 +2,7 @@ using System; using System.Data.Common; using System.Globalization; using System.Linq; -using BarTender; +//using BarTender; using DOAN.Infrastructure.Helper; using DOAN.Model; using DOAN.Model.MES.base_; @@ -1505,50 +1505,51 @@ namespace DOAN.Service.MES.product ProWorkorderExportDto param ) { - var dataList = await Context - .Queryable() - .Where(p => param.WorkorderArray.Contains(p.Workorder)) - .ToListAsync(); - if (dataList.Count == 0) - { - return new CustomException(500, "未找到匹配的工单数据"); - } - Application bartenderApp = null; - Format bartenderFormat = null; - try - { - bartenderApp = new Application { Visible = false }; - bartenderFormat = bartenderApp.Formats.Open(param.Path); - // 4. 遍历数据并打印 - foreach (var data in dataList) - { - bartenderFormat.SetNamedSubStringValue("workorder", data.Workorder); - bartenderFormat.SetNamedSubStringValue("stoveCode", data.StoveCode); - bartenderFormat.SetNamedSubStringValue("qty", data.PlanNum.ToString()); - await Task.Delay(500); - bartenderFormat.PrintOut(false, false); // 静默打印 - } + return null; + //var dataList = await Context + // .Queryable() + // .Where(p => param.WorkorderArray.Contains(p.Workorder)) + // .ToListAsync(); + //if (dataList.Count == 0) + //{ + // return new CustomException(500, "未找到匹配的工单数据"); + //} + //Application bartenderApp = null; + //Format bartenderFormat = null; + //try + //{ + // bartenderApp = new Application { Visible = false }; + // bartenderFormat = bartenderApp.Formats.Open(param.Path); + // // 4. 遍历数据并打印 + // foreach (var data in dataList) + // { + // bartenderFormat.SetNamedSubStringValue("workorder", data.Workorder); + // bartenderFormat.SetNamedSubStringValue("stoveCode", data.StoveCode); + // bartenderFormat.SetNamedSubStringValue("qty", data.PlanNum.ToString()); + // await Task.Delay(500); + // bartenderFormat.PrintOut(false, false); // 静默打印 + // } - return new CustomException(200, "标签打印成功"); - } - catch (Exception ex) - { - // 5. 错误处理(记录日志) - Console.WriteLine($"打印标签时出错: {ex.Message}"); - return new CustomException(500, $"打印标签失败: {ex.Message}"); - } - finally - { - // 6. 确保资源释放(逆序关闭) - if (bartenderFormat != null) - { - bartenderFormat.Close(BtSaveOptions.btDoNotSaveChanges); - } - if (bartenderApp != null) - { - bartenderApp.Quit(BtSaveOptions.btDoNotSaveChanges); - } - } + // return new CustomException(200, "标签打印成功"); + //} + //catch (Exception ex) + //{ + // // 5. 错误处理(记录日志) + // Console.WriteLine($"打印标签时出错: {ex.Message}"); + // return new CustomException(500, $"打印标签失败: {ex.Message}"); + //} + //finally + //{ + // // 6. 确保资源释放(逆序关闭) + // if (bartenderFormat != null) + // { + // bartenderFormat.Close(BtSaveOptions.btDoNotSaveChanges); + // } + // if (bartenderApp != null) + // { + // bartenderApp.Quit(BtSaveOptions.btDoNotSaveChanges); + // } + //} } } } diff --git a/global.json b/global.json new file mode 100644 index 0000000..1f74105 --- /dev/null +++ b/global.json @@ -0,0 +1,6 @@ +{ + "sdk": { + "version": "8.0.416", + "rollForward": "patch" + } +} \ No newline at end of file