seyounth.hyosung.ty/0001-.patch

372 lines
17 KiB
Diff
Raw Normal View History

2025-03-20 18:28:21 +08:00
From ce0a2a6362e96697323b6547b4d1697e25e07072 Mon Sep 17 00:00:00 2001
From: anerx <512464164@qq.com>
Date: Thu, 20 Mar 2025 18:28:21 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=89=93=E5=8D=B0=E9=83=A8?=
=?UTF-8?q?=E5=88=86=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Agv/HyosungAgvService.cs | 2 +-
.../Plc/HyosungPlcService.cs | 21 +++++++--
.../Plc/IHyosungPlcService.cs | 2 +-
.../Printer/HyosungPrinter.cs | 2 +-
.../Entities/AgvBinEntity.cs | 2 +
.../Services/AgvBinService.cs | 47 ++++++++++++++-----
.../Services/Hyosung/HyosungWmsService.cs | 18 +++----
Seyounth.Hyosung.Runtime/HyosungRuntime.cs | 24 +++++-----
Seyounth.Hyosung/ViewModels/HomeViewModel.cs | 1 +
.../Views/Pages/HomeViewPage.xaml | 22 +++++----
Seyounth.Hyosung/Views/Pages/VarietyPage.xaml | 2 +
11 files changed, 94 insertions(+), 49 deletions(-)
diff --git a/Seyounth.Hyosung.Core/Agv/HyosungAgvService.cs b/Seyounth.Hyosung.Core/Agv/HyosungAgvService.cs
index 5d804af..7d095f4 100644
--- a/Seyounth.Hyosung.Core/Agv/HyosungAgvService.cs
+++ b/Seyounth.Hyosung.Core/Agv/HyosungAgvService.cs
@@ -35,7 +35,7 @@ public class HyosungAgvService(
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);
}
diff --git a/Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs b/Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs
index 9a5da67..14198dc 100644
--- a/Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs
+++ b/Seyounth.Hyosung.Core/Plc/HyosungPlcService.cs
@@ -105,14 +105,25 @@ public class HyosungPlcService(ILogger<HyosungPlcService> 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<int, Task>? OnPlcRequestScanProduct;
@@ -254,11 +265,11 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
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)
{
diff --git a/Seyounth.Hyosung.Core/Plc/IHyosungPlcService.cs b/Seyounth.Hyosung.Core/Plc/IHyosungPlcService.cs
index c92c092..13208d0 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 WritePrintLabelResultAsync(int index, bool result);
+ Task WritePrintLabelResultAsync(int index, int side, bool result);
/// <summary>
/// Plc请求扫描产品
diff --git a/Seyounth.Hyosung.Core/Printer/HyosungPrinter.cs b/Seyounth.Hyosung.Core/Printer/HyosungPrinter.cs
index 31abdbf..9e3d9b8 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.ToString("0.0")}\"" },
+ { "$900", $"\"{labelResult.NET_WEIGHT:0.0}\"" },
{ "25-01-01", $"\"{DateTime.Now:yy-MM-dd}\"" },
{ "$90", $"\"{variety.TotalCount}\"" },
{ "$965", $"\"{labelResult.GROSS_WEIGHT}\"" },
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/Services/AgvBinService.cs b/Seyounth.Hyosung.Data/Services/AgvBinService.cs
index 74211c1..7436ae1 100644
--- a/Seyounth.Hyosung.Data/Services/AgvBinService.cs
+++ b/Seyounth.Hyosung.Data/Services/AgvBinService.cs
@@ -18,22 +18,43 @@ public class AgvBinService : IAgvBinService
public async Task<AgvBinEntity> 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")
{
- 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 == false)
+ .SetColumns(x => x.IsFree, true)
+ .ExecuteCommandAsync();
}
+ else if (bin.BinCode == "B33")
+ {
+ await _repository.AsUpdateable()
+ .Where(x => x.RackType == 1 && x.IsDeleted == false)
+ .SetColumns(x => x.IsFree, true)
+ .ExecuteCommandAsync();
+ }
+
+ return bin;
- return _cache.Where(a => a is { IsFree: true }).OrderBy(a => a.CtnrType).First();
+ // 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)
diff --git a/Seyounth.Hyosung.Data/Services/Hyosung/HyosungWmsService.cs b/Seyounth.Hyosung.Data/Services/Hyosung/HyosungWmsService.cs
index 7cb6c21..4513593 100644
--- a/Seyounth.Hyosung.Data/Services/Hyosung/HyosungWmsService.cs
+++ b/Seyounth.Hyosung.Data/Services/Hyosung/HyosungWmsService.cs
@@ -53,12 +53,12 @@ public class HyosungWmsService : IHyosungWmsService
else
{
await _db.Updateable<MST_BOXNO_SEQ_NON_DATE>()
- .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 @@ public class HyosungWmsService : IHyosungWmsService
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<LabelResult>()
@@ -80,10 +80,10 @@ public class HyosungWmsService : IHyosungWmsService
x.BE_ID == "2240"
)
.FirstAsync();
- } catch (Exception e)
+ }
+ catch (Exception e)
{
throw e;
}
-
}
}
\ No newline at end of file
diff --git a/Seyounth.Hyosung.Runtime/HyosungRuntime.cs b/Seyounth.Hyosung.Runtime/HyosungRuntime.cs
index 7165216..87fa36a 100644
--- a/Seyounth.Hyosung.Runtime/HyosungRuntime.cs
+++ b/Seyounth.Hyosung.Runtime/HyosungRuntime.cs
@@ -291,29 +291,31 @@ public class HyosungRuntime(
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/ViewModels/HomeViewModel.cs b/Seyounth.Hyosung/ViewModels/HomeViewModel.cs
index ecfee3b..b48e525 100644
--- a/Seyounth.Hyosung/ViewModels/HomeViewModel.cs
+++ b/Seyounth.Hyosung/ViewModels/HomeViewModel.cs
@@ -51,5 +51,6 @@ public partial class HomeViewModel : ObservableObject
{
Stack1 = _runtime.Stack1;
Stack2 = _runtime.Stack2;
+ PackLineOption = _runtime.PackLineOption;
}
}
\ No newline at end of file
diff --git a/Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml b/Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml
index 3ffc4b3..74b45b0 100644
--- a/Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml
+++ b/Seyounth.Hyosung/Views/Pages/HomeViewPage.xaml
@@ -67,6 +67,9 @@
<GridViewColumn
DisplayMemberBinding="{Binding Lot}"
Header="Lot" />
+ <GridViewColumn
+ DisplayMemberBinding="{Binding ScanTime}"
+ Header="扫码时间" />
<GridViewColumn
DisplayMemberBinding="{Binding StackTime}"
Header="码垛时间" />
@@ -125,6 +128,9 @@
<GridViewColumn
DisplayMemberBinding="{Binding Lot}"
Header="Lot" />
+ <GridViewColumn
+ DisplayMemberBinding="{Binding ScanTime}"
+ Header="扫码时间" />
<GridViewColumn
DisplayMemberBinding="{Binding StackTime}"
Header="码垛时间" />
@@ -305,7 +311,7 @@
</Grid.ColumnDefinitions>
<TextBlock VerticalAlignment="Center" Margin="10"
Foreground="White" Grid.Row="0" Grid.Column="0" Text="主-贴标数:" />
- <TextBox Foreground="White" IsEnabled="False" Margin="10" Grid.Row="0" Grid.Column="1" />
+ <TextBox Foreground="White" IsEnabled="False" Margin="10" Grid.Row="0" Grid.Column="1" />
<TextBlock VerticalAlignment="Center" Margin="10"
Foreground="White" Grid.Row="1" Grid.Column="0" Text="主-前:" />
<CheckBox Grid.Row="1" Grid.Column="1" HorizontalAlignment="Center" />
@@ -317,27 +323,27 @@
<TextBlock VerticalAlignment="Center" Margin="10"
Foreground="White" Grid.Row="3" Grid.Column="0" Text="主-后:" />
<CheckBox Grid.Row="3" Grid.Column="1" HorizontalAlignment="Center" />
-
+
<TextBlock VerticalAlignment="Center" Margin="10"
Foreground="White" Grid.Row="4" Grid.Column="0" Text="主-右:" />
<CheckBox Grid.Row="4" Grid.Column="1" HorizontalAlignment="Center" />
-
+
<TextBlock VerticalAlignment="Center" Margin="10"
Foreground="White" Grid.Row="0" Grid.Column="2" Text="副-贴标数:" />
- <TextBox Foreground="White" IsEnabled="False" Margin="10" Grid.Row="0" Grid.Column="3" />
-
+ <TextBox Foreground="White" IsEnabled="False" Margin="10" Grid.Row="0" Grid.Column="3" />
+
<TextBlock VerticalAlignment="Center" Margin="10"
Foreground="White" Grid.Row="1" Grid.Column="2" Text="副-前:" />
<CheckBox Grid.Row="1" Grid.Column="3" HorizontalAlignment="Center" />
-
+
<TextBlock VerticalAlignment="Center" Margin="10"
Foreground="White" Grid.Row="2" Grid.Column="2" Text="副-左:" />
<CheckBox Grid.Row="2" Grid.Column="3" HorizontalAlignment="Center" />
-
+
<TextBlock VerticalAlignment="Center" Margin="10"
Foreground="White" Grid.Row="3" Grid.Column="2" Text="副-后:" />
<CheckBox Grid.Row="3" Grid.Column="3" HorizontalAlignment="Center" />
-
+
<TextBlock VerticalAlignment="Center" Margin="10"
Foreground="White" Grid.Row="4" Grid.Column="2" Text="副-右:" />
<CheckBox Grid.Row="4" Grid.Column="3" HorizontalAlignment="Center" />
diff --git a/Seyounth.Hyosung/Views/Pages/VarietyPage.xaml b/Seyounth.Hyosung/Views/Pages/VarietyPage.xaml
index 0713f96..ea2e362 100644
--- a/Seyounth.Hyosung/Views/Pages/VarietyPage.xaml
+++ b/Seyounth.Hyosung/Views/Pages/VarietyPage.xaml
@@ -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">
<DataGrid.Columns>
--
2.43.0.windows.1