package com.fjhx.controller.water;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.base.Condition;
import com.fjhx.entity.water.WaterTransfer;
import com.fjhx.params.water.WaterTransferVo;
import com.fjhx.service.water.WaterTransferService;
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-28
 */
@RestController
@RequestMapping("/waterTransfer")
public class WaterTransferController {

    @Autowired
    private WaterTransferService waterTransferService;

    /**
     * 添加面料转仓
     */
    @PostMapping("/add")
    public R add(@RequestBody List<WaterTransferVo> waterTransferVoList) {
        waterTransferService.add(waterTransferVoList);
        return R.success();
    }

    /**
     * 待复核列表
     */
    @PostMapping("/toBeReviewedList")
    public R toBeReviewedList() {
        List<Map<String, Object>> result = waterTransferService.toBeReviewedList();
        return R.success(result);
    }

    /**
     * 明细
     */
    @PostMapping("/details")
    public R details(@RequestBody WaterTransfer waterTransfer) {
        Map<String, Object> result = waterTransferService.details(waterTransfer.getId());
        return R.success(result);
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public R delete(@RequestBody WaterTransfer waterTransfer) {
        waterTransferService.delete(waterTransfer.getId());
        return R.success();
    }

    /**
     * 提交
     */
    @PostMapping("/submit")
    public R submit(@RequestBody WaterTransferVo waterTransferVo) {
        waterTransferService.submit(waterTransferVo);
        return R.success();
    }

    /**
     * 转仓看板统计
     */
    @PostMapping("/statistics")
    public R statistics(@RequestBody Condition condition) {
        Map<String, Object> result = waterTransferService.statistics(condition);
        return R.success(result);
    }

    /**
     * 转仓看板分页
     */
    @PostMapping("/page")
    public R page(@RequestBody Condition condition) {
        Page<Map<String, Object>> result = waterTransferService.getPage(condition);
        return R.success(result);
    }

}

