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.RecordWorkprocedureamountDay;
import com.ruoyi.report.service.IRecordWorkprocedureamountDayService;
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-03
 */
@Controller
@RequestMapping("/report/WorkProcedureAmountDatReport")
public class RecordWorkprocedureamountDayController extends BaseController
{
    private String prefix = "report/WorkProcedureAmountDatReport";

    @Autowired
    private IRecordWorkprocedureamountDayService recordWorkprocedureamountDayService;

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

    /**
     * 查询工序产量日报列表
     */
    @RequiresPermissions("report:WorkProcedureAmountDatReport:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RecordWorkprocedureamountDay recordWorkprocedureamountDay)
    {
        startPage();
        List<RecordWorkprocedureamountDay> list = recordWorkprocedureamountDayService.selectRecordWorkprocedureamountDayList(recordWorkprocedureamountDay);
        return getDataTable(list);
    }

    /**
     * 导出工序产量日报列表
     */
    @RequiresPermissions("report:WorkProcedureAmountDatReport:export")
    @Log(title = "工序产量日报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RecordWorkprocedureamountDay recordWorkprocedureamountDay)
    {
        List<RecordWorkprocedureamountDay> list = recordWorkprocedureamountDayService.selectRecordWorkprocedureamountDayList(recordWorkprocedureamountDay);
        ExcelUtil<RecordWorkprocedureamountDay> util = new ExcelUtil<RecordWorkprocedureamountDay>(RecordWorkprocedureamountDay.class);
        return util.exportExcel(list, "WorkProcedureAmountDatReport");
    }

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

    /**
     * 新增保存工序产量日报
     */
    @RequiresPermissions("report:WorkProcedureAmountDatReport:add")
    @Log(title = "工序产量日报", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RecordWorkprocedureamountDay recordWorkprocedureamountDay)
    {
        return toAjax(recordWorkprocedureamountDayService.insertRecordWorkprocedureamountDay(recordWorkprocedureamountDay));
    }

    /**
     * 修改工序产量日报
     */
    @GetMapping("/edit/{objid}")
    public String edit(@PathVariable("objid") Long objid, ModelMap mmap)
    {
        RecordWorkprocedureamountDay recordWorkprocedureamountDay = recordWorkprocedureamountDayService.selectRecordWorkprocedureamountDayById(objid);
        mmap.put("recordWorkprocedureamountDay", recordWorkprocedureamountDay);
        return prefix + "/edit";
    }

    /**
     * 修改保存工序产量日报
     */
    @RequiresPermissions("report:WorkProcedureAmountDatReport:edit")
    @Log(title = "工序产量日报", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RecordWorkprocedureamountDay recordWorkprocedureamountDay)
    {
        return toAjax(recordWorkprocedureamountDayService.updateRecordWorkprocedureamountDay(recordWorkprocedureamountDay));
    }

    /**
     * 删除工序产量日报
     */
    @RequiresPermissions("report:WorkProcedureAmountDatReport:remove")
    @Log(title = "工序产量日报", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(recordWorkprocedureamountDayService.deleteRecordWorkprocedureamountDayByIds(ids));
    }
}
