package com.zksy.web.controller.manhole;


import com.zksy.base.service.MaintenanceDataStatService;
import com.zksy.common.annotation.Anonymous;
import com.zksy.common.core.controller.BaseController;
import com.zksy.common.core.domain.AjaxResult2;
import com.zksy.manhole.dto.in.MaintenanceDataStatQueryInDTO;
import com.zksy.manhole.dto.in.MaintenanceDataStatTrendInDTO;
import com.zksy.manhole.dto.out.AbnormalTerminalTrendOutDTO;
import com.zksy.manhole.dto.out.CaseRateTrendOutDTO;
import com.zksy.manhole.dto.out.MaintenanceDataStatOutDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 窨井盖监测系统-数据统计Controller
 * 
 * @author xianggx
 * @date 2026-05-06
 */
@RestController
@RequestMapping("/manhole/maintenanceDataStat")
@Api(tags = "窨井盖监测系统-数据统计")
public class MaintenanceDataStatController extends BaseController
{
    @Autowired
    private MaintenanceDataStatService maintenanceDataStatService;

    /**
     * 根据日期查询运维数据统计
     */
    @Anonymous
    @PostMapping(value = "/queryByDate")
    @ApiOperation(value = "根据日期查询运维数据统计")
    public AjaxResult2<MaintenanceDataStatOutDTO> queryByDate(@RequestBody MaintenanceDataStatQueryInDTO queryInDTO)
    {
        MaintenanceDataStatOutDTO outDTO = maintenanceDataStatService.queryByDate(queryInDTO);
        if(outDTO == null){
            return AjaxResult2.error("该日期的统计数据不存在");
        }
        return AjaxResult2.success(outDTO);
    }

    /**
     * 周度/月度 异常终端设备数量趋势分析
     */
    @Anonymous
    @PostMapping(value = "/abnormalTerminalTrend")
    @ApiOperation(value = "周度/月度 异常终端设备数量趋势分析")
    public AjaxResult2<List<AbnormalTerminalTrendOutDTO>> abnormalTerminalTrend(@RequestBody MaintenanceDataStatTrendInDTO inDTO)
    {
        return AjaxResult2.success(maintenanceDataStatService.abnormalTerminalTrend(inDTO));
    }

    /**
     * 周度/月度 案件处置率、案件延期率趋势分析
     */
    @Anonymous
    @PostMapping(value = "/caseRateTrend")
    @ApiOperation(value = "周度/月度 案件处置率、案件延期率趋势分析")
    public AjaxResult2<List<CaseRateTrendOutDTO>> caseRateTrend(@RequestBody MaintenanceDataStatTrendInDTO inDTO)
    {
        return AjaxResult2.success(maintenanceDataStatService.caseRateTrend(inDTO));
    }
}
