fix(back-end): shift model
All checks were successful
Build, Test and Deploy / test-backend (push) Successful in 1m13s
Build, Test and Deploy / build-and-push (push) Successful in 29s
Build, Test and Deploy / deploy (push) Successful in 9s

This commit is contained in:
2026-02-17 16:25:21 +01:00
parent 701a10e886
commit 85a4db1630
2 changed files with 17 additions and 7 deletions

View File

@@ -88,6 +88,12 @@ public class OrderController {
order.setCreatedAt(OffsetDateTime.now()); order.setCreatedAt(OffsetDateTime.now());
order.setUpdatedAt(OffsetDateTime.now()); order.setUpdatedAt(OffsetDateTime.now());
order.setCurrency("CHF"); order.setCurrency("CHF");
// Initialize all NOT NULL monetary fields before first persist.
order.setSetupCostChf(session.getSetupCostChf() != null ? session.getSetupCostChf() : BigDecimal.ZERO);
order.setShippingCostChf(BigDecimal.ZERO);
order.setDiscountChf(BigDecimal.ZERO);
order.setSubtotalChf(BigDecimal.ZERO);
order.setTotalChf(BigDecimal.ZERO);
// Billing // Billing
order.setBillingCustomerType(request.getCustomer().getCustomerType()); order.setBillingCustomerType(request.getCustomer().getCustomerType());
@@ -193,7 +199,7 @@ public class OrderController {
// Update Order Totals // Update Order Totals
order.setSubtotalChf(subtotal); order.setSubtotalChf(subtotal);
order.setSetupCostChf(session.getSetupCostChf()); order.setSetupCostChf(session.getSetupCostChf() != null ? session.getSetupCostChf() : BigDecimal.ZERO);
order.setShippingCostChf(BigDecimal.valueOf(9.00)); // Default shipping? or 0? order.setShippingCostChf(BigDecimal.valueOf(9.00)); // Default shipping? or 0?
// TODO: Calc implementation for shipping // TODO: Calc implementation for shipping

View File

@@ -10,6 +10,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
@@ -79,8 +80,7 @@ public class SlicerService {
command.add("--load-filaments"); command.add("--load-filaments");
command.add(fFile.getAbsolutePath()); command.add(fFile.getAbsolutePath());
command.add("--ensure-on-bed"); command.add("--ensure-on-bed");
command.add("--arrange"); // Single-model jobs do not need arrange; it can fail on near-limit models.
command.add("1"); // force arrange
command.add("--slice"); command.add("--slice");
command.add("0"); // slice plate 0 command.add("0"); // slice plate 0
command.add("--outputdir"); command.add("--outputdir");
@@ -95,19 +95,23 @@ public class SlicerService {
// 4. Run Process // 4. Run Process
ProcessBuilder pb = new ProcessBuilder(command); ProcessBuilder pb = new ProcessBuilder(command);
pb.directory(tempDir.toFile()); pb.directory(tempDir.toFile());
// pb.inheritIO(); // Useful for debugging, but maybe capture instead? Path slicerLogPath = tempDir.resolve("orcaslicer.log");
pb.redirectErrorStream(true);
pb.redirectOutput(slicerLogPath.toFile());
Process process = pb.start(); Process process = pb.start();
boolean finished = process.waitFor(5, TimeUnit.MINUTES); boolean finished = process.waitFor(5, TimeUnit.MINUTES);
if (!finished) { if (!finished) {
process.destroy(); process.destroyForcibly();
throw new IOException("Slicer timed out"); throw new IOException("Slicer timed out");
} }
if (process.exitValue() != 0) { if (process.exitValue() != 0) {
// Read stderr String error = "";
String error = new String(process.getErrorStream().readAllBytes()); if (Files.exists(slicerLogPath)) {
error = Files.readString(slicerLogPath, StandardCharsets.UTF_8);
}
throw new IOException("Slicer failed with exit code " + process.exitValue() + ": " + error); throw new IOException("Slicer failed with exit code " + process.exitValue() + ": " + error);
} }