package com.elephant.framework.galaxy.aroad.module.szgl.controller;

import com.elephant.framework.galaxy.aroad.bigdata.*;
import com.elephant.framework.galaxy.aroad.module.codegen.response.R;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/szgl")
public class SzglController {
    /**
     *  全局搜索路段、收费站、桥梁、隧道
     * @Param keyword 搜索条件
     */
    @GetMapping("/bigdata")
    public R getBigData(@RequestParam("keyword") String keyword) throws Exception {
        List<Map<String,Object>> responseList = new ArrayList<>();
        //查询匹配桥梁名称
        Boolean bridgeOne = EsUtil_fanshe.queryBridgeOne(keyword, "basicbridgedata", "2018", 0, 2000000000);
        if(bridgeOne){
            responseList.add(new HashMap<String,Object>(){{
                put("label","桥梁");
                put("name","qiaoliang");
            }});
        }
        //查询匹配路段名称
        Boolean highWayOne = EsUtil_fanshe.queryHighWayOne(keyword ,"basichighwaydata", "2018", 0, 2000000000);
        if(highWayOne){
            responseList.add(new HashMap<String,Object>(){{
                put("label","路段");
                put("name","luduan");
            }});
        }
        //查询匹配隧道名称
        Boolean tunnelOne = EsUtil_fanshe.queryTunnelOne(keyword, "basictunneldata", "2018", 0, 2000000000);
        if(tunnelOne){
            responseList.add(new HashMap<String,Object>(){{
                put("label","隧道");
                put("name","suidao");
            }});
        }
        //查询匹配收费站名称
        Boolean baseRoadTollOne = EsUtil_fanshe.queryBaseRoadTollOne(keyword, "baseroadtolldata", "2018", 0, 2000000000);
        if(baseRoadTollOne){
            responseList.add(new HashMap<String,Object>(){{
                put("label","收费站");
                put("name","shoufeizhan");
            }});
        }
        return new R<>(responseList);
    }
    /**
     * 查询桥梁
     * @Param keyword 搜索条件
     */
    @GetMapping("/bridge")
    public R getBridge(@RequestParam("keyword") String keyword) throws Exception {
        ArrayList<LuKeBridge> luKeBridges = EsUtil_fanshe.queryBridge(keyword, "basicbridgedata", "2018", 0, 2000000000);
        return new R<>(luKeBridges);
    }
    /**
     * 查询路段
     * @Param keyword 搜索条件
     */
    @GetMapping("/highWay")
    public R getHighWay(@RequestParam("keyword") String keyword) throws Exception {
        ArrayList<LuKeHighWay> lukehighways = EsUtil_fanshe.queryHighWay(keyword, "basichighwaydata", "2018", 0, 2000000000);
        return new R<>(lukehighways);
    }
    /**
     * 查询隧道
     * @Param keyword 搜索条件
     */
    @GetMapping("/tunnel")
    public R getTunnel(@RequestParam("keyword") String keyword) throws Exception {
        ArrayList<BasicTunnel> basicTunnels = EsUtil_fanshe.queryTunnel("广州桥", "basictunneldata", "2018", 0, 2000000000);
        return new R<>(basicTunnels);
    }
    /**
     * 查询收费站
     * @Param keyword 搜索条件
     */
    @GetMapping("/baseRoadToll")
    public R getBaseRoadToll(@RequestParam("keyword") String keyword) throws Exception {
        ArrayList<BaseRoadToll_String> baseRoadTollStrings = EsUtil_fanshe.queryBaseRoadTollString(keyword, "baseroadtolldata", "2018", 0, 2000000000);
        return new R<>(baseRoadTollStrings);
    }
}
