optimized reason for slot difference
This commit is contained in:
@ -23,7 +23,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'de.jottyfan:timetrackjooq:20240104b'
|
||||
implementation 'de.jottyfan:timetrackjooq:20240105'
|
||||
|
||||
implementation 'org.apache.logging.log4j:log4j-api:latest.release'
|
||||
implementation 'org.apache.logging.log4j:log4j-core:latest.release'
|
||||
|
@ -23,6 +23,7 @@ import org.jooq.InsertOnDuplicateSetMoreStep;
|
||||
import org.jooq.InsertOnDuplicateStep;
|
||||
import org.jooq.Record1;
|
||||
import org.jooq.Record3;
|
||||
import org.jooq.Record4;
|
||||
import org.jooq.Record5;
|
||||
import org.jooq.SelectConditionStep;
|
||||
import org.jooq.SelectHavingStep;
|
||||
@ -160,11 +161,11 @@ public class DoneRepository {
|
||||
}
|
||||
|
||||
public Map<LocalDate, SlotBean> getSlots(LocalDate from, LocalDate until, String login) {
|
||||
SelectSeekStep1<Record3<Integer, LocalDate, Integer>, LocalDate> sql = jooq
|
||||
SelectSeekStep1<Record4<Integer, LocalDate, String, Integer>, LocalDate> sql = jooq
|
||||
// @formatter:off
|
||||
.select(T_REQUIRED_WORKTIME.PK_REQUIRED_WORKTIME,
|
||||
T_REQUIRED_WORKTIME.DAY,
|
||||
// T_REQUIRED_WORKTIME.REASON,
|
||||
T_REQUIRED_WORKTIME.REASON,
|
||||
T_REQUIRED_WORKTIME.REQUIRED_MINUTES)
|
||||
.from(T_REQUIRED_WORKTIME)
|
||||
.innerJoin(T_LOGIN).on(T_LOGIN.PK.eq(T_REQUIRED_WORKTIME.FK_LOGIN))
|
||||
@ -174,14 +175,14 @@ public class DoneRepository {
|
||||
.orderBy(T_REQUIRED_WORKTIME.DAY);
|
||||
// @formatter:on
|
||||
LOGGER.trace(sql);
|
||||
Iterator<Record3<Integer, LocalDate, Integer>> i = sql.fetch().iterator();
|
||||
Iterator<Record4<Integer, LocalDate, String, Integer>> i = sql.fetch().iterator();
|
||||
Map<LocalDate, SlotBean> map = new HashMap<>();
|
||||
while (i.hasNext()) {
|
||||
Record3<Integer, LocalDate, Integer> n = i.next();
|
||||
Record4<Integer, LocalDate, String, Integer> n = i.next();
|
||||
LocalDate day = n.get(T_REQUIRED_WORKTIME.DAY);
|
||||
Integer pk = n.get(T_REQUIRED_WORKTIME.PK_REQUIRED_WORKTIME);
|
||||
Integer minutes = n.get(T_REQUIRED_WORKTIME.REQUIRED_MINUTES);
|
||||
String reason = null; // n.get(T_REQUIRED_WORKTIME.REASON);
|
||||
String reason = n.get(T_REQUIRED_WORKTIME.REASON);
|
||||
map.put(day, SlotBean.of(pk, day, minutes, reason));
|
||||
}
|
||||
return map;
|
||||
@ -195,11 +196,11 @@ public class DoneRepository {
|
||||
* @return the slot or null
|
||||
*/
|
||||
public SlotBean getSlot(Integer id, String login) {
|
||||
SelectConditionStep<Record3<Integer, LocalDate, Integer>> sql = jooq
|
||||
SelectConditionStep<Record4<Integer, LocalDate, String, Integer>> sql = jooq
|
||||
// @formatter:off
|
||||
.select(T_REQUIRED_WORKTIME.PK_REQUIRED_WORKTIME,
|
||||
T_REQUIRED_WORKTIME.DAY,
|
||||
// T_REQUIRED_WORKTIME.REASON,
|
||||
T_REQUIRED_WORKTIME.REASON,
|
||||
T_REQUIRED_WORKTIME.REQUIRED_MINUTES)
|
||||
.from(T_REQUIRED_WORKTIME)
|
||||
.innerJoin(T_LOGIN).on(T_LOGIN.PK.eq(T_REQUIRED_WORKTIME.FK_LOGIN))
|
||||
@ -207,10 +208,10 @@ public class DoneRepository {
|
||||
.and(T_REQUIRED_WORKTIME.PK_REQUIRED_WORKTIME.eq(id));
|
||||
// @formatter:on
|
||||
LOGGER.trace(sql);
|
||||
Record3<Integer, LocalDate, Integer> r = sql.fetchOne();
|
||||
Record4<Integer, LocalDate, String, Integer> r = sql.fetchOne();
|
||||
return r == null ? null
|
||||
: SlotBean.of(r.get(T_REQUIRED_WORKTIME.PK_REQUIRED_WORKTIME), r.get(T_REQUIRED_WORKTIME.DAY),
|
||||
r.get(T_REQUIRED_WORKTIME.REQUIRED_MINUTES), null/*r.get(T_REQUIRED_WORKTIME.REASON)*/);
|
||||
r.get(T_REQUIRED_WORKTIME.REQUIRED_MINUTES), r.get(T_REQUIRED_WORKTIME.REASON));
|
||||
}
|
||||
|
||||
public void addSlot(SlotBean bean, String login) {
|
||||
@ -219,16 +220,16 @@ public class DoneRepository {
|
||||
.insertInto(T_REQUIRED_WORKTIME,
|
||||
T_REQUIRED_WORKTIME.DAY,
|
||||
T_REQUIRED_WORKTIME.REQUIRED_MINUTES,
|
||||
// T_REQUIRED_WORKTIME.REASON,
|
||||
T_REQUIRED_WORKTIME.REASON,
|
||||
T_REQUIRED_WORKTIME.FK_LOGIN)
|
||||
.select(jooq
|
||||
.select(DSL.val(bean.getDay()), DSL.val(bean.getMinutes()), /* DSL.val(bean.getReason()), */ T_LOGIN.PK)
|
||||
.select(DSL.val(bean.getDay()), DSL.val(bean.getMinutes()), DSL.val(bean.getReason()), T_LOGIN.PK)
|
||||
.from(T_LOGIN)
|
||||
.where(T_LOGIN.LOGIN.eq(login)))
|
||||
.onConflict(T_REQUIRED_WORKTIME.FK_LOGIN, T_REQUIRED_WORKTIME.DAY)
|
||||
.doUpdate()
|
||||
.set(T_REQUIRED_WORKTIME.REQUIRED_MINUTES, bean.getMinutes());
|
||||
// .set(T_REQUIRED_WORKTIME.REASON, bean.getReason());
|
||||
.set(T_REQUIRED_WORKTIME.REQUIRED_MINUTES, bean.getMinutes())
|
||||
.set(T_REQUIRED_WORKTIME.REASON, bean.getReason());
|
||||
// @formatter:off
|
||||
LOGGER.trace(sql);
|
||||
sql.execute();
|
||||
@ -239,7 +240,7 @@ public class DoneRepository {
|
||||
// @formatter:off
|
||||
.update(T_REQUIRED_WORKTIME)
|
||||
.set(T_REQUIRED_WORKTIME.REQUIRED_MINUTES, bean.getMinutes())
|
||||
// .set(T_REQUIRED_WORKTIME.REASON, bean.getReason())
|
||||
.set(T_REQUIRED_WORKTIME.REASON, bean.getReason())
|
||||
.where(T_REQUIRED_WORKTIME.PK_REQUIRED_WORKTIME.eq(bean.getId()))
|
||||
.and(T_REQUIRED_WORKTIME.FK_LOGIN.in(jooq
|
||||
.select(T_LOGIN.PK)
|
||||
|
@ -265,7 +265,7 @@
|
||||
</a><a th:href="@{/done/slot/add?day={d}(d=${s.day})}" class="slot_badge_middle" th:unless="${s.id}">
|
||||
<i class="fas fa-plus"></i>
|
||||
</a>
|
||||
<span class="slot_badge_middle slot_reason" th:if="${s.reason}" th:text="${s.reason}"></span><span class="slot_badge_right boldy" th:text="${s.printTime()}" th:if="${s.id}"></span><span
|
||||
<span class="slot_badge_middle slot_reason" th:if="${s.reason}" th:text="${s.reason}"></span><span th:class="${s.reason != null ? 'slot_badge_right' : 'slot_badge_right boldy'}" th:text="${s.printTime()}" th:if="${s.id}"></span><span
|
||||
class="slot_badge_right" th:unless="${s.id}"> --:-- </span>
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user