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> {


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

    int save(WorkTimeOrder workTimeOrder);

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

    int updateStatusById(Integer reviewerId, Integer id, String reason);

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

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

    /**
     * @param year
     * @param month
     * @param userId
     * @return
     */
    List<DayWorkTimeAndType> listByDateAndUserId(@Param("year") Integer year, @Param("month") Integer month, @Param("userId") Integer userId);


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

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

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