esoe
3 months ago
16 changed files with 436 additions and 98 deletions
@ -0,0 +1,20 @@ |
|||||||
|
package ru.mlokoin.gates.controller.v1; |
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Controller; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.reactive.function.client.WebClient; |
||||||
|
|
||||||
|
import ru.mlokoin.gates.repository.Storage; |
||||||
|
|
||||||
|
@Controller |
||||||
|
@RequestMapping(path = "/document/educations/info") |
||||||
|
public class InfoXlsxController { |
||||||
|
@Autowired |
||||||
|
private WebClient client; |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private Storage storage; |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,112 @@ |
|||||||
|
<!DOCTYPE HTML> |
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" |
||||||
|
xmlns:th="http://www.thymeleaf.org"> |
||||||
|
<head> |
||||||
|
<meta charset="utf-8"> |
||||||
|
<title>info-xlsx</title> |
||||||
|
<script src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs@2/webcomponents-loader.min.js"></script> |
||||||
|
<script type="module" src="https://cdn.jsdelivr.net/gh/zerodevx/zero-md@1/src/zero-md.min.js"></script> |
||||||
|
<style> |
||||||
|
caption { |
||||||
|
caption-side: top; |
||||||
|
text-align: left; |
||||||
|
/* padding-bottom: 10px; */ |
||||||
|
font-weight: bold; |
||||||
|
font-size: x-large; |
||||||
|
} |
||||||
|
</style> |
||||||
|
</head> |
||||||
|
|
||||||
|
<body> |
||||||
|
<header> |
||||||
|
|
||||||
|
</header> |
||||||
|
<main> |
||||||
|
<div class="doc-info"> |
||||||
|
<h2>DASHBOARD:</h2> |
||||||
|
<table rules="all"> |
||||||
|
<thead> |
||||||
|
<th><span>Параметр</span></th> |
||||||
|
<!-- <th>В файле: <span th:text="${filename}"></span></th> --> |
||||||
|
<th>В базе данных:</th> |
||||||
|
<!-- <th><span>отсутствующие в базе</span></th> --> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
<tr> |
||||||
|
<td> |
||||||
|
<a th:href="@{/program-cretareas/check/{id}(id=${id})}">Критерии:</a> |
||||||
|
</td> |
||||||
|
<!-- <td><span th:text="${xlsxReview.programCretareaCount}"></span></td> --> |
||||||
|
<td><span th:text="${baseReview.programCretareaCount}"></span></td> |
||||||
|
<!-- <td><span th:text="${absentReview.programCretareaCount}"></span></td> --> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td> |
||||||
|
<a th:href="@{/programs/check/{id}(id=${id})}">Программы:</a> |
||||||
|
</td> |
||||||
|
<!-- <td><span th:text="${xlsxReview.programsCount}"></span></td> --> |
||||||
|
<td><span th:text="${baseReview.programsCount}"></span></td> |
||||||
|
<!-- <td><span th:text="${absentReview.programsCount}"></span></td> --> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td> |
||||||
|
<a th:href="@{/teachers/check/{id}(id=${id})}">Преподаватели:</a> |
||||||
|
</td> |
||||||
|
<!-- <td><span th:text="${xlsxReview.teachersCount}"></span></td> --> |
||||||
|
<td><span th:text="${baseReview.teachersCount}"></span></td> |
||||||
|
<!-- <td><span th:text="${absentReview.teachersCount}"></span></td> --> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td> |
||||||
|
<a th:href="@{/buildings/check/{id}(id=${id})}">Объекты строительства:</a> |
||||||
|
</td> |
||||||
|
<!-- <td><span th:text="${xlsxReview.buildingsCount}"></span></td> --> |
||||||
|
<td><span th:text="${baseReview.buildingsCount}"></span></td> |
||||||
|
<!-- <td><span th:text="${absentReview.buildingsCount}"></span></td> --> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td> |
||||||
|
<a th:href="@{/organizations/check/{id}(id=${id})}">Организации:</a> |
||||||
|
</td> |
||||||
|
<!-- <td><span th:text="${xlsxReview.organizationsCount}"></span></td> --> |
||||||
|
<td><span th:text="${baseReview.organizationsCount}"></span></td> |
||||||
|
<!-- <td><span th:text="${absentReview.organizationsCount}"></span></td> --> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td> |
||||||
|
<a th:href="@{/courses/check/{id}(id=${id})}">Курсы:</a> |
||||||
|
</td> |
||||||
|
<!-- <td><span th:text="${xlsxReview.coursesCount}"></span></td> --> |
||||||
|
<td><span th:text="${baseReview.coursesCount}"></span></td> |
||||||
|
<!-- <td><span th:text="${absentReview.coursesCount}"></span></td> --> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td> |
||||||
|
<a th:href="@{/students/check/{id}(id=${id})}">Студенты:</a> |
||||||
|
</td> |
||||||
|
<!-- <td><span th:text="${xlsxReview.studentsCount}"></span></td> --> |
||||||
|
<td><span th:text="${baseReview.studentsCount}"></span></td> |
||||||
|
<!-- <td><span th:text="${absentReview.studentsCount}"></span></td> --> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td> |
||||||
|
<a th:href="@{/document/educations/view/{id}(id=${id})}">Обучения:</a> |
||||||
|
</td> |
||||||
|
<!-- <td><span th:text="${xlsxReview.educationsCount}"></span></td> --> |
||||||
|
<td><span th:text="${baseReview.educationsCount}"></span></td> |
||||||
|
<!-- <td><span th:text="${absentReview.educationsCount}"></span></td> --> |
||||||
|
</tr> |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
</div> |
||||||
|
<hr> |
||||||
|
<div class="errors"> |
||||||
|
<h2>Ошибки:</h2> |
||||||
|
<div th:each="error : ${errors}"> |
||||||
|
<span th:text="${error}"></span> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<hr> |
||||||
|
</main> |
||||||
|
</body> |
||||||
|
</html> |
@ -0,0 +1,80 @@ |
|||||||
|
package ru.molokoin.storagers.model; |
||||||
|
|
||||||
|
import java.io.File; |
||||||
|
import java.io.FileInputStream; |
||||||
|
import java.io.IOException; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
import org.apache.poi.ss.usermodel.Cell; |
||||||
|
import org.apache.poi.ss.usermodel.DateUtil; |
||||||
|
import org.apache.poi.ss.usermodel.Row; |
||||||
|
import org.apache.poi.ss.usermodel.Sheet; |
||||||
|
import org.apache.poi.ss.usermodel.Workbook; |
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
||||||
|
import org.springframework.web.multipart.MultipartFile; |
||||||
|
|
||||||
|
import jakarta.annotation.sql.DataSourceDefinition; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import lombok.Builder; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.NoArgsConstructor; |
||||||
|
|
||||||
|
/** |
||||||
|
* Данные извлекаемые из файла порциями заданного размера |
||||||
|
*/ |
||||||
|
|
||||||
|
@AllArgsConstructor |
||||||
|
@NoArgsConstructor |
||||||
|
@Builder |
||||||
|
@Data |
||||||
|
public class XlsxMultipartDocument { |
||||||
|
private Document document; |
||||||
|
private FileInputStream fis; |
||||||
|
private Workbook workbook; |
||||||
|
private Sheet sheet; |
||||||
|
|
||||||
|
public XlsxMultipartDocument(Document document){ |
||||||
|
this.document = document; |
||||||
|
try { |
||||||
|
this.fis = new FileInputStream(new File(document.getPath())); |
||||||
|
this.workbook = new XSSFWorkbook(fis); |
||||||
|
this.sheet = workbook.getSheetAt(0); |
||||||
|
} catch (IOException e) { |
||||||
|
System.out.println("Не читается файл: " + e.getMessage()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Получение физического количества строк в документе, |
||||||
|
* что бы это не значило |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public int getLineCount() { |
||||||
|
return sheet.getPhysicalNumberOfRows(); |
||||||
|
} |
||||||
|
|
||||||
|
public List<XlsxCell> line(int n) { |
||||||
|
Row row = sheet.getRow(n); |
||||||
|
List<XlsxCell> cells = new ArrayList<>(); |
||||||
|
if (row == null) return cells; //пустая строка
|
||||||
|
|
||||||
|
//перебор ячейек в строке
|
||||||
|
for (Cell cell : row) { |
||||||
|
cells.add(new XlsxCell(cell)); |
||||||
|
} |
||||||
|
return cells; |
||||||
|
} |
||||||
|
|
||||||
|
public void close() { |
||||||
|
try { |
||||||
|
workbook.close(); |
||||||
|
fis.close(); |
||||||
|
} catch (IOException e) { |
||||||
|
System.out.println("Не удалось закрыть потоки: " + e.getMessage()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue