package com.ruoyi.web.controller.flood;

import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.service.IFloodCaseService;
import com.ruoyi.system.service.IFloodEmergencyPlanService;
import com.ruoyi.system.service.IFloodKnowledgeBaseService;

/**
 * 洪水数据统计Controller
 *
 * @author jackeyhuang
 * @version 1.0.0
 * @date 2026-01-11
 */
@RestController
@RequestMapping("/flood/statistics")
public class FloodStatisticsController extends BaseController
{
    @Autowired
    private IFloodKnowledgeBaseService floodKnowledgeBaseService;

    @Autowired
    private IFloodEmergencyPlanService floodEmergencyPlanService;

    @Autowired
    private IFloodCaseService floodCaseService;

    /**
     * 获取统计数据
     *
     * @return 统计数据
     */
    @GetMapping("/data")
    public AjaxResult getStatistics()
    {
        Map<String, Object> statistics = new HashMap<>();
        
        // 统计知识库总数
        int knowledgeBaseCount = floodKnowledgeBaseService.countFloodKnowledgeBase();
        statistics.put("knowledgeBaseCount", knowledgeBaseCount);
        
        // 统计应急预案总数
        int emergencyPlanCount = floodEmergencyPlanService.countFloodEmergencyPlan();
        statistics.put("emergencyPlanCount", emergencyPlanCount);
        
        // 统计案例库总数
        int caseCount = floodCaseService.countFloodCase();
        statistics.put("caseCount", caseCount);
        
        return success(statistics);
    }
}
