|
|
@ -3,6 +3,7 @@ using Newtonsoft.Json;
|
|
|
|
using PrintBarCode.Business;
|
|
|
|
using PrintBarCode.Business;
|
|
|
|
using PrintBarCode.Helper;
|
|
|
|
using PrintBarCode.Helper;
|
|
|
|
using PrintBarCode.Model;
|
|
|
|
using PrintBarCode.Model;
|
|
|
|
|
|
|
|
using ServiceStack;
|
|
|
|
using ServiceStack.Messaging;
|
|
|
|
using ServiceStack.Messaging;
|
|
|
|
using SlnMesnac.Common;
|
|
|
|
using SlnMesnac.Common;
|
|
|
|
using SlnMesnac.Model.domain;
|
|
|
|
using SlnMesnac.Model.domain;
|
|
|
@ -20,6 +21,19 @@ namespace PrintBarCode
|
|
|
|
private readonly RedisHandler _redisHandler;
|
|
|
|
private readonly RedisHandler _redisHandler;
|
|
|
|
private PrintBusiness printBusiness = new PrintBusiness();
|
|
|
|
private PrintBusiness printBusiness = new PrintBusiness();
|
|
|
|
private readonly DebugConfig debugConfig = DebugConfig.Instance;
|
|
|
|
private readonly DebugConfig debugConfig = DebugConfig.Instance;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public delegate void addLog(string message);
|
|
|
|
|
|
|
|
public static event addLog? addLogEvent;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 刷新日志信息
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="msg"></param>
|
|
|
|
|
|
|
|
public delegate void PrintMessageToListBox(string msg);
|
|
|
|
|
|
|
|
public event PrintMessageToListBox? PrintMessageToListBoxEvent;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MessageClient(RedisHandler redisHandler)
|
|
|
|
public MessageClient(RedisHandler redisHandler)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_redisHandler = redisHandler;
|
|
|
|
_redisHandler = redisHandler;
|
|
|
@ -74,8 +88,8 @@ namespace PrintBarCode
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string channelWork = $"print_{debugConfig.IP}";
|
|
|
|
string channelWork = $"print_{debugConfig.IP}";
|
|
|
|
string jsonString = _redisHandler.ConsumeMessageFromWorker(channelWork);
|
|
|
|
// string jsonString = _redisHandler.ConsumeMessageFromWorker(channelWork);
|
|
|
|
// string jsonString = "{\"template\":\"product\",\"printContent\":\"[{\\\"saleOrderCode\\\":\\\"\\\",\\\"materialName\\\":\\\"多功能自动剥线钳\\\",\\\"qrcode\\\":\\\"20241019112921CP001\\\",\\\"materialSpec\\\":\\\"\\\",\\\"qty\\\":\\\"1\\\",\\\"materialCode\\\":\\\"MES.MC.A00861\\\",\\\"barcode\\\":\\\"20241019112921CP001\\\",\\\"productPlanCode\\\":\\\"20241019111402JL012\\\"}]\"}";
|
|
|
|
string jsonString = "{\"template\":\"product\",\"printContent\":\"[{\\\"saleOrderCode\\\":\\\"\\\",\\\"materialName\\\":\\\"多功能自动剥线钳\\\",\\\"qrcode\\\":\\\"20241019112921CP001\\\",\\\"materialSpec\\\":\\\"\\\",\\\"qty\\\":\\\"1\\\",\\\"materialCode\\\":\\\"MES.MC.A00861\\\",\\\"barcode\\\":\\\"20241019112921CP001\\\",\\\"productPlanCode\\\":\\\"20241019111402JL012\\\"}]\"}";
|
|
|
|
if (!string.IsNullOrEmpty(jsonString))
|
|
|
|
if (!string.IsNullOrEmpty(jsonString))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var result = JsonParser.ParseJson(jsonString);
|
|
|
|
var result = JsonParser.ParseJson(jsonString);
|
|
|
@ -85,14 +99,17 @@ namespace PrintBarCode
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (item is RawBarCodeInfo rawBarCodeInfo)
|
|
|
|
if (item is RawBarCodeInfo rawBarCodeInfo)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
addLogEvent?.Invoke(rawBarCodeInfo.ToJson());
|
|
|
|
printBusiness.PrintRawBarCodeInfo(rawBarCodeInfo);
|
|
|
|
printBusiness.PrintRawBarCodeInfo(rawBarCodeInfo);
|
|
|
|
Console.WriteLine($"SaleOrderCode: {rawBarCodeInfo.SaleOrderCode}, MaterialName: {rawBarCodeInfo.MaterialName}, PoNo: {rawBarCodeInfo.PoNo}, QrCode: {rawBarCodeInfo.QrCode}, BatchCode: {rawBarCodeInfo.BatchCode}, MaterialSpec: {rawBarCodeInfo.MaterialSpec}, MaterialCode: {rawBarCodeInfo.MaterialCode}, Barcode: {rawBarCodeInfo.Barcode}");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (item is ProductBarCodeInfo productBarCodeInfo)
|
|
|
|
else if (item is ProductBarCodeInfo productBarCodeInfo)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
addLogEvent?.Invoke(productBarCodeInfo.ToJson());
|
|
|
|
printBusiness.PrintProductBarCodeInfo(productBarCodeInfo);
|
|
|
|
printBusiness.PrintProductBarCodeInfo(productBarCodeInfo);
|
|
|
|
}else if (item is BindBarCodeInfo bindBarCodeInfo)
|
|
|
|
}else if (item is BindBarCodeInfo bindBarCodeInfo)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
addLogEvent?.Invoke(bindBarCodeInfo.ToJson());
|
|
|
|
printBusiness.PrintBindBarCodeInfo(bindBarCodeInfo);
|
|
|
|
printBusiness.PrintBindBarCodeInfo(bindBarCodeInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
Thread.Sleep(1000);
|
|
|
|