diff --git a/Seyounth.Hyosung.Data/Entities/StorageBinEntity.cs b/Seyounth.Hyosung.Data/Entities/StorageBinEntity.cs new file mode 100644 index 0000000..efe6507 --- /dev/null +++ b/Seyounth.Hyosung.Data/Entities/StorageBinEntity.cs @@ -0,0 +1,35 @@ +using SqlSugar; + +namespace Seyounth.Hyosung.Data.Entities; + +public class StorageBinEntity +{ + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + + public string BinName { get; set; } + + + public string LowerBinCode { get; set; } + + [SugarColumn(IsNullable = true)] public string? UpperBinCode { get; set; } + + public bool IsDouble { get; set; } + + public int BinStatus { get; set; } + + public int LowerCtnrCode { get; set; } + + [SugarColumn(IsNullable = true)] + public int UpperCtnrCode { get; set; } + + [SugarColumn(IsNullable = true)] public bool NeedSameLot { get; set; } = false; + + public int BindLot { get; set; } = 0; + + + public int BinPosition { get; set; } + + public int Sort { get; set; } +} \ No newline at end of file diff --git a/Seyounth.Hyosung.Data/Entities/VarietyEntity.cs b/Seyounth.Hyosung.Data/Entities/VarietyEntity.cs index eb09ce4..7764c09 100644 --- a/Seyounth.Hyosung.Data/Entities/VarietyEntity.cs +++ b/Seyounth.Hyosung.Data/Entities/VarietyEntity.cs @@ -93,4 +93,6 @@ public class VarietyEntity [SugarColumn(IsNullable =true)] public double? GrossWeight { get; set; } + [SugarColumn(IsNullable =true)] + public bool NeedSameStack { get; set; } } \ No newline at end of file diff --git a/Seyounth.Hyosung.Data/Models/Variety.cs b/Seyounth.Hyosung.Data/Models/Variety.cs index b4fd677..06eccc8 100644 --- a/Seyounth.Hyosung.Data/Models/Variety.cs +++ b/Seyounth.Hyosung.Data/Models/Variety.cs @@ -70,6 +70,8 @@ public class Variety public double? GrossWeight { get; set; } + public bool NeedSameStack { get; set; } + public static Variety Create(VarietyEntity entity, List pallets) { var variety = new Variety() @@ -101,7 +103,8 @@ public class Variety HasBox = entity.HasBox, LastNo = entity.LastNo, NetWeight = entity.NetWeight, - GrossWeight = entity.GrossWeight + GrossWeight = entity.GrossWeight, + NeedSameStack = entity.NeedSameStack }; if (entity.PaperTrayId != null && entity.PaperTrayId != 0) variety.PaperTray = Pallet.FromEntity(pallets.First(x => x.Id == entity.PaperTrayId)); @@ -141,7 +144,8 @@ public class Variety HasBox = HasBox, LastNo = LastNo, NetWeight = NetWeight, - GrossWeight = GrossWeight + GrossWeight = GrossWeight, + NeedSameStack = NeedSameStack }; return entity; } diff --git a/Seyounth.Hyosung.Data/Services/IStorageBinService.cs b/Seyounth.Hyosung.Data/Services/IStorageBinService.cs new file mode 100644 index 0000000..a3ad800 --- /dev/null +++ b/Seyounth.Hyosung.Data/Services/IStorageBinService.cs @@ -0,0 +1,11 @@ +using Seyounth.Hyosung.Data.Entities; +using Seyounth.Hyosung.Data.Models; + +namespace Seyounth.Hyosung.Data.Services; + +public interface IStorageBinService +{ + Task GetAvailableBin(Tray tray, Variety variety); + + Task BindAsync(StorageBinEntity entity); +} \ No newline at end of file diff --git a/Seyounth.Hyosung.Data/Services/ITrayService.cs b/Seyounth.Hyosung.Data/Services/ITrayService.cs index 078cb98..cccd965 100644 --- a/Seyounth.Hyosung.Data/Services/ITrayService.cs +++ b/Seyounth.Hyosung.Data/Services/ITrayService.cs @@ -29,21 +29,9 @@ public interface ITrayService Task GetIsPacking(); - /// - /// 生成控制号 - /// - /// - /// - Task StorageAsync(string trayCode); - /// - /// 打印托盘 - /// - /// - /// - /// - /// - /// + Task StorageAsync(string trayCode); + Task PrintTrayAsync(string trayCode, MST_ITEM_2240_V itemInfo,Variety variety); Task UpdateHeightAsync(string trayCode, int height); diff --git a/Seyounth.Hyosung.Data/Services/StorageBinService.cs b/Seyounth.Hyosung.Data/Services/StorageBinService.cs new file mode 100644 index 0000000..83f7adf --- /dev/null +++ b/Seyounth.Hyosung.Data/Services/StorageBinService.cs @@ -0,0 +1,66 @@ +using Seyounth.Hyosung.Data.Entities; +using Seyounth.Hyosung.Data.Models; +using Seyounth.Hyosung.Data.Repositories; + +namespace Seyounth.Hyosung.Data.Services; + +public class StorageBinService(IRepository repository) +:IStorageBinService +{ + public async Task GetAvailableBin(Tray tray, Variety variety) + { + StorageBinEntity bin; + var db = repository.CopyNew(); + if (tray.StackHeight >= 180) + { + bin = await db.AsQueryable() + .Where(x => !x.IsDouble && x.BinStatus == 0) + .OrderBy(x => x.Sort).FirstAsync() ?? await db.AsQueryable() + .Where(x => x.BinStatus == 0) + .OrderBy(x => x.Sort).FirstAsync(); + } + else if (variety.NeedSameStack) + { + bin = await db.AsQueryable() + .Where(x => x.BinStatus == 1 && x.IsDouble && x.BindLot == variety.Lot) + .OrderBy(x => x.Sort).FirstAsync() ?? await db.AsQueryable() + .Where(x => x.BinStatus == 0) + .OrderBy(x => x.Sort).FirstAsync(); + } + else + { + bin = await db.AsQueryable() + .Where(x => x.BinStatus == 1 && !x.NeedSameLot) + .OrderBy(x => x.Sort).FirstAsync() ?? await db.AsQueryable() + .Where(x => x.BinStatus == 0) + .OrderBy(x => x.Sort).FirstAsync(); + } + + if (bin.BinName == "B10") + { + await db.AsUpdateable() + .Where(x => x.BinPosition == 2) + .SetColumns(x => x.BinStatus, 0) + .SetColumns(x => x.BindLot, 0) + .SetColumns(x => x.NeedSameLot, false) + .ExecuteCommandAsync(); + } + else if (bin.BinName == "B32") + { + await db.AsUpdateable() + .Where(x => x.BinPosition == 1) + .SetColumns(x => x.BinStatus, 0) + .SetColumns(x => x.BindLot, 0) + .SetColumns(x => x.NeedSameLot, false) + .ExecuteCommandAsync(); + } + + return bin; + } + + + public async Task BindAsync(StorageBinEntity entity) + { + await repository.AsUpdateable(entity).ExecuteCommandAsync(); + } +} \ No newline at end of file diff --git a/Seyounth.Hyosung.Runtime/HyosungRuntime.cs b/Seyounth.Hyosung.Runtime/HyosungRuntime.cs index bd7c972..ed9a4a7 100644 --- a/Seyounth.Hyosung.Runtime/HyosungRuntime.cs +++ b/Seyounth.Hyosung.Runtime/HyosungRuntime.cs @@ -425,7 +425,7 @@ public class HyosungRuntime( 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 hyosungWmsService.AddLabelResult(new LabelResult(tray, variety)); } logger.LogInformation($"plc request print label success");