xyc
3 天以前 53052625c7c520744a4ca061e204ec9594ca67f8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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);
    }
}