Summary Report + Import Map Bugfixes
This commit is contained in:
parent
c261652ce6
commit
f4e9b16792
@ -37,13 +37,14 @@ public class Exporter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Führt den Imput aus -> File holen, Daten in db erstellen
|
* Führt den Imput aus -> File holen, Daten in db erstellen
|
||||||
* @throws FileNotFoundException Fehler beim File öffnen
|
* @throws IOException Fehler beim File öffnen
|
||||||
*/
|
*/
|
||||||
public void doImport() throws FileNotFoundException {
|
public void doImport() throws IOException {
|
||||||
this.touren = JsonHelper.getTourenFromJson(new FileReader(this.path));
|
this.touren = JsonHelper.getTourenFromJson(new FileReader(this.path));
|
||||||
DbConnect dbConnect = new DbConnect();
|
DbConnect dbConnect = new DbConnect();
|
||||||
dbConnect.delAllData();
|
dbConnect.delAllData();
|
||||||
for (Tour tour:this.touren) {
|
for (Tour tour:this.touren) {
|
||||||
|
new DirectionMap(tour.getStart(), tour.getZiel(), tour.getName());
|
||||||
dbConnect.addTour(tour);
|
dbConnect.addTour(tour);
|
||||||
ArrayList<Log> logs = tour.getLogs();
|
ArrayList<Log> logs = tour.getLogs();
|
||||||
for (Log log:logs) {
|
for (Log log:logs) {
|
||||||
|
@ -3,6 +3,7 @@ package tourplaner.business;
|
|||||||
import com.itextpdf.text.*;
|
import com.itextpdf.text.*;
|
||||||
import com.itextpdf.text.Font;
|
import com.itextpdf.text.Font;
|
||||||
import com.itextpdf.text.Image;
|
import com.itextpdf.text.Image;
|
||||||
|
import tourplaner.data.DbConnect;
|
||||||
import tourplaner.object.Log;
|
import tourplaner.object.Log;
|
||||||
import tourplaner.object.Tour;
|
import tourplaner.object.Tour;
|
||||||
|
|
||||||
@ -36,6 +37,59 @@ public class Reporter {
|
|||||||
private static Font smallBold = new Font(Font.TIMES_ROMAN, 12,
|
private static Font smallBold = new Font(Font.TIMES_ROMAN, 12,
|
||||||
Font.BOLD);
|
Font.BOLD);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Erstellt den Summary Report
|
||||||
|
*/
|
||||||
|
public static void sumReport(){
|
||||||
|
ArrayList<Tour> tours = TourPlaner.getAllTours();
|
||||||
|
String file = ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "report", "path") + "summary.pdf";
|
||||||
|
try {
|
||||||
|
Document document = new Document();
|
||||||
|
PdfWriter.getInstance(document, new FileOutputStream(file));
|
||||||
|
document.open();
|
||||||
|
addSumRepo(document, tours);
|
||||||
|
|
||||||
|
document.close();
|
||||||
|
} catch (DocumentException | FileNotFoundException e) {
|
||||||
|
LogHelper.error(e.getMessage(), e.getClass().getName());
|
||||||
|
}
|
||||||
|
FileHelper.openDefault(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Content des Sumary reports
|
||||||
|
* @param document Document auf das geschrieben wird
|
||||||
|
* @param touren Touren die berechnet werden
|
||||||
|
* @throws DocumentException Fehler beim schreiben auf das Dokument
|
||||||
|
*/
|
||||||
|
private static void addSumRepo(Document document, ArrayList<Tour> touren) throws DocumentException {
|
||||||
|
double dauer = 0;
|
||||||
|
double strecke = 0;
|
||||||
|
double calDauer = 0;
|
||||||
|
double calStecke = 0;
|
||||||
|
for (Tour tour:touren) {
|
||||||
|
calStecke += tour.getStrecke();
|
||||||
|
calDauer += Double.parseDouble(tour.getDauer());
|
||||||
|
ArrayList<Log> logs = tour.getLogs();
|
||||||
|
for (Log log:logs) {
|
||||||
|
dauer += log.getDauer();
|
||||||
|
strecke += log.getStrecke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Anchor anchor = new Anchor("Zusammengefasster Report", catFont);
|
||||||
|
anchor.setName("Zusammengefasster Report");
|
||||||
|
// Second parameter is the number of the chapter
|
||||||
|
Chapter catPart = new Chapter(new Paragraph(anchor), 1);
|
||||||
|
Paragraph subPara = new Paragraph("Daten", subFont);
|
||||||
|
Section subCatPart = catPart.addSection(subPara);
|
||||||
|
subCatPart.add(new Paragraph(ConfigHelper.getLangIniString("reportvon") + System.getProperty("user.name") + ", " + new Date()));
|
||||||
|
subCatPart.add(new Paragraph("Gesammte Zeit aller Logs: " + dauer));
|
||||||
|
subCatPart.add(new Paragraph("gesammte Strecke aller Logs: " + strecke));
|
||||||
|
subCatPart.add(new Paragraph("Berechnete Zeit aller Logs: " + calDauer));
|
||||||
|
subCatPart.add(new Paragraph("Berechnete Strecke aller Touren: " + calStecke));
|
||||||
|
document.add(catPart);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Erstellt einen Tour Report
|
* Erstellt einen Tour Report
|
||||||
* @param tourname Name der Tour die Gereportet werden soll
|
* @param tourname Name der Tour die Gereportet werden soll
|
||||||
|
@ -175,13 +175,4 @@ public class TourPlaner{
|
|||||||
FileHelper.openDefault(path);
|
FileHelper.openDefault(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Importiert daten
|
|
||||||
* @param path Path zu den Daten
|
|
||||||
* @throws FileNotFoundException File konnte nicht geöffnet werden
|
|
||||||
*/
|
|
||||||
public static void importData(String path) throws FileNotFoundException {
|
|
||||||
Exporter exporter = new Exporter(path);
|
|
||||||
exporter.doImport();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -52,12 +52,12 @@
|
|||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" onAction="#importBtn" text="Import" />
|
<MenuItem mnemonicParsing="false" onAction="#importBtn" text="Import" />
|
||||||
<MenuItem mnemonicParsing="false" onAction="#exportBtn" text="Export" />
|
<MenuItem mnemonicParsing="false" onAction="#exportBtn" text="Export" />
|
||||||
<MenuItem mnemonicParsing="false" onAction="#nimpButton" text="Keine Funktion" />
|
<MenuItem mnemonicParsing="false" onAction="#reportSum" text="Report alles" />
|
||||||
|
<MenuItem mnemonicParsing="false" onAction="#tourReport" text="Tour Report erstellen" />
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu mnemonicParsing="false" text="Optionen">
|
<Menu mnemonicParsing="false" text="Optionen">
|
||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" onAction="#tourReport" text="Tour Report erstellen" />
|
|
||||||
<MenuItem mnemonicParsing="false" onAction="#nimpButton" text="Keine Funktion" />
|
<MenuItem mnemonicParsing="false" onAction="#nimpButton" text="Keine Funktion" />
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
@ -230,17 +230,22 @@ public class TourplanerController implements Initializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void exportBtn(){
|
private void exportBtn(){
|
||||||
this.viewModel.exportData();
|
this.viewModel.exportData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void importBtn(){
|
private void importBtn(){
|
||||||
deselectAll();
|
deselectAll();
|
||||||
this.viewModel.importData();
|
this.viewModel.importData();
|
||||||
syncTourNamen();
|
syncTourNamen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private void reportSum(){
|
||||||
|
this.viewModel.sumReport();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Funktion für noch nicht implementierte sachen wie im Menu der 'Bearbeiten' und 'Optionen' Knopf
|
* Funktion für noch nicht implementierte sachen wie im Menu der 'Bearbeiten' und 'Optionen' Knopf
|
||||||
*/
|
*/
|
||||||
|
@ -3,11 +3,8 @@ package tourplaner.viewmodels;
|
|||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import tourplaner.business.Exporter;
|
import tourplaner.business.*;
|
||||||
import tourplaner.business.TourPlaner;
|
|
||||||
import tourplaner.ui.AlertHelper;
|
import tourplaner.ui.AlertHelper;
|
||||||
import tourplaner.business.ConfigHelper;
|
|
||||||
import tourplaner.business.LogHelper;
|
|
||||||
import tourplaner.object.Log;
|
import tourplaner.object.Log;
|
||||||
import tourplaner.object.Tour;
|
import tourplaner.object.Tour;
|
||||||
|
|
||||||
@ -604,17 +601,24 @@ public class ViewModel {
|
|||||||
/**
|
/**
|
||||||
* Importiert alle daten von einem File das hier gewählt wird
|
* Importiert alle daten von einem File das hier gewählt wird
|
||||||
*/
|
*/
|
||||||
public void importData(){
|
public void importData() {
|
||||||
String file = AlertHelper.fileChooser("Importiere");
|
String file = AlertHelper.fileChooser("Importiere");
|
||||||
System.out.println("IMPORT: " + file);
|
System.out.println("IMPORT: " + file);
|
||||||
if (file != null){
|
if (file != null){
|
||||||
try {
|
try {
|
||||||
this.tourNamen = FXCollections.observableArrayList();
|
this.tourNamen = FXCollections.observableArrayList();
|
||||||
new Exporter(file).doImport();
|
new Exporter(file).doImport();
|
||||||
} catch (FileNotFoundException e) {
|
} catch (IOException e) {
|
||||||
AlertHelper.error("Error", "Import Error", "Fehler beim Importieren");
|
AlertHelper.error("Error", "Import Error", "Fehler beim Importieren");
|
||||||
LogHelper.error(e);
|
LogHelper.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Erstellt einen Summary Report
|
||||||
|
*/
|
||||||
|
public void sumReport(){
|
||||||
|
Reporter.sumReport();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user