package com.zcloud.modules.map.controller;


import com.zcloud.modules.map.service.FourColourService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * 说明：地图四色四固定图层
 * 官网：www.zcloudchina.com
 */
@Controller
@RequestMapping("/map/FourColour")
public class FourColourController{

    @Autowired
    private FourColourService fourColourService;



    /**
     * 告警信息列表
     */
    @RequestMapping(value="/alarmStatistics")
    public Object getAlarmStatistics(@RequestBody Map<String, Object> params) throws Exception{
        if(StringUtils.isNotEmpty(params.get("route").toString())){
            return fourColourService.getAlarmStatistics(params.get("route").toString());
        }else {
            Map<String, Object> map = new HashMap<>();
            map.put("result","error");
            map.put("msg","缺少必填参数route");
            return map;
        }
    }

    /**
     * 人员车辆进场趋势分析
     */
    @RequestMapping(value="/personInAndCarIn")
    @ResponseBody
    public Object personInAndCarIn() throws Exception{
        return fourColourService.personInAndCarIn();
    }


    /**
     * 工单列表信息
     */
    @RequestMapping(value="/currentDayGdDetailInfor")
    public Object currentDayGdDetailInfor(@RequestBody Map<String, Object> params) throws Exception{
        if(StringUtils.isNotEmpty(params.get("route").toString())){
            return fourColourService.currentDayGdDetailInfor(params.get("route").toString());
        }else {
            Map<String, Object> map = new HashMap<>();
            map.put("result","error");
            map.put("msg","缺少必填参数route");
            return map;
        }
    }

    /**
     * 工单列表信息(新) 根据区域获取工单信息
     */
    @RequestMapping(value="/getGDDetailListByArea")
    public Object getGDDetailListByArea(@RequestBody Map<String, Object> params) throws Exception{
        Map<String, Object> map = new HashMap<>();
        map.put("result","error");
        String pageNum = "";
        String pageSize = "";
        String str = "";
        String type = "";
        if(StringUtils.isEmpty(params.get("pageNum").toString())){
            map.put("msg","缺少必填参数pageNum");
            return map;
        }else if(StringUtils.isEmpty(params.get("pageSize").toString())){
            map.put("msg","缺少必填参数pageSize");
            return map;
        }
        pageNum = params.get("pageNum").toString();
        pageSize = params.get("pageSize").toString();
        return fourColourService.getGDDetailListByArea(pageNum, pageSize, type, str);

    }


    /**
     * 车辆类型信息
     */
    @RequestMapping(value="/carTypeAnalysis")
    public Object carTypeAnalysis(@RequestBody Map<String, Object> params) throws Exception{
        if(StringUtils.isNotEmpty(params.get("route").toString())){
            return fourColourService.carTypeAnalysis(params.get("route").toString());
        }else {
            Map<String, Object> map = new HashMap<>();
            map.put("result","error");
            map.put("msg","缺少必填参数route");
            return map;
        }
    }
}
