@@ -15,10 +15,10 @@ public class ViolationStatisticsResponse {
|
|||||||
private long newViolations;
|
private long newViolations;
|
||||||
|
|
||||||
@JsonProperty("total_complaints")
|
@JsonProperty("total_complaints")
|
||||||
private int totalComplaints;
|
private Long totalComplaints;
|
||||||
|
|
||||||
@JsonProperty("total_law_cases")
|
@JsonProperty("total_law_cases")
|
||||||
private int totalLawCases;
|
private Long totalLawCases;
|
||||||
|
|
||||||
@JsonProperty("in_progress_violations")
|
@JsonProperty("in_progress_violations")
|
||||||
private long inProgressViolations;
|
private long inProgressViolations;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public interface ComplaintEntityRepository extends JpaRepository<ComplaintEntity
|
|||||||
Long getComplaintsWithoutLawCaseCount();
|
Long getComplaintsWithoutLawCaseCount();
|
||||||
|
|
||||||
@Query("SELECT COUNT(c) FROM ComplaintEntity c WHERE c.violation.id IN :violations")
|
@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")
|
@Query("SELECT c FROM ComplaintEntity c WHERE c.email IN :emails")
|
||||||
Page<ComplaintEntity> getComplaintsByUserEmails(@Param("emails") List<String> emails, Pageable pageable);
|
Page<ComplaintEntity> getComplaintsByUserEmails(@Param("emails") List<String> emails, Pageable pageable);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public interface LawCaseRepository extends JpaRepository<LawCase, Long> {
|
|||||||
Long getTotalLawCasesCount();
|
Long getTotalLawCasesCount();
|
||||||
|
|
||||||
@Query("SELECT COUNT(l) FROM LawCase l WHERE l.violationId IN :violationIds")
|
@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);
|
Optional<LawCase> getLawCaseByViolationIdAndType(Long violationId, LawCaseType type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package ru.soune.nocopy.service.violation;
|
package ru.soune.nocopy.service.violation;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.springframework.data.domain.*;
|
import org.springframework.data.domain.*;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -24,6 +25,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@Slf4j
|
||||||
public class ViolationService {
|
public class ViolationService {
|
||||||
|
|
||||||
private final ViolationRepository violationRepository;
|
private final ViolationRepository violationRepository;
|
||||||
@@ -220,11 +222,25 @@ public class ViolationService {
|
|||||||
Set<String> inProgressStatuses = Set.of(
|
Set<String> inProgressStatuses = Set.of(
|
||||||
ViolationStatus.LEGAL_IN_WORK.name(),
|
ViolationStatus.LEGAL_IN_WORK.name(),
|
||||||
ViolationStatus.COMPLAINT_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();
|
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()
|
long newViolations = violations.stream()
|
||||||
.filter(v -> v.getStatus().equals(ViolationStatus.NEW.name()))
|
.filter(v -> v.getStatus().equals(ViolationStatus.NEW.name()))
|
||||||
.count();
|
.count();
|
||||||
@@ -237,14 +253,30 @@ public class ViolationService {
|
|||||||
.filter(v -> v.getStatus().equals(ViolationStatus.AUTHORIZED_USE.name()))
|
.filter(v -> v.getStatus().equals(ViolationStatus.AUTHORIZED_USE.name()))
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
int totalComplaints = 0;
|
Long totalComplaints = 0L;
|
||||||
int totalLawCases = 0;
|
Long totalLawCases = 0L;
|
||||||
|
|
||||||
if (!violationIds.isEmpty()) {
|
if (!violationIds.isEmpty()) {
|
||||||
totalComplaints = complaintRepository.countComplaintByViolations(violationIds);
|
totalComplaints = complaintRepository.countComplaintByViolations(violationIds);
|
||||||
totalLawCases = lawCaseRepository.countLawCaseByViolationIds(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()
|
return ViolationStatisticsResponse.builder()
|
||||||
.totalViolations(violations.size())
|
.totalViolations(violations.size())
|
||||||
.newViolations(newViolations)
|
.newViolations(newViolations)
|
||||||
|
|||||||
Reference in New Issue
Block a user