package com.bonus.material.app.controller;

import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.app.domain.MachineOcrBean;
import com.bonus.material.app.service.AppOcrService;
import com.bonus.material.common.annotation.PreventRepeatSubmit;
import com.bonus.material.ma.domain.vo.MachineVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * app ocr扫描接口
 * @Author ma_sh
 * @create 2025/1/2 13:49
 */
@RestController
@RequestMapping("/app/ocr")
public class AppOcrController extends BaseController {

    @Resource
    private AppOcrService appOcrService;

    /**
     * 查询机具出库列表
     * @param bean
     * @return
     */
    @GetMapping("/findByPage")
    public AjaxResult findByPage(MachineOcrBean bean) {
        startPage();
        List<MachineOcrBean> list = appOcrService.findByPage(bean);
        return AjaxResult.success(getDataTable(list));
    }

    /**
     * 根据code查询机具出库列表
     * @param bean
     * @return
     */
    @GetMapping("/findOutListByDeviceCode")
    public AjaxResult findOutListByDeviceCode(MachineOcrBean bean) {
        List<MachineVo> list = appOcrService.findOutListByDeviceCode(bean);
        return AjaxResult.success(list);
    }

    /**
     * 提交机具出库
     * @param bean
     * @return
     */
    @ApiOperation(value = "提交机具出库")
    @PreventRepeatSubmit
    @PostMapping("/submitOcrOut")
    public AjaxResult submitOcrOut(@RequestBody MachineOcrBean bean)
    {
        return appOcrService.submitOcrOut(bean);
    }

    /**
     * 根据code查询机具退料列表
     * @param bean
     * @return
     */
    @GetMapping("/findBackListByDeviceCode")
    public AjaxResult findBackListByDeviceCode(MachineOcrBean bean) {
        List<MachineVo> list = appOcrService.findBackListByDeviceCode(bean);
        return AjaxResult.success(list);
    }

    /**
     * 提交机具退料
     * @param bean
     * @return
     */
    @ApiOperation(value = "提交机具退料")
    @PreventRepeatSubmit
    @PostMapping("/submitOcrBack")
    public AjaxResult submitOcrBack(@RequestBody MachineOcrBean bean)
    {
        return appOcrService.submitOcrBack(bean);
    }

    @ApiOperation(value = "获取ocr编码")
    @PreventRepeatSubmit
    @PostMapping("/getOcrCode")
    public AjaxResult getOcrCode(@RequestBody MachineOcrBean bean)
    {
        return appOcrService.getOcrCode(bean);
    }

    @ApiOperation(value = "获取ocr编码")
    @PreventRepeatSubmit
    @PostMapping("/getOcrCodeTwo")
    public AjaxResult getOcrCodeTwo(@RequestBody MachineOcrBean bean)
    {
        return appOcrService.getOcrCodeTwo(bean);
    }

    @ApiOperation(value = "推送设备至第三方入库")
    @PreventRepeatSubmit
    @PostMapping("/addDeviceNumber")
    public AjaxResult addDeviceNumber(@RequestBody MachineOcrBean bean)
    {
        return appOcrService.addDeviceNumber(bean);
    }
}
