Как отслеживать обновленные значения в строке таблицы тимелина и обновлять только эти значения в базе данных, а не просматривать все записи? - PullRequest
0 голосов
/ 24 марта 2020

У меня есть приложение Spring Boot с табличным дисплеем в пользовательском интерфейсе (тимилеф). В настоящее время сталкивается с проблемой тайм-аута 504. При отправке значений таблицы в форме.

Вот структура таблицы в тимелице:

enter image description here

Вот соответствующий код тимелина для таблицы:

<form method="post" action="/mktsupply" th:object="${allocationReportForm}">
<table class="datatable table table-striped table-bordered">
        <thead>
        <tr>
            <th>Allocation Report</th>
        </tr>
        <tr>
            <th> Current Week </th>
            <th> Product </th>
            <th> Market </th>
            <th> Original Demand </th>
            <th> Balance Demand </th>
            <th> Allocation Week Number </th>
            <th> Demand Allocation </th>
        </tr>
        </thead>
        <tr th:each="allocationReportDTO,iteration : *{allocationReportDTOList}">
            <td style="background-color:yellow"><input type="text" th:field="*{allocationReportDTOList[__${iteration.index}__].week}" readonly/></td>
            <td style="background-color:yellow"><input type="text" th:field="*{allocationReportDTOList[__${iteration.index}__].product}" readonly/></td>
            <td style="background-color:yellow"><input type="text" th:field="*{allocationReportDTOList[__${iteration.index}__].market}" readonly/></td>
            <td style="background-color:yellow"><input type="text" th:field="*{allocationReportDTOList[__${iteration.index}__].originalDemand}" readonly/></td>
            <td style="background-color:green"><input type="text" th:field="*{allocationReportDTOList[__${iteration.index}__].balanceDemand}" readonly/></td>
            <td style="background-color:yellow">
                <span th:each="entry : ${allocationReportDTO.weekWiseAllocation}">
                        <input type="text" th:value="${entry.key}" readonly/>
                </span>
            </td>
            <td style="background-color:#00FFFF">
                <span th:each="entry : ${allocationReportDTO.weekWiseAllocation}">
                    <input type="number" step="1" th:field="*{allocationReportDTOList[__${iteration.index}__].weekWiseAllocation[__${entry.key}__]}"/>
                </span>
            </td>
        </tr>
    </table>
    </form>

После отправки form POST я выполняю следующие операции:

  • Обновление 3 таблиц для значений в every single row в стол. ( это то место, где я хочу оптимизировать )
  • Перезагрузка 3 разных представлений на одной странице после обновления (выборка таблиц).

Вот DTO класс:

public class AllocationReportDTO {

private String week;
private String product;
private String market;
private int originalDemand;
private int balanceDemand;
private Map<String,Integer> weekWiseAllocation;
private int totalDemandAllocation;

public String getWeek() {
    return week;
}

public void setWeek(String week) {
    this.week = week;
}

public String getProduct() {
    return product;
}

public void setProduct(String product) {
    this.product = product;
}


public String getMarket() {
    return market;
}

public void setMarket(String market) {
    this.market = market;
}

public int getOriginalDemand() {
    return originalDemand;
}

public void setOriginalDemand(int originalDemand) {
    this.originalDemand = originalDemand;
}

public int getBalanceDemand() {
    return balanceDemand;
}

public void setBalanceDemand(int balanceDemand) {
    this.balanceDemand = balanceDemand;
}

public Map<String, Integer> getWeekWiseAllocation() {
    return weekWiseAllocation;
}

public void setWeekWiseAllocation(Map<String, Integer> weekWiseAllocation) {
    this.weekWiseAllocation = weekWiseAllocation;
}

Приложение будет работать нормально, если у меня есть тестовые данные с несколькими строками. Проблема возникает, когда я загружаю большие данные в базу данных. Приложение дает 504 времени ожидания шлюза для больших данных. Возможная проблема заключается в огромном количестве операций обновления, идущих в базу данных.

Я хотел бы свести к минимуму количество операций (обновление / повторение), чтобы избавиться от этой проблемы. Здесь возникает проблема с отслеживанием «только» тех строк, которые обновляются пользователем. Например, скажем, пользователь изменил значение W14 с «8» на «5» в первом ряду (см. Скриншот выше), тогда я должен сделать только одну операцию обновления вместо обновления всех значений с W14 до W25.

Как нам этого добиться?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...