Bartender调整

This commit is contained in:
2025-12-29 08:25:14 +08:00
parent 1bbe7c3549
commit aa217ab03e
2 changed files with 55 additions and 45 deletions

View File

@@ -8,6 +8,17 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<NoWarn>1591</NoWarn> <NoWarn>1591</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<COMReference Include="BarTender">
<WrapperTool>tlbimp</WrapperTool>
<VersionMinor>1</VersionMinor>
<VersionMajor>10</VersionMajor>
<Guid>d58562c1-e51b-11cf-8941-00a024a9083f</Guid>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="NPOI" Version="2.7.2" /> <PackageReference Include="NPOI" Version="2.7.2" />
<PackageReference Include="QuestPDF" Version="2024.12.1" /> <PackageReference Include="QuestPDF" Version="2024.12.1" />

View File

@@ -2,7 +2,7 @@ using System;
using System.Data.Common; using System.Data.Common;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
//using BarTender; using BarTender;
using DOAN.Infrastructure.Helper; using DOAN.Infrastructure.Helper;
using DOAN.Model; using DOAN.Model;
using DOAN.Model.MES.base_; using DOAN.Model.MES.base_;
@@ -1505,51 +1505,50 @@ namespace DOAN.Service.MES.product
ProWorkorderExportDto param ProWorkorderExportDto param
) )
{ {
return null; var dataList = await Context
//var dataList = await Context .Queryable<ProWorkorder>()
// .Queryable<ProWorkorder>() .Where(p => param.WorkorderArray.Contains(p.Workorder))
// .Where(p => param.WorkorderArray.Contains(p.Workorder)) .ToListAsync();
// .ToListAsync(); if (dataList.Count == 0)
//if (dataList.Count == 0) {
//{ return new CustomException(500, "未找到匹配的工单数据");
// return new CustomException(500, "未找到匹配的工单数据"); }
//} Application bartenderApp = null;
//Application bartenderApp = null; Format bartenderFormat = null;
//Format bartenderFormat = null; try
//try {
//{ bartenderApp = new Application { Visible = false };
// bartenderApp = new Application { Visible = false }; bartenderFormat = bartenderApp.Formats.Open(param.Path);
// bartenderFormat = bartenderApp.Formats.Open(param.Path); // 4. 遍历数据并打印
// // 4. 遍历数据并打印 foreach (var data in dataList)
// foreach (var data in dataList) {
// { bartenderFormat.SetNamedSubStringValue("workorder", data.Workorder);
// bartenderFormat.SetNamedSubStringValue("workorder", data.Workorder); bartenderFormat.SetNamedSubStringValue("stoveCode", data.StoveCode);
// bartenderFormat.SetNamedSubStringValue("stoveCode", data.StoveCode); bartenderFormat.SetNamedSubStringValue("qty", data.PlanNum.ToString());
// bartenderFormat.SetNamedSubStringValue("qty", data.PlanNum.ToString()); await Task.Delay(500);
// await Task.Delay(500); bartenderFormat.PrintOut(false, false); // 静默打印
// bartenderFormat.PrintOut(false, false); // 静默打印 }
// }
// return new CustomException(200, "标签打印成功"); return new CustomException(200, "标签打印成功");
//} }
//catch (Exception ex) catch (Exception ex)
//{ {
// // 5. 错误处理(记录日志) // 5. 错误处理(记录日志)
// Console.WriteLine($"打印标签时出错: {ex.Message}"); Console.WriteLine($"打印标签时出错: {ex.Message}");
// return new CustomException(500, $"打印标签失败: {ex.Message}"); return new CustomException(500, $"打印标签失败: {ex.Message}");
//} }
//finally finally
//{ {
// // 6. 确保资源释放(逆序关闭) // 6. 确保资源释放(逆序关闭)
// if (bartenderFormat != null) if (bartenderFormat != null)
// { {
// bartenderFormat.Close(BtSaveOptions.btDoNotSaveChanges); bartenderFormat.Close(BtSaveOptions.btDoNotSaveChanges);
// } }
// if (bartenderApp != null) if (bartenderApp != null)
// { {
// bartenderApp.Quit(BtSaveOptions.btDoNotSaveChanges); bartenderApp.Quit(BtSaveOptions.btDoNotSaveChanges);
// } }
//} }
} }
} }
} }