aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/ru/mrfoxygmfr/warehouse_accounting/http/controllers/StorageSlotsController.java96
-rw-r--r--src/main/resources/templates/storageSlotEdit.html39
-rw-r--r--src/main/resources/templates/storageSlots.html82
3 files changed, 217 insertions, 0 deletions
diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/http/controllers/StorageSlotsController.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/http/controllers/StorageSlotsController.java
new file mode 100644
index 0000000..2a9b28e
--- /dev/null
+++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/http/controllers/StorageSlotsController.java
@@ -0,0 +1,96 @@
+package ru.mrfoxygmfr.warehouse_accounting.http.controllers;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import ru.mrfoxygmfr.warehouse_accounting.db.dao.*;
+import ru.mrfoxygmfr.warehouse_accounting.db.dao.specs.StorageSlotSpecs;
+import ru.mrfoxygmfr.warehouse_accounting.db.models.*;
+
+import java.util.List;
+
+@Controller
+public class StorageSlotsController {
+ @Autowired
+ private StorageSlotDAO storageSlotDAO;
+
+ @GetMapping("storageSlots")
+ public String storageSlots(@RequestParam(name = "storageSlotHeightLess", required = false) Integer heightLess,
+ @RequestParam(name = "storageSlotHeightGreater", required = false) Integer heightGreater,
+ @RequestParam(name = "storageSlotWidthLess", required = false) Integer widthLess,
+ @RequestParam(name = "storageSlotWidthGreater", required = false) Integer widthGreater,
+ @RequestParam(name = "storageSlotDepthLess", required = false) Integer depthLess,
+ @RequestParam(name = "storageSlotDepthGreater", required = false) Integer depthGreater,
+ Model model) {
+ Specification<StorageSlot> spec = Specification.where(null);
+ if (heightLess != null) {
+ spec = spec.and(StorageSlotSpecs.storageSlotHeightLess(heightLess));
+ model.addAttribute("storageSlotHeightLessFilter", heightLess);
+ }
+ if (heightGreater != null) {
+ spec = spec.and(StorageSlotSpecs.storageSlotHeightGreater(heightGreater));
+ model.addAttribute("storageSlotHeightGreaterFilter", heightGreater);
+ }
+ if (widthLess != null) {
+ spec = spec.and(StorageSlotSpecs.storageSlotWidthLess(widthLess));
+ model.addAttribute("storageSlotWidthLessFilter", widthLess);
+ }
+ if (widthGreater != null) {
+ spec = spec.and(StorageSlotSpecs.storageSlotWidthGreater(widthGreater));
+ model.addAttribute("storageSlotWidthGreaterFilter", widthGreater);
+ }
+ if (depthLess != null) {
+ spec = spec.and(StorageSlotSpecs.storageSlotDepthLess(depthLess));
+ model.addAttribute("storageSlotDepthLessFilter", depthLess);
+ }
+ if (depthGreater != null) {
+ spec = spec.and(StorageSlotSpecs.storageSlotDepthGreater(depthGreater));
+ model.addAttribute("storageSlotDepthGreaterFilter", depthGreater);
+ }
+
+ List<StorageSlot> storageSlots = storageSlotDAO.findAll(spec);
+ model.addAttribute("storageSlots", storageSlots);
+ return "storageSlots";
+ }
+
+ @GetMapping("storageSlot")
+ public String storageSlot(@RequestParam(name = "id") Integer id, Model model) {
+ StorageSlot storageSlot = storageSlotDAO.findById(id).orElseThrow();
+ model.addAttribute("storageSlot", storageSlot);
+ return "storageSlotEdit";
+ }
+
+
+ @PostMapping("storageSlot")
+ public String storageSlot(@RequestParam(name = "storageSlotId") Integer id,
+ @RequestParam(name = "storageSlotLocation") String location,
+ @RequestParam(name = "storageSlotHeight") Integer height,
+ @RequestParam(name = "storageSlotWidth") Integer width,
+ @RequestParam(name = "storageSlotDepth") Integer depth) {
+ StorageSlot storageSlot;
+ if (id == -1) {
+ storageSlot = new StorageSlot(location, height, width, depth);
+ } else {
+ storageSlot = storageSlotDAO.findById(id).orElseThrow();
+ storageSlot.setLocation(location);
+ storageSlot.setHeight(height);
+ storageSlot.setWidth(width);
+ storageSlot.setDepth(depth);
+ }
+ storageSlotDAO.save(storageSlot);
+ return "redirect:/storageSlots";
+ }
+
+ @GetMapping("newStorageSlot")
+ public String newStorageSlot(Model model) {
+ StorageSlot storageSlot = new StorageSlot();
+ storageSlot.setId(-1);
+ model.addAttribute("storageSlot", storageSlot);
+ model.addAttribute("newItem", true);
+ return "storageSlotEdit";
+ }
+}
diff --git a/src/main/resources/templates/storageSlotEdit.html b/src/main/resources/templates/storageSlotEdit.html
new file mode 100644
index 0000000..720a20a
--- /dev/null
+++ b/src/main/resources/templates/storageSlotEdit.html
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML>
+<html xmlns:th="http://www.thymeleaf.org" lang="en">
+<div th:replace="~{common :: head}"></div>
+
+<body>
+<div th:replace="~{common :: page-header}"></div>
+
+<div class="indent">
+ <div id="updateToggleSelector">
+ <button id="updateBtn" class="btn btn-primary" onclick="toggleDisabled()">Изменить</button> <br><br>
+ </div>
+
+ <form method="post" action="/storageSlot">
+ <input disabled hidden id="storageSlotId" name="storageSlotId" th:value="${storageSlot.getId()}">
+
+ <label for="storageSlotLocation">Локация:</label>
+ <input disabled type="text" id="storageSlotLocation" name="storageSlotLocation" required th:value="${storageSlot.getLocation()}"><br><br>
+
+ <label for="storageSlotHeight">Высота:</label>
+ <input disabled type="text" id="storageSlotHeight" name="storageSlotHeight" required th:value="${storageSlot.getHeight()}"><br><br>
+
+ <label for="storageSlotWidth">Ширина:</label>
+ <input disabled type="text" id="storageSlotWidth" name="storageSlotWidth" required th:value="${storageSlot.getWidth()}"><br><br>
+
+ <label for="storageSlotDepth">Глубина:</label>
+ <input disabled type="text" id="storageSlotDepth" name="storageSlotDepth" required th:value="${storageSlot.getDepth()}"><br><br>
+
+ <input id="saveBtn" type="submit" value="Сохранить" class="btn btn-primary" hidden>
+
+ </form>
+</div>
+
+
+<div th:replace="~{common :: site-footer}"></div>
+<div th:replace="~{common :: site-script}"></div>
+<div th:replace="~{common :: editFieldsToggle}"></div>
+
+</body>
+</html> \ No newline at end of file
diff --git a/src/main/resources/templates/storageSlots.html b/src/main/resources/templates/storageSlots.html
new file mode 100644
index 0000000..3f09ee6
--- /dev/null
+++ b/src/main/resources/templates/storageSlots.html
@@ -0,0 +1,82 @@
+<!DOCTYPE HTML>
+<html xmlns:th="http://www.thymeleaf.org" lang="en">
+<div th:replace="~{common :: head}"></div>
+
+<body>
+<div th:replace="~{common :: page-header}"></div>
+
+<div class="indent">
+ <form method="get" action="/newStorageSlot">
+ <button id="newOperationBtn" type="submit" class="btn btn-primary">Создать новую ячейку хранения</button>
+ </form>
+ <br>
+
+ <form method="get" action="/storageSlots">
+ <table class="table">
+ <thead class="theme-dark">
+ <tr>
+ <th colspan="6">Фильтры</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>Высота</td>
+ <td>
+ от <input type="text" id="storageSlotHeightGreaterFilter" name="storageSlotHeightGreater" th:value="${storageSlotHeightGreaterFilter}">
+ до <input type="text" id="storageSlotHeightLessFilter" name="storageSlotHeightLess" th:value="${storageSlotHeightLessFilter}">
+ </td>
+ </tr>
+ <tr>
+ <td>Ширина</td>
+ <td>
+ от <input type="text" id="storageSlotWidthGreaterFilter" name="storageSlotWidthGreater" th:value="${storageSlotWidthGreaterFilter}">
+ до <input type="text" id="storageSlotWidthLessFilter" name="storageSlotWidthLess" th:value="${storageSlotWidthLessFilter}">
+ </td>
+ </tr>
+ <tr>
+ <td>Глубина</td>
+ <td>
+ от <input type="text" id="storageSlotDepthGreaterFilter" name="storageSlotDepthGreater" th:value="${storageSlotDepthGreaterFilter}">
+ до <input type="text" id="storageSlotDepthLessFilter" name="storageSlotDepthLess" th:value="${storageSlotDepthLessFilter}">
+ </td>
+ </tr>
+ <tr>
+ <td colspan="6"><input id="saveBtn" type="submit" value="Применить" class="btn btn-primary"></td>
+ </tr>
+ </tbody>
+ </table>
+ </form>
+
+ <table class="table table-bordered table-warning">
+ <thead class="thead-dark">
+ <tr>
+ <th scope="col">ID</th>
+ <th scope="col">Локация</th>
+ <th scope="col">Габариты (В*Ш*Г)</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr th:if="${storageSlots.isEmpty()}">
+ <td colspan="6">Данному фильтру не удовлетворяет ни одного места хранения.</td>
+ </tr>
+ <tr th:each="storageSlot : ${storageSlots}">
+ <td>
+ <a th:href="'/storageSlot?id=' + ${storageSlot.getId()}">
+ <span th:text="${storageSlot.getId()}"></span>
+ </a>
+ </td>
+ <td>
+ <span th:text="${storageSlot.getLocation()}"></span>
+ </td>
+ <td>
+ <span th:text="${storageSlot.getHeight()} + ' * ' + ${storageSlot.getWidth()} + ' * ' + ${storageSlot.getDepth()}"></span>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+</div>
+
+<div th:replace="~{common :: site-footer}"></div>
+<div th:replace="~{common :: site-script}"></div>
+</body>
+</html> \ No newline at end of file