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.RecordPlanrateamountDay;
import com.ruoyi.report.service.IRecordPlanrateamountDayService;
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/PlanRateAmountDatReport")
public class RecordPlanrateamountDayController extends BaseController
{
    private String prefix = "report/PlanRateAmountDatReport";

    @Autowired
    private IRecordPlanrateamountDayService recordPlanrateamountDayService;

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

    /**
     * 查询计划完成率产量日报列表
     */
    @RequiresPermissions("report:PlanRateAmountDatReport:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RecordPlanrateamountDay recordPlanrateamountDay)
    {
        startPage();
        List<RecordPlanrateamountDay> list = recordPlanrateamountDayService.selectRecordPlanrateamountDayList(recordPlanrateamountDay);
        return getDataTable(list);
    }

    /**
     * 导出计划完成率产量日报列表
     */
    @RequiresPermissions("report:PlanRateAmountDatReport:export")
    @Log(title = "计划完成率产量日报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RecordPlanrateamountDay recordPlanrateamountDay)
    {
        List<RecordPlanrateamountDay> list = recordPlanrateamountDayService.selectRecordPlanrateamountDayList(recordPlanrateamountDay);
        ExcelUtil<RecordPlanrateamountDay> util = new ExcelUtil<RecordPlanrateamountDay>(RecordPlanrateamountDay.class);
        return util.exportExcel(list, "PlanRateAmountDatReport");
    }

    /**
     * 新增计划完成率产量日报
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存计划完成率产量日报
     */
    @RequiresPermissions("report:PlanRateAmountDatReport:add")
    @Log(title = "计划完成率产量日报", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RecordPlanrateamountDay recordPlanrateamountDay)
    {
        return toAjax(recordPlanrateamountDayService.insertRecordPlanrateamountDay(recordPlanrateamountDay));
    }

    /**
     * 修改计划完成率产量日报
     */
    @GetMapping("/edit/{objid}")
    public String edit(@PathVariable("objid") Long objid, ModelMap mmap)
    {
        RecordPlanrateamountDay recordPlanrateamountDay = recordPlanrateamountDayService.selectRecordPlanrateamountDayById(objid);
        mmap.put("recordPlanrateamountDay", recordPlanrateamountDay);
        return prefix + "/edit";
    }

    /**
     * 修改保存计划完成率产量日报
     */
    @RequiresPermissions("report:PlanRateAmountDatReport:edit")
    @Log(title = "计划完成率产量日报", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RecordPlanrateamountDay recordPlanrateamountDay)
    {
        return toAjax(recordPlanrateamountDayService.updateRecordPlanrateamountDay(recordPlanrateamountDay));
    }

    /**
     * 删除计划完成率产量日报
     */
    @RequiresPermissions("report:PlanRateAmountDatReport:remove")
    @Log(title = "计划完成率产量日报", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(recordPlanrateamountDayService.deleteRecordPlanrateamountDayByIds(ids));
    }
}
