package jnpf.attendance.controller;

import cn.hutool.core.date.DateUtil;
import com.fantaibao.permission.annotation.FtbCheckPermission;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import jnpf.attendance.FtbStatisticsApi;
import jnpf.attendance.dto.*;
import jnpf.attendance.service.AttendanceCustomizeTableService;
import jnpf.attendance.service.AttendanceDayStatisticsService;
import jnpf.attendance.service.AttendanceSealSettingService;
import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.constants.MessageTopicConstants;
import jnpf.database.util.TenantDataSourceUtil;
import jnpf.enums.attendance.TriggerSceneEnum;
import jnpf.exception.LoginException;
import jnpf.model.attendance.dto.*;
import jnpf.model.attendance.event.StatisticsBatchClearDto;
import jnpf.model.attendance.event.StatisticsSingleDto;
import jnpf.model.attendance.vo.attendance.*;
import jnpf.model.personnels.vo.analysis.PersonnelDataAnalysisListVO;
import jnpf.personnels.utils.PersonnelDataAnalysisUtil;
import jnpf.util.FtbUtil;
import jnpf.util.NoDataSourceBind;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.MutablePair;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 考勤统计WEB
 */
@Slf4j
@RestController
@RequestMapping(value = "/attendance/statistics")
public class WebStatisticsController implements FtbStatisticsApi {
    @Resource
    private RocketMQTemplate rocketMqTemplate;
    @Resource
    private AttendanceDayStatisticsService dayStaService;
    @Autowired
    private AttendanceCustomizeTableService tableService;
    @Resource
    private AttendanceSealSettingService sealSettingService;

    @Override
    @Operation(summary = "用户日统计数据初始化")
    @GetMapping(value = "/userDayStatisticsInit")
    public ActionResult<Boolean> userDayStatisticsInit(@RequestParam(value = "tenantId") String tenantId) {
        return ActionResult.success(dayStaService.handleDataForJob(tenantId));
    }

    @Operation(summary = "日度统计-汇总")
    @PostMapping("/dayStatistics")
    public ActionResult<List<DayStatisticsDataVo>> dayStatistics(@Valid @RequestBody DayStatisticsDataDto req) {
        return ActionResult.success(dayStaService.getDayStatisticsData(req));
    }

    @Operation(summary = "日度统计-分页列表")
    @PostMapping(value = "/dayPageList")
    public ActionResult<PageListVO<DayStatisticsPageListVo>> dayPageList(@Valid @RequestBody DayStatisticsPageListDto req) {
        PageInfo<DayStatisticsPageListVo> page = dayStaService.getDayPageList(req);
        return ActionResult.page(page.getList(), FtbUtil.getPagination(page));
    }

    @Operation(summary = "日度统计-导出")
    @PostMapping(value = "/dayDataExport")
    public ActionResult<Boolean> dayDataExport(@Valid @RequestBody DayStatisticsExportDto req) {
        dayStaService.dayDataExport(req);
        return ActionResult.success();
    }

    @Operation(summary = "月度统计-汇总")
    @PostMapping("/monthStatistics")
    public ActionResult<List<DayStatisticsDataVo>> monthStatistics(@Valid @RequestBody MouthStatisticsDataDto req) {
        return ActionResult.success(dayStaService.getMonthStatisticsData(req));
    }

    @Operation(summary = "月度统计-分页列表")
    @PostMapping(value = "/monthPageList")
    public ActionResult<PageListVO<MonthStatisticsPageListVo>> monthPageList(@Valid @RequestBody MonthStatisticsPageListDto req) throws Exception {
        PageInfo<MonthStatisticsPageListVo> page = dayStaService.getMonthPageList(req);
        return ActionResult.page(page.getList(), FtbUtil.getPagination(page));
    }

    @Operation(summary = "月度统计-导出")
    @PostMapping(value = "/monthDataExport")
    public ActionResult<Boolean> monthDataExport(@Valid @RequestBody MonthStatisticsExportDto req) {
        dayStaService.monthDataExport(req);
        return ActionResult.success();
    }

    @Override
    @Operation(summary = "个人考勤日报通知")
    @GetMapping(value = "/dayStatisticsNotice")
    public ActionResult<Boolean> dayStatisticsNotice(@RequestParam(value = "tenantId") String tenantId) {
        return ActionResult.success(dayStaService.dayStatisticsNotice(tenantId));
    }

