package com.openhis.web.inhospitalnursestation.controller;

import com.core.common.core.domain.R;
import com.openhis.web.inhospitalnursestation.appservice.IOrgDeviceStockTakeAppService;
import com.openhis.web.inhospitalnursestation.dto.OrgDeviceSummaryParam;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 科室耗材盘点
 *
 * @author wuyan
 * @date 2025/11/05
 */
@RestController
@RequestMapping("/nurse-station/orgdevice-stocktake")
@Slf4j
@AllArgsConstructor
public class OrgDeviceStockTakeController {

    @Resource
    private IOrgDeviceStockTakeAppService orgDeviceStockTakeService;

    /**
     * 查询科室耗材汇总
     *
     * @param orgDeviceSummaryParam 查询条件
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @param pageNo 当前页码
     * @param pageSize 查询条数
     * @param searchKey 模糊查询关键字
     * @param request 请求
     * @return 科室耗材汇总单
     */
    @GetMapping(value = "/summary-from")
    public R<?> getOrgDeviceSummaryFromPage(OrgDeviceSummaryParam orgDeviceSummaryParam, String startTime,
        String endTime, @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, String searchKey,
        HttpServletRequest request) {
        return orgDeviceStockTakeService.getOrgDeviceSummaryFromPage(orgDeviceSummaryParam, startTime, endTime, pageNo,
            pageSize, searchKey, request);
    }

    /**
     * 科室耗材汇总
     *
     * @return 科室耗材汇总单
     */
    @PutMapping(value = "/orgdevice-summary")
    public R<?> orgDeviceSummary(OrgDeviceSummaryParam orgDeviceSummaryParam) {
        return orgDeviceStockTakeService.orgDeviceSummary(orgDeviceSummaryParam);
    }

}
