package cn.iocoder.yudao.module.stockOperate.controller.admin;


import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSo;
import cn.iocoder.yudao.module.stockOperate.service.DlRepairSoService;
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoReqVO;
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoRespVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * 采购单领料单(DlRepairSo)表控制层
 *
 * @author 小李
 * @date 9:13 2024/9/13
 **/
@RestController
@RequestMapping("/repair/so")
public class DlRepairSoController {
    /**
     * 服务对象
     */
    @Resource
    private DlRepairSoService dlRepairSoService;

    /**
     * 采购单/领料单 新增
     *
     * @param repairSoRespVO 采购单对象
     * @author 小李
     * @date 10:49 2024/9/14
     **/
    @PostMapping("/create")
    @Operation(summary = "采购单/领料单 新增")
    public CommonResult<?> createRepairSo(@RequestBody DlRepairSoRespVO repairSoRespVO) {
        dlRepairSoService.createRepairSo(repairSoRespVO);
        return CommonResult.ok();
    }

    /**
     * 采购单/领料单新增分页
     *
     * @param repairSoReqVO 查询对象
     * @param pageNo        页码
     * @param pageSize      条数
     * @author 小李
     * @date 18:14 2024/9/14
     **/
    @GetMapping("/page")
    @Operation(summary = "采购单/领料单 分页")
    public CommonResult<?> getRepairSoPage(DlRepairSoReqVO repairSoReqVO,
                                           @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
                                           @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        Page<DlRepairSo> page = new Page<>(pageNo, pageSize);
        return success(dlRepairSoService.getRepairSoPage(repairSoReqVO, page));
    }

    /**
     * 采购单/领料单 作废
     *
     * @param repairSoReqVO 作废对象
     * @author 小李
     * @date 11:12 2024/9/18
     **/
    @PostMapping("/void")
    @Operation(summary = "采购单/领料单 作废")
    public CommonResult<?> voidRepairSo(@RequestBody DlRepairSoReqVO repairSoReqVO) {
        dlRepairSoService.voidRepairSo(repairSoReqVO);
        return CommonResult.ok();
    }

    /**
     * 采购单/领料单 查看
     *
     * @param id 主键
     * @author 小李
     * @date 9:34 2024/9/22
     **/
    @GetMapping("/get")
    @Operation(summary = "采购单/领料单 查看")
    public CommonResult<?> getRepairSoById(@RequestParam("id") String id) {
        return success(dlRepairSoService.getRepairSoById(id));
    }

    /**
     * 员工确认领料
     *
     * @param id 单据ID 领料单主表
     * @author 小李
     * @date 11:58 2024/10/21
     **/
    @GetMapping("/confirmGet")
    @Operation(summary = "员工确认领料")
    public CommonResult<?> confirmGet(@RequestParam("id") String id) {
        dlRepairSoService.confirmGet(id);
        return CommonResult.ok();
    }

    /**
     * 员工确认退料
     *
     * @param id 退料单主表ID
     * @author 小李
     * @date 19:41 2024/10/21
     **/
    @GetMapping("/confirmBack")
    @Operation(summary = "员工确认退料")
    public CommonResult<?> confirmBack(@RequestParam("id") String id) {
        dlRepairSoService.confirmBack(id);
        return CommonResult.ok();
    }


    /**
     * 采购入库
     *
     * @param repairSoReqVO DlRepairSoReqVO实体
     * @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
     * @author PQZ
     * @date 10:43 2024/10/25
     **/
    @PostMapping("/inWare")
    @Operation(summary = "采购入库")
    public CommonResult<?> inWare(@RequestBody DlRepairSoReqVO repairSoReqVO) {
        dlRepairSoService.inWare(repairSoReqVO);
        return CommonResult.ok();
    }
}