    @Override
    @Operation(summary = "个人统计月报通知")
    @GetMapping(value = "/monthStatisticsNotice")
    public ActionResult<Boolean> monthStatisticsNotice(@RequestParam(value = "tenantId") String tenantId) {
        return ActionResult.success(dayStaService.monthStatisticsNotice(tenantId));
    }

    @Override
    @Operation(summary = "连续未排班通知")
    @GetMapping(value = "/consentUnscheduledNotice")
    public void consentUnscheduledNotice(@RequestParam(value = "tenantId") String tenantId) {
        dayStaService.consentUnscheduledNotice(tenantId);
    }

    @Override
    @Operation(summary = "团队统计月报通知")
    @GetMapping(value = "/teamMonthStatisticsNotice")
    public ActionResult<Boolean> teamMonthStatisticsNotice(@RequestParam(value = "tenantId") String tenantId) {
        return ActionResult.success(dayStaService.teamMonthStatisticsNotice(tenantId));
    }

    @Override
    @Operation(summary = "计算考勤组平均工时(实际出勤工时)")
    @PostMapping(value = "/countAttendanceAvgHours")
    public List<AttendanceCountAvgHoursVo> countAttendanceAvgHours(@Valid @RequestBody AttendanceCountAvgHoursDto dto) {
        return dayStaService.countAttendanceAvgHours(dto);
    }

    @Override
    @Operation(summary = "获取多考勤组月度统计数据")
    @PostMapping(value = "/getAttendanceAvgHoursDetails")
    public ActionResult<MonthStatsDetailsVo> getAttendanceAvgHoursDetails(@Valid @RequestBody MonthStatsDetailsDto dto) {
        MonthStatsDetailsVo result = dayStaService.getAttendanceAvgHoursDetails(dto);
        return ActionResult.success(result);
    }

    @Override
    @Operation(summary = "获取多考勤组月度人均工时折线图")
    @PostMapping(value = "/getAttendanceMonthPerCapita")
    public ActionResult<List<MonthStatsPerCapitaVo>> getAttendanceMonthPerCapita(@Valid @RequestBody MonthStatsDetailsDto dto) {
        return ActionResult.success(dayStaService.getAttendanceMonthPerCapita(dto));
    }

    @Override
    @Operation(summary = "获取多考勤组月度日常情况")
    @PostMapping(value = "/getAttendanceDailySituation")
    public ActionResult<List<MonthStatsDailySituationVo>> getAttendanceDailySituation(@Valid @RequestBody MonthStatsDetailsDto dto) {
        return ActionResult.success(dayStaService.getAttendanceDailySituation(dto));
    }

    @Override
    @Operation(summary = "获取多考勤组月度考勤工时排行")
    @PostMapping(value = "/getAttendanceHoursRanking")
    public ActionResult<List<MonthStatsHoursRankingVo>> getAttendanceHoursRanking(@Valid @RequestBody MonthStatsDetailsDto dto) {
        return ActionResult.success(dayStaService.getAttendanceHoursRanking(dto));
    }

    @Override
    @Operation(summary = "获取多考勤组月度全勤情况")
    @PostMapping(value = "/getAttendanceFullSituation")
    public ActionResult<List<MonthStatsFullSituationVo>> getAttendanceFullSituation(@Valid @RequestBody MonthStatsDetailsDto dto) {
        return ActionResult.success(dayStaService.getAttendanceFullSituation(dto));
    }

    @Override
    @Operation(summary = "获取多考勤组月度异常情况")
    @PostMapping(value = "/getAttendanceAbnormalCondition")
    public ActionResult<MonthStatsAbnormalConditionVo> getAttendanceAbnormalCondition(@Valid @RequestBody MonthStatsDetailsDto dto) {
        return ActionResult.success(dayStaService.getAttendanceAbnormalCondition(dto));
    }

    @Override
    @Operation(summary = "获取多考勤组月度加班情况")
    @PostMapping(value = "/getAttendanceOvertimeSituation")
    public ActionResult<List<MonthStatsOvertimeSituationVo>> getAttendanceOvertimeSituation(@Valid @RequestBody MonthStatsDetailsDto dto) {
        return ActionResult.success(dayStaService.getAttendanceOvertimeSituation(dto));
    }

