From 3d567646305a4e577a4456edb2985dafabacb932 Mon Sep 17 00:00:00 2001 From: taoleite Date: Wed, 25 Jun 2025 16:52:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Estorage=20main=20model=20?= =?UTF-8?q?=E7=BC=96=E5=86=99bysku=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controllers/OutputRequestController.cs | 31 ++++++++- Data/MichelinDbContext.cs | 3 + Entities/STORAGE_MAIN.cs | 51 ++++++++++++++ .../Implement/StorageMainRepository.cs | 68 +++++++++++++++++++ .../Interface/IStorageMainRepository.cs | 11 +++ 5 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 Entities/STORAGE_MAIN.cs create mode 100644 Repositories/Implement/StorageMainRepository.cs create mode 100644 Repositories/Interface/IStorageMainRepository.cs diff --git a/Controllers/OutputRequestController.cs b/Controllers/OutputRequestController.cs index b29594d..4d22cb5 100644 --- a/Controllers/OutputRequestController.cs +++ b/Controllers/OutputRequestController.cs @@ -20,6 +20,7 @@ namespace WMS_GIRAF_Interface.Controllers IProductInformationRepository productInformationRepository, IIoControlRepository ioControlRepository, IIoControlRouteRepository ioControlRouteRepository, + IStorageMainRepository storageMainRepository, CellLogicService cellLogicService) : ControllerBase { @@ -198,6 +199,15 @@ namespace WMS_GIRAF_Interface.Controllers //无需筛选巷道状态,直接选择可用轮胎,只需考虑availableEvacuationPosts即可,筛选lane_way #region outlevel 4/3/2/1 + string temp = $@"SELECT TOP 1 STORAGE_ID FROM V_STORAGE_LIST + WHERE RUN_STATUS = 'Enable' + AND (requestNumber IS NULL OR requestNumber = '') + AND IsBlocked = {(outputRequest.productIsBlocked ? 1 : 0)} + AND LOTNUMBER = '{outputRequest.sku}' + AND PopulationNumber = '{outputRequest.productClass}' + AND Lane_way IN ({string.Join(",", outputRequest.availableEvacuationPosts)}) + ORDER BY OutLevel DESC , HdvDateTimeInUtc"; + var checkHighPriorityTire = context.V_StorageList.FromSqlRaw( $@"SELECT TOP 1 STORAGE_ID FROM V_STORAGE_LIST WHERE RUN_STATUS = 'Enable' @@ -205,7 +215,26 @@ namespace WMS_GIRAF_Interface.Controllers AND IsBlocked = {(outputRequest.productIsBlocked ? 1 : 0)} AND LOTNUMBER = '{outputRequest.sku}' AND PopulationNumber = '{outputRequest.productClass}' - AND Lane_way IN({string.Join(",",outputRequest.availableEvacuationPosts)})"); + AND Lane_way IN ({string.Join(",",outputRequest.availableEvacuationPosts)}) + ORDER BY OutLevel DESC , HdvDateTimeInUtc").ToList(); + + if (checkHighPriorityTire.Count > 0) + { + //选择当前的可用的轮胎,更新需求号 + var storageId = checkHighPriorityTire[0].STORAGE_ID; + if (storageId != 0 && storageId !=null) + { + var getStorageMain = storageMainRepository.GetStorageMain("StorageId", storageId.ToString()); + } + + + + + } + else + { + + } #endregion diff --git a/Data/MichelinDbContext.cs b/Data/MichelinDbContext.cs index a7f6a4f..5b9d4ed 100644 --- a/Data/MichelinDbContext.cs +++ b/Data/MichelinDbContext.cs @@ -22,6 +22,9 @@ public class MichelinDbContext : DbContext public DbSet ProductInformation { get; set; } + public DbSet Storage_Main { get; set; } + + //视图类声明 public virtual DbSet V_ManageInCount { get; set; } public virtual DbSet V_WhCellEnable { get; set; } diff --git a/Entities/STORAGE_MAIN.cs b/Entities/STORAGE_MAIN.cs new file mode 100644 index 0000000..5cf1c3d --- /dev/null +++ b/Entities/STORAGE_MAIN.cs @@ -0,0 +1,51 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace WMS_GIRAF_Interface.Entities; + +[Table("STORAGE_MAIN")] +public class STORAGE_MAIN +{ + [Column("STORAGE_ID")] + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int? STORAGE_ID { get; set; } + + [Column("CELL_ID")] + public int? CELL_ID { get; set; } + + [Column("STOCK_BARCODE")] + public string? STOCK_BARCODE { get; set; } + + [Column("CELL_MODEL")] + public string? CELL_MODEL { get; set; } + [Column("LOTNUMBER")] + public string? LOTNUMBER { get; set; } + [Column("PopulationNumber")] + public string? PopulationNumber { get; set; } + [Column("FabricationDateTimeInUtc")] + public string? FabricationDateTimeInUtc { get; set; } + [Column("DryDateTimeInUtc")] + public string? DryDateTimeInUtc { get; set; } + [Column("OldDateTimeInUtc")] + public string? OldDateTimeInUtc { get; set; } + [Column("HdvDateTimeInUtc")] + public string? HdvDateTimeInUtc { get; set; } + [Column("IsPriority")] + public bool? IsPriority { get; set; } + [Column("IsBlocked")] + public bool? IsBlocked { get; set; } + [Column("STORAGE_LIST_QUANTITY")] + public int? STORAGE_LIST_QUANTITY { get; set; } = 1; + [Column("EntryTime")] + public string? EntryTime { get; set; } + [Column("STORAGE_REMARK")] + public string? STORAGE_REMARK { get; set; } + [Column("GOODS_ID")] + public int? GOODS_ID { get; set; } + [Column("requestNumber")] + public string? requestNumber { get; set; } + + + +} \ No newline at end of file diff --git a/Repositories/Implement/StorageMainRepository.cs b/Repositories/Implement/StorageMainRepository.cs new file mode 100644 index 0000000..7b5131a --- /dev/null +++ b/Repositories/Implement/StorageMainRepository.cs @@ -0,0 +1,68 @@ +using Serilog; +using WMS_GIRAF_Interface.Data; +using WMS_GIRAF_Interface.Entities; +using WMS_GIRAF_Interface.Repositories.Interface; + + +namespace WMS_GIRAF_Interface.Repositories.Implement; + +public class StorageMainRepository:IStorageMainRepository +{ + private readonly MichelinDbContext _context; + + /// + /// 构造函数 + /// + /// + public StorageMainRepository(MichelinDbContext context) + { + _context = context; + } + + public STORAGE_MAIN? GetStorageMain(string type, string filterInfo) + { + STORAGE_MAIN? storageMain = type switch + { + "barcode" => _context.Storage_Main.FirstOrDefault(x => x.STOCK_BARCODE == filterInfo), + "storageId" => _context.Storage_Main.FirstOrDefault(x => x.STORAGE_ID == Convert.ToInt32(filterInfo)), + "requestNumber" => _context.Storage_Main.FirstOrDefault(x => x.requestNumber == filterInfo), + _ => _context.Storage_Main.FirstOrDefault(x => x.STOCK_BARCODE == filterInfo) + }; + + return storageMain; + } + public bool UpdateStorageMain(STORAGE_MAIN storageMain) + { + if (storageMain == null || storageMain.STORAGE_ID == 0) + { + throw new ArgumentNullException(nameof(UpdateStorageMain)); + } + _context.Storage_Main.Update(storageMain); + Log.Information($"Update storage main info({storageMain.STOCK_BARCODE});"); + _context.SaveChanges(); + return true; + } + + public bool DeleteStorageMain(STORAGE_MAIN storageMain) + { + if(storageMain == null || storageMain.STORAGE_ID == 0) + { + throw new ArgumentNullException(nameof(DeleteStorageMain)); + } + _context.Storage_Main.Remove(storageMain); + _context.SaveChanges(); + Log.Information($"Deleted storage main info({storageMain.STOCK_BARCODE});"); + return true; + } + public bool AddStorageMain(STORAGE_MAIN storageMain) + { + if (storageMain==null) + { + throw new ArgumentNullException(nameof(AddStorageMain)); + } + _context.Storage_Main.Add(storageMain); + _context.SaveChanges(); + Log.Information($"Add storage main info({storageMain.STOCK_BARCODE});"); + return true; + } +} \ No newline at end of file diff --git a/Repositories/Interface/IStorageMainRepository.cs b/Repositories/Interface/IStorageMainRepository.cs new file mode 100644 index 0000000..5091305 --- /dev/null +++ b/Repositories/Interface/IStorageMainRepository.cs @@ -0,0 +1,11 @@ +using WMS_GIRAF_Interface.Entities; + +namespace WMS_GIRAF_Interface.Repositories.Interface; + +public interface IStorageMainRepository +{ + public STORAGE_MAIN? GetStorageMain(string type, string filterInfo); + public bool AddStorageMain(STORAGE_MAIN storageMain); + public bool UpdateStorageMain(STORAGE_MAIN storageMain); + public bool DeleteStorageMain(STORAGE_MAIN storageMain); +} \ No newline at end of file