package com.ruoyi.web.controller.business;

import java.util.List;

import com.ruoyi.business.domain.TInspectReport;
import com.ruoyi.business.service.ITInspectReportService;
import com.ruoyi.framework.web.service.DictService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 检验记录报表Controller
 *
 * @author wms
 * @date 2022-05-29
 */
@Controller
@RequestMapping("/business/inspectReport")
public class InspectReportController extends BaseController
{
    private String prefix = "business/inspectReport";

    @Autowired
    private ITInspectReportService tInspectReportService;

    @Autowired
    private  DictService dict;

    @RequiresPermissions("business:inspectReport:view")
    @GetMapping()
    public String stock(ModelMap mmap)
    {
        mmap.put("tInspectReport", new TInspectReport());
        return prefix + "/inspectReportMain";
    }

    /**
     * 查询检验记录报表
     */
    @RequiresPermissions("business:inspectReport:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo empty(TInspectReport tInspectReport)
    {
        startPage();
        List<TInspectReport> list = tInspectReportService.selectTInspectReportList(tInspectReport);
        return getDataTable(list);
    }

    /**
     * 导出检验记录报表
     */
    @RequiresPermissions("business:inspectReport:export")
    @Log(title = "导出检验记录表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult emptyExport(TInspectReport tInspectReport)
    {
        List<TInspectReport> list = tInspectReportService.selectTInspectReportList(tInspectReport);
        ExcelUtil<TInspectReport> util = new ExcelUtil<TInspectReport>(TInspectReport.class);
        return util.exportExcel(list, "检验记录报表");
    }
}