    @Operation(summary = "考勤封账-自动封账设置详情")
    @GetMapping(value = "/getAutoSealSettingInfo")
    public ActionResult<MonthAutoSealSettingVo> getAutoSealSettingInfo() {
        return ActionResult.success(sealSettingService.getAutoSealSettingInfo());
    }

    @Operation(summary = "考勤封账-自动封账设置")
    @PutMapping(value = "/autoSealSetting")
    public ActionResult<Boolean> autoSealSetting(@Valid @RequestBody MonthAutoSealSettingDto dto) {
        return ActionResult.success(sealSettingService.autoSealSetting(dto));
    }

    @Override
    @Operation(summary = "考勤封账-自动封账定时器")
    @PutMapping(value = "/autoSealTimer")
    public ActionResult<Boolean> autoSealTimer(@RequestParam(value = "tenantId") String tenantId) {
        return ActionResult.success(sealSettingService.autoSealTimer(tenantId));
    }

    @Operation(summary = "考勤封账-分页列表")
    @PostMapping(value = "/sealPageList")
    public ActionResult<PageListVO<MonthSealPageListVo>> sealPageList(@Valid @RequestBody MonthSealPageListDto dto) {
        PageInfo<MonthSealPageListVo> page = dayStaService.sealPageList(dto);
        return ActionResult.page(page.getList(), FtbUtil.getPagination(page));
    }

    @Operation(summary = "考勤封账-批量|单个封账")
    @PutMapping(value = "/sealSubmit")
    public ActionResult<Boolean> sealSubmit(@Valid @RequestBody MonthSealSubmitDto dto) {
        return ActionResult.success(dayStaService.sealSubmit(dto));
    }

    @Operation(summary = "考勤封账-解封")
    @PutMapping(value = "/unSealSubmit")
    public ActionResult<Boolean> unSealSubmit(@Valid @RequestBody MonthUnSealSubmitDto dto) {
        return ActionResult.success(dayStaService.unSealSubmit(dto));
    }

    @Operation(summary = "批量查询用户是否封账")
    @PostMapping(value = "/selectUserIsSeal")
    public ActionResult<Map<String, Boolean>> selectUserIsSeal(@Valid @RequestBody MonthSealSubmitDto dto) {
        return ActionResult.success(dayStaService.selectUserIsSeal(dto.getUserIdList(), dto.getMonth()));
    }

    @Override
    @Operation(summary = "薪酬考勤数据支持（薪酬）")
    @PostMapping(value = "/salaryAttendanceSupport")
    public Map<String, SalaryAttendanceSupportVo> salaryAttendanceSupport(@Valid @RequestBody SalaryAttendanceSupportDto dto) {
        return dayStaService.salaryAttendanceSupport(dto);
    }

    @Override
    @Operation(summary = "考勤统计数据日度列表表头（薪酬）")
    @PostMapping(value = "/attendanceDayStaTable")
    public List<AttendanceCustomizeTableVo> attendanceDayStaTable() {
        return tableService.findList(null, null, 1);
    }

    @Override
    @Operation(summary = "考勤统计数据日度列表（薪酬）")
    @PostMapping(value = "/attendanceDayStaList")
    public List<DayStatisticsPageListVo> attendanceDayStaList(@Valid @RequestBody SalaryAttendanceSupportDto dto) {
        return dayStaService.attendanceStaList(dto);
    }

    @Override
    @Operation(summary = "获取日出勤信息")
    @NoDataSourceBind
    @PostMapping(value = "/getAttendanceDayStaList")
    public List<DayStatisticsVo> getAttendanceDayStaList(@Valid @RequestBody DayStatisticsDto dto) {
        //切换成租户库
        try {
            TenantDataSourceUtil.switchTenant(dto.getTenantId());
        } catch (LoginException e) {
            throw new RuntimeException("切换租户失败");
        }
        return dayStaService.getAttendanceDayStaList(dto);
    }

