package com.ruoyi.web.controller.zhdd;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.zhdd.domain.Incident;
import com.ruoyi.zhdd.domain.IncidentProcess;
import com.ruoyi.zhdd.domain.IncidentTask;
import com.ruoyi.zhdd.domain.IncidentTaskPerson;
import com.ruoyi.zhdd.domain.Plan;
import com.ruoyi.zhdd.domain.bo.IncidentBo;
import com.ruoyi.zhdd.domain.bo.IncidentTaskBo;
import com.ruoyi.zhdd.domain.bo.IncidentTasksBo;
import com.ruoyi.zhdd.domain.vo.IncidentVo;
import com.ruoyi.zhdd.domain.vo.PlanVo;
import com.ruoyi.zhdd.service.IIncidentProcessService;
import com.ruoyi.zhdd.service.IIncidentService;
import com.ruoyi.zhdd.service.IIncidentTaskPersonService;
import com.ruoyi.zhdd.service.IIncidentTaskService;
import com.ruoyi.zhdd.service.IPlanService;
import com.ruoyi.zhdd.service.IPlanTaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 事件基础Controller
 *
 * @author xitong
 * @date 2021-09-28
 */
@Validated
@Api(value = "大屏接口控制器", tags = {"大屏接口管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/zhdd/bigscreen")
public class BigScreenController extends BaseController {

    private final IIncidentService iIncidentService;

    private final IIncidentTaskService incidentTaskService;

    private final IIncidentTaskPersonService incidentTaskPersonService;

    private final IIncidentProcessService iIncidentProcessService;

    private final IPlanTaskService planTaskService;

    private final IPlanService planService;

    /**
     * 查询事件基础列表
     */
    @ApiOperation("大屏查询事件列表数据")
    @GetMapping("/incident/list")
    public AjaxResult<List<IncidentVo>> list(@Validated(QueryGroup.class) IncidentBo bo) {
        return AjaxResult.success(iIncidentService.listVo(Wrappers.<Incident>lambdaQuery()
            .eq(Incident::getStatus, 3)
            .in(Incident::getLevel, 1, 2)
            .orderByDesc(Incident::getCreateTime)));
    }


}
