added dynamic scaling for route section heights in reports and adjusted query ordering for calculation jobs
This commit is contained in:
parent
01125fc875
commit
d997178d00
4 changed files with 42 additions and 13 deletions
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<div class="route-container">
|
||||
<div class="route-container" :style="{height: routeSectionScale + 'rem'}">
|
||||
<div class="route">
|
||||
<div class="route-section" v-for="section in sections" :key="section.id">
|
||||
<div class="route-section-line"></div>
|
||||
|
|
@ -55,6 +55,10 @@ export default {
|
|||
name: 'ReportRoute',
|
||||
components: {PhArrowRight, PhCaretDoubleRight, PhCaretRight, PhTruck, PhTruckTrailer, PhTrain, PhBoat},
|
||||
props: {
|
||||
routeSectionScale: {
|
||||
type: Number,
|
||||
default: 20
|
||||
},
|
||||
sections: {
|
||||
type: Array,
|
||||
required: true,
|
||||
|
|
@ -73,7 +77,7 @@ export default {
|
|||
<style scoped>
|
||||
.route-container {
|
||||
padding: 20px;
|
||||
min-height: 20rem;
|
||||
height: 20rem
|
||||
}
|
||||
|
||||
.route {
|
||||
|
|
|
|||
|
|
@ -138,12 +138,12 @@
|
|||
</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"
|
||||
:stretch-content="true" :initially-collapsed="true">
|
||||
<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>
|
||||
|
||||
|
|
@ -258,6 +258,10 @@ export default {
|
|||
chartScale: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
routeSectionScale: {
|
||||
type: Array,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,16 @@
|
|||
<template>
|
||||
<div>
|
||||
<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">
|
||||
<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>
|
||||
|
||||
|
|
@ -20,7 +26,8 @@
|
|||
</div>
|
||||
<div v-else-if="hasReport">
|
||||
<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>
|
||||
</div>
|
||||
<div v-else class="empty-container">
|
||||
|
|
@ -65,6 +72,20 @@ export default {
|
|||
hasReport() {
|
||||
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() {
|
||||
return this.reportsStore.reports
|
||||
},
|
||||
|
|
@ -75,19 +96,19 @@ export default {
|
|||
return this.reportsStore.getChartScale;
|
||||
},
|
||||
partNumber() {
|
||||
if(!this.hasReport) return null;
|
||||
if (!this.hasReport) return null;
|
||||
return this.reportsStore.reports[0].material.part_number;
|
||||
},
|
||||
period() {
|
||||
if(!this.hasReport) return null;
|
||||
if (!this.hasReport) return null;
|
||||
const start = this.reportsStore.reports[0].start_date;
|
||||
const end = this.reportsStore.reports[0].end_date;
|
||||
|
||||
if(end === null) {
|
||||
return `Validity period: since ${this.buildDate(start)}` ;
|
||||
if (end === null) {
|
||||
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: {
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public class CalculationJobRepository {
|
|||
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 */
|
||||
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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue