package com.fjhx.stock.controller;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.base.Condition;
import com.fjhx.stock.service.StockWaterService;
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-07-04
 */
@RestController
@RequestMapping("/stockWater")
public class StockWaterController {

    @Autowired
    private StockWaterService stockWaterService;


    /**
     * 库存报表-》领料序时浦-》统计
     */
    @PostMapping("getPickingStatistics")
    public R getPickingStatistics(@RequestBody Map<String, String> condition) {
        Map<String, Object> result = stockWaterService.getPickingStatistics(condition);
        return R.success(result);
    }

    /**
     * 库存报表-》领料序时浦-》分页类型统计
     */
    @PostMapping("getPickingStockChangeTypeCount")
    public R getPickingStockChangeTypeCount(@RequestBody Map<String, String> condition) {
        Map<String, Integer> result = stockWaterService.getPickingStockChangeTypeCount(condition);
        return R.success(result);
    }

    /**
     * 库存报表-》领料序时浦-》分页列表
     */
    @PostMapping("getPickingPage")
    public R getPickingPage(@RequestBody Map<String, String> condition) {
        Page<Map<String, Object>> result = stockWaterService.getPickingPage(condition);
        return R.success(result);
    }

    /**
     * 申购管理-》合同付款-》申购金额统计
     */
    @PostMapping("subscriptionAmountStatistics")
    public R contractPaymentStatistics(@RequestBody Map<String, String> condition) {
        Map<String, Object> result = stockWaterService.contractPaymentStatistics(condition);
        return R.success(result);
    }

    /**
     * 申购管理-》合同付款-》申购金额列表
     */
    @PostMapping("subscriptionAmountPage")
    public R subscriptionAmountPage(@RequestBody Map<String, String> condition) {
        Page<Map<String, Object>> result = stockWaterService.subscriptionAmountPage(condition);
        return R.success(result);
    }

    /**
     * 今日剩余统计（原库存管理）
     */
    @PostMapping("remainingToday")
    public R remainingToday(@RequestBody Map<String, String> condition) {
        Map<String, Object> result = stockWaterService.remainingToday(condition);
        return R.success(result);
    }

    /**
     * 今日剩余分页列表（原库存管理）
     */
    @PostMapping("remainingTodayPage")
    public R remainingTodayPage(@RequestBody Map<String, String> condition) {
        Page<Map<String, Object>> result = stockWaterService.remainingTodayPage(condition);
        return R.success(result);
    }

    /**
     * 今日剩余分页列表（原库存管理）
     */
    @PostMapping("remainingTodayList")
    public R remainingTodayList(@RequestBody Map<String, String> condition) {
        List<Map<String, Object>> result = stockWaterService.remainingTodayList(condition);
        return R.success(result);
    }

    /**
     * 今日剩余在库列表
     */
    @PostMapping("inStockList")
    public R inStockList(@RequestBody Map<String, String> condition) {
        List<Map<String, Object>> result = stockWaterService.inStockList(condition);
        return R.success(result);
    }

    /**
     * 入库序时浦
     */
    @PostMapping("receiptSequence")
    public R receiptSequence(@RequestBody Map<String, String> condition) {
        Page<Map<String, Object>> result = stockWaterService.receiptSequence(condition);
        return R.success(result);
    }

    /**
     * 合同付款列表关联
     */
    @PostMapping("contractPaymentList")
    public R contractPaymentList(@RequestBody Map<String, String> condition) {
        List<Map<String, Object>> result = stockWaterService.contractPaymentList(condition);
        return R.success(result);
    }

    /**
     * 入库单列表关联
     */
    @PostMapping("receiptList")
    public R receiptList(@RequestBody Map<String, String> condition) {
        List<Map<String, Object>> result = stockWaterService.receiptList(condition);
        return R.success(result);
    }

    /**
     * 领料
     */
    @PostMapping("/issue")
    public R issue(@RequestBody Condition condition) {
        List<JSONObject> list = stockWaterService.issue(condition);
        return R.success(list);
    }

    /**
     * 退料
     */
    @PostMapping("/materialReturn")
    public R materialReturn(@RequestBody Condition condition) {
        List<JSONObject> list = stockWaterService.materialReturn(condition);
        return R.success(list);
    }

    /**
     * 转入
     */
    @PostMapping("/transferIn")
    public R transferIn(@RequestBody Condition condition) {
        List<JSONObject> list = stockWaterService.transferIn(condition);
        return R.success(list);
    }

    /**
     * 转出
     */
    @PostMapping("/transferOut")
    public R transferOut(@RequestBody Condition condition) {
        List<JSONObject> list = stockWaterService.transferOut(condition);
        return R.success(list);
    }

    /**
     * 盘点详情
     */
    @PostMapping("inventoryDetails")
    public R inventoryDetails(@RequestBody Condition condition) {
        List<Map<String, Object>> list = stockWaterService.inventoryDetails(condition);
        return R.success(list);
    }

    @PostMapping("outPage")
    public R outPage(@RequestBody Condition condition) {
        Page<Map<String, Object>> result = stockWaterService.outPage(condition);
        return R.success(result);
    }

    @PostMapping("outStatistics")
    public R outStatistics(@RequestBody Condition condition) {
        Map<String, Object> result = stockWaterService.outStatistics(condition);
        return R.success(result);
    }

    @PostMapping("swap")
    public R swap(@RequestBody Condition condition) {
        stockWaterService.swap(condition);
        return R.success();
    }


}

