package com.bonus.material.warningAnalysis.controller;

import com.bonus.common.core.utils.poi.ExcelUtil;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import com.bonus.material.common.annotation.PreventRepeatSubmit;
import com.bonus.material.warningAnalysis.domain.UseMaintenanceWarningBean;
import com.bonus.material.warningAnalysis.service.UseMaintenanceWarningService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
* @description 工程在用检修预警
* @author hay
* @date   2025/3/6 15:32
*/
@Api(tags = "工程在用检修预警接口")
@RestController
@RequestMapping("/useMaintenanceWarning")
public class UseMaintenanceWarningController extends BaseController
{
    @Autowired
    private UseMaintenanceWarningService service;

    /**
     * 查询工程在用检修预警
     */
    @ApiOperation(value = "查询检修预警列表")
    @GetMapping("/list")
    public TableDataInfo list(UseMaintenanceWarningBean bean)
    {
        startPage();
        List<UseMaintenanceWarningBean> list = service.getList(bean);
        return getDataTable(list);
    }

    /**
     * 查询安全工器具检修列表
     * @param bean
     * @return
     */
    @ApiOperation(value = "查询安全工器具检修列表")
    @GetMapping("/getOverTimeList")
    public TableDataInfo getOverTimeList(UseMaintenanceWarningBean bean)
    {
        startPage();
        List<UseMaintenanceWarningBean> list = service.getOverTimeListList(bean);
        return getDataTable(list);
    }

    /**
     * 导出安全工器具检修过期列表
     * @param response
     * @param bean
     */
    @ApiOperation(value = "导出安全工器具检修过期列表")
    @PreventRepeatSubmit
    @SysLog(title = "检修预警", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出安全工器具检修过期列表")
    @PostMapping("/exportOverTimeList")
    public void exportOverTimeList(HttpServletResponse response, UseMaintenanceWarningBean bean)
    {
        List<UseMaintenanceWarningBean> list = service.getOverTimeListList(bean);
        ExcelUtil<UseMaintenanceWarningBean> util = new ExcelUtil<UseMaintenanceWarningBean>(UseMaintenanceWarningBean.class);
        util.exportExcel(response, list, "安全工器具检修过期列表");
    }

    /**
     * 导出
     */
    @ApiOperation(value = "导出检修预警列表")
    @PreventRepeatSubmit
    @SysLog(title = "检修预警", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出检修预警列表")
    @PostMapping("/export")
    public void export(HttpServletResponse response, UseMaintenanceWarningBean bean)
    {
        List<UseMaintenanceWarningBean> list = service.getList(bean);
        ExcelUtil<UseMaintenanceWarningBean> util = new ExcelUtil<UseMaintenanceWarningBean>(UseMaintenanceWarningBean.class);
        util.exportExcel(response, list, "检修预警数据");
    }


}
