You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
135 lines
4.6 KiB
C#
135 lines
4.6 KiB
C#
using PrintBarCode.Helper;
|
|
using PrintBarCode.Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace PrintBarCode.Business
|
|
{
|
|
public class PrintBusiness
|
|
{
|
|
|
|
private DebugConfig debugConfig = DebugConfig.Instance;
|
|
private static string basePath = AppDomain.CurrentDomain.BaseDirectory;
|
|
|
|
PrintHelper PrintH = new PrintHelper();
|
|
|
|
private RawPrinterHelper zplp = new RawPrinterHelper();
|
|
public PrintBusiness()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 打印原材料条码方法
|
|
/// </summary>
|
|
public void PrintRawBarCodeInfo(RawBarCodeInfo rawBarCodeInfo)
|
|
{
|
|
// 拼接成目标文件的完整路径
|
|
string path = Path.Combine(basePath, "templates", "rawTemplate.prn");
|
|
|
|
//
|
|
string[] args = new string[]
|
|
{
|
|
rawBarCodeInfo.MaterialName,
|
|
rawBarCodeInfo.MaterialCode,
|
|
rawBarCodeInfo.MaterialSpec,
|
|
rawBarCodeInfo.BatchCode,
|
|
rawBarCodeInfo.PoNo,
|
|
rawBarCodeInfo.SaleOrderCode,
|
|
rawBarCodeInfo.Barcode,
|
|
rawBarCodeInfo.QrCode,
|
|
};
|
|
|
|
// 将属性值用 "~" 连接起来,不带前缀
|
|
string TempStr = $"{rawBarCodeInfo.MaterialName}~{rawBarCodeInfo.MaterialCode}~{rawBarCodeInfo.MaterialSpec}~{rawBarCodeInfo.BatchCode}~{rawBarCodeInfo.PoNo}~{rawBarCodeInfo.SaleOrderCode}~{rawBarCodeInfo.Barcode}~{rawBarCodeInfo.QrCode}";
|
|
|
|
|
|
string ZplStr = PrintH.GetPrintString(path, TempStr);//替换后字符串
|
|
|
|
bool pringFlag = zplp.SendStringToPrinter(debugConfig.PrintName, ZplStr);
|
|
if (pringFlag == false)
|
|
{
|
|
Console.WriteLine("打印错误,检查后请重新操作!");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 打印成品条码方法
|
|
/// </summary>
|
|
public void PrintProductBarCodeInfo(ProductBarCodeInfo productBarCodeInfo)
|
|
{
|
|
// 拼接成目标文件的完整路径
|
|
string path = Path.Combine(basePath, "templates", "productTemplate.prn");
|
|
|
|
//
|
|
string[] args = new string[]
|
|
{
|
|
productBarCodeInfo.MaterialName,
|
|
productBarCodeInfo.MaterialCode,
|
|
productBarCodeInfo.MaterialSpec,
|
|
productBarCodeInfo.ProductPlanCode,
|
|
productBarCodeInfo.SaleOrderCode,
|
|
productBarCodeInfo.BarCode,
|
|
productBarCodeInfo.Qty,
|
|
productBarCodeInfo.QrCode,
|
|
|
|
};
|
|
|
|
string TempStr = $"{productBarCodeInfo.MaterialName}~{productBarCodeInfo.MaterialCode}~{productBarCodeInfo.MaterialSpec}~{productBarCodeInfo.ProductPlanCode}~{productBarCodeInfo.SaleOrderCode}~{productBarCodeInfo.BarCode}~{productBarCodeInfo.Qty}~{productBarCodeInfo.QrCode}";
|
|
|
|
string ZplStr = PrintH.GetPrintString(path, TempStr);//替换后字符串
|
|
|
|
bool pringFlag = zplp.SendStringToPrinter(debugConfig.PrintName, ZplStr);
|
|
if (pringFlag == false)
|
|
{
|
|
Console.WriteLine("打印错误,检查后请重新操作!");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 打印配对码方法
|
|
/// </summary>
|
|
public void PrintBindBarCodeInfo(BindBarCodeInfo bindBarCodeInfo)
|
|
{
|
|
// 拼接成目标文件的完整路径
|
|
string path = Path.Combine(basePath, "templates", "bindTemplate.prn");
|
|
|
|
//
|
|
string[] args = new string[]
|
|
{
|
|
bindBarCodeInfo.MaterialName,
|
|
bindBarCodeInfo.MaterialCode,
|
|
bindBarCodeInfo.MaterialSpec,
|
|
bindBarCodeInfo.BatchCode,
|
|
bindBarCodeInfo.PoNo,
|
|
bindBarCodeInfo.SaleOrderCode,
|
|
bindBarCodeInfo.Barcode,
|
|
bindBarCodeInfo.QrCode,
|
|
};
|
|
|
|
// 将属性值用 "~" 连接起来,不带前缀
|
|
string TempStr = $"{bindBarCodeInfo.MaterialName}~{bindBarCodeInfo.MaterialCode}~{bindBarCodeInfo.MaterialSpec}~{bindBarCodeInfo.BatchCode}~{bindBarCodeInfo.PoNo}~{bindBarCodeInfo.SaleOrderCode}~{bindBarCodeInfo.Barcode}~{bindBarCodeInfo.QrCode}";
|
|
|
|
|
|
string ZplStr = PrintH.GetPrintString(path, TempStr);//替换后字符串
|
|
|
|
bool pringFlag = zplp.SendStringToPrinter(debugConfig.PrintName, ZplStr);
|
|
if (pringFlag == false)
|
|
{
|
|
Console.WriteLine("打印错误,检查后请重新操作!");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|