    @NoDataSourceBind
    @Operation(summary = "模拟统计数据消息推送")
    @GetMapping("/mockStatisticsPush")
    public ActionResult<Boolean> mockStatisticsPush(@RequestParam("tenantId") String tenantId,
                                                    @RequestParam("groupId") String groupId,
                                                    @RequestParam("userId") String userId,
                                                    @RequestParam("day") String day) {
        StatisticsSingleDto courseEventDTO = StatisticsSingleDto.builder()
                .tenantId(tenantId)
                .groupId(groupId)
                .userId(userId)
                .triggerSceneEnum(TriggerSceneEnum.MANUAL_TRIGGER)
                .day(DateUtil.parse(day))
                .build();
        Message<StatisticsSingleDto> message = MessageBuilder.withPayload(courseEventDTO).build();
        rocketMqTemplate.syncSend(MessageTopicConstants.ATTENDANCE_STATISTICS_SINGLE_TOPIC, message, 3000L, 2);
        return ActionResult.success();
    }

    @NoDataSourceBind
    @Operation(summary = "日统计触发")
    @GetMapping("/dayStatisticsTriggered11")
    public ActionResult<Boolean> dayStatisticsTriggered(@RequestParam("tenantId") String tenantId,
                                                        @RequestParam("userId") Boolean userId,
                                                        @RequestParam("user") Integer user,
                                                        @RequestParam("day") Boolean day) throws LoginException {
        StatisticsSingleDto courseEventDTO = StatisticsSingleDto.builder()
                .tenantId(tenantId)
                .groupId(groupId)
                .userId(userId)
                .day(DateUtil.parse(day))
                .triggerSceneEnum(TriggerSceneEnum.MANUAL_TRIGGER)
                .build();
        dayStaService.statisticDataChange(courseEventDTO);
        return ActionResult.success();
    }

    @NoDataSourceBind
    @Operation(summary = "日统计数据清除")
    @GetMapping("/dayStatisticsClear")
    public ActionResult<Boolean> dayStatisticsClear(@RequestParam("tenantId") String tenantId,
                                                    @RequestParam("groupId") String groupId,
                                                    @RequestParam("userId") List<String> userList,
                                                    @RequestParam("day") String day,
                                                    @RequestParam("startDay") String startDay) {
        StatisticsBatchClearDto courseEventDTO = StatisticsBatchClearDto.builder()
                .tenantId(tenantId)
                .groupId(groupId)
                .userIdList(userList)
                .day(DateUtil.parse(day))
                .startDay(DateUtil.parse(startDay))
                .build();
        dayStaService.batchStatisticDataClear(courseEventDTO);
        return ActionResult.success();
    }

    @NoDataSourceBind
    @Operation(summary = "重新生成日统计数据")
    @GetMapping(value = "/regenerateDayData")
    public ActionResult<Boolean> regenerateDayData(@RequestParam("tenantId") String tenantId,
                                                   @RequestParam("start") Date start) {
        dayStaService.regenerateDayData(tenantId, start);
        return ActionResult.success();
    }

    @NoDataSourceBind
    @Operation(summary = "处理历史数据")
    @GetMapping(value = "/processHistoricalData")
    public ActionResult<Boolean> processHistoricalData(@RequestParam("tenantId") String tenantId,
                                                       @RequestParam("start") Date start,
                                                       @RequestParam("end") Date end) {
        dayStaService.processHistoricalData(tenantId, start, end);
        return ActionResult.success();
    }

    @Override
    @Operation(summary = "获取各维度出勤人数")
    @PostMapping(value = "/getDimensionsAttendanceCountMap")
    public Map<String, List<DateDimensionsRangeVo>> getDimensionsAttendanceCountMap(@Valid @RequestBody DimensionsAttendanceCountDto dto) {
        return dayStaService.getDimensionsAttendanceCountMap(dto);
    }

    @Override
    @Operation(summary = "获取各维度出勤人数（天维度）")
    @PostMapping(value = "/getDimensionsAttendanceDayCountMap")
    public Map<String, Map<Date, Integer>> getDimensionsAttendanceDayCountMap(@Valid @RequestBody DimensionsAttendanceDayCountDto dto) {
        return dayStaService.getDimensionsAttendanceDayCountMap(dto);
    }

    @Operation(summary = "日度计薪统计-分页列表")
    @PostMapping(value = "/dayPayrollPageList")
    public ActionResult<PageListVO<DayPayrollStatisticsPageListVo>> dayPayrollPageList(@Valid @RequestBody DayPayrollStatisticsPageListDto req) {
        PageInfo<DayPayrollStatisticsPageListVo> page = dayStaService.getDayPayrollPageList(req);
        return ActionResult.page(page.getList(), FtbUtil.getPagination(page));
    }

