Erweiterungen

This commit is contained in:
2025-09-15 18:14:40 +02:00
parent 751836e8a4
commit 45a775b71a
5 changed files with 37 additions and 25 deletions

View File

@@ -79,6 +79,7 @@ public class MongoConfig {
log.debug("Creating TodoListTask");
task = new TodoListTask();
if (source.containsKey("todo_items")) {
// Suppressing unchecked cast warning as MongoDB document structure is validated
@SuppressWarnings("unchecked")
List<String> todoItems = (List<String>) source.get("todo_items");
((TodoListTask) task).setTodoItems(todoItems);

View File

@@ -145,7 +145,8 @@ public class MessageController {
Object cid = request.get("clientId");
if (cid != null)
clientId = cid.toString();
} catch (Exception ignored) {
} catch (Exception e) {
log.debug("Could not extract clientId from request: {}", e.getMessage());
}
if (clientId == null || clientId.isBlank()) {
clientId = getClientIdForUserId(appUserId);
@@ -210,7 +211,8 @@ public class MessageController {
Object tt = payload != null ? payload.get("taskType") : null;
if (tt != null)
taskType = tt.toString();
} catch (Exception ignored) {
} catch (Exception e) {
log.debug("Could not extract taskType from payload: {}", e.getMessage());
}
handleTaskCompleted(payload, taskType);
}
@@ -272,13 +274,15 @@ public class MessageController {
if (extra instanceof Map<?, ?> extraData) {
Object barcodesObj = extraData.get("barcodes");
if (barcodesObj instanceof List<?> barcodesList) {
// Suppressing unchecked cast warning as extraData structure is validated from MQTT payload
@SuppressWarnings("unchecked")
List<String> barcodes = (List<String>) barcodesList;
if (!barcodes.isEmpty()) {
for (String barcodeString : barcodes) {
String completedBy = task.getCompletedBy() != null ? task.getCompletedBy() : "Unknown";
Barcode barcodeEntry = new Barcode(new ObjectId(taskId.toString()), barcodeString,
task.getCompletedBy());
completedBy);
barcodeRepository.save(barcodeEntry);
}
@@ -325,8 +329,9 @@ public class MessageController {
Object signatureSvgObj = extraData.get("signatureSvg");
if (signatureSvgObj instanceof String signatureSvg) {
if (!signatureSvg.isBlank()) {
String completedBy = task.getCompletedBy() != null ? task.getCompletedBy() : "Unknown";
Signature signatureEntry = new Signature(new ObjectId(taskId.toString()), signatureSvg,
task.getCompletedBy());
completedBy);
signatureRepository.save(signatureEntry);
extraDataSummary = "Unterschrift erfasst (SVG, " + signatureSvg.length() + " Zeichen)";
@@ -369,13 +374,15 @@ public class MessageController {
if (extra instanceof Map<?, ?> extraData) {
Object photosObj = extraData.get("photos");
if (photosObj instanceof List<?> photosList) {
// Suppressing unchecked cast warning as extraData structure is validated from MQTT payload
@SuppressWarnings("unchecked")
List<String> photos = (List<String>) photosList;
if (!photos.isEmpty()) {
for (String photoString : photos) {
String completedBy = task.getCompletedBy() != null ? task.getCompletedBy() : "Unknown";
Photo photoEntry = new Photo(new ObjectId(taskId.toString()), photoString,
task.getCompletedBy());
completedBy);
photoRepository.save(photoEntry);
}
@@ -428,7 +435,8 @@ public class MessageController {
String taskType = task.getTaskType() != null ? task.getTaskType().toString() : "Unknown";
String taskDisplayName = task.getDisplayName() != null ? task.getDisplayName() : taskType;
jobHistoryService.logTaskCompletion(jobId, taskType, taskIdStr, task.getCompletedBy(), taskDisplayName,
String completedBy = task.getCompletedBy() != null ? task.getCompletedBy() : "Unknown";
jobHistoryService.logTaskCompletion(jobId, taskType, taskIdStr, completedBy, taskDisplayName,
extraDataSummary);
} catch (Exception e) {
log.warn("Failed to log task completion history for task {}: {}", taskIdStr, e.getMessage());
@@ -438,7 +446,7 @@ public class MessageController {
try {
ObjectId jobId = new ObjectId(task.getJobIdAsString());
String taskType = task.getTaskType() != null ? task.getTaskType().toString() : "Unknown";
String completedBy = task.getCompletedBy();
String completedBy = task.getCompletedBy() != null ? task.getCompletedBy() : "Unknown";
emailService.sendTaskCompletionNotification(jobId, taskType, taskIdStr, completedBy);
@@ -449,7 +457,8 @@ public class MessageController {
e.getMessage());
}
log.info("Task marked completed. taskId={}, completedBy={}, extraData={}", taskIdStr, task.getCompletedBy(),
String completedBy = task.getCompletedBy() != null ? task.getCompletedBy() : "Unknown";
log.info("Task marked completed. taskId={}, completedBy={}, extraData={}", taskIdStr, completedBy,
extraDataSummary);
} catch (IllegalArgumentException ex) {
log.error("Invalid taskId format for completion: {}", taskIdStr);

View File

@@ -58,7 +58,8 @@ public class MqttV5ClientManager implements SmartLifecycle {
client = builder.buildAsync();
var connect = client.connectWith().cleanStart(props.isCleanStart()).keepAlive(props.getKeepAlive())
.sessionExpiryInterval(props.getSessionExpiryInterval()).simpleAuth().username("app")
.sessionExpiryInterval(props.getSessionExpiryInterval()).simpleAuth()
.username("app")
.password("apppwd".getBytes(StandardCharsets.UTF_8)).applySimpleAuth();
log.info("[MQTT] Connecting to {} with clientId={} ...", props.getBrokerUri(), clientId);

View File

@@ -1139,7 +1139,7 @@ public class AddJobView extends Main {
}
} catch (Exception e) {
// Fehler beim Laden des Entwurfs sollten nicht die Anwendung blockieren
System.err.println("Fehler beim Laden des Entwurfs: " + e.getMessage());
log.warn("Fehler beim Laden des Entwurfs: {}", e.getMessage());
}
}
@@ -1228,11 +1228,6 @@ public class AddJobView extends Main {
CargoItem item = new CargoItem();
cargoItemsState.add(item);
// Pre-fill current input values into backing item
item.setDescription(desc.getValue());
item.setQuantity(qty.getValue());
item.setWeightKg(weight.getValue());
item.setLengthMm(len.getValue());
// Initialize from current inputs
item.setDescription(desc.getValue());
item.setQuantity(qty.getValue());
@@ -1240,8 +1235,6 @@ public class AddJobView extends Main {
item.setLengthMm(len.getValue());
item.setWidthMm(wid.getValue());
item.setHeightMm(hei.getValue());
item.setWidthMm(wid.getValue());
item.setHeightMm(hei.getValue());
desc.addValueChangeListener(ev -> {
item.setDescription(ev.getValue());
@@ -1340,8 +1333,8 @@ public class AddJobView extends Main {
*/
private String getCurrentUsername() {
try {
// Hier würden Sie normalerweise den SecurityService verwenden
// Für diese Demo nehmen wir einen festen Wert
// TODO: Implement actual security service to get current username
// For demo purposes using fixed value
return "test@votianlt.de";
} catch (Exception e) {
return null;

View File

@@ -27,6 +27,7 @@ import de.assecutor.votianlt.model.task.ConfirmationTask;
import de.assecutor.votianlt.model.task.BarcodeTask;
import de.assecutor.votianlt.model.AppUser;
import de.assecutor.votianlt.pages.base.ui.component.ViewToolbar;
import lombok.extern.slf4j.Slf4j;
import de.assecutor.votianlt.repository.CargoItemRepository;
import de.assecutor.votianlt.repository.JobRepository;
import de.assecutor.votianlt.repository.TaskRepository;
@@ -48,6 +49,7 @@ import java.util.Objects;
@Route(value = "job_summary", layout = de.assecutor.votianlt.pages.base.ui.view.MainLayout.class)
@PageTitle("Zusammenfassung")
@RolesAllowed("USER")
@Slf4j
public class JobSummaryView extends Main implements HasUrlParameter<String> {
private final JobRepository jobRepository;
@@ -303,7 +305,8 @@ public class JobSummaryView extends Main implements HasUrlParameter<String> {
if (au.getEmail() != null && !au.getEmail().isBlank())
return au.getEmail();
}
} catch (Exception ignored) {
} catch (Exception e) {
log.debug("Failed to resolve AppUser name for ID {}: {}", appUserIdString, e.getMessage());
}
return appUserIdString; // Fallback: show raw string if lookup fails
}
@@ -368,7 +371,7 @@ public class JobSummaryView extends Main implements HasUrlParameter<String> {
+ " }" + " });" + " if (!bounds.isEmpty()) { map.fitBounds(bounds); }"
+ " }});" + " }" + " if (!(window.google && window.google.maps)) {"
+ " var s=document.createElement('script');"
+ " s.src='https://maps.googleapis.com/maps/api/js?key=AIzaSyDnbitL06iLp3elmj-WtPudCykX9xvXcVE&libraries=places';"
+ " s.src='https://maps.googleapis.com/maps/api/js?key=" + getGoogleMapsApiKey() + "&libraries=places';"
+ " s.onload=init; document.head.appendChild(s);" + " } else { init(); }" + "})();");
map.getElement().executeJs(js, map.getElement(), routeInfo.getElement());
@@ -494,7 +497,7 @@ public class JobSummaryView extends Main implements HasUrlParameter<String> {
}
}
} catch (Exception e) {
// Ignore errors when loading photos
log.debug("Failed to load photos for task {}: {}", task.getId(), e.getMessage());
}
}
} else if (task instanceof ConfirmationTask confirmationTask) {
@@ -535,7 +538,7 @@ public class JobSummaryView extends Main implements HasUrlParameter<String> {
}
}
} catch (Exception e) {
// Ignore errors when loading signature
log.debug("Failed to load signature for task {}: {}", task.getId(), e.getMessage());
}
}
} else if (task instanceof BarcodeTask barcodeTask) {
@@ -573,7 +576,7 @@ public class JobSummaryView extends Main implements HasUrlParameter<String> {
}
}
} catch (Exception e) {
// Ignore errors when loading barcodes
log.debug("Failed to load barcodes for task {}: {}", task.getId(), e.getMessage());
}
}
}
@@ -833,7 +836,7 @@ public class JobSummaryView extends Main implements HasUrlParameter<String> {
"<svg viewBox=\"0 0 " + cleanWidth + " " + cleanHeight + "\"");
}
} catch (Exception e) {
// Ignore extraction errors
log.debug("Failed to extract SVG dimensions for viewBox: {}", e.getMessage());
}
}
}
@@ -855,6 +858,11 @@ public class JobSummaryView extends Main implements HasUrlParameter<String> {
return null;
}
private String getGoogleMapsApiKey() {
// TODO: Move API key to configuration properties
return "AIzaSyDnbitL06iLp3elmj-WtPudCykX9xvXcVE";
}
private void resetAllTaskCardHoverStates() {
// Reset hover state for all task cards
for (Div taskCard : taskCards) {