package com.fjhx.material.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.base.Condition;
import com.fjhx.entity.material.MaterialReceiving;
import com.fjhx.entity.material.MaterialReceivingDetails;
import com.fjhx.material.service.MaterialReceivingService;
import com.fjhx.params.material.MaterialReceivingVo;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 物料接收 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-10-11
 */
@RestController
@RequestMapping("/materialReceiving")
public class MaterialReceivingController {

    @Autowired
    private MaterialReceivingService materialReceivingService;

    @PostMapping("/page")
    public R page(@RequestBody Map<String, String> condition) {
        Page<MaterialReceiving> result = materialReceivingService.getPage(condition);
        return R.success(result);
    }

    @PostMapping("/add")
    public R add(@RequestBody MaterialReceivingVo materialReceivingVo) {
        materialReceivingService.add(materialReceivingVo);
        return R.success();
    }

    @PostMapping("/edit")
    public R edit(@RequestBody MaterialReceivingVo materialReceivingVo) {
        materialReceivingService.edit(materialReceivingVo);
        return R.success();
    }

    @PostMapping("/delete")
    public R delete(@RequestBody MaterialReceivingVo materialReceivingVo) {
        materialReceivingService.delete(materialReceivingVo);
        return R.success();
    }

    /**
     * 出库提交
     */
    @PostMapping("/submit")
    public R submit(@RequestBody MaterialReceivingVo materialReceivingVo) {
        materialReceivingService.submit(materialReceivingVo);
        return R.success();
    }

    /**
     * 物料接收列表
     */
    @PostMapping("/list")
    public R list(@RequestBody MaterialReceivingVo materialReceivingVo) {
        List<Map<String, Object>> result = materialReceivingService.getList(materialReceivingVo);
        return R.success(result);
    }

    /**
     * 物料接收操作
     */
    @PostMapping("/operation")
    public R operation(@RequestBody Condition condition) {
        materialReceivingService.operation(condition);
        return R.success();
    }

    /**
     * 流程详情
     */
    @PostMapping("flowDetails")
    public R flowDetails(@RequestBody Condition condition) {
        List<Map<String, Object>> result = materialReceivingService.flowDetails(condition);
        return R.success(result);
    }

    /**
     * 流程处理
     */
    @PostMapping("handleFlow")
    public R handleFlow(@RequestBody Condition condition) {
        materialReceivingService.handleFlow(condition);
        return R.success();
    }

    /**
     * 待出库物料
     */
    @PostMapping("toBeReceivedList")
    public R toBeReceivedList(@RequestBody Condition condition) {
        List<Map<String, Object>> result = materialReceivingService.toBeReceivedList(condition);
        return R.success(result);
    }

    /**
     * 忽略驳回
     */
    @PostMapping("ignore")
    public R ignore(@RequestBody MaterialReceivingDetails materialReceivingDetails) {
        materialReceivingService.ignore(materialReceivingDetails);
        return R.success();
    }

}

