diff --git a/StockMan.CORE/Components/LocationDX.razor b/StockMan.CORE/Components/LocationDX.razor
index 9178113..dbf192d 100644
--- a/StockMan.CORE/Components/LocationDX.razor
+++ b/StockMan.CORE/Components/LocationDX.razor
@@ -1,33 +1,55 @@
- @if (listItemByLoc != null)
- {
+@if (listItemByLoc != null)
+{
+
+
+}
\ No newline at end of file
diff --git a/StockMan.CORE/Components/LocationDX.razor.cs b/StockMan.CORE/Components/LocationDX.razor.cs
index b617aa9..8388213 100644
--- a/StockMan.CORE/Components/LocationDX.razor.cs
+++ b/StockMan.CORE/Components/LocationDX.razor.cs
@@ -27,11 +27,22 @@ namespace StockMan.CORE.Components
public string locSX_ID { get; set; } = "";
[Parameter]
public string locDX_ID { get; set; } = "";
+ [Parameter]
+ public List
? ListLocationByType { get; set; } = null;
[Inject]
protected StockDataService SDService { get; set; } = null!;
public List? listItemByLoc { get; set; } = null;
-
+ //protected string _id { get; set; } = "";
+ protected string id
+ {
+ get => locDX_ID;
+ set
+ {
+ locDX_ID = value;
+ ReloadData();
+ }
+ }
//protected string rawCode
//{
@@ -49,7 +60,12 @@ namespace StockMan.CORE.Components
//}
protected override async Task OnParametersSetAsync()
{
- listItemByLoc = await SDService.ItemsGetByLocation(locDX_ID);
+ await ReloadData();
+ }
+
+ protected async Task ReloadData()
+ {
+ listItemByLoc = await SDService.ItemsGetByLocation(id);
}
}
diff --git a/StockMan.CORE/Components/LocationSX.razor b/StockMan.CORE/Components/LocationSX.razor
index b3c0e79..430467f 100644
--- a/StockMan.CORE/Components/LocationSX.razor
+++ b/StockMan.CORE/Components/LocationSX.razor
@@ -1,33 +1,72 @@
@if (listItemByLoc != null)
{
+
+
}
\ No newline at end of file
diff --git a/StockMan.CORE/Components/LocationSX.razor.cs b/StockMan.CORE/Components/LocationSX.razor.cs
index 9c3c86c..7315cc5 100644
--- a/StockMan.CORE/Components/LocationSX.razor.cs
+++ b/StockMan.CORE/Components/LocationSX.razor.cs
@@ -29,9 +29,25 @@ namespace StockMan.CORE.Components
public string locDX_ID { get; set; } = "";
[Inject]
protected StockDataService SDService { get; set; } = null!;
- public List
? listItemByLoc { get; set; } = null;
-
+ [Inject]
+ protected NavigationManager NavManager { get; set; } = null!;
+ protected List? listItemByLoc { get; set; } = null;
+ [Parameter]
+ public List? ListLocationByType { get; set; } = null;
+ [Parameter]
+ public string UserName { get; set; } = "";
+ public ItemStockModel? currItem { get; set; } = null;
+ public int qty { get; set; } = 0;
+ protected string id
+ {
+ get => locSX_ID;
+ set
+ {
+ locSX_ID = value;
+ ReloadData();
+ }
+ }
//protected string rawCode
//{
@@ -49,8 +65,37 @@ namespace StockMan.CORE.Components
//}
protected override async Task OnParametersSetAsync()
{
- listItemByLoc = await SDService.ItemsGetByLocation(locSX_ID);
+ await ReloadData();
}
+ protected async Task ReloadData()
+ {
+ listItemByLoc = await SDService.ItemsGetByLocation(locSX_ID);
+ }
+ protected async Task Move()
+ {
+ bool done = false;
+ if (currItem != null)
+ {
+ if (qty != currItem.QtyConf)
+ {
+ done = await SDService.MoveItems_New(currItem.Id, locSX_ID, locDX_ID, UserName, qty);
+ }
+ else
+ {
+ done = await SDService.MoveItems(currItem.Id, locSX_ID, locDX_ID, UserName);
+ }
+ }
+ if (done)
+ {
+ NavManager.NavigateTo(NavManager.Uri);
+ }
+ }
+ protected async Task SetMove(ItemStockModel item)
+ {
+ await Task.Delay(1);
+ currItem = item;
+ qty = item.QtyConf;
+ }
}
}
\ No newline at end of file
diff --git a/StockMan.CORE/Data/StockDataService.cs b/StockMan.CORE/Data/StockDataService.cs
index cafb352..10d5f15 100644
--- a/StockMan.CORE/Data/StockDataService.cs
+++ b/StockMan.CORE/Data/StockDataService.cs
@@ -410,6 +410,30 @@ namespace StockMan.CORE.Data
Log.Debug($"EliminaDup Read from {source}: {ts.TotalMilliseconds}ms");
return result;
}
+ public async Task MoveItems(int stockId, string locationIdFrom, string locationIdTo, string oprId)
+ {
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ bool result = false;
+ string source = "DB";
+ result = await dbController.MoveItems(stockId, locationIdFrom, locationIdTo, oprId);
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"MoveItems Read from {source}: {ts.TotalMilliseconds}ms");
+ return result;
+ }
+ public async Task MoveItems_New(int stockId, string locationIdFrom, string locationIdTo, string oprId, int qtyMov)
+ {
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ bool result = false;
+ string source = "DB";
+ result = await dbController.MoveItems_New(stockId, locationIdFrom, locationIdTo, oprId, qtyMov);
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"MoveItems_New Read from {source}: {ts.TotalMilliseconds}ms");
+ return result;
+ }
///
/// Lista Articoli da ricerca
@@ -495,6 +519,46 @@ namespace StockMan.CORE.Data
/// Lista Location
///
///
+ public async Task> LocationGetLocType()
+ {
+ string source = "DB";
+ List? dbResult = new List();
+ string currKey = $"{rKeyLocType}: *";
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ string? rawData = await redisDb.StringGetAsync(currKey);
+ if (!string.IsNullOrEmpty(rawData))
+ {
+ source = "REDIS";
+ var tempResult = JsonConvert.DeserializeObject>(rawData);
+ if (tempResult == null)
+ {
+ dbResult = new List();
+ }
+ else
+ {
+ dbResult = tempResult;
+ }
+ }
+ else
+ {
+ dbResult = dbController.LocationGetLocType();
+ rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
+ await redisDb.StringSetAsync(currKey, rawData, LongCache);
+ }
+ if (dbResult == null)
+ {
+ dbResult = new List();
+ }
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"LocationGetLocType | {source} in: {ts.TotalMilliseconds} ms");
+ return dbResult;
+ }
+ ///
+ /// Lista Location
+ ///
+ ///
public async Task> StockStatus()
{
string source = "DB";
diff --git a/StockMan.CORE/Pages/StatoMag.razor b/StockMan.CORE/Pages/StatoMag.razor
index 655fa02..29bd983 100644
--- a/StockMan.CORE/Pages/StatoMag.razor
+++ b/StockMan.CORE/Pages/StatoMag.razor
@@ -7,11 +7,16 @@
{
}
+else
+{
+
+}
-
-
+
+
-
diff --git a/StockMan.CORE/Pages/StatoMag.razor.cs b/StockMan.CORE/Pages/StatoMag.razor.cs
index 6ea1674..e6123f0 100644
--- a/StockMan.CORE/Pages/StatoMag.razor.cs
+++ b/StockMan.CORE/Pages/StatoMag.razor.cs
@@ -23,8 +23,12 @@ namespace StockMan.CORE.Pages
{
public partial class StatoMag
{
+ [Inject]
+ protected StockDataService SDService { get; set; } = null!;
protected string currLocId_SX { get; set; } = "";
protected string currLocId_DX { get; set; } = "";
+ public List
? listLocationByType { get; set; } = null;
+ protected OperatorModel currOpr { get; set; } = new OperatorModel();
protected async Task catchCurrLocId_SX(string locId)
{
@@ -36,5 +40,24 @@ namespace StockMan.CORE.Pages
await Task.Delay(1);
currLocId_DX = locId;
}
+ protected async Task resetIds()
+ {
+ await Task.Delay(1);
+ currLocId_DX = "";
+ currLocId_SX = "";
+ }
+
+ protected override async Task OnInitializedAsync()
+ {
+ listLocationByType = await SDService.LocationGetLocType();
+ currOpr = await SDService.OperatorsGetByCodExt(userName);
+ }
+
+ [Inject]
+ protected MessageService MService { get; set; } = null!;
+ protected string userName
+ {
+ get => MService.newUserName;
+ }
}
}
\ No newline at end of file
diff --git a/StockMan.Data/Controllers/StoManController.cs b/StockMan.Data/Controllers/StoManController.cs
index f4d4518..5117b08 100644
--- a/StockMan.Data/Controllers/StoManController.cs
+++ b/StockMan.Data/Controllers/StoManController.cs
@@ -620,6 +620,24 @@ namespace StockMan.Data.Controllers
}
return dbResult;
}
+ ///
+ /// Lista Locazioni join con tabella location type
+ ///
+ ///
+ public List LocationGetLocType()
+ {
+ List dbResult = new List();
+ using (StockManContext localDbCtx = new StockManContext(_configuration))
+ {
+ dbResult = localDbCtx
+ .DbSetLocation
+ .Include(l=>l.LocTypeNav)
+ .Where(x=>x.LocTypeNav.IsStock)
+ .OrderBy(x => x.Id)
+ .ToList();
+ }
+ return dbResult;
+ }
///
/// Lista Tipi Locazioni
@@ -728,7 +746,7 @@ namespace StockMan.Data.Controllers
{
var ItemID = new SqlParameter("@ItemID", itemID);
- var callResulr = await dbCtx
+ var callResult = await dbCtx
.Database
.ExecuteSqlRawAsync("exec dbo.stp_ItemConsolidate @ItemID", ItemID);
@@ -748,7 +766,7 @@ namespace StockMan.Data.Controllers
{
var ItemID = new SqlParameter("@ItemID", itemID);
- var callResulr = await dbCtx
+ var callResult = await dbCtx
.Database
.ExecuteSqlRawAsync("exec dbo.stp_ItemShrinkHist @ItemID", ItemID);
@@ -756,6 +774,51 @@ namespace StockMan.Data.Controllers
}
return answ;
}
+ ///
+ /// Muove gli items nei vari scaffali
+ ///
+ ///
+ public async Task MoveItems(int stockId, string locationIdFrom, string locationIdTo, string oprId)
+ {
+ bool answ = false;
+ using (var dbCtx = new StockManContext(_configuration))
+ {
+ var StockId = new SqlParameter("@StockID", stockId);
+ var LocationIdFrom = new SqlParameter("@LocationID_FROM", locationIdFrom);
+ var LocationIdTo = new SqlParameter("@LocationID_TO", locationIdTo);
+ var OprId = new SqlParameter("@OperatorID", oprId);
+
+ var callResult = await dbCtx
+ .Database
+ .ExecuteSqlRawAsync("exec dbo.stp_ItemStockMove @StockID, @LocationID_FROM, @LocationID_TO, @OperatorID", StockId, LocationIdFrom, LocationIdTo, OprId);
+
+ answ = true;
+ }
+ return answ;
+ }
+ ///
+ /// Muove gli items nei vari scaffali
+ ///
+ ///
+ public async Task MoveItems_New(int stockId, string locationIdFrom, string locationIdTo, string oprId, int qtyMov)
+ {
+ bool answ = false;
+ using (var dbCtx = new StockManContext(_configuration))
+ {
+ var StockId = new SqlParameter("@StockID", stockId);
+ var LocationIdFrom = new SqlParameter("@LocationID_FROM", locationIdFrom);
+ var LocationIdTo = new SqlParameter("@LocationID_TO", locationIdTo);
+ var OprId = new SqlParameter("@OperatorID", oprId);
+ var QtyMov = new SqlParameter("@QtyMov", qtyMov);
+
+ var callResult = await dbCtx
+ .Database
+ .ExecuteSqlRawAsync("exec stp_ItemStockMove_New @StockID, @LocationID_FROM, @LocationID_TO, @OperatorID, @QtyMov", StockId, LocationIdFrom, LocationIdTo, OprId, QtyMov);
+
+ answ = true;
+ }
+ return answ;
+ }
#endregion Public Methods
diff --git a/StockMan.Data/DbModels/LocTypeModel.cs b/StockMan.Data/DbModels/LocTypeModel.cs
index 600afb5..13dd05c 100644
--- a/StockMan.Data/DbModels/LocTypeModel.cs
+++ b/StockMan.Data/DbModels/LocTypeModel.cs
@@ -22,5 +22,6 @@ namespace StockMan.Data.DbModels
public bool IsFor { get; set; }
public virtual ICollection Locations { get; set; }
+
}
}
diff --git a/StockMan.Data/DbModels/LocationModel.cs b/StockMan.Data/DbModels/LocationModel.cs
index 3967f0d..798b00b 100644
--- a/StockMan.Data/DbModels/LocationModel.cs
+++ b/StockMan.Data/DbModels/LocationModel.cs
@@ -20,8 +20,8 @@ namespace StockMan.Data.DbModels
public string Id { get; set; } = null!;
public string Descr { get; set; } = null!;
public string LocTypeId { get; set; } = null!;
-
- public virtual LocTypeModel LocType { get; set; } = null!;
+ [ForeignKey("LocTypeId")]
+ public virtual LocTypeModel LocTypeNav { get; set; } = null!;
public virtual ICollection ItemFluxExtLocations { get; set; }
public virtual ICollection ItemFluxLocations { get; set; }
public virtual ICollection ItemStocks { get; set; }
diff --git a/StockMan.Data/StockManContext.cs b/StockMan.Data/StockManContext.cs
index 1f9da31..652f51f 100644
--- a/StockMan.Data/StockManContext.cs
+++ b/StockMan.Data/StockManContext.cs
@@ -300,7 +300,7 @@ namespace StockMan.Data
.HasColumnName("LocTypeID")
.HasDefaultValueSql("('')");
- entity.HasOne(d => d.LocType)
+ entity.HasOne(d => d.LocTypeNav)
.WithMany(p => p.Locations)
.HasForeignKey(d => d.LocTypeId)
.OnDelete(DeleteBehavior.ClientSetNull)