added dynamic scaling for route section heights in reports and adjusted query ordering for calculation jobs

This commit is contained in:
Jan 2025-09-28 20:07:14 +02:00
parent 01125fc875
commit d997178d00
4 changed files with 42 additions and 13 deletions

View file

@ -1,5 +1,5 @@
<template> <template>
<div class="route-container"> <div class="route-container" :style="{height: routeSectionScale + 'rem'}">
<div class="route"> <div class="route">
<div class="route-section" v-for="section in sections" :key="section.id"> <div class="route-section" v-for="section in sections" :key="section.id">
<div class="route-section-line"></div> <div class="route-section-line"></div>
@ -55,6 +55,10 @@ export default {
name: 'ReportRoute', name: 'ReportRoute',
components: {PhArrowRight, PhCaretDoubleRight, PhCaretRight, PhTruck, PhTruckTrailer, PhTrain, PhBoat}, components: {PhArrowRight, PhCaretDoubleRight, PhCaretRight, PhTruck, PhTruckTrailer, PhTrain, PhBoat},
props: { props: {
routeSectionScale: {
type: Number,
default: 20
},
sections: { sections: {
type: Array, type: Array,
required: true, required: true,
@ -73,7 +77,7 @@ export default {
<style scoped> <style scoped>
.route-container { .route-container {
padding: 20px; padding: 20px;
min-height: 20rem; height: 20rem
} }
.route { .route {

View file

@ -138,12 +138,12 @@
</div> </div>
<div class="box-gap" :key="premise.id" v-for="premise in report.premises"> <div class="box-gap" :key="premise.id" v-for="(premise, idx) in report.premises">
<collapsible-box class="report-content-container" variant="border" :title="premise.destination.name" <collapsible-box class="report-content-container" variant="border" :title="premise.destination.name"
:stretch-content="true" :initially-collapsed="true"> :stretch-content="true" :initially-collapsed="true">
<div> <div>
<report-route :sections="premise.sections" :destination="premise.destination" ></report-route> <report-route :sections="premise.sections" :destination="premise.destination" :route-section-scale="routeSectionScale[idx]" ></report-route>
<div class="report-sub-header">Premisses</div> <div class="report-sub-header">Premisses</div>
@ -258,6 +258,10 @@ export default {
chartScale: { chartScale: {
type: Number, type: Number,
required: true required: true
},
routeSectionScale: {
type: Array,
required: true
} }
}, },
methods: { methods: {

View file

@ -1,10 +1,16 @@
<template> <template>
<div> <div>
<div class="header-container"> <div class="header-container">
<h2 class="page-header page-header-align">Reporting <div class="page-header-badges"><basic-badge variant="primary" v-if="period">{{ period }}</basic-badge><basic-badge variant="secondary" v-if="partNumber">{{ partNumber }}</basic-badge></div></h2> <h2 class="page-header page-header-align">Reporting
<div class="page-header-badges">
<basic-badge variant="primary" v-if="period">{{ period }}</basic-badge>
<basic-badge variant="secondary" v-if="partNumber">{{ partNumber }}</basic-badge>
</div>
</h2>
<div class="header-controls"> <div class="header-controls">
<basic-button @click="createReport" icon="file">Create report</basic-button> <basic-button @click="createReport" icon="file">Create report</basic-button>
<basic-button :disabled="!hasReport" variant="secondary" @click="downloadReport" icon="Download">Export</basic-button> <basic-button :disabled="!hasReport" variant="secondary" @click="downloadReport" icon="Download">Export
</basic-button>
</div> </div>
</div> </div>
@ -20,7 +26,8 @@
</div> </div>
<div v-else-if="hasReport"> <div v-else-if="hasReport">
<box> <box>
<report v-for="report in reports" :key="report.id" :report="report" :chart-scale="chartScale"></report> <report v-for="report in reports" :key="report.id" :report="report" :chart-scale="chartScale"
:route-section-scale="routeSectionScale"></report>
</box> </box>
</div> </div>
<div v-else class="empty-container"> <div v-else class="empty-container">
@ -65,6 +72,20 @@ export default {
hasReport() { hasReport() {
return this.reportsStore.reports?.length > 0; return this.reportsStore.reports?.length > 0;
}, },
routeSectionScale() {
const reports = this.reportsStore.reports;
const scale = new Array(reports.map(r => r.premises.length).reduce((max, n) => Math.max(n, max), 0)).fill(0);
for (let i = 0; i < scale.length; i++) {
for (const report of reports) {
if(report.premises.length > i) {
scale[i] = Math.max(scale[i], report.premises[i].sections.length);
}
}
}
return scale.map(s => (s+1)*4);
},
reports() { reports() {
return this.reportsStore.reports return this.reportsStore.reports
}, },
@ -75,19 +96,19 @@ export default {
return this.reportsStore.getChartScale; return this.reportsStore.getChartScale;
}, },
partNumber() { partNumber() {
if(!this.hasReport) return null; if (!this.hasReport) return null;
return this.reportsStore.reports[0].material.part_number; return this.reportsStore.reports[0].material.part_number;
}, },
period() { period() {
if(!this.hasReport) return null; if (!this.hasReport) return null;
const start = this.reportsStore.reports[0].start_date; const start = this.reportsStore.reports[0].start_date;
const end = this.reportsStore.reports[0].end_date; const end = this.reportsStore.reports[0].end_date;
if(end === null) { if (end === null) {
return `Validity period: since ${this.buildDate(start)}` ; return `Validity period: since ${this.buildDate(start)}`;
} }
return `Validity period: ${this.buildDate(start)} ${this.buildDate(end)}` ; return `Validity period: ${this.buildDate(start)} ${this.buildDate(end)}`;
} }
}, },
methods: { methods: {

View file

@ -65,7 +65,7 @@ public class CalculationJobRepository {
public Optional<CalculationJob> getCalculationJobWithJobStateValid(Integer periodId, Integer nodeId, Integer materialId) { public Optional<CalculationJob> getCalculationJobWithJobStateValid(Integer periodId, Integer nodeId, Integer materialId) {
/* there should only be one job per period id, node id and material id combination */ /* there should only be one job per period id, node id and material id combination */
String query = "SELECT * FROM calculation_job AS cj INNER JOIN premise AS p ON cj.premise_id = p.id WHERE job_state = 'VALID' AND validity_period_id = ? AND p.supplier_node_id = ? AND material_id = ? LIMIT 1"; String query = "SELECT * FROM calculation_job AS cj INNER JOIN premise AS p ON cj.premise_id = p.id WHERE job_state = 'VALID' AND validity_period_id = ? AND p.supplier_node_id = ? AND material_id = ? ORDER BY cj.calculation_date DESC LIMIT 1";
var job = jdbcTemplate.query(query, new CalculationJobMapper(), periodId, nodeId, materialId); var job = jdbcTemplate.query(query, new CalculationJobMapper(), periodId, nodeId, materialId);