package com.ruoyi.ibs.task.mapper;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.ibs.task.domain.dto.WorkRecordDTO;
import com.ruoyi.ibs.task.domain.entity.Alter;
import com.ruoyi.ibs.task.domain.entity.WorkRecord;
import com.ruoyi.ibs.task.domain.vo.AlterVO;
import com.ruoyi.ibs.task.domain.vo.WorkCompleteVO;
import com.ruoyi.ibs.task.domain.vo.WorkRecordVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 工作清单记录Mapper接口
 * 
 * @author ruoyi
 * @date 2025-10-11
 */
@Mapper
public interface WorkRecordMapper extends BaseMapper<WorkRecord> {

    /**
     * 查询我的工作清单记录列表
     * 
     * @param workRecordDTO,username 工作清单记录
     * @return 工作清单记录集合
     */
    List<WorkRecordVO> selectWorkRecordList(@Param("dto") WorkRecordDTO workRecordDTO, @Param("username") String username);

    /**
     * 修改工作清单记录
     * 
     * @param workRecordList 工作清单记录
     * @return 结果
     */
    int batchSubmitWorkRecord(@Param("list") List<WorkRecord> workRecordList);

    /**
     * 查询工作清单完成情况
     *
     * @param workRecordDTO 工作清单记录主键
     * @return 工作清单记录
     */
    List<WorkCompleteVO> selectCompleteStatus(@Param("dto") WorkRecordDTO workRecordDTO, @Param("postIds") List<Long> postIds);

    /**
     * 查询需要生成工作清单的记录
     * @param frequencyType
     * @param startTime
     * @param endTime
     * @return
     */
    List<WorkRecord> selectRecordsToGenerate(@Param("frequencyType") String frequencyType, @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    /**
     * 批量插入工作清单记录
     *
     * @param workRecordList 工作清单记录
     * @return 结果
     */
    int batchInsertWorkRecord(@Param("workRecordList") List<WorkRecord> workRecordList);

    /**
     * 查询预警信息
     *
     * @param alterType 预警类型
     * @return 预警信息
     */
    List<AlterVO> selectAlterList(@Param("username") String username, @Param("status") String status, @Param("alterType") String alterType);

    int updateOverdueRecord(@Param("now") LocalDateTime now);

    int updateReadTime(@Param(("isAlter")) Integer isAlter, @Param("username") String username);

    int updateAlter(Alter alter);

    List<String> selectAlterTypesByHeadId(String headId);

    int updateReadTimeById(@Param("id") Long id, @Param("username") String username);

    int updateAlterByRole(@Param("alterType") String alterType, @Param("username") String username);
}
