package com.bonus.sgzb.material.controller;

import com.bonus.sgzb.common.core.utils.poi.ExcelUtil;
import com.bonus.sgzb.common.core.web.controller.BaseController;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.log.annotation.Log;
import com.bonus.sgzb.common.log.enums.BusinessType;
import com.bonus.sgzb.common.security.annotation.RequiresPermissions;
import com.bonus.sgzb.material.domain.InputRecord;
import com.bonus.sgzb.material.domain.OutRecord;
import com.bonus.sgzb.material.domain.ScrapRecord;
import com.bonus.sgzb.material.service.InputRecordService;
import com.bonus.sgzb.material.service.ScrapRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * @author hay
 * @description 综合查询--机具入库查询
 * @date 2024/2/26 14:15
 */
@Api(tags = "综合查询--机具入库查询")
@RestController
@RequestMapping("/inputRecord")
public class InputRecordController extends BaseController {
    @Autowired
    private InputRecordService inputRecordService;

    /**
     * 机具入库查询列表
     */
    @ApiOperation(value = "综合查询--机具入库查询列表")
    @GetMapping("/getInputRecordList")
    @RequiresPermissions("storage:list:query")
    public AjaxResult getInputRecordList(InputRecord bean) {
        startPage();
        List<InputRecord> list = inputRecordService.getInputRecordList(bean);
        return AjaxResult.success(getDataTable(list));
    }

    @ApiOperation(value = "综合查询--机具出库查询列表")
    @GetMapping("/getOutputRecordList")
    public AjaxResult getOutputRecordList(OutRecord bean) {
        startPage();
        List<OutRecord> list = inputRecordService.getOutputRecordList(bean);
        return AjaxResult.success(getDataTable(list));
    }

    /**
     * 导出综合查询机具入库查询列表
     */
    @ApiOperation("导出综合查询机具入库查询列表")
    @Log(title = "导出综合查询机具入库查询列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @RequiresPermissions("storage:list:export")
    public void exInputport(HttpServletResponse response, InputRecord bean) {
        List<InputRecord> list = inputRecordService.getInputRecordList(bean);
        ExcelUtil<InputRecord> util = new ExcelUtil<InputRecord>(InputRecord.class);
        util.exportExcel(response, list, "综合查询--入库记录");
    }

    @ApiOperation("导出综合查询机具出库查询列表")
    @Log(title = "导出综合查询机具出库查询列表", businessType = BusinessType.EXPORT)
    @PostMapping("/exOutputport")
    public void exOutputport(HttpServletResponse response, OutRecord bean) {
        List<OutRecord> list = inputRecordService.getOutputRecordList(bean);
        ExcelUtil<OutRecord> util = new ExcelUtil<OutRecord>(OutRecord.class);
        util.exportExcel(response, list, "综合查询--出库记录");
    }

}
