dev add statistic files protected
Test Workflow / test (push) Successful in 3s

This commit is contained in:
vladp
2026-04-15 18:28:42 +07:00
parent 2d80b40b27
commit be62dd458a
8 changed files with 137 additions and 1 deletions
@@ -0,0 +1,40 @@
package ru.soune.nocopy.service.statistic;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import ru.soune.nocopy.dto.statistic.ViolationStatisticResponse;
import ru.soune.nocopy.repository.ComplaintEntityRepository;
import ru.soune.nocopy.repository.LawCaseRepository;
import ru.soune.nocopy.repository.ViolationRepository;
@Service
@RequiredArgsConstructor
@Slf4j
public class ViolationStatisticService {
private final ViolationRepository violationRepository;
private final ComplaintEntityRepository complaintRepository;
private final LawCaseRepository lawCaseRepository;
public ViolationStatisticResponse getViolationStatistics() {
Long totalViolations = violationRepository.getTotalViolationsCount();
Long totalComplaints = complaintRepository.getTotalComplaintsCount();
Long totalLawCases = lawCaseRepository.getTotalLawCasesCount();
Long complaintsWithoutCase = complaintRepository.getComplaintsWithoutLawCaseCount();
Long violationsWithComplaint = violationRepository.getViolationsWithComplaintCount();
Long violationsWithoutComplaint = totalViolations - violationsWithComplaint;
return ViolationStatisticResponse.builder()
.totalViolations(totalViolations != null ? totalViolations : 0L)
.totalComplaints(totalComplaints != null ? totalComplaints : 0L)
.totalLawCases(totalLawCases != null ? totalLawCases : 0L)
.complaintsWithoutCase(complaintsWithoutCase != null ? complaintsWithoutCase : 0L)
.violationsWithComplaint(violationsWithComplaint != null ? violationsWithComplaint : 0L)
.violationsWithoutComplaint(violationsWithoutComplaint)
.build();
}
}