From c73cd4854298f7de21cc3c54efa1c4bbcd55793d Mon Sep 17 00:00:00 2001 From: anerx <512464164@qq.com> Date: Wed, 26 Mar 2025 15:16:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B91=E5=8F=B7=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E6=9C=BA=E4=B8=BA=E9=BB=91=E8=89=B2=E6=A0=87=E7=AD=BE=E6=89=93?= =?UTF-8?q?=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Plc/HyosungPlcService.cs | 30 +++++-------------- .../Plc/IHyosungPlcService.cs | 2 +- .../Printer/HyosungPrinter.cs | 2 +- .../Entities/VarietyEntity.cs | 18 +++++------ .../Models/Plc/PackLineOption.cs | 2 ++ Seyounth.Hyosung.Data/Models/Variety.cs | 8 +++-- Seyounth.Hyosung.Runtime/HyosungRuntime.cs | 24 ++++----------- 7 files changed, 31 insertions(+), 55 deletions(-) diff --git a/Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs b/Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs index 62b178c..1b3e658 100644 --- a/Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs +++ b/Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs @@ -103,13 +103,14 @@ public class HyosungPlcService(ILogger logger) : IHyosungPlcS ls.Add((short)(option.IsPack ? 1 : 2)); ls.Add((short)(option.IsFilm ? 1 : 2)); ls.Add((short)(option.IsLam ? 1 : 2)); + ls.Add((short)(option.IsBlack ? 2 : 1)); await _writer.WriteShortsAsync(12120, ls.ToArray()); } - public async Task WritePrintLableOptionsAsync(int side, int slave) + public async Task WritePrintLableOptionsAsync(bool isBlack, int count) { short masterCount = 0; - switch (side) + switch (count) { case 0: masterCount = 1; @@ -128,27 +129,10 @@ public class HyosungPlcService(ILogger logger) : IHyosungPlcS break; } - short slaveCount = 0; - switch (slave) - { - case 0: - slaveCount = 1; - break; - case 1: - slaveCount = 2; - break; - case 2: - slaveCount = 6; - break; - case 3: - slaveCount = 14; - break; - case 4: - slaveCount = 30; - break; - } - - await _writer.WriteShortsAsync(13050, [1, 1, 1, masterCount]); + if (isBlack) + await _writer.WriteShortsAsync(13050, [1, 1, masterCount, 1]); + else + await _writer.WriteShortsAsync(13050, [1, 1, 1, masterCount]); } public async Task WritePrintLabelResultAsync(int index, bool result) diff --git a/Seyounth.Hyosung.Core/Plc/IHyosungPlcService.cs b/Seyounth.Hyosung.Core/Plc/IHyosungPlcService.cs index b15f47b..3372905 100644 --- a/Seyounth.Hyosung.Core/Plc/IHyosungPlcService.cs +++ b/Seyounth.Hyosung.Core/Plc/IHyosungPlcService.cs @@ -58,7 +58,7 @@ public interface IHyosungPlcService Task WritePackLineOptionAsync(PackLineOption option); - Task WritePrintLableOptionsAsync(int side,int slaveCount); + Task WritePrintLableOptionsAsync(bool isBlack,int slaveCount); Task WritePrintLabelResultAsync(int index, bool result); diff --git a/Seyounth.Hyosung.Core/Printer/HyosungPrinter.cs b/Seyounth.Hyosung.Core/Printer/HyosungPrinter.cs index e3f88bf..3512e42 100644 --- a/Seyounth.Hyosung.Core/Printer/HyosungPrinter.cs +++ b/Seyounth.Hyosung.Core/Printer/HyosungPrinter.cs @@ -50,7 +50,7 @@ public class HyosungPrinter( private async Task PrintLabel1Async(Tray tray) { await _masterPrinter.CleanContextAsync(); - var content = await GetPrint1Content(tray); + var content = await GetPrint2Content(tray); await _masterPrinter.SendContentAsync(content); await _masterPrinter.PrintAsync(); } diff --git a/Seyounth.Hyosung.Data/Entities/VarietyEntity.cs b/Seyounth.Hyosung.Data/Entities/VarietyEntity.cs index eb09ce4..669f10d 100644 --- a/Seyounth.Hyosung.Data/Entities/VarietyEntity.cs +++ b/Seyounth.Hyosung.Data/Entities/VarietyEntity.cs @@ -57,7 +57,7 @@ public class VarietyEntity [SugarColumn(ColumnDescription = "垛头数量")] public int? StackHeadCount { get; set; } - [SugarColumn(ColumnDescription = "纸托Id",IsNullable =true)] + [SugarColumn(ColumnDescription = "纸托Id", IsNullable = true)] public int? PaperTrayId { get; set; } [SugarColumn(ColumnDescription = "是否需要纸箱")] @@ -84,13 +84,11 @@ public class VarietyEntity [SugarColumn(ColumnDescription = "副标签数量")] public int SubLabelCount { get; set; } - [SugarColumn(IsNullable =true)] - public int? LastNo { get; set; } - - [SugarColumn(IsNullable =true)] - public double? NetWeight { get; set; } - - [SugarColumn(IsNullable =true)] - public double? GrossWeight { get; set; } - + [SugarColumn(IsNullable = true)] public int? LastNo { get; set; } + + [SugarColumn(IsNullable = true)] public double? NetWeight { get; set; } + + [SugarColumn(IsNullable = true)] public double? GrossWeight { get; set; } + + [SugarColumn(IsNullable = true)] public bool? IsBlack { get; set; } } \ No newline at end of file diff --git a/Seyounth.Hyosung.Data/Models/Plc/PackLineOption.cs b/Seyounth.Hyosung.Data/Models/Plc/PackLineOption.cs index 13d0e74..f806a59 100644 --- a/Seyounth.Hyosung.Data/Models/Plc/PackLineOption.cs +++ b/Seyounth.Hyosung.Data/Models/Plc/PackLineOption.cs @@ -17,4 +17,6 @@ public partial class PackLineOption : ObservableObject [ObservableProperty] private bool isLam; [ObservableProperty] private string trayCode; + + [ObservableProperty] private bool isBlack; } \ No newline at end of file diff --git a/Seyounth.Hyosung.Data/Models/Variety.cs b/Seyounth.Hyosung.Data/Models/Variety.cs index b4fd677..3f4d99a 100644 --- a/Seyounth.Hyosung.Data/Models/Variety.cs +++ b/Seyounth.Hyosung.Data/Models/Variety.cs @@ -69,6 +69,8 @@ public class Variety public double? NetWeight { get; set; } public double? GrossWeight { get; set; } + + public bool? IsBlack { get; set; } public static Variety Create(VarietyEntity entity, List pallets) { @@ -101,7 +103,8 @@ public class Variety HasBox = entity.HasBox, LastNo = entity.LastNo, NetWeight = entity.NetWeight, - GrossWeight = entity.GrossWeight + GrossWeight = entity.GrossWeight, + IsBlack = entity.IsBlack }; if (entity.PaperTrayId != null && entity.PaperTrayId != 0) variety.PaperTray = Pallet.FromEntity(pallets.First(x => x.Id == entity.PaperTrayId)); @@ -141,7 +144,8 @@ public class Variety HasBox = HasBox, LastNo = LastNo, NetWeight = NetWeight, - GrossWeight = GrossWeight + GrossWeight = GrossWeight, + IsBlack = IsBlack }; return entity; } diff --git a/Seyounth.Hyosung.Runtime/HyosungRuntime.cs b/Seyounth.Hyosung.Runtime/HyosungRuntime.cs index 4244c61..3b27be1 100644 --- a/Seyounth.Hyosung.Runtime/HyosungRuntime.cs +++ b/Seyounth.Hyosung.Runtime/HyosungRuntime.cs @@ -121,7 +121,6 @@ public class HyosungRuntime( var trays = await trayService.GetTodayTrayAsync(); foreach (var tray in trays) { - } } @@ -354,6 +353,7 @@ public class HyosungRuntime( PackLineOption.IsLam = true; else PackLineOption.IsLam = false; + PackLineOption.IsBlack = variety.IsBlack ?? false; await hyosungPlcService.WritePackLineOptionAsync(PackLineOption); logger.LogInformation($"plc request pack line option success"); } @@ -386,14 +386,14 @@ public class HyosungRuntime( // } tray = await trayService.PrintTrayAsync(arg, mod, variety); await dictService.SetValue("System", "CurrentPackingTrayCode", arg); - await hyosungPlcService.WritePrintLableOptionsAsync(variety.MasterLabelCount, variety.SubLabelCount); + await hyosungPlcService.WritePrintLableOptionsAsync(variety.IsBlack ?? false, variety.MasterLabelCount); + await hyosungWmsService.AddLabelResult(new LabelResult(tray, variety)); logger.LogInformation("request print option succeed"); } - catch(Exception e) + catch (Exception e) { logger.LogError(e, "GetPrintOptionError"); } - } /// @@ -413,20 +413,8 @@ public class HyosungRuntime( await trayService.UpdateHeightAsync(tray.TrayCode, height); try { - if (arg1 == 1) - { - await printer.PrintAsync(1, tray.TrayCode); - await hyosungPlcService.WritePrintLabelResultAsync(arg1, true); - } - else - { - await printer.PrintAsync(2, tray.TrayCode); - await hyosungPlcService.WritePrintLabelResultAsync(arg1, true); - // await varietyService.SetLastNo(variety.Id, tray.ControlNo.Value); - //await hyosungWmsService.UpdateControlNo(variety, tray.ControlNo.Value); - await hyosungWmsService.AddLabelResult(new LabelResult(tray, variety)); - } - + await printer.PrintAsync(arg1, tray.TrayCode); + await hyosungPlcService.WritePrintLabelResultAsync(arg1, true); logger.LogInformation($"plc request print label success"); } catch (Exception e)