This commit is contained in:
@@ -48,7 +48,8 @@ public class HandlerConfig {
|
|||||||
StatisticTokenHandler statisticTokenHandler,
|
StatisticTokenHandler statisticTokenHandler,
|
||||||
StatisticIncomeHandler statisticIncomeHandler,
|
StatisticIncomeHandler statisticIncomeHandler,
|
||||||
MonitoringStatisticHandler monitoringStatisticHandler,
|
MonitoringStatisticHandler monitoringStatisticHandler,
|
||||||
DockViewFileHandler dockViewFileHandler
|
DockViewFileHandler dockViewFileHandler,
|
||||||
|
StatisticComplaintHandler statisticComplaintHandler
|
||||||
|
|
||||||
) {
|
) {
|
||||||
Map<Integer, RequestHandler> map = new HashMap<>();
|
Map<Integer, RequestHandler> map = new HashMap<>();
|
||||||
@@ -89,6 +90,7 @@ public class HandlerConfig {
|
|||||||
map.put(30026, statisticIncomeHandler);
|
map.put(30026, statisticIncomeHandler);
|
||||||
map.put(30027, monitoringStatisticHandler);
|
map.put(30027, monitoringStatisticHandler);
|
||||||
map.put(30028, dockViewFileHandler);
|
map.put(30028, dockViewFileHandler);
|
||||||
|
map.put(30029, statisticComplaintHandler);
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package ru.soune.nocopy.dto.statistic;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ComplaintStatisticRequest {
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package ru.soune.nocopy.dto.statistic;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class ComplaintStatisticResponse {
|
||||||
|
|
||||||
|
@JsonProperty("total_complaint")
|
||||||
|
private Long totalComplaints;
|
||||||
|
|
||||||
|
@JsonProperty("total_created")
|
||||||
|
private Long totalCreated;
|
||||||
|
|
||||||
|
@JsonProperty("total_in_work")
|
||||||
|
private Long totalInWork;
|
||||||
|
|
||||||
|
@JsonProperty("total_completed")
|
||||||
|
private Long totalCompleted;
|
||||||
|
|
||||||
|
@JsonProperty("total_cancelled")
|
||||||
|
private Long totalCancelled;
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package ru.soune.nocopy.handler;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import ru.soune.nocopy.dto.BaseRequest;
|
||||||
|
import ru.soune.nocopy.dto.BaseResponse;
|
||||||
|
import ru.soune.nocopy.dto.MessageCode;
|
||||||
|
import ru.soune.nocopy.dto.statistic.ComplaintStatisticResponse;
|
||||||
|
import ru.soune.nocopy.service.statistic.ComplaintStatisticService;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class StatisticComplaintHandler implements RequestHandler {
|
||||||
|
|
||||||
|
private final ComplaintStatisticService complaintStatisticService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseResponse handle(BaseRequest request) throws Exception {
|
||||||
|
ComplaintStatisticResponse complaintStatisticResponse = complaintStatisticService.complaintStatistic();
|
||||||
|
|
||||||
|
return new BaseResponse(
|
||||||
|
request.getMsgId(),
|
||||||
|
MessageCode.SUCCESS.getCode(),
|
||||||
|
MessageCode.SUCCESS.getDescription(),
|
||||||
|
complaintStatisticResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,6 +33,9 @@ public interface ComplaintEntityRepository extends JpaRepository<ComplaintEntity
|
|||||||
@Query("SELECT COUNT(c.id) FROM ComplaintEntity c")
|
@Query("SELECT COUNT(c.id) FROM ComplaintEntity c")
|
||||||
Long getTotalComplaintsCount();
|
Long getTotalComplaintsCount();
|
||||||
|
|
||||||
|
@Query("SELECT COUNT(c.id) FROM ComplaintEntity c WHERE c.status = :status")
|
||||||
|
Long getTotalComplaintsCountByStatus(@Param("status")String status);
|
||||||
|
|
||||||
@Query("""
|
@Query("""
|
||||||
SELECT COUNT(c.id)
|
SELECT COUNT(c.id)
|
||||||
FROM ComplaintEntity c
|
FROM ComplaintEntity c
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package ru.soune.nocopy.service.statistic;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import ru.soune.nocopy.dto.statistic.ComplaintStatisticResponse;
|
||||||
|
import ru.soune.nocopy.entity.complaint.ComplaintStatus;
|
||||||
|
import ru.soune.nocopy.repository.ComplaintEntityRepository;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ComplaintStatisticService {
|
||||||
|
|
||||||
|
private final ComplaintEntityRepository complaintEntityRepository;
|
||||||
|
|
||||||
|
public ComplaintStatisticResponse complaintStatistic() {
|
||||||
|
|
||||||
|
return ComplaintStatisticResponse.builder()
|
||||||
|
.totalComplaints(complaintEntityRepository.getTotalComplaintsCount())
|
||||||
|
.totalCancelled(complaintEntityRepository.getTotalComplaintsCountByStatus(ComplaintStatus.CANCELLED.name()))
|
||||||
|
.totalCreated(complaintEntityRepository.getTotalComplaintsCountByStatus(ComplaintStatus.CREATED.name()))
|
||||||
|
.totalCompleted(complaintEntityRepository.getTotalComplaintsCountByStatus(ComplaintStatus.COMPLETED.name()))
|
||||||
|
.totalInWork(complaintEntityRepository.getTotalComplaintsCountByStatus(ComplaintStatus.IN_WORK.name()))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user