package com.goldenwater.web.controller.portal;

import com.goldenwater.common.core.controller.BaseController;
import com.goldenwater.common.core.domain.AjaxResult;
import org.springframework.web.bind.annotation.*;

import java.util.*;

@RestController
@RequestMapping("/portal/jkth")
public class JkthController extends BaseController {

    @GetMapping("/shit/{index}")
    public AjaxResult shit(@PathVariable Integer index) {
        Map<String, Object> data = new HashMap<>();
        data.put("index", index);
        switch (index) {
            case 1:
                data.put("title", "太湖水质概况");
                data.put("rows", getShit1Data());
                break;
            case 2:
                data.put("title", "太湖水位数据");
                data.put("rows", getShit2Data());
                break;
            case 3:
                data.put("title", "太湖出入湖水量");
                data.put("rows", getShit3Data());
                break;
            case 4:
                data.put("title", "太湖营养指数");
                data.put("rows", getShit4Data());
                break;
            case 5:
                data.put("title", "太湖水质类别");
                data.put("rows", getShit5Data());
                break;
            case 6:
                data.put("title", "引江济太调水");
                data.put("rows", getShit6Data());
                break;
            case 7:
                data.put("title", "太湖蓝藻监测");
                data.put("rows", getShit7Data());
                break;
            default:
                return error("无效的索引");
        }
        return success(data);
    }

    private List<Map<String, Object>> getShit1Data() {
        List<Map<String, Object>> list = new ArrayList<>();
        list.add(mapOf("year", "2024", "avgWaterLevel", "3.45", "maxWaterLevel", "4.12", "minWaterLevel", "2.89", "waterQuality", "Ⅳ类", "algaeDensity", "1200"));
        list.add(mapOf("year", "2023", "avgWaterLevel", "3.52", "maxWaterLevel", "4.23", "minWaterLevel", "2.95", "waterQuality", "Ⅳ类", "algaeDensity", "1350"));
        list.add(mapOf("year", "2022", "avgWaterLevel", "3.38", "maxWaterLevel", "4.05", "minWaterLevel", "2.78", "waterQuality", "Ⅳ类", "algaeDensity", "1100"));
        return list;
    }

    private List<Map<String, Object>> getShit2Data() {
        List<Map<String, Object>> list = new ArrayList<>();
        list.add(mapOf("year", "2024", "yearStartWaterLevel", "3.38", "yearEddtWaterLevel", "3.45", "avgWaterLevel", "3.42", "maxWaterLevel", "4.12", "minWaterLevel", "2.89", "maxRange", "1.23", "avgRange", "0.53"));
        list.add(mapOf("year", "2023", "yearStartWaterLevel", "3.42", "yearEddtWaterLevel", "3.38", "avgWaterLevel", "3.48", "maxWaterLevel", "4.23", "minWaterLevel", "2.95", "maxRange", "1.28", "avgRange", "0.55"));
        list.add(mapOf("year", "2022", "yearStartWaterLevel", "3.35", "yearEddtWaterLevel", "3.42", "avgWaterLevel", "3.39", "maxWaterLevel", "4.05", "minWaterLevel", "2.78", "maxRange", "1.27", "avgRange", "0.51"));
        return list;
    }

    private List<Map<String, Object>> getShit3Data() {
        List<Map<String, Object>> list = new ArrayList<>();
        list.add(mapOf("year", "2024", "hxq", "52.3", "wcxyq", "8.5", "ycdlq", "12.1", "pdpxq", "6.8", "hjhq", "15.2", "zxq", "4.3", "wyh", "3.1", "tph", "7.9", "mlh", "5.6", "flowType", "入湖"));
        list.add(mapOf("year", "2023", "hxq", "48.7", "wcxyq", "7.9", "ycdlq", "11.5", "pdpxq", "6.2", "hjhq", "14.8", "zxq", "3.9", "wyh", "2.8", "tph", "7.2", "mlh", "5.1", "flowType", "入湖"));
        list.add(mapOf("year", "2024", "hxq", "45.6", "wcxyq", "7.2", "ycdlq", "10.8", "pdpxq", "5.9", "hjhq", "13.5", "zxq", "3.6", "wyh", "2.5", "tph", "6.8", "mlh", "4.8", "flowType", "出湖"));
        return list;
    }

