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.RecordDeviceamountDay;
import com.ruoyi.report.service.IRecordDeviceamountDayService;
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/DeviceAmountDayReport")
public class RecordDeviceamountDayController extends BaseController
{
    private String prefix = "report/DeviceAmountDayReport";

    @Autowired
    private IRecordDeviceamountDayService recordDeviceamountDayService;

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

    /**
     * 查询设备产量日报列表
     */
    @RequiresPermissions("report:DeviceAmountDayReport:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RecordDeviceamountDay recordDeviceamountDay)
    {
        startPage();
        List<RecordDeviceamountDay> list = recordDeviceamountDayService.selectRecordDeviceamountDayList(recordDeviceamountDay);
        return getDataTable(list);
    }

    /**
     * 导出设备产量日报列表
     */
    @RequiresPermissions("report:DeviceAmountDayReport:export")
    @Log(title = "设备产量日报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RecordDeviceamountDay recordDeviceamountDay)
    {
        List<RecordDeviceamountDay> list = recordDeviceamountDayService.selectRecordDeviceamountDayList(recordDeviceamountDay);
        ExcelUtil<RecordDeviceamountDay> util = new ExcelUtil<RecordDeviceamountDay>(RecordDeviceamountDay.class);
        return util.exportExcel(list, "DeviceAmountDayReport");
    }

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

    /**
     * 新增保存设备产量日报
     */
    @RequiresPermissions("report:DeviceAmountDayReport:add")
    @Log(title = "设备产量日报", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RecordDeviceamountDay recordDeviceamountDay)
    {
        return toAjax(recordDeviceamountDayService.insertRecordDeviceamountDay(recordDeviceamountDay));
    }

    /**
     * 修改设备产量日报
     */
    @GetMapping("/edit/{objid}")
    public String edit(@PathVariable("objid") Long objid, ModelMap mmap)
    {
        RecordDeviceamountDay recordDeviceamountDay = recordDeviceamountDayService.selectRecordDeviceamountDayById(objid);
        mmap.put("recordDeviceamountDay", recordDeviceamountDay);
        return prefix + "/edit";
    }

    /**
     * 修改保存设备产量日报
     */
    @RequiresPermissions("report:DeviceAmountDayReport:edit")
    @Log(title = "设备产量日报", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RecordDeviceamountDay recordDeviceamountDay)
    {
        return toAjax(recordDeviceamountDayService.updateRecordDeviceamountDay(recordDeviceamountDay));
    }

    /**
     * 删除设备产量日报
     */
    @RequiresPermissions("report:DeviceAmountDayReport:remove")
    @Log(title = "设备产量日报", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(recordDeviceamountDayService.deleteRecordDeviceamountDayByIds(ids));
    }
}
