package com.ruoyi.web.controller.report;

import java.util.List;
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.PathVariable;
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.report.domain.RecordMaterialcodeamountDay;
import com.ruoyi.report.service.IRecordMaterialcodeamountDayService;
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 CaesarBao
 * @date 2020-11-04
 */
@Controller
@RequestMapping("/report/MaterialCodeAmountDatReport")
public class RecordMaterialcodeamountDayController extends BaseController
{
    private String prefix = "report/MaterialCodeAmountDatReport";

    @Autowired
    private IRecordMaterialcodeamountDayService recordMaterialcodeamountDayService;

    @RequiresPermissions("report:MaterialCodeAmountDatReport:view")
    @GetMapping()
    public String MaterialCodeAmountDatReport()
    {
        return prefix + "/MaterialCodeAmountDatReport";
    }

    /**
     * 查询规格产量日报列表
     */
    @RequiresPermissions("report:MaterialCodeAmountDatReport:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RecordMaterialcodeamountDay recordMaterialcodeamountDay)
    {
        startPage();
        List<RecordMaterialcodeamountDay> list = recordMaterialcodeamountDayService.selectRecordMaterialcodeamountDayList(recordMaterialcodeamountDay);
        return getDataTable(list);
    }

    /**
     * 导出规格产量日报列表
     */
    @RequiresPermissions("report:MaterialCodeAmountDatReport:export")
    @Log(title = "规格产量日报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RecordMaterialcodeamountDay recordMaterialcodeamountDay)
    {
        List<RecordMaterialcodeamountDay> list = recordMaterialcodeamountDayService.selectRecordMaterialcodeamountDayList(recordMaterialcodeamountDay);
        ExcelUtil<RecordMaterialcodeamountDay> util = new ExcelUtil<RecordMaterialcodeamountDay>(RecordMaterialcodeamountDay.class);
        return util.exportExcel(list, "MaterialCodeAmountDatReport");
    }

    /**
     * 新增规格产量日报
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存规格产量日报
     */
    @RequiresPermissions("report:MaterialCodeAmountDatReport:add")
    @Log(title = "规格产量日报", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RecordMaterialcodeamountDay recordMaterialcodeamountDay)
    {
        return toAjax(recordMaterialcodeamountDayService.insertRecordMaterialcodeamountDay(recordMaterialcodeamountDay));
    }

    /**
     * 修改规格产量日报
     */
    @GetMapping("/edit/{objid}")
    public String edit(@PathVariable("objid") Long objid, ModelMap mmap)
    {
        RecordMaterialcodeamountDay recordMaterialcodeamountDay = recordMaterialcodeamountDayService.selectRecordMaterialcodeamountDayById(objid);
        mmap.put("recordMaterialcodeamountDay", recordMaterialcodeamountDay);
        return prefix + "/edit";
    }

    /**
     * 修改保存规格产量日报
     */
    @RequiresPermissions("report:MaterialCodeAmountDatReport:edit")
    @Log(title = "规格产量日报", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RecordMaterialcodeamountDay recordMaterialcodeamountDay)
    {
        return toAjax(recordMaterialcodeamountDayService.updateRecordMaterialcodeamountDay(recordMaterialcodeamountDay));
    }

    /**
     * 删除规格产量日报
     */
    @RequiresPermissions("report:MaterialCodeAmountDatReport:remove")
    @Log(title = "规格产量日报", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(recordMaterialcodeamountDayService.deleteRecordMaterialcodeamountDayByIds(ids));
    }
}
