Subject: [PATCH] 更新打印部分代码 --- Index: Seyounth.Hyosung.Core/Agv/HyosungAgvService.cs IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/Seyounth.Hyosung.Core/Agv/HyosungAgvService.cs b/Seyounth.Hyosung.Core/Agv/HyosungAgvService.cs --- a/Seyounth.Hyosung.Core/Agv/HyosungAgvService.cs (revision e3f343fbb080e86d7154639348f436b03e9362b4) +++ b/Seyounth.Hyosung.Core/Agv/HyosungAgvService.cs (revision ce0a2a6362e96697323b6547b4d1697e25e07072) @@ -35,7 +35,7 @@ PositionCode = bin.CtnrCode, Type = "05" }; - var ctnrType = await dictService.GetKeyAsync("AgvRackType", height.ToString()); + var ctnrType = await dictService.GetKeyAsync("AgvRackType", bin.Height.ToString()); await _agv.CarryToAsync(start, stop, ctnrType, 120, "1"); await agvBinService.BindAsync(bin); } Index: Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs b/Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs --- a/Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs (revision e3f343fbb080e86d7154639348f436b03e9362b4) +++ b/Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs (revision ce0a2a6362e96697323b6547b4d1697e25e07072) @@ -105,14 +105,25 @@ 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; @@ -254,11 +265,11 @@ YarnCount = status[0], TotalYarnCount = status[1] }; - if (yarn1!=0) + if (yarn1 != 0) info.YarnCode.Add(yarn1); - if (yarn2!=0) + if (yarn2 != 0) info.YarnCode.Add(yarn2); - if (yarn3!=0) + if (yarn3 != 0) info.YarnCode.Add(yarn3); if (info.YarnCode.Count != info.YarnCount) { Index: Seyounth.Hyosung.Core/Plc/IHyosungPlcService.cs IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/Seyounth.Hyosung.Core/Plc/IHyosungPlcService.cs b/Seyounth.Hyosung.Core/Plc/IHyosungPlcService.cs --- a/Seyounth.Hyosung.Core/Plc/IHyosungPlcService.cs (revision e3f343fbb080e86d7154639348f436b03e9362b4) +++ b/Seyounth.Hyosung.Core/Plc/IHyosungPlcService.cs (revision ce0a2a6362e96697323b6547b4d1697e25e07072) @@ -58,7 +58,7 @@ Task WritePackLineOptionAsync(PackLineOption option); - Task WritePrintLabelResultAsync(int index, bool result); + Task WritePrintLabelResultAsync(int index, int side, bool result); /// /// Plc请求扫描产品 Index: Seyounth.Hyosung.Core/Printer/HyosungPrinter.cs IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/Seyounth.Hyosung.Core/Printer/HyosungPrinter.cs b/Seyounth.Hyosung.Core/Printer/HyosungPrinter.cs --- a/Seyounth.Hyosung.Core/Printer/HyosungPrinter.cs (revision e3f343fbb080e86d7154639348f436b03e9362b4) +++ b/Seyounth.Hyosung.Core/Printer/HyosungPrinter.cs (revision ce0a2a6362e96697323b6547b4d1697e25e07072) @@ -111,7 +111,7 @@ { "1670dtex -144F", $"\"{tray.DtexFila}\"" }, { "1500D - 144F", $"\"{tray.DenFila}\"" }, { "$SA", $"\"{tray.Grade}\"" }, - { "$900", $"\"{labelResult.NET_WEIGHT.ToString("0.0")}\"" }, + { "$900", $"\"{labelResult.NET_WEIGHT:0.0}\"" }, { "25-01-01", $"\"{DateTime.Now:yy-MM-dd}\"" }, { "$90", $"\"{variety.TotalCount}\"" }, { "$965", $"\"{labelResult.GROSS_WEIGHT}\"" }, Index: Seyounth.Hyosung.Data/Entities/AgvBinEntity.cs IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/Seyounth.Hyosung.Data/Entities/AgvBinEntity.cs b/Seyounth.Hyosung.Data/Entities/AgvBinEntity.cs --- a/Seyounth.Hyosung.Data/Entities/AgvBinEntity.cs (revision e3f343fbb080e86d7154639348f436b03e9362b4) +++ b/Seyounth.Hyosung.Data/Entities/AgvBinEntity.cs (revision ce0a2a6362e96697323b6547b4d1697e25e07072) @@ -31,4 +31,6 @@ [SugarColumn(ColumnDescription = "排序")] public int Sort { get; set; } + + public bool IsDeleted { get; set; } } \ No newline at end of file Index: Seyounth.Hyosung.Data/Services/AgvBinService.cs IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/Seyounth.Hyosung.Data/Services/AgvBinService.cs b/Seyounth.Hyosung.Data/Services/AgvBinService.cs --- a/Seyounth.Hyosung.Data/Services/AgvBinService.cs (revision e3f343fbb080e86d7154639348f436b03e9362b4) +++ b/Seyounth.Hyosung.Data/Services/AgvBinService.cs (revision ce0a2a6362e96697323b6547b4d1697e25e07072) @@ -18,22 +18,43 @@ public async Task GetAvailableBin(int height) { - if (height < 180) + var bin = await _repository.AsQueryable() + .Where(x => x.IsFree && x.IsDeleted == false) + .OrderBy(x => x.Sort) + .FirstAsync(); + if (bin.BinCode == "B10") + { + await _repository.AsUpdateable() + .Where(x => x.RackType == 2 && x.IsDeleted == false) + .SetColumns(x => x.IsFree, true) + .ExecuteCommandAsync(); + } + else if (bin.BinCode == "B33") { - 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 == 1 && x.IsDeleted == false) + .SetColumns(x => x.IsFree, true) + .ExecuteCommandAsync(); } - return _cache.Where(a => a is { IsFree: true }).OrderBy(a => a.CtnrType).First(); + return bin; + + // if (height < 180) + // { + // 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(); + // } + // + // return _cache.Where(a => a is { IsFree: true }).OrderBy(a => a.CtnrType).First(); } public Task BindAsync(AgvBinEntity entity) Index: Seyounth.Hyosung.Data/Services/Hyosung/HyosungWmsService.cs IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/Seyounth.Hyosung.Data/Services/Hyosung/HyosungWmsService.cs b/Seyounth.Hyosung.Data/Services/Hyosung/HyosungWmsService.cs --- a/Seyounth.Hyosung.Data/Services/Hyosung/HyosungWmsService.cs (revision e3f343fbb080e86d7154639348f436b03e9362b4) +++ b/Seyounth.Hyosung.Data/Services/Hyosung/HyosungWmsService.cs (revision ce0a2a6362e96697323b6547b4d1697e25e07072) @@ -53,12 +53,12 @@ else { await _db.Updateable() - .SetColumns(i => new MST_BOXNO_SEQ_NON_DATE - { - LastNo = controlNo, - ModifiedTime = DateTime.Now, - 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(); @@ -70,7 +70,7 @@ try { string code = $"{itemCode.Trim()} {DateTime.Now.AddDays(0):yyMMdd}"; - string code2 = $"{lot.Trim()}{(controlNo-1).ToString().PadLeft(4, '0')}0"; + string code2 = $"{lot.Trim()}{(controlNo - 1).ToString().PadLeft(4, '0')}0"; // 使用 SqlSugar 进行查询 return await _db.Queryable() @@ -80,10 +80,10 @@ x.BE_ID == "2240" ) .FirstAsync(); - } catch (Exception e) + } + catch (Exception e) { throw e; } - } } \ No newline at end of file Index: Seyounth.Hyosung.Runtime/HyosungRuntime.cs IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/Seyounth.Hyosung.Runtime/HyosungRuntime.cs b/Seyounth.Hyosung.Runtime/HyosungRuntime.cs --- a/Seyounth.Hyosung.Runtime/HyosungRuntime.cs (revision e3f343fbb080e86d7154639348f436b03e9362b4) +++ b/Seyounth.Hyosung.Runtime/HyosungRuntime.cs (revision ce0a2a6362e96697323b6547b4d1697e25e07072) @@ -291,29 +291,31 @@ 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"); } } Index: Seyounth.Hyosung/ViewModels/HomeViewModel.cs IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/Seyounth.Hyosung/ViewModels/HomeViewModel.cs b/Seyounth.Hyosung/ViewModels/HomeViewModel.cs --- a/Seyounth.Hyosung/ViewModels/HomeViewModel.cs (revision e3f343fbb080e86d7154639348f436b03e9362b4) +++ b/Seyounth.Hyosung/ViewModels/HomeViewModel.cs (revision ce0a2a6362e96697323b6547b4d1697e25e07072) @@ -51,5 +51,6 @@ { Stack1 = _runtime.Stack1; Stack2 = _runtime.Stack2; + PackLineOption = _runtime.PackLineOption; } } \ No newline at end of file Index: Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml b/Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml --- a/Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml (revision e3f343fbb080e86d7154639348f436b03e9362b4) +++ b/Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml (revision ce0a2a6362e96697323b6547b4d1697e25e07072) @@ -68,6 +68,9 @@ DisplayMemberBinding="{Binding Lot}" Header="Lot" /> + @@ -125,6 +128,9 @@ + @@ -305,7 +311,7 @@ - + @@ -317,27 +323,27 @@ - + - + - - + + - + - + - + Index: Seyounth.Hyosung/Views/Pages/VarietyPage.xaml IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/Seyounth.Hyosung/Views/Pages/VarietyPage.xaml b/Seyounth.Hyosung/Views/Pages/VarietyPage.xaml --- a/Seyounth.Hyosung/Views/Pages/VarietyPage.xaml (revision e3f343fbb080e86d7154639348f436b03e9362b4) +++ b/Seyounth.Hyosung/Views/Pages/VarietyPage.xaml (revision ce0a2a6362e96697323b6547b4d1697e25e07072) @@ -67,6 +67,8 @@ AutoGenerateColumns="False" HeadersVisibility="All" VerticalContentAlignment="Center" + VirtualizingStackPanel.IsVirtualizing="True" + VirtualizingStackPanel.VirtualizationMode="Recycling" ItemsSource="{Binding ViewModel.Varieties, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" CellEditEnding="DataGrid_CellEditEnding">