change - 文件模板修改

master
frankiecao 11 months ago
parent 524ad14e75
commit 8647094253

@ -37,9 +37,12 @@ namespace SlnMesnac.LabelPrint.BarTender
bool result = false;
try
{
if (labelInfo.productType == "Gas" || labelInfo.productType == "TF")
if (labelInfo.productType == "Gas")
{
result = this.PrintGasLabel(labelInfo);
}else if (labelInfo.productType == "TF")
{
result = this.PrintTFLabel(labelInfo);
}else if(labelInfo.productType == "Drum")
{
result = this.PrintDrumLabel(labelInfo);
@ -88,14 +91,30 @@ namespace SlnMesnac.LabelPrint.BarTender
}
/// <summary>
/// 气体、不锈钢标签打印
/// 气体打印
/// </summary>
/// <param name="labelInfo"></param>
private bool PrintGasLabel(BaseLabelInfo labelInfo)
{
bool result = false;
PrintEquip equip = new GasLabelPrintEquip();
equip.tempPath = "C:\\Users\\Administrator\\Desktop\\模板01.btw";
equip.tempPath = "C:\\Users\\Administrator\\Desktop\\模板一.btw";
equip.ParaClass = labelInfo;
equip.Open();
result = equip.print();
equip.Colse();
return result;
}
/// <summary>
/// 不锈钢标签打印
/// </summary>
/// <param name="labelInfo"></param>
private bool PrintTFLabel(BaseLabelInfo labelInfo)
{
bool result = false;
PrintEquip equip = new TFLabelPrintEquip();
equip.tempPath = "C:\\Users\\Administrator\\Desktop\\模板二.btw";
equip.ParaClass = labelInfo;
equip.Open();
result = equip.print();
@ -110,8 +129,8 @@ namespace SlnMesnac.LabelPrint.BarTender
private bool PrintDrumLabel(BaseLabelInfo labelInfo)
{
bool result = false;
PrintEquip equip = new LabelPrintEquip();
equip.tempPath = "C:\\Users\\Administrator\\Desktop\\模板01.btw";
PrintEquip equip = new DrumLabelPrintEquip();
equip.tempPath = "C:\\Users\\Administrator\\Desktop\\模板.btw";
equip.ParaClass = labelInfo;
equip.Open();
result = equip.print();
@ -123,8 +142,8 @@ namespace SlnMesnac.LabelPrint.BarTender
private bool PrintUnitLabel(BaseLabelInfo labelInfo)
{
bool result = false;
PrintEquip equip = new LabelPrintEquip();
equip.tempPath = "C:\\Users\\Administrator\\Desktop\\模板01.btw";
PrintEquip equip = new UnitLabelPrintEquip();
equip.tempPath = "C:\\Users\\Administrator\\Desktop\\模板.btw";
equip.ParaClass = labelInfo;
equip.Open();
result = equip.print();
@ -136,8 +155,8 @@ namespace SlnMesnac.LabelPrint.BarTender
private bool PrintPalletLabel(BaseLabelInfo labelInfo)
{
bool result = false;
PrintEquip equip = new LabelPrintEquip();
equip.tempPath = "C:\\Users\\Administrator\\Desktop\\模板01.btw";
PrintEquip equip = new PalletLabelPrintEquip();
equip.tempPath = "C:\\Users\\Administrator\\Desktop\\模板.btw";
equip.ParaClass = labelInfo;
equip.Open();
result = equip.print();

@ -46,9 +46,13 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="equip\DrumLabelPrintEquip.cs" />
<Compile Include="equip\GasLabelPrintEquip.cs" />
<Compile Include="equip\LabelPrintEquip.cs" />
<Compile Include="equip\PalletLabelPrintEquip.cs" />
<Compile Include="equip\PrintEquip.cs" />
<Compile Include="equip\TFLablePrintEquip.cs" />
<Compile Include="equip\UnitLabelPrintEquip.cs" />
<Compile Include="PrintManager.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

@ -0,0 +1,74 @@
using SlnMesnac.LabelPrint.Bartender.equip;
using SlnMesnac.LabelPrint.Common;
using SlnMesnac.LabelPrint.Log4net;
using SlnMesnac.LabelPrint.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SlnMesnac.LabelPrint.BarTender.equip
{
public class DrumLabelPrintEquip : PrintEquip
{
private readonly LogHelper logHelper = LogHelper.Instance;
private readonly JsonChange jsonChange = JsonChange.Instance;
public override bool AddPara()
{
var para = base.ParaClass as BaseLabelInfo;
if (para != null)
{
try
{
logHelper.Info($"打印标签信息:{jsonChange.ModeToJson(para)}");
//base.EngineFormat.SubStrings["rfid"].Value =
// para.column_A.ToString() + para.column_B.ToString() + para.column_C.ToString()
// + para.column_D.ToString() + para.column_E.ToString() + para.column_F.ToString()
// + para.column_G.ToString() + para.column_H.ToString() + para.column_I.ToString()
// + para.column_J.ToString();
//stirng 转为16进制
string msg = para.column_A.ToString() + para.column_B.ToString() + para.column_C.ToString()
+ para.column_D.ToString() + para.column_E.ToString() + para.column_F.ToString()
+ para.column_G.ToString() + para.column_H.ToString() + para.column_I.ToString()
+ para.column_J.ToString();
byte[] buffer = Encoding.UTF8.GetBytes(msg);
string hexString = BitConverter.ToString(buffer).Replace("-",string.Empty);
//Console.WriteLine(hexString);
base.EngineFormat.SubStrings["rfid"].Value = hexString;
base.EngineFormat.SubStrings["qrcode"].Value =
para.column_A.ToString() + para.column_B.ToString() + para.column_C.ToString()
+ para.column_D.ToString() + para.column_E.ToString() + para.column_F.ToString()
+ para.column_G.ToString() + para.column_H.ToString() + para.column_I.ToString()
+ para.column_J.ToString();
base.EngineFormat.SubStrings["cylinder"].Value = para.column_H.ToString();
base.EngineFormat.SubStrings["exp.date"].Value = para.column_J.ToString();
base.EngineFormat.SubStrings["lot"].Value = para.column_F.ToString();
base.EngineFormat.SubStrings["p/n"].Value = para.column_D.ToString();
base.EngineFormat.SubStrings["barcode1"].Value = "4" + para.column_D.ToString() + " " + para.column_J.ToString();
base.EngineFormat.SubStrings["barcode2"].Value = "5" + para.column_H.ToString();
base.EngineFormat.SubStrings["barcode3"].Value = "6" + para.column_F.ToString();
//para.column_A.ToString();
return true;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return false;
}
}
else
{
return false;
}
}
}
}

@ -14,7 +14,6 @@ namespace SlnMesnac.LabelPrint.BarTender.equip
{
private readonly LogHelper logHelper = LogHelper.Instance;
private readonly JsonChange jsonChange = JsonChange.Instance;
public override bool AddPara()
{
var para = base.ParaClass as BaseLabelInfo;
@ -23,7 +22,40 @@ namespace SlnMesnac.LabelPrint.BarTender.equip
try
{
logHelper.Info($"打印标签信息:{jsonChange.ModeToJson(para)}");
base.EngineFormat.SubStrings["barcode"].Value = para.column_A.ToString();
//base.EngineFormat.SubStrings["rfid"].Value =
// para.column_A.ToString() + para.column_B.ToString() + para.column_C.ToString()
// + para.column_D.ToString() + para.column_E.ToString() + para.column_F.ToString()
// + para.column_G.ToString() + para.column_H.ToString() + para.column_I.ToString()
// + para.column_J.ToString();
//stirng 转为16进制
string msg = para.column_A.ToString() + para.column_B.ToString() + para.column_C.ToString()
+ para.column_D.ToString() + para.column_E.ToString() + para.column_F.ToString()
+ para.column_G.ToString() + para.column_H.ToString() + para.column_I.ToString()
+ para.column_J.ToString();
byte[] buffer = Encoding.UTF8.GetBytes(msg);
string hexString = BitConverter.ToString(buffer).Replace("-",string.Empty);
//Console.WriteLine(hexString);
base.EngineFormat.SubStrings["rfid"].Value = hexString;
base.EngineFormat.SubStrings["qrcode"].Value =
para.column_A.ToString() + para.column_B.ToString() + para.column_C.ToString()
+ para.column_D.ToString() + para.column_E.ToString() + para.column_F.ToString()
+ para.column_G.ToString() + para.column_H.ToString() + para.column_I.ToString()
+ para.column_J.ToString();
base.EngineFormat.SubStrings["cylinder"].Value = para.column_H.ToString();
base.EngineFormat.SubStrings["exp.date"].Value = para.column_J.ToString();
base.EngineFormat.SubStrings["lot"].Value = para.column_F.ToString();
base.EngineFormat.SubStrings["p/n"].Value = para.column_D.ToString();
base.EngineFormat.SubStrings["barcode1"].Value = "4" + para.column_D.ToString() + " " + para.column_J.ToString();
base.EngineFormat.SubStrings["barcode2"].Value = "5" + para.column_H.ToString();
base.EngineFormat.SubStrings["barcode3"].Value = "6" + para.column_F.ToString();
//para.column_A.ToString();
return true;
}
catch (Exception e)

@ -0,0 +1,47 @@
using SlnMesnac.LabelPrint.Bartender.equip;
using SlnMesnac.LabelPrint.Common;
using SlnMesnac.LabelPrint.Log4net;
using SlnMesnac.LabelPrint.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SlnMesnac.LabelPrint.BarTender.equip
{
public class PalletLabelPrintEquip : PrintEquip
{
private readonly LogHelper logHelper = LogHelper.Instance;
private readonly JsonChange jsonChange = JsonChange.Instance;
public override bool AddPara()
{
var para = base.ParaClass as BaseLabelInfo;
if (para != null)
{
try
{
logHelper.Info($"打印标签信息:{jsonChange.ModeToJson(para)}");
string msg = "25BUN33000074" + para.column_A.ToString();
byte[] buffer = Encoding.UTF8.GetBytes( msg );
string hexString = BitConverter.ToString( buffer).Replace("-",string.Empty);
base.EngineFormat.SubStrings["rfid"].Value = hexString;
base.EngineFormat.SubStrings["qrcode"].Value = "25BUN33000074" + para.column_A.ToString();
base.EngineFormat.SubStrings["barcode"].Value = "25BUN33000074" + para.column_A.ToString();
base.EngineFormat.SubStrings["pallet"].Value = para.column_A.ToString();
return true;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return false;
}
}
else
{
return false;
}
}
}
}

@ -68,7 +68,7 @@ namespace SlnMesnac.LabelPrint.Bartender.equip
Result re = EngineFormat.Print();
result = re == Result.Success ? true : false;
string st = re == Result.Success ? "成功" : "失败";
Console.WriteLine("文件打印" + st + re.ToString());
Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")}文件打印" + st + re.ToString());
}
else
{

@ -0,0 +1,74 @@
using SlnMesnac.LabelPrint.Bartender.equip;
using SlnMesnac.LabelPrint.Common;
using SlnMesnac.LabelPrint.Log4net;
using SlnMesnac.LabelPrint.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SlnMesnac.LabelPrint.BarTender.equip
{
public class TFLabelPrintEquip : PrintEquip
{
private readonly LogHelper logHelper = LogHelper.Instance;
private readonly JsonChange jsonChange = JsonChange.Instance;
public override bool AddPara()
{
var para = base.ParaClass as BaseLabelInfo;
if (para != null)
{
try
{
logHelper.Info($"打印标签信息:{jsonChange.ModeToJson(para)}");
//base.EngineFormat.SubStrings["rfid"].Value =
// para.column_A.ToString() + para.column_B.ToString() + para.column_C.ToString()
// + para.column_D.ToString() + para.column_E.ToString() + para.column_F.ToString()
// + para.column_G.ToString() + para.column_H.ToString() + para.column_I.ToString()
// + para.column_J.ToString();
//stirng 转为16进制
string msg = para.column_A.ToString() + para.column_B.ToString() + para.column_C.ToString()
+ para.column_D.ToString() + para.column_E.ToString() + para.column_F.ToString()
+ para.column_G.ToString() + para.column_H.ToString() + para.column_I.ToString()
+ para.column_J.ToString();
byte[] buffer = Encoding.UTF8.GetBytes(msg);
string hexString = BitConverter.ToString(buffer).Replace("-", string.Empty);
//Console.WriteLine(hexString);
base.EngineFormat.SubStrings["rfid"].Value = hexString;
base.EngineFormat.SubStrings["qrcode"].Value =
para.column_A.ToString() + para.column_B.ToString() + para.column_C.ToString()
+ para.column_D.ToString() + para.column_E.ToString() + para.column_F.ToString()
+ para.column_G.ToString() + para.column_H.ToString() + para.column_I.ToString()
+ para.column_J.ToString();
base.EngineFormat.SubStrings["cylinder"].Value = para.column_H.ToString();
base.EngineFormat.SubStrings["exp.date"].Value = para.column_J.ToString();
base.EngineFormat.SubStrings["lot"].Value = para.column_F.ToString();
base.EngineFormat.SubStrings["p/n"].Value = para.column_D.ToString();
base.EngineFormat.SubStrings["barcode1"].Value = "4" + para.column_D.ToString() + " " + para.column_J.ToString();
base.EngineFormat.SubStrings["barcode2"].Value = "5" + para.column_H.ToString();
base.EngineFormat.SubStrings["barcode3"].Value = "6" + para.column_F.ToString();
//para.column_A.ToString();
return true;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return false;
}
}
else
{
return false;
}
}
}
}

@ -0,0 +1,66 @@
using SlnMesnac.LabelPrint.Bartender.equip;
using SlnMesnac.LabelPrint.Common;
using SlnMesnac.LabelPrint.Log4net;
using SlnMesnac.LabelPrint.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SlnMesnac.LabelPrint.BarTender.equip
{
public class UnitLabelPrintEquip : PrintEquip
{
private readonly LogHelper logHelper = LogHelper.Instance;
private readonly JsonChange jsonChange = JsonChange.Instance;
public override bool AddPara()
{
var para = base.ParaClass as BaseLabelInfo;
if (para != null)
{
try
{
logHelper.Info($"打印标签信息:{jsonChange.ModeToJson(para)}");
//base.EngineFormat.SubStrings["rfid"].Value =
// para.column_A.ToString() + para.column_B.ToString() + para.column_C.ToString()
// + para.column_D.ToString() + para.column_E.ToString() + para.column_F.ToString()
// + para.column_G.ToString() + para.column_H.ToString() + para.column_I.ToString()
// + para.column_J.ToString();
//stirng 转为16进制
string msg = para.column_A.ToString() + para.column_B.ToString() + para.column_C.ToString()
+ para.column_D.ToString() + para.column_E.ToString();
byte[] buffer = Encoding.UTF8.GetBytes(msg);
string hexString = BitConverter.ToString(buffer).Replace("-", string.Empty);
//Console.WriteLine(hexString);
base.EngineFormat.SubStrings["rfid"].Value = hexString;
base.EngineFormat.SubStrings["qrcode"].Value = para.column_A.ToString() + para.column_B.ToString() + para.column_C.ToString()
+ para.column_D.ToString() + para.column_E.ToString();
base.EngineFormat.SubStrings["exp.date"].Value = para.column_E.ToString();
base.EngineFormat.SubStrings["lot"].Value = para.column_B.ToString();
base.EngineFormat.SubStrings["serial"].Value = para.column_D.ToString();
base.EngineFormat.SubStrings["p/n"].Value = para.column_A.ToString();
base.EngineFormat.SubStrings["barcode"].Value = para.column_D.ToString();
//"UN1H1/Y2.0/170/23 USA/+AA1964" +
return true;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return false;
}
}
else
{
return false;
}
}
}
}

@ -36,6 +36,12 @@ namespace SlnMesnac.LabelPrint.FileOperate
List<BaseLabelInfo> result = null;
try
{
string fileName = GetFileName(filePath);
if (string.IsNullOrEmpty(fileName))
{
return result;
}
var sheetNames = MiniExcel.GetSheetNames(filePath);
if (sheetNames != null)
@ -56,13 +62,9 @@ namespace SlnMesnac.LabelPrint.FileOperate
dynamic labelDynamic = info[i];
BaseLabelInfo labelInfo = new BaseLabelInfo();
labelInfo.label = labelDynamic;
labelInfo.productType = sheetName;
if(labelDynamic.A == null)
{
continue;
}
labelInfo.productType = fileName;
labelInfo.column_A = labelDynamic.A;
if (sheetName == "Pallet")
if (fileName == "Pallet")
{
labelInfo.recordTime = DateTime.Now;
result.Add(labelInfo);
@ -71,20 +73,34 @@ namespace SlnMesnac.LabelPrint.FileOperate
labelInfo.column_B = labelDynamic.B;
labelInfo.column_C = labelDynamic.C;
labelInfo.column_D = labelDynamic.D;
labelInfo.column_E = labelDynamic.E;
if (sheetName == "Unit")
if(fileName == "Gas" || fileName == "TF" || fileName == "Drum")
{
labelInfo.recordTime = DateTime.Now;
result.Add(labelInfo);
continue;
}
labelInfo.column_F = labelDynamic.F;
labelInfo.column_G = labelDynamic.G;
labelInfo.column_H = labelDynamic.H;
labelInfo.column_I = labelDynamic.I;
labelInfo.column_J = labelDynamic.J;
labelInfo.recordTime = DateTime.Now;
result.Add(labelInfo);
labelInfo.column_E = labelDynamic.E;
if (fileName == "Unit")
{
if (labelInfo.column_D == null)
{
continue;
}
else
{
labelInfo.recordTime = DateTime.Now;
result.Add(labelInfo);
continue;
}
}
//labelInfo.column_F = labelDynamic.F;
//labelInfo.column_G = labelDynamic.G;
//labelInfo.column_H = labelDynamic.H;
//labelInfo.column_I = labelDynamic.I;
//labelInfo.column_J = labelDynamic.J;
//labelInfo.recordTime = DateTime.Now;
//result.Add(labelInfo);
}
}
}
@ -97,5 +113,38 @@ namespace SlnMesnac.LabelPrint.FileOperate
return result;
}
/// <summary>
/// 获取产品型号
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
private string GetFileName(string filePath)
{
if (filePath.Contains("Gas"))
{
return "Gas";
}else if (filePath.Contains("TF"))
{
return "TF";
}
else if (filePath.Contains("Drum"))
{
return "Drum";
}
else if (filePath.Contains("Unit"))
{
return "Unit";
}
else if (filePath.Contains("Pallet"))
{
return "Pallet";
}
else
{
return string.Empty;
}
}
}
}

@ -32,7 +32,7 @@ namespace SlnMesnac.LabelPrint.Log4net
*
*/
//private readonly string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log4net.config");
private readonly string fileName = "C:\\项目代码\\RFID标签打印项目\\SlnMesnac.LabelPrint\\SlnMesnac.LabelPrint.Log4net\\config\\log4net.config";
private readonly string fileName = "D:\\project\\RFID标签打印项目\\SlnMesnac.LabelPrint\\SlnMesnac.LabelPrint.Log4net\\config\\log4net.config";
private LogHelper()
{

@ -18,7 +18,7 @@ namespace SlnMesnac.LabelPrint.Timer
private readonly PrintManager printManager = PrintManager.Instance;
private readonly JsonChange jsonChange = JsonChange.Instance;
private System.Timers.Timer timer = new System.Timers.Timer(2000);
private System.Timers.Timer timer = new System.Timers.Timer(5000);
/// <summary>
/// 日志刷新
@ -121,7 +121,7 @@ namespace SlnMesnac.LabelPrint.Timer
timer.Stop();
timer.Close();
timer.Dispose();
timer = new System.Timers.Timer(2000);
timer = new System.Timers.Timer(5000);
}
result = true;
}

@ -57,11 +57,11 @@
<DataGridTextColumn Binding="{Binding column_C}" Header="C" Width="150" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding column_D}" Header="D" Width="150" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding column_E}" Header="E" Width="150" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding column_F}" Header="F" Width="150" IsReadOnly="True"/>
<!--<DataGridTextColumn Binding="{Binding column_F}" Header="F" Width="150" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding column_G}" Header="G" Width="150" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding column_H}" Header="H" Width="150" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding column_I}" Header="I" Width="150" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding column_J}" Header="J" Width="150" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding column_J}" Header="J" Width="150" IsReadOnly="True"/>-->
<DataGridTextColumn Binding="{Binding recordTime,StringFormat=\{0:MM月dd日 HH:mm\}}" Header="时间" Width="150" IsReadOnly="True"/>
</DataGrid.Columns>
</DataGrid>

@ -103,7 +103,7 @@ namespace SlnMesnac.LabelPrint.viewModel
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Multiselect = true; //该值确定是否可以选择多个文件
openFileDialog.Title = "请选择文件"; //弹窗的标题
openFileDialog.InitialDirectory = "D:\\"; //默认打开的文件夹的位置
openFileDialog.InitialDirectory = "C:\\Users\\Administrator\\Desktop"; //默认打开的文件夹的位置
openFileDialog.Filter = "MicroSoft Excel文件(*.xlsx)|*.xlsx|所有文件(*.*)|*.*"; //筛选文件
if (openFileDialog.ShowDialog() == true)

Loading…
Cancel
Save