Compare commits
No commits in common. "master" and "Code-long" have entirely different histories.
371
0001-.patch
371
0001-.patch
@ -1,371 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
||||||
@ -1,7 +1,6 @@
|
|||||||
using System.Net.Http.Json;
|
using System.Net.Http.Json;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Seyounth.Hyosung.Core.Agv.HikModels;
|
using Seyounth.Hyosung.Core.Agv.HikModels;
|
||||||
using Seyounth.Hyosung.Data.Entities;
|
|
||||||
|
|
||||||
namespace Seyounth.Hyosung.Core.Agv;
|
namespace Seyounth.Hyosung.Core.Agv;
|
||||||
|
|
||||||
@ -46,8 +45,7 @@ public class HikAgv(ILogger<HikAgv> logger)
|
|||||||
logger.LogInformation($"task {taskCode} cancel succeed.");
|
logger.LogInformation($"task {taskCode} cancel succeed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string> CarryToAsync(AgvPosition start, AgvPosition end, string ctnrType, int priority,
|
public async Task CarryToAsync(AgvPosition start, AgvPosition end, string ctnrType, int priority, string taskType)
|
||||||
string taskType)
|
|
||||||
{
|
{
|
||||||
var url = Url + SchedulingTaskUri;
|
var url = Url + SchedulingTaskUri;
|
||||||
var input = new
|
var input = new
|
||||||
@ -66,75 +64,17 @@ public class HikAgv(ILogger<HikAgv> logger)
|
|||||||
var rs = await PostAsync<string>(url, input);
|
var rs = await PostAsync<string>(url, input);
|
||||||
if (rs is null)
|
if (rs is null)
|
||||||
{
|
{
|
||||||
throw new NullReferenceException($"{start.PositionCode} carry to {end.PositionCode} error: result is null");
|
logger.LogWarning($"{start.PositionCode} carry to {end.PositionCode} error: result is null");
|
||||||
}
|
|
||||||
|
|
||||||
if (rs.Code != "0")
|
|
||||||
{
|
|
||||||
throw new Exception(
|
|
||||||
$"{start.PositionCode} carry to {end.PositionCode} error: code is {rs.Code} message is {rs.Message}");
|
|
||||||
}
|
|
||||||
|
|
||||||
return rs.Data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task WaitingForTaskCompletedAsync(string taskCode)
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
var input = new
|
|
||||||
{
|
|
||||||
reqCode = GetRequestCode(),
|
|
||||||
taskCodes = new List<string> { taskCode }
|
|
||||||
};
|
|
||||||
var rs = await PostAsync<List<TaskStatusModel>>(Url + "queryTaskStatus", input);
|
|
||||||
if (rs is null)
|
|
||||||
{
|
|
||||||
throw new NullReferenceException($"task {taskCode} wait completed error: result is null");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rs.Code != "0")
|
|
||||||
{
|
|
||||||
throw new Exception($"task {taskCode} wait completed error: code is {rs.Code} message is {rs.Message}");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查是否有符合条件的任务状态为 9
|
|
||||||
var task = rs.Data.FirstOrDefault(t => t.taskCode == taskCode);
|
|
||||||
if (task is { taskStatus: "9" })
|
|
||||||
{
|
|
||||||
logger.LogInformation($"task {taskCode} wait completed succeed");
|
|
||||||
break; // 退出循环
|
|
||||||
}
|
|
||||||
|
|
||||||
// 可以添加适当的延迟,避免频繁请求
|
|
||||||
await Task.Delay(1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task UnBin(AgvBinEntity bin)
|
|
||||||
{
|
|
||||||
var url = Url + "bindCtnrAndBin";
|
|
||||||
var input = new
|
|
||||||
{
|
|
||||||
reqCode = GetRequestCode(),
|
|
||||||
stgBinCode = bin.CtnrCode,
|
|
||||||
ctnrTyp = bin.HeightCode,
|
|
||||||
indBind = "0"
|
|
||||||
};
|
|
||||||
var rs = await PostAsync<string>(url, input);
|
|
||||||
if (rs is null)
|
|
||||||
{
|
|
||||||
logger.LogWarning($"agv unbin {bin.CtnrCode} error: result is null");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rs.Code != "0")
|
if (rs.Code != "0")
|
||||||
{
|
{
|
||||||
logger.LogWarning($"agv unbin {bin.CtnrCode} error: code is {rs.Code} message:{rs.Message}");
|
logger.LogWarning($"{start.PositionCode} carry to {end.PositionCode} error: code is {rs.Code}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.LogInformation($"agv unbin {bin.CtnrCode} succeed");
|
logger.LogInformation($"{start.PositionCode} carry to {end.PositionCode} succeed");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task MovingToAsync(AgvPosition des, string taskType)
|
public async Task MovingToAsync(AgvPosition des, string taskType)
|
||||||
|
|||||||
@ -1,8 +0,0 @@
|
|||||||
namespace Seyounth.Hyosung.Core.Agv.HikModels;
|
|
||||||
|
|
||||||
public class TaskStatusModel
|
|
||||||
{
|
|
||||||
public string taskCode { get; set; }
|
|
||||||
|
|
||||||
public string taskStatus { get; set; }
|
|
||||||
}
|
|
||||||
@ -1,6 +1,5 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Seyounth.Hyosung.Core.Agv.HikModels;
|
using Seyounth.Hyosung.Core.Agv.HikModels;
|
||||||
using Seyounth.Hyosung.Data.Entities;
|
|
||||||
using Seyounth.Hyosung.Data.Services;
|
using Seyounth.Hyosung.Data.Services;
|
||||||
|
|
||||||
namespace Seyounth.Hyosung.Core.Agv;
|
namespace Seyounth.Hyosung.Core.Agv;
|
||||||
@ -14,7 +13,7 @@ public class HyosungAgvService(
|
|||||||
private readonly HikAgv _agv = new(loggerFactory.CreateLogger<HikAgv>());
|
private readonly HikAgv _agv = new(loggerFactory.CreateLogger<HikAgv>());
|
||||||
|
|
||||||
|
|
||||||
public async Task StorageAsync(string trayCode)
|
public async Task StorageAsync(long trayCode)
|
||||||
{
|
{
|
||||||
AgvStatusInfo? status;
|
AgvStatusInfo? status;
|
||||||
do
|
do
|
||||||
@ -24,7 +23,7 @@ public class HyosungAgvService(
|
|||||||
} while (status is null);
|
} while (status is null);
|
||||||
|
|
||||||
var tray = await trayService.GetByCode(trayCode);
|
var tray = await trayService.GetByCode(trayCode);
|
||||||
var height = (int)Math.Ceiling((double)((tray.StackHeight ?? 0) / 10.0)!);
|
var height = (int)Math.Ceiling((double)(tray.StackHeight / 10.0)!);
|
||||||
var bin = await agvBinService.GetAvailableBin(height);
|
var bin = await agvBinService.GetAvailableBin(height);
|
||||||
AgvPosition start = new AgvPosition()
|
AgvPosition start = new AgvPosition()
|
||||||
{
|
{
|
||||||
@ -36,20 +35,8 @@ public class HyosungAgvService(
|
|||||||
PositionCode = bin.CtnrCode,
|
PositionCode = bin.CtnrCode,
|
||||||
Type = "05"
|
Type = "05"
|
||||||
};
|
};
|
||||||
if (!string.IsNullOrEmpty(bin.HeightCode))
|
var ctnrType = await dictService.GetKeyAsync("AgvRackType", height.ToString());
|
||||||
await UnBin(bin);
|
await _agv.CarryToAsync(start, stop, ctnrType, 120, "1");
|
||||||
var ctnrType = await dictService.GetKeyAsync("AgvRackType", bin.Height.ToString());
|
|
||||||
if (string.IsNullOrEmpty(ctnrType))
|
|
||||||
ctnrType = "14";
|
|
||||||
bin.HeightCode = ctnrType;
|
|
||||||
|
|
||||||
var taskCode = await _agv.CarryToAsync(start, stop, ctnrType, 120, "1");
|
|
||||||
await _agv.WaitingForTaskCompletedAsync(taskCode);
|
|
||||||
await agvBinService.BindAsync(bin);
|
await agvBinService.BindAsync(bin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UnBin(AgvBinEntity bin)
|
|
||||||
{
|
|
||||||
await _agv.UnBin(bin);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,5 +1,3 @@
|
|||||||
using Seyounth.Hyosung.Data.Entities;
|
|
||||||
|
|
||||||
namespace Seyounth.Hyosung.Core.Agv;
|
namespace Seyounth.Hyosung.Core.Agv;
|
||||||
|
|
||||||
public interface IHyosungAgvService
|
public interface IHyosungAgvService
|
||||||
@ -9,7 +7,5 @@ public interface IHyosungAgvService
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="trayCode"></param>
|
/// <param name="trayCode"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task StorageAsync(string trayCode);
|
Task StorageAsync(long trayCode);
|
||||||
|
|
||||||
Task UnBin(AgvBinEntity bin);
|
|
||||||
}
|
}
|
||||||
@ -1,4 +1,3 @@
|
|||||||
using System.Text.Json;
|
|
||||||
using MCProtocol;
|
using MCProtocol;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Seyounth.Hyosung.Data.Models;
|
using Seyounth.Hyosung.Data.Models;
|
||||||
@ -47,12 +46,12 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
logger.LogInformation($"write [{variety.Id}] to plc address[4230]");
|
logger.LogInformation($"write [{variety.Id}] to plc address[4230]");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task WriteScanYarnResultAsync(bool result, short? varietyId = null, string? yarnCode = null)
|
public async Task WriteScanYarnResultAsync(bool result, short? varietyId = null, long yarnCode = 0)
|
||||||
{
|
{
|
||||||
if (result && yarnCode != null && varietyId != null)
|
if (result && yarnCode != null && varietyId != null)
|
||||||
{
|
{
|
||||||
await _writer.WriteShortsAsync(4009, varietyId.Value);
|
await _writer.WriteShortsAsync(4009, varietyId.Value);
|
||||||
await _writer.WriteStringAsync(4010, yarnCode);
|
await _writer.WriteLongAsync(4010, yarnCode);
|
||||||
logger.LogInformation($"write [{yarnCode}] to plc address[4010]");
|
logger.LogInformation($"write [{yarnCode}] to plc address[4010]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,10 +81,10 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
isLeaving = false;
|
isLeaving = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task WriteTrayCodeAsync(int index, string trayCode)
|
public async Task WriteTrayCodeAsync(int index, long trayCode)
|
||||||
{
|
{
|
||||||
var address = index == 1 ? 4100 : 4110;
|
var address = index == 1 ? 4100 : 4110;
|
||||||
await _writer.WriteStringAsync(address, trayCode);
|
await _writer.WriteLongAsync(address, trayCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task WriteReceivedYarnCountAsync(int count)
|
public async Task WriteReceivedYarnCountAsync(int count)
|
||||||
@ -106,71 +105,14 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
await _writer.WriteShortsAsync(12120, ls.ToArray());
|
await _writer.WriteShortsAsync(12120, ls.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task WritePrintLableOptionsAsync(int side, int slave)
|
|
||||||
{
|
|
||||||
short masterCount = 0;
|
|
||||||
switch (side)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
masterCount = 1;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
masterCount = 2;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
masterCount = 6;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
masterCount = 14;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
masterCount = 30;
|
|
||||||
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, 2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task WritePrintLabelResultAsync(int index, bool result)
|
public async Task WritePrintLabelResultAsync(int index, bool result)
|
||||||
{
|
{
|
||||||
var address = index == 1 ? 13060 : 13061;
|
var address = index == 1 ? 13060 : 13061;
|
||||||
|
if (index == 2)
|
||||||
|
await _writer.WriteShortsAsync(13053, 4);
|
||||||
await _writer.WriteShortsAsync(address, (short)(result ? 1 : 2));
|
await _writer.WriteShortsAsync(address, (short)(result ? 1 : 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task WriteScanEntryResultAsync(int index, bool result)
|
|
||||||
{
|
|
||||||
var address = index == 1 ? 4530 : 4531;
|
|
||||||
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;
|
public event Func<int, Task>? OnPlcRequestScanProduct;
|
||||||
|
|
||||||
@ -182,11 +124,10 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
|
|
||||||
public event Func<PlcStackingInfo, Task>? OnPlcPutCompleted;
|
public event Func<PlcStackingInfo, Task>? OnPlcPutCompleted;
|
||||||
|
|
||||||
public event Func<string, Task>? OnPlcRequestPackLineOption;
|
public event Func<long, Task>? OnPlcRequestPackLineOption;
|
||||||
|
|
||||||
|
public event Func<int, long, int, Task>? OnRequestPrintLabel;
|
||||||
|
|
||||||
public event Func<int, int, Task>? OnRequestPrintLabel;
|
|
||||||
public event Func<string, Task> OnRequestGetPrintLableOption;
|
|
||||||
public event Func<int, Task>? OnRequestScanEntry;
|
|
||||||
|
|
||||||
private async Task ReadLoop(CancellationToken token)
|
private async Task ReadLoop(CancellationToken token)
|
||||||
{
|
{
|
||||||
@ -194,7 +135,6 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await QueryScanEntry();
|
|
||||||
await QueryScanProductRequest();
|
await QueryScanProductRequest();
|
||||||
await QueryScanFixtureRequest();
|
await QueryScanFixtureRequest();
|
||||||
if (!isLeaving)
|
if (!isLeaving)
|
||||||
@ -204,7 +144,6 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
await QueryPackLineOption();
|
await QueryPackLineOption();
|
||||||
await QueryPrintLabel();
|
await QueryPrintLabel();
|
||||||
await Task.Delay(100, token);
|
await Task.Delay(100, token);
|
||||||
await QueryGetPrintLabel();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -265,16 +204,17 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
// var stackStatus = await _reader.ReadShortsAsync(12110, 1);
|
// var stackStatus = await _reader.ReadShortsAsync(12110, 1);
|
||||||
if (leavingProductionLine[0] == 1)
|
if (leavingProductionLine[0] == 1)
|
||||||
{
|
{
|
||||||
var trayCode = await _reader.ReadStringAsync(12600);
|
await _writer.WriteShortsAsync(4020, 0);
|
||||||
//if (!string.IsNullOrEmpty(trayCode))
|
var trayCode = await _reader.ReadLongAsync(12600);
|
||||||
//{
|
if (trayCode != 0)
|
||||||
|
{
|
||||||
PlcStackInfo info = new PlcStackInfo()
|
PlcStackInfo info = new PlcStackInfo()
|
||||||
{
|
{
|
||||||
TrayCode = trayCode
|
TrayCode = trayCode
|
||||||
};
|
};
|
||||||
isLeaving = true;
|
isLeaving = true;
|
||||||
OnPlcRequestLeavingProductionLine?.Invoke(info);
|
OnPlcRequestLeavingProductionLine?.Invoke(info);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,24 +243,22 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
var status = await _reader.ReadShortsAsync(4691, 2);
|
var status = await _reader.ReadShortsAsync(4691, 2);
|
||||||
if (status[0] > 0)
|
if (status[0] > 0)
|
||||||
{
|
{
|
||||||
logger.LogInformation($"request put yarn completed");
|
|
||||||
await _writer.WriteShortsAsync(4690, 0, 0, 0);
|
await _writer.WriteShortsAsync(4690, 0, 0, 0);
|
||||||
var trayCode = await _reader.ReadStringAsync(4620);
|
var trayCode = await _reader.ReadLongAsync(4620);
|
||||||
var yarn1 = await _reader.ReadStringAsync(4630);
|
var yarn1 = await _reader.ReadLongAsync(4630);
|
||||||
var yarn2 = await _reader.ReadStringAsync(4640);
|
var yarn2 = await _reader.ReadLongAsync(4640);
|
||||||
var yarn3 = await _reader.ReadStringAsync(4650);
|
var yarn3 = await _reader.ReadLongAsync(4650);
|
||||||
var info = new PlcStackingInfo()
|
var info = new PlcStackingInfo()
|
||||||
{
|
{
|
||||||
TrayCode = trayCode,
|
TrayCode = trayCode,
|
||||||
YarnCount = status[0],
|
YarnCount = status[0],
|
||||||
TotalYarnCount = status[1]
|
TotalYarnCount = status[1]
|
||||||
};
|
};
|
||||||
logger.LogInformation($"request put yarn get info: {JsonSerializer.Serialize(info)}");
|
if (yarn1!=0)
|
||||||
if (!string.IsNullOrEmpty(yarn1))
|
|
||||||
info.YarnCode.Add(yarn1);
|
info.YarnCode.Add(yarn1);
|
||||||
if (!string.IsNullOrEmpty(yarn2))
|
if (yarn2!=0)
|
||||||
info.YarnCode.Add(yarn2);
|
info.YarnCode.Add(yarn2);
|
||||||
if (!string.IsNullOrEmpty(yarn3))
|
if (yarn3!=0)
|
||||||
info.YarnCode.Add(yarn3);
|
info.YarnCode.Add(yarn3);
|
||||||
if (info.YarnCode.Count != info.YarnCount)
|
if (info.YarnCode.Count != info.YarnCount)
|
||||||
{
|
{
|
||||||
@ -342,52 +280,29 @@ public class HyosungPlcService(ILogger<HyosungPlcService> logger) : IHyosungPlcS
|
|||||||
var requestPackLineOption = await _reader.ReadShortsAsync(4022, 1);
|
var requestPackLineOption = await _reader.ReadShortsAsync(4022, 1);
|
||||||
if (requestPackLineOption[0] == 1)
|
if (requestPackLineOption[0] == 1)
|
||||||
{
|
{
|
||||||
var trayCode = await _reader.ReadStringAsync(12100);
|
var trayCode = await _reader.ReadLongAsync(12100);
|
||||||
await _writer.WriteShortsAsync(4022, 0);
|
await _writer.WriteShortsAsync(4022, 0);
|
||||||
OnPlcRequestPackLineOption?.Invoke(trayCode);
|
OnPlcRequestPackLineOption?.Invoke(trayCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task QueryScanEntry()
|
|
||||||
{
|
|
||||||
var requestScanEntry = await _reader.ReadShortsAsync(4030, 2);
|
|
||||||
if (requestScanEntry[0] == 1)
|
|
||||||
{
|
|
||||||
await _writer.WriteShortsAsync(4030, 0);
|
|
||||||
OnRequestScanEntry?.Invoke(1);
|
|
||||||
}
|
|
||||||
else if (requestScanEntry[1] == 1)
|
|
||||||
{
|
|
||||||
await _writer.WriteShortsAsync(4030, 0);
|
|
||||||
OnRequestScanEntry?.Invoke(2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task QueryGetPrintLabel()
|
|
||||||
{
|
|
||||||
var trayCode = await _reader.ReadStringAsync(13000);
|
|
||||||
if (!string.IsNullOrEmpty(trayCode) && !trayCode.StartsWith("0000"))
|
|
||||||
{
|
|
||||||
await _reader.WriteStringAsync(13000, "00000000000000000000");
|
|
||||||
OnRequestGetPrintLableOption?.Invoke(trayCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task QueryPrintLabel()
|
private async Task QueryPrintLabel()
|
||||||
{
|
{
|
||||||
var requestPrintLabel = await _reader.ReadShortsAsync(13010, 3);
|
var requestPrintLabel = await _reader.ReadShortsAsync(13010, 3);
|
||||||
if (requestPrintLabel[0] == 1)
|
if (requestPrintLabel[0] == 1)
|
||||||
{
|
{
|
||||||
|
var trayCode = await _reader.ReadLongAsync(13000);
|
||||||
await _writer.WriteShortsAsync(13010, 0);
|
await _writer.WriteShortsAsync(13010, 0);
|
||||||
await _writer.WriteShortsAsync(13012, 0);
|
await _writer.WriteShortsAsync(13012, 0);
|
||||||
OnRequestPrintLabel?.Invoke(1, requestPrintLabel[2]);
|
OnRequestPrintLabel?.Invoke(1, trayCode, requestPrintLabel[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requestPrintLabel[1] == 1)
|
if (requestPrintLabel[1] == 1)
|
||||||
{
|
{
|
||||||
|
var trayCode = await _reader.ReadLongAsync(13000);
|
||||||
await _writer.WriteShortsAsync(13011, 0);
|
await _writer.WriteShortsAsync(13011, 0);
|
||||||
await _writer.WriteShortsAsync(13012, 0);
|
await _writer.WriteShortsAsync(13012, 0);
|
||||||
OnRequestPrintLabel?.Invoke(2, requestPrintLabel[2]);
|
OnRequestPrintLabel?.Invoke(2, trayCode, requestPrintLabel[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -24,7 +24,7 @@ public interface IHyosungPlcService
|
|||||||
/// <param name="varietyId">品类ID</param>
|
/// <param name="varietyId">品类ID</param>
|
||||||
/// <param name="yarnCode">纱码</param>
|
/// <param name="yarnCode">纱码</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task WriteScanYarnResultAsync(bool result, short? varietyId = null, string? yarnCode = null);
|
Task WriteScanYarnResultAsync(bool result, short? varietyId = null, long yarnCode = 0);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 写入治具扫码结果
|
/// 写入治具扫码结果
|
||||||
@ -47,7 +47,7 @@ public interface IHyosungPlcService
|
|||||||
/// <param name="index"></param>
|
/// <param name="index"></param>
|
||||||
/// <param name="trayCode"></param>
|
/// <param name="trayCode"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task WriteTrayCodeAsync(int index, string trayCode);
|
Task WriteTrayCodeAsync(int index, long trayCode);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 写入收到的纱数量
|
/// 写入收到的纱数量
|
||||||
@ -58,13 +58,8 @@ public interface IHyosungPlcService
|
|||||||
|
|
||||||
Task WritePackLineOptionAsync(PackLineOption option);
|
Task WritePackLineOptionAsync(PackLineOption option);
|
||||||
|
|
||||||
Task WritePrintLableOptionsAsync(int side,int slaveCount);
|
|
||||||
|
|
||||||
Task WritePrintLabelResultAsync(int index, bool result);
|
Task WritePrintLabelResultAsync(int index, bool result);
|
||||||
|
|
||||||
|
|
||||||
Task WriteScanEntryResultAsync(int index, bool result);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Plc请求扫描产品
|
/// Plc请求扫描产品
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -93,14 +88,10 @@ public interface IHyosungPlcService
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Plc请求打包线选项
|
/// Plc请求打包线选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
event Func<string, Task> OnPlcRequestPackLineOption;
|
event Func<long, Task> OnPlcRequestPackLineOption;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 贴标站请求贴标
|
/// 贴标站请求贴标
|
||||||
/// </summary>
|
/// </summary>
|
||||||
event Func<int, int, Task> OnRequestPrintLabel;
|
event Func<int, long, int, Task> OnRequestPrintLabel;
|
||||||
|
|
||||||
event Func<string, Task> OnRequestGetPrintLableOption;
|
|
||||||
|
|
||||||
event Func<int, Task> OnRequestScanEntry;
|
|
||||||
}
|
}
|
||||||
@ -51,6 +51,27 @@ public class McPlc(string host, int port, Mitsubishi.McFrame type)
|
|||||||
return shorts;
|
return shorts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<long> 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)
|
public async Task WriteShortsAsync(int address, params short[] values)
|
||||||
{
|
{
|
||||||
var code = await _mc.WriteDeviceBlock(Mitsubishi.PlcDeviceType.D, address, values.Length,
|
var code = await _mc.WriteDeviceBlock(Mitsubishi.PlcDeviceType.D, address, values.Length,
|
||||||
@ -79,8 +100,8 @@ public class McPlc(string host, int port, Mitsubishi.McFrame type)
|
|||||||
// 将字符串使用 ASCII 编码转换为字节数组
|
// 将字符串使用 ASCII 编码转换为字节数组
|
||||||
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(value);
|
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(value);
|
||||||
// 确保字节数组长度为 10
|
// 确保字节数组长度为 10
|
||||||
byte[] fixedLengthBytes = new byte[fixedLength*2];
|
byte[] fixedLengthBytes = new byte[fixedLength];
|
||||||
Array.Copy(bytes, fixedLengthBytes, Math.Min(bytes.Length, fixedLength*2));
|
Array.Copy(bytes, fixedLengthBytes, Math.Min(bytes.Length, fixedLength));
|
||||||
// 调用 WriteBytesAsync 方法写入字节数组
|
// 调用 WriteBytesAsync 方法写入字节数组
|
||||||
await WriteBytesAsync(address, fixedLengthBytes);
|
await WriteBytesAsync(address, fixedLengthBytes);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,32 +7,18 @@ public class AveryPrinter(string host, int port)
|
|||||||
{
|
{
|
||||||
public string Host => host;
|
public string Host => host;
|
||||||
public int Port => port;
|
public int Port => port;
|
||||||
private Socket _socket = new(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
private readonly Socket _socket = new(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||||
|
|
||||||
public async Task ConnectAsync(CancellationToken token)
|
public async Task ConnectAsync(CancellationToken token)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _socket.ConnectAsync(Host, Convert.ToInt32(port), token);
|
await _socket.ConnectAsync(Host, Convert.ToInt32(port), token);
|
||||||
}
|
}catch(Exception e)
|
||||||
catch (Exception e)
|
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Host[{Host}:{port}] error:{e.Message}");
|
Console.WriteLine($"Host[{Host}:{port}] error:{e.Message}");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<bool> CheckConnectAsync()
|
|
||||||
{
|
|
||||||
byte[] arrMsg = [0xff];
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await _socket.SendAsync(arrMsg); //发送字节数组
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task CloseAsync(CancellationToken token)
|
public async Task CloseAsync(CancellationToken token)
|
||||||
@ -43,13 +29,7 @@ public class AveryPrinter(string host, int port)
|
|||||||
|
|
||||||
public async Task SendContentAsync(string context)
|
public async Task SendContentAsync(string context)
|
||||||
{
|
{
|
||||||
if (!await CheckConnectAsync())
|
await _socket.SendAsync(Encoding.UTF8.GetBytes(context));
|
||||||
{
|
|
||||||
_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
|
||||||
await ConnectAsync(CancellationToken.None);
|
|
||||||
}
|
|
||||||
|
|
||||||
await _socket.SendAsync(Encoding.ASCII.GetBytes(context));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private const string CleanCmd = "#!A1#!CA#!P1";
|
private const string CleanCmd = "#!A1#!CA#!P1";
|
||||||
@ -57,23 +37,11 @@ public class AveryPrinter(string host, int port)
|
|||||||
|
|
||||||
public async Task CleanContextAsync()
|
public async Task CleanContextAsync()
|
||||||
{
|
{
|
||||||
if (!await CheckConnectAsync())
|
await _socket.SendAsync(Encoding.UTF8.GetBytes(CleanCmd));
|
||||||
{
|
|
||||||
_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
|
||||||
await ConnectAsync(CancellationToken.None);
|
|
||||||
}
|
|
||||||
|
|
||||||
await _socket.SendAsync(Encoding.ASCII.GetBytes(CleanCmd));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PrintAsync()
|
public async Task PrintAsync()
|
||||||
{
|
{
|
||||||
if (!await CheckConnectAsync())
|
await _socket.SendAsync(Encoding.UTF8.GetBytes(PrintCmd));
|
||||||
{
|
|
||||||
_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
|
||||||
await ConnectAsync(CancellationToken.None);
|
|
||||||
}
|
|
||||||
|
|
||||||
await _socket.SendAsync(Encoding.ASCII.GetBytes(PrintCmd));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -15,8 +15,8 @@ public class HyosungPrinter(
|
|||||||
IHyosungWmsService hyosungWmsService,
|
IHyosungWmsService hyosungWmsService,
|
||||||
IOptions<PrintTemp> options) : IHyosungPrinter
|
IOptions<PrintTemp> options) : IHyosungPrinter
|
||||||
{
|
{
|
||||||
private readonly AveryPrinter _masterPrinter = new("192.168.3.61", 9100);
|
private readonly AveryPrinter _masterPrinter = new("192.168.3.60", 9100);
|
||||||
private readonly AveryPrinter _slavePrinter = new("192.168.3.60", 9100);
|
private readonly AveryPrinter _slavePrinter = new("192.168.3.61", 9100);
|
||||||
|
|
||||||
public async Task StartAsync(CancellationToken token)
|
public async Task StartAsync(CancellationToken token)
|
||||||
{
|
{
|
||||||
@ -34,7 +34,7 @@ public class HyosungPrinter(
|
|||||||
logger.LogInformation("printer disconnected");
|
logger.LogInformation("printer disconnected");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PrintAsync(int index, string trayCode)
|
public async Task PrintAsync(int index, long trayCode)
|
||||||
{
|
{
|
||||||
var tray = await trayService.GetByCode(trayCode);
|
var tray = await trayService.GetByCode(trayCode);
|
||||||
if (index == 1)
|
if (index == 1)
|
||||||
@ -66,7 +66,7 @@ public class HyosungPrinter(
|
|||||||
private async Task<string> GetPrint1Content(Tray tray)
|
private async Task<string> GetPrint1Content(Tray tray)
|
||||||
{
|
{
|
||||||
var variety = await varietyService.GetById(tray.VarietyId);
|
var variety = await varietyService.GetById(tray.VarietyId);
|
||||||
var yarns = await yarnService.GetYarnsByTrayIdAsync(tray.Id);
|
var yarns = await yarnService.GetYarnsByTrayIdAsync(tray.VarietyId);
|
||||||
var dic = new Dictionary<string, string>();
|
var dic = new Dictionary<string, string>();
|
||||||
if (yarns.Count > 0)
|
if (yarns.Count > 0)
|
||||||
{
|
{
|
||||||
@ -84,7 +84,7 @@ public class HyosungPrinter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
string temp;
|
string temp;
|
||||||
if (variety.SubLabelCount == 1)
|
if (variety.MasterLabelCount == 1)
|
||||||
temp = options.Value.Partition;
|
temp = options.Value.Partition;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -103,32 +103,30 @@ public class HyosungPrinter(
|
|||||||
private async Task<string> GetPrint2Content(Tray tray)
|
private async Task<string> GetPrint2Content(Tray tray)
|
||||||
{
|
{
|
||||||
var variety = await varietyService.GetById(tray.VarietyId);
|
var variety = await varietyService.GetById(tray.VarietyId);
|
||||||
|
var labelResult =
|
||||||
var netWeight = tray.NetWeight.ToString("0.0");
|
await hyosungWmsService.GetLabelResult(variety.Code, variety.Lot.ToString(), tray.ControlNo!.Value);
|
||||||
if (netWeight.EndsWith(".0"))
|
|
||||||
netWeight = netWeight.Replace(".0", "");
|
|
||||||
var dic = new Dictionary<string, string>
|
var dic = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{ "$1153", $"\"{variety.Lot}\"" },
|
{ "$1153", $"\"{variety.Lot}\"" },
|
||||||
{ "1670dtex -144F", $"\"{tray.DtexFila}\"" },
|
{ "1670dtex -144F", $"\"{tray.DtexFila}\"" },
|
||||||
{ "1500D - 144F", $"\"{tray.DenFila}\"" },
|
{ "1500D - 144F", $"\"{tray.DenFila}\"" },
|
||||||
{ "$SA", $"\"{tray.Grade}\"" },
|
{ "$SA", $"\"{tray.Grade}\"" },
|
||||||
{ "$900", $"\"{netWeight}\"" },
|
{ "$900", $"\"{labelResult.NET_WEIGHT.ToString("0.0")}\"" },
|
||||||
{ "25-01-01", $"\"{DateTime.Now:yy-MM-dd}\"" },
|
{ "25-01-01", $"\"{DateTime.Now:yy-MM-dd}\"" },
|
||||||
{ "$90", $"\"{variety.TotalCount}\"" },
|
{ "$90", $"\"{variety.TotalCount}\"" },
|
||||||
{ "$965", $"\"{tray.GrossWeight}\"" },
|
{ "$965", $"\"{labelResult.GROSS_WEIGHT}\"" },
|
||||||
{
|
{
|
||||||
"250101J068",
|
"250101J068",
|
||||||
$"\"{DateTime.Now.ToString("yyMMdd" + "J") + tray.ControlNo.ToString()?.PadLeft(3, '0')}\""
|
$"\"{DateTime.Now.ToString("yyMMdd" + "J") + tray.ControlNo.ToString()?.PadLeft(3, '0')}\""
|
||||||
},
|
},
|
||||||
{ "DTYY-JPA11530SFG250101000900115305480", $"{tray.Barcode}" }
|
{ "DTYY-JPA11530SFG250101000900115305480", $"\"{labelResult.BAR_CODE}\"" }
|
||||||
};
|
};
|
||||||
string content = options.Value.DefaultTemp;
|
string content = options.Value.DefaultTemp;
|
||||||
foreach (var (key, value) in dic)
|
foreach (var (key, value) in dic)
|
||||||
{
|
{
|
||||||
content = content.Replace(key, value);
|
content = content.Replace(key, value);
|
||||||
}
|
}
|
||||||
logger.LogInformation($"print content: {content}");
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -11,5 +11,5 @@ public interface IHyosungPrinter
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="trayCode"></param>
|
/// <param name="trayCode"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task PrintAsync(int index,string trayCode);
|
Task PrintAsync(int index,long trayCode);
|
||||||
}
|
}
|
||||||
@ -5,12 +5,10 @@ using Newtonsoft.Json.Linq;
|
|||||||
|
|
||||||
namespace Seyounth.Hyosung.Core.Scanner;
|
namespace Seyounth.Hyosung.Core.Scanner;
|
||||||
|
|
||||||
public class HikScanner(string host, int port,int timeout=1000)
|
public class HikScanner(string host, int port)
|
||||||
{
|
{
|
||||||
public string Host => host;
|
public string Host => host;
|
||||||
public int Port => port;
|
public int Port => port;
|
||||||
|
|
||||||
public int Timeout => timeout;
|
|
||||||
private Socket _socket = new(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
private Socket _socket = new(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||||
|
|
||||||
public async Task ConnectAsync(CancellationToken token)
|
public async Task ConnectAsync(CancellationToken token)
|
||||||
@ -25,71 +23,27 @@ public class HikScanner(string host, int port,int timeout=1000)
|
|||||||
_socket.Dispose();
|
_socket.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Restart()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_socket.Close();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
|
|
||||||
_socket = new(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
|
||||||
await _socket.ConnectAsync(Host, Port);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task Stop()
|
|
||||||
{
|
|
||||||
var cmd = "stop"u8.ToArray();
|
|
||||||
await _socket.SendAsync(cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<string> ScanAsync()
|
public async Task<string> ScanAsync()
|
||||||
{
|
{
|
||||||
var barcode = string.Empty;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!_socket.Connected)
|
byte[] cmd = "start"u8.ToArray();
|
||||||
{
|
await _socket.SendAsync(cmd);
|
||||||
_socket = new(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
byte[] buffer = new byte[1024];
|
||||||
await _socket.ConnectAsync(Host, Port);
|
int len = await _socket.ReceiveAsync(buffer).WaitAsync(TimeSpan.FromMilliseconds(2000));
|
||||||
}
|
cmd = "stop"u8.ToArray();
|
||||||
|
await _socket.SendAsync(cmd);
|
||||||
byte[] _ = new byte[1024];
|
byte[] _ = new byte[1024];
|
||||||
while (_socket.Available > 0)
|
while (_socket.Available > 0)
|
||||||
{
|
{
|
||||||
await _socket.ReceiveAsync(_, SocketFlags.None);
|
await _socket.ReceiveAsync(_, SocketFlags.None);
|
||||||
}
|
}
|
||||||
_socket.ReceiveTimeout = 1000;
|
return Encoding.ASCII.GetString(buffer, 0, len);
|
||||||
byte[] cmd = "start"u8.ToArray();
|
|
||||||
await _socket.SendAsync(cmd);
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
int len = await _socket.ReceiveAsync(buffer).WaitAsync(TimeSpan.FromMilliseconds(Timeout));
|
|
||||||
barcode= Encoding.ASCII.GetString(buffer, 0, len);
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
_socket.Close();
|
return string.Empty;
|
||||||
_socket = new(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
|
||||||
await _socket.ConnectAsync(Host, Port);
|
|
||||||
byte[] _ = new byte[1024];
|
|
||||||
while (_socket.Available > 0)
|
|
||||||
{
|
|
||||||
await _socket.ReceiveAsync(_, SocketFlags.None);
|
|
||||||
}
|
}
|
||||||
_socket.ReceiveTimeout = 1000;
|
|
||||||
byte[] cmd = "start"u8.ToArray();
|
|
||||||
await _socket.SendAsync(cmd);
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
int len = await _socket.ReceiveAsync(buffer).WaitAsync(TimeSpan.FromMilliseconds(1000));
|
|
||||||
barcode= Encoding.ASCII.GetString(buffer, 0, len);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
var cmd = "stop"u8.ToArray();
|
|
||||||
await _socket.SendAsync(cmd);
|
|
||||||
}
|
|
||||||
return barcode;
|
|
||||||
// 清空缓冲区 防止收到之前的数据
|
// 清空缓冲区 防止收到之前的数据
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -12,10 +12,6 @@ public class HyosungScannerService : IHyosungScannerService
|
|||||||
|
|
||||||
private readonly ConcurrentDictionary<int, HikScanner> _fixtureScanners = new();
|
private readonly ConcurrentDictionary<int, HikScanner> _fixtureScanners = new();
|
||||||
|
|
||||||
private readonly List<HikScanner> _carScanners = new();
|
|
||||||
private readonly List<HikScanner> _varietyScanners = new();
|
|
||||||
private List<string> lastCodes = new List<string>();
|
|
||||||
|
|
||||||
|
|
||||||
public HyosungScannerService(ILogger<HyosungScannerService> logger)
|
public HyosungScannerService(ILogger<HyosungScannerService> logger)
|
||||||
{
|
{
|
||||||
@ -28,19 +24,12 @@ public class HyosungScannerService : IHyosungScannerService
|
|||||||
_fixtureScanners.TryAdd(2, new HikScanner("192.168.3.32", 2001));
|
_fixtureScanners.TryAdd(2, new HikScanner("192.168.3.32", 2001));
|
||||||
_fixtureScanners.TryAdd(3, new HikScanner("192.168.3.33", 2001));
|
_fixtureScanners.TryAdd(3, new HikScanner("192.168.3.33", 2001));
|
||||||
_fixtureScanners.TryAdd(4, new HikScanner("192.168.3.30", 2001));
|
_fixtureScanners.TryAdd(4, new HikScanner("192.168.3.30", 2001));
|
||||||
_carScanners.Add(new HikScanner("192.168.30.46", 2001,5000));
|
|
||||||
//_carScanners.Add(new HikScanner("1920.168.3.48", 2001,5000));
|
|
||||||
_varietyScanners.Add(new HikScanner("192.168.30.47", 2001,10000));
|
|
||||||
//_varietyScanners.Add(new HikScanner("192.168.3.49", 2001,10000));
|
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
lastCodes.Add("");
|
|
||||||
lastCodes.Add("");
|
|
||||||
lastCodes.Add("");
|
|
||||||
lastCodes.Add("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task StartAsync(CancellationToken token)
|
public async Task StartAsync(CancellationToken token)
|
||||||
{
|
{
|
||||||
|
|
||||||
// 创建一个超时任务
|
// 创建一个超时任务
|
||||||
var timeoutTask = Task.Delay(2000, token);
|
var timeoutTask = Task.Delay(2000, token);
|
||||||
|
|
||||||
@ -58,23 +47,8 @@ public class HyosungScannerService : IHyosungScannerService
|
|||||||
return Task.WhenAny(connectTask, timeoutTask);
|
return Task.WhenAny(connectTask, timeoutTask);
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
var varietyScannerTasks = _varietyScanners.Select(scanner =>
|
|
||||||
{
|
|
||||||
var connectTask = scanner.ConnectAsync(token);
|
|
||||||
return Task.WhenAny(connectTask, timeoutTask);
|
|
||||||
}).ToList();
|
|
||||||
|
|
||||||
// 为每个车号扫描器创建一个带有超时的连接任务
|
|
||||||
var carScannerTasks = _carScanners.Select(scanner =>
|
|
||||||
{
|
|
||||||
var connectTask = scanner.ConnectAsync(token);
|
|
||||||
return Task.WhenAny(connectTask, timeoutTask);
|
|
||||||
}).ToList();
|
|
||||||
|
|
||||||
// 合并所有任务
|
// 合并所有任务
|
||||||
var allTasks = new List<Task>();
|
var allTasks = new List<Task>();
|
||||||
allTasks.AddRange(carScannerTasks);
|
|
||||||
allTasks.AddRange(varietyScannerTasks);
|
|
||||||
allTasks.AddRange(yarnScannerTasks);
|
allTasks.AddRange(yarnScannerTasks);
|
||||||
allTasks.AddRange(fixtureScannerTasks);
|
allTasks.AddRange(fixtureScannerTasks);
|
||||||
|
|
||||||
@ -101,26 +75,6 @@ public class HyosungScannerService : IHyosungScannerService
|
|||||||
Console.WriteLine($"夹具扫描器连接超时");
|
Console.WriteLine($"夹具扫描器连接超时");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var task in varietyScannerTasks)
|
|
||||||
{
|
|
||||||
var innerTask = task as Task<Task>;
|
|
||||||
if (innerTask.Result == timeoutTask)
|
|
||||||
{
|
|
||||||
// 处理纱线扫描器连接超时的情况
|
|
||||||
Console.WriteLine($"产品扫描器连接超时");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var task in carScannerTasks)
|
|
||||||
{
|
|
||||||
var innerTask = task as Task<Task>;
|
|
||||||
if (innerTask.Result == timeoutTask)
|
|
||||||
{
|
|
||||||
// 处理车号扫描器连接超时的情况
|
|
||||||
Console.WriteLine($"车号扫描器连接超时");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// foreach (var scanner in _yarnScanners)
|
// foreach (var scanner in _yarnScanners)
|
||||||
// {
|
// {
|
||||||
// await scanner.ConnectAsync(token);
|
// await scanner.ConnectAsync(token);
|
||||||
@ -141,63 +95,41 @@ public class HyosungScannerService : IHyosungScannerService
|
|||||||
|
|
||||||
public async Task<Yarn?> ScanYarnAsync(int varietyId)
|
public async Task<Yarn?> ScanYarnAsync(int varietyId)
|
||||||
{
|
{
|
||||||
List<Task<string>> ls = _yarnScanners.Select(scanner => scanner.ScanAsync()).ToList();
|
List<Task<Yarn?>> ls = _yarnScanners.Select(scanner => scanner.ScanAsync()
|
||||||
|
.ContinueWith(task =>
|
||||||
|
{
|
||||||
|
if (task.IsCompletedSuccessfully && !string.IsNullOrEmpty(task.Result))
|
||||||
|
{
|
||||||
|
_logger.LogInformation($"scanner[{scanner.Host}:{scanner.Port}] scan yarn {task.Result}");
|
||||||
|
return Yarn.Create(task.Result, varietyId);
|
||||||
|
}
|
||||||
|
|
||||||
//停止所有的扫码枪
|
return null;
|
||||||
|
}))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
while (ls.Count > 0)
|
while (ls.Count > 0)
|
||||||
{
|
{
|
||||||
// 使用 Task.WhenAny 方法等待任意一个任务完成
|
// 使用 Task.WhenAny 方法等待任意一个任务完成
|
||||||
Task<string> completedTask = await Task.WhenAny(ls);
|
Task<Yarn?> completedTask = await Task.WhenAny(ls);
|
||||||
// 移除已经完成的任务
|
// 移除已经完成的任务
|
||||||
ls.Remove(completedTask);
|
ls.Remove(completedTask);
|
||||||
// 获取完成任务的结果
|
// 获取完成任务的结果
|
||||||
string result = await completedTask;
|
Yarn? result = await completedTask;
|
||||||
// 如果结果不为空,立即返回结果
|
// 如果结果不为空,立即返回结果
|
||||||
if (!string.IsNullOrEmpty(result))
|
if (result != null)
|
||||||
{
|
{
|
||||||
_yarnScanners.Select(async scanner => await scanner.Stop());
|
return result;
|
||||||
return Yarn.Create(result, varietyId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//_yarnScanners.Select( scanner => scanner.Stop());
|
|
||||||
_logger.LogWarning($"all scanner no scan yarn");
|
_logger.LogWarning($"all scanner no scan yarn");
|
||||||
_yarnScanners.Select(async scanner => await scanner.Restart());
|
|
||||||
// 如果所有任务都完成且没有找到非空结果,返回 null
|
// 如果所有任务都完成且没有找到非空结果,返回 null
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string> ScanFixtureAsync(int fixtureId)
|
public async Task<string> ScanFixtureAsync(int fixtureId)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
return await _fixtureScanners[fixtureId].ScanAsync();
|
return await _fixtureScanners[fixtureId].ScanAsync();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
_logger.LogError(e, $"Fixture{fixtureId} Scan Error");
|
|
||||||
await _fixtureScanners[fixtureId].Restart();
|
|
||||||
return await _fixtureScanners[fixtureId].ScanAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
//string code = "";
|
|
||||||
//do
|
|
||||||
//{
|
|
||||||
// code= await _fixtureScanners[fixtureId].ScanAsync();
|
|
||||||
// await Task.Delay(100);
|
|
||||||
//} while (code != lastCodes[fixtureId - 1]);
|
|
||||||
//lastCodes[fixtureId - 1] = code;
|
|
||||||
//return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<string> ScanYarnCarAsync(int entryId)
|
|
||||||
{
|
|
||||||
return await _carScanners[entryId - 1].ScanAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<string> ScanVarietyAsync(int entryId)
|
|
||||||
{
|
|
||||||
return await _varietyScanners[entryId - 1].ScanAsync();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -21,8 +21,4 @@ public interface IHyosungScannerService
|
|||||||
/// <param name="fixtureId"></param>
|
/// <param name="fixtureId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<string> ScanFixtureAsync(int fixtureId);
|
Task<string> ScanFixtureAsync(int fixtureId);
|
||||||
|
|
||||||
Task<string> ScanYarnCarAsync(int entryId);
|
|
||||||
|
|
||||||
Task<string> ScanVarietyAsync(int entryId);
|
|
||||||
}
|
}
|
||||||
@ -31,9 +31,4 @@ public class AgvBinEntity
|
|||||||
|
|
||||||
[SugarColumn(ColumnDescription = "排序")]
|
[SugarColumn(ColumnDescription = "排序")]
|
||||||
public int Sort { get; set; }
|
public int Sort { get; set; }
|
||||||
|
|
||||||
[SugarColumn(IsNullable =true)]
|
|
||||||
public string HeightCode { get; set; }
|
|
||||||
|
|
||||||
public bool IsDeleted { get; set; }
|
|
||||||
}
|
}
|
||||||
@ -12,7 +12,7 @@ public class ScannedYarnEntity
|
|||||||
public string QrCode { get; set; }
|
public string QrCode { get; set; }
|
||||||
|
|
||||||
[SugarColumn(ColumnDescription = "纱线代码", Length = 20)]
|
[SugarColumn(ColumnDescription = "纱线代码", Length = 20)]
|
||||||
public string ScanCode { get; set; }
|
public long ScanCode { get; set; }
|
||||||
|
|
||||||
[SugarColumn(ColumnDescription = "Lot")]
|
[SugarColumn(ColumnDescription = "Lot")]
|
||||||
public int Lot { get; set; }
|
public int Lot { get; set; }
|
||||||
|
|||||||
@ -9,7 +9,7 @@ public class TrayEntity
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[SugarColumn(ColumnDescription = "托盘唯一号")]
|
[SugarColumn(ColumnDescription = "托盘唯一号")]
|
||||||
public string TrayCode { get; set; }
|
public long TrayCode { get; set; }
|
||||||
|
|
||||||
[SugarColumn(ColumnDescription = "所属的品类信息")]
|
[SugarColumn(ColumnDescription = "所属的品类信息")]
|
||||||
public int VarietyId { get; set; }
|
public int VarietyId { get; set; }
|
||||||
@ -40,10 +40,4 @@ public class TrayEntity
|
|||||||
[SugarColumn(IsNullable = true)] public double GrossWeight { get; set; }
|
[SugarColumn(IsNullable = true)] public double GrossWeight { get; set; }
|
||||||
|
|
||||||
[SugarColumn(IsNullable = true)] public int? AgvBinId { get; set; }
|
[SugarColumn(IsNullable = true)] public int? AgvBinId { get; set; }
|
||||||
|
|
||||||
[SugarColumn(IsNullable = true)] public string? Barcode { get; set; }
|
|
||||||
|
|
||||||
[SugarColumn(IsNullable = true)] public bool? IsPacking { get; set; } = false;
|
|
||||||
|
|
||||||
[SugarColumn(IsNullable = true)] public bool? Exported { get; set; }
|
|
||||||
}
|
}
|
||||||
@ -84,13 +84,4 @@ public class VarietyEntity
|
|||||||
[SugarColumn(ColumnDescription = "副标签数量")]
|
[SugarColumn(ColumnDescription = "副标签数量")]
|
||||||
public int SubLabelCount { get; set; }
|
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; }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -16,5 +16,5 @@ public partial class PackLineOption : ObservableObject
|
|||||||
|
|
||||||
[ObservableProperty] private bool isLam;
|
[ObservableProperty] private bool isLam;
|
||||||
|
|
||||||
[ObservableProperty] private string trayCode;
|
[ObservableProperty] private long trayCode;
|
||||||
}
|
}
|
||||||
@ -5,6 +5,6 @@ namespace Seyounth.Hyosung.Data.Models.Plc;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class PlcStackInfo
|
public class PlcStackInfo
|
||||||
{
|
{
|
||||||
public string TrayCode { get; set; }
|
public long TrayCode { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2,9 +2,9 @@ namespace Seyounth.Hyosung.Data.Models.Plc;
|
|||||||
|
|
||||||
public class PlcStackingInfo
|
public class PlcStackingInfo
|
||||||
{
|
{
|
||||||
public string TrayCode { get; set; }
|
public long TrayCode { get; set; }
|
||||||
|
|
||||||
public List<string> YarnCode { get; set; } = new List<string>();
|
public List<long> YarnCode { get; set; } = new ();
|
||||||
|
|
||||||
public int YarnCount { get; set; }
|
public int YarnCount { get; set; }
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ public class Tray
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public string TrayCode { get; set; }
|
public long TrayCode { get; set; }
|
||||||
|
|
||||||
public int VarietyId { get; set; }
|
public int VarietyId { get; set; }
|
||||||
|
|
||||||
@ -36,12 +36,6 @@ public class Tray
|
|||||||
|
|
||||||
public int? AgvBinId { get; set; }
|
public int? AgvBinId { get; set; }
|
||||||
|
|
||||||
public string? Barcode { get; set; }
|
|
||||||
|
|
||||||
public bool? IsPacking { get; set; }
|
|
||||||
|
|
||||||
public bool? Exported { get; set; }
|
|
||||||
|
|
||||||
public TrayEntity ToEntity()
|
public TrayEntity ToEntity()
|
||||||
{
|
{
|
||||||
return new TrayEntity()
|
return new TrayEntity()
|
||||||
@ -61,10 +55,7 @@ public class Tray
|
|||||||
Grade = Grade,
|
Grade = Grade,
|
||||||
Type = Type,
|
Type = Type,
|
||||||
Unit = Unit,
|
Unit = Unit,
|
||||||
AgvBinId = AgvBinId,
|
AgvBinId = AgvBinId
|
||||||
Barcode = Barcode,
|
|
||||||
IsPacking = IsPacking,
|
|
||||||
Exported = Exported
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,10 +78,7 @@ public class Tray
|
|||||||
Grade = entity.Grade,
|
Grade = entity.Grade,
|
||||||
Type = entity.Type,
|
Type = entity.Type,
|
||||||
Unit = entity.Unit,
|
Unit = entity.Unit,
|
||||||
AgvBinId = entity.AgvBinId,
|
AgvBinId = entity.AgvBinId
|
||||||
Barcode = entity.Barcode,
|
|
||||||
IsPacking = entity.IsPacking,
|
|
||||||
Exported = entity.Exported
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,12 +64,6 @@ public class Variety
|
|||||||
|
|
||||||
public bool IsTurn { get; set; }
|
public bool IsTurn { get; set; }
|
||||||
|
|
||||||
public int? LastNo { get; set; }
|
|
||||||
|
|
||||||
public double? NetWeight { get; set; }
|
|
||||||
|
|
||||||
public double? GrossWeight { get; set; }
|
|
||||||
|
|
||||||
public static Variety Create(VarietyEntity entity, List<PalletEntity> pallets)
|
public static Variety Create(VarietyEntity entity, List<PalletEntity> pallets)
|
||||||
{
|
{
|
||||||
var variety = new Variety()
|
var variety = new Variety()
|
||||||
@ -98,10 +92,7 @@ public class Variety
|
|||||||
MiddlePallet = Pallet.FromEntity(pallets.First(x => x.Id == entity.MiddlePalletId)),
|
MiddlePallet = Pallet.FromEntity(pallets.First(x => x.Id == entity.MiddlePalletId)),
|
||||||
TopAndBottomPallet = Pallet.FromEntity(pallets.First(x => x.Id == entity.TopAndBottomPalletId)),
|
TopAndBottomPallet = Pallet.FromEntity(pallets.First(x => x.Id == entity.TopAndBottomPalletId)),
|
||||||
Tray = Pallet.FromEntity(pallets.First(x => x.Id == entity.TrayId)),
|
Tray = Pallet.FromEntity(pallets.First(x => x.Id == entity.TrayId)),
|
||||||
HasBox = entity.HasBox,
|
HasBox = entity.HasBox
|
||||||
LastNo = entity.LastNo,
|
|
||||||
NetWeight = entity.NetWeight,
|
|
||||||
GrossWeight = entity.GrossWeight
|
|
||||||
};
|
};
|
||||||
if (entity.PaperTrayId != null && entity.PaperTrayId != 0)
|
if (entity.PaperTrayId != null && entity.PaperTrayId != 0)
|
||||||
variety.PaperTray = Pallet.FromEntity(pallets.First(x => x.Id == entity.PaperTrayId));
|
variety.PaperTray = Pallet.FromEntity(pallets.First(x => x.Id == entity.PaperTrayId));
|
||||||
@ -139,9 +130,6 @@ public class Variety
|
|||||||
TopAndBottomPalletId = TopAndBottomPallet.Id,
|
TopAndBottomPalletId = TopAndBottomPallet.Id,
|
||||||
TrayId = Tray.Id,
|
TrayId = Tray.Id,
|
||||||
HasBox = HasBox,
|
HasBox = HasBox,
|
||||||
LastNo = LastNo,
|
|
||||||
NetWeight = NetWeight,
|
|
||||||
GrossWeight = GrossWeight
|
|
||||||
};
|
};
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,7 @@ public class Yarn
|
|||||||
|
|
||||||
public string QrCode { get; set; }
|
public string QrCode { get; set; }
|
||||||
|
|
||||||
public string ScanCode { get; set; }
|
public long ScanCode { get; set; }
|
||||||
|
|
||||||
public int Lot { get; set; }
|
public int Lot { get; set; }
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ public class Yarn
|
|||||||
ProduceTime = parts[3],
|
ProduceTime = parts[3],
|
||||||
ScanTime = DateTime.Now,
|
ScanTime = DateTime.Now,
|
||||||
VarietyId = varietyId,
|
VarietyId = varietyId,
|
||||||
ScanCode = DateTime.Now.ToTimestamp().ToString(),
|
ScanCode = DateTime.Now.ToTimestamp(),
|
||||||
TrayId = null
|
TrayId = null
|
||||||
};
|
};
|
||||||
yarn.WorkShift = parts[1] switch
|
yarn.WorkShift = parts[1] switch
|
||||||
@ -79,7 +79,7 @@ public class Yarn
|
|||||||
ScanTime = DateTime.Now,
|
ScanTime = DateTime.Now,
|
||||||
VarietyId = varietyId,
|
VarietyId = varietyId,
|
||||||
TrayId = null,
|
TrayId = null,
|
||||||
ScanCode = DateTime.Now.ToTimestamp().ToString().PadLeft(10, '0'),
|
ScanCode = DateTime.Now.ToTimestamp(),
|
||||||
};
|
};
|
||||||
yarn.WorkShift = parts[5] switch
|
yarn.WorkShift = parts[5] switch
|
||||||
{
|
{
|
||||||
|
|||||||
@ -36,7 +36,7 @@ public static class ServiceExtensions
|
|||||||
//#endif
|
//#endif
|
||||||
return sqlSugar;
|
return sqlSugar;
|
||||||
});
|
});
|
||||||
services.AddSingleton(typeof(IRepository<>), typeof(Repository<>));
|
services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
|
||||||
services.AddSingleton<IVarietyService, VarietyService>();
|
services.AddSingleton<IVarietyService, VarietyService>();
|
||||||
services.AddSingleton<IYarnService, YarnService>();
|
services.AddSingleton<IYarnService, YarnService>();
|
||||||
services.AddSingleton<ITrayService, TrayService>();
|
services.AddSingleton<ITrayService, TrayService>();
|
||||||
@ -44,7 +44,6 @@ public static class ServiceExtensions
|
|||||||
services.AddSingleton<IDictService, DictService>();
|
services.AddSingleton<IDictService, DictService>();
|
||||||
services.AddSingleton<IHyosungWmsService, HyosungWmsService>();
|
services.AddSingleton<IHyosungWmsService, HyosungWmsService>();
|
||||||
services.AddSingleton<IPalletService, PalletService>();
|
services.AddSingleton<IPalletService, PalletService>();
|
||||||
services.AddSingleton<IReportExportService, ReportExportService>();
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,36 +13,33 @@ public class AgvBinService : IAgvBinService
|
|||||||
public AgvBinService(IServiceProvider provider)
|
public AgvBinService(IServiceProvider provider)
|
||||||
{
|
{
|
||||||
_repository = provider.CreateScope().ServiceProvider.GetRequiredService<IRepository<AgvBinEntity>>();
|
_repository = provider.CreateScope().ServiceProvider.GetRequiredService<IRepository<AgvBinEntity>>();
|
||||||
//_repository = provider.GetService<IRepository<AgvBinEntity>>();
|
|
||||||
_cache = _repository.GetList();
|
_cache = _repository.GetList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<AgvBinEntity> GetAvailableBin(int height)
|
public async Task<AgvBinEntity> GetAvailableBin(int height)
|
||||||
{
|
{
|
||||||
var bin = await _repository.CopyNew().AsQueryable()
|
if (height < 180)
|
||||||
.Where(x => x.IsFree && !x.IsDeleted).OrderBy(x => x.Sort).FirstAsync();
|
|
||||||
if (bin.BinCode == "B10")
|
|
||||||
{
|
{
|
||||||
await _repository.CopyNew().AsUpdateable()
|
return _cache
|
||||||
.Where(x => x.RackType == 2 && !x.IsDeleted)
|
.Where(x =>
|
||||||
.SetColumns(x => x.IsFree, true)
|
x is { CtnrType: 1, IsFree: true } ||
|
||||||
.ExecuteCommandAsync();
|
x is { CtnrType: 2, IsFree: true } &&
|
||||||
}
|
_cache.Any(y =>
|
||||||
else if (bin.BinCode == "B33")
|
y is { CtnrType: 1, IsFree: false } && y.BinCode == x.BinCode &&
|
||||||
{
|
y is { Height: < 180 })
|
||||||
await _repository.CopyNew().AsUpdateable()
|
)
|
||||||
.Where(x => x.RackType == 1 && !x.IsDeleted)
|
.OrderByDescending(x => x.CtnrType)
|
||||||
.SetColumns(x => x.IsFree, true)
|
.ThenBy(x => x.Sort)
|
||||||
.ExecuteCommandAsync();
|
.First();
|
||||||
}
|
}
|
||||||
|
|
||||||
return bin;
|
return _cache.Where(a => a is { IsFree: true }).OrderBy(a => a.CtnrType).First();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task BindAsync(AgvBinEntity entity)
|
public Task BindAsync(AgvBinEntity entity)
|
||||||
{
|
{
|
||||||
entity.IsFree = false;
|
entity.IsFree = false;
|
||||||
_cache.First(e => e.Id == entity.Id).IsFree = false;
|
_cache.First(e => e.Id == entity.Id).IsFree = false;
|
||||||
return _repository.CopyNew().UpdateAsync(entity);
|
return _repository.UpdateAsync(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -15,30 +15,17 @@ public class DictService : IDictService
|
|||||||
{
|
{
|
||||||
_repository = provider.CreateScope()
|
_repository = provider.CreateScope()
|
||||||
.ServiceProvider.GetRequiredService<IRepository<DictEntity>>();
|
.ServiceProvider.GetRequiredService<IRepository<DictEntity>>();
|
||||||
//_repository = provider.GetService<IRepository<DictEntity>>();
|
|
||||||
_cache = _repository.GetList();
|
_cache = _repository.GetList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<string> GetKeyAsync(string type, string name)
|
public async Task<string> GetKeyAsync(string type, string name)
|
||||||
{
|
{
|
||||||
return _cache.FirstOrDefault(d => d.Type == type && d.Value == name)?.Key ?? "";
|
return _cache.FirstOrDefault(d => d.Type == type && d.Value == name)?.Value ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<DictEntity>> GetDictsByTypeAsync(string type)
|
public async Task<List<DictEntity>> GetDictsByTypeAsync(string type)
|
||||||
{
|
{
|
||||||
return _cache.Where(d => d.Type == type).ToList();
|
return _cache.Where(d => d.Type == type).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SetValue(string type, string key, string value)
|
|
||||||
{
|
|
||||||
await _repository.CopyNew().AsUpdateable()
|
|
||||||
.Where(x => x.Type == type && x.Key == key).SetColumns(x => x.Value, value).ExecuteCommandAsync(); ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<string> GetValue(string type, string key)
|
|
||||||
{
|
|
||||||
var dict = await _repository.CopyNew().GetFirstAsync(x => x.Type == type && x.Key == key);
|
|
||||||
return dict.Value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,4 +1,3 @@
|
|||||||
using Seyounth.Hyosung.Data.Models;
|
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
|
||||||
namespace Seyounth.Hyosung.Data.Services.Hyosung.Entities;
|
namespace Seyounth.Hyosung.Data.Services.Hyosung.Entities;
|
||||||
@ -6,71 +5,34 @@ namespace Seyounth.Hyosung.Data.Services.Hyosung.Entities;
|
|||||||
[SugarTable("LABEL_RESULT")]
|
[SugarTable("LABEL_RESULT")]
|
||||||
public class LabelResult
|
public class LabelResult
|
||||||
{
|
{
|
||||||
public string BE_ID { get; set; } = "2240";
|
public string BE_ID { get; set; }
|
||||||
public string BAR_CODE { get; set; } = "";
|
public string BAR_CODE { get; set; }
|
||||||
public string ITEM_CODE { get; set; } = "";
|
public string ITEM_CODE { get; set; }
|
||||||
public string LABEL_ID { get; set; } = "TY_CN_PRODUCT";
|
public string LABEL_ID { get; set; }
|
||||||
public string WMS_UOM { get; set; } = "";
|
public string WMS_UOM { get; set; }
|
||||||
public string ERP_UOM { get; set; } = "";
|
public string ERP_UOM { get; set; }
|
||||||
public string MFG_DATE { get; set; } = "";
|
public string MFG_DATE { get; set; }
|
||||||
public decimal NET_WEIGHT { get; set; } = 0;
|
public decimal NET_WEIGHT { get; set; }
|
||||||
public decimal GROSS_WEIGHT { get; set; } = 0;
|
public double GROSS_WEIGHT { get; set; }
|
||||||
public string MFG_LINE { get; set; } = "TYJP11";
|
public string MFG_LINE { get; set; }
|
||||||
public string GRADE { get; set; } = "";
|
public string GRADE { get; set; }
|
||||||
public string LOT { get; set; } = "";
|
public string LOT { get; set; }
|
||||||
|
public string BOX_NO { get; set; }
|
||||||
public string BOX_NO { get; set; } = "";
|
public string DENIER { get; set; }
|
||||||
|
public string FILA { get; set; }
|
||||||
// public string DENIER { get; set; } = "";
|
public string CUSTOMER_NAME { get; set; }
|
||||||
// public string FILA { get; set; } = "";
|
public string REMARKS { get; set; }
|
||||||
public string CUSTOMER_NAME { get; set; } = "";
|
public string TRI_INTERFACE_YN { get; set; }
|
||||||
|
public string TRI_TYPE { get; set; }
|
||||||
// public string REMARKS { get; set; } = "";
|
public string COMMON_S1 { get; set; }
|
||||||
// public string TRI_INTERFACE_YN { get; set; } = "";
|
public string COMMON_S2 { get; set; }
|
||||||
public string TRI_TYPE { get; set; } = "ZP10";
|
public string COMMON_S3 { get; set; }
|
||||||
public string COMMON_S1 { get; set; } = "";
|
public string COMMON_S4 { get; set; }
|
||||||
public string COMMON_S2 { get; set; } = "";
|
public string COMMON_S5 { get; set; }
|
||||||
|
public string COMMON_N1 { get; set; }
|
||||||
public string COMMON_S3 { get; set; } = "";
|
public string TRI_YN { get; set; }
|
||||||
public string COMMON_S4 { get; set; } = "";
|
public string CREATED_BY { get; set; }
|
||||||
public string COMMON_S5 { get; set; } = "";
|
public string CREATED_ON { get; set; }
|
||||||
|
public string MODIFIED_BY { get; set; }
|
||||||
//public string COMMON_S4 { get; set; } = "";
|
public string MODIFIED_ON { get; set; }
|
||||||
//public string COMMON_S5 { get; set; } = "";
|
|
||||||
//public string COMMON_N1 { get; set; } = "";
|
|
||||||
//public string TRI_YN { get; set; } = "";
|
|
||||||
public string CREATED_BY { get; set; } = "seyounth";
|
|
||||||
public string CREATED_ON { get; set; } = DateTime.Now.ToString("yyyy-MM-dd");
|
|
||||||
public string MODIFIED_BY { get; set; } = "seyounth";
|
|
||||||
public string MODIFIED_ON { get; set; } = DateTime.Now.ToString("yyyy-MM-dd");
|
|
||||||
|
|
||||||
public double COMMON_N1 { get; set; } = 0;
|
|
||||||
|
|
||||||
public LabelResult(Tray tray, Variety variety)
|
|
||||||
{
|
|
||||||
LABEL_ID = tray.TrayCode;
|
|
||||||
BE_ID = "2240";
|
|
||||||
BAR_CODE = tray.Barcode ?? "";
|
|
||||||
ITEM_CODE = variety.Code;
|
|
||||||
MFG_DATE = DateTime.Now.ToString("yyyyMMdd");
|
|
||||||
NET_WEIGHT = (decimal)tray.NetWeight;
|
|
||||||
GROSS_WEIGHT = (decimal)tray.GrossWeight;
|
|
||||||
GRADE = tray.Grade ?? "";
|
|
||||||
LOT = variety.Lot.ToString();
|
|
||||||
BOX_NO = $"{DateTime.Now.ToString("yyMMdd" + "J") + tray.ControlNo.ToString()?.PadLeft(3, '0')}";
|
|
||||||
CREATED_BY = "seyounth";
|
|
||||||
CREATED_ON = DateTime.Now.ToString("yyyy-MM-dd");
|
|
||||||
COMMON_S1 = tray.Type?? "";
|
|
||||||
COMMON_S2 = variety.TotalCount.ToString();
|
|
||||||
COMMON_S3=tray.DenFila?? "";
|
|
||||||
COMMON_S4 = tray.DtexFila?? "";
|
|
||||||
COMMON_S5 = "0";
|
|
||||||
COMMON_N1 = (double)tray.ControlNo;
|
|
||||||
MODIFIED_BY = "seyounth";
|
|
||||||
MODIFIED_ON = DateTime.Now.ToString("yyyy-MM-dd");
|
|
||||||
}
|
|
||||||
|
|
||||||
public LabelResult()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,26 +0,0 @@
|
|||||||
namespace Seyounth.Hyosung.Data.Services.Hyosung.Entities;
|
|
||||||
|
|
||||||
public class MST_ITEM
|
|
||||||
{
|
|
||||||
public string BE_ID { get; set; } = "2240";
|
|
||||||
|
|
||||||
public string ITEM_CODE { get; set; }
|
|
||||||
|
|
||||||
public string ITEM_CODE_TYPE { get; set; } = "FERT";
|
|
||||||
|
|
||||||
public string COMMON_S1 { get; set; }
|
|
||||||
|
|
||||||
public string COMMON_S2 { get; set; }
|
|
||||||
|
|
||||||
public string COMMON_S3 { get; set; }
|
|
||||||
|
|
||||||
public string COMMON_S4 { get; set; }
|
|
||||||
|
|
||||||
public string COMMON_S5 { get; set; }
|
|
||||||
|
|
||||||
public string ERP_UOM_ID { get; set; }
|
|
||||||
|
|
||||||
public string WMS_UOM_ID { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
namespace Seyounth.Hyosung.Data.Services.Hyosung.Entities;
|
|
||||||
|
|
||||||
public class MST_ITEM_VERSION
|
|
||||||
{
|
|
||||||
public string ITEM_CODE { get; set; }
|
|
||||||
|
|
||||||
public string WORK_CENTER { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -80,32 +80,10 @@ public class HyosungWmsService : IHyosungWmsService
|
|||||||
x.BE_ID == "2240"
|
x.BE_ID == "2240"
|
||||||
)
|
)
|
||||||
.FirstAsync();
|
.FirstAsync();
|
||||||
}
|
} catch (Exception e)
|
||||||
catch (Exception e)
|
|
||||||
{
|
{
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task AddLabelResult(LabelResult result)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var mst_item = await _db.Queryable<MST_ITEM>()
|
|
||||||
.FirstAsync(t => t.BE_ID == "2240"
|
|
||||||
&& t.ITEM_CODE == result.ITEM_CODE
|
|
||||||
&& t.ITEM_CODE_TYPE == "FERT");
|
|
||||||
result.WMS_UOM = mst_item.WMS_UOM_ID;
|
|
||||||
result.ERP_UOM = mst_item.ERP_UOM_ID;
|
|
||||||
|
|
||||||
var workCenter = await _db.Queryable<MST_ITEM_VERSION>()
|
|
||||||
.FirstAsync(v => v.ITEM_CODE == result.ITEM_CODE);
|
|
||||||
result.MFG_LINE=(workCenter?.WORK_CENTER)??"TYJP11";
|
|
||||||
await _db.Insertable(result).ExecuteCommandAsync();
|
|
||||||
}catch(Exception e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -12,6 +12,4 @@ public interface IHyosungWmsService
|
|||||||
Task UpdateControlNo(Variety variety, int controlNo);
|
Task UpdateControlNo(Variety variety, int controlNo);
|
||||||
|
|
||||||
Task<LabelResult> GetLabelResult(string itemCode,string lot,int controlNo);
|
Task<LabelResult> GetLabelResult(string itemCode,string lot,int controlNo);
|
||||||
|
|
||||||
Task AddLabelResult(LabelResult result);
|
|
||||||
}
|
}
|
||||||
@ -7,8 +7,4 @@ public interface IDictService
|
|||||||
Task<string> GetKeyAsync(string type, string value);
|
Task<string> GetKeyAsync(string type, string value);
|
||||||
|
|
||||||
Task<List<DictEntity>> GetDictsByTypeAsync(string type);
|
Task<List<DictEntity>> GetDictsByTypeAsync(string type);
|
||||||
|
|
||||||
Task SetValue(string type, string key,string value);
|
|
||||||
|
|
||||||
Task<string> GetValue(string type, string key);
|
|
||||||
}
|
}
|
||||||
@ -1,13 +0,0 @@
|
|||||||
namespace Seyounth.Hyosung.Data.Services;
|
|
||||||
|
|
||||||
public interface IReportExportService
|
|
||||||
{
|
|
||||||
Task ExportAsync(string trayCode);
|
|
||||||
|
|
||||||
Task ExportSampleAsync(string trayCode);
|
|
||||||
|
|
||||||
|
|
||||||
Task ExportNoExportAsync();
|
|
||||||
|
|
||||||
Task ExportTodayTotalReportAsync();
|
|
||||||
}
|
|
||||||
@ -1,4 +1,3 @@
|
|||||||
using System.Globalization;
|
|
||||||
using Seyounth.Hyosung.Data.Models;
|
using Seyounth.Hyosung.Data.Models;
|
||||||
using Seyounth.Hyosung.Data.Services.Hyosung.Entities;
|
using Seyounth.Hyosung.Data.Services.Hyosung.Entities;
|
||||||
|
|
||||||
@ -18,23 +17,21 @@ public interface ITrayService
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="code"></param>
|
/// <param name="code"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> GetIdByCode(string code);
|
Task<int> GetIdByCode(long code);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="code"></param>
|
/// <param name="code"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<Tray> GetByCode(string code);
|
Task<Tray> GetByCode(long code);
|
||||||
|
|
||||||
Task<Tray> GetIsPacking();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生成控制号
|
/// 生成控制号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="trayCode"></param>
|
/// <param name="trayCode"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task StorageAsync(string trayCode);
|
Task StorageAsync(long trayCode);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 打印托盘
|
/// 打印托盘
|
||||||
@ -44,16 +41,5 @@ public interface ITrayService
|
|||||||
/// <param name="controlNo"></param>
|
/// <param name="controlNo"></param>
|
||||||
/// <param name="itemInfo"></param>
|
/// <param name="itemInfo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<Tray> PrintTrayAsync(string trayCode, MST_ITEM_2240_V itemInfo,Variety variety);
|
Task PrintTrayAsync(long trayCode, int stackHeight, int controlNo, MST_ITEM_2240_V itemInfo);
|
||||||
|
|
||||||
Task UpdateHeightAsync(string trayCode, int height);
|
|
||||||
|
|
||||||
|
|
||||||
Task ExportedAsync(string trayCode);
|
|
||||||
|
|
||||||
Task<List<string>> GetNoExportCodesAsync();
|
|
||||||
|
|
||||||
Task SetControlNoAsync(string trayCode, int controlNo);
|
|
||||||
|
|
||||||
Task<List<Tray>> GetTodayTrayAsync();
|
|
||||||
}
|
}
|
||||||
@ -39,9 +39,4 @@ public interface IVarietyService
|
|||||||
/// <param name="pallet"></param>
|
/// <param name="pallet"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task AddPalletAsync(Pallet pallet);
|
Task AddPalletAsync(Pallet pallet);
|
||||||
|
|
||||||
|
|
||||||
Task SetLastNo(int varietyId, int lastNo);
|
|
||||||
|
|
||||||
Task<int?> GetLastNo(int varietyId);
|
|
||||||
}
|
}
|
||||||
@ -5,21 +5,21 @@ namespace Seyounth.Hyosung.Data.Services;
|
|||||||
|
|
||||||
public interface IYarnService
|
public interface IYarnService
|
||||||
{
|
{
|
||||||
ConcurrentDictionary<string, Yarn> NoFinished { get; }
|
ConcurrentDictionary<long, Yarn> NoFinished { get; }
|
||||||
|
|
||||||
Task<Yarn?> AddYarnAsync(Yarn yarn);
|
Task<Yarn?> AddYarnAsync(Yarn yarn);
|
||||||
|
|
||||||
|
|
||||||
Task<List<Yarn>> GetYarnsByTrayIdAsync(int trayId);
|
Task<List<Yarn>> GetYarnsByTrayIdAsync(int trayId);
|
||||||
|
|
||||||
Task<Yarn> GetYarnByCodeAsync(string code);
|
Task<Yarn> GetYarnByCodeAsync(long code);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 完成指定纱
|
/// 完成指定纱
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="yarnCode"></param>
|
/// <param name="yarnCode"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task FinishYarnAsync(string yarnCode);
|
Task FinishYarnAsync(long yarnCode);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 绑定托盘号
|
/// 绑定托盘号
|
||||||
@ -27,5 +27,5 @@ public interface IYarnService
|
|||||||
/// <param name="yarnCode"></param>
|
/// <param name="yarnCode"></param>
|
||||||
/// <param name="trayId"></param>
|
/// <param name="trayId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task BindTrayAsync(string yarnCode, int trayId);
|
Task BindTrayAsync(long yarnCode, int trayId);
|
||||||
}
|
}
|
||||||
@ -14,7 +14,6 @@ public class PalletService : IPalletService
|
|||||||
{
|
{
|
||||||
_palletRepository = serviceProvider.CreateScope().ServiceProvider
|
_palletRepository = serviceProvider.CreateScope().ServiceProvider
|
||||||
.GetRequiredService<IRepository<PalletEntity>>();
|
.GetRequiredService<IRepository<PalletEntity>>();
|
||||||
// _palletRepository = serviceProvider.GetService<IRepository<PalletEntity>>();
|
|
||||||
_pallets = _palletRepository.GetList().Select(Pallet.FromEntity).ToList();
|
_pallets = _palletRepository.GetList().Select(Pallet.FromEntity).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,251 +0,0 @@
|
|||||||
using System.Data;
|
|
||||||
using System.Globalization;
|
|
||||||
using ClosedXML.Excel;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Seyounth.Hyosung.Data.Models;
|
|
||||||
|
|
||||||
namespace Seyounth.Hyosung.Data.Services;
|
|
||||||
|
|
||||||
public class ReportExportService(
|
|
||||||
IYarnService yarnService,
|
|
||||||
IVarietyService varietyService,
|
|
||||||
ITrayService trayService,
|
|
||||||
ILogger<ReportExportService> logger)
|
|
||||||
: IReportExportService
|
|
||||||
{
|
|
||||||
const string TempPath = "./exportTemp.xlsx";
|
|
||||||
|
|
||||||
public async Task ExportAsync(string trayCode)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var tray = await trayService.GetByCode(trayCode);
|
|
||||||
var variety = await varietyService.GetById(tray.VarietyId);
|
|
||||||
var yarns = await yarnService.GetYarnsByTrayIdAsync(tray.Id);
|
|
||||||
await Create(tray, variety, yarns);
|
|
||||||
await trayService.ExportedAsync(tray.TrayCode);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
logger.LogError(e, $"export report [{trayCode}] error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task ExportSampleAsync(string trayCode)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var tray = await trayService.GetByCode(trayCode);
|
|
||||||
var variety = await varietyService.GetById(tray.VarietyId);
|
|
||||||
var yarns = await yarnService.GetYarnsByTrayIdAsync(tray.Id);
|
|
||||||
await CreateSample(tray, variety, yarns);
|
|
||||||
await trayService.ExportedAsync(tray.TrayCode);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
logger.LogError(e, $"export report [{trayCode}] error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task CreateSample(Tray tray, Variety variety, List<Yarn> yarns)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DataTable dt = new DataTable();
|
|
||||||
dt.Columns.Add("LOT");
|
|
||||||
dt.Columns.Add("DEN");
|
|
||||||
dt.Columns.Add("总个数/垛");
|
|
||||||
dt.Columns.Add("生产时间");
|
|
||||||
dt.Columns.Add("机台");
|
|
||||||
dt.Columns.Add("班次");
|
|
||||||
dt.Columns.Add("码垛时间");
|
|
||||||
for (int i = 1; i <= yarns.Count; i++)
|
|
||||||
{
|
|
||||||
if (i == 1)
|
|
||||||
{
|
|
||||||
dt.Rows.Add(yarns[i - 1].Lot, tray.DenFila, yarns.Count, yarns[i - 1].ProduceTime,
|
|
||||||
yarns[i - 1].Machine, yarns[i - 1].WorkShift, yarns[i - 1].StackTime);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dt.Rows.Add(yarns[i - 1].Lot, tray.DenFila, " ", yarns[i - 1].ProduceTime,
|
|
||||||
yarns[i - 1].Machine, yarns[i - 1].WorkShift,yarns[i - 1].StackTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var path = await GetDirectoryAsync();
|
|
||||||
var fileName = $"{variety.Lot}_{tray.Barcode.Split(" ")[1]}_{DateTime.Now:yyyyMMdd}.xlsx";
|
|
||||||
var filePath = Path.Combine(path, fileName);
|
|
||||||
using var workbook = new XLWorkbook();
|
|
||||||
var worksheet = workbook.Worksheets.Add(dt,"export");
|
|
||||||
// 设置数据行字体大小
|
|
||||||
var dataRows = worksheet.RowsUsed();
|
|
||||||
foreach (var row in dataRows)
|
|
||||||
{
|
|
||||||
row.Style.Font.FontSize = 14;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 自动调整列宽
|
|
||||||
worksheet.Columns().AdjustToContents();
|
|
||||||
workbook.SaveAs(filePath);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
logger.LogError(e, "export today report error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Create(Tray tray, Variety variety, List<Yarn> yarns)
|
|
||||||
{
|
|
||||||
using var workbook = new XLWorkbook(TempPath);
|
|
||||||
var worksheet = workbook.Worksheet(1); // 假设使用第一个工作表
|
|
||||||
|
|
||||||
worksheet.Cell("D2").Value = tray.Barcode; // 填充 TrayCode 到第一列
|
|
||||||
worksheet.Cell("D3").Value = variety.Code; // 填充 VarietyName 到第二列
|
|
||||||
worksheet.Cell("D4").Value = tray.DenFila;
|
|
||||||
worksheet.Cell("I3").Value = tray.FinishTime?.ToString("yyyy-MM-dd HH:mm:ss");
|
|
||||||
worksheet.Cell("I4").Value = tray.DtexFila;
|
|
||||||
worksheet.Cell("L3").Value = tray.Grade;
|
|
||||||
worksheet.Cell("M3").Value = variety.StackingLayers;
|
|
||||||
worksheet.Cell("N3").Value = tray.Unit?.ToString();
|
|
||||||
worksheet.Cell("O3").Value = yarns.Count.ToString();
|
|
||||||
worksheet.Cell("P3").Value = tray.ControlNo?.ToString();
|
|
||||||
worksheet.Cell("Q3").Value = tray.GrossWeight.ToString(CultureInfo.InvariantCulture);
|
|
||||||
worksheet.Cell("R3").Value = tray.NetWeight.ToString(CultureInfo.InvariantCulture);
|
|
||||||
|
|
||||||
int row = 8; // 假设数据从第二行开始填充
|
|
||||||
for (int i = 1; i <= yarns.Count; i++)
|
|
||||||
{
|
|
||||||
worksheet.Cell(row, "B").Value = i; // 填充 YarnId 到第一列
|
|
||||||
worksheet.Cell(row, "C").Value = yarns[i - 1].Lot; // 填充 YarnName 到第二列
|
|
||||||
worksheet.Cell(row, "D").Value = variety.Code; // 填充 YarnName 到第二列
|
|
||||||
worksheet.Cell(row, "F").Value = yarns[i - 1].Machine;
|
|
||||||
worksheet.Cell(row, "H").Value = yarns[i - 1].WorkShift;
|
|
||||||
worksheet.Cell(row, "I").Value = yarns[i - 1].QrCode;
|
|
||||||
worksheet.Cell(row, "P").Value = yarns[i - 1].StackTime?.ToString("yyyy-MM-dd HH:mm:ss");
|
|
||||||
row++;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 8; i < row; i++)
|
|
||||||
{
|
|
||||||
worksheet.Row(i).Height = 31.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 自动调整列宽
|
|
||||||
// worksheet.Columns().AdjustToContents();
|
|
||||||
// 获取数据区域
|
|
||||||
var dataRange = worksheet.Range(8, 2, row - 1, 18);
|
|
||||||
// 设置外边框样式
|
|
||||||
dataRange.Style.Border.OutsideBorder = XLBorderStyleValues.Thick;
|
|
||||||
dataRange.Style.Border.InsideBorder = XLBorderStyleValues.Medium;
|
|
||||||
dataRange.Style.Border.OutsideBorderColor = XLColor.Black;
|
|
||||||
var path = await GetDirectoryAsync(tray.FinishTime);
|
|
||||||
var fileName =
|
|
||||||
$"{variety.Lot}-{tray.TrayCode}-{tray.FinishTime?.ToString("yyyyMMddHHmmss")}.xlsx";
|
|
||||||
var filePath = Path.Combine(path, fileName);
|
|
||||||
// 保存工作簿到新文件
|
|
||||||
workbook.SaveAs(filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task ExportNoExportAsync()
|
|
||||||
{
|
|
||||||
var codes = await trayService.GetNoExportCodesAsync();
|
|
||||||
codes.ForEach(async void (code) =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await ExportSampleAsync(code);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
logger.LogError(e, $"export report [{code}] error");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task ExportTodayTotalReportAsync()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DataTable dt = new DataTable();
|
|
||||||
dt.Columns.Add("序号");
|
|
||||||
dt.Columns.Add("LOT");
|
|
||||||
dt.Columns.Add("品类");
|
|
||||||
dt.Columns.Add("条码");
|
|
||||||
dt.Columns.Add("数量");
|
|
||||||
dt.Columns.Add("毛重");
|
|
||||||
dt.Columns.Add("净重");
|
|
||||||
dt.Columns.Add("控制号");
|
|
||||||
dt.Columns.Add("完成时间");
|
|
||||||
var trays = await trayService.GetTodayTrayAsync();
|
|
||||||
for (int i = 0; i < trays.Count; i++)
|
|
||||||
{
|
|
||||||
var variety = await varietyService.GetById(trays[i].VarietyId);
|
|
||||||
var yarns = await yarnService.GetYarnsByTrayIdAsync(trays[i].Id);
|
|
||||||
dt.Rows.Add(i + 1, variety.Lot, variety.Code, trays[i].Barcode, yarns.Count,
|
|
||||||
trays[i].GrossWeight, trays[i].NetWeight, trays[i].ControlNo,
|
|
||||||
trays[i].FinishTime?.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
||||||
}
|
|
||||||
|
|
||||||
var path = await GetTotalDirectoryAsync();
|
|
||||||
var fileName = $"每日报表-{DateTime.Now:yyyyMMdd}.xlsx";
|
|
||||||
var filePath = Path.Combine(path, fileName);
|
|
||||||
using var workbook = new XLWorkbook();
|
|
||||||
var worksheet = workbook.Worksheets.Add(dt);
|
|
||||||
var headerRow = worksheet.FirstRowUsed();
|
|
||||||
headerRow.Style.Font.FontSize = 16;
|
|
||||||
|
|
||||||
// 设置数据行字体大小
|
|
||||||
var dataRows = worksheet.RowsUsed().Skip(1);
|
|
||||||
foreach (var row in dataRows)
|
|
||||||
{
|
|
||||||
row.Style.Font.FontSize = 14;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 自动调整列宽
|
|
||||||
worksheet.Columns().AdjustToContents();
|
|
||||||
workbook.SaveAs(filePath);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
logger.LogError(e, "export today report error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<string> GetTotalDirectoryAsync(DateTime? date = null)
|
|
||||||
{
|
|
||||||
var root = "D:\\每日报表";
|
|
||||||
if (date is null)
|
|
||||||
date = DateTime.Now;
|
|
||||||
// 构建文件夹路径,格式为 年/月/日
|
|
||||||
string directoryPath = Path.Combine(root, date.Value.Year.ToString(), date.Value.Month.ToString());
|
|
||||||
|
|
||||||
// 检查文件夹是否存在
|
|
||||||
if (!Directory.Exists(directoryPath))
|
|
||||||
{
|
|
||||||
// 如果不存在,则创建文件夹
|
|
||||||
await Task.Run(() => Directory.CreateDirectory(directoryPath));
|
|
||||||
}
|
|
||||||
|
|
||||||
return directoryPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<string> GetDirectoryAsync(DateTime? date = null)
|
|
||||||
{
|
|
||||||
var root = "D:\\码垛信息";
|
|
||||||
if (date is null)
|
|
||||||
date = DateTime.Now;
|
|
||||||
// 构建文件夹路径,格式为 年/月/日
|
|
||||||
string directoryPath = Path.Combine(root, date.Value.Year.ToString(), date.Value.Month.ToString(),
|
|
||||||
date.Value.Day.ToString());
|
|
||||||
|
|
||||||
// 检查文件夹是否存在
|
|
||||||
if (!Directory.Exists(directoryPath))
|
|
||||||
{
|
|
||||||
// 如果不存在,则创建文件夹
|
|
||||||
await Task.Run(() => Directory.CreateDirectory(directoryPath));
|
|
||||||
}
|
|
||||||
|
|
||||||
return directoryPath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -6,62 +6,57 @@ using Seyounth.Hyosung.Data.Models;
|
|||||||
using Seyounth.Hyosung.Data.Repositories;
|
using Seyounth.Hyosung.Data.Repositories;
|
||||||
using Seyounth.Hyosung.Data.Services.Hyosung;
|
using Seyounth.Hyosung.Data.Services.Hyosung;
|
||||||
using Seyounth.Hyosung.Data.Services.Hyosung.Entities;
|
using Seyounth.Hyosung.Data.Services.Hyosung.Entities;
|
||||||
using SqlSugar;
|
|
||||||
|
|
||||||
namespace Seyounth.Hyosung.Data.Services;
|
namespace Seyounth.Hyosung.Data.Services;
|
||||||
|
|
||||||
public class TrayService : ITrayService
|
public class TrayService : ITrayService
|
||||||
{
|
{
|
||||||
//private readonly ConcurrentDictionary<string, Tray> _cache = new();
|
private readonly ConcurrentDictionary<long, Tray> _cache = new();
|
||||||
// private readonly <TrayEntity> _repository;
|
private readonly IRepository<TrayEntity> _repository;
|
||||||
private readonly IHyosungWmsService _hyosungWmsService;
|
private readonly IHyosungWmsService _hyosungWmsService;
|
||||||
|
|
||||||
private readonly ISqlSugarClient _db;
|
public TrayService(IServiceProvider provider, IHyosungWmsService hyosungWmsService)
|
||||||
|
|
||||||
public TrayService(IServiceProvider provider, IHyosungWmsService hyosungWmsService, ISqlSugarClient db)
|
|
||||||
{
|
{
|
||||||
_db = db;
|
_repository = provider.CreateScope().ServiceProvider.GetRequiredService<IRepository<TrayEntity>>();
|
||||||
// _repository = provider.CreateScope().ServiceProvider.GetRequiredService<IRepository<TrayEntity>>();
|
var trays = _repository.GetList(t => t.ControlNo == null);
|
||||||
//_repository = provider.GetService<IRepository<TrayEntity>>();
|
|
||||||
// var trays = _db.Queryable<TrayEntity>().Where(t => t.ControlNo == null).ToListAsync().Result;
|
|
||||||
_hyosungWmsService = hyosungWmsService;
|
_hyosungWmsService = hyosungWmsService;
|
||||||
//foreach (var tray in trays)
|
foreach (var tray in trays)
|
||||||
//{
|
{
|
||||||
// _cache.TryAdd(tray.TrayCode, Tray.FromEntity(tray));
|
_cache.TryAdd(tray.TrayCode, Tray.FromEntity(tray));
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Tray> GeneraNewTray(int varietyId)
|
public async Task<Tray> GeneraNewTray(int varietyId)
|
||||||
{
|
{
|
||||||
var tray = new Tray()
|
var tray = new Tray()
|
||||||
{
|
{
|
||||||
TrayCode = DateTime.Now.ToTimestamp().ToString(),
|
TrayCode = DateTime.Now.ToTimestamp(),
|
||||||
VarietyId = varietyId,
|
VarietyId = varietyId,
|
||||||
CreateTime = DateTime.Now
|
CreateTime = DateTime.Now
|
||||||
};
|
};
|
||||||
var count = await _db.CopyNew().Queryable<TrayEntity>().CountAsync(t => t.VarietyId == tray.VarietyId);
|
var count = await _repository.CountAsync(t => t.VarietyId == tray.VarietyId);
|
||||||
tray.IsEven = count % 2 == 0;
|
tray.IsEven = count % 2 == 0;
|
||||||
var identity = await _db.CopyNew().Insertable<TrayEntity>(tray.ToEntity()).ExecuteReturnIdentityAsync();
|
var identity = await _repository.InsertReturnIdentityAsync(tray.ToEntity());
|
||||||
tray.Id = identity;
|
tray.Id = identity;
|
||||||
// _cache.TryAdd(tray.TrayCode, tray);
|
_cache.TryAdd(tray.TrayCode, tray);
|
||||||
return tray;
|
return tray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> GetIdByCode(string code)
|
public async Task<int> GetIdByCode(long code)
|
||||||
{
|
{
|
||||||
//try
|
try
|
||||||
//{
|
{
|
||||||
// return _cache[code].Id;
|
return _cache[code].Id;
|
||||||
//}
|
}
|
||||||
//catch
|
catch
|
||||||
//{
|
{
|
||||||
return (await _db.CopyNew().Queryable<TrayEntity>().Where(d => d.TrayCode == code).FirstAsync()).Id;
|
return (await _repository.GetFirstAsync(d => d.TrayCode == code)).Id;
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Tray> GetByCode(string code)
|
public async Task<Tray> GetByCode(long code)
|
||||||
{
|
{
|
||||||
return Tray.FromEntity(await _db.CopyNew().Queryable<TrayEntity>().Where(t => t.TrayCode == code).FirstAsync());
|
return Tray.FromEntity(await _repository.GetSingleAsync(t => t.TrayCode == code));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task StorageAsync(string trayCode, int stackHeight, int controlNo, MST_ITEM_2240_V itemInfo)
|
public Task StorageAsync(string trayCode, int stackHeight, int controlNo, MST_ITEM_2240_V itemInfo)
|
||||||
@ -69,89 +64,36 @@ public class TrayService : ITrayService
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Tray> PrintTrayAsync(string trayCode, MST_ITEM_2240_V itemInfo, Variety variety)
|
public async Task PrintTrayAsync(long trayCode, int stackHeight, int controlNo, MST_ITEM_2240_V itemInfo)
|
||||||
{
|
{
|
||||||
Tray tray;
|
Tray tray;
|
||||||
//try
|
try
|
||||||
//{
|
{
|
||||||
// tray = _cache[trayCode];
|
tray = _cache[trayCode];
|
||||||
//}
|
}
|
||||||
//catch
|
catch
|
||||||
//{
|
{
|
||||||
tray = await GetByCode(trayCode);
|
tray = await GetByCode(trayCode);
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
tray.ControlNo = controlNo;
|
||||||
|
tray.StackHeight = stackHeight;
|
||||||
tray.Grade = itemInfo.GRADE;
|
tray.Grade = itemInfo.GRADE;
|
||||||
tray.Type = itemInfo.TYPE;
|
tray.Type = itemInfo.TYPE;
|
||||||
tray.DenFila = itemInfo.DEN_FILA;
|
tray.DenFila = itemInfo.DEN_FILA;
|
||||||
tray.DtexFila = itemInfo.DTEX_FILA;
|
tray.DtexFila = itemInfo.DTEX_FILA;
|
||||||
tray.Unit = itemInfo.UNIT;
|
tray.Unit = itemInfo.UNIT;
|
||||||
tray.NetWeight = variety.NetWeight ?? itemInfo.NET_WEIGHT;
|
tray.NetWeight = itemInfo.NET_WEIGHT;
|
||||||
tray.GrossWeight = variety.GrossWeight ?? itemInfo.GROSS_WEIGHT;
|
tray.GrossWeight = itemInfo.GROSS_WEIGHT;
|
||||||
var netWeight = tray.NetWeight.ToString("0.0");
|
await _repository.UpdateAsync(tray.ToEntity());
|
||||||
if (netWeight.EndsWith(".0"))
|
_cache.Remove(tray.TrayCode, out _);
|
||||||
netWeight = netWeight.Replace(".0", "");
|
|
||||||
tray.Barcode =
|
|
||||||
$"{itemInfo.ITEM_CODE} {DateTime.Now:yyMMdd}{netWeight.PadLeft(6,'0')}{itemInfo.LOTNO.PadLeft(4, '0')}{tray.ControlNo?.ToString().PadLeft(4, '0')}0";
|
|
||||||
await _db.Updateable<TrayEntity>(tray.ToEntity()).ExecuteCommandAsync();
|
|
||||||
// _cache.Remove(tray.TrayCode, out _);
|
|
||||||
return tray;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task StorageAsync(string trayCode)
|
public async Task StorageAsync(long trayCode)
|
||||||
{
|
{
|
||||||
var tray = await _db.CopyNew().Queryable<TrayEntity>().Where(d => d.TrayCode == trayCode).FirstAsync();
|
var tray = await GetByCode(trayCode);
|
||||||
tray.FinishTime = DateTime.Now;
|
tray.FinishTime = DateTime.Now;
|
||||||
tray.IsPacking = true;
|
await _repository.UpdateAsync(tray.ToEntity());
|
||||||
await _db.CopyNew().Updateable<TrayEntity>(tray).ExecuteCommandAsync();
|
_cache.Remove(tray.TrayCode, out _);
|
||||||
// _cache.TryRemove(tray.TrayCode, out _);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task UpdateHeightAsync(string trayCode, int height)
|
|
||||||
{
|
|
||||||
await _db.CopyNew().Updateable<TrayEntity>()
|
|
||||||
.Where(x => x.TrayCode == trayCode)
|
|
||||||
.SetColumns(x => x.StackHeight, height)
|
|
||||||
.SetColumns(x => x.IsPacking, false)
|
|
||||||
.ExecuteCommandAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task ExportedAsync(string trayCode)
|
|
||||||
{
|
|
||||||
return _db.CopyNew().Updateable<TrayEntity>()
|
|
||||||
.Where(x => x.TrayCode == trayCode)
|
|
||||||
.SetColumns(x => x.Exported, true).ExecuteCommandAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<List<string>> GetNoExportCodesAsync()
|
|
||||||
{
|
|
||||||
var tray = await _db.CopyNew().Queryable<TrayEntity>().Where(x => x.Exported != true && x.FinishTime != null)
|
|
||||||
.ToListAsync();
|
|
||||||
var trayCodes = tray.Select(x => x.TrayCode).ToList();
|
|
||||||
return trayCodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task SetControlNoAsync(string trayCode, int controlNo)
|
|
||||||
{
|
|
||||||
return _db.CopyNew()
|
|
||||||
.Updateable<TrayEntity>()
|
|
||||||
.Where(d => d.TrayCode == trayCode)
|
|
||||||
.SetColumns(x => x.ControlNo, controlNo)
|
|
||||||
.ExecuteCommandAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<List<Tray>> GetTodayTrayAsync()
|
|
||||||
{
|
|
||||||
return _db.CopyNew()
|
|
||||||
.Queryable<TrayEntity>()
|
|
||||||
.Where(x => x.FinishTime >= DateTime.Today && x.FinishTime < DateTime.Today.AddDays(1))
|
|
||||||
.ToListAsync(x => Tray.FromEntity(x));
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Tray> GetIsPacking()
|
|
||||||
{
|
|
||||||
var tray = await _db.CopyNew().Queryable<TrayEntity>().Where(x => x.IsPacking != null && x.IsPacking.Value)
|
|
||||||
.FirstAsync();
|
|
||||||
return Tray.FromEntity(tray);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -20,8 +20,6 @@ public class VarietyService : IVarietyService
|
|||||||
_varietyRepository =
|
_varietyRepository =
|
||||||
provider.CreateScope().ServiceProvider.GetRequiredService<IRepository<VarietyEntity>>();
|
provider.CreateScope().ServiceProvider.GetRequiredService<IRepository<VarietyEntity>>();
|
||||||
_palletRepository = provider.CreateScope().ServiceProvider.GetRequiredService<IRepository<PalletEntity>>();
|
_palletRepository = provider.CreateScope().ServiceProvider.GetRequiredService<IRepository<PalletEntity>>();
|
||||||
//_varietyRepository = provider.GetService<IRepository<VarietyEntity>>();
|
|
||||||
// _palletRepository = provider.GetService<IRepository<PalletEntity>>();
|
|
||||||
_varietiesCache = new List<VarietyEntity>(_varietyRepository.GetList());
|
_varietiesCache = new List<VarietyEntity>(_varietyRepository.GetList());
|
||||||
_palletsCache = new List<PalletEntity>(_palletRepository.GetList());
|
_palletsCache = new List<PalletEntity>(_palletRepository.GetList());
|
||||||
}
|
}
|
||||||
@ -86,18 +84,4 @@ public class VarietyService : IVarietyService
|
|||||||
{
|
{
|
||||||
return _varietiesCache.Select(v => Variety.Create(v, _palletsCache.ToList())).ToList();
|
return _varietiesCache.Select(v => Variety.Create(v, _palletsCache.ToList())).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int?> GetLastNo(int varietyId)
|
|
||||||
{
|
|
||||||
var variety = await (_varietyRepository.CopyNew().GetFirstAsync(x=>x.Id==varietyId));
|
|
||||||
return variety.LastNo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task SetLastNo(int varietyId,int lastNo)
|
|
||||||
{
|
|
||||||
await _varietyRepository.CopyNew().AsUpdateable()
|
|
||||||
.Where(x => x.Id == varietyId)
|
|
||||||
.SetColumns(x => x.LastNo , lastNo)
|
|
||||||
.ExecuteCommandAsync();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -13,8 +13,7 @@ public class YarnService : IYarnService
|
|||||||
public YarnService(IServiceProvider provider)
|
public YarnService(IServiceProvider provider)
|
||||||
{
|
{
|
||||||
_yarnRepository = provider.CreateScope().ServiceProvider.GetRequiredService<IRepository<ScannedYarnEntity>>();
|
_yarnRepository = provider.CreateScope().ServiceProvider.GetRequiredService<IRepository<ScannedYarnEntity>>();
|
||||||
// _yarnRepository = provider.GetService<IRepository<ScannedYarnEntity>>();
|
NoFinished = new ConcurrentDictionary<long, Yarn>();
|
||||||
NoFinished = new ConcurrentDictionary<string, Yarn>();
|
|
||||||
var yarns = _yarnRepository.GetList(y => !y.IsFinished);
|
var yarns = _yarnRepository.GetList(y => !y.IsFinished);
|
||||||
foreach (var yarn in yarns)
|
foreach (var yarn in yarns)
|
||||||
{
|
{
|
||||||
@ -22,11 +21,11 @@ public class YarnService : IYarnService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentDictionary<string, Yarn> NoFinished { get; }
|
public ConcurrentDictionary<long, Yarn> NoFinished { get; }
|
||||||
|
|
||||||
public async Task<Yarn?> AddYarnAsync(Yarn yarn)
|
public async Task<Yarn?> AddYarnAsync(Yarn yarn)
|
||||||
{
|
{
|
||||||
var id = await _yarnRepository.CopyNew().InsertReturnIdentityAsync(yarn.ToEntity());
|
var id = await _yarnRepository.InsertReturnIdentityAsync(yarn.ToEntity());
|
||||||
yarn.Id = id;
|
yarn.Id = id;
|
||||||
NoFinished.TryAdd(yarn.ScanCode, yarn);
|
NoFinished.TryAdd(yarn.ScanCode, yarn);
|
||||||
return yarn;
|
return yarn;
|
||||||
@ -34,11 +33,11 @@ public class YarnService : IYarnService
|
|||||||
|
|
||||||
public async Task<List<Yarn>> GetYarnsByTrayIdAsync(int trayId)
|
public async Task<List<Yarn>> GetYarnsByTrayIdAsync(int trayId)
|
||||||
{
|
{
|
||||||
return (await _yarnRepository.CopyNew().GetListAsync(y => y.TrayId == trayId))
|
return (await _yarnRepository.GetListAsync(y => y.TrayId == trayId))
|
||||||
.Select(Yarn.FromEntity).ToList();
|
.Select(Yarn.FromEntity).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Yarn> GetYarnByCodeAsync(string code)
|
public async Task<Yarn> GetYarnByCodeAsync(long code)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -46,27 +45,27 @@ public class YarnService : IYarnService
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return Yarn.FromEntity(await _yarnRepository.CopyNew().GetFirstAsync(d => d.ScanCode == code)) ;
|
return Yarn.FromEntity(await _yarnRepository.GetFirstAsync(d => d.ScanCode == code)) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task FinishYarnAsync(string yarnCode)
|
public async Task FinishYarnAsync(long yarnCode)
|
||||||
{
|
{
|
||||||
var yarn = NoFinished[yarnCode];
|
var yarn = NoFinished[yarnCode];
|
||||||
yarn.IsFinished = true;
|
yarn.IsFinished = true;
|
||||||
await _yarnRepository.CopyNew().UpdateAsync(yarn.ToEntity());
|
await _yarnRepository.UpdateAsync(yarn.ToEntity());
|
||||||
NoFinished.TryRemove(yarnCode, out _);
|
NoFinished.TryRemove(yarnCode, out _);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task BindTrayAsync(string yarnCode, int trayId)
|
public async Task BindTrayAsync(long yarnCode, int trayId)
|
||||||
{
|
{
|
||||||
var yarn = NoFinished[yarnCode];
|
var yarn = NoFinished[yarnCode];
|
||||||
yarn.TrayId = trayId;
|
yarn.TrayId = trayId;
|
||||||
yarn.StackTime = DateTime.Now;
|
yarn.StackTime = DateTime.Now;
|
||||||
yarn.IsFinished = true;
|
yarn.IsFinished = true;
|
||||||
yarn.IsFinished = true;
|
yarn.IsFinished = true;
|
||||||
await _yarnRepository.CopyNew().UpdateAsync(yarn.ToEntity());
|
await _yarnRepository.UpdateAsync(yarn.ToEntity());
|
||||||
NoFinished.TryRemove(yarnCode, out _);
|
NoFinished.TryRemove(yarnCode, out _);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,12 +7,10 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ClosedXML" Version="0.104.2" />
|
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||||
<PackageReference Include="McProtocol" Version="1.2.5" />
|
<PackageReference Include="McProtocol" Version="1.2.5" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.3" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.3" />
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.3" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.3" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.3" />
|
|
||||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.182" />
|
<PackageReference Include="SqlSugarCore" Version="5.1.4.182" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
@ -20,10 +18,4 @@
|
|||||||
<ProjectReference Include="..\Seyounth.Core\Seyounth.Core.csproj" />
|
<ProjectReference Include="..\Seyounth.Core\Seyounth.Core.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="exportTemp.xlsx">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Binary file not shown.
@ -10,7 +10,6 @@ using Seyounth.Hyosung.Data.Models;
|
|||||||
using Seyounth.Hyosung.Data.Models.Plc;
|
using Seyounth.Hyosung.Data.Models.Plc;
|
||||||
using Seyounth.Hyosung.Data.Services;
|
using Seyounth.Hyosung.Data.Services;
|
||||||
using Seyounth.Hyosung.Data.Services.Hyosung;
|
using Seyounth.Hyosung.Data.Services.Hyosung;
|
||||||
using Seyounth.Hyosung.Data.Services.Hyosung.Entities;
|
|
||||||
using Seyounth.Hyosung.Runtime.Models;
|
using Seyounth.Hyosung.Runtime.Models;
|
||||||
|
|
||||||
namespace Seyounth.Hyosung.Runtime;
|
namespace Seyounth.Hyosung.Runtime;
|
||||||
@ -24,21 +23,14 @@ public class HyosungRuntime(
|
|||||||
ITrayService trayService,
|
ITrayService trayService,
|
||||||
IVarietyService varietyService,
|
IVarietyService varietyService,
|
||||||
IHyosungAgvService hyosungAgvService,
|
IHyosungAgvService hyosungAgvService,
|
||||||
IHyosungWmsService hyosungWmsService,
|
IHyosungWmsService hyosungWmsService) : IHyosungRuntime
|
||||||
IDictService dictService,
|
|
||||||
IReportExportService reportExportService) : IHyosungRuntime
|
|
||||||
{
|
{
|
||||||
public PackLineOption PackLineOption { get; private set; }
|
public PackLineOption PackLineOption { get; private set; }
|
||||||
public StackStationModel Stack1 { get; private set; } = new();
|
public StackStationModel Stack1 { get; private set; } = new();
|
||||||
public StackStationModel Stack2 { get; private set; } = new();
|
public StackStationModel Stack2 { get; private set; } = new();
|
||||||
|
|
||||||
private ConcurrentQueue<int> _packingQueue = new ConcurrentQueue<int>();
|
|
||||||
|
|
||||||
private string currentPrintTrayCode = "";
|
|
||||||
|
|
||||||
public async Task StartAsync(CancellationToken token)
|
public async Task StartAsync(CancellationToken token)
|
||||||
{
|
{
|
||||||
reportExportService.ExportNoExportAsync();
|
|
||||||
//启动扫码服务
|
//启动扫码服务
|
||||||
await hyosungScannerService.StartAsync(token);
|
await hyosungScannerService.StartAsync(token);
|
||||||
await printer.StartAsync(token);
|
await printer.StartAsync(token);
|
||||||
@ -50,50 +42,9 @@ public class HyosungRuntime(
|
|||||||
hyosungPlcService.OnPlcPutCompleted += OnPlcPutCompleted;
|
hyosungPlcService.OnPlcPutCompleted += OnPlcPutCompleted;
|
||||||
hyosungPlcService.OnPlcRequestPackLineOption += OnPlcRequestPackLineOption;
|
hyosungPlcService.OnPlcRequestPackLineOption += OnPlcRequestPackLineOption;
|
||||||
hyosungPlcService.OnRequestPrintLabel += OnPlcRequestPrintLabel;
|
hyosungPlcService.OnRequestPrintLabel += OnPlcRequestPrintLabel;
|
||||||
hyosungPlcService.OnRequestGetPrintLableOption += OnRequestGetPrintLabel;
|
|
||||||
hyosungPlcService.OnRequestScanEntry += OnPlcRequestScanEntry;
|
|
||||||
await hyosungPlcService.StartAsync(token);
|
await hyosungPlcService.StartAsync(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OnPlcRequestScanEntry(int arg)
|
|
||||||
{
|
|
||||||
logger.LogInformation($"plc request scan entry:{arg}");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var carCode = await hyosungScannerService.ScanYarnCarAsync(arg);
|
|
||||||
var varietyId = await hyosungScannerService.ScanVarietyAsync(arg);
|
|
||||||
if (string.IsNullOrEmpty(carCode) || string.IsNullOrEmpty(varietyId))
|
|
||||||
{
|
|
||||||
await hyosungPlcService.WriteScanEntryResultAsync(arg, false);
|
|
||||||
logger.LogInformation($"scan entry fail");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var carType = carCode[..1];
|
|
||||||
int carNumber = carType switch
|
|
||||||
{
|
|
||||||
"A" => 1,
|
|
||||||
"B" => 2,
|
|
||||||
"C" => 3,
|
|
||||||
"D" => 4,
|
|
||||||
_ => 0
|
|
||||||
};
|
|
||||||
var variety = await varietyService.GetById(int.Parse(varietyId));
|
|
||||||
variety.YarnCarType = carNumber;
|
|
||||||
variety.YarnCarSide = 1;
|
|
||||||
await SendVarietyToPlcAsync(variety);
|
|
||||||
await hyosungPlcService.WriteScanEntryResultAsync(arg, true);
|
|
||||||
logger.LogInformation($"scan entry success: {carCode}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
await hyosungPlcService.WriteScanEntryResultAsync(arg, false);
|
|
||||||
logger.LogError(e, $"scan entry fail");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public async Task StopAsync(CancellationToken token)
|
public async Task StopAsync(CancellationToken token)
|
||||||
{
|
{
|
||||||
//先停止扫码服务
|
//先停止扫码服务
|
||||||
@ -116,15 +67,6 @@ public class HyosungRuntime(
|
|||||||
logger.LogInformation($"send variety to plc success: {variety.Id}");
|
logger.LogInformation($"send variety to plc success: {variety.Id}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task GenerateReportAsync()
|
|
||||||
{
|
|
||||||
var trays = await trayService.GetTodayTrayAsync();
|
|
||||||
foreach (var tray in trays)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 处理PLC请求扫描治具事件
|
/// 处理PLC请求扫描治具事件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -203,8 +145,6 @@ public class HyosungRuntime(
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
await trayService.StorageAsync(info.TrayCode);
|
await trayService.StorageAsync(info.TrayCode);
|
||||||
|
|
||||||
reportExportService.ExportSampleAsync(info.TrayCode);
|
|
||||||
await hyosungAgvService.StorageAsync(info.TrayCode);
|
await hyosungAgvService.StorageAsync(info.TrayCode);
|
||||||
//标志下线已完成
|
//标志下线已完成
|
||||||
await hyosungPlcService.LeaveCompletedAsync();
|
await hyosungPlcService.LeaveCompletedAsync();
|
||||||
@ -305,55 +245,31 @@ public class HyosungRuntime(
|
|||||||
/// <param name="arg"></param>
|
/// <param name="arg"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="NotImplementedException"></exception>
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
private async Task OnPlcRequestPackLineOption(string arg)
|
private async Task OnPlcRequestPackLineOption(long arg)
|
||||||
{
|
{
|
||||||
logger.LogInformation($"plc request pack line option");
|
logger.LogInformation($"plc request pack line option");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var tray = await trayService.GetByCode(arg);
|
var tray = await trayService.GetByCode(arg);
|
||||||
var variety = await varietyService.GetById(tray.VarietyId);
|
var variety = await varietyService.GetById(tray.VarietyId);
|
||||||
_packingQueue.Enqueue(variety.Id);
|
|
||||||
var mod = await hyosungWmsService.GetItemInfoByItemCode(variety.Code);
|
|
||||||
var grade = "1";
|
|
||||||
if (mod.GRADE != "AA") grade = mod.GRADE;
|
|
||||||
var count = _packingQueue.Count(x => x == variety.Id);
|
|
||||||
var control = await varietyService.GetLastNo(variety.Id);
|
|
||||||
if (control is null)
|
|
||||||
control = await hyosungWmsService.GetControlNo(variety, grade);
|
|
||||||
else
|
|
||||||
control = control + 1;
|
|
||||||
if (control == 1000)
|
|
||||||
control = 1;
|
|
||||||
var isEven = control % 2 == 0;
|
|
||||||
await varietyService.SetLastNo(variety.Id, control.Value);
|
|
||||||
await trayService.SetControlNoAsync(arg, control.Value);
|
|
||||||
PackLineOption = new PackLineOption()
|
PackLineOption = new PackLineOption()
|
||||||
{
|
{
|
||||||
HeadCount = variety.StackHeadCount ?? 0,
|
HeadCount = variety.StackHeadCount ?? 0,
|
||||||
HasBox = variety.HasBox,
|
HasBox = variety.HasBox,
|
||||||
|
IsTop = variety.NeedTopBoard is NeedType.Need or NeedType.NotNeed
|
||||||
|
? variety.NeedTopBoard == NeedType.Need
|
||||||
|
: tray.IsEven && variety.NeedTopBoard == NeedType.EvenNeed,
|
||||||
|
IsPack = variety.NeedPackStrap is NeedType.Need or NeedType.NotNeed
|
||||||
|
? variety.NeedPackStrap == NeedType.Need
|
||||||
|
: tray.IsEven && variety.NeedPackStrap == NeedType.EvenNeed,
|
||||||
|
IsFilm = variety.NeedFilmWrapping is NeedType.Need or NeedType.NotNeed
|
||||||
|
? variety.NeedFilmWrapping == NeedType.Need
|
||||||
|
: tray.IsEven && variety.NeedFilmWrapping == NeedType.EvenNeed,
|
||||||
|
IsLam = variety.NeedFilmCoating is NeedType.Need or NeedType.NotNeed
|
||||||
|
? variety.NeedFilmCoating == NeedType.Need
|
||||||
|
: tray.IsEven && variety.NeedFilmCoating == NeedType.EvenNeed,
|
||||||
TrayCode = arg
|
TrayCode = arg
|
||||||
};
|
};
|
||||||
if (variety.NeedTopBoard == NeedType.Need || (isEven && variety.NeedTopBoard == NeedType.EvenNeed) ||
|
|
||||||
(!isEven && variety.NeedTopBoard == NeedType.OddNeed))
|
|
||||||
PackLineOption.IsTop = true;
|
|
||||||
else
|
|
||||||
PackLineOption.IsTop = false;
|
|
||||||
if (variety.NeedPackStrap == NeedType.Need || (isEven && variety.NeedPackStrap == NeedType.EvenNeed) ||
|
|
||||||
(!isEven && variety.NeedPackStrap == NeedType.OddNeed))
|
|
||||||
PackLineOption.IsPack = true;
|
|
||||||
else
|
|
||||||
PackLineOption.IsPack = false;
|
|
||||||
if (variety.NeedFilmWrapping == NeedType.Need ||
|
|
||||||
(isEven && variety.NeedFilmWrapping == NeedType.EvenNeed) ||
|
|
||||||
(!isEven && variety.NeedFilmWrapping == NeedType.OddNeed))
|
|
||||||
PackLineOption.IsFilm = true;
|
|
||||||
else
|
|
||||||
PackLineOption.IsFilm = false;
|
|
||||||
if (variety.NeedFilmCoating == NeedType.Need || (isEven && variety.NeedFilmCoating == NeedType.EvenNeed) ||
|
|
||||||
(!isEven && variety.NeedFilmCoating == NeedType.OddNeed))
|
|
||||||
PackLineOption.IsLam = true;
|
|
||||||
else
|
|
||||||
PackLineOption.IsLam = false;
|
|
||||||
await hyosungPlcService.WritePackLineOptionAsync(PackLineOption);
|
await hyosungPlcService.WritePackLineOptionAsync(PackLineOption);
|
||||||
logger.LogInformation($"plc request pack line option success");
|
logger.LogInformation($"plc request pack line option success");
|
||||||
}
|
}
|
||||||
@ -363,39 +279,6 @@ public class HyosungRuntime(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OnRequestGetPrintLabel(string arg)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
logger.LogInformation("request print option");
|
|
||||||
currentPrintTrayCode = arg;
|
|
||||||
var tray = await trayService.GetByCode(arg);
|
|
||||||
var variety = await varietyService.GetById(tray.VarietyId);
|
|
||||||
var mod = await hyosungWmsService.GetItemInfoByItemCode(variety.Code);
|
|
||||||
// var grade = "1";
|
|
||||||
// if (mod.GRADE != "AA") grade = mod.GRADE;
|
|
||||||
// int? controlNo;
|
|
||||||
// if (tray.ControlNo is null || tray.ControlNo == 0)
|
|
||||||
// {
|
|
||||||
// controlNo = await varietyService.GetLastNo(variety.Id);
|
|
||||||
// if (controlNo is null)
|
|
||||||
// controlNo = await hyosungWmsService.GetControlNo(variety, grade);
|
|
||||||
// else
|
|
||||||
// controlNo += 1;
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
tray = await trayService.PrintTrayAsync(arg, mod, variety);
|
|
||||||
await dictService.SetValue("System", "CurrentPackingTrayCode", arg);
|
|
||||||
await hyosungPlcService.WritePrintLableOptionsAsync(variety.MasterLabelCount, variety.SubLabelCount);
|
|
||||||
logger.LogInformation("request print option succeed");
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
logger.LogError(e, "GetPrintOptionError");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 处理贴标站请求贴标事件
|
/// 处理贴标站请求贴标事件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -403,31 +286,29 @@ public class HyosungRuntime(
|
|||||||
/// <param name="arg2"></param>
|
/// <param name="arg2"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="NotImplementedException"></exception>
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
private async Task OnPlcRequestPrintLabel(int arg1, int height)
|
private async Task OnPlcRequestPrintLabel(int arg1, long trayCode, int height)
|
||||||
{
|
{
|
||||||
var trayCode = await dictService.GetValue("System", "CurrentPackingTrayCode");
|
logger.LogInformation($"plc request print label:{arg1} {trayCode} {height}");
|
||||||
var tray = await trayService.GetByCode(trayCode);
|
|
||||||
logger.LogInformation($"plc request print label:{arg1} {tray.TrayCode} {height}");
|
|
||||||
//var tray = await trayService.GetByCode(currentPrintTrayCode);
|
|
||||||
var variety = await varietyService.GetById(tray.VarietyId);
|
|
||||||
await trayService.UpdateHeightAsync(tray.TrayCode, height);
|
|
||||||
try
|
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);
|
||||||
|
await trayService.PrintTrayAsync(trayCode, height, controlNo, mod);
|
||||||
if (arg1 == 1)
|
if (arg1 == 1)
|
||||||
{
|
{
|
||||||
await printer.PrintAsync(1, tray.TrayCode);
|
|
||||||
await hyosungPlcService.WritePrintLabelResultAsync(arg1, true);
|
await printer.PrintAsync(1, trayCode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
await printer.PrintAsync(2, trayCode);
|
||||||
await printer.PrintAsync(2, tray.TrayCode);
|
|
||||||
await hyosungPlcService.WritePrintLabelResultAsync(arg1, true);
|
|
||||||
var version=await hyosungWmsService.GetItemInfoByItemCode(variety.Code);
|
|
||||||
// await varietyService.SetLastNo(variety.Id, tray.ControlNo.Value);
|
|
||||||
//await hyosungWmsService.UpdateControlNo(variety, tray.ControlNo.Value);
|
|
||||||
// await hyosungWmsService.AddLabelResult(new LabelResult(tray, variety));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
await hyosungPlcService.WritePrintLabelResultAsync(arg1, true);
|
||||||
|
await hyosungWmsService.UpdateControlNo(variety, controlNo);
|
||||||
logger.LogInformation($"plc request print label success");
|
logger.LogInformation($"plc request print label success");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|||||||
@ -32,10 +32,4 @@ public interface IHyosungRuntime
|
|||||||
/// <param name="variety"></param>
|
/// <param name="variety"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task SendVarietyToPlcAsync(Variety variety);
|
Task SendVarietyToPlcAsync(Variety variety);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 生成当日报表
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task GenerateReportAsync();
|
|
||||||
}
|
}
|
||||||
@ -9,7 +9,7 @@ namespace Seyounth.Hyosung.Runtime.Models;
|
|||||||
public partial class StackStationModel
|
public partial class StackStationModel
|
||||||
{
|
{
|
||||||
[ObservableProperty] [DefaultValue("NoData")]
|
[ObservableProperty] [DefaultValue("NoData")]
|
||||||
private string trayCode;
|
private long trayCode;
|
||||||
|
|
||||||
[ObservableProperty] [DefaultValue("NoData")]
|
[ObservableProperty] [DefaultValue("NoData")]
|
||||||
private string varietyCode;
|
private string varietyCode;
|
||||||
|
|||||||
@ -5,7 +5,6 @@ using System.Reflection;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
@ -31,7 +30,6 @@ public partial class App : Application
|
|||||||
|
|
||||||
public App()
|
public App()
|
||||||
{
|
{
|
||||||
RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.Default;
|
|
||||||
var builder = Host
|
var builder = Host
|
||||||
.CreateApplicationBuilder();
|
.CreateApplicationBuilder();
|
||||||
builder.Logging.ClearProviders();
|
builder.Logging.ClearProviders();
|
||||||
|
|||||||
@ -19,8 +19,6 @@ public partial class HomeViewModel : ObservableObject
|
|||||||
|
|
||||||
[ObservableProperty] private List<string> _yarnCarTypes;
|
[ObservableProperty] private List<string> _yarnCarTypes;
|
||||||
|
|
||||||
[ObservableProperty] private List<string> _yarnCarSide;
|
|
||||||
|
|
||||||
[ObservableProperty] private Variety _selectedVariety;
|
[ObservableProperty] private Variety _selectedVariety;
|
||||||
|
|
||||||
[ObservableProperty] private PackLineOption _packLineOption;
|
[ObservableProperty] private PackLineOption _packLineOption;
|
||||||
@ -38,9 +36,6 @@ public partial class HomeViewModel : ObservableObject
|
|||||||
_yarnCarTypes.Add("B");
|
_yarnCarTypes.Add("B");
|
||||||
_yarnCarTypes.Add("C");
|
_yarnCarTypes.Add("C");
|
||||||
_yarnCarTypes.Add("D");
|
_yarnCarTypes.Add("D");
|
||||||
_yarnCarSide = new();
|
|
||||||
_yarnCarSide.Add("正面");
|
|
||||||
_yarnCarSide.Add("反面");
|
|
||||||
_varieties = new ObservableCollection<Variety>(varietyService.GetAll());
|
_varieties = new ObservableCollection<Variety>(varietyService.GetAll());
|
||||||
DispatcherTimer timer = new DispatcherTimer();
|
DispatcherTimer timer = new DispatcherTimer();
|
||||||
timer = new DispatcherTimer();
|
timer = new DispatcherTimer();
|
||||||
@ -56,6 +51,5 @@ public partial class HomeViewModel : ObservableObject
|
|||||||
{
|
{
|
||||||
Stack1 = _runtime.Stack1;
|
Stack1 = _runtime.Stack1;
|
||||||
Stack2 = _runtime.Stack2;
|
Stack2 = _runtime.Stack2;
|
||||||
PackLineOption = _runtime.PackLineOption;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,12 +173,11 @@
|
|||||||
Foreground="White"
|
Foreground="White"
|
||||||
ItemsSource="{Binding ViewModel.YarnCarTypes}" />
|
ItemsSource="{Binding ViewModel.YarnCarTypes}" />
|
||||||
<TextBlock VerticalAlignment="Center" Margin="10"
|
<TextBlock VerticalAlignment="Center" Margin="10"
|
||||||
Foreground="White" Grid.Row="2" Grid.Column="0" Text="纱车正反面:" />
|
Foreground="White" Grid.Row="2" Grid.Column="0" Text="码垛层数:" />
|
||||||
<ComboBox x:Name="YarnSideComboBox" Grid.Column="1" Margin="10" Grid.Row="2"
|
<TextBox Grid.Column="1" Margin="10" Grid.Row="2" IsEnabled="False"
|
||||||
HorizontalAlignment="Stretch"
|
TextAlignment="Right"
|
||||||
HorizontalContentAlignment="Right"
|
|
||||||
Foreground="White"
|
Foreground="White"
|
||||||
ItemsSource="{Binding ViewModel.YarnCarSide}" />
|
Text="{Binding ViewModel.SelectedVariety.StackingLayers}" />
|
||||||
<TextBlock VerticalAlignment="Center" Margin="10"
|
<TextBlock VerticalAlignment="Center" Margin="10"
|
||||||
Foreground="White" Grid.Row="3" Grid.Column="0" Text="总数:" />
|
Foreground="White" Grid.Row="3" Grid.Column="0" Text="总数:" />
|
||||||
<TextBox Grid.Column="1" Margin="10" Grid.Row="3" IsEnabled="False"
|
<TextBox Grid.Column="1" Margin="10" Grid.Row="3" IsEnabled="False"
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using MaterialDesignThemes.Wpf;
|
using MaterialDesignThemes.Wpf;
|
||||||
using Seyounth.Hyosung.Data.Models;
|
using Seyounth.Hyosung.Data.Models;
|
||||||
using Seyounth.Hyosung.Data.Services;
|
|
||||||
using Seyounth.Hyosung.Data.Services.Hyosung;
|
using Seyounth.Hyosung.Data.Services.Hyosung;
|
||||||
using Seyounth.Hyosung.Runtime;
|
using Seyounth.Hyosung.Runtime;
|
||||||
using Seyounth.Hyosung.ViewModels;
|
using Seyounth.Hyosung.ViewModels;
|
||||||
@ -20,10 +19,7 @@ namespace Seyounth.Hyosung.Views.Pages
|
|||||||
|
|
||||||
private readonly IHyosungWmsService _wmsService;
|
private readonly IHyosungWmsService _wmsService;
|
||||||
|
|
||||||
public HomeViewPage(HomeViewModel viewModel,
|
public HomeViewPage(HomeViewModel viewModel, IHyosungRuntime runtime, IHyosungWmsService wmsService)
|
||||||
IHyosungRuntime runtime,
|
|
||||||
IHyosungWmsService wmsService,
|
|
||||||
IVarietyService varietyService)
|
|
||||||
{
|
{
|
||||||
_wmsService = wmsService;
|
_wmsService = wmsService;
|
||||||
_runtime = runtime;
|
_runtime = runtime;
|
||||||
@ -45,7 +41,7 @@ namespace Seyounth.Hyosung.Views.Pages
|
|||||||
ButtonProgressAssist.SetIsIndicatorVisible(ChangeVarietyButton, true);
|
ButtonProgressAssist.SetIsIndicatorVisible(ChangeVarietyButton, true);
|
||||||
ChangeVarietyButton.IsEnabled = false;
|
ChangeVarietyButton.IsEnabled = false;
|
||||||
|
|
||||||
variety.YarnCarSide = YarnSideComboBox.SelectedIndex+1;
|
variety.YarnCarSide = 1;
|
||||||
variety.YarnCarType = YarnCarTypeComboBox.SelectedIndex + 1;
|
variety.YarnCarType = YarnCarTypeComboBox.SelectedIndex + 1;
|
||||||
_runtime.SendVarietyToPlcAsync(variety)
|
_runtime.SendVarietyToPlcAsync(variety)
|
||||||
.ContinueWith(task =>
|
.ContinueWith(task =>
|
||||||
@ -71,11 +67,7 @@ namespace Seyounth.Hyosung.Views.Pages
|
|||||||
{
|
{
|
||||||
var variety = selectedItem as Variety;
|
var variety = selectedItem as Variety;
|
||||||
var info = await _wmsService.GetItemInfoByItemCode(variety.Code);
|
var info = await _wmsService.GetItemInfoByItemCode(variety.Code);
|
||||||
int? controlNo;
|
var controlNo = await _wmsService.GetControlNo(variety, info.GRADE);
|
||||||
if (variety.LastNo is null || variety.LastNo == 0)
|
|
||||||
controlNo = await _wmsService.GetControlNo(variety, info.GRADE);
|
|
||||||
else
|
|
||||||
controlNo = variety.LastNo + 1;
|
|
||||||
await Dispatcher.InvokeAsync(() =>
|
await Dispatcher.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
ControlNoTextBlock.Text = $"控制号: {controlNo}";
|
ControlNoTextBlock.Text = $"控制号: {controlNo}";
|
||||||
|
|||||||
391
更新打印部分代码.patch
391
更新打印部分代码.patch
@ -1,391 +0,0 @@
|
|||||||
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<int, Task>? 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);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 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<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")
|
|
||||||
+ {
|
|
||||||
+ 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<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 @@
|
|
||||||
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 @@
|
|
||||||
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" />
|
|
||||||
<GridViewColumn
|
|
||||||
+ DisplayMemberBinding="{Binding ScanTime}"
|
|
||||||
+ Header="扫码时间" />
|
|
||||||
+ <GridViewColumn
|
|
||||||
DisplayMemberBinding="{Binding StackTime}"
|
|
||||||
Header="码垛时间" />
|
|
||||||
</GridView>
|
|
||||||
@@ -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" />
|
|
||||||
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">
|
|
||||||
<DataGrid.Columns>
|
|
||||||
391
更新打印部分代码1.patch
391
更新打印部分代码1.patch
@ -1,391 +0,0 @@
|
|||||||
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<int, Task>? 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);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 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<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")
|
|
||||||
+ {
|
|
||||||
+ 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<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 @@
|
|
||||||
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 @@
|
|
||||||
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" />
|
|
||||||
<GridViewColumn
|
|
||||||
+ DisplayMemberBinding="{Binding ScanTime}"
|
|
||||||
+ Header="扫码时间" />
|
|
||||||
+ <GridViewColumn
|
|
||||||
DisplayMemberBinding="{Binding StackTime}"
|
|
||||||
Header="码垛时间" />
|
|
||||||
</GridView>
|
|
||||||
@@ -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" />
|
|
||||||
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">
|
|
||||||
<DataGrid.Columns>
|
|
||||||
Loading…
x
Reference in New Issue
Block a user