package com.fjhx.controller.water;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.base.Condition;
import com.fjhx.entity.water.WaterBack;
import com.fjhx.params.water.WaterBackAddVo;
import com.fjhx.params.water.WaterBackVo;
import com.fjhx.service.water.WaterBackService;
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-27
 */
@RestController
@RequestMapping("/waterBack")
public class WaterBackController {

    @Autowired
    private WaterBackService waterBackService;

    /**
     * 添加退货
     */
    @PostMapping("/add")
    public R add(@RequestBody List<WaterBackAddVo> waterBackAddVoList) {
        waterBackService.add(waterBackAddVoList);
        return R.success();
    }

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

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

    /**
     * 删除
     */
    @PostMapping("/delete")
    public R delete(@RequestBody WaterBack waterBack) {
        waterBackService.delete(waterBack.getId());
        return R.success();
    }

    /**
     * 提交
     */
    @PostMapping("/submit")
    public R submit(@RequestBody WaterBackVo waterBackVo) {
        waterBackService.submit(waterBackVo);
        return R.success();
    }

    /**
     * 获取直喷打纸热传角色用户
     */
    @PostMapping("/getUserByAppointDept")
    public R getUserByAppointDept() {
        Map<String, JSONObject> result = waterBackService.getUserByAppointDept();
        return R.success(result);
    }

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

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

}

