package com.casic.missiles.modular.system.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.casic.missiles.modular.system.dto.SelectDto;
import com.casic.missiles.modular.system.dto.UserClientView;
import com.casic.missiles.modular.system.model.AlarmJob;
import com.casic.missiles.core.datascope.DataScope;
import org.apache.ibatis.annotations.Param;

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

/**
 * <p>
 * 报警工单表 Mapper 接口
 * </p>
 *
 * @author casic123
 * @since 2019-05-17
 */
public interface AlarmJobMapper extends BaseMapper<AlarmJob> {
    List<Map<String,Object>> jobList(@Param("page") Page<Map<String,Object>> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent, @Param("dataScope") DataScope dataScope,@Param("userId")Long userId);
    List<Map<String,Object>> jobListApp(@Param("page") Page<Map<String,Object>> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId);
    // List<AlarmJob> jobListExport(@Param("page") Page<AlarmJob> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("jobStatus") String jobStatus, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope);
    List<Map<String,Object>> jobListDelayRe(@Param("page") Page<Map<String,Object>> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope,@Param("userId")Long userId);
    List<Map<String,Object>> jobListDelayReApp(@Param("page") Page<Map<String,Object>> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId);

    List<Map<String,Object>> jobListDelayPro(@Param("page") Page<Map<String,Object>> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("dataScope") DataScope dataScope,@Param("userId")Long userId);
    List<Map<String,Object>> jobListDelayProApp(@Param("page") Page<Map<String,Object>> page, @Param("keywords") String keywords, @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("alarmType") String alarmType, @Param("alarmContent") String alarmContent,@Param("deptId")Long deptId,@Param("userId")Long userId,@Param("leaderId")Long leaderId);

    List<Map<String,Object>> jobListSearchApp(@Param("page") Page<Map<String,Object>> page, @Param("keywords") String keywords, @Param("alarmLevel")String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime,
                                    @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime,
                                    @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime,
                                    @Param("deptId")Long deptId, @Param("userId")Long userId, @Param("leaderId")Long leaderId);
    List<Map<String,Object>> jobListSearch(@Param("page") Page<Map<String,Object>> page, @Param("keywords") String keywords, @Param("alarmLevel")String alarmLevel, @Param("alarmContent") String alarmContent, @Param("jobStatus") String jobStatus, @Param("beginTime") String beginTime, @Param("endTime") String endTime,
                                           @Param("getJobBeginTime") String getJobBeginTime, @Param("getJobEndTime") String getJobEndTime, @Param("shouldGetBeginTime") String shouldGetBeginTime, @Param("shouldGetEndTime") String shouldGetEndTime,
                                           @Param("handleJobBeginTime") String handleJobBeginTime, @Param("handleJobEndTime") String handleJobEndTime, @Param("shouldHandleBeginTime") String shouldHandleBeginTime, @Param("shouldHandleEndTime") String shouldHandleEndTime,
                                           @Param("dataScope") DataScope dataScope,@Param("userId")Long userId);

    Map<String,Object> countByJobStatus(@Param("deptId")long deptId,@Param("spanDays") int spanDays);
    Map<String,Object> countMyJob(@Param("userId")long userId,@Param("deptId")long deptId,@Param("spanDays") int spanDays);
    List<Map<String,Object>> jobInfo(@Param("id") int id,@Param("dataScope") DataScope dataScope,@Param("personId") Long personId);
//    boolean getJob(@Param("id") int id,@Param("personId") long personId);
    boolean getJob(@Param("id") int id,@Param("personId") long personId,@Param("getTime")Date getTime ,@Param("shouldHandleTime")Date shouldHandleTime);
    boolean confirmJob(@Param("id") int id,@Param("personId") long personId,@Param("firstState") String firstState,@Param("firstStatePhotos") String firstStatePhotos,@Param("needHandle") String needHandle);
    boolean confirmOverJobAndAlarm(@Param("id") int id,@Param("personId") long personId,@Param("firstState") String firstState,@Param("firstStatePhotos") String firstStatePhotos);
    boolean transferJob(@Param("id") int id,@Param("transferPerson") long transferPerson,@Param("flowRec") String flowRec);
    boolean saveJob(@Param("id") int id,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos);
    boolean overJob(@Param("id") int id,@Param("personId") long personId,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos);
    boolean overAlarm(@Param("jobId") int id);
    boolean overJobAndAlarm(@Param("id") int id,@Param("personId") long personId,@Param("handleMessage") String handleMessage,@Param("handlePhotos") String handlePhotos);
    boolean handleJob(@Param("id") int id,@Param("personId") long personId);

    List<Map<String,Object>> countByDataScope(@Param("dataScope") DataScope dataScope,@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("beginTime")String beginTime,@Param("endTime")String endTime);
    Integer countByResponse(@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("deptId") Long deptId,@Param("beginTime")String beginTime,@Param("endTime")String endTime);
    Integer countByUser(@Param("alarmType")String alarmType,@Param("jobStatus")String jobStatus,@Param("userId") Long userId,@Param("beginTime")String beginTime,@Param("endTime")String endTime);

    String selectClientIdByUser(@Param("userId") Long userId);
    List<UserClientView> selectUserByWellCode(@Param("wellCode") String wellCode);
    List<Long> selectUseIds(@Param("roleIds") List<Long> roleIds);
    List<SelectDto> selectRoles();
}
