/*
 * Copyright [2022] [https://www.xiaonuo.vip]
 *
 * Snowy采用APACHE LICENSE 2.0开源协议，您在使用过程中，需要注意以下几点：
 *
 * 1.请不要删除和修改根目录下的LICENSE文件。
 * 2.请不要删除和修改Snowy源码头部的版权声明。
 * 3.本项目代码可免费商业使用，商业使用请保留源码和相关描述文件的项目出处，作者声明等。
 * 4.分发源码时候，请注明软件出处 https://www.xiaonuo.vip
 * 5.不可二次分发开源参与同类竞品，如有想法可联系团队xiaonuobase@qq.com商议合作。
 * 6.若您的项目无法满足以上几点，需要更多功能代码，获取Snowy商业授权许可，请在官网购买授权，地址为 https://www.xiaonuo.vip
 */
package com.unis.statisticalReport.info.modular.conReportinfo.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.basic.info.modular.enumInfo.entity.BasicEnum;
import com.unis.basic.info.modular.enumInfo.service.BasicEnumService;
import com.unis.common.pojo.CommonResult;
import com.unis.emergencySupport.modular.es.entity.EsNetworkEntry;
import com.unis.emergencySupport.modular.es.param.EsNetworkEntryPageParam;
import com.unis.emergencySupport.modular.es.service.EsNetworkEntryService;
import com.unis.statisticalReport.info.modular.conReportinfo.entity.vo.EsNetworkEntryPageReportinfo;
import com.unis.statisticalReport.info.modular.conReportinfo.entity.vo.EsNetworkEntryReportinfo;
import com.unis.statisticalReport.info.modular.conReportinfo.entity.vo.PlanReportinfo;
import com.unis.statisticalReport.info.modular.conReportinfo.entity.vo.ReserveReportDetailsinfo;
import com.unis.statisticalReport.info.modular.conReportinfo.entity.vo.ReserveReportStorehouseinfo;
import com.unis.statisticalReport.info.modular.conReportinfo.entity.vo.ReserveReportinfo;
import com.unis.statisticalReport.info.modular.conReportinfo.entity.vo.StorehouseCapacityReportinfo;
import com.unis.statisticalReport.info.modular.conReportinfo.param.EsNetworkEntryReportinfoParam;
import com.unis.statisticalReport.info.modular.conReportinfo.param.PlanReportinfoParam;
import com.unis.statisticalReport.info.modular.conReportinfo.param.ReserveReportinfoParam;
import com.unis.statisticalReport.info.modular.conReportinfo.param.StorehouseCapacityReportinfoParam;
import com.unis.statisticalReport.info.modular.conReportinfo.service.ConReportinfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * 统计报表控制器
 *
 * @author TS
 * @date  2024/05/31 10:02
 */
@Api(tags = "统计报表控制器")
@ApiSupport(author = "UNIS_TEAM", order = 1)
@RestController
@Validated
public class ConReportinfoController {

    @Resource
    private ConReportinfoService conReportinfoService;
    @Resource
    private BasicEnumService basicEnumService;
    @Resource
    private EsNetworkEntryService esNetworkEntryService;

    /**
     * 获取储备统计图表数据
     *
     * @author TS
     * @date  2024/05/31 10:02
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("获取储备统计图表数据")
//    @GetMapping("/statisticalReport.info/conReportinfo/getReserveChartDatas")
    @GetMapping("/client/c/statisticalReport.info/conReportinfo/getReserveChartDatas")
    public CommonResult<List<ReserveReportinfo>> getReserveChartDatas(ReserveReportinfoParam reserveReportinfoParam) {
        return CommonResult.data(conReportinfoService.getReserveChartDatas(reserveReportinfoParam));
    }

    /**
     * 获取储备统计图表-仓房数据
     *
     * @author TS
     * @date  2024/05/31 15:21
     */
    @ApiOperationSupport(order = 2)
    @ApiOperation("获取储备统计图表-仓房数据")
//    @GetMapping("/statisticalReport.info/conReportinfo/findStorehousePage")
    @GetMapping("/client/c/statisticalReport.info/conReportinfo/findStorehousePage")
    public CommonResult<IPage<ReserveReportStorehouseinfo>> findStorehousePage(ReserveReportinfoParam reserveReportinfoParam) {
        return CommonResult.data(conReportinfoService.findStorehousePage(reserveReportinfoParam));
    }
    /**
     * 获取储备统计图表-仓房数据详情
     *
     * @author TS
     * @date  2024/05/31 15:21
     */
    @ApiOperationSupport(order = 3)
    @ApiOperation("获取储备统计图表-仓房数据详情")
//    @GetMapping("/statisticalReport.info/conReportinfo/getStorehouseDetails")
    @GetMapping("/client/c/statisticalReport.info/conReportinfo/getStorehouseDetails")
    public CommonResult<ReserveReportDetailsinfo> getStorehouseDetails(@RequestParam("orgId") @NotBlank(message = "库区Id不能为空") String orgId,
                                                                       @RequestParam("storehouseId") @NotBlank(message = "仓房Id不能为空")String storehouseId,
                                                                       @RequestParam("warehouseId") @NotBlank(message = "货位d不能为空")String warehouseId) {
        return CommonResult.data(conReportinfoService.getStorehouseDetails(orgId,storehouseId,warehouseId));
    }

