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.RecordShiftamountDay;
import com.ruoyi.report.service.IRecordShiftamountDayService;
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/ShiftAmountDatReport")
public class RecordShiftamountDayController extends BaseController
{
    private String prefix = "report/ShiftAmountDatReport";

    @Autowired
    private IRecordShiftamountDayService recordShiftamountDayService;

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

    /**
     * 查询班次产量日报列表
     */
    @RequiresPermissions("report:ShiftAmountDatReport:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RecordShiftamountDay recordShiftamountDay)
    {
        startPage();
        List<RecordShiftamountDay> list = recordShiftamountDayService.selectRecordShiftamountDayList(recordShiftamountDay);
        return getDataTable(list);
    }

    /**
     * 导出班次产量日报列表
     */
    @RequiresPermissions("report:ShiftAmountDatReport:export")
    @Log(title = "班次产量日报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RecordShiftamountDay recordShiftamountDay)
    {
        List<RecordShiftamountDay> list = recordShiftamountDayService.selectRecordShiftamountDayList(recordShiftamountDay);
        ExcelUtil<RecordShiftamountDay> util = new ExcelUtil<RecordShiftamountDay>(RecordShiftamountDay.class);
        return util.exportExcel(list, "ShiftAmountDatReport");
    }

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

    /**
     * 新增保存班次产量日报
     */
    @RequiresPermissions("report:ShiftAmountDatReport:add")
    @Log(title = "班次产量日报", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RecordShiftamountDay recordShiftamountDay)
    {
        return toAjax(recordShiftamountDayService.insertRecordShiftamountDay(recordShiftamountDay));
    }

    /**
     * 修改班次产量日报
     */
    @GetMapping("/edit/{objid}")
    public String edit(@PathVariable("objid") Long objid, ModelMap mmap)
    {
        RecordShiftamountDay recordShiftamountDay = recordShiftamountDayService.selectRecordShiftamountDayById(objid);
        mmap.put("recordShiftamountDay", recordShiftamountDay);
        return prefix + "/edit";
    }

    /**
     * 修改保存班次产量日报
     */
    @RequiresPermissions("report:ShiftAmountDatReport:edit")
    @Log(title = "班次产量日报", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RecordShiftamountDay recordShiftamountDay)
    {
        return toAjax(recordShiftamountDayService.updateRecordShiftamountDay(recordShiftamountDay));
    }

    /**
     * 删除班次产量日报
     */
    @RequiresPermissions("report:ShiftAmountDatReport:remove")
    @Log(title = "班次产量日报", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(recordShiftamountDayService.deleteRecordShiftamountDayByIds(ids));
    }
}
