-
- Aggiungi foto
-
-
- }
+
+
+ Aggiungi foto
+
+
@@ -113,7 +113,8 @@
@foreach (var articolo in Scheda.Articoli)
{
-
+
@articolo.Descrizione
@@ -143,23 +144,23 @@
}
-
-
-
-
-
+
+
+
+
-
-
@@ -187,7 +188,7 @@
@code {
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!;
[Parameter] public required string CodMdep { get; set; }
- [Parameter] public required DateOnly Data { get; set; }
+ [Parameter] public required DateTime Data { get; set; }
[Parameter] public bool IsNew { get; set; }
[Parameter] public Scheda Scheda { get; set; } = new();
@@ -214,7 +215,7 @@
protected override void OnInitialized()
{
Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
-
+
OnScannerService.OnNewScanSuccessful += HandleNewScanSuccessful;
OnScannerService.OnErrorScan += OnErrorScan;
@@ -226,6 +227,8 @@
private void LoadAttached()
{
+ if (Scheda.ImageNames == null) return;
+
FileLoading = true;
StateHasChanged();
@@ -237,7 +240,8 @@
CodMdep = CodMdep,
Data = Data,
Rilevatore = UserSession.User.Username
- }
+ },
+ Scheda.ImageNames
);
await InvokeAsync(() =>
@@ -254,9 +258,40 @@
{
VisibleOverlay = true;
StateHasChanged();
+
+ SaveSchedaResponseDto? apiResponse = null;
+ try
+ {
+ if (!IsView)
+ {
+ apiResponse = await IntegrySteupService.SaveScheda(
+ new SaveRequestDto
+ {
+ LocalIdScheda = Scheda.Id,
+ ActivityTypeId = Scheda.ActivityTypeId,
+ CodJfas = Scheda.CodJfas,
+ CodMdep = CodMdep,
+ DataCreazione = Data,
+ Note = Scheda.Note,
+ PersonaRif = Scheda.Responsabile,
+ Barcodes = Scheda.Articoli.ConvertAll(x => x.Barcode),
+ Scandeza = (ScadenzaEnum)Scheda.Scadenza,
+ ParentActivityId = IsNew ? null : Scheda.Ispezione?.ActivityId
+ }
+ );
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+
+ await ModalHelper.ShowError(Dialog, e.Message);
+ }
- if (IsNew) await NewSave();
- else await Update();
+ if (IsNew) await NewSave(apiResponse);
+ else await Update(apiResponse);
+
+ if (Scheda.ActivityId.IsValorized()) await UploadFile(Scheda.ActivityId!);
await AttachedService.CleanTempStorageAsync();
@@ -268,7 +303,7 @@
MudDialog.Close(Scheda);
}
- private async Task NewSave()
+ private async Task NewSave(SaveSchedaResponseDto? apiResponse)
{
if (!AttachedList.IsNullOrEmpty())
{
@@ -291,10 +326,18 @@
}
}
+ if (apiResponse != null)
+ {
+ await IspezioniService.UpdateActivityIdIspezioneAsync(CodMdep, Data,
+ UserSession.User.Username, apiResponse.ActivityIdIspezione
+ );
+ Scheda.ActivityId = apiResponse.ActivityIdScheda;
+ }
+
await IspezioniService.AddSchedaAsync(CodMdep, Data, UserSession.User.Username, Scheda);
}
- private async Task Update()
+ private async Task Update(SaveSchedaResponseDto? apiResponse)
{
if (!AttachedList.IsNullOrEmpty())
{
@@ -324,7 +367,33 @@
}
}
+ Scheda.ActivityId = apiResponse?.ActivityIdScheda;
await IspezioniService.UpdateSchedaAsync(Scheda);
+
+ if (apiResponse != null)
+ await IspezioniService.UpdateActivityIdIspezioneAsync(CodMdep, Data,
+ UserSession.User.Username, apiResponse.ActivityIdIspezione
+ );
+ }
+
+ private async Task UploadFile(string activityId)
+ {
+ if (AttachedList.IsNullOrEmpty()) return;
+
+ var ispezione = new Ispezione
+ {
+ CodMdep = CodMdep,
+ Data = Data,
+ Rilevatore = UserSession.User.Username
+ };
+
+ foreach (var file in AttachedList!.Where(x => x.ToUpload))
+ {
+ if (file.FileBytes == null || file.Name == null) continue;
+
+ await IntegrySteupService.UploadFile(activityId, file.FileBytes, file.Name);
+ await AttachedService.MoveInspectionFileFromToUploadToFinal(ispezione, file.Name);
+ }
}
private async Task Cancel()
@@ -436,6 +505,7 @@
var target = AttachedList![AttachedList.Count - attachedList.Count + i];
target.TempPath = origUrl;
target.ThumbPath = thumbUrl;
+ target.ToUpload = true;
StateHasChanged();
});
}
@@ -456,7 +526,7 @@
Snackbar.Add("Selezionare prima il reparto", Severity.Error);
return;
}
-
+
OnLoading = true;
TextLoading = "Download articoli in griglia";
StateHasChanged();
@@ -477,25 +547,27 @@
}
catch (Exception e)
{
+ Console.WriteLine(e.Message);
+
await InvokeAsync(() =>
{
OnLoading = false;
TextLoading = null;
StateHasChanged();
-
+
OnError(e.Message);
});
-
+
return;
}
-
+
var modal = await ModalHelper.OpenSelectArt(Dialog, articoli);
-
+
await InvokeAsync(() =>
{
OnLoading = false;
TextLoading = null;
-
+
StateHasChanged();
});
@@ -581,17 +653,17 @@
{
OnLoading = false;
StateHasChanged();
-
+
if (art != null)
{
RecalcDirty(true);
-
+
Scheda.Articoli.Add(new SchedaArticolo
{
Barcode = art.Barcode,
Descrizione = art.Descrizione
});
-
+
StateHasChanged();
}
else
@@ -602,12 +674,14 @@
}
catch (Exception e)
{
+ Console.WriteLine(e.Message);
+
await InvokeAsync(() =>
{
OnLoading = false;
StateHasChanged();
});
-
+
OnError(e.Message);
}
}
@@ -627,7 +701,7 @@
{
var index = Scheda.Articoli.FindIndex(x => x.Barcode.Equals(barcode));
if (index < 0) return;
-
+
RecalcDirty(true);
Scheda.Articoli.RemoveAt(index);
StateHasChanged();
diff --git a/SteUp.Shared/Core/Data/SteupDataService.cs b/SteUp.Shared/Core/Data/SteupDataService.cs
index 0e55d5a..ade3df5 100644
--- a/SteUp.Shared/Core/Data/SteupDataService.cs
+++ b/SteUp.Shared/Core/Data/SteupDataService.cs
@@ -1,12 +1,13 @@
using IntegryApiClient.Core.Domain.Abstraction.Contracts.Account;
using IntegryApiClient.Core.Domain.Abstraction.Contracts.Device;
-using SteUp.Shared.Core.BarcodeReader.Contracts;
using SteUp.Shared.Core.Data.Contracts;
using SteUp.Shared.Core.Dto;
using SteUp.Shared.Core.Dto.PageState;
+using SteUp.Shared.Core.Helpers;
using SteUp.Shared.Core.Interface.IntegryApi;
using SteUp.Shared.Core.Interface.LocalDb;
using SteUp.Shared.Core.Interface.System;
+using SteUp.Shared.Core.Interface.System.Network;
namespace SteUp.Shared.Core.Data;
@@ -15,12 +16,14 @@ public class SteupDataService(
IUserSession userSession,
IDeviceService deviceService,
IGenericSystemService genericSystemService,
+ IIspezioniService ispezioniService,
IDbInitializer dbInitializer) : ISteupDataService
{
public async Task Init()
{
await dbInitializer.InitializeAsync();
await LoadDataAsync();
+ await CheckAndUpdateStatus();
RegisterAppVersion();
}
@@ -31,6 +34,48 @@ public class SteupDataService(
);
}
+ private async Task CheckAndUpdateStatus()
+ {
+ var ispezioni = await ispezioniService.GetAllIspezioniWithSchedeAsync();
+ var listActivityId = ispezioni
+ .Where(x => x.ActivityId != null)
+ .Select(x => x.ActivityId!)
+ .ToList();
+
+ if (!listActivityId.IsNullOrEmpty())
+ {
+ var stati = await integrySteupService.RetrieveStatoIspezioni(
+ new RetrieveStatoIspezioniRequestDto
+ {
+ ActivityIdList = listActivityId
+ }
+ );
+
+ if (stati != null)
+ {
+ foreach (var stato in stati)
+ {
+ var ispezione = ispezioni.Find(x =>
+ x.ActivityId != null &&
+ x.ActivityId.EqualsIgnoreCase(stato.ActivityId)
+ );
+
+ var newStatus = StatusEnumHelper.ConvertToStatusEnum(stato.ActivityResultId);
+
+ if (ispezione != null && ispezione.Stato != newStatus)
+ {
+ await ispezioniService.UpdateStatoIspezioneAsync(
+ ispezione.CodMdep,
+ ispezione.Data,
+ ispezione.Rilevatore,
+ newStatus
+ );
+ }
+ }
+ }
+ }
+ }
+
private async Task LoadDataAsync()
{
if (!await userSession.IsLoggedIn()) return;
diff --git a/SteUp.Shared/Core/Dto/AttachedDto.cs b/SteUp.Shared/Core/Dto/AttachedDto.cs
index 61b908c..60a747b 100644
--- a/SteUp.Shared/Core/Dto/AttachedDto.cs
+++ b/SteUp.Shared/Core/Dto/AttachedDto.cs
@@ -16,6 +16,7 @@ public class AttachedDto
public bool SavedOnAppData { get; set; }
public bool ToRemove { get; set; }
+ public bool ToUpload { get; set; }
public Stream? FileContent =>
FileBytes is null ? null : new MemoryStream(FileBytes);
diff --git a/SteUp.Shared/Core/Dto/RetrieveStatoIspezioniRequestDto.cs b/SteUp.Shared/Core/Dto/RetrieveStatoIspezioniRequestDto.cs
new file mode 100644
index 0000000..c6d70a5
--- /dev/null
+++ b/SteUp.Shared/Core/Dto/RetrieveStatoIspezioniRequestDto.cs
@@ -0,0 +1,9 @@
+using System.Text.Json.Serialization;
+
+namespace SteUp.Shared.Core.Dto;
+
+public class RetrieveStatoIspezioniRequestDto
+{
+ [JsonPropertyName("activityIdList")]
+ public required List ActivityIdList { get; set; }
+}
\ No newline at end of file
diff --git a/SteUp.Shared/Core/Dto/SaveRequestDto.cs b/SteUp.Shared/Core/Dto/SaveRequestDto.cs
new file mode 100644
index 0000000..7abc596
--- /dev/null
+++ b/SteUp.Shared/Core/Dto/SaveRequestDto.cs
@@ -0,0 +1,37 @@
+using System.Text.Json.Serialization;
+using SteUp.Shared.Core.Enum;
+
+namespace SteUp.Shared.Core.Dto;
+
+public class SaveRequestDto
+{
+ [JsonPropertyName("localIdScheda")]
+ public int? LocalIdScheda { get; set; }
+
+ [JsonPropertyName("codMdep")]
+ public string? CodMdep { get; set; }
+
+ [JsonPropertyName("note")]
+ public string? Note { get; set; }
+
+ [JsonPropertyName("parentActivityId")]
+ public string? ParentActivityId { get; set; }
+
+ [JsonPropertyName("activityTypeId")]
+ public string? ActivityTypeId { get; set; }
+
+ [JsonPropertyName("codJfas")]
+ public string? CodJfas { get; set; }
+
+ [JsonPropertyName("personaRif")]
+ public string? PersonaRif { get; set; }
+
+ [JsonPropertyName("scandeza")]
+ public ScadenzaEnum Scandeza { get; set; }
+
+ [JsonPropertyName("dataCreazione")]
+ public DateTime? DataCreazione { get; set; }
+
+ [JsonPropertyName("barcodes")]
+ public List? Barcodes { get; set; }
+}
\ No newline at end of file
diff --git a/SteUp.Shared/Core/Dto/SaveSchedaResponseDto.cs b/SteUp.Shared/Core/Dto/SaveSchedaResponseDto.cs
new file mode 100644
index 0000000..fea2816
--- /dev/null
+++ b/SteUp.Shared/Core/Dto/SaveSchedaResponseDto.cs
@@ -0,0 +1,24 @@
+using System.Text.Json.Serialization;
+
+namespace SteUp.Shared.Core.Dto;
+
+public class SaveSchedaResponseDto
+{
+ [JsonPropertyName("activityIdIspezione")]
+ public string? ActivityIdIspezione { get; set; }
+
+ [JsonPropertyName("activityIdScheda")]
+ public string? ActivityIdScheda { get; set; }
+
+ [JsonPropertyName("activityIdSchedaList")]
+ public List? ActivityIdSchedaList { get; set; }
+
+ public class SchedaActivityId
+ {
+ [JsonPropertyName("localId")]
+ public int? LocalId { get; set; }
+
+ [JsonPropertyName("activityId")]
+ public string? ActivityId { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/SteUp.Shared/Core/Dto/StbActivityDto.cs b/SteUp.Shared/Core/Dto/StbActivityDto.cs
new file mode 100644
index 0000000..142b0ab
--- /dev/null
+++ b/SteUp.Shared/Core/Dto/StbActivityDto.cs
@@ -0,0 +1,12 @@
+using System.Text.Json.Serialization;
+
+namespace SteUp.Shared.Core.Dto;
+
+public class StbActivityDto
+{
+ [JsonPropertyName("activityId")]
+ public string ActivityId { get; set; } = string.Empty;
+
+ [JsonPropertyName("activityResultId")]
+ public string ActivityResultId { get; set; } = string.Empty;
+}
\ No newline at end of file
diff --git a/SteUp.Shared/Core/Entities/Ispezione.cs b/SteUp.Shared/Core/Entities/Ispezione.cs
index 283065b..82f6e1c 100644
--- a/SteUp.Shared/Core/Entities/Ispezione.cs
+++ b/SteUp.Shared/Core/Entities/Ispezione.cs
@@ -7,10 +7,12 @@ public class Ispezione : EntityBase
{
[Required]
public string CodMdep { get; set; } = string.Empty;
- public DateOnly Data { get; set; }
+ public DateTime Data { get; set; }
[Required]
public string Rilevatore { get; set; } = string.Empty;
+ public string? ActivityId { get; set; }
+
public StatusEnum Stato { get; set; } = StatusEnum.InCorso;
public List Schede { get; set; } = [];
diff --git a/SteUp.Shared/Core/Entities/Scheda.cs b/SteUp.Shared/Core/Entities/Scheda.cs
index 75d34a5..2aba30a 100644
--- a/SteUp.Shared/Core/Entities/Scheda.cs
+++ b/SteUp.Shared/Core/Entities/Scheda.cs
@@ -8,11 +8,12 @@ public class Scheda : EntityBase
{
[Key]
public int Id { get; set; }
+ public string? ActivityId { get; set; }
public string? CodJfas { get; set; }
[Required]
public string CodMdep { get; set; } = string.Empty;
- public DateOnly Data { get; set; }
+ public DateTime Data { get; set; }
[Required]
public string Rilevatore { get; set; } = string.Empty;
public Ispezione? Ispezione { get; set; }
@@ -24,7 +25,7 @@ public class Scheda : EntityBase
public string? ActivityTypeId { get; set; }
public string? Note { get; set; }
public string? Responsabile { get; set; }
- public int Scadenza { get; set; } = 1460;
+ public int Scadenza { get; set; }
[NotMapped]
public JtbFasiDto? Reparto
diff --git a/SteUp.Shared/Core/Enum/ScadenzaEnum.cs b/SteUp.Shared/Core/Enum/ScadenzaEnum.cs
new file mode 100644
index 0000000..2c27025
--- /dev/null
+++ b/SteUp.Shared/Core/Enum/ScadenzaEnum.cs
@@ -0,0 +1,9 @@
+namespace SteUp.Shared.Core.Enum;
+
+public enum ScadenzaEnum
+{
+ Bassa2Mesi = 0,
+ Media1Mese = 1,
+ Alta1Settimana = 2,
+ Altissima24Ore = 3
+}
\ No newline at end of file
diff --git a/SteUp.Shared/Core/Enum/StatusEnum.cs b/SteUp.Shared/Core/Enum/StatusEnum.cs
index 9c76cfe..6d0eaa5 100644
--- a/SteUp.Shared/Core/Enum/StatusEnum.cs
+++ b/SteUp.Shared/Core/Enum/StatusEnum.cs
@@ -4,5 +4,6 @@ public enum StatusEnum
{
InCorso = 0,
Completata = 1,
- Esporta = 2
+ Verifica = 2,
+ Annullata = 3
}
\ No newline at end of file
diff --git a/SteUp.Shared/Core/Helpers/ModalHelper.cs b/SteUp.Shared/Core/Helpers/ModalHelper.cs
index b3f8de5..9dc0afe 100644
--- a/SteUp.Shared/Core/Helpers/ModalHelper.cs
+++ b/SteUp.Shared/Core/Helpers/ModalHelper.cs
@@ -25,7 +25,7 @@ public abstract class ModalHelper
return await modal.Result;
}
- public static async Task OpenFormScheda(IDialogService dialog, string codMdep, DateOnly data,
+ public static async Task OpenFormScheda(IDialogService dialog, string codMdep, DateTime data,
bool isNew = false, Scheda? scheda = null)
{
scheda = isNew && scheda == null ? new Scheda() : scheda;
diff --git a/SteUp.Shared/Core/Helpers/ObjectExtensions.cs b/SteUp.Shared/Core/Helpers/ObjectExtensions.cs
index 7054358..ab3c514 100644
--- a/SteUp.Shared/Core/Helpers/ObjectExtensions.cs
+++ b/SteUp.Shared/Core/Helpers/ObjectExtensions.cs
@@ -10,9 +10,13 @@ public static class ObjectExtensions
public static bool IsNullOrEmpty(this string? obj) =>
string.IsNullOrEmpty(obj);
+ public static bool IsValorized(this string? obj) => !obj.IsNullOrEmpty();
+
public static bool EqualsIgnoreCase(this string obj, string other) =>
string.Equals(obj, other, StringComparison.InvariantCultureIgnoreCase);
public static bool ContainsIgnoreCase(this string obj, string other) =>
obj.Contains(other, StringComparison.InvariantCultureIgnoreCase);
+
+ public static int Count(this List? obj) => obj?.Count ?? 0;
}
\ No newline at end of file
diff --git a/SteUp.Shared/Core/Helpers/StatusEnumHelper.cs b/SteUp.Shared/Core/Helpers/StatusEnumHelper.cs
index e674a7c..997a99a 100644
--- a/SteUp.Shared/Core/Helpers/StatusEnumHelper.cs
+++ b/SteUp.Shared/Core/Helpers/StatusEnumHelper.cs
@@ -11,18 +11,30 @@ public static class StatusEnumHelper
{
StatusEnum.InCorso => "IN CORSO",
StatusEnum.Completata => "COMPLETATA",
- StatusEnum.Esporta => "ESPORTATA",
+ StatusEnum.Verifica => "VERIFICA",
+ StatusEnum.Annullata => "ANNULLATA",
_ => throw new ArgumentOutOfRangeException(nameof(enumValue), enumValue, null)
};
}
+ public static StatusEnum ConvertToStatusEnum(string stringValue)
+ {
+ return stringValue switch
+ {
+ "COMPLETATA" => StatusEnum.Completata,
+ "ANNULLATA" => StatusEnum.Annullata,
+ "VERIFICA" => StatusEnum.Verifica,
+ _ => StatusEnum.InCorso
+ };
+ }
+
public static Color GetColor(this StatusEnum enumValue)
{
return enumValue switch
{
- StatusEnum.InCorso => Color.Warning,
- StatusEnum.Completata or
- StatusEnum.Esporta => Color.Success,
+ StatusEnum.InCorso or StatusEnum.Verifica => Color.Warning,
+ StatusEnum.Completata => Color.Success,
+ StatusEnum.Annullata => Color.Error,
_ => Color.Default
};
}
diff --git a/SteUp.Shared/Core/Interface/IntegryApi/IIntegrySteupService.cs b/SteUp.Shared/Core/Interface/IntegryApi/IIntegrySteupService.cs
index 429343f..f4fe3be 100644
--- a/SteUp.Shared/Core/Interface/IntegryApi/IIntegrySteupService.cs
+++ b/SteUp.Shared/Core/Interface/IntegryApi/IIntegrySteupService.cs
@@ -10,4 +10,11 @@ public interface IIntegrySteupService
Task
- > RetrieveActivityType();
Task
- ?> RetrieveGrigliaPlu(RetrieveGrigliaPluRequestDto request);
Task
- ?> RetrieveStatoIspezioni(RetrieveStatoIspezioniRequestDto request);
+
+ //Save
+ Task
- > GetAllIspezioniWithSchedeAsync();
Task AddIspezioneAsync(Ispezione ispezione);
- Task
- > GetAllSchedeOfIspezioneAsync(string codMdep, DateOnly data, string rilevatore);
+ Task AddSchedaAsync(string codMdep, DateTime data, string rilevatore, Scheda scheda);
+ Task
- > GetAllSchedeOfIspezioneAsync(string codMdep, DateTime data, string rilevatore);
Task
- ?> SelectImageFromGallery();
- Task
- ?> GetInspectionFiles(Ispezione ispezione);
+ Task
- ?> GetInspectionFiles(Ispezione ispezione, List