    /**
     * c端根据id获取子节点数据
     * @param enumid 节点id
     * @return
     */
    @ApiOperation(value="c端根据id获取子节点数据")
//    @GetMapping("/statisticalReport.info/conReportinfo/getAllChildren")
    @GetMapping("/client/c/statisticalReport.info/conReportinfo/getAllChildren")
    @ApiImplicitParams({
            @ApiImplicitParam(name="enumid", value="字典id", paramType="query"),
            @ApiImplicitParam(name="isQueryFristNode", value="是否只查询第一级", paramType="query")
    })
    public CommonResult<List<BasicEnum>> getAllChildren(String  enumid, Boolean isQueryFristNode) {
        List<BasicEnum> list  = basicEnumService.queryAllChildren(enumid,isQueryFristNode);
        return CommonResult.data(list);
    }


    /**
     * 获取仓容统计图表数据
     *
     * @author TS
     * @date  2024/05/31 10:02
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation("获取仓容统计图表数据")
//    @GetMapping("/statisticalReport.info/conReportinfo/getStorehouseChartDatas")
    @GetMapping("/client/c/statisticalReport.info/conReportinfo/getStorehouseChartDatas")
    public CommonResult<List<StorehouseCapacityReportinfo>> getStorehouseChartDatas() {
        return CommonResult.data(conReportinfoService.getStorehouseChartDatas());
    }

    /**
     * 获取仓容统计图表-仓房数据
     *
     * @author TS
     * @date  2024/05/31 15:21
     */
    @ApiOperationSupport(order = 6)
    @ApiOperation("获取仓容统计图表-仓房数据")
    @GetMapping("/client/c/statisticalReport.info/conReportinfo/findStorehouseCapacityPage")
    public CommonResult<IPage<StorehouseCapacityReportinfo>> findStorehouseCapacityPage(StorehouseCapacityReportinfoParam capacityReportinfoParam) {
        return CommonResult.data(conReportinfoService.findStorehouseCapacityPage(capacityReportinfoParam));
    }

    /**
     * 获取应急保障报表分页
     *
     * @author TS
     * @date  2024/05/28 09:21
     */
    @ApiOperationSupport(order = 7)
    @ApiOperation("获取应急保障报表分页")
    @GetMapping("/client/c/statisticalReport.info/conReportinfo/findEsNetworkEntryPage")
    public CommonResult<IPage<EsNetworkEntryPageReportinfo>> findEsNetworkEntryPage(EsNetworkEntryReportinfoParam esNetworkEntryReportinfoParam) {
        return CommonResult.data(conReportinfoService.findEsNetworkEntryPage(esNetworkEntryReportinfoParam));
    }
    /**
     * 获取应急保障报表详情
     *
     * @author TS
     * @date  2024/05/28 09:21
     */
    @ApiOperationSupport(order = 8)
    @ApiOperation("获取应急保障报表详情")
    @GetMapping("/client/c/statisticalReport.info/conReportinfo/getEsNetworkEntryDetails")
    public CommonResult<EsNetworkEntryReportinfo> getEsNetworkEntryDetails(EsNetworkEntryReportinfoParam esNetworkEntryReportinfoParam) {
        return CommonResult.data(conReportinfoService.getEsNetworkEntryDetails(esNetworkEntryReportinfoParam));
    }

    /**
     * 获取收购报表分页
     *
     * @author TS
     * @date  2024/06/04 11:21
     */
    @ApiOperationSupport(order = 7)
    @ApiOperation("获取收购报表分页")
    @GetMapping("/client/c/statisticalReport.info/conReportinfo/findBuyPlanPage")
    public CommonResult<IPage<PlanReportinfo>> findBuyPlanPage(PlanReportinfoParam planReportinfoParam) {
        return CommonResult.data(conReportinfoService.findBuyPlanPage(planReportinfoParam));
    }

    /**
     * 获取收购报表详情
     *
     * @author TS
     * @date  2024/05/28 09:21
     */
    @ApiOperationSupport(order = 8)
    @ApiOperation("获取收购报表详情")
    @GetMapping("/client/c/statisticalReport.info/conReportinfo/getBuyPlanDetails")
    public CommonResult<PlanReportinfo> getBuyPlanDetails(@RequestParam("id") @NotBlank(message = "不能为空") String id) {
        return CommonResult.data(conReportinfoService.getBuyPlanDetails(id));
    }
    /**
     * 获取当日购销报表分页
     *
     * @author TS
     * @date  2024/06/04 11:21
     */
    @ApiOperationSupport(order = 7)
    @ApiOperation("获取当日购销报表分页")
    @GetMapping("/client/c/statisticalReport.info/conReportinfo/findCurrentPlanPage")
    public CommonResult<IPage<PlanReportinfo>> findCurrentPlanPage(PlanReportinfoParam planReportinfoParam) {
        return CommonResult.data(conReportinfoService.findCurrentPlanPage(planReportinfoParam));
    }

    /**
     * 获取当日购销报表详情
     *
     * @author TS
     * @date  2024/05/28 09:21
     */
    @ApiOperationSupport(order = 8)
    @ApiOperation("获取当日购销报表详情")
    @GetMapping("/client/c/statisticalReport.info/conReportinfo/getCurrentPlanDetails")
    public CommonResult<PlanReportinfo> getCurrentPlanDetails(@RequestParam("id") @NotBlank(message = "不能为空") String id,@RequestParam("warehouseId") @NotBlank(message = "货位Id不能为空") String warehouseId) {
        return CommonResult.data(conReportinfoService.getCurrentPlanDetails(id,warehouseId));
    }
}
