Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added jar #2

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: src.Solution.Main

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ a30b4d51-11b4-49b2-b356-466e92a66df7 Иванов Иван Иванович 16.0
```sh
cd <имя_репозитория>
```

2. **Импортируйте проект в IntelliJ IDEA**:
- Откройте IntelliJ IDEA.
- Выберите "File > Open".
Expand Down
13 changes: 13 additions & 0 deletions result/report.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
24
a30b4d51-11b4-49b2-b356-466e92a66df7 Иванов Иван Иванович 06.05.2024 8
0f0ccd5e-cd46-462a-b92d-69a6ff147465 Петров Алексей Сергеевич 06.05.2024 6
75cd02d8-6b1f-42fb-9c59-7db675b28a2d Сорокина Анна Павловна 06.05.2024 8.5
e5dbc47c-52f6-480a-876d-f97b17cb7cab Журавлева Елена Анатольевна 06.05.2024 9
e5dbc47c-52f6-480a-876d-f97b17cb7cab Журавлева Елена Анатольевна 07.05.2024 9
0f0ccd5e-cd46-462a-b92d-69a6ff147465 Петров Алексей Сергеевич 07.05.2024 7
a30b4d51-11b4-49b2-b356-466e92a66df7 Иванов Иван Иванович 07.05.2024 8
75cd02d8-6b1f-42fb-9c59-7db675b28a2d Сорокина Анна Павловна 07.05.2024 8.5
75cd02d8-6b1f-42fb-9c59-7db675b28a2d Сорокина Анна Павловна 08.05.2024 8
e5dbc47c-52f6-480a-876d-f97b17cb7cab Журавлева Елена Анатольевна 08.05.2024 10
a30b4d51-11b4-49b2-b356-466e92a66df7 Иванов Иван Иванович 08.05.2024 8
0f0ccd5e-cd46-462a-b92d-69a6ff147465 Петров Алексей Сергеевич 08.05.2024 8
File renamed without changes.
Binary file added result/school2024-test-task6.jar
Binary file not shown.
10 changes: 8 additions & 2 deletions src/Solution/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ public class Main {

private final static String inputFilePath = "report.txt";
private final static String outputFilePath = "result.txt";


/**
* Главный метод программы, который выполняет анализ дизбаланса и записывает результаты в файл.
*
Expand All @@ -27,34 +25,42 @@ public static void main(String[] args) throws IOException {

// Чтение входного файла
List<String> lines = Files.readAllLines(Paths.get(inputFilePath));

// Извлечение недельной нормы списания
Integer weeklyNorm = Integer.parseInt(lines.getFirst().trim());

// Парсинг записей о времени
List<TimeEntry> entries = lines.stream()
.skip(1)
.map(TimeEntry::parse)
.toList();

// Подсчет общего количества списанных часов для каждого сотрудника
Map<String, Double> totalHours = new HashMap<>();
entries.forEach(entry -> {
totalHours.put(entry.getFullName(),totalHours.getOrDefault(entry.getFullName(), 0.0) + entry.getHours());
});

// Вычисление дизбаланса для каждого сотрудника
List<Disbalance> disbalances = totalHours.entrySet().stream()
.map(e -> new Disbalance(e.getKey(), e.getValue() - weeklyNorm))
.filter(d -> Math.abs(d.getDisbalance()) > weeklyNorm * 0.1)
.toList();


// Разделение дизбалансов на отрицательные и положительные
List<Disbalance> negativeDisbalances = disbalances.stream()
.filter(d -> d.getDisbalance() < 0)
.sorted(Comparator.comparing(Disbalance::getFullName))
.toList();


List<Disbalance> positiveDisbalances = disbalances.stream()
.filter(d -> d.getDisbalance() > 0)
.sorted(Comparator.comparing(Disbalance::getFullName))
.toList();


// Запись результатов в выходной файл
try (BufferedWriter writer = Files.newBufferedWriter(Paths.get(outputFilePath))) {
for (Disbalance d : negativeDisbalances) {
Expand Down