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.RecordGroupamountDay;
import com.ruoyi.report.service.IRecordGroupamountDayService;
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/GroupAmountDatReport")
public class RecordGroupamountDayController extends BaseController
{
    private String prefix = "report/GroupAmountDatReport";

    @Autowired
    private IRecordGroupamountDayService recordGroupamountDayService;

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

    /**
     * 查询班组产量日报列表
     */
    @RequiresPermissions("report:GroupAmountDatReport:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RecordGroupamountDay recordGroupamountDay)
    {
        startPage();
        List<RecordGroupamountDay> list = recordGroupamountDayService.selectRecordGroupamountDayList(recordGroupamountDay);
        return getDataTable(list);
    }

    /**
     * 导出班组产量日报列表
     */
    @RequiresPermissions("report:GroupAmountDatReport:export")
    @Log(title = "班组产量日报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RecordGroupamountDay recordGroupamountDay)
    {
        List<RecordGroupamountDay> list = recordGroupamountDayService.selectRecordGroupamountDayList(recordGroupamountDay);
        ExcelUtil<RecordGroupamountDay> util = new ExcelUtil<RecordGroupamountDay>(RecordGroupamountDay.class);
        return util.exportExcel(list, "GroupAmountDatReport");
    }

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

    /**
     * 新增保存班组产量日报
     */
    @RequiresPermissions("report:GroupAmountDatReport:add")
    @Log(title = "班组产量日报", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RecordGroupamountDay recordGroupamountDay)
    {
        return toAjax(recordGroupamountDayService.insertRecordGroupamountDay(recordGroupamountDay));
    }

    /**
     * 修改班组产量日报
     */
    @GetMapping("/edit/{objid}")
    public String edit(@PathVariable("objid") Long objid, ModelMap mmap)
    {
        RecordGroupamountDay recordGroupamountDay = recordGroupamountDayService.selectRecordGroupamountDayById(objid);
        mmap.put("recordGroupamountDay", recordGroupamountDay);
        return prefix + "/edit";
    }

    /**
     * 修改保存班组产量日报
     */
    @RequiresPermissions("report:GroupAmountDatReport:edit")
    @Log(title = "班组产量日报", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RecordGroupamountDay recordGroupamountDay)
    {
        return toAjax(recordGroupamountDayService.updateRecordGroupamountDay(recordGroupamountDay));
    }

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