package com.ruoyi.web.controller.business;

import java.util.List;

import com.ruoyi.business.domain.TScrapReport;
import com.ruoyi.business.service.ITScrapReportService;
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/scrapReport")
public class ScrapReportController extends BaseController
{
    private String prefix = "business/scrapReport";

    @Autowired
    private ITScrapReportService tScrapReportService;

    @Autowired
    private  DictService dict;

    @RequiresPermissions("business:scrapReport:view")
    @GetMapping()
    public String stock(ModelMap mmap)
    {
        mmap.put("tScrapReport", new TScrapReport());
        return prefix + "/scrapReportMain";
    }

    /**
     * 查询报废记录报表
     */
    @RequiresPermissions("business:scrapReport:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo empty(TScrapReport tScrapReport)
    {
        startPage();
        List<TScrapReport> list = tScrapReportService.selectTScrapReportList(tScrapReport);
        return getDataTable(list);
    }

    /**
     * 导出报废记录报表
     */
    @RequiresPermissions("business:scrapReport:export")
    @Log(title = "导出报废记录报表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult emptyExport(TScrapReport tScrapReport)
    {
        List<TScrapReport> list = tScrapReportService.selectTScrapReportList(tScrapReport);
        ExcelUtil<TScrapReport> util = new ExcelUtil<TScrapReport>(TScrapReport.class);
        return util.exportExcel(list, "报废记录报表");
    }
}
