package com.ruoyi.project.production.controller;

import java.util.Date;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.production.domain.TMonthlyQualityReportS5012;
import com.ruoyi.project.production.service.ITMonthlyQualityReportS5012Service;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 质量月报S5012Controller
 *
 * @author ruoyi
 * @date 2023-10-27
 */
@RestController
@RequestMapping("/production/s5012")
public class TMonthlyQualityReportS5012Controller extends BaseController
{
    @Autowired
    private ITMonthlyQualityReportS5012Service tMonthlyQualityReportS5012Service;

    /**
     * 查询质量月报S5012列表
     */
    @PreAuthorize("@ss.hasPermi('production:quality:list')")
    @GetMapping("/list")
    public AjaxResult list(TMonthlyQualityReportS5012 tMonthlyQualityReportS5012)
    {
        Date endDate = tMonthlyQualityReportS5012.getEndDate();
        endDate.setHours(23);
        endDate.setMinutes(59);
        endDate.setSeconds(59);
        tMonthlyQualityReportS5012.setEndDate(endDate);
        return AjaxResult.success(tMonthlyQualityReportS5012Service.selectTMonthlyQualityReportS5012List(tMonthlyQualityReportS5012));
    }

    /**
     * 导出质量月报S5012列表
     */
    @PreAuthorize("@ss.hasPermi('production:quality:export')")
    @Log(title = "质量月报S5012", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TMonthlyQualityReportS5012 tMonthlyQualityReportS5012)
    {
        List<TMonthlyQualityReportS5012> list = tMonthlyQualityReportS5012Service.selectTMonthlyQualityReportS5012List(tMonthlyQualityReportS5012);
        ExcelUtil<TMonthlyQualityReportS5012> util = new ExcelUtil<TMonthlyQualityReportS5012>(TMonthlyQualityReportS5012.class);
        return util.exportExcel(list, "s5012");
    }

    /**
     * 获取质量月报S5012详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:quality:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tMonthlyQualityReportS5012Service.selectTMonthlyQualityReportS5012ById(id));
    }

    /**
     * 新增质量月报S5012
     */
    @PreAuthorize("@ss.hasPermi('production:quality:add')")
    @Log(title = "质量月报S5012", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TMonthlyQualityReportS5012 tMonthlyQualityReportS5012)
    {
        return toAjax(tMonthlyQualityReportS5012Service.insertTMonthlyQualityReportS5012(tMonthlyQualityReportS5012));
    }

    /**
     * 修改质量月报S5012
     */
    @PreAuthorize("@ss.hasPermi('production:quality:edit')")
    @Log(title = "质量月报S5012", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TMonthlyQualityReportS5012 tMonthlyQualityReportS5012)
    {
        return toAjax(tMonthlyQualityReportS5012Service.updateTMonthlyQualityReportS5012(tMonthlyQualityReportS5012));
    }

    /**
     * 删除质量月报S5012
     */
    @PreAuthorize("@ss.hasPermi('production:quality:remove')")
    @Log(title = "质量月报S5012", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tMonthlyQualityReportS5012Service.deleteTMonthlyQualityReportS5012ByIds(ids));
    }
}
