package com.fjhx.controller.check;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.base.Condition;
import com.fjhx.entity.water.WaterTag;
import com.fjhx.params.check.CheckDetailVo;
import com.fjhx.params.check.CheckInfoEx;
import com.fjhx.service.check.CheckInfoService;
import com.fjhx.service.water.WaterTagService;
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-11-01
 */
@RestController
@RequestMapping("/check")
public class CheckController {

    @Autowired
    private CheckInfoService checkInfoService;

    @Autowired
    private WaterTagService waterTagService;

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

    @PostMapping("/getInHouseTagList")
    public R getInHouseTagList(@RequestBody WaterTag waterTag) {
        List<WaterTag> result = waterTagService.getInHouseTagList(waterTag);
        return R.success(result);
    }

    @PostMapping("/submit")
    public R submit(@RequestBody CheckDetailVo checkDetailVo) {
        checkInfoService.submit(checkDetailVo);
        return R.success();
    }

    /**
     * 库存管理盘点记录 月统计
     */
    @PostMapping("monthlyStatistics")
    public R monthlyStatistics(@RequestBody Condition condition) {
        Map<String, Object> result = checkInfoService.monthlyStatistics(condition);
        return R.success(result);
    }

    /**
     * 库存管理盘点记录 月统计
     */
    @PostMapping("count")
    public R count(@RequestBody Condition condition) {
        Long count = checkInfoService.getCount(condition);
        return R.success(count);
    }

    /**
     * 库存管理盘点记录 按仓库统计盘点次数
     */
    @PostMapping("houseCount")
    public R houseCount(@RequestBody Condition condition) {
        List<Map<String, Object>> result = checkInfoService.houseCount(condition);
        return R.success(result);
    }

    /**
     * 库存管理盘点记录 按盘点类型统计盘点次数
     */
    @PostMapping("typeCount")
    public R typeCount(@RequestBody Condition condition) {
        Map<String, Object> result = checkInfoService.typeCount(condition);
        return R.success(result);
    }

    /**
     * 库存管理盘点记录 按盘点结果统计盘点次数
     */
    @PostMapping("peopleCheckResultCount")
    public R peopleCheckResultCount(@RequestBody Condition condition) {
        Map<String, Object> result = checkInfoService.peopleCheckResultCount(condition);
        return R.success(result);
    }

    /**
     * 库存管理盘点记录 分页
     */
    @PostMapping("webPage")
    public R webPage(@RequestBody Condition condition) {
        Page<Map<String, Object>> result = checkInfoService.webPage(condition);
        return R.success(result);
    }

    /**
     * 库存管理盘点记录 按盘点人统计盘点次数
     */
    @PostMapping("userCount")
    public R userCount(@RequestBody Condition condition) {
        List<Map<String, Object>> result = checkInfoService.userCount(condition);
        return R.success(result);
    }

    /**
     * 库存管理盘点记录 异常标签工艺类型统计
     */
    @PostMapping("errorTagTechnologyTypeCount")
    public R errorTagTechnologyTypeCount(@RequestBody Condition condition) {
        List<Map<String, Object>> result = checkInfoService.errorTagTechnologyTypeCount(condition);
        return R.success(result);
    }

    /**
     * 库存管理盘点记录 异常标签用途统计
     */
    @PostMapping("errorTagPurposeCount")
    public R errorTagPurposeCount(@RequestBody Condition condition) {
        List<Map<String, Object>> result = checkInfoService.errorTagPurposeCount(condition);
        return R.success(result);
    }

    /**
     * 库存管理盘点记录 异常标签处理类型统计
     */
    @PostMapping("errorTagHandleTypeCount")
    public R errorTagHandleTypeCount(@RequestBody Condition condition) {
        List<Map<String, Object>> result = checkInfoService.errorTagHandleTypeCount(condition);
        return R.success(result);
    }

    /**
     * 库存管理盘点记录 异常标签处理类型统计
     */
    @PostMapping("errorTagPage")
    public R errorTagPage(@RequestBody Condition condition) {
        Page<Map<String, Object>> result = checkInfoService.errorTagPage(condition);
        return R.success(result);
    }

    /**
     * 库存管理盘点记录 异常物料类型
     */
    @PostMapping("errorMaterialPurpose")
    public R errorMaterialPurpose(@RequestBody Condition condition) {
        List<String> result = checkInfoService.errorMaterialPurpose(condition);
        return R.success(result);
    }

    /**
     * 库存管理盘点记录 异常物料分页
     */
    @PostMapping("errorMaterialPage")
    public R errorMaterialPage(@RequestBody Condition condition) {
        Page<Map<String, Object>> result = checkInfoService.errorMaterialPage(condition);
        return R.success(result);
    }

    /**
     * 库存管理盘点记录 异常物料分页
     */
    @PostMapping("errorMaterialTagPage")
    public R errorMaterialTagPage(@RequestBody Condition condition) {
        Page<Map<String, Object>> result = checkInfoService.errorMaterialTagPage(condition);
        return R.success(result);
    }

    /**
     * 盘点结果统计
     */
    @PostMapping("checkResultStatistics")
    public R checkResultStatistics(@RequestBody Condition condition) {
        Map<String, Object> result = checkInfoService.checkResultStatistics(condition);
        return R.success(result);
    }

    /**
     * 查看物料分页
     */
    @PostMapping("materialDetailPage")
    public R materialDetailPage(@RequestBody Condition condition) {
        Page<Map<String, Object>> result = checkInfoService.materialDetailPage(condition);
        return R.success(result);
    }

    /**
     * 发起人工盘点
     */
    @PostMapping("initiateManualCounting")
    public R initiateManualCounting(@RequestBody CheckInfoEx checkInfoEx) {
        checkInfoService.initiateManualCounting(checkInfoEx);
        return R.success();
    }

}