    @Operation(summary = "月度计薪统计-分页列表")
    @PostMapping(value = "/monthPayrollPageList")
    public ActionResult<PageListVO<MonthPayrollStatisticsPageListVo>> monthPayrollPageList(@Valid @RequestBody MonthPayrollStatisticsPageListDto req) throws Exception {
        PageInfo<MonthPayrollStatisticsPageListVo> page = dayStaService.getMonthPayrollPageList(req);
        return ActionResult.page(page.getList(), FtbUtil.getPagination(page));
    }

    @Operation(summary = "考勤平均工时趋势-分页列表")
    @PostMapping(value = "/averageWorkHoursTrend/pageList")
    public ActionResult<PersonnelDataAnalysisListVO> averageWorkHoursTrendPageList(@Valid @RequestBody PersonnelApiInfoPageListDto dto) {
        PageListVO<AverageTrendPageListVo> result = dayStaService.averageWorkHoursTrendPageList(dto);
        return ActionResult.success(PersonnelDataAnalysisUtil.encapsulatePageData(result, AverageTrendPageListVo.class));
    }

    @Operation(summary = "考勤平均工时趋势-导出")
    @PostMapping(value = "/averageWorkHoursTrend/export")
    public void averageWorkHoursTrendExport(HttpServletResponse response, @Valid @RequestBody PersonnelApiInfoPageListDto pageDto) throws Exception {
        dayStaService.averageWorkHoursTrendExport(response, pageDto);
    }

    @Operation(summary = "人均工时趋势-分页列表")
    @PostMapping(value = "/personWorkHoursTrend/pageList")
    public ActionResult<PersonnelDataAnalysisListVO> personWorkHoursTrendPageList(@Valid @RequestBody PersonnelApiInfoSinglePageListDto pageDto) {
        PageListVO<PersonnelTrendPageListVo> result = dayStaService.personWorkHoursTrendPageList(pageDto);
        return ActionResult.success(PersonnelDataAnalysisUtil.encapsulatePageData(result, PersonnelTrendPageListVo.class));
    }

    @Operation(summary = "人均工时趋势-导出")
    @PostMapping(value = "/personWorkHoursTrend/export")
    public void personWorkHoursTrendExport(HttpServletResponse response, @Valid @RequestBody PersonnelApiInfoSinglePageListDto pageDto) throws Exception {
        dayStaService.personWorkHoursTrendExport(response, pageDto);
    }

    @Operation(summary = "考勤组日常情况-分页列表")
    @PostMapping(value = "/dailySituation/pageList")
    public ActionResult<PersonnelDataAnalysisListVO> dailySituationPageList(@Valid @RequestBody PersonnelApiInfoSinglePageListDto pageDto) {
        PageListVO<DailySituationPageListVo> result = dayStaService.dailySituationPageList(pageDto);
        return ActionResult.success(PersonnelDataAnalysisUtil.encapsulatePageData(result, DailySituationPageListVo.class));
    }

    @Operation(summary = "考勤组日常情况-导出")
    @PostMapping(value = "/dailySituation/export")
    public void dailySituationExport(HttpServletResponse response, @Valid @RequestBody PersonnelApiInfoSinglePageListDto pageDto) throws Exception {
        dayStaService.dailySituationExport(response, pageDto);
    }

    @Operation(summary = "考勤工时排行-分页列表")
    @PostMapping(value = "/workHoursRanking/pageList")
    public ActionResult<PersonnelDataAnalysisListVO> workHoursRankingPageList(@Valid @RequestBody PersonnelApiInfoSinglePageListDto pageDto) {
        PageListVO<WorkHoursRankingPageListVo> result = dayStaService.workHoursRankingPageList(pageDto);
        return ActionResult.success(PersonnelDataAnalysisUtil.encapsulatePageData(result, WorkHoursRankingPageListVo.class));
    }

    @Operation(summary = "考勤工时排行-导出")
    @PostMapping(value = "/workHoursRanking/export")
    public void workHoursRankingExport(HttpServletResponse response, @Valid @RequestBody PersonnelApiInfoSinglePageListDto pageDto) throws Exception {
        dayStaService.workHoursRankingExport(response, pageDto);
    }

