package cn.wisenergy.mapper;

import cn.wisenergy.model.app.WorkTimeOrder;
import cn.wisenergy.model.dto.DayWorkTimeAndType;
import cn.wisenergy.model.dto.MonthlyWorkingHoursStatistics;
import cn.wisenergy.model.dto.WorkTimeAndCostCollect;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author chenqi
 * @since 2021-01-19
 */
public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> {


    /**
     * 功能：获取某个月的数据
     * @param userId
     * @param workMonth
     * @return
     */
    List<WorkTimeOrder> geByMonth(@Param("userId")Integer userId,@Param("workMonth") Date workMonth ,@Param("status")Integer status);

    List<WorkTimeOrder> getByDay(@Param("userId") Integer userId,@Param("workDay") Date workDay);

    int save(WorkTimeOrder workTimeOrder);

    int updateByIds(@Param("reviewerId") Integer reviewerId, @Param("ids") List<Integer> ids);

    int updateStatusById(@Param("reviewerId") Integer reviewerId,@Param("id") Integer id,@Param("reason") String reason);

    List<WorkTimeOrder> queryByPage(@Param("status") Integer status, @Param("projectId")Integer projectId, @Param("type")Integer type,@Param("deptId") Integer deptId);

    /**
     * 根据填报项目类型获取次数和工时汇总
     *
     * @param userId
     * @return
     */
    List<MonthlyWorkingHoursStatistics> statisticsByProjectType(@Param("userId") Integer userId, @Param("currentMonthFirstDay") Date currentMonthFirstDay);

    /**
     * 获取用户在某月的工时、工时类型、工单日期
     *
     * @param year
     * @param month
     * @param userIds
     * @return
     */
    List<DayWorkTimeAndType> listByDateAndUserId(@Param("year") Integer year, @Param("month") Integer month, @Param("userIds") List<Integer> userIds);


    /**
     * 根据条件获取大于某时间的工单数量
     *
     * @param map
     * @return
     */
    Integer getCountByCondition(Map<String, Object> map);

    List<WorkTimeAndCostCollect> getWorkTimeAndCostCollect(@Param("projectIds") List<Integer> projectIds, @Param("firstDayOfMonth") String firstDayOfMonth);

    /**
     * 获取上班日期集合
     * @param firstDayOfMonth
     * @return
     */
    List<Date> getDaysByDateAndStatus(@Param("firstDayOfMonth") Date firstDayOfMonth,@Param("userId") Integer userId);


    List<WorkTimeOrder> getAutoOrder(Integer autoExamine);

    int updateAutoExamine(@Param("workIds") List<Integer> workIds);

}
