package com.casic.missiles.modular.alarm.controller;

import com.casic.missiles.core.common.service.ICommonPermissionService;
import com.casic.missiles.core.util.ToolUtil;
import com.casic.missiles.modular.alarm.service.ISysDictService;
import com.casic.missiles.core.base.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 控制器
 *
 * @author dev
 * @Date 2019-05-17 10:51:12
 */
@Controller
@RequestMapping("/alarm")
public class SysDictController extends BaseController {


    @Autowired
    private ISysDictService sysDictService;
    @Autowired
    private ICommonPermissionService iCommonPermissionService;

    @Value("${smartcity.office.maxRowsExcel}")
    private  int maxRowsExcel;

    /**
     * 获取列表
     */
    @RequestMapping(value = "/type")
    @ResponseBody
    public List<Map<String, Object>> listAlarmType(String condition) {
        List<Map<String,Object>> list = new ArrayList<>();
        list =  sysDictService.getTypeViaName("报警状态");
        return list;
    }

    @RequestMapping(value = "/contentType")
    @ResponseBody
    public Map<String, Object> listContentType(@RequestParam(value = "alarmType" ,required = true) String alarmType, HttpServletRequest httpServletRequest) {
        String deviceType = httpServletRequest.getParameter("deviceType");
        if (ToolUtil.isEmpty(deviceType)){
            deviceType="";
        }
        Map<String,Object> retMap = new HashMap<>();
        Map<String,Object> listMap = new HashMap<>();
        List<Map<String,Object>> list = new ArrayList<>();
        list =  sysDictService.getAlarmContent(alarmType,deviceType);
        listMap.put("list",list);
        retMap.put("code",200);
        retMap.put("message","success");
        retMap.put("data",listMap);
        return retMap;
    }

}
