removido dados ficticios
This commit is contained in:
@@ -174,41 +174,7 @@ class MaintenanceRepository(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a static sample dataset for quick testing and demonstration.
|
||||
*/
|
||||
suspend fun loadSampleData() = withContext(Dispatchers.IO) {
|
||||
val now = System.currentTimeMillis()
|
||||
val sampleActivities = listOf(
|
||||
MaintenanceActivity("OS-2", "SUBSTITUIÇÃO DO EIXO E ROTOR DO EXAUSTOR", "UTILIDADES", "Mecânica", "Carlos Silva", "14/08/2026", "18/08/2026", 0, lastUpdated = now),
|
||||
MaintenanceActivity("OS-5", "REVISÃO NO FLAP DE ENTRADA DO EXAUSTOR DA CALDEIRA", "UTILIDADES", "Mecânica", "Carlos Silva", "14/08/2026", "20/08/2026", 0, lastUpdated = now),
|
||||
MaintenanceActivity("OS-6", "REFORÇAR ESTRUTURA DO MANCAL DO VENTILADOR", "UTILIDADES", "Mecânica", "Carlos Silva", "15/08/2026", "17/08/2026", 0, lastUpdated = now),
|
||||
MaintenanceActivity("OS-8", "TROCA DOS EMBUCHAMENTOS DOS DUMPERS DO VENTILADOR PRIMARIO", "UTILIDADES", "Mecânica", "João Pedro", "14/08/2026", "14/08/2026", 0, lastUpdated = now),
|
||||
MaintenanceActivity("OS-10", "TROCA DA ROSCA CV-111014", "UTILIDADES", "Mecânica", "Marcos Rocha", "14/08/2026", "14/08/2026", 0, lastUpdated = now),
|
||||
MaintenanceActivity("OS-11", "ALINHAMENTO DA FIXAÇÃO DA BOBINA ENRROLADORA", "UTILIDADES", "Mecânica", "Marcos Rocha", "14/08/2026", "14/08/2026", 0, lastUpdated = now),
|
||||
MaintenanceActivity("OS-1024", "SUBSTITUIÇÃO DA CHAPA DE FIXAÇÃO DOS APARADORES", "UTILIDADES", "Mecânica", "GTEC 1", "17/08/2026", "18/08/2026", 50, "Iniciada a desmontagem da chapa antiga.", lastUpdated = now),
|
||||
MaintenanceActivity("OS-16", "ADEQUAÇÃO NA ALIMENTAÇÃO DA CORREIA", "UTILIDADES", "Mecânica", "GTEC 1", "19/08/2026", "21/08/2026", 10, lastUpdated = now)
|
||||
)
|
||||
dao.clearAllActivities()
|
||||
dao.insertActivities(sampleActivities)
|
||||
|
||||
// Pre-populate some history
|
||||
for (activity in sampleActivities) {
|
||||
if (activity.percentualExecucao > 0) {
|
||||
dao.insertHistory(
|
||||
OSUpdateHistory(
|
||||
numeroOs = activity.numeroOs,
|
||||
percentualAnterior = 0,
|
||||
percentualNovo = activity.percentualExecucao,
|
||||
observacao = activity.observacoes,
|
||||
recurso = activity.recurso,
|
||||
emailEditor = "admin@cargill.com",
|
||||
timestamp = now - 3600000 // 1 hour ago
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a fully functional bidirectional synchronization with the central Google Sheet.
|
||||
|
||||
@@ -450,11 +450,6 @@ fun MaintenanceDashboardScreen(
|
||||
}
|
||||
}
|
||||
|
||||
if (activities.isEmpty()) {
|
||||
TextButton(onClick = { viewModel.resetToSampleData() }) {
|
||||
Text("Carregar Demo", color = CargillGreen, fontSize = 13.sp, fontWeight = FontWeight.Bold)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Main OS List View
|
||||
@@ -554,11 +549,7 @@ fun MaintenanceDashboardScreen(
|
||||
if (showImporterSheet) {
|
||||
ImporterConsoleSheet(
|
||||
onDismiss = { showImporterSheet = false },
|
||||
onChooseFile = { filePickerLauncher.launch("text/*") },
|
||||
onLoadSample = {
|
||||
viewModel.resetToSampleData()
|
||||
showImporterSheet = false
|
||||
}
|
||||
onChooseFile = { filePickerLauncher.launch("text/*") }
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1475,8 +1466,7 @@ fun TimelineLogItem(log: OSUpdateHistory) {
|
||||
@Composable
|
||||
fun ImporterConsoleSheet(
|
||||
onDismiss: () -> Unit,
|
||||
onChooseFile: () -> Unit,
|
||||
onLoadSample: () -> Unit
|
||||
onChooseFile: () -> Unit
|
||||
) {
|
||||
ModalBottomSheet(
|
||||
onDismissRequest = onDismiss,
|
||||
@@ -1554,23 +1544,6 @@ fun ImporterConsoleSheet(
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text("Selecionar CSV no Dispositivo", fontWeight = FontWeight.Bold)
|
||||
}
|
||||
|
||||
// Action 2: Load model data directly
|
||||
OutlinedButton(
|
||||
onClick = {
|
||||
onLoadSample()
|
||||
onDismiss()
|
||||
},
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(48.dp),
|
||||
colors = ButtonDefaults.outlinedButtonColors(contentColor = CargillBlack),
|
||||
border = BorderStroke(1.dp, CargillBlack)
|
||||
) {
|
||||
Icon(Icons.Default.FileOpen, contentDescription = "Carregar Planilha Modelo")
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text("Pre-carregar Planilha Modelo Cargill (10 OSs)", fontWeight = FontWeight.Bold)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
@@ -150,7 +150,7 @@ class MaintenanceViewModel(private val repository: MaintenanceRepository) : View
|
||||
|
||||
init {
|
||||
_currentUser.value = repository.getSavedUser()
|
||||
// Automatically check and pull service orders from Sheets on first launch. Fall back to local sample data if sync fails.
|
||||
// Automatically check and pull service orders from Sheets on first launch.
|
||||
viewModelScope.launch {
|
||||
val currentList = repository.allActivities.first()
|
||||
if (currentList.isEmpty()) {
|
||||
@@ -163,9 +163,7 @@ class MaintenanceViewModel(private val repository: MaintenanceRepository) : View
|
||||
_syncStatusMessage.value = "Sincronização inicial concluída! ${result.syncedItems} OSs sincronizadas."
|
||||
}
|
||||
is SyncResult.Error -> {
|
||||
// Safe offline fallback in case of no connectivity or invalid credentials
|
||||
_syncStatusMessage.value = "Usando dados modelo: ${result.message}"
|
||||
repository.loadSampleData()
|
||||
_syncStatusMessage.value = "Falha na sincronização inicial: ${result.message}"
|
||||
}
|
||||
}
|
||||
_isSyncing.value = false
|
||||
@@ -226,16 +224,7 @@ class MaintenanceViewModel(private val repository: MaintenanceRepository) : View
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to preload sample data on-demand.
|
||||
*/
|
||||
fun resetToSampleData() {
|
||||
viewModelScope.launch {
|
||||
_importStatusMessage.value = "Carregando planilha modelo..."
|
||||
repository.loadSampleData()
|
||||
_importStatusMessage.value = "Ordens de serviço padrão carregadas com sucesso!"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs synchronized check.
|
||||
|
||||
Reference in New Issue
Block a user