dev fix add count
Test Workflow / test (push) Has been cancelled

This commit is contained in:
2026-04-28 14:15:29 +07:00
parent 610ab0977d
commit 284b402cdc
4 changed files with 42 additions and 10 deletions
@@ -15,10 +15,10 @@ public class ViolationStatisticsResponse {
private long newViolations;
@JsonProperty("total_complaints")
private int totalComplaints;
private Long totalComplaints;
@JsonProperty("total_law_cases")
private int totalLawCases;
private Long totalLawCases;
@JsonProperty("in_progress_violations")
private long inProgressViolations;
@@ -42,7 +42,7 @@ public interface ComplaintEntityRepository extends JpaRepository<ComplaintEntity
Long getComplaintsWithoutLawCaseCount();
@Query("SELECT COUNT(c) FROM ComplaintEntity c WHERE c.violation.id IN :violations")
int countComplaintByViolations(@Param("violations") List<Long> violations);
Long countComplaintByViolations(@Param("violations") List<Long> violations);
@Query("SELECT c FROM ComplaintEntity c WHERE c.email IN :emails")
Page<ComplaintEntity> getComplaintsByUserEmails(@Param("emails") List<String> emails, Pageable pageable);
@@ -45,7 +45,7 @@ public interface LawCaseRepository extends JpaRepository<LawCase, Long> {
Long getTotalLawCasesCount();
@Query("SELECT COUNT(l) FROM LawCase l WHERE l.violationId IN :violationIds")
int countLawCaseByViolationIds(@Param("violationIds") List<Long> violationIds);
Long countLawCaseByViolationIds(@Param("violationIds") List<Long> violationIds);
Optional<LawCase> getLawCaseByViolationIdAndType(Long violationId, LawCaseType type);
}
@@ -1,6 +1,7 @@
package ru.soune.nocopy.service.violation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.data.domain.*;
import org.springframework.stereotype.Service;
@@ -24,6 +25,7 @@ import java.util.stream.Collectors;
@Service
@AllArgsConstructor
@Slf4j
public class ViolationService {
private final ViolationRepository violationRepository;
@@ -220,11 +222,25 @@ public class ViolationService {
Set<String> inProgressStatuses = Set.of(
ViolationStatus.LEGAL_IN_WORK.name(),
ViolationStatus.COMPLAINT_IN_WORK.name(),
ViolationStatus.COMPLAINT_AND_LEGAL_IN_WORK.name()
);
ViolationStatus.COMPLAINT_AND_LEGAL_IN_WORK.name());
List<Long> violationIds = violations.stream().map(Violation::getId).toList();
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!! Violations ids: " + violationIds);
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
long newViolations = violations.stream()
.filter(v -> v.getStatus().equals(ViolationStatus.NEW.name()))
.count();
@@ -237,14 +253,30 @@ public class ViolationService {
.filter(v -> v.getStatus().equals(ViolationStatus.AUTHORIZED_USE.name()))
.count();
int totalComplaints = 0;
int totalLawCases = 0;
Long totalComplaints = 0L;
Long totalLawCases = 0L;
if (!violationIds.isEmpty()) {
totalComplaints = complaintRepository.countComplaintByViolations(violationIds);
totalLawCases = lawCaseRepository.countLawCaseByViolationIds(violationIds);
}
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!! totalLawCases: " + totalLawCases);
log.info("!!!!!!!!!!!!!!!!!!!!!!!!! totalComplaints: " + totalComplaints);
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
log.info("!!!!!!!!!!!!!!!!!!!!!!!!!");
return ViolationStatisticsResponse.builder()
.totalViolations(violations.size())
.newViolations(newViolations)