package com.shkj.wms.controller.business;

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

import com.shkj.common.annotation.Log;
import com.shkj.common.core.controller.BaseController;
import com.shkj.common.core.domain.Result;
import com.shkj.common.core.page.TableDataInfo;
import com.shkj.common.enums.BusinessType;
import com.shkj.common.utils.poi.ExcelUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.shkj.wms.domain.BusinPlcException;
import com.shkj.wms.service.IBusinPlcExceptionService;

/**
 * PLC异常内容Controller
 * 
 * @author zjx
 * @date 2023-09-27
 */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/wms/exception")
public class BusinPlcExceptionController extends BaseController
{
    private IBusinPlcExceptionService businPlcExceptionService;

    /**
     * 查询PLC异常内容列表
     */
    @PreAuthorize("@ss.hasPermi('wms:exception:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusinPlcException businPlcException)
    {
        startPage();
        List<BusinPlcException> list = businPlcExceptionService.selectBusinPlcExceptionList(businPlcException);
        return getDataTable(list);
    }

    /**
     * 导出PLC异常内容列表
     */
    @PreAuthorize("@ss.hasPermi('wms:exception:export')")
    @Log(title = "PLC异常内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusinPlcException businPlcException)
    {
        List<BusinPlcException> list = businPlcExceptionService.selectBusinPlcExceptionList(businPlcException);
        ExcelUtil<BusinPlcException> util = new ExcelUtil<BusinPlcException>(BusinPlcException.class);
        util.exportExcel(response, list, "PLC异常内容数据");
    }

    /**
     * 获取PLC异常内容详细信息
     */
    @PreAuthorize("@ss.hasPermi('wms:exception:query')")
    @GetMapping("/getInfo")
    public Result<BusinPlcException> getInfo(@PathVariable("id") Long id)
    {
        return businPlcExceptionService.selectBusinPlcExceptionById(id);
    }

    /**
     * 新增PLC异常内容
     */
    @PreAuthorize("@ss.hasPermi('wms:exception:add')")
    @Log(title = "PLC异常内容", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public Result<Boolean> add(@RequestBody BusinPlcException businPlcException)
    {
        return businPlcExceptionService.insertBusinPlcException(businPlcException);
    }

    /**
     * 修改PLC异常内容
     */
    @PreAuthorize("@ss.hasPermi('wms:exception:edit')")
    @Log(title = "PLC异常内容", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public Result<Boolean> edit(@RequestBody BusinPlcException businPlcException)
    {
        return businPlcExceptionService.updateBusinPlcException(businPlcException);
    }

    /**
     * 删除PLC异常内容
     */
    @PreAuthorize("@ss.hasPermi('wms:exception:remove')")
    @Log(title = "PLC异常内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/del")
    public Result<Boolean> remove(@RequestParam Long[] ids)
    {
        return businPlcExceptionService.deleteBusinPlcExceptionByIds(ids);
    }
}
