From ab2ae0969af9280443498834694e9707d83781e3 Mon Sep 17 00:00:00 2001 From: anerx <512464164@qq.com> Date: Thu, 20 Mar 2025 19:32:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Extensions/DateTimeExtensions.cs | 4 +- .../Agv/HyosungAgvService.cs | 2 +- .../Agv/IHyosungAgvService.cs | 2 +- .../Plc/HyosungPlcService.cs | 51 +++++++++++-------- .../Plc/IHyosungPlcService.cs | 10 ++-- Seyounth.Hyosung.Core/Plc/McPlc.cs | 21 -------- .../Printer/HyosungPrinter.cs | 2 +- .../Printer/IHyosungPrinter.cs | 2 +- .../Entities/AgvBinEntity.cs | 2 + .../Entities/ScannedYarnEntity.cs | 2 +- Seyounth.Hyosung.Data/Entities/TrayEntity.cs | 4 +- .../Models/Plc/PackLineOption.cs | 2 +- .../Models/Plc/PlcStackInfo.cs | 2 +- .../Models/Plc/PlcStackingInfo.cs | 4 +- Seyounth.Hyosung.Data/Models/Tray.cs | 2 +- Seyounth.Hyosung.Data/Models/Yarn.cs | 6 +-- .../Services/AgvBinService.cs | 28 +++++----- .../Services/ITrayService.cs | 8 +-- .../Services/IYarnService.cs | 8 +-- Seyounth.Hyosung.Data/Services/TrayService.cs | 21 ++++---- Seyounth.Hyosung.Data/Services/YarnService.cs | 10 ++-- Seyounth.Hyosung.Runtime/HyosungRuntime.cs | 28 +++++----- .../Models/StackStationModel.cs | 2 +- 23 files changed, 109 insertions(+), 114 deletions(-) diff --git a/Seyounth.Core/Extensions/DateTimeExtensions.cs b/Seyounth.Core/Extensions/DateTimeExtensions.cs index 3b6736f..326190b 100644 --- a/Seyounth.Core/Extensions/DateTimeExtensions.cs +++ b/Seyounth.Core/Extensions/DateTimeExtensions.cs @@ -2,8 +2,8 @@ namespace Seyounth.Core.Extensions; public static class DateTimeExtensions { - public static long ToTimestamp(this DateTime dateTime) + public static int ToTimestamp(this DateTime dateTime) { - return new DateTimeOffset(dateTime).ToUnixTimeMilliseconds(); + return (int)new DateTimeOffset(dateTime).ToUnixTimeSeconds(); } } \ No newline at end of file diff --git a/Seyounth.Hyosung.Core/Agv/HyosungAgvService.cs b/Seyounth.Hyosung.Core/Agv/HyosungAgvService.cs index 7d095f4..5f88bab 100644 --- a/Seyounth.Hyosung.Core/Agv/HyosungAgvService.cs +++ b/Seyounth.Hyosung.Core/Agv/HyosungAgvService.cs @@ -13,7 +13,7 @@ public class HyosungAgvService( private readonly HikAgv _agv = new(loggerFactory.CreateLogger()); - public async Task StorageAsync(long trayCode) + public async Task StorageAsync(string trayCode) { AgvStatusInfo? status; do diff --git a/Seyounth.Hyosung.Core/Agv/IHyosungAgvService.cs b/Seyounth.Hyosung.Core/Agv/IHyosungAgvService.cs index 46e57ca..a94d7a0 100644 --- a/Seyounth.Hyosung.Core/Agv/IHyosungAgvService.cs +++ b/Seyounth.Hyosung.Core/Agv/IHyosungAgvService.cs @@ -7,5 +7,5 @@ public interface IHyosungAgvService /// /// /// - Task StorageAsync(long trayCode); + Task StorageAsync(string trayCode); } \ No newline at end of file diff --git a/Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs b/Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs index 9a5da67..1b752ab 100644 --- a/Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs +++ b/Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs @@ -46,12 +46,12 @@ public class HyosungPlcService(ILogger logger) : IHyosungPlcS logger.LogInformation($"write [{variety.Id}] to plc address[4230]"); } - public async Task WriteScanYarnResultAsync(bool result, short? varietyId = null, long yarnCode = 0) + public async Task WriteScanYarnResultAsync(bool result, short? varietyId = null, string? yarnCode= null ) { if (result && yarnCode != null && varietyId != null) { await _writer.WriteShortsAsync(4009, varietyId.Value); - await _writer.WriteLongAsync(4010, yarnCode); + await _writer.WriteStringAsync(4010, yarnCode); logger.LogInformation($"write [{yarnCode}] to plc address[4010]"); } @@ -81,10 +81,10 @@ public class HyosungPlcService(ILogger logger) : IHyosungPlcS isLeaving = false; } - public async Task WriteTrayCodeAsync(int index, long trayCode) + public async Task WriteTrayCodeAsync(int index, string trayCode) { var address = index == 1 ? 4100 : 4110; - await _writer.WriteLongAsync(address, trayCode); + await _writer.WriteStringAsync(address, trayCode); } public async Task WriteReceivedYarnCountAsync(int count) @@ -105,14 +105,25 @@ public class HyosungPlcService(ILogger logger) : IHyosungPlcS await _writer.WriteShortsAsync(12120, ls.ToArray()); } - public async Task WritePrintLabelResultAsync(int index, bool result) + public async Task WritePrintLabelResultAsync(int index, int side, bool result) { var address = index == 1 ? 13060 : 13061; if (index == 2) - await _writer.WriteShortsAsync(13053, 4); + { + var data = SetBit(0, side); + await _writer.WriteShortsAsync(13053, data); + } + await _writer.WriteShortsAsync(address, (short)(result ? 1 : 2)); } + static byte SetBit(byte value, int bitPosition) + { + // 创建一个掩码,该掩码只有第 bitPosition 位为 1 + byte mask = (byte)(1 << bitPosition); + // 使用按位或操作将 value 的第 bitPosition 位置为 1 + return (byte)(value | mask); + } public event Func? OnPlcRequestScanProduct; @@ -124,9 +135,9 @@ public class HyosungPlcService(ILogger logger) : IHyosungPlcS public event Func? OnPlcPutCompleted; - public event Func? OnPlcRequestPackLineOption; + public event Func? OnPlcRequestPackLineOption; - public event Func? OnRequestPrintLabel; + public event Func? OnRequestPrintLabel; private async Task ReadLoop(CancellationToken token) @@ -205,8 +216,8 @@ public class HyosungPlcService(ILogger logger) : IHyosungPlcS if (leavingProductionLine[0] == 1) { await _writer.WriteShortsAsync(4020, 0); - var trayCode = await _reader.ReadLongAsync(12600); - if (trayCode != 0) + var trayCode = await _reader.ReadStringAsync(12600); + if (!string.IsNullOrEmpty(trayCode)) { PlcStackInfo info = new PlcStackInfo() { @@ -244,21 +255,21 @@ public class HyosungPlcService(ILogger logger) : IHyosungPlcS if (status[0] > 0) { await _writer.WriteShortsAsync(4690, 0, 0, 0); - var trayCode = await _reader.ReadLongAsync(4620); - var yarn1 = await _reader.ReadLongAsync(4630); - var yarn2 = await _reader.ReadLongAsync(4640); - var yarn3 = await _reader.ReadLongAsync(4650); + var trayCode = await _reader.ReadStringAsync(4620); + var yarn1 = await _reader.ReadStringAsync(4630); + var yarn2 = await _reader.ReadStringAsync(4640); + var yarn3 = await _reader.ReadStringAsync(4650); var info = new PlcStackingInfo() { TrayCode = trayCode, YarnCount = status[0], TotalYarnCount = status[1] }; - if (yarn1!=0) + if (!string.IsNullOrEmpty(yarn1)) info.YarnCode.Add(yarn1); - if (yarn2!=0) + if (!string.IsNullOrEmpty(yarn2)) info.YarnCode.Add(yarn2); - if (yarn3!=0) + if (!string.IsNullOrEmpty(yarn3)) info.YarnCode.Add(yarn3); if (info.YarnCode.Count != info.YarnCount) { @@ -280,7 +291,7 @@ public class HyosungPlcService(ILogger logger) : IHyosungPlcS var requestPackLineOption = await _reader.ReadShortsAsync(4022, 1); if (requestPackLineOption[0] == 1) { - var trayCode = await _reader.ReadLongAsync(12100); + var trayCode = await _reader.ReadStringAsync(12100); await _writer.WriteShortsAsync(4022, 0); OnPlcRequestPackLineOption?.Invoke(trayCode); } @@ -291,7 +302,7 @@ public class HyosungPlcService(ILogger logger) : IHyosungPlcS var requestPrintLabel = await _reader.ReadShortsAsync(13010, 3); if (requestPrintLabel[0] == 1) { - var trayCode = await _reader.ReadLongAsync(13000); + var trayCode = await _reader.ReadStringAsync(13000); await _writer.WriteShortsAsync(13010, 0); await _writer.WriteShortsAsync(13012, 0); OnRequestPrintLabel?.Invoke(1, trayCode, requestPrintLabel[2]); @@ -299,7 +310,7 @@ public class HyosungPlcService(ILogger logger) : IHyosungPlcS if (requestPrintLabel[1] == 1) { - var trayCode = await _reader.ReadLongAsync(13000); + 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/Plc/IHyosungPlcService.cs b/Seyounth.Hyosung.Core/Plc/IHyosungPlcService.cs index c92c092..3cc2f4f 100644 --- a/Seyounth.Hyosung.Core/Plc/IHyosungPlcService.cs +++ b/Seyounth.Hyosung.Core/Plc/IHyosungPlcService.cs @@ -24,7 +24,7 @@ public interface IHyosungPlcService /// 品类ID /// 纱码 /// - Task WriteScanYarnResultAsync(bool result, short? varietyId = null, long yarnCode = 0); + Task WriteScanYarnResultAsync(bool result, short? varietyId = null, string? yarnCode = null); /// /// 写入治具扫码结果 @@ -47,7 +47,7 @@ public interface IHyosungPlcService /// /// /// - Task WriteTrayCodeAsync(int index, long trayCode); + Task WriteTrayCodeAsync(int index, string trayCode); /// /// 写入收到的纱数量 @@ -58,7 +58,7 @@ public interface IHyosungPlcService Task WritePackLineOptionAsync(PackLineOption option); - Task WritePrintLabelResultAsync(int index, bool result); + Task WritePrintLabelResultAsync(int index, int side, bool result); /// /// Plc请求扫描产品 @@ -88,10 +88,10 @@ public interface IHyosungPlcService /// /// Plc请求打包线选项 /// - event Func OnPlcRequestPackLineOption; + event Func OnPlcRequestPackLineOption; /// /// 贴标站请求贴标 /// - event Func OnRequestPrintLabel; + event Func OnRequestPrintLabel; } \ No newline at end of file diff --git a/Seyounth.Hyosung.Core/Plc/McPlc.cs b/Seyounth.Hyosung.Core/Plc/McPlc.cs index 268319b..b86f602 100644 --- a/Seyounth.Hyosung.Core/Plc/McPlc.cs +++ b/Seyounth.Hyosung.Core/Plc/McPlc.cs @@ -51,27 +51,6 @@ public class McPlc(string host, int port, Mitsubishi.McFrame type) return shorts; } - public async Task ReadLongAsync(int address) - { - // 一个 long 类型是 8 字节,所以需要读取 8 个字节的数据 - var bytes = await ReadBytesAsync(address, 8); - // 确保读取到了足够的字节 - if (bytes.Length < 8) - { - throw new Exception("读取 long 类型数据时字节数不足"); - } - // 将字节数组转换为 long 类型 - return BitConverter.ToInt64(bytes, 0); - } - - public async Task WriteLongAsync(int address, long value) - { - byte[] bytes = BitConverter.GetBytes(value); - - // Write the byte array to the PLC - await WriteBytesAsync(address, bytes); - } - public async Task WriteShortsAsync(int address, params short[] values) { var code = await _mc.WriteDeviceBlock(Mitsubishi.PlcDeviceType.D, address, values.Length, diff --git a/Seyounth.Hyosung.Core/Printer/HyosungPrinter.cs b/Seyounth.Hyosung.Core/Printer/HyosungPrinter.cs index 31abdbf..e7b98c9 100644 --- a/Seyounth.Hyosung.Core/Printer/HyosungPrinter.cs +++ b/Seyounth.Hyosung.Core/Printer/HyosungPrinter.cs @@ -34,7 +34,7 @@ public class HyosungPrinter( logger.LogInformation("printer disconnected"); } - public async Task PrintAsync(int index, long trayCode) + public async Task PrintAsync(int index, string trayCode) { var tray = await trayService.GetByCode(trayCode); if (index == 1) diff --git a/Seyounth.Hyosung.Core/Printer/IHyosungPrinter.cs b/Seyounth.Hyosung.Core/Printer/IHyosungPrinter.cs index 1a41047..4a2cbac 100644 --- a/Seyounth.Hyosung.Core/Printer/IHyosungPrinter.cs +++ b/Seyounth.Hyosung.Core/Printer/IHyosungPrinter.cs @@ -11,5 +11,5 @@ public interface IHyosungPrinter /// /// /// - Task PrintAsync(int index,long trayCode); + Task PrintAsync(int index,string trayCode); } \ No newline at end of file diff --git a/Seyounth.Hyosung.Data/Entities/AgvBinEntity.cs b/Seyounth.Hyosung.Data/Entities/AgvBinEntity.cs index e6143bd..b426c16 100644 --- a/Seyounth.Hyosung.Data/Entities/AgvBinEntity.cs +++ b/Seyounth.Hyosung.Data/Entities/AgvBinEntity.cs @@ -31,4 +31,6 @@ public class AgvBinEntity [SugarColumn(ColumnDescription = "排序")] public int Sort { get; set; } + + public bool IsDeleted { get; set; } } \ No newline at end of file diff --git a/Seyounth.Hyosung.Data/Entities/ScannedYarnEntity.cs b/Seyounth.Hyosung.Data/Entities/ScannedYarnEntity.cs index 3ee217d..cc731c2 100644 --- a/Seyounth.Hyosung.Data/Entities/ScannedYarnEntity.cs +++ b/Seyounth.Hyosung.Data/Entities/ScannedYarnEntity.cs @@ -12,7 +12,7 @@ public class ScannedYarnEntity public string QrCode { get; set; } [SugarColumn(ColumnDescription = "纱线代码", Length = 20)] - public long ScanCode { get; set; } + public string ScanCode { get; set; } [SugarColumn(ColumnDescription = "Lot")] public int Lot { get; set; } diff --git a/Seyounth.Hyosung.Data/Entities/TrayEntity.cs b/Seyounth.Hyosung.Data/Entities/TrayEntity.cs index 0b3c324..5f69179 100644 --- a/Seyounth.Hyosung.Data/Entities/TrayEntity.cs +++ b/Seyounth.Hyosung.Data/Entities/TrayEntity.cs @@ -9,12 +9,12 @@ public class TrayEntity public int Id { get; set; } [SugarColumn(ColumnDescription = "托盘唯一号")] - public long TrayCode { get; set; } + public string TrayCode { get; set; } [SugarColumn(ColumnDescription = "所属的品类信息")] public int VarietyId { get; set; } - [SugarColumn(ColumnDescription = "垛高", IsNullable = true)] + [SugarColumn(ColumnDescription = "垛高",IsNullable =true)] public int? StackHeight { get; set; } [SugarColumn(ColumnDescription = "是否为双号")] diff --git a/Seyounth.Hyosung.Data/Models/Plc/PackLineOption.cs b/Seyounth.Hyosung.Data/Models/Plc/PackLineOption.cs index 0eb7fe4..13d0e74 100644 --- a/Seyounth.Hyosung.Data/Models/Plc/PackLineOption.cs +++ b/Seyounth.Hyosung.Data/Models/Plc/PackLineOption.cs @@ -16,5 +16,5 @@ public partial class PackLineOption : ObservableObject [ObservableProperty] private bool isLam; - [ObservableProperty] private long trayCode; + [ObservableProperty] private string trayCode; } \ No newline at end of file diff --git a/Seyounth.Hyosung.Data/Models/Plc/PlcStackInfo.cs b/Seyounth.Hyosung.Data/Models/Plc/PlcStackInfo.cs index 88282ff..4899f27 100644 --- a/Seyounth.Hyosung.Data/Models/Plc/PlcStackInfo.cs +++ b/Seyounth.Hyosung.Data/Models/Plc/PlcStackInfo.cs @@ -5,6 +5,6 @@ namespace Seyounth.Hyosung.Data.Models.Plc; /// public class PlcStackInfo { - public long TrayCode { get; set; } + public string TrayCode { get; set; } } \ No newline at end of file diff --git a/Seyounth.Hyosung.Data/Models/Plc/PlcStackingInfo.cs b/Seyounth.Hyosung.Data/Models/Plc/PlcStackingInfo.cs index 873bcd1..0975857 100644 --- a/Seyounth.Hyosung.Data/Models/Plc/PlcStackingInfo.cs +++ b/Seyounth.Hyosung.Data/Models/Plc/PlcStackingInfo.cs @@ -2,9 +2,9 @@ namespace Seyounth.Hyosung.Data.Models.Plc; public class PlcStackingInfo { - public long TrayCode { get; set; } + public string TrayCode { get; set; } - public List YarnCode { get; set; } = new (); + public List YarnCode { get; set; } = new List(); public int YarnCount { get; set; } diff --git a/Seyounth.Hyosung.Data/Models/Tray.cs b/Seyounth.Hyosung.Data/Models/Tray.cs index 26aec10..dbb07df 100644 --- a/Seyounth.Hyosung.Data/Models/Tray.cs +++ b/Seyounth.Hyosung.Data/Models/Tray.cs @@ -6,7 +6,7 @@ public class Tray { public int Id { get; set; } - public long TrayCode { get; set; } + public string TrayCode { get; set; } public int VarietyId { get; set; } diff --git a/Seyounth.Hyosung.Data/Models/Yarn.cs b/Seyounth.Hyosung.Data/Models/Yarn.cs index 8e6496e..3a19b26 100644 --- a/Seyounth.Hyosung.Data/Models/Yarn.cs +++ b/Seyounth.Hyosung.Data/Models/Yarn.cs @@ -9,7 +9,7 @@ public class Yarn public string QrCode { get; set; } - public long ScanCode { get; set; } + public string ScanCode { get; set; } public int Lot { get; set; } @@ -53,7 +53,7 @@ public class Yarn ProduceTime = parts[3], ScanTime = DateTime.Now, VarietyId = varietyId, - ScanCode = DateTime.Now.ToTimestamp(), + ScanCode = DateTime.Now.ToTimestamp().ToString(), TrayId = null }; yarn.WorkShift = parts[1] switch @@ -79,7 +79,7 @@ public class Yarn ScanTime = DateTime.Now, VarietyId = varietyId, TrayId = null, - ScanCode = DateTime.Now.ToTimestamp(), + ScanCode = DateTime.Now.ToTimestamp().ToString().PadLeft(10, '0'), }; yarn.WorkShift = parts[5] switch { diff --git a/Seyounth.Hyosung.Data/Services/AgvBinService.cs b/Seyounth.Hyosung.Data/Services/AgvBinService.cs index 74211c1..be932ca 100644 --- a/Seyounth.Hyosung.Data/Services/AgvBinService.cs +++ b/Seyounth.Hyosung.Data/Services/AgvBinService.cs @@ -18,22 +18,24 @@ public class AgvBinService : IAgvBinService public async Task GetAvailableBin(int height) { - if (height < 180) + var bin = await _repository.AsQueryable() + .Where(x => x.IsFree && !x.IsDeleted).OrderBy(x => x.Sort).FirstAsync(); + if (bin.BinCode == "B10") { - return _cache - .Where(x => - x is { CtnrType: 1, IsFree: true } || - x is { CtnrType: 2, IsFree: true } && - _cache.Any(y => - y is { CtnrType: 1, IsFree: false } && y.BinCode == x.BinCode && - y is { Height: < 180 }) - ) - .OrderByDescending(x => x.CtnrType) - .ThenBy(x => x.Sort) - .First(); + await _repository.AsUpdateable() + .Where(x => x.RackType == 2 && !x.IsDeleted) + .SetColumns(x => x.IsFree, true) + .ExecuteCommandAsync(); + } + else if (bin.BinCode == "B33") + { + await _repository.AsUpdateable() + .Where(x => x.RackType == 1 && !x.IsDeleted) + .SetColumns(x => x.IsFree, true) + .ExecuteCommandAsync(); } - return _cache.Where(a => a is { IsFree: true }).OrderBy(a => a.CtnrType).First(); + return bin; } public Task BindAsync(AgvBinEntity entity) diff --git a/Seyounth.Hyosung.Data/Services/ITrayService.cs b/Seyounth.Hyosung.Data/Services/ITrayService.cs index 0741330..bc574f9 100644 --- a/Seyounth.Hyosung.Data/Services/ITrayService.cs +++ b/Seyounth.Hyosung.Data/Services/ITrayService.cs @@ -17,21 +17,21 @@ public interface ITrayService /// /// /// - Task GetIdByCode(long code); + Task GetIdByCode(string code); /// /// /// /// /// - Task GetByCode(long code); + Task GetByCode(string code); /// /// 生成控制号 /// /// /// - Task StorageAsync(long trayCode); + Task StorageAsync(string trayCode); /// /// 打印托盘 @@ -41,5 +41,5 @@ public interface ITrayService /// /// /// - Task PrintTrayAsync(long trayCode, int stackHeight, int controlNo, MST_ITEM_2240_V itemInfo); + Task PrintTrayAsync(string trayCode, int stackHeight, int controlNo, MST_ITEM_2240_V itemInfo); } \ No newline at end of file diff --git a/Seyounth.Hyosung.Data/Services/IYarnService.cs b/Seyounth.Hyosung.Data/Services/IYarnService.cs index 43c72ac..3a90579 100644 --- a/Seyounth.Hyosung.Data/Services/IYarnService.cs +++ b/Seyounth.Hyosung.Data/Services/IYarnService.cs @@ -5,21 +5,21 @@ namespace Seyounth.Hyosung.Data.Services; public interface IYarnService { - ConcurrentDictionary NoFinished { get; } + ConcurrentDictionary NoFinished { get; } Task AddYarnAsync(Yarn yarn); Task> GetYarnsByTrayIdAsync(int trayId); - Task GetYarnByCodeAsync(long code); + Task GetYarnByCodeAsync(string code); /// /// 完成指定纱 /// /// /// - Task FinishYarnAsync(long yarnCode); + Task FinishYarnAsync(string yarnCode); /// /// 绑定托盘号 @@ -27,5 +27,5 @@ public interface IYarnService /// /// /// - Task BindTrayAsync(long yarnCode, int trayId); + Task BindTrayAsync(string yarnCode, int trayId); } \ No newline at end of file diff --git a/Seyounth.Hyosung.Data/Services/TrayService.cs b/Seyounth.Hyosung.Data/Services/TrayService.cs index f4e7725..143d75b 100644 --- a/Seyounth.Hyosung.Data/Services/TrayService.cs +++ b/Seyounth.Hyosung.Data/Services/TrayService.cs @@ -11,7 +11,7 @@ namespace Seyounth.Hyosung.Data.Services; public class TrayService : ITrayService { - private readonly ConcurrentDictionary _cache = new(); + private readonly ConcurrentDictionary _cache = new(); private readonly IRepository _repository; private readonly IHyosungWmsService _hyosungWmsService; @@ -30,7 +30,7 @@ public class TrayService : ITrayService { var tray = new Tray() { - TrayCode = DateTime.Now.ToTimestamp(), + TrayCode =DateTime.Now.ToTimestamp().ToString(), VarietyId = varietyId, CreateTime = DateTime.Now }; @@ -42,19 +42,21 @@ public class TrayService : ITrayService return tray; } - public async Task GetIdByCode(long code) + public async Task GetIdByCode(string code) { try { return _cache[code].Id; + } catch { return (await _repository.GetFirstAsync(d => d.TrayCode == code)).Id; } + } - public async Task GetByCode(long code) + public async Task GetByCode(string code) { return Tray.FromEntity(await _repository.GetSingleAsync(t => t.TrayCode == code)); } @@ -64,7 +66,7 @@ public class TrayService : ITrayService throw new NotImplementedException(); } - public async Task PrintTrayAsync(long trayCode, int stackHeight, int controlNo, MST_ITEM_2240_V itemInfo) + public async Task PrintTrayAsync(string trayCode, int stackHeight, int controlNo, MST_ITEM_2240_V itemInfo) { Tray tray; try @@ -75,7 +77,7 @@ public class TrayService : ITrayService { tray = await GetByCode(trayCode); } - + tray.ControlNo = controlNo; tray.StackHeight = stackHeight; tray.Grade = itemInfo.GRADE; @@ -89,11 +91,8 @@ public class TrayService : ITrayService _cache.Remove(tray.TrayCode, out _); } - public async Task StorageAsync(long trayCode) + public async Task StorageAsync(string trayCode) { - var tray = await GetByCode(trayCode); - tray.FinishTime = DateTime.Now; - await _repository.UpdateAsync(tray.ToEntity()); - _cache.Remove(tray.TrayCode, out _); + } } \ No newline at end of file diff --git a/Seyounth.Hyosung.Data/Services/YarnService.cs b/Seyounth.Hyosung.Data/Services/YarnService.cs index b55003f..138993b 100644 --- a/Seyounth.Hyosung.Data/Services/YarnService.cs +++ b/Seyounth.Hyosung.Data/Services/YarnService.cs @@ -13,7 +13,7 @@ public class YarnService : IYarnService public YarnService(IServiceProvider provider) { _yarnRepository = provider.CreateScope().ServiceProvider.GetRequiredService>(); - NoFinished = new ConcurrentDictionary(); + NoFinished = new ConcurrentDictionary(); var yarns = _yarnRepository.GetList(y => !y.IsFinished); foreach (var yarn in yarns) { @@ -21,7 +21,7 @@ public class YarnService : IYarnService } } - public ConcurrentDictionary NoFinished { get; } + public ConcurrentDictionary NoFinished { get; } public async Task AddYarnAsync(Yarn yarn) { @@ -37,7 +37,7 @@ public class YarnService : IYarnService .Select(Yarn.FromEntity).ToList(); } - public async Task GetYarnByCodeAsync(long code) + public async Task GetYarnByCodeAsync(string code) { try { @@ -50,7 +50,7 @@ public class YarnService : IYarnService } - public async Task FinishYarnAsync(long yarnCode) + public async Task FinishYarnAsync(string yarnCode) { var yarn = NoFinished[yarnCode]; yarn.IsFinished = true; @@ -58,7 +58,7 @@ public class YarnService : IYarnService NoFinished.TryRemove(yarnCode, out _); } - public async Task BindTrayAsync(long yarnCode, int trayId) + public async Task BindTrayAsync(string yarnCode, int trayId) { var yarn = NoFinished[yarnCode]; yarn.TrayId = trayId; diff --git a/Seyounth.Hyosung.Runtime/HyosungRuntime.cs b/Seyounth.Hyosung.Runtime/HyosungRuntime.cs index 7165216..18b7d17 100644 --- a/Seyounth.Hyosung.Runtime/HyosungRuntime.cs +++ b/Seyounth.Hyosung.Runtime/HyosungRuntime.cs @@ -245,7 +245,7 @@ public class HyosungRuntime( /// /// /// - private async Task OnPlcRequestPackLineOption(long arg) + private async Task OnPlcRequestPackLineOption(string arg) { logger.LogInformation($"plc request pack line option"); try @@ -286,34 +286,36 @@ public class HyosungRuntime( /// /// /// - private async Task OnPlcRequestPrintLabel(int arg1, long trayCode, int height) + private async Task OnPlcRequestPrintLabel(int arg1, string trayCode, int height) { logger.LogInformation($"plc request print label:{arg1} {trayCode} {height}"); try { - - 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); + 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); if (arg1 == 1) { - - await printer.PrintAsync(1, trayCode); + await printer.PrintAsync(1, trayCode); + await hyosungPlcService.WritePrintLabelResultAsync(arg1, variety.SubLabelCount, true); } else + { await printer.PrintAsync(2, trayCode); + await hyosungPlcService.WritePrintLabelResultAsync(arg1, variety.MasterLabelCount, true); + } + - await hyosungPlcService.WritePrintLabelResultAsync(arg1, true); await hyosungWmsService.UpdateControlNo(variety, controlNo); logger.LogInformation($"plc request print label success"); } catch (Exception e) { - await hyosungPlcService.WritePrintLabelResultAsync(arg1, false); + await hyosungPlcService.WritePrintLabelResultAsync(arg1, 1,false); logger.LogError(e, "print label fail"); } } diff --git a/Seyounth.Hyosung.Runtime/Models/StackStationModel.cs b/Seyounth.Hyosung.Runtime/Models/StackStationModel.cs index 254d8ac..2ba2c04 100644 --- a/Seyounth.Hyosung.Runtime/Models/StackStationModel.cs +++ b/Seyounth.Hyosung.Runtime/Models/StackStationModel.cs @@ -9,7 +9,7 @@ namespace Seyounth.Hyosung.Runtime.Models; public partial class StackStationModel { [ObservableProperty] [DefaultValue("NoData")] - private long trayCode; + private string trayCode; [ObservableProperty] [DefaultValue("NoData")] private string varietyCode;