fix(back-end): nozle layer height
All checks were successful
Build and Deploy / test-backend (push) Successful in 41s
PR Checks / prettier-autofix (pull_request) Successful in 10s
Build and Deploy / test-frontend (push) Successful in 1m14s
PR Checks / security-sast (pull_request) Successful in 33s
PR Checks / test-backend (pull_request) Successful in 27s
PR Checks / test-frontend (pull_request) Successful in 1m8s
Build and Deploy / build-and-push (push) Successful in 1m10s
Build and Deploy / deploy (push) Successful in 11s
All checks were successful
Build and Deploy / test-backend (push) Successful in 41s
PR Checks / prettier-autofix (pull_request) Successful in 10s
Build and Deploy / test-frontend (push) Successful in 1m14s
PR Checks / security-sast (pull_request) Successful in 33s
PR Checks / test-backend (pull_request) Successful in 27s
PR Checks / test-frontend (pull_request) Successful in 1m8s
Build and Deploy / build-and-push (push) Successful in 1m10s
Build and Deploy / deploy (push) Successful in 11s
This commit is contained in:
@@ -12,9 +12,11 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class NozzleLayerHeightPolicyService {
|
public class NozzleLayerHeightPolicyService {
|
||||||
|
private static final Logger logger = Logger.getLogger(NozzleLayerHeightPolicyService.class.getName());
|
||||||
private static final BigDecimal DEFAULT_NOZZLE = BigDecimal.valueOf(0.40).setScale(2, RoundingMode.HALF_UP);
|
private static final BigDecimal DEFAULT_NOZZLE = BigDecimal.valueOf(0.40).setScale(2, RoundingMode.HALF_UP);
|
||||||
private static final BigDecimal DEFAULT_LAYER = BigDecimal.valueOf(0.20).setScale(3, RoundingMode.HALF_UP);
|
private static final BigDecimal DEFAULT_LAYER = BigDecimal.valueOf(0.20).setScale(3, RoundingMode.HALF_UP);
|
||||||
|
|
||||||
@@ -27,7 +29,8 @@ public class NozzleLayerHeightPolicyService {
|
|||||||
public Map<BigDecimal, List<BigDecimal>> getActiveRulesByNozzle() {
|
public Map<BigDecimal, List<BigDecimal>> getActiveRulesByNozzle() {
|
||||||
List<NozzleLayerHeightOption> rules = ruleRepo.findByIsActiveTrueOrderByNozzleDiameterMmAscLayerHeightMmAsc();
|
List<NozzleLayerHeightOption> rules = ruleRepo.findByIsActiveTrueOrderByNozzleDiameterMmAscLayerHeightMmAsc();
|
||||||
if (rules.isEmpty()) {
|
if (rules.isEmpty()) {
|
||||||
return fallbackRules();
|
logger.warning("No active nozzle->layer rules found in DB (table nozzle_layer_height_option is empty)");
|
||||||
|
return Map.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<BigDecimal, List<BigDecimal>> byNozzle = new LinkedHashMap<>();
|
Map<BigDecimal, List<BigDecimal>> byNozzle = new LinkedHashMap<>();
|
||||||
@@ -120,24 +123,4 @@ public class NozzleLayerHeightPolicyService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<BigDecimal, List<BigDecimal>> fallbackRules() {
|
|
||||||
Map<BigDecimal, List<BigDecimal>> fallback = new LinkedHashMap<>();
|
|
||||||
fallback.put(scaleNozzle(0.20), scaleLayers(0.04, 0.06, 0.08, 0.10, 0.12));
|
|
||||||
fallback.put(scaleNozzle(0.40), scaleLayers(0.08, 0.12, 0.16, 0.20, 0.24, 0.28));
|
|
||||||
fallback.put(scaleNozzle(0.60), scaleLayers(0.16, 0.20, 0.24, 0.30, 0.36));
|
|
||||||
fallback.put(scaleNozzle(0.80), scaleLayers(0.20, 0.28, 0.36, 0.40, 0.48, 0.56));
|
|
||||||
return fallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
private BigDecimal scaleNozzle(double value) {
|
|
||||||
return BigDecimal.valueOf(value).setScale(2, RoundingMode.HALF_UP);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<BigDecimal> scaleLayers(double... values) {
|
|
||||||
List<BigDecimal> scaled = new ArrayList<>();
|
|
||||||
for (double value : values) {
|
|
||||||
scaled.add(BigDecimal.valueOf(value).setScale(3, RoundingMode.HALF_UP));
|
|
||||||
}
|
|
||||||
return scaled;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user