package com.fjhx.applet.controller;

import com.fjhx.applet.service.MaterialReceiveService;
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;

@RestController
@RequestMapping("/materialReceive")
public class MaterialReceiveController {

    @Autowired
    private MaterialReceiveService materialReceiveService;

    /**
     * 手持机出库提交
     */
    @PostMapping("/submit")
    public R submit(@RequestBody Map<String, String> condition) {
        materialReceiveService.submit(condition.get("checkUserId"));
        return R.success();
    }

    @PostMapping("/list")
    public R list(@RequestBody Map<String, String> condition) {
        List<Map<String, Object>> list = materialReceiveService.getList(condition.get("account"));
        return R.success(list);
    }

    @PostMapping("/operation")
    public R operation(@RequestBody Map<String, Object> condition) {
        materialReceiveService.operation(condition);
        return R.success();
    }

    @PostMapping("flowDetails")
    public R flowDetails(@RequestBody Map<String, String> condition) {
        return R.success(materialReceiveService.flowDetails(condition));
    }

    @PostMapping("handleFlow")
    public R handleFlow(@RequestBody Map<String, String> condition) {
        materialReceiveService.handleFlow(condition);
        return R.success();
    }

    @PostMapping("/receiveBackupList")
    public R receiveBackupList(@RequestBody Map<String, String> condition) {
        List<Map<String, Object>> list = materialReceiveService.getReceiveBackupList(condition.get("account"));
        return R.success(list);
    }

}
