From c527e8135fab6bb44db0f15bc0c9194957c2b857 Mon Sep 17 00:00:00 2001 From: zhangzhuo <512464164@qq.com> Date: Wed, 19 Mar 2025 02:42:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBUG=20=20=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E4=B8=BA=E5=8F=AF=E6=89=93=E5=8D=B0=E6=A0=87?= =?UTF-8?q?=E7=AD=BE2=201=E5=BC=A0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Plc/HyosungPlcService.cs | 9 ++--- .../Printer/HyosungPrinter.cs | 2 +- .../Services/Hyosung/Entities/LabelResult.cs | 2 +- .../Services/Hyosung/HyosungWmsService.cs | 36 ++++++++++++------- Seyounth.Hyosung.Data/Services/TrayService.cs | 11 +++++- Seyounth.Hyosung.Runtime/HyosungRuntime.cs | 12 ++++--- 6 files changed, 47 insertions(+), 25 deletions(-) diff --git a/Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs b/Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs index 872fbde..e1f03f2 100644 --- a/Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs +++ b/Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs @@ -97,18 +97,19 @@ public class HyosungPlcService(ILogger logger) : IHyosungPlcS List ls = new List(); ls.Add((short)option.HeadCount); ls.Add((short)(option.IsTop ? 1 : 2)); - await _writer.WriteShortsAsync(12120, ls.ToArray()); - ls.Clear(); + ls.Add(1); ls.Add((short)(option.HasBox ? 1 : 2)); ls.Add((short)(option.IsPack ? 1 : 2)); ls.Add((short)(option.IsFilm ? 1 : 2)); ls.Add((short)(option.IsLam ? 1 : 2)); - await _writer.WriteShortsAsync(12123, ls.ToArray()); + await _writer.WriteShortsAsync(12120, ls.ToArray()); } public async Task WritePrintLabelResultAsync(int index, bool result) { var address = index == 1 ? 13060 : 13061; + if (index == 2) + await _writer.WriteShortsAsync(13053, 4); await _writer.WriteShortsAsync(address, (short)(result ? 1 : 2)); } @@ -298,7 +299,7 @@ public class HyosungPlcService(ILogger logger) : IHyosungPlcS if (requestPrintLabel[1] == 1) { - var trayCode = await _reader.ReadStringAsync(13001); + var trayCode = await _reader.ReadStringAsync(13000); await _writer.WriteShortsAsync(13011, 0); await _writer.WriteShortsAsync(13012, 0); OnRequestPrintLabel?.Invoke(2, trayCode, requestPrintLabel[2]); diff --git a/Seyounth.Hyosung.Core/Printer/HyosungPrinter.cs b/Seyounth.Hyosung.Core/Printer/HyosungPrinter.cs index c35e2b3..e7b98c9 100644 --- a/Seyounth.Hyosung.Core/Printer/HyosungPrinter.cs +++ b/Seyounth.Hyosung.Core/Printer/HyosungPrinter.cs @@ -111,7 +111,7 @@ public class HyosungPrinter( { "1670dtex -144F", $"\"{tray.DtexFila}\"" }, { "1500D - 144F", $"\"{tray.DenFila}\"" }, { "$SA", $"\"{tray.Grade}\"" }, - { "$900", $"\"{labelResult.NET_WEIGHT}\"" }, + { "$900", $"\"{labelResult.NET_WEIGHT.ToString("0.0")}\"" }, { "25-01-01", $"\"{DateTime.Now:yy-MM-dd}\"" }, { "$90", $"\"{variety.TotalCount}\"" }, { "$965", $"\"{labelResult.GROSS_WEIGHT}\"" }, diff --git a/Seyounth.Hyosung.Data/Services/Hyosung/Entities/LabelResult.cs b/Seyounth.Hyosung.Data/Services/Hyosung/Entities/LabelResult.cs index 670df31..0cbe46a 100644 --- a/Seyounth.Hyosung.Data/Services/Hyosung/Entities/LabelResult.cs +++ b/Seyounth.Hyosung.Data/Services/Hyosung/Entities/LabelResult.cs @@ -5,7 +5,7 @@ namespace Seyounth.Hyosung.Data.Services.Hyosung.Entities; [SugarTable("LABEL_RESULT")] public class LabelResult { - public int BE_ID { get; set; } + public string BE_ID { get; set; } public string BAR_CODE { get; set; } public string ITEM_CODE { get; set; } public string LABEL_ID { get; set; } diff --git a/Seyounth.Hyosung.Data/Services/Hyosung/HyosungWmsService.cs b/Seyounth.Hyosung.Data/Services/Hyosung/HyosungWmsService.cs index 75bf340..7cb6c21 100644 --- a/Seyounth.Hyosung.Data/Services/Hyosung/HyosungWmsService.cs +++ b/Seyounth.Hyosung.Data/Services/Hyosung/HyosungWmsService.cs @@ -53,9 +53,12 @@ public class HyosungWmsService : IHyosungWmsService else { await _db.Updateable() - .SetColumns(i => i.LastNo == controlNo - && i.ModifiedTime == DateTime.Now - && i.ModifiedBy == "seyounth") + .SetColumns(i => new MST_BOXNO_SEQ_NON_DATE + { + LastNo = controlNo, + ModifiedTime = DateTime.Now, + ModifiedBy = "seyounth" + }) .Where(i => i.BeId == "2240" && i.ItemCode == variety.Code && i.CheckCode == checkCode).ExecuteCommandAsync(); @@ -64,16 +67,23 @@ public class HyosungWmsService : IHyosungWmsService public async Task GetLabelResult(string itemCode, string lot, int controlNo) { - string code = $"{itemCode.Trim()} {DateTime.Now.AddDays(0):yyMMdd}"; - string code2 = $"{lot.Trim()}{controlNo.ToString().PadLeft(4, '0')}0"; + try + { + string code = $"{itemCode.Trim()} {DateTime.Now.AddDays(0):yyMMdd}"; + string code2 = $"{lot.Trim()}{(controlNo-1).ToString().PadLeft(4, '0')}0"; - // 使用 SqlSugar 进行查询 - return await _db.Queryable() - .Where(x => - x.BAR_CODE.Substring(0, 24) == code && - x.BAR_CODE.Substring(x.BAR_CODE.Length - 9, 9) == code2 && - x.BE_ID == 2240 - ) - .FirstAsync(); + // 使用 SqlSugar 进行查询 + return await _db.Queryable() + .Where(x => + x.BAR_CODE.Substring(0, 24) == code && + x.BAR_CODE.Substring(x.BAR_CODE.Length - 9, 9) == code2 && + x.BE_ID == "2240" + ) + .FirstAsync(); + } catch (Exception e) + { + throw e; + } + } } \ No newline at end of file diff --git a/Seyounth.Hyosung.Data/Services/TrayService.cs b/Seyounth.Hyosung.Data/Services/TrayService.cs index e9989aa..143d75b 100644 --- a/Seyounth.Hyosung.Data/Services/TrayService.cs +++ b/Seyounth.Hyosung.Data/Services/TrayService.cs @@ -68,7 +68,16 @@ public class TrayService : ITrayService public async Task PrintTrayAsync(string trayCode, int stackHeight, int controlNo, MST_ITEM_2240_V itemInfo) { - var tray = _cache[trayCode]; + Tray tray; + try + { + tray = _cache[trayCode]; + } + catch + { + tray = await GetByCode(trayCode); + } + tray.ControlNo = controlNo; tray.StackHeight = stackHeight; tray.Grade = itemInfo.GRADE; diff --git a/Seyounth.Hyosung.Runtime/HyosungRuntime.cs b/Seyounth.Hyosung.Runtime/HyosungRuntime.cs index abd217c..c85ea72 100644 --- a/Seyounth.Hyosung.Runtime/HyosungRuntime.cs +++ b/Seyounth.Hyosung.Runtime/HyosungRuntime.cs @@ -291,22 +291,24 @@ public class HyosungRuntime( logger.LogInformation($"plc request print label:{arg1} {trayCode} {height}"); try { - if (arg1 == 1) - { + var tray = await trayService.GetByCode(trayCode); var variety = await varietyService.GetById(tray.VarietyId); var mod = await hyosungWmsService.GetItemInfoByItemCode(variety.Code); var grade = "1"; if (mod.GRADE != "AA") grade = mod.GRADE; var controlNo = await hyosungWmsService.GetControlNo(variety, grade); - await trayService.PrintTrayAsync(trayCode, height, controlNo, mod); - await printer.PrintAsync(1, trayCode); - await hyosungWmsService.UpdateControlNo(variety, controlNo); + await trayService.PrintTrayAsync(trayCode, height, controlNo, mod); + if (arg1 == 1) + { + + await printer.PrintAsync(1, trayCode); } else await printer.PrintAsync(2, trayCode); await hyosungPlcService.WritePrintLabelResultAsync(arg1, true); + await hyosungWmsService.UpdateControlNo(variety, controlNo); logger.LogInformation($"plc request print label success"); } catch (Exception e)