    @Operation(summary = "考勤组全勤情况-分页列表")
    @PostMapping(value = "/fullAttendanceStatus/pageList")
    public ActionResult<PersonnelDataAnalysisListVO> fullAttendanceStatusPageList(@Valid @RequestBody PersonnelApiInfoSinglePageListDto pageDto) {
        PageListVO<FullAttendanceStatusPageListVo> result = dayStaService.fullAttendanceStatusPageList(pageDto);
        return ActionResult.success(PersonnelDataAnalysisUtil.encapsulatePageData(result, FullAttendanceStatusPageListVo.class));
    }

    @Operation(summary = "考勤组全勤情况-导出")
    @PostMapping(value = "/fullAttendanceStatus/export")
    public void fullAttendanceStatusExport(HttpServletResponse response, @Valid @RequestBody PersonnelApiInfoSinglePageListDto pageDto) throws Exception {
        dayStaService.fullAttendanceStatusExport(response, pageDto);
    }

    @Operation(summary = "考勤异常情况-分页列表")
    @PostMapping(value = "/exceptionSituation/pageList")
    public ActionResult<PersonnelDataAnalysisListVO> exceptionSituationPageList(@Valid @RequestBody PersonnelApiInfoSinglePageListDto pageDto) {
        PageListVO<ExceptionSituationPageListVo> result = dayStaService.exceptionSituationPageList(pageDto);
        return ActionResult.success(PersonnelDataAnalysisUtil.encapsulatePageData(result, ExceptionSituationPageListVo.class));
    }

    @Operation(summary = "考勤异常情况-导出")
    @PostMapping(value = "/exceptionSituation/export")
    public void exceptionSituationExport(HttpServletResponse response, @Valid @RequestBody PersonnelApiInfoSinglePageListDto pageDto) throws Exception {
        dayStaService.exceptionSituationExport(response, pageDto);
    }

    @Operation(summary = "考勤组加班情况-分页列表")
    @PostMapping(value = "/overtimeSituation/pageList")
    public ActionResult<PersonnelDataAnalysisListVO> overtimeSituationPageList(@Valid @RequestBody PersonnelApiInfoSinglePageListDto pageDto) {
        PageListVO<OvertimeSituationPageListVo> result = dayStaService.overtimeSituationPageList(pageDto);
        return ActionResult.success(PersonnelDataAnalysisUtil.encapsulatePageData(result, OvertimeSituationPageListVo.class));
    }

    @Operation(summary = "考勤组加班情况-导出")
    @PostMapping(value = "/overtimeSituation/export")
    public void overtimeSituationExport(HttpServletResponse response, @Valid @RequestBody PersonnelApiInfoSinglePageListDto pageDto) throws Exception {
        dayStaService.overtimeSituationExport(response, pageDto);
    }

    @Operation(summary = "查询用户考勤统计信息")
    @PostMapping(value = "/queryUserStatisticsInfo")
    @FtbCheckPermission("attendance_2.0.statistics.monthlyStatistics")
    public ActionResult<QueryStatisticsInfoVo> queryUserStatisticsInfo(@Valid @RequestBody QueryStatisticsInfoDto dto) {
        return ActionResult.success(dayStaService.queryUserStatisticsInfo(dto));
    }

    @Operation(summary = "查询考勤组的考勤情况")
    @PostMapping(value = "/queryGroupStatistics")
    @FtbCheckPermission("attendance_2.0.statistics.monthlyStatistics")
    public ActionResult<QueryGroupStatisticsVo> queryGroupStatistics(@Valid @RequestBody QueryGroupStatisticsDto dto) {
        return ActionResult.success(dayStaService.queryGroupStatistics(dto));
    }

    @Operation(summary = "查询用户的加班情况")
    @PostMapping(value = "/queryUserOvertime")
    @FtbCheckPermission("attendance_2.0.statistics.monthlyStatistics")
    public ActionResult<QueryUserOvertimeVo> queryUserOvertime(@Valid @RequestBody QueryStatisticsInfoDto dto) {
        return ActionResult.success(dayStaService.queryUserOvertime(dto));
    }

    @Operation(summary = "查询用户的上班情况")
    @PostMapping(value = "/queryUserWorkSituation")
    public ActionResult<Map<String, UserWorkSituationVo>> queryUserWorkSituation(@Valid @RequestBody UserWorkSituationDto dto) {
        return ActionResult.success(dayStaService.queryUserWorkSituation(dto));
    }

}
