package com.fizz.business.controller;


import com.fizz.business.service.CrmPdoExcoilService;
import com.fizz.business.vo.ReportDetailVO;
import com.fizz.business.vo.ReportSummaryVO;
import com.ruoyi.common.annotation.Anonymous;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.format.annotation.DateTimeFormat;
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 javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

@RestController
@RequestMapping("/api/report")
@Tag(name= "报表接口",description = "报表接口")
@Anonymous
public class ReportController {

    @Resource
    private CrmPdoExcoilService crmPdoExcoilService;

    @GetMapping("/summary")
    @Operation(summary = "生产实绩报表-汇总信息查询")
    public ReportSummaryVO getReportSummary(
            @RequestParam(required = false) String groupNo,
            @RequestParam(required = false) String shiftNo,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime startTime,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime
    ) {
        return crmPdoExcoilService.getReportSummary(groupNo, shiftNo, startTime, endTime);
    }

    @GetMapping("/details")
    @Operation(summary = "生产实绩报表-产出明细查询")
    public List<ReportDetailVO> getReportDetails(
            @RequestParam(required = false) String groupNo,
            @RequestParam(required = false) String shiftNo,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime startTime,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime
    ) {
        return crmPdoExcoilService.getReportDetails(groupNo, shiftNo, startTime, endTime);
    }


}
