scambio oggetti tra scaffali

This commit is contained in:
zaccaria.majid
2023-02-27 16:51:41 +01:00
parent 020792d7f4
commit 53bcb3d5f6
11 changed files with 350 additions and 72 deletions
+53 -31
View File
@@ -1,33 +1,55 @@
@if (listItemByLoc != null)
{
@if (listItemByLoc != null)
{
<div class="card">
<div class="card-header bg-success text-light d-flex justify-content-between">
<div class="py-2">
SPOSTARE VERSO:
</div>
<div>
<select class="form-select" @bind="@id">
<option value=" ">--Selezionare una locazione--</option>
@if (ListLocationByType != null)
{
<table class="table table-striped table-bordered small">
<thead>
<tr class="">
<th></th>
<th>Descr. Articolo</th>
<th>Giacenza</th>
<th>Valore Unit.</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in listItemByLoc)
{
<tr>
<td></td>
<td>
@item.ItemNav.Descr
</td>
<td>
@item.QtyConf
</td>
<td>
@($"{item.ItemNav.CurrValue:C2}")
</td>
<td></td>
@foreach (var item in ListLocationByType)
{
<option value="@item.Id">@item.Descr</option>
}
}
</select>
</div>
<div>&nbsp;</div>
</div>
<div class="card-body">
<table class="table table-striped table-bordered small">
<thead>
<tr class="">
<th></th>
<th>Descr. Articolo</th>
<th>Giacenza</th>
<th>Valore Unit.</th>
<th></th>
</tr>
}
</tbody>
</table>
}
</thead>
<tbody>
@foreach (var item in listItemByLoc)
{
<tr>
<td></td>
<td>
@item.ItemNav.Descr
</td>
<td>
@item.QtyConf
</td>
<td>
@($"{item.ItemNav.CurrValue:C2}")
</td>
<td></td>
</tr>
}
</tbody>
</table>
</div>
</div>
}
+18 -2
View File
@@ -27,11 +27,22 @@ namespace StockMan.CORE.Components
public string locSX_ID { get; set; } = "";
[Parameter]
public string locDX_ID { get; set; } = "";
[Parameter]
public List<LocationModel>? ListLocationByType { get; set; } = null;
[Inject]
protected StockDataService SDService { get; set; } = null!;
public List<ItemStockModel>? 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);
}
}
+66 -27
View File
@@ -1,33 +1,72 @@
@if (listItemByLoc != null)
{
<div class="card">
<div class="card-header bg-primary text-light d-flex justify-content-between">
<div class="py-2">
SPOSTARE DA:
</div>
<div>
<select class="form-select" @bind="@id">
<option value="">--Selezionare una locazione--</option>
@if (ListLocationByType != null)
{
<table class="table table-striped table-bordered small">
<thead>
<tr class="">
<th></th>
<th>Descr. Articolo</th>
<th>Giacenza</th>
<th>Valore Unit.</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in listItemByLoc)
@foreach (var item in ListLocationByType)
{
<option value="@item.Id">@item.Descr</option>
}
}
</select>
</div>
<div><button class="btn btn-sm bg-warning py-2"> Scambia <i class="fa-solid fa-arrow-right-arrow-left"></i> </button></div>
</div>
<div class="card-body">
@if (currItem != null)
{
<tr>
<td></td>
<td>
@item.ItemNav.Descr
</td>
<td>
@item.QtyConf
</td>
<td>
@($"{item.ItemNav.CurrValue:C2}")
</td>
<td></td>
</tr>
<div class="d-flex justify-content-between">
<div>
confermare di voler trasferire
</div>
<div>
<input class="form-input" @bind="@qty" />
</div>
<div>
<button class="btn btn-sm btn-success" @onclick="()=>Move()">Conferma</button>
</div>
<div>
<button class="btn btn-sm btn-danger">Annulla</button>
</div>
</div>
}
</tbody>
</table>
<table class="table table-striped table-bordered small">
<thead>
<tr class="">
<th></th>
<th>Descr. Articolo</th>
<th>Giacenza</th>
<th>Valore Unit.</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in listItemByLoc)
{
<tr>
<td></td>
<td>
@item.ItemNav.Descr
</td>
<td>
@item.QtyConf
</td>
<td>
@($"{item.ItemNav.CurrValue:C2}")
</td>
<td><button class="btn btn-sm btn-info" @onclick="()=>SetMove(item)">Sposta<i class="fa-solid fa-arrow-right"></i></button></td>
</tr>
}
</tbody>
</table>
</div>
</div>
}
+48 -3
View File
@@ -29,9 +29,25 @@ namespace StockMan.CORE.Components
public string locDX_ID { get; set; } = "";
[Inject]
protected StockDataService SDService { get; set; } = null!;
public List<ItemStockModel>? listItemByLoc { get; set; } = null;
[Inject]
protected NavigationManager NavManager { get; set; } = null!;
protected List<ItemStockModel>? listItemByLoc { get; set; } = null;
[Parameter]
public List<LocationModel>? 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;
}
}
}
+64
View File
@@ -410,6 +410,30 @@ namespace StockMan.CORE.Data
Log.Debug($"EliminaDup Read from {source}: {ts.TotalMilliseconds}ms");
return result;
}
public async Task<bool> 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<bool> 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;
}
/// <summary>
/// Lista Articoli da ricerca
@@ -495,6 +519,46 @@ namespace StockMan.CORE.Data
/// Lista Location
/// </summary>
/// <returns></returns>
public async Task<List<LocationModel>> LocationGetLocType()
{
string source = "DB";
List<LocationModel>? dbResult = new List<LocationModel>();
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<List<LocationModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<LocationModel>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbController.LocationGetLocType();
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, LongCache);
}
if (dbResult == null)
{
dbResult = new List<LocationModel>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"LocationGetLocType | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
/// <summary>
/// Lista Location
/// </summary>
/// <returns></returns>
public async Task<List<VLocationValModel>> StockStatus()
{
string source = "DB";
+9 -4
View File
@@ -7,11 +7,16 @@
{
<ValStockGiac LocId_SX="catchCurrLocId_SX" LocId_DX="catchCurrLocId_DX"></ValStockGiac>
}
else
{
<button class="btn btn-danger mb-2" @onclick="()=>resetIds()">RESET</button>
}
<div class="row">
<div class="col">
<LocationSX locSX_ID="@currLocId_SX" locDX_ID="@currLocId_DX"></LocationSX>
<div class="col-5">
<LocationSX UserName="@currOpr.Id" locSX_ID="@currLocId_SX" locDX_ID="@currLocId_DX" ListLocationByType="@listLocationByType"></LocationSX>
</div>
<div class="col">
<LocationDX locDX_ID="@currLocId_DX" locSX_ID="@currLocId_SX"></LocationDX>
<div class="col-1"><button class="btn btn-sm bg-warning py-2"> Scambia <i class="fa-solid fa-arrow-right-arrow-left"></i> </button></div>
<div class="col-5">
<LocationDX locDX_ID="@currLocId_DX" locSX_ID="@currLocId_SX" ListLocationByType="@listLocationByType"></LocationDX>
</div>
</div>
+23
View File
@@ -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<LocationModel>? 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;
}
}
}
+65 -2
View File
@@ -620,6 +620,24 @@ namespace StockMan.Data.Controllers
}
return dbResult;
}
/// <summary>
/// Lista Locazioni join con tabella location type
/// </summary>
/// <returns></returns>
public List<LocationModel> LocationGetLocType()
{
List<LocationModel> dbResult = new List<LocationModel>();
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;
}
/// <summary>
/// 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;
}
/// <summary>
/// Muove gli items nei vari scaffali
/// </summary>
/// <returns></returns>
public async Task<bool> 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;
}
/// <summary>
/// Muove gli items nei vari scaffali
/// </summary>
/// <returns></returns>
public async Task<bool> 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
+1
View File
@@ -22,5 +22,6 @@ namespace StockMan.Data.DbModels
public bool IsFor { get; set; }
public virtual ICollection<LocationModel> Locations { get; set; }
}
}
+2 -2
View File
@@ -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<ItemFluxModel> ItemFluxExtLocations { get; set; }
public virtual ICollection<ItemFluxModel> ItemFluxLocations { get; set; }
public virtual ICollection<ItemStockModel> ItemStocks { get; set; }
+1 -1
View File
@@ -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)