add-添加库位码打印模版

dev
liuwf 1 week ago
parent 46975892d4
commit 624328a050

@ -129,6 +129,34 @@ namespace PrintBarCode.Business
}
/// <summary>
/// 打印小条码库位码方法
/// </summary>
public void PrintSmallBarCodeInfo(SmallCodeInfo smallCodeInfo)
{
// 拼接成目标文件的完整路径
string path = Path.Combine(basePath, "templates", "smallTemplate.prn");
string[] args = new string[]
{
smallCodeInfo.QrCode,
smallCodeInfo.Text,
};
// 将属性值用 "~" 连接起来,不带前缀
string TempStr = $"{smallCodeInfo.QrCode}~{smallCodeInfo.Text}";
string ZplStr = PrintH.GetPrintString(path, TempStr);//替换后字符串
bool pringFlag = zplp.SendStringToPrinter(debugConfig.PrintName, ZplStr);
if (pringFlag == false)
{
Console.WriteLine("打印错误,检查后请重新操作!");
}
}
}
}

@ -36,6 +36,11 @@ namespace PrintBarCode.Helper
var bindBarCodeInfoList = JsonSerializer.Deserialize<List<BindBarCodeInfo>>(output.PrintContent);
return bindBarCodeInfoList.Cast<object>().ToList();
}
else if(output.Template == "small")
{
var smallCodeInfoList = JsonSerializer.Deserialize<List<SmallCodeInfo>>(output.PrintContent);
return smallCodeInfoList.Cast<object>().ToList();
}
else
{
return null;

@ -111,6 +111,10 @@ namespace PrintBarCode
{
addLogEvent?.Invoke(bindBarCodeInfo.ToJson());
printBusiness.PrintBindBarCodeInfo(bindBarCodeInfo);
}else if(item is SmallCodeInfo smallCodeInfo)
{
addLogEvent?.Invoke(smallCodeInfo.ToJson());
printBusiness.PrintSmallBarCodeInfo(smallCodeInfo);
}
Thread.Sleep(1000);
}

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace PrintBarCode.Model
{
public class SmallCodeInfo
{
[JsonPropertyName("text")]
public string Text { get; set; }
[JsonPropertyName("qrcode")]
public string QrCode { get; set; }
}
}
Loading…
Cancel
Save