package com.fjhx.stock.controller;

import com.fjhx.entity.stock.StockDetail;
import com.fjhx.params.stock.PickingTrackingNumStatisticsResult;
import com.fjhx.stock.service.StockDetailService;
import org.springblade.core.tenant.annotation.TenantIgnore;
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.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 物料库存明细 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-08-01
 */
@TenantIgnore
@RestController
@RequestMapping("/stockDetail")
public class StockDetailController {

    @Autowired
    private StockDetailService stockDetailService;

    /**
     * 根据qrcode查询物料信息
     */
    @PostMapping("/getMaterialInfoByQrCode")
    public R getMaterialInfoByQrCode(@RequestBody Map<String, String> condition) {
        Map<String, Object> result = stockDetailService.getMaterialInfoByQrCode(condition);
        return R.success(result);
    }

    /**
     * 赋值货架
     */
    @PostMapping("/setAreaId")
    public R setAreaId(@RequestBody List<StockDetail> stockDetail) {
        stockDetailService.setAreaId(stockDetail);
        return R.success();
    }

    /**
     * 获取限定领料列表
     */
    @PostMapping("/restrictedPicking")
    public R restrictedPicking(@RequestBody Map<String, String> condition) {
        List<Map<String, Object>> result = stockDetailService.restrictedPicking(condition);
        return R.success(result);
    }

    /**
     * 提交限定领料列表
     */
    @PostMapping("/submitRestrictedPicking")
    public R submitRestrictedPicking(@RequestBody Map<String, Object> condition) {
        stockDetailService.submitRestrictedPicking(condition);
        return R.success();
    }

    /**
     * 领料追踪用户统计
     */
    @PostMapping("/pickingTrackingUserStatistics")
    public R pickingTrackingUserStatistics(@RequestBody Map<String, String> condition) {
        List<HashMap<String, Object>> result = stockDetailService.pickingTrackingUserStatistics(condition);
        return R.success(result);
    }

    /**
     * 领料追踪数量统计
     */
    @PostMapping("/pickingTrackingNumStatistics")
    public R pickingTrackingNumStatistics(@RequestBody Map<String, String> condition) {
        PickingTrackingNumStatisticsResult result = stockDetailService.pickingTrackingNumStatistics(condition);
        return R.success(result);
    }

    /**
     * 指定领料信息
     */
    @PostMapping("/appointInfo")
    public R appointInfo(@RequestBody Map<String, String> condition) {
        List<Map<String, Object>> result = stockDetailService.appointInfo(condition);
        return R.success(result);
    }

    /**
     * 指定领料信息
     */
    @PostMapping("/pickingTrackingList")
    public R pickingTrackingList(@RequestBody Map<String, String> condition) {
        List<Map<String, Object>> result = stockDetailService.pickingTrackingList(condition);
        return R.success(result);
    }


}

