package com.unis.purchaseAndSalesSupervision.modular.yjbj.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.unis.common.pojo.CommonResult;
import com.unis.mobileInfo.modular.crk.param.BusinessRecordParam;
import com.unis.purchaseAndSalesSupervision.modular.yjbj.entity.StorageJkqWarning;
import com.unis.purchaseAndSalesSupervision.modular.yjbj.entity.StorageRotationWarning;
import com.unis.purchaseAndSalesSupervision.modular.yjbj.entity.ZqlTable;
import com.unis.purchaseAndSalesSupervision.modular.yjbj.param.*;
import com.unis.purchaseAndSalesSupervision.modular.yjbj.service.YjbjService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/yjbjController")
@Api(tags = "预警报警查询控制器")
@ApiSupport(author = "UNIS_TEAM", order = 1)
@Validated
public class YjbjController {

    @Resource
    private YjbjService yjbjService;

    @ApiOperationSupport(order = 1)
    @GetMapping("/getZqlList")
    @ApiOperation(value="查询转圈粮、以陈顶新数据", notes = "支持分页")
    public CommonResult<Page<ZqlTable>> getZqlList(ZqlPageParam yjbjPageParam) {
        return CommonResult.data(yjbjService.selectZqlListPage(yjbjPageParam));
    }

    @GetMapping(value = "queryZqlById")
    @ApiOperation(value = "根据id查询一条转圈粮、以陈顶新数据", notes = "")
    public CommonResult<ZqlTable> queryZqlById(ZqlIdParam zqlIdParam) {
        return CommonResult.data(yjbjService.queryZqlById(zqlIdParam));
    }

    @GetMapping(value = "/getLhList")
    @ApiOperation(value="查询应轮未轮、临近轮换期数据", notes = "支持分页")
    public CommonResult<Page<StorageRotationWarning>> getLhList(StorageRotationWarningPageParam storageRotationWarningPageParam)  {
        return CommonResult.data(yjbjService.selectLhList(storageRotationWarningPageParam));
    }

    @GetMapping(value = "queryLhById")
    @ApiOperation(value = "根据id查询一条应轮未轮、临近轮换期数据", notes = "")
    public CommonResult<StorageRotationWarning> queryLhById(StorageRotationWarningIdParam storageRotationWarningIdParam) {
        return CommonResult.data(yjbjService.queryLhById(storageRotationWarningIdParam));
    }

    @GetMapping(value = "/getCjkqList")
    @ApiOperation(value="查询超架空期数据列表", notes = "支持分页")
    public CommonResult<Page<StorageJkqWarning>> getCjkqList(StorageJkqWarningPageParam storageJkqWarningPageParam)  {
        return CommonResult.data(yjbjService.selectCjkqList(storageJkqWarningPageParam));
    }

    @GetMapping(value = "queryCjkqById")
    @ApiOperation(value = "根据id查询一超架空期数据", notes = "")
    public CommonResult<StorageJkqWarning> queryCjkqById(StorageJkqWarningIdParam storageJkqWarningIdParam) {
        return CommonResult.data(yjbjService.queryCjkqById(storageJkqWarningIdParam));
    }

    @ApiOperationSupport(order = 7)
    @ApiOperation("*行为采集及分析")
    @GetMapping("/getXwcjfxList")
    public CommonResult<IPage<List<Map<String,Object>>>> getXwcjfxList(@Valid XwcjfxPageParam xwcjfxPageParam) {
        return CommonResult.data(yjbjService.getXwcjfxList(xwcjfxPageParam));
    }

    @ApiOperationSupport(order = 8)
    @ApiOperation("*出库计划执行监管")
    @GetMapping("/getCkjhzxjgList")
    public CommonResult<IPage<List<Map<String,Object>>>> getCkjhzxjgList(@Valid XwcjfxPageParam xwcjfxPageParam) {
        return CommonResult.data(yjbjService.getCkjhzxjgList(xwcjfxPageParam));
    }
}
