package com.goomood.phm.controller;

import com.goomood.common.core.controller.BaseController;
import com.goomood.common.core.domain.AjaxResult;
import com.goomood.phm.service.FaultMonitorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 故障统计控制器
 */
@Api(tags = "故障统计API")
@RestController
@RequestMapping("/statistics")
public class FaultStatisticsController extends BaseController {

    @Resource
    private FaultMonitorService faultMonitorService;

    /**
     * 获取近三年下月故障最多的5类部件
     */
    @ApiOperation("获取近三年下月故障最多的5类部件")
    @GetMapping("/top5NextMonth")
    public AjaxResult getTop5FaultyPartsNextMonthInThreeYears() {
        Map<String, Long> result = faultMonitorService.getTop5FaultyPartsNextMonthInThreeYears();
        return success(result);
    }

    /**
     * 获取近半年故障最多的5类部件
     */
    @ApiOperation("获取近半年故障最多的5类部件")
    @GetMapping("/top5SixMonths")
    public AjaxResult getTop5FaultyPartsInSixMonths() {
        Map<String, Long> result = faultMonitorService.getTop5FaultyPartsInSixMonths();
        return success(result);
    }
}    