export optimization

This commit is contained in:
Jottyfan
2023-10-21 21:46:22 +02:00
parent e0e972cfe8
commit 3dd39751af
4 changed files with 15 additions and 9 deletions

View File

@ -8,7 +8,7 @@ plugins {
}
group = 'de.jottyfan.camporganizer'
version = '0.6.1'
version = '0.6.2'
description = """CampOrganizer2"""

View File

@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import de.jottyfan.camporganizer.db.jooq.enums.EnumModule;
import de.jottyfan.camporganizer.db.jooq.enums.EnumSex;
import de.jottyfan.camporganizer.module.confirmation.board.model.CampBean;
import de.jottyfan.camporganizer.module.confirmation.board.model.PersonBean;
import de.jottyfan.camporganizer.module.confirmation.confirmation.ConfirmationRepository;
@ -98,7 +99,7 @@ public class ConfirmationBoardRepository {
bean.setForename(r.get(T_PERSON.FORENAME));
bean.setPaid(r.get(T_PERSON.PAID) == null ? null : r.get(T_PERSON.PAID).doubleValue());
bean.setPhone(r.get(T_PERSON.PHONE));
bean.setSex(r.get(T_PERSON.SEX) == null ? null : r.get(T_PERSON.SEX).getLiteral());
bean.setSex(r.get(T_PERSON.SEX) == null ? null : (r.get(T_PERSON.SEX).equals(EnumSex.male) ? "männlich" : "weiblich"));
bean.setStreet(r.get(T_PERSON.STREET));
bean.setSurname(r.get(T_PERSON.SURNAME));
bean.setZip(r.get(T_PERSON.ZIP));

View File

@ -17,14 +17,14 @@ import de.jottyfan.camporganizer.module.confirmation.board.model.PersonBean;
@Service
public class List2CSVService {
private static final String QUOTE = "\"";
private static final String SEP = ",";
private static final String SEP = ";";
private StringBuilder append(StringBuilder buf, String s) {
return buf.append(s == null || s.isEmpty() ? SEP : String.format("%s%s%s%s", QUOTE, s, QUOTE, SEP));
}
private StringBuilder append(StringBuilder buf, Double d) {
return buf.append(d == null ? SEP : String.format("%s%s%s%s", QUOTE, d.toString(), QUOTE, SEP));
return buf.append(d == null ? SEP : String.format("%.2f%s", d, SEP));
}
private StringBuilder append(StringBuilder buf, Boolean b) {
@ -32,16 +32,21 @@ public class List2CSVService {
}
private StringBuilder append(StringBuilder buf, LocalDateTime l) {
return buf.append(l == null ? SEP : String.format("%s%s%s%s", QUOTE, l.format(DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm")), QUOTE, SEP));
return buf.append(l == null ? SEP
: String.format("%s%s%s%s", QUOTE, l.format(DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm")), QUOTE, SEP));
}
private StringBuilder append(StringBuilder buf, LocalDate l) {
return buf.append(l == null ? SEP : String.format("%s%s%s%s", QUOTE, l.format(DateTimeFormatter.ofPattern("dd.MM.yyyy")), QUOTE, SEP));
return buf.append(l == null ? SEP
: String.format("%s%s%s%s", QUOTE, l.format(DateTimeFormatter.ofPattern("dd.MM.yyyy")), QUOTE, SEP));
}
public String toCsv(List<PersonBean> list) {
StringBuilder buf = new StringBuilder();
buf.append("Bezahlt,Vorname,Nachname,Strasse,PLZ,Ort,Telefon,Email,Geschlecht,Rolle,Geburtsdatum,Anmeldestatus,Anmeldedatum,Fotoeinverständnis,Kommentar\n");
String title = String.format(
"Bezahlt%sVorname%sNachname%sStrasse%sPLZ%sOrt%sTelefon%sEmail%sGeschlecht%sRolle%sGeburtsdatum%sAnmeldestatus%sAnmeldedatum%sFotoeinverständnis%sKommentar\n",
SEP, SEP, SEP, SEP, SEP, SEP, SEP, SEP, SEP, SEP, SEP, SEP, SEP, SEP);
buf.append(title);
for (PersonBean bean : list) {
append(buf, bean.getPaid());
append(buf, bean.getForename());
@ -52,7 +57,7 @@ public class List2CSVService {
append(buf, bean.getPhone());
append(buf, bean.getEmail());
append(buf, bean.getSex());
append(buf, bean.getCamprole());
append(buf, bean.getCamprolle());
append(buf, bean.getBirthDate());
append(buf, bean.getAccept());
append(buf, bean.getCreated());

View File

@ -35,7 +35,7 @@
<td><div th:text="${p.street}"></div> <span th:text="${p.zip}"></span>&nbsp;<span th:text="${p.city}"></span></td>
<td><div th:text="'Tel.: ' + ${p.phone}"></div>
<div th:text="${p.email}"></div></td>
<td><div th:text="${p.sex == 'male' ? 'männlich' : 'weiblich'}"></div>
<td><div th:text="${p.sex}"></div>
<div th:text="${p.camprolle}"></div></td>
<td><div th:text="${#temporals.format(p.birthDate, 'dd.MM.yyyy')}"></div>
<div th:text="${p.getAge(campStartDate)} + ' Jahre'"></div></td>