package com.ruoyi.web.controller.doubleDefense;

import com.ruoyi.common.annotation.Log;
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.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.doubledefense.domain.CheckTask;
import com.ruoyi.doubledefense.domain.CheckTaskInventory;
import com.ruoyi.doubledefense.dto.CheckTaskDTO;
import com.ruoyi.doubledefense.dto.CheckTaskInventoryDTO;
import com.ruoyi.doubledefense.dto.res.CheckTaskInventoryResultDTO;
import com.ruoyi.doubledefense.dto.res.CheckTaskResultDTO;
import com.ruoyi.doubledefense.service.ICheckTaskInventoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 隐患排查任务清单Controller
 *
 * @date 2023-08-26
 */
@Api(tags = "排查任务清单-废弃")
@RestController
@RequestMapping("/doubledefense/taskInventory")
public class CheckTaskInventoryController extends BaseController
{
    @Autowired
    private ICheckTaskInventoryService checkTaskInventoryService;

    /**
     * 查询隐患排查任务清单列表
     */
    @ApiOperation("查询隐患排查任务清单列表")
    @GetMapping("/list")
    public TableDataInfo  list(CheckTaskInventoryDTO checkTaskInventoryDTO)
    {
        CheckTaskInventory checkTaskInventory = new CheckTaskInventory();
        BeanUtils.copyProperties(checkTaskInventoryDTO,checkTaskInventory);

        startPage();
        List<CheckTaskInventory> list = checkTaskInventoryService.selectCheckTaskInventoryList(checkTaskInventory);

        return getDataTable(list);
    }

    /**
     * 导出隐患排查任务清单列表
     */
    @ApiOperation("导出隐患排查任务列表")
    @Log(title = "隐患排查任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CheckTaskInventoryDTO checkTaskInventoryDTO) {

        CheckTaskInventory checkTaskInventory = new CheckTaskInventory();
        BeanUtils.copyProperties(checkTaskInventoryDTO,checkTaskInventory);
        List<CheckTaskInventory> list = checkTaskInventoryService.selectCheckTaskInventoryList(checkTaskInventory);

        List<CheckTaskInventoryResultDTO> checkTaskInventoryResultDTOList = new ArrayList<>();
        BeanUtils.copyProperties(list,checkTaskInventoryResultDTOList);
        ExcelUtil<CheckTaskInventoryResultDTO> util = new ExcelUtil<>(CheckTaskInventoryResultDTO.class);
        util.exportExcel(response, checkTaskInventoryResultDTOList, "隐患排查任务清单数据");

//        List<CheckTaskResultDTO> list = null;//checkTaskInventoryService.selectCheckTaskList(checkTask);
//        ExcelUtil<CheckTaskResultDTO> util = new ExcelUtil<>(CheckTaskResultDTO.class);
//        util.exportExcel(response, list, "隐患排查任务清单数据");
    }

    /**
     * 获取隐患排查任务清单详细信息
     */
    @ApiOperation("获取隐患排查任务详细信息")

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(checkTaskInventoryService.selectCheckTaskInventoryById(id));
    }
}