    private List<Map<String, Object>> getShit4Data() {
        List<Map<String, Object>> list = new ArrayList<>();
        list.add(mapOf("year", "2024", "allLakeIndex", "58.5", "allLackAvgIndex", "56.8", "moderateIndex", "62.3", "mildIndex", "52.1"));
        list.add(mapOf("year", "2023", "allLakeIndex", "59.2", "allLackAvgIndex", "57.5", "moderateIndex", "63.1", "mildIndex", "53.4"));
        list.add(mapOf("year", "2022", "allLakeIndex", "57.8", "allLackAvgIndex", "56.2", "moderateIndex", "61.5", "mildIndex", "51.8"));
        return list;
    }

    private List<Map<String, Object>> getShit5Data() {
        List<Map<String, Object>> list = new ArrayList<>();
        list.add(mapOf("year", "2024", "season", "春季", "wlh", "Ⅳ类", "mlh", "Ⅳ类", "zsh", "Ⅲ类", "gh", "Ⅲ类", "dth", "Ⅴ类", "hxq", "Ⅳ类", "avgValue", "4.2"));
        list.add(mapOf("year", "2024", "season", "夏季", "wlh", "Ⅳ类", "mlh", "Ⅴ类", "zsh", "Ⅲ类", "gh", "Ⅳ类", "dth", "Ⅴ类", "hxq", "Ⅳ类", "avgValue", "4.5"));
        list.add(mapOf("year", "2024", "season", "秋季", "wlh", "Ⅲ类", "mlh", "Ⅳ类", "zsh", "Ⅲ类", "gh", "Ⅲ类", "dth", "Ⅳ类", "hxq", "Ⅲ类", "avgValue", "3.8"));
        list.add(mapOf("year", "2024", "season", "冬季", "wlh", "Ⅲ类", "mlh", "Ⅲ类", "zsh", "Ⅱ类", "gh", "Ⅲ类", "dth", "Ⅳ类", "hxq", "Ⅲ类", "avgValue", "3.5"));
        return list;
    }

    private List<Map<String, Object>> getShit6Data() {
        List<Map<String, Object>> list = new ArrayList<>();
        list.add(mapOf("year", "2024", "province", "江苏", "checkRiver", "望虞河", "gtV", "12.5", "ratio", "65%", "remark", "调水改善太湖水质"));
        list.add(mapOf("year", "2024", "province", "浙江", "checkRiver", "太浦河", "gtV", "8.3", "ratio", "35%", "remark", "保障下游供水"));
        list.add(mapOf("year", "2023", "province", "江苏", "checkRiver", "望虞河", "gtV", "11.8", "ratio", "62%", "remark", "调水改善太湖水质"));
        list.add(mapOf("year", "2023", "province", "浙江", "checkRiver", "太浦河", "gtV", "7.9", "ratio", "38%", "remark", "保障下游供水"));
        return list;
    }

    private List<Map<String, Object>> getShit7Data() {
        List<Map<String, Object>> list = new ArrayList<>();
        list.add(mapOf("year", "2024", "addr", "无锡贡湖", "gmsy", "轻度", "ad", "0.8", "zl", "微囊藻", "zd", "1200", "typeFlow", "蓝藻"));
        list.add(mapOf("year", "2024", "addr", "苏州东山", "gmsy", "中度", "ad", "1.2", "zl", "微囊藻", "zd", "1800", "typeFlow", "蓝藻"));
        list.add(mapOf("year", "2024", "addr", "宜兴周铁", "gmsy", "轻度", "ad", "0.6", "zl", "鱼腥藻", "zd", "900", "typeFlow", "蓝藻"));
        list.add(mapOf("year", "2023", "addr", "无锡贡湖", "gmsy", "中度", "ad", "1.0", "zl", "微囊藻", "zd", "1500", "typeFlow", "蓝藻"));
        return list;
    }

    private Map<String, Object> mapOf(String... args) {
        Map<String, Object> map = new LinkedHashMap<>();
        for (int i = 0; i < args.length; i += 2) {
            map.put(args[i], args[i + 1]);
        }
        return map;
    }
}
