package com.emergencyrepair.business.service;
|
|
import com.emergencyrepair.business.dto.report.ReportContractorDto;
|
import com.emergencyrepair.business.dto.report.ReportMetricDto;
|
import com.emergencyrepair.business.dto.report.ReportOverviewDto;
|
import com.emergencyrepair.business.dto.report.ReportTeamDto;
|
import com.emergencyrepair.business.dto.report.ReportTrendDto;
|
import com.emergencyrepair.business.mapper.ReportMapper;
|
import lombok.RequiredArgsConstructor;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.Arrays;
|
import java.util.List;
|
|
@Service
|
@RequiredArgsConstructor
|
@Transactional(readOnly = true)
|
public class ReportService {
|
private final ReportMapper reportMapper;
|
|
public ReportOverviewDto overview() {
|
ReportOverviewDto report = reportMapper.selectOverview();
|
report.setChart(Arrays.asList(
|
metric("工程总数", report.getEngineeringTotal()),
|
metric("重大故障", report.getMajorFault()),
|
metric("涉H统计", report.getHRelated()),
|
metric("监测项目", report.getMonitorItem()),
|
metric("未完工", report.getUnfinished()),
|
metric("已完工", report.getCompleted()),
|
metric("完工待试验", report.getWaitTest()),
|
metric("销项工程", report.getCancelled())
|
));
|
return report;
|
}
|
|
public List<ReportMetricDto> topEquipment() {
|
return reportMapper.selectTopEquipment();
|
}
|
|
public List<ReportTeamDto> byTeam() {
|
return reportMapper.selectByTeam();
|
}
|
|
public List<ReportContractorDto> contractors() {
|
return reportMapper.selectContractors();
|
}
|
|
public List<ReportTrendDto> yearlyTrend() {
|
return reportMapper.selectYearlyTrend();
|
}
|
|
private ReportMetricDto metric(String name, Long value) {
|
return new ReportMetricDto(name, value == null ? 0L : value);
|
}
|
}
|