/*
 * Copyright ©2023 CJB-CNIT Team. All rights reserved
 */
package com.openhis.web.reportmanage.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.core.common.core.domain.R;
import com.openhis.web.reportmanage.appservice.IReportAppService;

import lombok.extern.slf4j.Slf4j;

/**
 * 报表 controller
 *
 * @author liuhr
 * @date 2025-11-06
 */
@RestController
@RequestMapping("/report-manage/report")
@Slf4j
public class ReportController {

    @Autowired
    private IReportAppService reportAppService;


    /**例子，Dto例子参考：ReportStockOutDetailDto
     * 药剂科报表_常规报表:出库明细表
     *
     * @param pageNo 当前页码
     * @param pageSize 查询条数
     * @param searchKey 模糊查询关键字
     * @param request 请求数据
     * @return 出库明细表
     */
    @GetMapping(value = "/stock-out-detail-page")
    public R<?> getStockOutDetailPage(@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
        @RequestParam(name = "searchKey", required = false) String searchKey, HttpServletRequest request) {
        return reportAppService.getStockOutDetailPage(pageNo,pageSize,searchKey,request);
    }

    /**Dto参考：ReportPatientMasterDetailDto
     * 药剂科报表:患者明细主表
     *
     * @param pageNo 当前页码
     * @param pageSize 查询条数
     * @param searchKey 模糊查询关键字
     * @param request 请求数据
     * @return 患者明细主报表
     */
    @GetMapping(value = "/patient-master-detail")
    public R<?> getPatientMasterDetailPage(@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
        @RequestParam(name = "searchKey", required = false) String searchKey, HttpServletRequest request) {
        return reportAppService.getPatientMasterDetailPage(pageNo,pageSize,searchKey,request);
    }

    /**Dto参考：ReportOfflinePurchaseRatioDto
     * 药剂科报表:线下采购占比
     *
     * @param pageNo 当前页码
     * @param pageSize 查询条数
     * @param searchKey 模糊查询关键字
     * @param request 请求数据
     * @return 线下采购占比报表
     */
    @GetMapping(value = "/offline-purchase-ratio")
    public R<?> getOfflinePurchaseRatioPage(@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
        @RequestParam(name = "searchKey", required = false) String searchKey, HttpServletRequest request) {
        return reportAppService.getOfflinePurchaseRatioPage(pageNo,pageSize,searchKey,request);
    }

    /**Dto参考：ReportMedicationUsageDto
     * 药剂科报表:药品使用情况
     *
     * @param pageNo 当前页码
     * @param pageSize 查询条数
     * @param searchKey 模糊查询关键字
     * @param request 请求数据
     * @return 药品使用情况报表
     */
    @GetMapping(value = "/medication-usage")
    public R<?> getMedicationUsagePage(@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
        @RequestParam(name = "searchKey", required = false) String searchKey, HttpServletRequest request) {
        return reportAppService.getMedicationUsagePage(pageNo,pageSize,searchKey,request);
    }

    /**Dto参考：ReportPatientDetailsDto
     * 药剂科报表:患者明细
     *
     * @param pageNo 当前页码
     * @param pageSize 查询条数
     * @param searchKey 模糊查询关键字
     * @param request 请求数据
     * @return 患者明细报表
     */
    @GetMapping(value = "/patient-details")
    public R<?> getPatientDetailsPage(@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
        @RequestParam(name = "searchKey", required = false) String searchKey, HttpServletRequest request) {
        return reportAppService.getPatientDetailsPage(pageNo,pageSize,searchKey,request);
    }

    /**Dto参考：ReportDrugCostGrowthDto
     * 药剂科报表:药品费用增长率
     *
     * @param pageNo 当前页码
     * @param pageSize 查询条数
     * @param searchKey 模糊查询关键字
     * @param request 请求数据
     * @return 药品费用增长率
     */
    @GetMapping(value = "/drug-expenses-growth-rate")
    public R<?> getDrugExpensesGrowthRate(@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
        @RequestParam(name = "searchKey", required = false) String searchKey, HttpServletRequest request) {
        return reportAppService.getDrugExpensesGrowthRate(pageNo,pageSize,searchKey,request);
    }

    /**Dto参考：ReportThirtyDayCollectionRateDto
     * 药剂科报表:30天回款率
     *
     * @param pageNo 当前页码
     * @param pageSize 查询条数
     * @param searchKey 模糊查询关键字
     * @param request 请求数据
     * @return 30天回款率
     */
    @GetMapping(value = "/thirty-day-collection-rate")
    public R<?> getThirtyDayCollectionRate(@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
        @RequestParam(name = "searchKey", required = false) String searchKey, HttpServletRequest request) {
        return reportAppService.getThirtyDayCollectionRate(pageNo,pageSize,searchKey,request);
    }

    /**Dto参考：ReportBasicInformationDetailsDto
     * 药剂科报表:基本情况报表
     *
     * @param pageNo 当前页码
     * @param pageSize 查询条数
     * @param searchKey 模糊查询关键字
     * @param request 请求数据
     * @return 基本情况报表
     */
    @GetMapping(value = "/basic-information-details")
    public R<?> getBasicInformationDetails(@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
        @RequestParam(name = "searchKey", required = false) String searchKey, HttpServletRequest request) {
        return reportAppService.getBasicInformationDetails(pageNo,pageSize,searchKey,request);
    }

    /**Dto参考：ReportMedicationStockOutDetailsDto
     * 药剂科报表:药品出库情况
     *
     * @param pageNo 当前页码
     * @param pageSize 查询条数
     * @param searchKey 模糊查询关键字
     * @param request 请求数据
     * @return 药品出库情况报表
     */
    @GetMapping(value = "/medication-stock-out-details")
    public R<?> getMedicationStockOutDetails(@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
        @RequestParam(name = "searchKey", required = false) String searchKey, HttpServletRequest request) {
        return reportAppService.getMedicationStockOutDetails(pageNo,pageSize,searchKey,request);
    }

    /**Dto参考：ReportProductUsageDto
     * 药剂科报表:产品使用情况
     *
     * @param pageNo 当前页码
     * @param pageSize 查询条数
     * @param searchKey 模糊查询关键字
     * @param request 请求数据
     * @return 产品使用情况报表
     */
    @GetMapping(value = "/product-usage-details")
    public R<?> getProductUsageDetails(@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
        @RequestParam(name = "searchKey", required = false) String searchKey, HttpServletRequest request) {
        return reportAppService.getProductUsageDetails(pageNo,pageSize,searchKey,request);
    }

    /**Dto参考：ReportNonWinQtyRatioDto
     * 药剂科报表:非中选产品采购量占比
     *
     * @param pageNo 当前页码
     * @param pageSize 查询条数
     * @param searchKey 模糊查询关键字
     * @param request 请求数据
     * @return 非中选产品采购量占比报表
     */
    @GetMapping(value = "/non-win-qty-ratio")
    public R<?> getNonWinQtyRatio(@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
        @RequestParam(name = "searchKey", required = false) String searchKey, HttpServletRequest request) {
        return reportAppService.getNonWinQtyRatio(pageNo,pageSize,searchKey,request);
    }

}
