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.UserWorkTimeStatisticsByProject;
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")List<Integer>  status, @Param("projectIds") List<Integer> projectIds, @Param("types") List<Integer> types, @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);

    /**
     * 获取项目或商机的成本
     *
     * @param map
     * @return
     */
    List<WorkTimeAndCostCollect> getWorkTimeAndCostCollect(Map<String, Object> map);

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


    List<WorkTimeOrder> getAutoOrder(Integer autoExamine);

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

    /**
     * 获取人员项目工时
     */
    List<UserWorkTimeStatisticsByProject> getUserProjectWorkTimeStatistics(Map<String, Object> map);

    /**
     * 根据工单状态获取填报条数
     *
     * @param userId
     * @param firstDayOfMonth
     * @param status
     * @return
     */
    List<MonthlyWorkingHoursStatistics> selectCountByTypeAndStatus(@Param("userId") Integer userId, @Param("firstDayOfMonth") Date firstDayOfMonth, @Param("status") Integer[] status);


    List<UserWorkTimeStatisticsByProject> selectListByType(Map<String,Object> map);
}
