|
|
|
|
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 = "55BUN544858988" + para.column_D.ToString() + "@"
|
|
|
|
|
+ para.column_B.ToString() + "+" + para.column_A.ToString()
|
|
|
|
|
+ "3300074" + ReformatDate(para.column_C.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 ="55BUN544858988" + para.column_D.ToString() + "@"
|
|
|
|
|
+ para.column_B.ToString() + "+" + para.column_A.ToString()
|
|
|
|
|
+ "3300074" + ReformatDate(para.column_C.ToString());
|
|
|
|
|
|
|
|
|
|
base.EngineFormat.SubStrings["container"].Value = para.column_A.ToString();
|
|
|
|
|
base.EngineFormat.SubStrings["exp.date"].Value = ReformatDate(para.column_C.ToString());
|
|
|
|
|
base.EngineFormat.SubStrings["lot"].Value = para.column_B.ToString();
|
|
|
|
|
base.EngineFormat.SubStrings["p/n"].Value = para.column_D.ToString();
|
|
|
|
|
base.EngineFormat.SubStrings["barcode1"].Value = "4" + para.column_D.ToString() + " " + ReformatDate(para.column_C.ToString()) + "TS";
|
|
|
|
|
base.EngineFormat.SubStrings["barcode2"].Value = "5" + para.column_A.ToString();
|
|
|
|
|
base.EngineFormat.SubStrings["barcode3"].Value = "6" + para.column_B.ToString();
|
|
|
|
|
//para.column_A.ToString();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(e.ToString());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 私有方法:重新组合日期字符串
|
|
|
|
|
private static string ReformatDate(string inputDate)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// 使用 DateTime.ParseExact 解析输入日期字符串
|
|
|
|
|
DateTime date = DateTime.ParseExact(inputDate, "dd.MM.yyyy", null);
|
|
|
|
|
|
|
|
|
|
// 使用 ToString 将日期格式化为目标格式
|
|
|
|
|
string formattedDate = date.ToString("yyyyMMdd");
|
|
|
|
|
|
|
|
|
|
return formattedDate;
|
|
|
|
|
}
|
|
|
|
|
catch (FormatException ex)
|
|
|
|
|
{
|
|
|
|
|
// 如果解析失败,可以在这里处理异常
|
|
|
|
|
Console.WriteLine("日期格式不正确:" + ex.Message);
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|